feat: collapse Ask AI matched items by default#122
Merged
Conversation
Apply review feedback from /simplify: - Reuse plural() from @/lib/utils for the "+N more items" footer. - Replace imperative inert ref callback with the JSX prop pattern used by the shared Disclosure component, plus aria-hidden on the collapsed section so AT consumers don't read clipped content. - Extract isExpandable to remove the four repeated mode comparisons. - Drop the redundant data-trashed on the interactive wrapper div; the inner open button still carries it for tests and styling hooks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
relevancestring:header-only(empty bin, no pill),nav-disclosure(truncated — bin has items but the AI returned none, count pill navigates to bin detail),inline-disclosure(matched items, count pill expands inline).relevancestarts withcontains "..."anditems.length === 1— preserves the "found it" moment for single-item lookups (e.g. "where's my drill") without expanding multi-match results by default.Architecture is client-only — no server schema, wire format, or executor changes. The decision logic lives in a new
src/features/ai/matchDisplay.tshelper. The disclosure UI is a newBinDisclosurePillcomponent (button in expand mode, span in nav mode).BinGroupHeaderwas refactored to accept atrailingslot plus aninteractiveflag for split-button rendering.Notable details
grid-template-rows: 0fr ⇄ 1frCSS trick (200ms ease-out,motion-reduce:transition-none). Inner<div className="min-h-0 overflow-hidden">clips during collapse.aria-expanded+aria-controls, the<section>hasaria-label="Items in {name}"andaria-hidden={!expanded}, and collapsed contents are excluded from the tab order viainert.min-h-[44px] min-w-[44px]per WCAG 2.5.5.useStateperBinItemGroupinstance; turns are keyed bymatch.bin_idinItemQueryResults, so new questions correctly reset state.Test plan
npx vitest run— 170 files / 1711 tests passnpx tsc --noEmit— cleannpx biome checkon changed files — cleannpx vite build— succeedsnpm run dev:all):N items ▾pillprefers-reduced-motion: reduce→ instant expand/collapseFiles
New:
src/features/ai/matchDisplay.ts(+ tests)src/features/ai/BinDisclosurePill.tsx(+ tests)Modified:
src/features/ai/BinGroupHeader.tsx(+ tests) — addstrailingslot andinteractivesplit modesrc/features/ai/BinItemGroup.tsx(+ tests) — wires the helpers, owns expand statesrc/features/ai/__tests__/AiTurnQueryResult.test.tsx— adds mixed-mode integration testsrc/features/ai/__tests__/QueryAnswerBody.test.tsx— fixture updated so item-name assertions remain meaningful with the new collapse default