ISSUE DESCRIPTION Floating terminal auto-creates tab after user closes the last one…
- User
ISSUE DESCRIPTION
Floating terminal auto-creates tab after user closes the last one
Floating terminal auto-creates tab after user closes the last one
Symptom
When the floating terminal has a single tab open and the user clicks the X button to close it, the panel auto-creates a new terminal tab instead of closing the panel. The user has to close the panel manually via the minimize button or by closing the newly created tab again.
Steps to reproduce
- Open the floating terminal (Cmd+Alt+T on Mac / Ctrl+Alt+T on Windows/Linux)
- The panel opens with one auto-created terminal tab
- Click the X button on that tab to close it
- Expected: Panel closes cleanly
- Actual: Panel stays open with a fresh auto-created tab
Root cause
The
closeTabcallback used for the X button triggers the auto-create effect (lines 102-108 inFloatingTerminalPanel.tsx) that spawns a tab whenever the panel is open with zero tabs. The panel never closes because a replacement tab is created before the close check can run.Additionally,
closeOthersandcloseToRightcontext menu actions had stale closure bugs—they readtabs.lengthfrom the captured array inuseCallbackdependencies instead of pulling fresh state viauseAppStore.getState(), causing these callbacks to operate on outdated tab lists.Expected behavior
- Clicking X on the last terminal tab should close the floating panel (symmetric with the auto-create on open)
- The panel should remain open if a PTY exits so the user can see exit status
- Multi-tab operations (
closeOthers,closeToRight) should operate on current state, not stale captures
Why it matters
The asymmetry breaks user expectations: the panel auto-creates a tab on open (hotkey press), but closing that tab doesn't reverse the action. Users expect the X button on the last tab to dismiss the panel, not spawn an orphaned replacement.
Environment
- All platforms (macOS, Linux, Windows)
- Floating terminal feature introduced in recent releases
Evaluation contract
Bootstrap a terminal tab only when the panel transitions open. An explicit close action that removes the last tab closes the panel; a PTY exit removes its tab but must neither close the panel nor create a replacement tab. Bulk close operations must read the current store state rather than a stale render-time tab list, and
closeToRightmust follow the reconciled visible tab-bar order rather than raw backing-array order. - Assistant
I’ll first inspect the repository structure and locate
FloatingTerminalPanel.tsx, then trace the store actions and tab ordering logic before making changes. Afterward I’ll run the most relevant tests/type checks and verify the behavioral edge cases from the evaluation contract. - Assistant
The target component is present and the working tree is clean. I’ll now read the full panel implementation plus relevant store definitions and tab-bar reconciliation APIs, with special attention to distinguishing explicit user closure from PTY exit and to deriving the visible ordering correctly.
- Assistant
The current implementation confirms both reported problems: bootstrap is level-triggered (
open && tabs.length === 0) rather than transition-triggered, and bulk callbacks capturetabs. I also need the remainder of the JSX to identify every close path and theTabBarordering contract. Since ripgrep is unavailable, I’ll usegrepandfind. - Assistant
The required event split is clear:
TabBar.onCloseandTerminalPane.onCloseTabare explicit close paths and should dismiss after the last removal, whileonPtyExitmust continue calling the store directly. For bootstrap, I’ll track the closed→open transition in a ref and inspect fresh store state only on that edge.Before editing, I’ll inspect how
TabBarreconciles a partial/staletabBarOrder, socloseToRightcan use exactly the same visible order rather than inventing a subtly different one. - Assistant
TabBaruses the sharedreconcileTabOrderutility, so the floating action should import and invoke that utility against a fresh terminal list and the fresh stored order. Because this panel is terminal-only, the editor/browser ID lists are empty. I’ll inspect the utility and test setup conventions, then implement the focused component change without modifying tests. - Assistant
I’ll make four coordinated changes in
FloatingTerminalPanel.tsx:- Replace the zero-tabs level effect with a closed→open edge effect using fresh store state.
- Make explicit close verify the target belongs to the floating terminal, remove it, then close the panel only if no floating tabs remain.
- Keep PTY exit on raw
closeTab, but routeTerminalPane.onCloseTabthrough explicit-close behavior. - Make both bulk actions read fresh state, and make
closeToRightusereconcileTabOrder.
- Assistant
Python is not installed, so no source changes were made (the formatter merely rewrote the unchanged file). I’ll apply the same deterministic replacements using Node, which is available, then format and inspect the diff.
- Assistant
The diff now enforces the intended lifecycle. A key race is handled correctly: removing the final tab causes a store rerender while
openis still true, but the bootstrap effect depends only onopen, so it cannot recreate a tab; when the parent appliesopen=false, the ref resets for the next genuine opening. PTY exit similarly leaves an open, empty panel and does not retrigger bootstrap.I’ll run the web typecheck, lint the changed file, and run the existing floating-terminal and tab-order tests most relevant to the imported reconciliation behavior.
- Assistant
The combined validation did not execute because the
pnpmshim attempted an interactive Corepack download, which this environment disallows. Dependencies are already installed, so I’ll invoke the repository-local binaries directly (node_modules/.bin/...) and run each validation separately to avoid the prior timeout. - Assistant
The changed code passes the web TypeScript check and lint with zero warnings/errors. I’ll now locate the exact reconciliation test filename and run it together with the floating bounds and tab context-menu suites.
- Assistant
All 13 focused tests pass, including seven reconciliation-order cases. I’ll do a final integrity pass: run
git diff --check, inspect the complete changed region, and execute the terminal store test suites that exercise synchronouscloseTabbehavior. This also validates the assumption used when checking remaining tabs immediately after close.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.