Skip to content
TheChatArchiveThe Chat Archive
xiaomi/mimo-v2.5-pro· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION Floating terminal auto-creates tab after user closes the last one…

  1. 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

    1. Open the floating terminal (Cmd+Alt+T on Mac / Ctrl+Alt+T on Windows/Linux)
    2. The panel opens with one auto-created terminal tab
    3. Click the X button on that tab to close it
    4. Expected: Panel closes cleanly
    5. Actual: Panel stays open with a fresh auto-created tab

    Root cause

    The closeTab callback used for the X button triggers the auto-create effect (lines 102-108 in FloatingTerminalPanel.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, closeOthers and closeToRight context menu actions had stale closure bugs—they read tabs.length from the captured array in useCallback dependencies instead of pulling fresh state via useAppStore.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 closeToRight must 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 using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to 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-$

  2. 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.

  3. Assistant

    Great, the main file is FloatingTerminalPanel.tsx. Let's examine it. First, let's open it with the open command.

  4. Assistant

    Let me read the rest of the file:

  5. Assistant

    Let me examine the closeTab implementation in the store to understand how it works:

  6. Assistant

    Let me look at how the closeTabsToRight works in the store, and also understand the tab bar order logic:

  7. Assistant

    Let me also look at the TabBar component to understand how it calls closeToRight and what tabBarOrder represents:

  8. Assistant

    Let me look at the reconcileTabOrder function to understand what tabBarOrder represents:

  9. Assistant

    Let me look at the TerminalPane component to understand the difference between onPtyExit and onCloseTab:

  10. Assistant

    Let me also look at how onOpenChange is used in the parent component and how the floating terminal panel is rendered:

  11. Assistant

    Let me look at how the floating terminal is opened/toggled:

  12. Assistant

    Let me look at the App.tsx to understand how the floating terminal panel is managed:

  13. Assistant

    Let me look at the toggleFloatingTerminal function to understand how open/close works:

  14. Assistant

    Let me look at the reconcileTabOrder function:

  15. Assistant

    Let me look at the TerminalPane component to understand the onPtyExit vs onCloseTab difference:

  16. Assistant

    Now let me understand how closeTab in the store works for the floating terminal tabs:

  17. Assistant

    Now let me check the closeTab implementation in the store for floating terminal tabs and look at the reconciled order:

  18. Assistant

    Let me look at how onPtyExit is handled in the main workspace (non-floating) terminal to understand the expected behavior:

  19. Assistant

    Let me look at the existing tests for the floating terminal to understand test structure:

  20. Assistant

    Let me look at the existing test file for the floating terminal panel to understand the testing patterns:

  21. Assistant

    Now let me look at how the store handles tabs for the floating terminal worktree:

  22. Assistant

    Now I have a thorough understanding of the codebase. Let me plan the fix:

    Root Causes:

    1. The auto-create effect (lines 97-108) fires whenever open && tabs.length === 0, so when the user closes the last tab, tabs.length drops to 0 and a new tab is auto-created.
    2. closeOthers and closeToRight capture tabs from the render cycle via useCallback dependencies - stale closure.
    3. closeToRight uses the raw tabs backing array order instead of the reconciled tabBarOrder.

    Fixes needed:

    1. Only auto-create a tab when the panel transitions from closed→open (not when tabs drop to 0 while already open).
    2. When user explicitly closes the last tab, close the panel. When PTY exits, just remove the tab (panel stays open, no replacement).
    3. closeOthers/closeToRight should read fresh state from useAppStore.getState().
    4. closeToRight should use the reconciled tabBarOrder.

    Let me implement the changes:

  23. Assistant

    Let me see the full auto-create effect and the close callbacks.

  24. Assistant

    Now let me see lines 100-220 to get the full auto-create effect and the close/other/closeToRight callbacks:

  25. Assistant

    Now I have a thorough understanding of the codebase and the issues. Let me implement the fix. I'll make the following changes:

    1. Auto-create effect: Only fire on panel open transition (closed→open), not when tabs drop to zero while already open
    2. closeFloatingTab: Check if it's the last tab and close the panel if so
    3. closeOthers/closeToRight: Use fresh state from useAppStore.getState() instead of stale closures
    4. closeToRight: Use reconciled tabBarOrder instead of raw backing array order
  26. Assistant

    Good, the auto-create effect is now properly guarded. Let me add a blank line after it and fix the closeFloatingTab callback:

  27. Assistant

    Now let me fix the closeFloatingTab callback to close the panel when the last tab is explicitly closed:

  28. Assistant

    Now let me fix closeOthers to use fresh state from the store:

  29. Assistant

    Now let me fix closeToRight to use fresh state and follow the reconciled tab-bar order:

  30. Assistant

    Now let me verify the complete file looks correct by viewing the key sections:

  31. Assistant

    Good. Now let me also look at the PTY exit handler in the JSX to make sure it doesn't need changes:

  32. Assistant

    Let me check the full JSX section to understand the TerminalPane rendering and the onPtyExit/onCloseTab callbacks:

  33. Assistant

    Now I need to update the onCloseTab callback in the TerminalPane to also use closeFloatingTab (which handles the last-tab-closes-panel logic):

  34. Assistant

    Let me now verify the complete file by looking at the full diff:

  35. 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 closeFloatingTab only closes the panel without closing the tab. Let me fix that:

  36. Assistant

    Now let me verify the full final diff to make sure everything is correct:

  37. Assistant

    Good, the diff looks clean. Now let me run the existing tests to make sure nothing is broken:

  38. Assistant

    Good, the existing tests pass. Let me also run any related store tests:

  39. 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:

  40. Assistant

    Let me find the tsconfig:

  41. Assistant

    Let me check if there's a specific script to run TypeScript checking:

  42. Assistant

    Let me check if there are any TypeScript errors specifically in my changed file:

  43. Assistant

    No TypeScript errors related to my changes. Let me also run any other related test files:

  44. 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:

  45. 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:

  46. Assistant

    Let me do one final check to verify the whole file structure is sound:

  47. Assistant

    Good, the file is well-formed. Let me now do a final review of the complete diff:

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.