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 trace the floating terminal component, its store actions, and existing tests first. I’ll then adjust the lifecycle distinction between explicit tab close and PTY exit, fix bulk operations to use fresh store state and visible ordering, run targeted tests/type checks, and review the final diff before submitting.
- Assistant
The repository does not have
rg, so I’ll usegrep/findinstead. The initial listing confirms a TypeScript project; I’m narrowing the search to source files and package scripts now. - Assistant
The key lifecycle fix is to make bootstrapping edge-triggered: only a closed→open transition creates the initial tab. PTY exit will still remove its tab, but because no open transition occurs, it cannot create a replacement. The X-button callback will close the panel when the post-close store state has no floating tabs. For bulk actions I’ll read
useAppStore.getState()at invocation time and derive right-side IDs with the samereconcileTabOrderhelper used byTabBar. - Assistant
python3is unavailable in this environment, so the edit did not run and no files were changed. I’ll apply the same exact transformation with a short Node script, which is already required by the project tooling. - Assistant
The implementation is now in place. I preserved
onPtyExit={() => closeTab(...)}separately fromonCloseTab, so PTY termination cannot close the panel, while explicit close uses the panel-aware callback. The right-side operation now uses current store tabs plus reconciled stored order, matching floatingTabBarrendering. I’ll run formatting/type checking and targeted tests next. - Assistant
The combined validation command was blocked because Corepack tried to download pnpm and prompted interactively; it timed out before running checks. I’ll rerun with the noninteractive Corepack setting, splitting formatting, typecheck, and tests so failures are attributable.
- Assistant
Formatting and web typechecking now pass, and the relevant tab-order/context-menu tests pass (9/9). I also reviewed the diff: only the floating panel changed, with no test modifications. I’ll run the renderer lint on the file and a final formatting check, then submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.