Skip to content

fix(window): accept the one-pixel frame Windows adds to resized bounds - #726

Open
shunxinyi-ljs wants to merge 1 commit into
Tencent:mainfrom
shunxinyi-ljs:fix/window-resize-frame-rounding
Open

shunxinyi-ljs wants to merge 1 commit into
Tencent:mainfrom
shunxinyi-ljs:fix/window-resize-frame-rounding

Conversation

@shunxinyi-ljs

Copy link
Copy Markdown

On Windows, bsk window resize fails on every call: the outer bounds come back one DIP taller than requested (900x700 → 900x701), and the exact-equality check reports that as window_resize_constrained.

Change. handleWindowResize now accepts reported bounds that differ from the request by the resize frame, and still fails when the difference is larger. The reply continues to return the bounds that took effect, so a caller that cares about the exact size reads the same numbers as before. The tolerance is one DIP per axis and lives in a named helper next to the existing zoom tolerance in the same file.

Failing evidence. Before the change, ten requests on Windows (widths 800/900, heights 600/601/700/701/720) returned protocol_error / window_resize_constrained ten times, always one DIP above the requested height: 800x600 → 601, 900x700 → 701, 900x720 → 721. The window did resize each time; only the verdict was wrong.

Verification.

  • New unit case in window.test.ts (accepts outer bounds one frame pixel larger than requested) fails on unmodified window.ts and passes with the change. A guard case (still reports bounds that differ by more than the frame, 900x703 for 900x700) passes on both sides.
  • window.test.ts and session.test.ts: 78 passed. tsc --noEmit and biome format clean on the changed files.
  • End to end against the same Chrome, with the extension rebuilt from this branch: the requests that failed before now return window_id, 900x601, 900x701, 900x702.

Behaviour change. A resize that lands within one DIP of the request is now a success that returns the effective bounds instead of a protocol_error. A one-pixel difference can no longer be reported as a constraint; anything larger still is.

Not in scope. Repeated resizes on an occluded window can still return window_resize_viewport_unchanged when Chrome stops updating layout metrics. That behaviour predates this change and is unchanged.

Chrome returns 900x701 for a 900x700 resize on Windows because the resize
frame is added after the bounds are rounded. The exact-equality check turned
every call into `window_resize_constrained`, so `bsk window resize` never
succeeded even though the window did resize.

Treat a one-DIP difference per axis as the size that took effect and keep
reporting the bounds Chrome returned; a larger difference still fails.
@shunxinyi-ljs
shunxinyi-ljs force-pushed the fix/window-resize-frame-rounding branch from a2caa98 to 1001ea3 Compare November 13, 2026 10:26
@shunxinyi-ljs
shunxinyi-ljs marked this pull request as ready for review November 13, 2026 10:34

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant