fix(app-shell): command palette idempotent open + locators (ADR-0054 Phase 1)#1879
Merged
Conversation
…Phase 1)
The top-bar "Search… ⌘K" button did not open the command palette under
automation: it re-emitted a synthetic ⌘K KeyboardEvent and relied on
CommandPalette's global listener being mounted and the browser not reserving
⌘K. The open path was also a non-idempotent toggle (`setOpen(p => !p)`) and the
open state lived only in component `useState`.
Implements ADR-0054 invariants C1/C3/C4 for the command palette (Phase 1, the
reference fix):
- C1 (idempotent, direct triggers): new `CommandPaletteProvider` /
`useCommandPalette()` owns the open state and a shared idempotent
`openCommandPalette()` (`setOpen(true)`). The header search buttons call it
directly — the synthetic `dispatchEvent(new KeyboardEvent(...))` is deleted.
⌘K stays an accelerator and may toggle (close-on-repeat); the OPEN path used
by buttons/links/programmatic callers is idempotent.
- C3 (URL-addressable state): open state is the `?palette=1` search param
(`?cmdk=1` alias on read), so the palette is deep-linkable, restores on
reload, and works with back/forward.
- C4 (stable locators): the dialog carries
`data-testid="overlay:command-palette"` + an ARIA name; the trigger carries
`data-testid="action:command-palette:open"` (`:open-mobile` for the compact
header). `CommandDialog` gains a `contentProps` passthrough so the locator/ARIA
land on the underlying dialog element.
Also adds `useRecordSearch` unit tests covering the `$search` query path
(trimmed query, exact `{ $search, $top }` payload, re-fire on query change) and
documents the palette's testability contract in the app-shell README.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Radix `DialogContent` requires a `DialogTitle` for an accessible name; the palette previously rendered none (console error + no SR name). `CommandDialog` now renders a visually-hidden `DialogTitle` (default "Command Palette", overridable) and an optional `DialogDescription`, so every CommandDialog is screen-reader accessible by construction (ADR-0054 C4). CommandPalette passes the translated title + placeholder; the redundant `aria-label` is dropped (the DialogTitle now provides the name via `aria-labelledby`). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
This was referenced Jun 22, 2026
feat(app-shell): useUrlOverlay primitive + URL-addressable shortcuts dialog (ADR-0054 Phase 2)
#1882
Merged
xuyushun441-sys
added a commit
that referenced
this pull request
Jun 22, 2026
…ADR-0054 Phase 5) (#1890) Locks in the testability contract so it can't regress ("counts can only go down"). - **Conformance test** (`adr0054-ratchet.test.ts`, runs in the gating `pnpm test` job): fails the build if a new synthetic-event trigger (`dispatchEvent(new KeyboardEvent/MouseEvent/PointerEvent)`) appears anywhere in `packages/*/src` or `apps/*/src`. Legitimate `CustomEvent`/`PopStateEvent` dispatch (event bus / history nudge) stays allowed. - **Local ESLint rule** `object-ui/no-synthetic-event-trigger` flags the same pattern in-editor (the repo `Lint` workflow is manual `workflow_dispatch`, so the test — not lint — is the CI gate). Plain-JS RuleTester unit test. - **Last two offenders fixed**: the sidebar swipe-to-open gestures (`UnifiedSidebar`, `AppSidebar`) dispatched a synthetic click on the trigger; now call the idempotent `setOpenMobile(true)` directly (C1). Tree is clean at zero. - Docs: README "Testability ratchet" section; ADR-0054 marked all five phases shipped. Completes the ADR-0054 rollout (Phases 1 #1879, 2 #1882, 3 #1883, 4 #1887, 5). Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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.
What & why
ADR-0054 "UI testability contract" — Phase 1 (the reference fix). The top-bar "Search… ⌘K" button did not open the command palette under automation: it re-emitted a synthetic
⌘KKeyboardEventand relied onCommandPalette's global listener being mounted and the browser not reserving⌘K. The open path was also a non-idempotenttoggleand open state lived only inuseState(not URL-addressable).This makes the palette deterministic for AI browser testing by fixing the shared primitive — every generated app inherits it.
Changes (invariants C1 / C3 / C4)
CommandPaletteProvider/useCommandPalette()owns open state and a shared idempotentopenCommandPalette()(setOpen(true)). The header search buttons call it directly; the syntheticdispatchEvent(new KeyboardEvent(...))is deleted.⌘Kstays a keyboard accelerator (may toggle for close-on-repeat); the OPEN path used by buttons/links/programmatic callers is idempotent.?palette=1search param (?cmdk=1alias on read) → deep-linkable, restores on reload, works with back/forward.data-testid="overlay:command-palette"+ a visually-hidden RadixDialogTitle(accessiblerole="dialog"/name). Trigger:data-testid="action:command-palette:open"(:open-mobilefor the compact header).CommandDialoggainscontentProps(forward a locator onto the dialog element) andtitle/description(accessible-by-construction).useRecordSearchunit tests for the$searchquery path (trimmed query, exact{ $search, $top }payload, re-fire on query change).Verification (browser, agent-browser / CDP-real keystrokes)
Worktree console (
packages/*/srcvia HMR) on:5182→ frameworkapp-showcasebackend on:3000:?palette=1).$searchfan-out to the backend (/api/v1/data/showcase_*?top=3&search=…, all 200) → "Records" group renders real hits.?palette=1(and legacy?cmdk=1) open the palette on fresh page load.⌘Ktoggles, Escape closes + clears the URL param, no Radix dialog a11y errors.Unit/type:
@object-ui/{i18n,components,react,app-shell}test suites green;tscbuild green for touched packages.🤖 Generated with Claude Code