Skip to content

fix(sessions): make remove, restart and undo recoverable - #311

Merged
maxthomas95 merged 1 commit into
mainfrom
fix/session-remove-restart-20261109
Nov 10, 2026
Merged

maxthomas95 merged 1 commit into
mainfrom
fix/session-remove-restart-20261109

Conversation

@maxthomas95

Copy link
Copy Markdown
Owner

Summary

Stacked on #308 (base branch fix/renderer-workflow-20261109); review and merge that one first. Renderer and docs only: no main-process, IPC or persistence changes.

Restart all

  • Each session's replacement is started first, takes over the original's panes and sidebar slot, and only then is the original removed. A session whose replacement cannot start is left as it was. This is the pattern Restart in this pane already used.
  • Sessions restart one at a time and each create is awaited. Before, every session was removed up front and the creates were fired without awaiting. The Vault login prompt has a single slot, so with an expired token only the last create resolved and the other sessions were gone, with nothing left to retry.
  • The toast reports the real outcome, for example "Restarted 3 of 4 sessions" with "1 failed: api (reason). They were left as they were." It used to announce success before any session had been created. A second Restart all on the same group is ignored while one is running.

Undo

  • Clear all → Undo restores sessions in turn through the same awaited path, and names anything it could not bring back, with a Retry action.
  • Removing a single ordinary session now shows the same Undo toast (8 s). Worktree sessions keep their confirmation dialog and get no Undo, since their directory may be removed with them.

Supporting changes

  • New layout action REPLACE_SESSION_ID swaps a session id wherever it is mounted, in both the split layout and Canvas, keeping pane ids and geometry.
  • handleCreateSession's Vault preflight + create moved into createSessionFromOptions, which returns created / cancelled / failed instead of reporting it, so a batch can summarize. handleCreateSession itself behaves as before, toasts included.
  • utils/session-batch.ts: runBatch (sequential; continues past a failure; a declined Vault login stops the batch and the rest are reported as not attempted) and summarizeBatch.

Test plan

  • npx tsc --noEmit
  • npx eslint on every touched file
  • npx vitest run — 202 files / 2345 tests pass; the one failure, src/main/usage/remote-command.test.ts "runs the quoted probe through a real POSIX shell", is the known Windows-host real-shell case. After a final one-line toast-duration tweak I re-ran typecheck, lint and npx vitest run src/renderer (69 files / 585 tests pass), not the full suite.
  • New unit tests: runBatch ordering, failure and cancel handling; summarizeBatch wording; REPLACE_SESSION_ID in the split reducer, the Canvas reducer and across both arrangements
  • Manual: Restart all on a group with 3+ sessions, some mounted in panes; panes keep their place and show the restarted sessions, conversations resume
  • Manual: Restart all with one session on an unreachable SSH host; that session stays, the others restart, the toast names it
  • Manual: Restart all with an expired Vault token and vault:// env vars; one login prompt, then every session restarts. Cancel the prompt instead: nothing is lost and the toast lists the sessions as not attempted
  • Manual: remove an ordinary session, click Undo; a session in the same directory resumes the conversation
  • Manual: Clear all, then Undo; with one unreachable host the toast offers Retry for just that session
  • Manual: remove a worktree session; the existing confirmation appears and there is no Undo toast

Out of scope

  • Keeping a restarted session's drag-ordered position. Saved order refers to the old id, so a restarted session sinks to the bottom of its group, as it did before.
  • Helm parent/child nesting across a restart or an Undo (not carried before either).
  • Awaiting creation in the New Session and New Environment dialogs (July C-3).
  • An App.tsx integration harness; the extracted logic is tested where it could be made pure.

🤖 Generated with Claude Code

Base automatically changed from fix/renderer-workflow-20261109 to main November 10, 2026 03:14
Follow-up to the focus/status/shortcut fixes (stacked on that branch).
Renderer and docs only.

Restart all
- Each session's replacement is now started first, takes over the
  original's panes (split and Canvas) and sidebar slot, and only then is
  the original removed. A session whose replacement cannot start is left
  as it was.
- Sessions restart one at a time and each create is awaited. Before,
  every session was removed up front and the creates were fired without
  awaiting; the Vault login prompt has a single slot, so with an expired
  token only the last create resolved and the rest of the sessions were
  simply gone.
- The toast reports what happened ("Restarted 3 of 4 sessions; 1 failed:
  api (reason). They were left as they were."), instead of announcing
  success before any session had been created. A second Restart all on
  the same group is ignored while one is running.

Undo
- Clear-all Undo restores sessions in turn with the same awaited path,
  and names anything it could not bring back with a Retry action.
- Removing a single ordinary session now shows the same Undo toast.
  Worktree sessions keep their confirmation dialog and get no Undo,
  since their directory may be removed with them.

Supporting changes
- New layout action REPLACE_SESSION_ID swaps a session id wherever it is
  mounted, in both arrangements, keeping pane ids and geometry.
- handleCreateSession's Vault preflight + create moved into
  createSessionFromOptions, which returns created / cancelled / failed
  instead of reporting it, so batches can summarize. Its own behaviour
  and toasts are unchanged.
- utils/session-batch.ts: runBatch (sequential, stops on cancel,
  continues past failures) and summarizeBatch, both unit-tested.

Tests: npx tsc --noEmit clean; eslint clean on touched files; vitest
202 files / 2345 tests pass. The one failure,
src/main/usage/remote-command.test.ts "runs the quoted probe through a
real POSIX shell", is the known Windows-host real-shell case.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@maxthomas95
maxthomas95 force-pushed the fix/session-remove-restart-20261109 branch from 0fbcbb7 to 6e14625 Compare November 10, 2026 03:17
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
45.6% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@maxthomas95
maxthomas95 merged commit b976342 into main Nov 10, 2026
10 of 11 checks passed
@maxthomas95
maxthomas95 deleted the fix/session-remove-restart-20261109 branch November 10, 2026 03:21
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