fix(launch): resize HUD overlay to fit system language prompt#37
Conversation
The system-language suggestion prompt is anchored at fixed top-8 of the renderer, but measureHudSize only sized the OS overlay to fit the bottom HUD bar. On a non-English OS that triggered the prompt for the first time, the window was too short and the prompt's buttons were clipped above the visible area, making the app appear unusable (issue #30). Include the prompt in the size measurement and observe it via the existing ResizeObserver so the bottom-anchored window grows upward to contain the prompt's full extent. Add a test asserting the overlay height covers the prompt plus top margin.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughLaunchWindow now includes the system-language prompt in HUD overlay sizing and resize observation. The tests add controllable ResizeObserver and i18n state, prompt strings, reset helpers, and assertions for overlay sizing and prompt actions. ChangesSystem language prompt sizing
Sequence Diagram(s)sequenceDiagram
participant Test
participant LaunchWindow
participant ResizeObserver
participant electronAPI
participant I18nContext
Test->>LaunchWindow: render with systemLocaleSuggestion
Test->>ResizeObserver: trigger stored callbacks
LaunchWindow->>electronAPI: setHudOverlaySize(...)
Test->>LaunchWindow: click prompt actions
LaunchWindow->>I18nContext: call prompt handlers
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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.test.tsx`:
- Around line 388-422: The HUD overlay sizing test is stubbing the prompt
element after render, but `measureHudSize()` is not being triggered again, so
the assertion only checks the initial `setHudOverlaySize` call. In
`LaunchWindow.test.tsx`, after spying on `getBoundingClientRect()` for the
prompt’s parent element, force a second resize/measurement pass so the updated
box is actually used and the prompt-sizing path is exercised. Use the existing
`renderLaunchWindow`, `window.electronAPI.setHudOverlaySize`, and
`measureHudSize`-driven behavior as the reference point for where the rerun
should be triggered.
In `@src/components/launch/LaunchWindow.tsx`:
- Around line 419-422: The system-language prompt callback in LaunchWindow.tsx
can run before the resize observer is available, so the prompt never gets
registered with observe(). Update the HUD observation flow around
setSystemLocalePromptEl and observeHudElement so the prompt is attached once
hudResizeObserverRef.current exists, and make sure any effect that backfills
observed elements includes systemLocalePromptRef alongside hudBarRef and
deviceSelectorRef.
🪄 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: 5afeac39-8907-440b-8609-8b09a6b54758
📒 Files selected for processing (2)
src/components/launch/LaunchWindow.test.tsxsrc/components/launch/LaunchWindow.tsx
Two follow-ups from the CodeRabbit review on #37: * measureHudSize's ResizeObserver effect only observed hudBarRef and deviceSelectorRef. If the system-language prompt (or language menu) mounted before the effect ran, their reflows would never trigger another resize. Backfill both refs in the effect. * The size-assertion test was stubbing getBoundingClientRect after render but never re-fired the observer, so it read the mount-time call (with height: 0 from jsdom) and passed for the wrong reason. Capture the ResizeObserver callback, fire it after stubbing, and also stub the bar's box to mimic a real layout — verified the test now fails (height 68 vs expected 186) when the prompt-sizing path is disabled.
- Use rect.top + promptHeight in measureHudSize so the prompt's measured bottom drives overlay height instead of a magic 32 that would silently drift from the Tailwind class. - Hoist StubResizeObserver / CapturingResizeObserver to module scope and factor resetLaunchMocks() so the two describes share setup. Drop the trivial button-routing test (the click handlers are direct i18n callbacks in the JSX).
Two follow-ups from the CodeRabbit review on #37: * measureHudSize's ResizeObserver effect only observed hudBarRef and deviceSelectorRef. If the system-language prompt (or language menu) mounted before the effect ran, their reflows would never trigger another resize. Backfill both refs in the effect. * The size-assertion test was stubbing getBoundingClientRect after render but never re-fired the observer, so it read the mount-time call (with height: 0 from jsdom) and passed for the wrong reason. Capture the ResizeObserver callback, fire it after stubbing, and also stub the bar's box to mimic a real layout — verified the test now fails (height 68 vs expected 186) when the prompt-sizing path is disabled.
Summary
The system-language suggestion prompt rendered at
fixed top-8of the HUD renderer, butmeasureHudSizeonly sized the OS overlay to fit the bottom HUD bar. On a non-English OS that triggered the prompt on first launch (issue #30), the window was too short and the prompt's buttons were clipped above the visible area, making the app appear unusable.Include the prompt in the size measurement and observe it via the existing
ResizeObserverso the bottom-anchored window grows upward to contain the prompt's full extent. A follow-up commit also backfills the new ref (and the pre-existing language-menu ref) into the observer effect, so a prompt that mounts before the effect runs still gets observed on later reflows.Related issue
Fixes #30
Type of change
Release impact
Desktop impact
Testing
npx tsc --noEmitcleannpx vitest run src/components/launch/LaunchWindow.test.tsx— 10/10 pass, including two new cases:npx biome checkon the touched files cleannpm run test— 243/243 passSummary by CodeRabbit