Skip to content

fix(website): clamp picker maxHeight to available space (#8252) - #8538

Merged
NicholasRBowers merged 1 commit into
mainfrom
fix/picker-menu-clamp-available-height-8252
Sep 5, 2026
Merged

NicholasRBowers merged 1 commit into
mainfrom
fix/picker-menu-clamp-available-height-8252

Conversation

@CrysisDeu

@CrysisDeu CrysisDeu commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

menuGeometry (shared by the @file, $skill, and /command pickers) returned a constant maxHeight: MENU_MAX_HEIGHT (320), trusting the count * rowH estimate to fit the chosen side. Real rows render taller than the estimate (~53px measured vs the 48px constant), and since #7673 pins an opens-above menu's bottom edge to grow upward, the surplus extends past the viewport TOP at short viewports (issue worked example: 3 rows at rect.top = 160 — 156px available, ~167px real height, 11px off-screen).

This implements the reporter's preferred option 1: clamp maxHeight to the space the chosen side actually has, so estimate accuracy becomes irrelevant to clipping — an over-tall menu scrolls inside its container instead. All three pickers already apply maxHeight to an overflow-y-auto container (FilePicker/SlashCommand on the portal itself, SkillPicker on the inner listbox), so no component changes were needed.

What changed (website/src/lib/pickerMenu.ts only, plus its test)

  • maxHeight = max(minSensibleHeight, min(MENU_MAX_HEIGHT, available)) where available is rect.top − margin above (capped at the viewport, for an anchor scrolled past the bottom edge) or innerHeight − rect.bottom − margin below.
  • minSensibleHeight = rowH + 8 + extraH: one row plus padding plus pinned chrome (the skill picker's scope footer must not eat the one guaranteed row), so a degenerate anchor never yields a sliver-height menu.
  • Fits-neither fallback: the side choice is still the existing estimate (rect.top − menuH − margin > 0); only when the chosen side cannot show even one row and the other side is roomier does the side flip there. Pure rect math — no post-mount measurement or reflow machinery (which the issue's option 1 deliberately avoids). Without this, a composer low in a 200px viewport opened below into 12px while 136px sat unused above.
  • Module doc comment now states the clamp honestly: the floor takes precedence when no side has one row of space, so the no-clip guarantee holds only while the chosen side has at least minSensibleHeight.

Tests (website/src/test/pickerMenu.test.ts)

All #7673 placement tests kept passing unchanged; new cases pin:

  • (a) opens-above at short rect.top → maxHeight == rect.top − margin (< 320) — no top clip
  • (b) opens-below near the viewport bottom → maxHeight == innerHeight − rect.bottom − margin
  • (c) generous space on either side → full MENU_MAX_HEIGHT
  • (d) the issue's worked example: 3 rows, rect.top = 160, rowH = 48 → above === true, maxHeight === 156
  • fits-neither flip: 200px viewport, anchor low → opens above with maxHeight = 136 instead of below into 12px
  • anchor scrolled past the viewport bottom (bottom floors at 0) → clamp capped at the viewport, not the off-screen rect.top
  • extraH funds the floor: skill-picker footer at a hopeless viewport → maxHeight = rowH + 8 + extraH
  • absolute floor when no side has room → rowH + 8

Verified locally: npx tsc -b and eslint clean. Vitest runs in CI (this host does not run test suites locally by operator policy).

Screenshots

Not applicable: the change is invisible at default viewport sizes — with normal space above the composer the clamp resolves to the same 320px cap as before, and the fixed defect (a menu edge a few px past the viewport boundary at short viewports) was itself derived from measurements rather than visually observed (see the issue: "the clipping itself is derived, not observed"). The geometry is pinned exactly by the unit-test matrix above, including the issue's worked example.

Review

Three model-pinned pre-push reviewers (2× GPT lane, 1× Opus lane). Converged finding fixed in this commit: the fits-neither case previously floored past the available space and could still clip; also fixed the viewport over-read for off-screen anchors, the extraH-less floor, an overstated doc claim, and a test helper that leaked a data property over happy-dom's innerHeight accessor. One cosmetic finding (clamped above-menu renders flush at y=0) rebutted: adding a top gap would break the issue's pinned worked example (maxHeight === 156).

Pattern harvest

Rule candidate: review checklist — a positioning helper that returns a FIXED pixel bound (maxHeight, maxWidth) while placing an element against a viewport edge must derive that bound from the space actually available on the chosen side, not from a constant; a constant bound silently trusts whatever size estimate chose the side. Same shape as this defect: menuGeometry clamped at a 320px constant while the side choice used an estimate that under-read real content. Grep-able signal: maxHeight: <CONSTANT> returned from a function that also reads getBoundingClientRect().

Closes #8252

@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — ✅ PASS

UX-level review of 45c0712ad33d7d1633e41fb1ef5f784c1cfe5c29 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

All three pickers already scroll the initial selection into view on open, and each applies the clamped maxHeight to a proper overflow-y-auto container — so a clamped menu scrolls with the highlighted row visible rather than clipping. The ordering above and placement above are computed from the same inputs, so the new fits-neither side-flip cannot desynchronize display order from placement. No strings, no screenshots, no layout regressions at normal viewports (clamp resolves to the prior 320px cap). The two documented edge behaviors — flush-at-y=0 above-menus and the one-row floor overhanging a hopeless viewport — are degenerate-viewport cosmetics that trade correctly against the pinned no-clip guarantee.

UX-Verdict: PASS

Pure geometry fix: pickers now scroll inside the viewport instead of clipping past its top; identical rendering at normal viewport sizes.

[UX-REVIEWED] 45c0712

@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of 45c0712ad33d7d1633e41fb1ef5f784c1cfe5c29 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Clamping maxHeight to the chosen side's real space is the right minimal fix — estimate accuracy becomes irrelevant to clipping, no measurement machinery added.

Suggestions

  • spaceAbove is capped at the viewport for an anchor past the bottom edge, but spaceBelow (innerHeight - rect.bottom - MARGIN) has no symmetric cap for an anchor scrolled above the viewport top — an opens-below menu there gets a clamp larger than the space under top = rect.bottom + MARGIN and can still clip; one Math.min(..., innerHeight) closes the stated no-clip guarantee's last hole.

[DESIGN-REVIEWED] 45c0712

@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed 45c0712ad33d7d1633e41fb1ef5f784c1cfe5c29 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 45c0712

Verdict parsed from the review's SHA-scoped output markers for commit 45c0712ad33d7d1633e41fb1ef5f784c1cfe5c29.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 45c0712ad33d7d1633e41fb1ef5f784c1cfe5c29: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of 45c0712ad33d7d1633e41fb1ef5f784c1cfe5c29 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

All evidence gathered. The clamp lands in the shared helper all three pickers consume; the hand-rolled clamps elsewhere (MicSourceMenu.tsx:207, WorkspacePicker.tsx:90, DevFleetPage.tsx:479) predate this PR and already do their own clamping, so nothing is duplicated. One sibling of the root cause remains unclamped (HookSkillsDropdown.tsx:89-91). Here is the review:

First-Principles-Verdict: PASS

The clamp fixes the reported clip at cause level — estimate accuracy no longer matters — and every rider is declared, derived, and pinned by a test.

What this change ships

Intent: stop picker menus from extending past the viewport edge at short viewports (issue #8252, option 1). This is a FIX.

  1. Picker menus now scroll inside the space the chosen side has instead of clipping off-screen — justified (the fix; issue's worked example pinned by test).
  2. At tiny viewports the menu flips to the roomier side when the chosen side can't show one row — justified; declared; same defect class (the old code opened below into 12px and clipped 300+px).
  3. A menu never renders below one row + footer, and may overhang when no side has room — justified floor; declared, doc states the weakened guarantee honestly.
  4. An anchor scrolled past the viewport bottom caps the clamp at the viewport, not the off-screen rect — justified; declared; derived from bottom flooring at 0.
  5. The 4 gap literal becomes the MARGIN constant — rides along; mandated by the documented no-magic-values rule; trivial.

Watch

  • The root cause the description itself names ("a FIXED pixel bound … while placing against a viewport edge") has 1 counted unfixed sibling: HookSkillsDropdown.tsx:89-91 positions at rect.bottom + 4 with a constant max-h-60 and no available-space clamp (grepped maxHeight|max-h- + getBoundingClientRect across website/src; InfoTip, CommentThreadPopover, MicSourceMenu, WorkspacePicker, DevFleetPage all already clamp). Out of this PR's scope — accepted-and-deferred, not a demand.

[FIRST-PRINCIPLES-REVIEWED] 45c0712

@github-actions

github-actions Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 45c0712ad33d7d1633e41fb1ef5f784c1cfe5c29 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 45c0712

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 45c0712ad33d7d1633e41fb1ef5f784c1cfe5c29: <one-sentence reason>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 4, 2026
menuGeometry returned a constant maxHeight of MENU_MAX_HEIGHT (320), trusting the count*rowH estimate to fit. Real rows render taller than the estimate (~53px vs 48px), and since #7673 pins an opens-above menu's bottom edge, the surplus extends past the viewport TOP at short viewports instead of covering the composer.

Clamp maxHeight to the space actually available on the chosen side (above: rect.top - margin, capped at the viewport for an off-screen anchor; below: innerHeight - rect.bottom - margin), capped at MENU_MAX_HEIGHT and floored at one row + padding + extraH. The estimate still picks the side; when its side cannot show even one row and the other side is roomier, the side flips there (pure rect math, no post-mount measurement). An over-tall menu scrolls inside its container - all three pickers already apply maxHeight to an overflow-y-auto container.

Closes #8252
@CrysisDeu
CrysisDeu force-pushed the fix/picker-menu-clamp-available-height-8252 branch from fc9437a to 45c0712 Compare September 4, 2026 23:51
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 4, 2026
@NicholasRBowers
NicholasRBowers enabled auto-merge (squash) September 5, 2026 00:29

@NicholasRBowers NicholasRBowers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tier 1 auto-approve: fix (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean, security checklist all-NO, AI reviewers green. Category: fix with clear root cause — pickerMenu geometry maxHeight was unclamped to the space actually available on the chosen side, letting a menu taller than the estimate clip past the viewport; pure rect math in website/src/lib/pickerMenu.ts plus its test.

@NicholasRBowers
NicholasRBowers merged commit f1f676d into main Sep 5, 2026
64 checks passed
@NicholasRBowers
NicholasRBowers deleted the fix/picker-menu-clamp-available-height-8252 branch September 5, 2026 00:29
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 5, 2026
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.

menuGeometry's row-height estimate under-reads real rows, so the picker's above/below decision is computed from a wrong height

3 participants