Add setting to confirm before closing Claude Code chat tab

Resolved 💬 3 comments Opened May 9, 2026 by hojjatmehri Closed May 12, 2026

Feature request: Confirm before closing chat panel/tab

Problem

When the Claude Code chat is opened as an editor tab (or even as a panel), it's very easy to close it accidentally — Cmd+W / Ctrl+W is muscle memory for closing files, and the chat tab looks just like any other tab. While the session is preserved in Session history and can be reopened, the interruption is annoying when it happens repeatedly during focused work.

Other IDE tools (like terminals with running processes, or unsaved files) prompt before closing. Claude Code chats — especially ones with long context, queued tool approvals, or in-progress agent work — would benefit from the same protection.

Proposed solution

Add a new extension setting, e.g.:

claudeCode.confirmBeforeClose: "never" | "whenBusy" | "always"
  • never (current behavior, default for back-compat)
  • whenBusy — only prompt if Claude is actively running, has a pending permission request, or has unsent input in the prompt box
  • always — prompt on every close of a Claude Code tab/panel

The prompt itself could mirror VS Code's native unsaved-changes dialog: "Close this Claude Code conversation? Don't Close / Close".

Why whenBusy matters

Closing a chat while Claude is mid-tool-call or waiting for a permission approval is the worst case — it can leave edits half-applied or interrupt long-running agent tasks. Even users who don't want a prompt every time would likely want one in this state.

Alternatives considered

  • Moving the chat to the sidebar (where Cmd+W doesn't close it) — works, but loses the multi-tab workflow that the docs explicitly recommend for parallel sessions.
  • Custom keybindings to disable Cmd+W on Claude tabs — VS Code's when clauses don't currently expose a context for "focused tab is a Claude Code tab," so this isn't user-achievable today.

Environment

  • VS Code: 1.119
  • Claude Code extension: [your version]
  • OS: Win11

Additional context

This comes up most when running multiple Claude Code conversations in tabs (as the docs suggest for parallel tasks). The more tabs you have, the higher the chance of an accidental close.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗