fix(panel): persist panel identity to prevent position/size swap on project switch#3424
Merged
gregpriday merged 4 commits intodevelopfrom Mar 16, 2026
Merged
Conversation
- Change ratioByWorktreeId from Record<string, number> to Record<string, WorktreeRatioEntry> - Store ordered [leftPanelId, rightPanelId] pair with each ratio entry - Replace useEffect swap detection with synchronous useMemo inversion - Add Zustand persist migration (v0→v1) for existing scalar ratio values - Update all tests for new WorktreeRatioEntry shape
- Format twoPaneSplitStore.ts to satisfy prettier checks - Format twoPaneSplitStore.test.ts to satisfy prettier checks
- Add useEffect to backfill [null, null] panels on first render for migrated entries - Extract resolveEffectiveRatio as pure testable helper function - Add comprehensive tests for ratio inversion logic (swap, stale, partial, null) - Use resolveEffectiveRatio in TwoPaneSplitLayout useMemo
- Auto-format backfill effect and import line
This was referenced Mar 16, 2026
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
twoPaneSplitStorepersisted only a scalar ratio with no record of which panel ID occupied the left slotResolves #3419
Changes
twoPaneSplitStore.ts: extended state shape to storeleftPanelIdByWorktreeIdalongside the ratio; addedresolveRatiohelper that inverts when the persisted left ID no longer matches the current left panelTwoPaneSplitLayout.tsx: callsresolveRatioon every render so cross-session order changes are corrected before the ratio is applied; existing in-sessionprevTerminalIdsRefinversion logic is preserved and still fires for live dragsfix(panel): backfill legacy null panel IDs and extract ratio resolvercommit extracts the resolver into a testable helper and handles null IDs from older persisted stateTesting
Unit tests in
src/store/__tests__/twoPaneSplitStore.test.tscover the swap-detection, inversion, backfill,preferPreviewdefault, and in-session drag paths. Persistence boundary hardening tests inpersistenceBoundaryHardening.test.tswere updated to match the new state shape. All tests pass.