chore(polish): cycle-end sweep — drop dead fields, dep-cycle, comments

Accumulated polish across the v1.7.1 R-Block reviewer findings. Single
sweep before Phase-3 Smoke-Gate.

Dep-cycle cleanup (Block H + #30):
- CommandHelpWindow drops the dead _inputBar ctor-param + discard that
  was J's speculative prep; this eliminates the InputBar <-> CommandHelpWindow
  ctor cycle at its root
- InputBar replaces Lazy<CommandHelpWindow> wrapper with direct
  CommandHelpWindow ctor-param now that the cycle is broken
- PluginHostFactory InputBar + CommandHelpWindow DI-regs simplified

Dead-field removals:
- MessageList drops _themes + _resolver (no reads after H's render-path
  swap to _chunkRenderer.DrawChunks)
- InputBar drops FocusedPreview (no consumer wiring in the new architecture)
- InputPreview drops SelectedCursorPos (v1.5.6 letter-by-letter renderer
  artifact, no callers in R1)
- InputPreview drops WhitespaceRegex + partial keyword on class (dead
  GeneratedRegex with no callers)

Visibility fixes:
- InputPreview + CommandHelpWindow + DebuggerWindow ctors flip
  public -> internal for consistency with internal sealed class declarations

DI helper extraction:
- PluginHostFactory MakePayloadHandler private static helper DRYs the
  7-arg list shared between PayloadHandler-singleton and Lender<T> factory

ImGui-rendering fix:
- MessageList.DrawCompactRow uses SameLine(0f, 0f) — eliminates visible
  ItemSpacing.X gap between sender-prefix and chunk content

Bug fixes:
- PayloadHandler.LeftClickPayload drops spurious unsafe keyword (no
  pointer ops in the method body; v1.5.6 had no unsafe here)
- PayloadHandler.StringifyMessage Aggregate seeded with string.Empty to
  fix empty-sequence crash for pure-icon messages
- PayloadHandler.MoveTooltip args==null LogWarning template simplified
  (?.GetType().Name was always null after the null-check — misleading)
- InputBar.SlashCommandCallback drops redundant BufTextLen==0 guard
  (BufTextSpan handles empty correctly)

Comment improvements (WHY-not-WHAT):
- ImGuiUtil.cs payload-state cluster comment moved below Buttons array
- PayloadHandler: §6.9 trimmed to 1 line, FindCharacterForPayload
  documented, hq symbol marker restored, MoveTooltip guard documented
  as defensive v1.7.1 addition, NativeItemTooltips branch explained,
  §4.2 theme colour swap explained
- DebuggerWindow class comment mentions PayloadHandler counters section
- InitHostedServices StopAsync explains params-overload semantics
- InputBar AppendPending null policy vs SetPendingMessage documented,
  CommandManager leading-slash assumption noted
- PluginHostFactory block comment explains singleton+Lender split

Build: 0 warnings, 0 errors. csharpier: clean. Version unchanged.
This commit is contained in:
2026-05-27 23:42:28 +02:00
parent d1bfddd9b8
commit f6749d206b
9 changed files with 47 additions and 76 deletions
+8 -9
View File
@@ -33,14 +33,13 @@ internal sealed class InputBar
private readonly TokenResolver _resolver;
private readonly ILogger<InputBar> _logger;
private readonly Action _onOpenSettings;
private readonly Lazy<CommandHelpWindow> _commandHelpWindow;
private readonly CommandHelpWindow _commandHelpWindow;
private string _pendingMessage = string.Empty;
private bool _isFocused;
private bool? _isFocusedOverride; // Test-only; null = honour per-frame Draw() value.
public bool Activate;
public bool FocusedPreview;
public InputBar(
SymbolPicker symbolPicker,
@@ -49,7 +48,7 @@ internal sealed class InputBar
TokenResolver resolver,
ILogger<InputBar> logger,
Action onOpenSettings,
Lazy<CommandHelpWindow> commandHelpWindow
CommandHelpWindow commandHelpWindow
)
{
_symbolPicker = symbolPicker;
@@ -99,6 +98,7 @@ internal sealed class InputBar
}
}
// Null treated as empty here (matches IsNullOrEmpty guard); contrast with SetPendingMessage which throws to surface PayloadHandler call-site bugs early.
public void AppendPending(string suffix)
{
if (string.IsNullOrEmpty(suffix))
@@ -231,7 +231,7 @@ internal sealed class InputBar
)
)
{
_commandHelpWindow.Value.IsOpen = false;
_commandHelpWindow.IsOpen = false;
TrySend(activeTab);
}
_isFocused = ImGui.IsItemFocused();
@@ -241,9 +241,7 @@ internal sealed class InputBar
// stays in sync with what the user is typing without a per-frame poll.
private int SlashCommandCallback(scoped ref ImGuiInputTextCallbackData data)
{
_commandHelpWindow.Value.IsOpen = false;
if (data.BufTextLen == 0)
return 0;
_commandHelpWindow.IsOpen = false;
var text = Encoding.UTF8.GetString(data.BufTextSpan);
if (!text.StartsWith('/'))
@@ -252,12 +250,13 @@ internal sealed class InputBar
var spaceIdx = text.IndexOf(' ');
var command = spaceIdx > 0 ? text[..spaceIdx] : text;
// Keys in CommandManager.Commands include the leading slash.
if (AllCommands.TryGetValue(command, out var textCommand))
_commandHelpWindow.Value.UpdateContent(textCommand.Description);
_commandHelpWindow.UpdateContent(textCommand.Description);
else if (
Plugin.CommandManager.Commands.TryGetValue(command, out var info) && info.ShowInHelp
)
_commandHelpWindow.Value.UpdateContent(info.HelpMessage);
_commandHelpWindow.UpdateContent(info.HelpMessage);
return 0;
}