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
Good, closeTab is synchronous. Now let's check for existing tests for FloatingTerminalPanel to understand expected behavior/test file naming conventions.
Assistant
Now let's implement the fix in FloatingTerminalPanel.tsx.
Assistant
Let's use the
replacespecial command instead.Assistant
Now let's update
closeFloatingTab,closeOthers,closeToRight, and theonCloseTab/onPtyExitusage. Also need to importreconcileTabOrder.Assistant
The line numbers shifted from my earlier read. Let's replace lines 186-215 directly.
Assistant
Now add the
reconcileTabOrderimport, and update theonCloseTabusage in the terminal pane mapping to usecloseFloatingTabwhile keepingonPtyExitcallingcloseTabdirectly.Assistant
Good, the import is added. Now let's fix the
onCloseTabline.Assistant
Now let's view the full file to double check everything is consistent, then run TypeScript checks / lint / tests.
Assistant
This looks correct. Now let's check TypeScript compile / lint for this file and run related tests.
Assistant
Good, TypeScript compiles cleanly. Now let's run relevant tests (reconcile-order tests, tabs tests, and any floating terminal related tests) via vitest.
Assistant
Good, the pnpm command didn't complete and no changes to tracked files. Let's check that package.json/pnpm-lock.yaml weren't modified.
Assistant
Let's check createTab signature to use it correctly in the script.
Assistant
Now let's write the temporary verification script.
Assistant
All three scenarios verified: bootstrap-on-open-transition, explicit close-closes-panel, PTY exit doesn't close panel or recreate tab, and closeToRight follows reconciled visible order. Now let's remove the temporary test file and run the broader existing test suite for affected areas.
Assistant
Now let's run the broader relevant existing test suites (tab-bar, terminals slice, tabs slice) to make sure nothing broke.
Assistant
All good, all tests passed. Now let's run full test suite briefly to check nothing else broke (maybe scoped, since full suite could take long).
Assistant
Confirmed pre-existing failures unrelated to my change (native binding issue in sandbox). Let's confirm the file diff is complete and clean.
Assistant
This is a complete, focused diff. Let's also double check
oxlintpasses for this file.Assistant
Lint passes cleanly. Now let's double check
git statusto ensure only intended file is modified, and no leftover temp files/node_modules changes.Assistant
Everything is clean. Let's go through the checklist.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.