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 start by understanding the repository structure and finding the relevant files mentioned in the issue description. The key file is
FloatingTerminalPanel.tsx. Let me explore the repository first.Assistant
Found the file. Let me look at its contents.
Assistant
Now I have a clear picture of the code. Let me also check the TabBar component to understand the callback chain and look for any related
Assistant
Let me check the TabBar to understand the onClose callback and how tabs are handled there.
Assistant
Now let me look at the store to understand
closeTaband the tab management:Assistant
Let me find the store index to understand the closeTab function.
Assistant
Let me look at the store index to understand how closeTab works.
Assistant
Let me check the tabs slice for
closeTab.Assistant
Let me look at the tabs slice to understand closeTab.
Assistant
Let me check what
closeTabdoes in the store and look at the types:Assistant
Let me look at the
closeTabimplementation in the terminals slice.Assistant
Let me see the rest of the closeTab function.
Assistant
Now I have a thorough understanding of the code. Let me implement the fixes. I'll address all the issues described:
- Auto-create effect - Use a
prevOpenRefto only bootstrap when panel transitions from closed to open closeFloatingTab- Close the panel when the last tab is explicitly removedcloseOthers- Read fresh state fromuseAppStore.getState()instead of stale closurecloseToRight- Read fresh state and usetabBarOrderfor visible order
Let me make the changes
- Auto-create effect - Use a
Assistant
Let me see the rest of the relevant sections - the effect and callbacks:
Assistant
Now let me make all the needed changes. I'll start with the auto-create effect and the ref:
Assistant
Now let me fix the auto-create effect (lines 98-104):
Assistant
The edit got mangled. Let me see the current state and fix it
Assistant
The edit was mangled. Let me restore the original file and redo this properly.
Assistant
Now let me create a script to make all the changes without shell escaping issues:
Assistant
Let me try with node instead:
Assistant
Let me use node for the replacements:
Assistant
All changes applied. Let me verify the final file looks correct:
Assistant
Let me check the rest of the file for
closeToRight:Assistant
All changes look correct. Let me verify the diff and check if TypeScript compilation passes:
Assistant
Let me check if there are existing tests related to this component and try to run TypeScript checks:
Assistant
Let me check the package.json for available build/lint commands:
Assistant
Let me try running the typecheck for the web/renderer part:
Assistant
Node modules aren't installed, so I can't run the typecheck. Let me verify the full file once more to ensure there are no issues:
Assistant
The file looks correct. Let me verify the existing tests that might be relevant and see if we can run them:
Assistant
The file looks syntactically and semantically correct. Let me also verify no other files reference the changed functions in a way that would break:
Assistant
All references are within the same file. The changes are self-contained. Let me submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.