From 0d4f359329d4e9049a7605aabc76f4bf1031a9d2 Mon Sep 17 00:00:00 2001 From: Norton Andreev Date: Mon, 14 Sep 2026 20:12:53 +0600 Subject: [PATCH 1/2] Show one live question as a row in the chat --- src/Capacitor.App/App.axaml | 13 +- .../Services/PendingPermissionRequest.cs | 21 +++ .../Services/PermissionService.cs | 25 ++++ src/Capacitor.App/ViewModels/ChatItems.cs | 16 ++- .../ViewModels/ChatTabViewModel.cs | 39 +++++- src/Capacitor.App/Views/ChatTabView.axaml | 53 ++++---- src/Capacitor.App/Views/ChatTabView.axaml.cs | 12 ++ .../Views/PendingCardTemplates.axaml | 31 +++-- .../ChatTabViewModelTests.cs | 65 +++++++++ .../ChatTabViewSmokeTests.cs | 126 ++++++++++++++++-- .../PermissionServiceTests.cs | 91 +++++++++++++ 11 files changed, 443 insertions(+), 49 deletions(-) diff --git a/src/Capacitor.App/App.axaml b/src/Capacitor.App/App.axaml index 90d834ceb..fa1da5c7d 100644 --- a/src/Capacitor.App/App.axaml +++ b/src/Capacitor.App/App.axaml @@ -76,9 +76,15 @@ ring and fill would read as a second box. Fluent's default placeholder follows the system theme and goes near-black on our dark surfaces — pin a readable muted tone. --> - @@ -378,6 +384,11 @@ + + + + + + @@ -76,7 +90,8 @@ - @@ -85,8 +100,6 @@ Plain text (no chip chrome) so it lines up with the detail. --> + + + + + + + + + @@ -139,22 +162,7 @@ VerticalAlignment="Center" /> - - - - - - - - - - - - - - - - @@ -180,15 +188,14 @@ - + MinHeight="38" MaxHeight="160" PlaceholderText="Write a message" IsVisible="{Binding ShowsComposer}" /> _readerGesture = false, DispatcherPriority.Background); @@ -78,11 +81,20 @@ void OnReaderGesture(object? sender, RoutedEventArgs e) { void OnScrollChanged(object? sender, ScrollChangedEventArgs e) { if (sender is not ScrollViewer scroll) return; + if (ListTextBoxOwnsFocus()) return; var atBottom = scroll.Offset.Y + scroll.Viewport.Height >= scroll.Extent.Height - BottomTolerance; _followTail = _readerGesture ? atBottom : _followTail || atBottom; if (_followTail && !atBottom) scroll.ScrollToEnd(); } + static bool OriginatesFromTextBox(RoutedEventArgs e) => + e.Source is Visual visual && (visual is TextBox || visual.GetVisualAncestors().OfType().Any()); + + bool ListTextBoxOwnsFocus() { + if (TopLevel.GetTopLevel(this)?.FocusManager?.GetFocusedElement() is not TextBox box) return false; + return box.GetVisualAncestors().OfType().Any(c => ReferenceEquals(c, ChatItems)); + } + /// The composer wraps, so the rendered rows, not the newlines, say whether the caret has a row /// above or below it; the newline count stands in only before the box has a text presenter. (int Line, int Lines) ComposerCaretLine() { diff --git a/src/Capacitor.App/Views/PendingCardTemplates.axaml b/src/Capacitor.App/Views/PendingCardTemplates.axaml index b0b30797a..6eb9132a4 100644 --- a/src/Capacitor.App/Views/PendingCardTemplates.axaml +++ b/src/Capacitor.App/Views/PendingCardTemplates.axaml @@ -4,7 +4,7 @@ - @@ -33,9 +33,17 @@ - + @@ -131,13 +139,8 @@ - - - - + + @@ -169,8 +172,8 @@ IsVisible="{Binding ShowsOtherAnswer}" Margin="6,0,0,0" Padding="12,5" FontSize="13" CornerRadius="7" Classes="kcapPrimary" Background="{StaticResource KcapPrimaryBrush}" Foreground="{StaticResource KcapOnPrimaryBrush}" /> - + @@ -224,7 +227,7 @@