Repository navigation
Description
Context
ui-react calls useMediaQuery 23 times (useMediaQuery, packages/ui-react/src/hooks/use-media-query.ts:10). Twenty of those calls change what renders: which tree mounts, an overlay variant, focus routing, or a capability. They stay JavaScript:
chat-page.tsx:145,149handoff-sheet.tsx:88graph-scene.tsx:84,682graph-page.tsx:50,51,218graph-controls.tsx:34desktop-palette.tsx:49settings-panel.tsx:52file-panel.tsx:43activity-page.tsx:72composer-view.tsx:132dictation-sheet.tsx:20side-rail.tsx:59session-list.tsx:119use-color-scheme.ts:19use-fine-pointer.ts:14storage-tab.tsx:48: an overlay variant viastorage-dialogs.tsx:50,214, plus a number thatStorageMaplays out with
Three calls change only a size or a CSS class. Each costs a subscription and a re-render, and each answers the wrong question or answers in the wrong layer:
StatsAnswer(wide,packages/ui-react/src/components/chat/stats/stats-answer.tsx:18) picksBarList'sbarWidth120 or 56 (stats-answer.tsx:60). The comment says the choice is about the room the answer's column has, but the code asks for the viewport. The answer renders inside the chat column next to the rail and the sessions pane, so it should ask its container.ConversationStrip(shortScreen,packages/ui-react/src/components/voice/conversation-strip.tsx:13) only switches one row's height between 44 and 52 (conversation-strip.tsx:60).ComposerRow(shortScreen,packages/ui-react/src/components/chat/composer-row.tsx:66) only adds a class that hides two rows (composer-row.tsx:70-78).
Items 2 and 3 really are about viewport height, so they become CSS @media (max-height: 580px) rules, not container queries.
The kit already uses size container queries (packages/ui-kit/src/tokens.css:2012, :2188, :2318, :2330). BarList takes its track width only as an inline pixel number (trackStyle, packages/ui-kit/src/evidence/BarList.tsx:82-83), and a stylesheet cannot override that.
Guide css/size-aware-styling: "Using container queries is recommended because it makes components truly modular. You do not need to know where the component will live". Support for size container queries: Chrome 105, Firefox 110, all targets.
Scope
BarListreads its track width from a CSS custom property, withbarWidthas the fallback:width: var(--bk-bar-track, <barWidth>px). The prop keeps its meaning for every existing caller.StatsAnswermakes its root aninline-sizecontainer and sets--bk-bar-track: 120pxinside an@containerrule. Pick the threshold so that every existing stats layout and visual baseline keeps its current bar width. Drop the hook.ConversationStripandComposerRowdropuseMediaQuery. The 44/52 height and the hidden rows move to@media (max-height: 580px)rules keyed on the existing data attributes (data-conversation-strip,data-session-strip,data-pending-follow-ups). ThevoiceActive && voiceReviewconditions stay as data attributes or classes that React sets.
Out of scope
- The 20 calls listed above as staying JavaScript, including
storage-tab.tsx'sResizeObserver(storage-tab.tsx:56-67), which feeds pixel sizes toStorageMap's layout. session-list.tsx:119(any-pointer: coarse). That is a pointer query, not a size query.- Changing any breakpoint value or any rendered size.
- Removing
useMediaQuery.
Acceptance criteria
-
git grep -n useMediaQuery -- packages/ui-react/src/components/chat/stats packages/ui-react/src/components/voice/conversation-strip.tsx packages/ui-react/src/components/chat/composer-row.tsxreturns nothing, and the total call count drops from 23 to 20. - A real-browser layout test fails before the change and passes after. It mounts
StatsAnswerin a 360px-wide container inside a 1280px-wide viewport and asserts a 56px bar track. Today the viewport query gives 120. - A real-browser layout test at 390×560, with voice review active, asserts that the strip's control row is 44px and the session strip is hidden. At 390×844 it asserts 52px and visible. It passes before and after, because behaviour is preserved.
-
bun run visualand the stats layout tests show no baseline change.
Verification
node scripts/visual.mjs --project=ui-react-layout --filter=<stats-and-strip-tests>
node scripts/visual.mjs --project=storybook --filter=BarList.stories
bun run visual
bun run test
bun run typecheck
bun run lintContract impact
- This touches the integration contract, so it needs the
contractlabel, aCONTRACT:commit prefix, and the doc updated in the same commit. - This changes a published package's behaviour, so it needs a changeset.
BarList gains an additive, optional custom-property hook. Kit component props are not listed in docs/integration-contract/package-api.md.
Activity