Skip to content
TheChatArchiveThe Chat Archive
DeepSeekdeepseek/deepseek-v4-pro· deepseekHugging 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. DeepSeek Assistant

    Let me start by understanding the repository structure and finding the relevant files mentioned in the issue description. The issue is about a floating terminal panel in what appears to be an Electron-based application (likely an IDE or terminal app). The file mentioned is FloatingTerminalPanel.tsx.

    Let me explore the repository first.

  3. DeepSeek Assistant

    Let me find the FloatingTerminalPanel.tsx specifically.

  4. DeepSeek Assistant

    Found it. Let me open this file.

  5. DeepSeek Assistant

    Let me continue reading the file, particularly around the auto-create effect (lines 97-110) and the closeTab callback

  6. DeepSeek Assistant

    Let me see the rest of the file, particularly how the tab bar and close handlers are wired up

  7. DeepSeek Assistant

    Let me see the rest of the file to understand how TabBar is wired up

  8. DeepSeek Assistant

    Now let me look at how closeTab works in the store, and how tabs are managed

  9. DeepSeek Assistant

    Let me look at the closeTab implementation in the terminals slice

  10. DeepSeek Assistant

    The open command only takes one file and one optional line number. Let me just open the file at the right line.

  11. DeepSeek Assistant

    Let me also check how closeTabsToRight is implemented in tabs.ts

  12. DeepSeek Assistant

    I can only pass one line number. Let me open at line 767.

  13. DeepSeek Assistant

    Now I have a good understanding of the issue. Let me also look at the test file to understand any existing tests for this component.

  14. DeepSeek Assistant

    Now I have a full understanding. Let me implement the fixes. First, let me re-open the file at the relevant section:

  15. DeepSeek Assistant

    Now let me make the changes. First, I'll add a prevOpenRef to track the previous open state. Let me add it after the existing refs:

  16. DeepSeek Assistant

    Let me see the exact content of those lines:

  17. DeepSeek Assistant

    Now let me add the prevOpenRef. I'll use the replace command to insert it after `normalizedInitialBoundsRef

  18. DeepSeek Assistant

    Let me use sed for the edits since the replace command is having issues:

  19. DeepSeek Assistant

    Let me try the edit command with heredoc syntax:

  20. DeepSeek Assistant

    Good. Now let me fix the auto-create effect to only trigger when the panel transitions open:

  21. DeepSeek Assistant

    Good. Now let me fix closeFloatingTab to close the panel when the last tab is being

  22. DeepSeek Assistant

    Now let me fix closeOthers to use fresh state from useAppStore.getState():

  23. DeepSeek Assistant

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

  24. DeepSeek Assistant

    All changes are in place. Let me verify the full file by checking the key sections:

  25. DeepSeek Assistant

    Let me also verify the onPtyExit handler and minimize button remain unchanged:

  26. DeepSeek Assistant

    Good. The onPtyExit still calls closeTab directly (not closeFloatingTab), which is correct. Let me now check if there are TypeScript compilation errors and run any relevant tests.

  27. DeepSeek Assistant

    TypeScript compilation passes without errors. Let me find and run any existing tests related to the floating terminal or terminal tabs.

  28. DeepSeek Assistant

    Let me look at the test files related to terminals to understand what tests exist and run them:

  29. DeepSeek Assistant

    Good, those tests pass. Let me run the terminals-related test files to make sure nothing is broken:

  30. DeepSeek Assistant

    That failure is unrelated to my changes (missing package). Let me run the terminals-hydration test instead

  31. DeepSeek Assistant

    These are pre-existing import issues unrelated to my changes. Let me run the tabs test and the terminals test:

  32. DeepSeek Assistant

    All test failures are pre-existing (missing package imports unrelated to my changes). Let me verify my changes with git diff

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