Repository navigation
Conversation
A cross-window tab drag recorded the source tab's INDEX when the drag started, and the drop removed whatever sat at that index. Nothing kept the index in step with the source window's tab list, so anything that closed a tab mid-drag shifted the list and the drop removed a bystander, while the dragged tab stayed behind and was then live in two windows at once. A shell exiting is enough to trigger it: PaneGroup::Event::Exited reaches handle_file_tree_event and closes that tab. cmd-W and another window handing a tab off do the same. The existing guard only bounds-checked the index, which does not help: after a shift the stale index is usually still in bounds and simply points at the wrong tab. The log::warn! for a stale index shows the staleness was anticipated, but only the out-of-bounds half was handled. ActiveDrag now captures the dragged pane group's EntityId at drag start, and the three source-cleanup DropResult variants carry that id instead of an index. Workspace resolves the tab at drop time via tab_index_for_pane_group_id and skips cleanly if it is already gone. Dropping the index from those variants makes the stale-index path unrepresentable rather than merely guarded. Regression test seeds a four-tab window, closes tab 0 mid-drag, and asserts the dragged tab is removed and the bystander survives. It fails on master.
Follow-up on the same invariant, from reviewing the first commit. The put-back branch of perform_handoff still resolved the source tab by the drag-start index, so dropping a tab back onto its own window's tab bar kept the original bug: it unsubscribed and removed a bystander, left the dragged tab's placeholder in place, and then re-inserted the real tab, leaving two TabData rows pointing at one pane group in one window. Placeholder rendering and the window snapshot read the same frozen index, so after a mid-drag tab close an innocent tab rendered at zero width and a save_app during the drag persisted a snapshot that omitted a bystander. Both now resolve through the pane group id; the drag model still decides WHETHER to collapse or skip, only the WHICH is resolved by identity. Removing the last remaining tab needed its own path. remove_tab treats the last tab as 'close the window' with a bare ctx.close_window(), which leaves suppress_detach_panes_on_window_close false, and on_window_closed would then detach the panes of a pane group that now lives in the target window. That was previously unreachable because the stale index was usually out of bounds and the removal was skipped; resolving by identity reaches it, so this path closes the same way the other content-transfer paths do. Also drops a duplicated allow(clippy::too_many_arguments) that would have failed CI under -D warnings. Tests: identity is captured by both begin_*_drag entry points; the last-tab drop suppresses pane detach; a drop whose tab already vanished removes nothing.
The identity helper was inserted between handle_drop_result's doc comment and the function, so the comment described the wrong thing and handle_drop_result was left undocumented. Also drops the helper to private, since both callers are in this file, and renames an index binding that read like a TabData.
|
Every PR must be linked to a same-repo issue before Oz can review it. This PR is linked to #14346, but no linked issue is marked See the contribution guidelines for the full readiness model. Powered by Oz |
There was a problem hiding this comment.
Every PR must be linked to a same-repo issue before Oz can review it.
This PR is linked to #14346, but no linked issue is marked ready-to-implement yet. Only repository maintainers apply that label, so please wait for a maintainer to mark the issue. Once it is marked, push a new commit or comment /oz-review to re-trigger review.
See the contribution guidelines for the full readiness model.
Powered by Oz
…indow-drag-removes-wrong-tab
|
Rebased onto current This one is only waiting on a readiness label for #14346, which is triaged as @oss-maintainers — two small asks:
|
…indow-drag-removes-wrong-tab
…indow-drag-removes-wrong-tab
…indow-drag-removes-wrong-tab
|
Hi @2solarmax — a reviewer requested changes on this PR and it hasn't had activity from you in 7 days. When you get a chance, please push updates or reply to the review so a reviewer can take another look. Without activity, this PR will be automatically closed after 14 days of inactivity. |
…indow-drag-removes-wrong-tab
|
Hi @2solarmax — a reviewer requested changes on this PR and it hasn't had activity from you in 7 days. When you get a chance, please push updates or reply to the review so a reviewer can take another look. Without activity, this PR will be automatically closed after 14 days of inactivity. |
|
Still here and ready — the fix is complete with a regression test, and this PR is waiting on issue #14346 getting a readiness label (only maintainers can apply it), so the blocker is on the review side rather than on me. Per the contribution guidelines, could a maintainer apply |
|
Hi @2solarmax — a reviewer requested changes on this PR and it hasn't had activity from you in 7 days. When you get a chance, please push updates or reply to the review so a reviewer can take another look. Without activity, this PR will be automatically closed after 14 days of inactivity. |
|
Hi @2solarmax — final reminder: a reviewer requested changes on this PR and it has been inactive for 10 days. It will be automatically closed in about 4 day(s) unless you push updates or reply. Maintainers can apply the |
|
Closing this pull request because the requested changes have gone unaddressed for over 14 days. If you'd like to continue, push your updates and reopen the PR (or comment to ask a maintainer to reopen) — we'd be glad to pick it back up. |
Description
A cross-window tab drag recorded the source tab's index when the drag started, and the drop removed whatever sat at that index. That index only moves in one situation, when you drag back over the source window's own tab bar and
set_source_placeholder_indexwalks it along with the placeholder. Nothing moves it when the source tab list shifts for a reason the drag did not cause, and a shell exiting is enough to do that with no input from the user at all.So the drop removed a bystander, closed its shell, and left the dragged tab in place, with both windows then holding a
TabDatapointing at the same pane group. The existing guard only bounds-checked the index, which does not help: after a tab is removed the stale index is usually still in bounds and just points at the neighbour.ActiveDragnow captures the dragged pane group'sEntityIdat drag start, and the three source-cleanupDropResultvariants carry that id instead of an index. Dropping the index from those variants is the point of the shape: the stale-index path stops being representable rather than staying guarded.Three more places on the same gesture needed the same treatment, all found while reviewing the first commit:
perform_handoff. Dropping a tab back onto its own window's tab bar still resolved by the frozen index, and its failure is worse: it unsubscribed and removed a bystander, left the dragged tab's placeholder in place, then re-inserted the real tab, leaving twoTabDatarows on one pane group in one window.save_appduring the drag persisted a snapshot that omitted a bystander while keeping the placeholder. The drag model still decides whether to collapse or skip; only the which is now resolved by identity.remove_tabtreats the last tab as "close the window" via a barectx.close_window(), which leavessuppress_detach_panes_on_window_closefalse, andon_window_closedwould then detach the panes of a pane group that now lives in the target window. That path was previously unreachable because the stale index was usually out of bounds and the removal was skipped entirely; resolving by identity reaches it, so it now closes the way the other content-transfer paths do.Not covered here:
reverse_handoffandon_drag_while_insertedare still index-based, but they operate on indices the drag itself owns inside the preview/target, not on the source list, so they are not affected by this class of shift.Linked Issue
Fixes #14346.
ready-to-specorready-to-implementJust filed, so it has not been triaged yet. Flagging for a readiness label. Happy to hold until it is labeled.
Related: #14152 (dragging whole tab groups between windows) builds on this same source-cleanup path. A group transfer removes several source tabs at once, which is where index-based cleanup gets worse, so this is probably worth landing underneath it. The open draft PR #14164 for that issue removes source tabs positionally by
{index, count}, so it carries this same defect at higher arity.Testing
Automated, all ungated so they run in default CI:
test_cross_window_drop_removes_the_dragged_tab_not_whatever_took_its_index— seeds a four-tab window, closes tab 0 mid-drag, and asserts the dragged tab is removed and the bystander survives. This is the regression test for the reported bug; onmaster, with the pre-change API, it removes the bystander and leaves the dragged tab.test_cross_window_drop_of_the_last_source_tab_closes_without_detaching_panes— covers the last-tab path above, asserting the window closes with pane detach suppressed.test_cross_window_drop_ignores_a_source_tab_that_is_already_gone— a drop whose tab vanished mid-drag removes nothing rather than falling back to an index.drag_captures_the_dragged_pane_group_identity— bothbegin_*_dragentry points capture the id, so cleanup has something to resolve through.Gates on this branch:
cargo clippy -p warp --all-targets --tests -- -D warnings— clean./script/format --check— cleancargo test -p warp --lib— 13 pre-existing environmental failures (OpenAI key, notebooks fs, telemetry, terminal, path resolution), identical set tomaster, which shows 15 on the same machine. No drag or tab-group test fails.I have manually tested my changes locally with
./script/runNot yet — flagging honestly rather than checking the box. The repro needs two windows and a 30-second timer mid-drag, and
drag_tabs_to_windowsis not in the default feature set, so it needs./script/run --features drag_tabs_to_windows. I can record it if you would like it before review; the deterministic unit test above covers the same state transition.Agent Mode
CHANGELOG-BUG-FIX: Fixed dragging a tab between windows closing the wrong tab when another tab in the source window closed mid-drag.