Skip to content

feat(close): warn before closing sessions that are still running - #191

Merged
mortenaslo merged 3 commits into
mainfrom
feat/close-warning-busy-sessions
Nov 6, 2026
Merged

mortenaslo merged 3 commits into
mainfrom
feat/close-warning-busy-sessions

Conversation

@mortenaslo

Copy link
Copy Markdown
Contributor

What

Closing the app — or closing sessions with Ctrl+W, the sidebar/toolbar ✕, Close (N) or either Close all… — while something is still running now lists the busy sessions (accent, name, why) and asks. Keep running is the default for Enter and Esc; closing needs a click on Close anyway. Same look as the shutdown board, as an owned dialog (an overlay can't be drawn over the WebView2 panes without collapsing the grid).

Busy (Services/SessionBusyRules, WPF-free, unit-tested):

  • OSC 7501 sessions: working (+progress) or blocked mid-turn — judged by the report only
  • other sessions: PTY output within the last 4s (SessionViewModel.NoteOutput, lock-free)
  • any session with a running run command

"Close all…" asks one question: the busy dialog when something is busy, otherwise its old Yes/No. Worktree removal keeps its own confirmation.

Off via Settings (Warn before closing sessions that are still running) or the dialog's "Don't warn me again". Never shown when Windows is logging off.

Tests

  • SessionBusyRulesTests (15)
  • UI CloseWarningTests: a ping -t session; pane ✕ → Keep running keeps it; app close → Keep running keeps the app; Close anyway exits. AppActions.CloseFirstSession confirms the dialog when a test session is still printing; AppFixture kills a process left asking.
  • Full suites green: 1170 unit, 11 UI (run on a locked screen)

Not yet checked by hand

Closing a Claude session mid-prompt with Ctrl+W in the real app.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NsYm9iLc2aRnRDfV2uZRQX

mortenaslo and others added 3 commits November 6, 2026 19:58
…ning

Closing the window while a session is busy now lists those sessions (accent,
name, why) and asks; "Keep running" is the default for Enter and Esc.

Busy (Services/SessionBusyRules, WPF-free, unit-tested):
- OSC 7501 sessions: working (+progress) or blocked mid-turn
- other sessions: PTY output within the last 4s
- any session with a running run command

Skipped when the new WarnOnCloseWhenBusy setting is off (Settings, or the
dialog's "Don't warn me again") and when Windows is logging off.
UI test CloseWarningTests drives both answers with a `ping -t` session.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NsYm9iLc2aRnRDfV2uZRQX
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NsYm9iLc2aRnRDfV2uZRQX
… menus too

Ctrl+W, the sidebar and toolbar ✕, the per-session "Close (N)" menu and both
"Close all…" items now go through RequestCloseSession(s) → ConfirmCloseBusy,
the same check and dialog as app close. "Close all…" asks one question: the
busy dialog when something is busy, else its old Yes/No. Worktree removal
keeps calling CloseCommand directly (it has its own confirmation).

UI test also checks the pane ✕; CloseFirstSession confirms the dialog when a
test session is still printing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NsYm9iLc2aRnRDfV2uZRQX
@mortenaslo
mortenaslo merged commit c66cd01 into main Nov 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant