From 01fc69efda5cd38ed265966d565975da1ec15777 Mon Sep 17 00:00:00 2001 From: Jon Kazama Date: Wed, 27 May 2026 07:59:39 +0200 Subject: [PATCH] feat(input-bar): add SetPendingMessage/AppendPending mutators + Activate/FocusedPreview flags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces v1.5.6's direct LogWindow.Chat mutation pattern with typed mutators that LogWarning + clip/drop on BufferCapacity overflow (silent-overwrite semantics preserved, but overflow is now observable via /xllog). Plumbing for v1.7.1 PayloadHandler resurrection — DrawPlayerPopup (tell- prefix) and DrawStatusPopup (status-link append) will call these mutators instead of mutating a public field. --- HellionChat/Ui/Components/InputBar.cs | 47 +++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/HellionChat/Ui/Components/InputBar.cs b/HellionChat/Ui/Components/InputBar.cs index eb4e7b3..95d65ca 100644 --- a/HellionChat/Ui/Components/InputBar.cs +++ b/HellionChat/Ui/Components/InputBar.cs @@ -36,6 +36,9 @@ internal sealed class InputBar private bool _isFocused; private bool? _isFocusedOverride; // Test-only; null = honour per-frame Draw() value. + public bool Activate; + public bool FocusedPreview; + public InputBar( SymbolPicker symbolPicker, FontManager fonts, @@ -69,6 +72,44 @@ internal sealed class InputBar public void ClearBuffer() => _pendingMessage = string.Empty; + // BufferCapacity is an ImGui UX limit, not a protocol constraint. We + // LogWarning + truncate/drop (matching v1.5.6's silent-overwrite semantics) + // so overflow is observable via /xllog without forcing try/catch at call-sites. + public void SetPendingMessage(string value) + { + if (value is null) + throw new ArgumentNullException(nameof(value)); + if (value.Length > BufferCapacity) + { + _logger.LogWarning( + "SetPendingMessage: value of length {Length} exceeds BufferCapacity ({Capacity}); truncating.", + value.Length, + BufferCapacity + ); + _pendingMessage = value[..BufferCapacity]; + } + else + { + _pendingMessage = value; + } + } + + public void AppendPending(string suffix) + { + if (string.IsNullOrEmpty(suffix)) + return; + if (_pendingMessage.Length + suffix.Length > BufferCapacity) + { + _logger.LogWarning( + "AppendPending: appending {SuffixLength} chars would exceed BufferCapacity ({Capacity}); dropping suffix.", + suffix.Length, + BufferCapacity + ); + return; + } + _pendingMessage += suffix; + } + public void Draw(Tab? activeTab) { if (!_fonts.FontsReady) @@ -168,6 +209,12 @@ internal sealed class InputBar private void DrawInputField(Tab? activeTab) { + if (Activate) + { + ImGui.SetKeyboardFocusHere(); + Activate = false; + } + ImGui.SetNextItemWidth(-QuickButtonsReserve); if ( ImGui.InputText(