From 9756871d8093cbc99685a8ddb1bade1151e0a77e Mon Sep 17 00:00:00 2001 From: Norton Andreev Date: Thu, 22 Oct 2026 20:36:07 +0300 Subject: [PATCH 1/2] Restrict desktop Escape interruption to confirmed foreground work --- .../ViewModels/ChatTabViewModel.cs | 11 +++ src/Capacitor.App/Views/ChatTabView.axaml | 2 +- src/Capacitor.App/Views/ChatTabView.axaml.cs | 8 +- .../ChatTabViewSmokeTests.cs | 95 +++++++++++++++++++ .../RemoteSessionViewSmokeTests.cs | 17 ++-- 5 files changed, 118 insertions(+), 15 deletions(-) diff --git a/src/Capacitor.App/ViewModels/ChatTabViewModel.cs b/src/Capacitor.App/ViewModels/ChatTabViewModel.cs index 4215e7777..4798d526b 100644 --- a/src/Capacitor.App/ViewModels/ChatTabViewModel.cs +++ b/src/Capacitor.App/ViewModels/ChatTabViewModel.cs @@ -434,6 +434,12 @@ public IReadOnlyList TerminalMenuChoices { readonly ObservableAsPropertyHelper _showsInterrupt; public bool ShowsInterrupt => _showsInterrupt.Value; + // Running alone, or background work while the parent waits, does not make Escape safe at its prompt. + public bool CanInterruptWithEscape => ShowsInterrupt && _awaitingInput == false; + + readonly ObservableAsPropertyHelper _interruptLabel; + public string InterruptLabel => _interruptLabel.Value; + string _vendor = ""; IReadOnlyList _options = HostedHarnessCatalog.Build(null); @@ -748,6 +754,11 @@ public ChatTabViewModel( && (AgentStatus.Kind == AgentStatusKind.Working || AgentStatus.IsRunningUnknownTurn)) .DisposeWith(_disposables); + _interruptLabel = this.WhenAnyValue(x => x.ShowsInterrupt, x => x.AgentStatus, + (_, _) => CanInterruptWithEscape ? "Interrupt (Esc)" : "Interrupt") + .ToProperty(this, x => x.InterruptLabel, initialValue: "Interrupt") + .DisposeWith(_disposables); + // The banner carries the read-only explanation for a flow participant, so the hint // goes blank there instead of offering a reply that can never be sent. _composerHint = Observable.CombineLatest( diff --git a/src/Capacitor.App/Views/ChatTabView.axaml b/src/Capacitor.App/Views/ChatTabView.axaml index 4d9901e25..fc0b2a110 100644 --- a/src/Capacitor.App/Views/ChatTabView.axaml +++ b/src/Capacitor.App/Views/ChatTabView.axaml @@ -473,7 +473,7 @@ -