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 inspect the repository structure and locate the floating terminal implementation and related tests, then reproduce the state-transition behavior at the most appropriate test level before changing it.
- Assistant
ripgrepis unavailable, so I’ll usefind/grepand read the repository guidance before opening the target component. - Assistant
The issue is localized in
FloatingTerminalPanel.tsx. I’ll inspect the complete component, its store APIs, tab-bar ordering model, and available renderer test setup so the fix respects lifecycle and reconciled visible order rather than merely suppressing one effect. - Assistant
The current effect is level-triggered (
open && zero tabs), confirming the reported race: any removal while open bootstraps again. The callbacks also capturetabs, andcloseToRightuses backing order. I’ll inspectTabBar’s order reconciliation and store close semantics, then identify a reusable pure extraction or component test strategy without adding repository tests. - Assistant
TabBaruses the exportedreconcileTabOrder, so the floating callback should use the same function against a fresh store snapshot. I’ll verifycloseTabis synchronous and inspect test/runtime configuration before implementing: a transition-only bootstrap ref, explicit-close panel dismissal, PTY-exit-only removal, and fresh-state bulk callbacks. - Assistant
The store mutation is synchronous, so last-tab status can be determined from one fresh snapshot before removal. I’ll now implement the lifecycle distinction. I’ll also route
TerminalPane.onCloseTabthrough the explicit-close handler while leavingonPtyExitdirectly oncloseTab, preserving the required difference between user intent and process exit. - Assistant
Python is unavailable in the environment and no file was changed. I’ll apply the same deterministic replacements with Node, which is already part of the project toolchain.
- Assistant
The diff now encodes all three lifecycle paths separately. Before broader tests, I’ll run formatting/checking on the changed file and the web TypeScript build; this should catch import ordering, hook dependency, and store typing issues.
- Assistant
Corepack attempted an interactive pnpm download, which this environment cannot accept, so none of those checks ran. I’ll invoke the repository-installed binaries directly and inspect package-manager availability; then run Vitest directly as well.
- Assistant
Formatting, lint, web typecheck, and whitespace validation all passed. I’ll inspect the formatted diff, then run the existing floating-terminal and tab-order tests plus the full unit suite if the focused set succeeds.
- Assistant
The focused tests pass. The code-path reasoning confirms the original reproduction: under the old effect, closing the sole tab changed
tabs.lengthto zero whileopenstayed true, retriggering creation; under the new effect, tab changes are not a dependency and only a false→trueopentransition can create. I’ll now run the full unit suite to detect regressions beyond the focused ordering/bounds coverage. - Assistant
The full suite reached 6,711 passing tests but cannot be considered green in this container: failures are unrelated environment/preexisting issues (missing Electron,
node-pty, andbetter-sqlite3native binaries, root-permission-sensitive filesystem assertions, and one timeout). The focused tests and all static checks remain green. I’ll do a final edge-case review and repository cleanliness check, including ensuring tests generated no tracked artifacts.
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 →