Repository navigation
restore the active source tab by document id, not tab index - #17947
Conversation
The active tab was persisted across reloads as a physical tab index, but documents are restored in persisted relativeOrder (falling back to creation time), which can differ from the in-session physical order -- e.g. after drag-reordering tabs, or after opening a document mid-session (new tabs are inserted after the current tab but restored at the end). Persist the active document's id instead and resolve it to a tab after the documents are restored. Addresses #17944
🍎 macOS Desktop E2E · ARM64✅ All tests passed!
📥 Download Playwright report⬇️ playwright-report.zip — extract and open
2 shards · macos-26 ARM64 · commit |
Code review findingsActionable items from an automated multi-agent review. Strengths, dismissed findings, and ratings Important
Suggestions
|
gtritchie
left a comment
There was a problem hiding this comment.
Overall looks good, a worthwhile-sounding tweak and the usual comment suggestions to consider.
…ed document is gone - SourceColumnManager.initialSelect / SourceColumn.initialSelect: when the persisted active document no longer exists (e.g. closed before the reload), select the active column's currently selected tab so it still receives onInitiallyLoaded() (and its startup external-edit check) - reword the SourceColumn.initialSelect comment: id resolution goes through the logical editors_ index, so it is robust to tab reordering by construction, not by assumption - e2e: tighten the set_client_state sniff to the activeTabDocId key (doc ids appear in other client-state structures), and add a test for the closed-document fallback path
|
Thanks for the review -- addressed in f1d215a.
Both e2e tests pass against the dev desktop build. |
The Source pane persisted the active tab across reloads as a physical tab index (the in-session display position mapped through the
tabOrder_permutation), but on restore the saved index was applied directly to the freshly built tab set, whose order comes from the persistedrelativeOrder(falling back to creation time). Whenever the two orders diverge -- tabs drag-reordered during the session, or a document opened mid-session (new tabs are inserted immediately after the current tab but restored at the end, since they keeprelativeOrder == 0) -- the wrong tab was selected after a reload or session restart.This change persists the active document's ID instead (client state key
activeTabDocId) and resolves it to a tab after the documents are restored:Source.java: theIntStateValuefor the active tab becomes aStringStateValueholding the active document ID.SourceColumnManager.initialSelect()now takes a doc ID, restores the last active column, and selects the column/tab containing that document.SourceColumn.initialSelect()looks the document up by ID and selects its tab.The in-session save/restore pair (
getPhysicalTabIndex()/setPhysicalTabIndex()) is untouched; only the cross-reload persistence path changes. The previously savedactiveTabinteger is simply ignored (one-time, the active tab falls back to the first restored document).Includes a Playwright regression test that opens documents so the physical order diverges from the restored order, reloads, and asserts the pre-reload active document is re-selected. Verified the test fails (selects the wrong tab, exactly as reported) against the unfixed build and passes with the fix.
Not included: the complementary
set_doc_orderchange suggested in the issue (persisting tab order when a tab is inserted at a non-terminal position). That would make the restored tab order match the pre-reload physical order, but it adds an RPC to every document open and is a separate, cosmetic symptom; the wrong-active-tab bug is fully addressed by the ID-based persistence.Fixes #17944.