Skip to content

feat(tui): confirm before quitting stops every session - #700

Merged
mohitranka merged 1 commit into
mainfrom
feat/quit-all-sessions
Sep 15, 2026
Merged

mohitranka merged 1 commit into
mainfrom
feat/quit-all-sessions

Conversation

@mohitranka

Copy link
Copy Markdown
Contributor

What

Quitting Forge has always retired every session actor, so the sessions the operator is not looking at die with the one they are. Nothing said so: neither Ctrl+D nor /quit reported how many turns, queued prompts, pending approvals, or unsaved editor buffers went with them.

This adds one quit gate:

  • Ctrl+D, /quit on the primary session, and the exit after a resolved unsaved-changes dialog all route through it. /quit in any other session view stays a per-session close, so the confirm exists in exactly one place.
  • It prompts only when a second session has a turn Running or Queued. Quitting one busy session the operator is watching stays instant; prompting for it would put a dialog in front of every quit.
  • Two rows, Cancel selected first. The dialog names only the categories that lose something (running turns, queued prompts, requests waiting on the operator, unsaved buffers by session label) and escalates its border to danger once a session view holds unsaved changes.
  • Confirming sweeps the roster and exits either way. Failures travel out in ExitSummary::quit_failure and print after the terminal is restored, because a toast on the final frame is a report nobody reads.

Shutdown had the same shape wrong: it propagated the first retirement failure out of its loop, stranding every session after it behind an exit that claimed success. Both it and the new CloseAllSessions now attempt the whole roster and collect failures.

Findings worth knowing

  • In repository mode the primary session is a supervised actor, so /quit on it previously closed the primary session rather than exiting. That path now goes through the gate.
  • Shutdown calls retire_actor_resources with allow_pending_interaction: true, so a session parked on an approval or an agent question was retired anyway and the request silently discarded. The confirm's summary is now the only place that says so.
  • reconcile_running_prompt_claims already repairs a stale running row on the next launch, so a session cancelled mid-turn comes back Interrupted rather than ◐ working.

Tests

  • 6 TUI tests (app::tests::multi_task): the gate threshold, the default-Cancel keymap, /quit routing on the primary, the rendered loss lines, the end-to-end sweep, and the pure loss-line formatting.
  • 2 supervisor tests: the sweep closes every session including one mid-turn; and one that refuses to retire (held session lock) is reported per session, counted as 1 of 2, and does not strand the other.
  • cargo fmt --all -- --check and clippy clean on forge-tui, forge-session, forge-cli. Release build + forge --version verified.
  • cargo test -p forge-tui is 1343 passed / 5 failed and cargo test -p forge-session 78/1 on this host. All failures reproduce on a clean base revision — they are sandbox unavailable: this host refused to apply confinement background-task and watcher tests, not this change.

Deliberately not in scope

The double-Ctrl+C escalation stays ungated (documented in FORGE-DESIGN.md 9.15); /quit gains no all argument; nothing crosses the repository lease into another Forge process.

refs: FORGE-DESIGN.md 9.15

Quitting Forge has always retired every session actor, so the sessions the operator is not looking at die with the one they are. Nothing said so: neither Ctrl+D nor /quit reported how many turns, queued prompts, pending approvals or unsaved editor buffers went with them.

Ask first, and only when the answer is not obvious: quitting one busy session the operator is watching stays instant, while a second session with a turn running or queued raises a two-row confirm that defaults to Cancel and names what the quit would discard. It is the one gate for Ctrl+D, /quit on the primary session, and the exit that follows a resolved unsaved-changes dialog; /quit in any other session view stays a per-session close.

The sweep is a new CloseAllSessions command that attempts the whole roster, reports what refused per session, and returns a count, so the app can exit on either outcome with the failure travelling out in the exit summary. Shutdown had the same shape wrong: it propagated the first retirement failure out of its loop, stranding every session after it behind an exit that claimed success.

refs: FORGE-DESIGN.md 9.15
@mohitranka
mohitranka force-pushed the feat/quit-all-sessions branch from b9dd02b to 0151c50 Compare September 15, 2026 17:49
@mohitranka
mohitranka merged commit cabe06a into main Sep 15, 2026
3 checks passed
@mohitranka
mohitranka deleted the feat/quit-all-sessions branch September 15, 2026 17:56
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