fix(dockview): correct pop-out restore double-offset (wrong-monitor drift)#176
Open
awaisali88 wants to merge 1 commit into
Open
fix(dockview): correct pop-out restore double-offset (wrong-monitor drift)#176awaisali88 wants to merge 1 commit into
awaisali88 wants to merge 1 commit into
Conversation
…rift) dockview's toJSON() serializes each pop-out group's position as ABSOLUTE screen coords (the pop-out window's screenX/screenY), but on restore fromJSON → addPopoutGroup re-opens the window at `window.screenX + position.left`, adding the MAIN window's screen offset to coords that are already absolute (dockview-core 6.6.1). On a multi-monitor setup — or any time the main window isn't at the screen origin — the restored pop-out drifts by the main window's offset and can land on the wrong monitor. `loadLayout` now pre-subtracts the main window's current screen origin from each saved pop-out position (new pure helper `correctPopoutRestoreOffset`) before fromJSON, so dockview's re-addition cancels and the window lands at its true saved absolute coordinates. No-op when there are no pop-outs or the main window is at (0,0). Unit-tested (offset math, round-trip invariant, no-mutation, null-position passthrough, no-op short-circuits). Compensates for dockview internal offset math — re-verify on dockview bumps. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What & why
Restored pop-out windows drift onto the wrong monitor today. dockview's
toJSON()saves each pop-out'spositionas absolute screen coordinates, butfromJSON→addPopoutGroupre-opens atwindow.screenX + position.left— re-adding the main window's screen offset to coordinates that are already absolute (dockview-core6.6.1,dockview-core.js:14580-14581). Whenever the main window isn't at the screen origin (any multi-monitor setup), the pop-out lands offset by the main window's position.This is a latent bug independent of the multi-window-restore feature; it ships first as its own fix (Phase 0 of the feature design spec,
docs/superpowers/specs/2026-06-14-multi-window-restore-design.md).The fix
session.loadLayoutnow pre-subtracts the main window's currentscreenX/screenYfrom each saved pop-outpositionbeforefromJSON, via a new pure helpercorrectPopoutRestoreOffset(src/modules/dockview/popoutOffset.ts). dockview's re-addition then cancels and the window lands at its true saved absolute coordinates. No-op when there are no pop-outs or the main window is at(0,0).Couples to dockview's internal offset math — flagged for re-verify on dockview bumps (CLAUDE.md library-gotcha rule).
Verification
Stage 1 (automated): the wrong-monitor manifestation requires real multiple monitors + pop-ups allowed for the origin, which isn't headless-reproducible — so there is no Playwright run embedded for this PR. The coordinate-correction logic is instead covered by 5 unit tests (
tests/unit/modules/dockview/popoutOffset.spec.ts): offset subtraction, the round-trip invariant (corrected + origin == saved absolute), no-mutation of the persisted blob, null-position passthrough, and the no-op short-circuits.Static gauntlet: lint ✓ · type-check (cache-free) ✓ · test 715/715 ✓ · spell ✓ · build ✓.
Stage 2 — human review (multi-monitor)
Tick each box; merge only when all are checked. To drive:
pnpm devon a multi-monitor machine, allow pop-ups for localhost.Specifically scrutinize: that the correction reads the current main-window origin at restore time (robust to the main window having moved between sessions), and that the normal no-pop-out restore path is untouched.
🤖 Generated with Claude Code