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(