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
Let me understand the issue:
- When a user closes the last tab in the floating terminal, instead of closing the panel, it auto-creates a new tab.
- The root cause is in
FloatingTerminalPanel.tsx, lines 102-108, where acloseTabcallback triggers an auto-create effect that spawns a tab whenever the panel is open with zero tabs. - Additionally,
closeOthersandcloseToRighthave stale closure bugs.
Let me explore the repository structure and find the relevant files.
Assistant
Let me find the
FloatingTerminalPanel.tsxfile specifically.Assistant
Let me open the file and look at the relevant code.
Assistant
Let me see the rest of the file to understand the auto-create effect and the closeTab callback.
Assistant
Let me continue to see closeOthers, closeToRight, and the rest of the file.
Assistant
Let me see the rest of the file, especially the JSX part where the tab X button triggers closeFloatingTab
Assistant
Let me look at the store's
closeTabfunction and understand how it works:Assistant
Let me find the store file.
Assistant
Let me look for the store's main file.
Assistant
Let me look at the store index file for
closeTab.Assistant
Let me search for closeTab more
Assistant
Let me look at the
closeTabimplementation and the surrounding code:Assistant
Let me find where
FloatingTerminalPanelis used to understand theonOpenChangeprop:Assistant
Let me look at App.tsx to see how FloatingTerminalPanel is used.
Assistant
Let me look at how PTY exit triggers tab closing to understand the flow better
Assistant
Now let me look at lines 336-350 to see how PTY exit and close tab are handled in the JSX:
Assistant
Let me look at the FloatingTerminalPanel.tsx lines around 336-350
Assistant
Let me check the
setFloatingTerminalOpenWithFocusimplementation to understand any potential conflictsAssistant
Let me see the
setFloatingTerminalOpenWithFocusfunction:Assistant
Now I have a complete understanding of the issue. Let me implement the fix.
Summary of changes needed:
-
Auto-create effect (lines 97-103): Use a
prevOpenRefso tabs are only bootstrapped when the panel transitions from closed to open. This prevents auto-creating after PTY exit. -
closeFloatingTab(lines 169-174): Check if closing the last tab; if so, close the panel viaonOpenChange(false). -
closeOthers(lines 176-185): UseuseAppStore.getState()instead of staletabsfrom closure. -
closeToRight(lines 187-198): UseuseAppStore.getState()for fresh state and followtabBarOrderfor visible tab order.
Let me start with the auto-create effect
-
Assistant
Now let me fix
closeFloatingTabto close the panel when closing the last tabAssistant
Now fix
closeOthersto use fresh stateAssistant
Now fix
closeToRightto use fresh state and follow tabBarOrderAssistant
Let me verify the entire file looks
Assistant
Let me check for TypeScript errors in the modified
Assistant
These are pre-existing config errors (path aliases, JSX — handled by the project's build tool). Let me run the project's own type check command
Assistant
No TypeScript errors related to our changes. Let me now look for existing tests related to FloatingTerminalPanel
Assistant
Let me check for relevant store tests that might test close
Assistant
Let me run the existing floating terminal tests
Assistant
Let me run the store cascades test that tests close
Assistant
Let me run the terminals test
Assistant
Let me review the complete modified file to make sure everything is
Assistant
The diff looks correct. Let me verify the build works by running the project's type check on the full project
Assistant
Type check passes cleanly. Let me do a final review of the changed file sections
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.