Skip to content

fix(launch): resize HUD overlay to fit system language prompt#37

Merged
EtienneLescot merged 5 commits into
mainfrom
fix/issue-30-language-prompt-resize
Jun 28, 2026
Merged

fix(launch): resize HUD overlay to fit system language prompt#37
EtienneLescot merged 5 commits into
mainfrom
fix/issue-30-language-prompt-resize

Conversation

@EtienneLescot

@EtienneLescot EtienneLescot commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

The system-language suggestion prompt rendered at fixed top-8 of the HUD renderer, but measureHudSize only 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 ResizeObserver so 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

  • Bug fix

Release impact

  • Patch

Desktop impact

  • Windows
  • macOS
  • Linux

Testing

  • npx tsc --noEmit clean
  • npx vitest run src/components/launch/LaunchWindow.test.tsx — 10/10 pass, including two new cases:
    • HUD overlay height covers the prompt + top margin when the system-language suggestion is shown
    • Switch / Keep-default buttons route to the i18n context callbacks
  • npx biome check on the touched files clean
  • Full unit suite npm run test — 243/243 pass

Summary by CodeRabbit

  • Bug Fixes
    • Improved the Launch window layout so the system language prompt is fully accommodated in the overlay sizing.
    • Fixed prompt-related resizing behavior to keep the window sized appropriately when language choice options appear.
    • Added coverage for prompt interactions, including switching languages and keeping the current language.

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.
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c6fb19d5-4a68-460a-a99d-d25e5c48216e

📥 Commits

Reviewing files that changed from the base of the PR and between a468f06 and aa66961.

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

📝 Walkthrough

Walkthrough

LaunchWindow 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.

Changes

System language prompt sizing

Layer / File(s) Summary
Prompt measurement
src/components/launch/LaunchWindow.tsx
Tracks the system-language prompt element, includes it in resize observation, and uses its measured bounds in HUD sizing.
Prompt tests
src/components/launch/LaunchWindow.test.tsx
Shares i18n state, adds prompt translation strings, resets launch mocks, and verifies overlay sizing and prompt actions.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 The prompt grew wide, the buttons stayed neat,
my hop-clicks now land on every seat.
The HUD holds steady, bright and new,
with English, default, and room to do.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately describes the main change to the launch HUD overlay sizing.
Linked Issues check ✅ Passed The changes address issue #30 by including the language prompt in HUD sizing so it stays visible and clickable.
Out of Scope Changes check ✅ Passed The PR stays focused on HUD overlay sizing and related tests, with no clear unrelated code changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description check ✅ Passed The description covers the required sections and key details; only the optional screenshots/video section is missing.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-30-language-prompt-resize

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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between 6c2fdd1 and 936f30a.

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

Comment thread src/components/launch/LaunchWindow.test.tsx
Comment thread src/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).
@EtienneLescot EtienneLescot merged commit b655acf into main Jun 28, 2026
10 of 11 checks passed
EtienneLescot added a commit that referenced this pull request Jun 28, 2026
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.
@EtienneLescot EtienneLescot deleted the fix/issue-30-language-prompt-resize branch June 28, 2026 17:47
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]: it cannot be used. The toolbar asks whether to switch to Chinese, but other buttons are unclickable

1 participant