refactor(ipc): drop this.-qualifier and trim BuildState comments

Same shadowing-via-instance-property as Plugin.CurrentTab above. Comments
trimmed to default 1-3 line density; security/threading WHY-blocks earn
their lines when they document non-obvious invariants, not standard C#
name resolution.
This commit is contained in:
2026-05-26 14:04:46 +02:00
parent 93bfd408bc
commit 7979568165
+6 -23
View File
@@ -70,30 +70,13 @@ internal sealed class TypingIpc : IDisposable
: usedChannel.Channel; : usedChannel.Channel;
var channelType = inputChannel.ToChatType(); var channelType = inputChannel.ToChatType();
// `Plugin` here is the instance property on TypingIpc (TypingIpc.cs:18 // MainWindow is Phase-1-resolved and never reassigned;
// `private Plugin Plugin { get; }`), NOT the type `HellionChat.Plugin`. // the `?.` is defense-in-depth for pre-Phase-1 IPC-pulls.
// C# resolves `Plugin.MainWindow` as `this.Plugin.MainWindow` because var mainWindowOpen = Plugin.MainWindow?.IsOpen ?? false;
// the instance property shadows the type name inside this class. Do
// NOT switch to a type-qualified read (CS0120 — `MainWindow` is an
// instance member, not a static one). MainWindow is resolved in Phase-1
// (Plugin.cs:295) and never re-assigned, so `this.Plugin.MainWindow`
// is non-null by the time TypingIpc.Update() runs (HostedServices only
// start after Phase-1). The `null!`-suppression on the MainWindow
// property would let us drop the `?.`, but a null-safe read costs
// nothing at runtime and shields against a theoretical pre-Phase-1
// caller (a future IPC-pull that fires before HostedServices start).
// Defense in depth, no behaviour change for the production path.
var mainWindowOpen = this.Plugin.MainWindow?.IsOpen ?? false;
// Stale-state guard: InputBar._isFocused is only written in DrawInputField, // Stale-state guard: InputBar's focus and pending-buffer fields are
// which only runs while MainWindow is open. After the user closes the // only written by DrawInputField. Closing MainWindow freezes them, so
// window, _isFocused freezes on the last value. _pendingMessage has the // gate all four state fields on mainWindowOpen.
// same stale problem — it is only cleared in TrySend (successful send)
// or ClearBuffer (manual reset), so closing MainWindow with non-empty
// buffer leaves PendingLength frozen above zero. Without gating all
// four state fields on mainWindowOpen, Cross-Plugin-Subscribers would
// keep seeing InputFocused: true / HasText: true / IsTyping: true /
// TextLength: N even though no input field exists.
var inputFocused = mainWindowOpen && _inputBar.IsFocused; var inputFocused = mainWindowOpen && _inputBar.IsFocused;
var hasText = mainWindowOpen && _inputBar.PendingLength > 0; var hasText = mainWindowOpen && _inputBar.PendingLength > 0;
var textLength = mainWindowOpen ? _inputBar.PendingLength : 0; var textLength = mainWindowOpen ? _inputBar.PendingLength : 0;