Skip to content

[Bug]: Closing a tab is sometimes a silent no-op #11308

Closed

Description

@puze8681

Operating system

macOS

Details

Short summary:
Closing a tab sometimes does nothing at all — the X (and Cmd+W, and the context-menu close) is a silent no-op with no error, no toast, and no log. Retrying does not help while the triggering condition holds. There are two independent code paths that dead-end a close, both traced below.

What happened?

1. closeTerminalTab aborts the whole close when the tab's worktree owner cannot be routed

src/renderer/src/components/terminal/terminal-tab-actions.ts

const worktreeRoute = resolveTerminalWorktreeRoute(state, owningWorktreeId)
if (!worktreeRoute) {
  options?.onCancel?.()
  return          // no local prune, no error, no toast
}

The tab-strip close button calls closeTerminalTab(tabId) with no onCancel (Terminal.tsx), so hitting this branch is indistinguishable from the click never registering.

resolveTerminalWorktreeRoute returns null whenever resolveWorktreeOperationRouteResult is not resolved. For a tab whose worktree row is absent from worktreesByRepo/detectedWorktreesByRepo, and whose repo is a plain local repo (local repos carry no executionHostId — see the addRemoteRepoFromPath comment in persistence.ts, and resolveIndexedRepoOperationRoute skips repos with neither executionHostId nor connectionId), resolution falls through to the legacy gates in worktree-operation-route.ts and returns missing when any of these hold:

  • runtimeEnvironmentCatalogHydrated === false. It starts false (runtime-status.ts) and only flips in setRuntimeEnvironments, reached via the fire-and-forget hydrateRuntimeEnvironmentStatuses() in fetchSettings. So this covers the startup window — and, if runtimeEnvironments.list() throws (that catch returns without setting anything), the entire session.
  • removedRuntimeEnvironmentIds.size > 0 — i.e. any runtime environment removed during this session.
  • Two or more saved runtime environments with one active (legacyRuntimeIsUnambiguous === false).

The worktree row is missing during startup hydration for repos whose scan has not landed yet, when a fetchWorktrees call failed, and for runtime-owned worktrees before the deferred remote-worktree-refresh completes.

activateTerminalTab has the same guard, so such a tab also cannot be selected.

Note that the fail-closed here buys nothing for safety: provider teardown already fails closed per PTY inside buildTerminalTabRetirementPlan, which routes each PTY through resolveTerminalHostOwnership(..., 'teardown') and pushes anything it cannot attribute onto unroutablePtyIds (skipped and warned). The outer gate only adds the ability to ignore the user's click.

2. closeUnifiedTab dead-ends when the tab's group record is missing

src/renderer/src/store/slices/tabs.ts

const group = findGroupForTab(state.groupsByWorktree, worktreeId, tab.groupId)
if (!group) {
  return null     // tab stays in unifiedTabsByWorktree forever
}

Every close path funnels through this action, including terminals.closeTab's unified sweep, so a tab whose group record disappeared while activeGroupIdByWorktree still points at that id renders in the strip (TabBar filters on tab.groupId === resolvedGroupId) and can never be removed — not by the X, not by Close Others / Close to the Right, not after a restart. Group records are dropped by tabOrder-based checks (closeUnifiedTab's collapse branch, and the empty-group filter in the workspace-tab reconciliation), so any desync between a group's tabOrder and the tabs pointing at it orphans those tabs.

How can we reproduce it?

Path 1, from a store state (verified with a unit test against the real resolver):

  1. Have at least one runtime environment saved, or start Orca and act before the runtime-environment catalog hydrates.
  2. Open a terminal tab on a local-repo worktree whose row is not in worktreesByRepo/detectedWorktreesByRepo (startup before that repo's worktree scan lands, or after its scan failed).
  3. Click the tab's X — nothing happens. resolveTerminalWorktreeRoute returns null and the close returns before any state change.

Path 2:

  1. Get a tab into a group id that no longer exists in groupsByWorktree while activeGroupIdByWorktree still points at it (host session-tab snapshot desync, or a group collapse racing a tab add).
  2. The tab renders and is unclosable through every close path.

Anything else that might help:

Two related-but-separate issues found while tracing this, not covered here:

  • Remote/host-owned worktrees prune locally and fire the host close as void closeWebRuntimeSessionTab(...). On RPC failure the catch in web-runtime-session.ts clears the close intents, so the next host snapshot re-adds the tab — the "closed, then it came back" symptom, distinct from "won't close". The host can also answer refused: true and republish.
  • pinned-tab-close-confirm.ts swallows a confirm click that lands within INTER_REQUEST_ACTION_GUARD_MS (350ms) of the previous one when a request is queued behind it. The dialog stays up, so a second click works.

Activity

  1. added
    os:macos
    on Jul 29, 2026
  2. added a commit that references this issue on Oct 10, 2026
    274e2f2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

os:macos

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions