Skip to content

fix(overlay): stop the HUD drag from drifting away from the cursor#125

Merged
EtienneLescot merged 3 commits into
mainfrom
fix/hud-drag-drift-100
Jul 19, 2026
Merged

fix(overlay): stop the HUD drag from drifting away from the cursor#125
EtienneLescot merged 3 commits into
mainfrom
fix/hud-drag-drift-100

Conversation

@EtienneLescot

@EtienneLescot EtienneLescot commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #100: dragging the HUD by its grip handle would drift away from the cursor rather than tracking it 1:1.

Root cause: two independent IPC channels can both reposition the HUD BrowserWindow. Pointer drags send incremental deltas via hud-overlay-move-by; separately, a ResizeObserver watching the HUD's content calls hud-overlay-set-size whenever the observed content size changes, which recomputes the window's bounds from a bottom-centre anchor using the window's current bounds at the time of the call. If a resize observation fires mid-drag (even a spurious one from transient reflow), its anchor recompute races the drag's own incremental repositioning, and the two compound into a net offset — read by users as the HUD "drifting away".

Fix: freeze content-size measurement while a drag is in progress (isDraggingHudRef), so hud-overlay-set-size cannot fire mid-drag. The content size is re-measured once via measureHudSize() right after the drag ends, so a real size change (e.g. from a toggle clicked mid-drag) still gets picked up promptly.

Verification

Verified via computer-use against a real dev build (not just code review):

  • Multiple multi-step drags (7-9 incremental pointer moves each, matching how a real drag event stream looks), covering different directions and distances.
  • Grip position after release matches the cursor's drop point to within a few px each time.
  • Re-checked position after a 2s settle — no drift, no post-drop jump.

Test plan

  • tsc --noEmit — clean
  • biome check — clean
  • Live computer-use verification: multiple drags, immediate + delayed position checks, no drift

Fixes #100

Summary by CodeRabbit

  • Bug Fixes
    • Improved HUD resizing while dragging to prevent layout and sizing glitches.
    • Overlay dimensions now resynchronize correctly after the HUD is moved.

Fixes #100: dragging the HUD by its grip handle would drift away from the
cursor rather than tracking it 1:1.

Root cause: two independent IPC channels can both reposition the HUD
BrowserWindow. Pointer drags send incremental deltas via
hud-overlay-move-by; separately, a ResizeObserver watching the HUD's content
calls hud-overlay-set-size whenever the observed content size changes, which
recomputes the window's bounds from a bottom-centre anchor using the
window's *current* bounds at the time of the call. If a resize observation
fires mid-drag (even a spurious one from transient reflow), its anchor
recompute races the drag's own incremental repositioning, and the two
compound into a net offset — read by users as the HUD "drifting away".

Fix: freeze content-size measurement while a drag is in progress
(isDraggingHudRef), so hud-overlay-set-size cannot fire mid-drag. The
content size is re-measured once via measureHudSize() right after the drag
ends, so a real size change (e.g. from a toggle that was clicked mid-drag)
still gets picked up promptly.

Verified via computer-use against a real dev build: multiple multi-step
drags (7-9 incremental pointer moves each, matching how a real drag event
stream looks) all track the cursor to within a few px, both immediately on
release and after a 2s settle -- no drift, no post-drop jump.
@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@EtienneLescot, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 3 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 24663274-cc3c-435e-b7e0-bd8f98f142df

📥 Commits

Reviewing files that changed from the base of the PR and between 6112ed5 and a1a2cf7.

📒 Files selected for processing (2)
  • src/components/launch/LaunchWindow.test.tsx
  • src/components/launch/LaunchWindow.tsx
📝 Walkthrough

Walkthrough

LaunchWindow now suppresses HUD size measurement while dragging and re-measures the overlay after dragging ends.

Changes

HUD drag synchronization

Layer / File(s) Summary
Guard and resynchronize HUD measurement
src/components/launch/LaunchWindow.tsx
Adds drag-state tracking, skips measureHudSize during HUD dragging, and re-runs measurement after pointer release.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

Suggested reviewers: itzadetunji

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the HUD drag drift fix and matches the main change.
Description check ✅ Passed The description covers the fix, related issue, and testing, with only some template sections omitted.
Linked Issues check ✅ Passed The change keeps the overlay aligned during drag by blocking resize measurements until release, which addresses #100.
Out of Scope Changes check ✅ Passed The diff stays focused on HUD drag and resize handling in LaunchWindow and adds no unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/hud-drag-drift-100

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/launch/LaunchWindow.tsx`:
- Around line 324-333: Add regression tests in the LaunchWindow test package for
the drag synchronization behavior: verify ResizeObserver-triggered measurement
is skipped while isDraggingHudRef is active, and verify measurement runs after
pointer release or the final drag movement. Exercise the existing drag handlers
and measureHudSize flow rather than testing implementation details directly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c14975e5-ca59-4a07-b71c-7ea944de2e32

📥 Commits

Reviewing files that changed from the base of the PR and between 44829d6 and 6112ed5.

📒 Files selected for processing (1)
  • src/components/launch/LaunchWindow.tsx

Comment thread src/components/launch/LaunchWindow.tsx
…ssion

Per CodeRabbit review on #125: covers the fix's actual behavior end-to-end
through the real drag handlers rather than testing isDraggingHudRef directly.

Adds data-testid="hud-drag-handle" (the drag grip had no selector) and a test
that: fires a real pointerdown on the handle, triggers a ResizeObserver
callback mid-drag and asserts setHudOverlaySize is NOT called (the race this
PR fixes), then fires pointermove/pointerup and asserts a measurement DOES
happen once released -- so a real size change made mid-drag still gets
picked up promptly.

Full suite: 53 files / 424 tests pass. tsc --noEmit and biome check clean.
@EtienneLescot
EtienneLescot merged commit 8b4a118 into main Jul 19, 2026
12 checks passed
@EtienneLescot
EtienneLescot deleted the fix/hud-drag-drift-100 branch July 19, 2026 12:20
EtienneLescot added a commit that referenced this pull request Jul 19, 2026
…ssion

Per CodeRabbit review on #125: covers the fix's actual behavior end-to-end
through the real drag handlers rather than testing isDraggingHudRef directly.

Adds data-testid="hud-drag-handle" (the drag grip had no selector) and a test
that: fires a real pointerdown on the handle, triggers a ResizeObserver
callback mid-drag and asserts setHudOverlaySize is NOT called (the race this
PR fixes), then fires pointermove/pointerup and asserts a measurement DOES
happen once released -- so a real size change made mid-drag still gets
picked up promptly.

Full suite: 53 files / 424 tests pass. tsc --noEmit and biome check clean.
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.

[Bug]: Holding the Openscreen Overlay drifts away to the right

1 participant