Skip to content

feat: confirm before closing a tab/pane session#142

Draft
yoziv wants to merge 1 commit into
InbarR:mainfrom
yoziv:feature/yoziv/confirm-close-session
Draft

feat: confirm before closing a tab/pane session#142
yoziv wants to merge 1 commit into
InbarR:mainfrom
yoziv:feature/yoziv/confirm-close-session

Conversation

@yoziv

@yoziv yoziv commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

What & why

Reaching for a tab with the mouse and missing sometimes lands on the tab (or a middle-click), instantly killing a live terminal / AI session. This adds an opt-in confirmation before a tab/pane is closed.

Complements the existing "Hide tab close buttons" setting — instead of hiding the ✕, you keep it and confirm.

Changes

  • New setting confirmOnCloseSession (default off, so no behavior change for existing users). Persisted via config; toggle added under Settings → Tabs ("Confirm before closing").
  • closeTerminal(id, opts?) gains opts.skipConfirm. When the setting is on and not skipped, it shows the existing tmax-styled confirmDialog (danger variant) naming the session.
  • New closeTerminals(ids) action so bulk closes (Close All / Close Others / close group / multi-select Ctrl+Shift+W) show one aggregate "Close N sessions?" confirm instead of one dialog per tab.

Single-close surfaces are all covered because they route through closeTerminal: tab ✕-click, middle-click, context-menu Close, Ctrl+Shift+W, command palette, and TerminalPanel close buttons.

User impact

  • Default off → existing users unaffected.
  • Turn it on to get a guard against accidental closes; Cancel keeps the session, Close ends it.

Cross-platform

Pure renderer/store logic — no platform-specific APIs. Modifier handling for the shortcut path is unchanged.

Testing

  • tsc --noEmit: 0 new type errors (verified against origin/main baseline — identical error count before/after; pre-existing ambient API/xterm typings only).
  • Manual: toggle on → ✕-click, middle-click, and Ctrl+Shift+W prompt; Close All prompts once for N tabs; toggle off → closes immediately as before.
  • Note: the store has no unit-test harness (it depends on window.terminalAPI + confirmDialog at runtime); an e2e spec alongside middle-click-titlebar-close.spec.ts is the right home for automated coverage and can follow.

Backlog: TASK-276

Add an opt-in "Confirm before closing" setting so an accidental tab-X
click or middle-click no longer kills a live terminal/AI session.

- New confirmOnCloseSession setting (default off) in terminal-store,
  persisted via config and toggled from Settings > Tabs.
- closeTerminal gains an opts.skipConfirm; when the setting is on it
  shows the existing tmax confirmDialog (danger) naming the session.
- New closeTerminals(ids) so bulk closes (Close All / Close Others /
  close group / multi-select) show one aggregate confirm instead of
  one dialog per tab.

Covers X-click, middle-click, context-menu close, Ctrl+Shift+W, and
command palette since they all route through closeTerminal.

Backlog: TASK-276

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 928d2772-f9cd-42d4-864a-24d999bd1328
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