Skip to content

Cross-window tab drag removes the wrong tab if the source tab list changes mid-drag #14346

Open

Description

@2solarmax

Pre-submit Checks

Describe the bug

Drag a tab out of one window and onto another, and if anything closes a tab in the source window while you are still holding the mouse, the drop closes the wrong tab there.

I went digging in cross_window_tab_drag.rs to work out why. The source window records the dragged tab's index when the drag starts, and on drop it removes whatever is sitting at that index. The index is only updated in one situation: if you drag back over the source window's own tab bar, set_source_placeholder_index moves it along with the placeholder. Nothing updates it when the source tab list shifts for a reason the drag did not cause.

Two things are wrong afterwards, not one:

  • an innocent tab is closed, and its shell goes with it
  • the tab you dragged is never removed from the source, so both windows are left holding a tab pointing at the same pane group

The list shifting mid-drag needs no effort. A shell exiting closes its own tab, with no input from you at all (PaneGroup::Event::Exited reaches handle_file_tree_event, which closes it). Cmd-W does it too, if the source window still has focus.

There is real staleness handling elsewhere in this file, source_placeholder_consumed and the bail-out in perform_handoff, but it is all scoped to shifts the drag itself causes. At the cleanup site the only guard is a bounds check, and after a tab is removed the stale index is usually still in bounds and simply points at the neighbour.

This sits behind FeatureFlag::DragTabsToWindows, which is in RELEASE_FLAGS for macOS and Windows, so it is on in stable.

To reproduce

  1. Open two Warp windows. Give window A four tabs; window B can have one.
  2. In window A's leftmost tab, run sleep 30; exit. That shell closes its own tab half a minute later with no further input, which is what shifts the tab list mid-drag.
  3. Straight away, grab window A's third tab and drag it out over window B's tab bar. Keep the button held. Do not let the cursor wander back over window A's own tab bar, that path updates the index and hides the bug.
  4. Wait, still holding, until window A's leftmost tab disappears on its own.
  5. Drop onto window B.

The dragged tab arrives in window B as expected. In window A, the fourth tab has been closed instead of the third, and the third is still sitting there.

It also reproduces deterministically without the timing, as a unit test: build a four-tab workspace, remove tab 0, then run the drop carrying the drag-start index. It removes the bystander and leaves the dragged tab.

Expected behavior

The drop removes the tab that was dragged, whatever index it currently occupies, and touches no other tab. If the dragged tab is already gone, because its own shell exited mid-drag, the drop should do nothing rather than remove something else.

Operating system (OS)

macOS

Operating system and version

macOS 26.5.2 (25F84), Apple silicon

Current Warp version

v0.2026.07.22.09.01.01 (stable). Also read and reproduced against master at da06b31.

Regression

No, this bug or issue has existed throughout my experience using Warp

Additional context

I have a fix ready and would like to open a PR. It captures the dragged pane group's id at drag start and resolves the source tab by identity at drop time, which also lets the index be dropped from the three source-cleanup DropResult variants entirely, so the stale-index path stops being representable rather than staying guarded. The same resolution is needed in the put-back branch of perform_handoff and in the two places that read the placeholder index for rendering and for the window snapshot.

The public repo history is squashed into a single import commit, so I could not blame this to a specific change.

Related: #14152 (dragging whole tab groups between windows). A group transfer would have to remove several source tabs at once, which is where index-based cleanup gets worse, so it is probably worth fixing this underneath first.

Does this block you from using Warp daily?

No

Is this an issue only in Warp?

Yes, I confirmed that this only happens in Warp, not other terminals.

Activity

  1. warp-for-oss commented on Jul 27, 2026

    @warp-for-oss
    Contributor

    @2solarmax

    Here's what I found while triaging this issue:

    The report includes enough detail to treat this as highly reproducible. Code inspection supports the stale source-tab-index cleanup path described in the issue.

    Maintainer details

    I concluded that cross-window tab drag can remove an unrelated source tab when the source tab list changes during the drag because cleanup is keyed by the drag-start tab index..

    Triage

    This is a code-backed bug in cross-window tab drag cleanup. The observed symptom is that if the source window's tab list shifts while a multi-tab cross-window drag is in progress, dropping the dragged tab into another window can remove the tab now occupying the original index instead of the tab being dragged.

    The likely root cause is that the drag state stores the source tab's index at drag start and later returns that index through the source-cleanup DropResult variants. The source workspace cleanup path only checks whether that index is still in bounds before unsubscribing/removing the tab, so a mid-drag source tab close can leave the stale index pointing at a bystander tab.

    Relevant code paths:

    • app/src/workspace/cross_window_tab_drag.rs stores and updates source_tab_index, uses it in finalize_preview_as_new_window / finalize_handoff, and only updates it for source-placeholder reordering.
    • app/src/workspace/view.rs handles DropResult::RemoveSourceTab and DropResult::RemoveSourceTabAndClosePreview by removing the tab at transferred_tab_index when that index is still in bounds.
    • crates/warp_features/src/lib.rs shows FeatureFlag::DragTabsToWindows enabled for release builds on macOS and Windows, so the affected feature is shipping on the reporter's platform.

    I did not find two or more open duplicate issues with the same stale-index cross-window drag corruption scenario. #14152 is related future work for dragging tab groups between windows, but it is not the same bug.

    This is my automated analysis and may be incorrect. A maintainer will verify the details.

    Powered by Oz

  2. added
    area:window-tabs-panes
    bug
    os:mac
    repro:high
    triaged
    on Jul 27, 2026
  3. 2solarmax commented on Aug 18, 2026

    @2solarmax
    Author

    The linked PR #14347 fixes this and has been waiting on the ready-to-implement label since July 27 — Oz bounces the PR mechanically until the issue carries it. This is a data-loss bug (a bystander tab gets closed instead of the dragged one), reproducible, with a regression test in the PR. If a maintainer can re-evaluate readiness: @oss-maintainers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:window-tabs-panesbugos:macrepro:hightriagedwarp:auto-triage-review

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions