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.Interface
No new interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /orca, current file: none) bash-$
- Assistant
I'll start by exploring the repository structure and locating the floating terminal panel code mentioned in the issue.
- Assistant
Let me read the FloatingTerminalPanel component and related store/lib code.
- Assistant
Let me read the rest of the file, especially the close tab logic and auto-create effect.
- Assistant
Let me continue reading the file and search for related tests and close-tab store logic.
- Assistant
Let me search more carefully for tests and related store code.
- Assistant
rg is not found, let me use grep instead.
- Assistant
Let me inspect tab-close patterns elsewhere, read the evaluation hints in docs/AGENTS, and check how PTY exit is handled.
- Assistant
Let me examine how the main terminal handles close operations and whether any related skills/docs describe the expected behavior.
- Assistant
Let me look at how Terminal.tsx handles closeOthers for reference, and read more of FloatingTerminalPanel and how open states work.
- Assistant
Let me look at Terminal.tsx handleCloseOthers and handleCloseToRight implementation carefully - they likely use getState() which is the correct pattern.
- Assistant
I need to see how PTY exit closes tabs in the floating terminal and what the full TabBar wiring looks like.
- Assistant
Let me check how TabBar reconciles order and whether any FloatingTerminalPanel tests or git history already sketched this fix.
- Assistant
Let me inspect reconcileTabOrder and how close operations should measure the last tab.
- Assistant
Let me check when TerminalPane calls onCloseTab versus onPtyExit.
- Assistant
I have a clear fix plan. Implementing the open-transition bootstrap, last-tab panel close, and stale-closure bulk close fixes.
- Assistant
The edit hit the wrong file — undoing that and applying the change to FloatingTerminalPanel.tsx.
- Assistant
Now I'll apply the full fix to FloatingTerminalPanel.tsx.
- Assistant
Good. Now replace the auto-create effect and the close callbacks.
- Assistant
There's a leftover line from the old effect — removing it and updating the close callbacks.
- Assistant
Updating the close callbacks next.
- Assistant
Also wire TerminalPane's explicit onCloseTab path through closeFloatingTab.
- Assistant
Yes, I should update onCloseTab to use closeFloatingTab.
- Assistant
I'll move
wasOpenRefnext to the other refs for cleaner hooks structure. - Assistant
Removing the duplicate
wasOpenRefdeclaration. - Assistant
Verifying the full file, that other files weren't touched, and that related tests still pass.
- Assistant
I'll run typecheck/lint on this file and the related unit tests.
- Assistant
Oxlint timed out. Let me try a quicker typecheck for web or just run vitest for the floating terminal bounds test.
- Assistant
Vitest is timing out with no output. Let me wait longer or try npx.
- Assistant
Hmm vitest keeps timing out. Let me check if node_modules/vitest exists and try running with a longer approach - maybe the problem is pipe with tail closing early.
- Assistant
Running a web typecheck to confirm the change compiles.
- Assistant
Corepack is prompting — I'll use the local binaries directly instead.
- Assistant
Typecheck passed. Doing a final review of the file.
- Assistant
Checking that
closeTabis synchronous so the remaining-tab count is accurate.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →