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 to understand the codebase and locate the relevant file(s). Let's first get an overview.
- Assistant
Great, the main file is
FloatingTerminalPanel.tsx. Let's examine it. First, let's open it with the open command. - Assistant
Let me read the rest of the file:
- Assistant
Let me examine the
closeTabimplementation in the store to understand how it works: - Assistant
Let me look at how the
closeTabsToRightworks in the store, and also understand the tab bar order logic: - Assistant
Let me also look at the TabBar component to understand how it calls closeToRight and what
tabBarOrderrepresents: - Assistant
Let me look at the reconcileTabOrder function to understand what tabBarOrder represents:
- Assistant
Let me look at the TerminalPane component to understand the difference between
onPtyExitandonCloseTab: - Assistant
Let me also look at how
onOpenChangeis used in the parent component and how the floating terminal panel is rendered: - Assistant
Let me look at how the floating terminal is opened/toggled:
- Assistant
Let me look at the App.tsx to understand how the floating terminal panel is managed:
- Assistant
Let me look at the toggleFloatingTerminal function to understand how open/close works:
- Assistant
Let me look at the reconcileTabOrder function:
- Assistant
Let me look at the TerminalPane component to understand the onPtyExit vs onCloseTab difference:
- Assistant
Now let me understand how
closeTabin the store works for the floating terminal tabs: - Assistant
Now let me check the
closeTabimplementation in the store for floating terminal tabs and look at the reconciled order: - Assistant
Let me look at how
onPtyExitis handled in the main workspace (non-floating) terminal to understand the expected behavior: - Assistant
Let me look at the existing tests for the floating terminal to understand test structure:
- Assistant
Let me look at the existing test file for the floating terminal panel to understand the testing patterns:
- Assistant
Now let me look at how the store handles tabs for the floating terminal worktree:
- Assistant
Now I have a thorough understanding of the codebase. Let me plan the fix:
Root Causes:
- The auto-create effect (lines 97-108) fires whenever
open && tabs.length === 0, so when the user closes the last tab,tabs.lengthdrops to 0 and a new tab is auto-created. closeOthersandcloseToRightcapturetabsfrom the render cycle viauseCallbackdependencies - stale closure.closeToRightuses the rawtabsbacking array order instead of the reconciledtabBarOrder.
Fixes needed:
- Only auto-create a tab when the panel transitions from closed→open (not when tabs drop to 0 while already open).
- When user explicitly closes the last tab, close the panel. When PTY exits, just remove the tab (panel stays open, no replacement).
closeOthers/closeToRightshould read fresh state fromuseAppStore.getState().closeToRightshould use the reconciledtabBarOrder.
Let me implement the changes:
- The auto-create effect (lines 97-108) fires whenever
- Assistant
Let me see the full auto-create effect and the close callbacks.
- Assistant
Now let me see lines 100-220 to get the full auto-create effect and the close/other/closeToRight callbacks:
- Assistant
Now I have a thorough understanding of the codebase and the issues. Let me implement the fix. I'll make the following changes:
- Auto-create effect: Only fire on panel open transition (closed→open), not when tabs drop to zero while already open
closeFloatingTab: Check if it's the last tab and close the panel if socloseOthers/closeToRight: Use fresh state fromuseAppStore.getState()instead of stale closurescloseToRight: Use reconciledtabBarOrderinstead of raw backing array order
- Assistant
Good, the auto-create effect is now properly guarded. Let me add a blank line after it and fix the
closeFloatingTabcallback: - Assistant
Now let me fix the
closeFloatingTabcallback to close the panel when the last tab is explicitly closed: - Assistant
Now let me fix
closeOthersto use fresh state from the store: - Assistant
Now let me fix
closeToRightto use fresh state and follow the reconciled tab-bar order: - Assistant
Now let me verify the complete file looks correct by viewing the key sections:
- Assistant
Good. Now let me also look at the PTY exit handler in the JSX to make sure it doesn't need changes:
- Assistant
Let me check the full JSX section to understand the TerminalPane rendering and the
onPtyExit/onCloseTabcallbacks: - Assistant
Now I need to update the
onCloseTabcallback in the TerminalPane to also usecloseFloatingTab(which handles the last-tab-closes-panel logic): - Assistant
Let me now verify the complete file by looking at the full diff:
- Assistant
The diff looks good. Let me now verify the key logic by checking one more scenario. I need to also ensure that when closing the last tab, we properly close the tab data in the store AND close the panel. Currently
closeFloatingTabonly closes the panel without closing the tab. Let me fix that: - Assistant
Now let me verify the full final diff to make sure everything is correct:
- Assistant
Good, the diff looks clean. Now let me run the existing tests to make sure nothing is broken:
- Assistant
Good, the existing tests pass. Let me also run any related store tests:
- Assistant
The store test failure is a pre-existing module resolution issue unrelated to my changes. Let me also run TypeScript checking to make sure there are no type errors:
- Assistant
Let me find the tsconfig:
- Assistant
Let me check if there's a specific script to run TypeScript checking:
- Assistant
Let me check if there are any TypeScript errors specifically in my changed file:
- Assistant
No TypeScript errors related to my changes. Let me also run any other related test files:
- Assistant
The store tests have pre-existing import issues unrelated to my changes. Let me now review my full changes one more time to verify they are correct:
- Assistant
The changes look correct. Let me now verify the final state of the whole file one more time to make sure there are no syntax or indentation issues:
- Assistant
Let me do one final check to verify the whole file structure is sound:
- Assistant
Good, the file is well-formed. Let me now do a final review of the complete diff:
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 →