Skip to content

[Bug]: Tab close confirmation is bypassed when using the close button or middle-click #10142

Closed

Description

@giyoungjeon

Operating system

macOS

Orca version

1.4.150

Details

Short summary

Closing a tab with Cmd+W shows a confirmation warning, but closing the same tab using the tab's X button or the middle mouse button closes it immediately without showing the warning.

I am not sure whether this difference is intentional, but the behavior is inconsistent and allows mouse-based tab closing to bypass the existing close confirmation safeguard.

Steps to reproduce
Open a terminal tab in a state where closing it with Cmd+W triggers a confirmation warning.
Press Cmd+W.
Observe that a close confirmation dialog appears.
Cancel the dialog.
Click the X button on the same tab.
Observe that the tab closes immediately without confirmation.
Repeat with another tab, using the middle mouse button on the tab.
Observe that the tab again closes immediately without confirmation.
Expected behavior

All methods of closing the same tab should follow the same confirmation policy:

Cmd+W
Clicking the tab's X button
Middle-clicking the tab

If the warning is intentionally shown only for keyboard-based closing, it would be helpful to clarify the intended behavior.

Actual behavior
Cmd+W: shows a close confirmation warning.
Tab X button: closes immediately without warning.
Middle mouse button: closes immediately without warning.
Impact

The X button and middle-click can bypass a safeguard that is present when using Cmd+W. This makes it easier to accidentally close a tab, especially because middle-clicking may happen unintentionally.

Additional context

Middle-click-to-close itself appears to be an intended tab behavior. The issue is specifically that it does not use the same confirmation flow as Cmd+W.

Could you confirm whether this behavior is intentional? If not, mouse-initiated tab closes should probably go through the same close-confirmation logic as the keyboard shortcut.

Activity

  1. added
    bug
    on Jul 23, 2026
  2. added theissue type on Jul 23, 2026
  3. added
    os:macos
    on Jul 23, 2026
  4. innocarpe commented on Jul 23, 2026

    @innocarpe
    Contributor

    I'd like to take this.

    Plan: Cmd+W already routes through handleRequestClosePane (child-process / agent confirm via CloseTerminalDialog). Tab X and middle-click call closeTerminalTab directly, which only has the pinned guard. I'll put the same running-process confirmation on closeTerminalTab (store-driven dialog so keyboard/menu/X/middle-click share one policy), and ensure the already-confirmed Cmd+W path re-enters with force so we don't double-prompt.

    PR shortly.

  5. nwparker commented on Jul 24, 2026

    @nwparker
    Contributor

    Reproduction status: has_repro (code-path conclusive)

    Verified on current tree / Orca 1.4.154. Running-process close confirmation only runs on the Cmd/Ctrl+W → pane close path. Tab X and middle-click skip the process probe and close immediately.

    Policy split

    Action Entry Running-process confirm?
    Cmd/Ctrl+W keyboard-handlers.ts → onRequestClosePane → TerminalPane.handleRequestClosePane Yes (inspectRuntimeTerminalProcess + CloseTerminalDialog)
    Tab X / middle-click SortableTab → onClose → Terminal.handleCloseTab → closeTerminalTab No (only guardPinnedTabClose for pinned tabs)

    Key code

    • Confirm path: src/renderer/src/components/terminal-pane/TerminalPane.tsx (~1289–1317) — probes child processes, may open CloseTerminalDialog
    • Mouse middle-click: src/renderer/src/components/tab-bar/SortableTab.tsx (e.button === 1 → onClose)
    • Mouse X: same file close button → onClose
    • Mouse destination: src/renderer/src/components/Terminal.tsx handleCloseTab → closeTerminalTab (no process inspection)

    UI re-run

    1. In a terminal tab: sleep 300 (or any long-running process).
    2. Press Cmd+W → expect “Stop running command?” (or agent copy); Cancel.
    3. Click the tab X → tab closes immediately with no dialog.
    4. Start another long command; middle-click the tab → same immediate close.

    Automated re-run

    # Show keyboard path has inspectRuntimeTerminalProcess / handleRequestClosePane
    rg -n "handleRequestClosePane|inspectRuntimeTerminalProcess|closeActivePane" \
      src/renderer/src/components/terminal-pane/
    
    # Show mouse path closes via closeTerminalTab without that probe
    rg -n "handleCloseTab|closeTerminalTab|button === 1" \
      src/renderer/src/components/Terminal.tsx \
      src/renderer/src/components/tab-bar/SortableTab.tsx
    
    pnpm exec vitest run --config config/vitest.config.ts \
      src/renderer/src/components/terminal/repro-10142-close-confirm-keyboard-vs-mouse.test.ts

    Fix direction

    Route tab X / middle-click through the same handleRequestClosePane / process-confirm policy as Cmd+W (or call a shared helper before closeTerminalTab when the tab has a live PTY with children).

  6. added
    has_repro
    on Jul 24, 2026
  7. added a commit that references this issue on Jul 27, 2026
    141f844
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bughas_reproos:macos

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions