Repository navigation
Cmdk binding - #210
Cmdk binding#210
Conversation
A faithful port of [email protected] (dip/cmdk) onto the octane renderer: the full Command namespace (Command/Root, Input, List, Item, Group, Separator, Dialog, Empty, Loading), useCommandState, and defaultFilter, with the DOM-authoritative store, item/group registration, textContent value inference, onInput-driven search, score filtering + DOM sort, keyboard navigation (arrows/Home/End/vim/ Enter), controlled value/loop/shouldFilter/custom filter, a radix-backed Command.Dialog, and SSR + hydration. Authored in idiomatic .tsrx and split into focused modules (barrel + components/, hooks.tsrx, context.tsrx, lib/) with a single .tsrx.d.ts sidecar. Covered by 26 behavioral + hydration + SSR tests. Octane divergences (documented in status.json / the file header): ref-as-prop (no forwardRef); native onInput instead of synthetic onChange; value inferred from the value prop or rendered textContent (opaque compiled children); sort() reorders only surviving items so hydrated unmounts don't orphan moved nodes; asChild is unsupported (SlottableWithNestedChildren has no faithful equivalent). Registers the package across the workspace: catalog + lockfile, the typecheck tsgo entry, cmdk + cmdk-ssr vitest projects, the MCP bridge, website bindings list + llms.txt, and the generated docs (packages.md, bindings-status.md, binding-parity-gaps.md), rulesync outputs, and evals corpus. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Integrate the latest upstream (6 commits: self-contained TanStack Start, SSR livelock fix, native-change timing, SSR/TTFB + tanstack-com benchmarks, and the Version Packages release) while preserving the @octanejs/cmdk port. Conflict resolution: - package.json: union of upstream's tanstack-start/typetests tsgo entry and the cmdk tsgo entry. - pnpm-lock.yaml: took upstream, then pnpm install re-reconciled cmdk. - Generated files regenerated (not hand-edited): docs/packages.md, docs/bindings-status.md, docs/binding-parity-gaps.md, the evals corpus manifest/training, and the rulesync targets. - website/src/routes/* and routeTree.gen.ts: took upstream's versions (the branch made no intentional route changes; upstream owns the @tanstack/octane-router -> @octanejs/tanstack-router migration). Verified: packages/cmdk + docs/cmdk-port-plan.md are byte-identical to the pre-merge commit (ec07498); cmdk tsrx-tsc/tsgo clean; 26/26 cmdk tests pass; repo-wide format:check clean; bindings/inventory/rules/parity-gaps/markers OK. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
@mrdiyorbek-juraev is attempting to deploy a commit to the Ripple Team Team on Vercel. A member of the Team first needs to authorize it. |
|
Took a deeper pass through the port. Really solid overall - it reads very close to upstream and the registration is complete. A few things need fixing before this lands though: 1. Group value registration is broken (the big one). Octane compiles custom-hook calls as 2. status.json contradicts itself. 3. 4. The batcher's 5. Phases 1-3 exit criteria are differential parity, but there's no Happy to re-review once 1-3 are in. |
Taking a look |
Group value registration was broken: octane compiles a custom-hook call as
withSlot(sym, hook, ...args, sym), so Group's 3-arg useValue() put that trailing
slot symbol into the `aliases` parameter (`= []` only defaults on undefined) and
aliases.map threw every render — aborting registration before context.value and
setAttribute ran. Groups therefore had no data-value at all, while every test
stayed green. Pass `aliases` explicitly and harden the read; add a console-noise
guard so an exception raised inside an effect fails the test that caused it.
Also fixes, from the same review:
- Group reordering resolved each group by `[data-value="<groupId>"]`, which can
never match (data-value holds the heading text) — upstream's group sort is
dead code. Resolve the id to its registered value so groups reorder by score.
- status.json contradicted itself (surface said SSR was uncovered while ssr said
supported), `verified` predated the work, notes still said "port in progress",
and the README claimed only the scorer shipped. All corrected.
- `--cmdk-list-height` was never implemented; port upstream's ResizeObserver,
guarded for hosts without one (SSR/jsdom) and recorded in status.json.
- The scheduler's bare `catch {}` swallowed user callbacks (a throwing
onValueChange vanished) and masked a jsdom scrollIntoView throw. Guard
scrollIntoView at its source and report failures instead of discarding them,
keeping sibling isolation.
Adds the differential suite (tests/differential) running the same fixtures
through @octanejs/cmdk and published [email protected], which immediately surfaced four
divergences: the `radix-` id prefix (now matched), aria-activedescendant on
flush-driven selections, group ordering, and DOM order not being restored when a
search is cleared. All recorded in status.json. `normaliseHtml` is exported from
the shared rig so documented divergences can be compared byte-for-byte minus a
single attribute.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Brings in 5 upstream commits: the safe inline-script content contract (octanejs#215), the tanstack.com shell port (octanejs#214), the TSRX directive arm output docs (octanejs#213), the inline hook-memo tier (octanejs#208), and the website menu / scroll-spy work (octanejs#209). Upstream added three bindings (tanstack-router-ssr-query, tanstack-hotkeys, tanstack-pacer), taking the table to 39. Six conflicts, all resolved as unions so neither side lost content: - website/src/content/bindings.json — @octanejs/cmdk listed alongside upstream's three new bindings; the "UI and interaction" description keeps command menus and gains keyboard shortcuts and event pacing. - website/public/llms.txt — same union in prose form. - docs/bindings-status.md, docs/packages.md, docs/binding-parity-gaps.md and the evals user-apps-v1 manifest are generated, so they were taken from upstream and regenerated (39 bindings, 48 publishable packages, 0 parity pins, 19 eval tasks). packages/cmdk is byte-identical to its pre-merge state; upstream's compiler changes do not perturb it. Verified: 32/32 cmdk and cmdk-ssr tests including both differential parity checks against [email protected], tsrx-tsc and tsgo clean, prettier clean, and all five freshness gates current. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Registering a changed item value during an active search scored that item into `filtered.items` but left `filtered.count` and `filtered.groups` describing the previous values. Those two drive `Command.Empty` and group visibility, so an item that started matching rendered while "no results" was still on screen, and its group could stay hidden. Re-derive the aggregate by calling filterItems() before sort() in the scheduled callback. filterItems() is the single place count, groups, and item scores are derived, so reusing it keeps them from drifting apart; the batcher already collapses a burst of value changes into one flush, so this is one O(items) pass per flush — the same work item registration does. [email protected] has the identical gap: its `value` path runs only sort(), while its own item-registration path runs filterItems() then sort(), so the omission reads as an oversight rather than intent. Recorded as a divergence and the bindings-status table regenerated. The regression test fails without the fix (Empty renders alongside the matching item) and covers group visibility on the same path. Co-Authored-By: Claude Opus 4.8 <[email protected]>
A QA pass found three ways the empty state could contradict what is on screen, plus a slow memory leak. All four are inherited from [email protected] rather than introduced by the port, so each is recorded as a divergence. - forceMount items are now counted. Upstream skips registration entirely for a force-mounted item, so it never reaches `filtered.count` and a search matching nothing renders the item and "no results" on top of each other. Tracked in a separate `forceMountedCount` so `filtered.count` keeps its upstream meaning for `useCommandState`. - Command.Empty renders nothing during SSR. Items register in layout effects, which never run on the server, so the count is unavoidably 0 there and every server-rendered page shipped "No results found." above a full list — permanently so without JavaScript. Empty subscribes to the store directly rather than through useCmdk: a server snapshot passed to a base hook from inside a custom .tsrx hook does not reach the SSR runtime. The hydration fixture is regenerated from real renderToString output, which no longer contains the empty state. - An item leaving a group is removed from that group's member set. Upstream never removes it, so a group accumulates dead ids for the Command's lifetime. No test can observe this — dead ids score 0, so there is no behavioural difference, only memory — and it rests on code review rather than coverage. - Duplicate item values are reported in development. Selection is keyed by value, so two items sharing one both render aria-selected while only the first responds to Enter. The runtime cannot pick a winner, so it warns rather than silently emitting an invalid single-select listbox. The console.error guard moves to tests/_setup.ts so hydration, SSR and differential runs are covered too, not just the behavioural suite — a suite-wide gap that previously let a per-render TypeError survive six green runs. Verified by injecting an error into the SSR suite. New coverage for the untested props that let the forceMount bug through: forceMount both directions, duplicate values, keywords, shouldFilter, defaultValue, disabled-item skip, and clearing the search (which pins the documented residual-order divergence in both directions). Docs corrected: status.json advertised a `Command.Root` that exists in neither the port nor upstream, and both it and the README still claimed no differential suite existed and that Radix Primitive/Slot were used. Verified: 42/42 cmdk + cmdk-ssr, 40/40 under the production compile (hmr: false), tsrx-tsc, tsgo, prettier and all freshness gates clean. Each fix was confirmed load-bearing by reverting it and watching the test fail, except the group-set cleanup as noted above. Co-Authored-By: Claude Opus 4.8 <[email protected]>
WebEferen
left a comment
There was a problem hiding this comment.
For now it crashes on the playground. @mrdiyorbek-juraev is working on to fix it
cmdk's sort is DOM-authoritative: it puts matches in score order by
physically relocating item nodes. React tolerates that because it
re-parents the nodes it owns on the next render. Octane instead fences
each component's DOM between a pair of comment markers and tracks the
range between them, so appending the element on its own stranded it
outside its own markers — the runtime's bookkeeping then described a
range that no longer held the node, and the next update or teardown ran
off stale references:
TypeError: Cannot read properties of undefined (reading 'm')
at unmountScope / runEffectLifecycleCallback
NotFoundError: Failed to execute 'insertBefore' on 'Node'
Reproduced by typing into the input and clearing it: the search relocates
items, narrowing unmounts them, and clearing remounts them. Bisection
pinned it to the relocation itself — disabling sort() entirely was clean,
disabling only the group reorder was not, and a search whose winning
group was already last never crashed.
Move each node together with the comment markers flanking it so the range
stays intact. This does couple the port to how octane fences a component;
there is no public API for relocating a range, so it is the narrowest
thing that works, and the durable fix belongs upstream — either a
supported relocate primitive or a teardown that tolerates externally
moved nodes. Any library that reorders DOM imperatively will hit this.
Also links the package into the playground with a demo covering items,
groups, separators, forceMount, loop and the dialog, so the behaviour can
be exercised by hand.
Brings in 12 upstream commits, including the shared TSRX semantic analysis across client/server/universal/Volar compilation (octanejs#230), the deferred hydration fix (octanejs#229), Lynx Milestone 7 worklets (octanejs#227), template-free production hydration (octanejs#218), and the dependency/TSRX toolchain refresh (octanejs#223) with the release that followed it. Two conflicts, both in generated files, resolved by taking upstream and regenerating from the merged tree: - docs/packages.md — 47 publishable packages upstream, 48 here. Verified as a strict superset: every package upstream lists is still present, and the only additions are `@octanejs/cmdk` and `packages/cmdk`. - packages/octane-evals/.../manifest.jsonl — all 19 task ids match upstream, and a field-level comparison shows only environment.overlayLockfileHash and grader.graderDigest differ. No prompt, policy, reference or grader command changed, so task semantics are untouched; both fields derive from the lockfile, which necessarily moved. pnpm install also rewrote pnpm-workspace.yaml as a side effect — it flattened upstream's `*esrap_common` YAML anchor and appended [email protected] to minimumReleaseAgeExclude. Both are reverted, so the file differs from upstream by exactly one line: the `cmdk: 1.1.1` catalog pin this package needs. packages/cmdk is unchanged apart from one comparator re-wrapped by the refreshed prettier; the whitespace-only diff is the entire delta. Verified: 43/43 cmdk and cmdk-ssr against the new compiler, 48/48 evals (including the corpus freshness gate), tsrx-tsc, tsgo, prettier, and all five generated-artifact gates current.
`[email protected]` is our own published package, resolved from the registry as an optional peer of `@tsrx/[email protected]`. It was published today, so `pnpm install --frozen-lockfile` rejected the lockfile: [ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION] 1 lockfile entries failed verification: [email protected] was published at 2026-07-22T09:29:59.000Z, within the minimumReleaseAge cutoff The lockfile is neither stale nor bypassed — every other optional peer of that same plugin (`@tsrx/react`, `@tsrx/ripple`, `@tsrx/solid`, and the plugin itself) is already excluded; `[email protected]` is the one that postdates the last curation of the list. Verified both ways: without this entry the check fails as above, with it `pnpm install --frozen-lockfile` reports the lockfile passes all 2065 entries. No `pnpm-lock.yaml` change, so the evals corpus does not need regenerating.
…unts quiet
Three defects, all on the item/group removal path, which had no test coverage —
the committed suite only ever removed items via the filter (where the Item
itself renders null) or by unmounting the whole Command.
1. Registration teardowns reported a cross-render update.
Octane runs a removed child's effect cleanups DURING the parent's render
(renderBranchSlot -> unmountBlock -> unmountScope -> runEffectCleanupCallback),
so scheduling follow-up work straight from a teardown landed its state update
mid-render and the runtime reported:
Cannot update a component (`CommandRoot`) while rendering a different
component (`__children$N`). Move the update out of the rendering component
body.
Advice a teardown cannot act on, since it does not choose when it runs.
Reproduced on all three registration paths (plain item, force-mounted item,
group) and on a realistic result list shrinking. Behaviour was correct
throughout — Empty appeared, selection advanced, aria-activedescendant
followed — but the message reached every consumer's console on the most
ordinary interaction a command menu has, and tests/_setup.ts treats a
console.error as a failure.
Teardowns now hop a microtask before scheduling (scheduleFromTeardown).
Only the teardowns defer: every other caller schedules from a layout effect,
where the synchronous update is load-bearing (the search -> filter ->
select-first chain has to settle inside one commit). Verified the deferral
changes only the diagnostic — the same fixtures produce byte-identical
behaviour logs against the pre-fix source. React has no equivalent problem
because it runs cleanups in the commit phase.
2. Only the plain-item teardown released the value it registered.
Items, force-mounted items and groups all register through the same
useValue, but forceItem's and group's teardowns never decremented the
dev-only owner count, and forceItem never cleared `ids`/`filtered.items` at
all. Re-showing a force-mounted item therefore counted its value again each
time and blamed the author for code holding exactly one live item with it:
[@octanejs/cmdk] 2 items share the value "Always visible (forceMount)"...
[@octanejs/cmdk] 3 items share the value "Always visible (forceMount)"...
plus unbounded growth of `ids`/`filtered.items` for the Command's lifetime.
All three paths now release through one `releaseValue` helper.
3. Removing the selected force-mounted item left nothing selected.
Pre-existing, and surfaced by the regression test written for (1). The value
kept pointing at a removed node, so nothing rendered aria-selected, the
combobox's aria-activedescendant dangled at a removed id, and Enter did
nothing until the user arrowed away. The force-mount teardown now re-selects
the same way the plain item teardown does. Upstream cannot have this bug
because it never registers force-mounted items — which is also why it cannot
fix it.
Tests: six added, each with a proven pre-fix failure — the three removal paths,
an async result set exercising Empty and selection handoff plus
aria-activedescendant, and the two duplicate-value repros matching the
playground's forceMount toggle.
Gates: cmdk + cmdk-ssr 49/49 (was 43), prod compile (hmr: false) 37/37,
typecheck clean, format:check clean, docs/bindings-status.md regenerated.
Reported in review. sort() reordered group hosts by score with a plain
`appendChild`, while item reordering already used `moveWithMarkers` so octane's
comment-marker ranges stay aligned with the DOM. A Group is a component too, so
relocating its host without its flanking markers stranded it outside its own
fence.
It surfaced not as a thrown error but as a silent orphan: when a relocated
group later unmounted, the runtime removed the heading and items it still
tracked and left the host behind.
<div cmdk-group="" role="presentation" data-value="Beta">
<div cmdk-group-items="" role="group" aria-labelledby="radix-:r0-in-4:"></div>
</div>
That is a visible empty block for anyone styling `[cmdk-group]`, a `role="group"`
inside the listbox whose `aria-labelledby` points at a removed id, and a ghost
that keeps its `data-value` — so the group lookup in sort() can match the dead
node instead of a live group of the same name. The shells accumulate as groups
churn.
The earlier QA pass tried this and cleared it, but only ever reordered groups
and then cleared the search or unmounted the whole Command — never removed an
individual relocated group, which is the transition that strands one.
Regression test: reorder three groups by score, remove one that sort() moved,
assert the host is gone rather than left as an empty shell. Pre-fix it reports
['Alpha', 'Gamma', undefined].
Gates: cmdk + cmdk-ssr 50/50, prod compile 38/38, typecheck clean,
format:check clean.
Resolves pnpm-workspace.yaml minimumReleaseAgeExclude in favor of upstream's bumped @tsrx/* pins (catalog already at ^0.1.47/^0.3.109), reconciles pnpm-lock.yaml via pnpm install on upstream's base, and regenerates the octane-evals corpus from the merged lockfile. Co-Authored-By: Claude Fable 5 <[email protected]>
Per maintainer review: resolve radix from the registry at a fixed release rather than linking the workspace source. The published package ships raw sources, so cmdk's suites still compile it through the same toolchain; the octane peer still resolves to the workspace runtime. Evals corpus regenerated for the lockfile change.
Resolves the root package.json typecheck script as the union of both sides (upstream's lynx:demo:typecheck step plus this branch's packages/cmdk entry), reconciles pnpm-lock.yaml via pnpm install, and regenerates the octane-evals corpus from the merged lockfile.
Brings in the consumer build contracts, Redact scheduler coverage, and the immutable-AST compiler conversion. Sole conflict was the generated evals manifest — resolved by reconciling the lockfile via pnpm install and regenerating the corpus. Validated post-merge: cmdk suite 50/50 against the new compiler internals, package typecheck, repo-wide format check.
|
had claude dig into this and impirically verify: Branch: VerdictThe engineering craft here is high — the comment quality is the best of any binding in But the suite is green because of what the fixtures pass, not because the behaviour is I'd hold the merge for F1 and F2. F3/F5 are quick fixes. The rest is polish. Gates I re-ran (all pass, as claimed)
F1 — Blocking: an item mounted while a search is active is permanently invisibleAn item added to a live menu never renders unless it carries an explicit Typing further makes it worse — narrowing Root cause — a genuine deadlock
Upstream cannot hit this: its Why the suite misses itThe only two fixtures with a changing item set both hand the port a value: Smallest correct fixTreat unregistered as visible rather than as score 0 — an item that has never been scored // item.tsrx, the render selector
: !s.search ? true
: s.filtered.items.has(id) ? (s.filtered.items.get(id) ?? 0) > 0 : trueIt renders once, F2 — High:
|
…per item Three defects from review, all of which the suite passed over because the fixtures happened to avoid the shapes that trigger them. 1. An item mounted while a search was active never rendered unless it carried an explicit `value`. Unscored was treated as scored-zero, which deadlocks: the item renders null, so `ref.current` stays null, so `useValue` has no textContent to infer from, so it registers empty and scores zero forever. Upstream cannot reach this — it reads the value out of `props.children` synchronously, while octane's compiled children are opaque, so the first render IS the registration. Unscored items now render once so that pass can happen. Every upstream cmdk example omits `value`; both existing async fixtures passed one, which is why this was invisible. 2. Ranking moved DOM nodes, which orphans them. A `@for` iteration wraps each item in a SECOND comment-fenced range on top of the component's own, so relocating a node carried it out of both: the loop later cleared an empty range and the real node survived in the list forever — every item stacked above "No results found.". `moveWithMarkers` only ever repaired the innermost range, so it broke again at each nesting construct. Ranking is now CSS `order` inside a flex container. Nothing moves, so no range can be violated, and clearing the search restores true source order because the styles are simply dropped — the physical reordering left a residue that accumulated across searches and never recovered. `getValidItems()` had to follow: it returned DOM order, which WAS the ranking while nodes moved. Left alone, selection and arrow keys would have navigated in source order behind a differently-ordered list. It now descends the ranked containers, with the flat query kept as a fast path for when no filter is active and DOM order already is visual order. 3. Removing the selected item alongside any sibling left nothing selected. All item teardowns scheduled under one batcher key, and the batcher is a Map, so the last teardown overwrote the rest and the surviving callback had captured a different `selectedItem`. Keyed per item now. The force-mount path also used one key for both its mount emit and its teardown re-select, so a mount and a removal in the same pass cancelled each other. Two tests were pinning bugs as contracts: `restores every item when the search is cleared` asserted the scrambled residue, and the differential's `clearing restores every item` documented it as a divergence from React. Both now assert parity, and that differential checkpoint compares the whole tree instead of a few hand-picked values. The filtering checkpoints strip only the three ranking declarations, so every other attribute and node still compares byte-for-byte. status.json divergence [3] rewritten for the ranking model; [4], which described the residual-order bug, is gone.
Nineteen conflicts. Every derived artifact was regenerated rather than hand-merged; the rest were unions, except where upstream deliberately removed what this branch had edited. Unions: - pnpm-workspace.yaml — kept both catalog entries (cmdk, tailwind-merge). - playground/octane/package.json — both dependency sets. - playground/octane/src/App.tsrx — both demos' imports (the body already auto-merged), and vite.config.ts's optimizeDeps exclude list. - website/src/content/bindings.json and website/public/llms.txt — both @octanejs/cmdk and @octanejs/shadcn, which landed upstream in this range. Superseded by upstream: - .rulesync/rules/project.md — the "rightsize the agent context surface" rewrite drops the binding enumeration this branch had added `cmdk` to; the inventory now lives in the generated docs/packages.md. - package.json — upstream restructured `typecheck` around a new `bindings:typecheck` step, so took theirs and re-inserted the cmdk entry in its original slot after sonner. Needed care: - playground/octane/index.html — upstream deleted the inline <style> block wholesale (playground chrome moved to CSS files), and this branch had edited that same block. Taking theirs alone would have silently dropped every cmdk demo style, so the `cmdk-*` rules were re-homed in playground/octane/src/styles/playground.css and translated from the old hard-coded palette to the shadcn tokens that file already uses (--fg/--panel/--accent/--muted → --foreground/--card/--primary/ --muted-foreground, the two rgba() values → color-mix, radii → the --radius scale). Regenerated: the five RuleSync targets, docs/packages.md, docs/bindings-status.md (41 bindings), docs/binding-parity-gaps.md, the user-app corpus manifest, and pnpm-lock.yaml — the lockfile re-resolved from the merged manifests so it carries both the packages/cmdk importer and upstream's packages/shadcn. `pnpm install` also refreshed the minimumReleaseAgeExclude pin from [email protected] to @0.1.16, which enters as a peer of @tsrx/typescript-plugin. Verified after the merge: cmdk + cmdk-ssr 53/53, cmdk typecheck clean, format:check clean, and rules/inventory/parity-gaps/bindings-status/changeset/ test-markers/tsrx-decls/context-budget checks all green.
The merge brought in the repo-wide rule that every sibling edge must be `workspace:*` (validateWorkspacePackages, gated by packages:inventory:check), which supersedes the earlier decision to pin @octanejs/radix to the published 0.1.12. Keeping the pin now fails that gate.
…id item Two consequences of moving ranking from DOM relocation to CSS `order`, both found in review. Group navigation still walked `nextElementSibling` and took each candidate's first item with `querySelector`, which are DOM-ordered. Under an active filter that disagrees with what is on screen, so alt+arrow could land on the wrong group. A two-group menu hides it — the item-level fallback happens to give the right answer when the sibling walk runs off the end — so the regression test uses three groups whose ranked order interleaves with their source order (Apple 0.9899 > Snap 0.1700 > Grape 0.1683 for "ap"), where the DOM-next group exists but is the wrong one. Pre-fix it selected Grape instead of Snap. Ranking also covered only the matches. An unranked flex child keeps the initial `order` of 0, which sorts it AHEAD of every ranked match rather than out of the way, so a force-mounted item — the one item that never scores and never unmounts — jumped to the top of its container whenever the search did not match it. Every valid item is ranked now, which puts zero-scoring items last, where upstream's append-in-score-order leaves them too. That exposed an older defect underneath. Force-mounted items and groups register their value through the same `useValue` hook as items, so `context.value` writes them a filter score — computed against whatever the search was at registration time, and never refreshed, because `filterItems()` walks `allItems`, which holds neither. A force-mounted item registered before the user typed kept `commandScore(value, '')` — 0.99, higher than a genuine prefix match — for the rest of its life. `filterItems()` now prunes scores for ids it does not own. `lib/dom.ts` was the sibling walk's only home and has no callers left, so it goes with it.
…paces disjoint Self-audit of the CSS-order ranking, after the review flagged the first of these. All three are the same root shape: an unranked flex child keeps `order: 0`, which sorts it AHEAD of every ranked one rather than out of the way, so anything the ranking fails to reach jumps to the top of its container. - Ungrouped items were numbered by their GLOBAL rank among all items while group hosts continued from a count of ungrouped items only. The two spaces overlap as soon as a grouped item outranks an ungrouped one: the ungrouped item's number skips ahead and can tie a group host, leaving sizer siblings to paint in DOM order. Sizer children are numbered densely now, so the group ranks that follow them stay disjoint. - `positionedNode` resolved one wrapper level, and only inside a group (`closest(GROUP_ITEMS > *)`). An item wrapped directly under the list therefore resolved to nothing and never got a rank, so its wrapper — the actual flex child — paints first. It now walks up to the container's direct child at any depth. Upstream resolves a single level too, but its appendChild model tolerates that: a node it cannot resolve simply is not moved, whereas here it is promoted to the top. - Group hosts had the same gap and now rank through their positioned node, and `getOrderedGroups` reads the rank from that node rather than the host, or a wrapped group would read 0 and collapse alt+arrow navigation back to DOM order. Regression tests cover a group whose item outranks an ungrouped sibling, and an item wrapped in a plain element under the list. Both selected the wrong element before the fix.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.
Reviewed by Cursor Bugbot for commit 0cb1231. Configure here.
MERGE — one conflict, in playground/octane/src/App.tsrx. Upstream's cmdk PR (octanejs#210) added a Command menu demo to the flat nav this branch replaces. Resolved to the sidebar shell, but taking it wholesale would have DROPPED the new demo: the shell reads from catalog.ts, not from the switch statement upstream edited. Registered it there instead, so the entry survives and gains a source view. AUDIT — the review flagged the first of these; the rest came from looking for its siblings. 1. Selecting a demo left the mobile sidebar open. Below the breakpoint the nav is a Sheet laid OVER the stage, so a selection that only changed the route left the sheet covering the demo it had just selected. It now closes the sheet on select, on mobile only. 2. `[data-slot='sidebar-menu-button']` was styled globally, reaching into a vendored component's internals from app CSS. No live bug — this app has one sidebar — but it would silently restyle any future one. Scoped to `.demo-sidebar`. 3. `collapsible="icon"` promises an icon rail, and these entries are text-only, so there was no icon to collapse to. It behaved as offcanvas regardless; now it says so. 4. An unresolvable route rendered the fallback demo while the URL kept the bad id, so sharing the link again propagated a route that does not exist. The URL is now rewritten to match what rendered. Verified against the production build in headless Chromium: the mobile sheet closes on select, deep links resolve, nav clicks update the URL, Cmd+B collapses, search filters, the merged cmdk demo renders with its source, and the console is clean.

Summary
@octanejs/cmdk, the[email protected]command menu ported to octane: the fullCommandnamespace,useCommandState, the vendored scorer, andCommand.Dialogover@octanejs/radix.orderrather than by relocating DOM nodes, which is what upstream does and what octane's comment-fenced ranges cannot tolerate.Why
cmdk is DOM-authoritative: it hides items by unmounting them and ranks matches by physically
appendChild-ing nodes into the list. Octane fences every component's DOM with comment markers and tracks the range between them, and a template construct like@foror@ifwraps each item in a second, outer range. That seam is where the port's real bugs lived:An item mounted while a search was active never rendered unless it carried an explicit
value— the single most common real-world flow, since results arrive while the user types. Unscored was treated as scored-zero, which deadlocks: the item rendersnull, soref.currentstaysnull, souseValuehas notextContentto infer from, so it registers empty and scores zero forever. Upstream cannot reach this because it reads the value out ofprops.childrensynchronously. Both existing async fixtures passed avalue, which is why it was invisible.Ranking orphaned DOM nodes. Relocating an item carried it out of every enclosing range at once, so a
@forlater cleared an emptied range and the real node survived forever — every item stacked above "No results found.".moveWithMarkersonly ever repaired the innermost range, so it broke again at each new nesting construct.Removing the selected item alongside a sibling left nothing selected. All item teardowns scheduled under one batcher key, and the batcher is a
Map, so the last teardown overwrote the rest and the surviving callback had captured a differentselectedItem.Ranking declaratively removes the whole class of bug rather than an instance of it, and it makes source order come back for free when the search clears — physical reordering left a residue that accumulated across searches and never recovered.
Changes
packages/cmdk(33 files)sort()assigns CSSorderinside a flex container instead of moving nodes;moveWithMarkersis gone. Item and group rank spaces are kept disjoint so the sizer's ungrouped items and group hosts cannot tie.getValidItems()walks the ranked containers so selection and arrow-key navigation agree with what is on screen, with the flat query kept as a fast path when no filter is active and DOM order already is visual order.useValuecan infer fromtextContent.status.jsondivergence rewritten for the ranking model; the entry describing the residual-order bug is deleted.@octanejs/radixmoves toworkspace:*, required by the sibling rule this branch merges in (see follow-ups).Elsewhere: playground cmdk demo (its styles live in
playground.cssin shadcn tokens, since upstream retired the inline<style>block), MCP bridge entry, root typecheck chain, and the generated inventories.Two tests were pinning bugs as contracts and now assert parity:
restores every item when the search is clearedasserted the scrambled residue, and the differential'sclearing restores every itemdocumented it as a divergence from React. That checkpoint now compares the whole tree instead of a few hand-picked values. The filtering checkpoints strip only the three ranking declarations, so every other attribute and node still compares byte-for-byte.Validation
pnpm format:check— cleanpnpm typecheck— not run in full.tsrx-tsc --noEmit -p packages/cmdk/tsconfig.jsonis clean.pnpm test— not run in full. The root invocation recurses into fixturenode_modulesin this checkout and is not a usable signal.vitest --project cmdk --project cmdk-ssr— 53 passed, covering behaviour, SSR, hydration and the differential rig against real[email protected]on React.rules:check,packages:inventory:check,binding-parity:gaps:check,bindings:status:check,changeset:check,test:markers:check,tsrx-decls:check,context:budget:check— all pass.Each of the three fixes has a regression test whose pre-fix failure was observed, not assumed:
expected [ 'Apple' ] to deeply equal [ 'Apple', 'Apricot' ],expected [ 'Apple', 'Banana', 'Salad' ] to deeply equal [], andno element matching [cmdk-item][aria-selected="true"].Risk / follow-ups
:nth-childstyling, drag handles) or on a custom containerdisplaydiverges from upstream. Recorded instatus.json.@octanejs/radixpin was reversed by upstream, not by choice. It was pinned to the published0.1.12on maintainer request so the port exercised the release consumers install. The merge brings invalidateWorkspacePackages, which rejects any sibling edge that is notworkspace:*; keeping the pin now failspackages:inventory:checkwithpackages/cmdk dependencies.@octanejs/radix must be "workspace:*". Worth a maintainer's confirmation that the dogfooding intent is satisfied another way.forceMountmenu never auto-selects (inherited from upstream, but the port half-adopted force-mounted items into the registration model); twoCommand.Lists under oneCommandemit duplicate ids;context.labelis dead (faithful to upstream). Each is a small follow-up rather than a blocker.Note
Medium Risk
New UI binding with intentional upstream divergences (flex
orderwhile filtering, SSR empty behavior) and broad command-menu registration/teardown paths; well-tested but affects accessibility and async result lists.Overview
Introduces
@octanejs/cmdk([email protected]): the fullCommandsurface, store, filtering, keyboard navigation,useCommandState, vendored scorer, andCommand.Dialogon@octanejs/radix, plus repo wiring (typecheck, vitest projects, generated binding docs, changeset).Ranking no longer
appendChild-reorders nodes (which broke Octane comment-fenced ranges inside keyed@for/@ifand left orphan items). While a filter is active, the list sizer and group item containers become flex columns and matches are ordered viaorder; clearing the search drops those styles and restores source order. Selection, arrows, and alt+arrow group stepping use the same visual order.Correctness fixes: items without a score yet render once so
textContentvalue inference works when results arrive mid-search; per-item registration teardown keys fix losing selection when removing the selected item with a sibling; force-mounted / group value registration is refreshed and ranked so stale scores and empty-state clashes don’t win; controlled selection keeps input/listaria-activedescendantin sync.@octanejs/radixisworkspace:*(replacing a pinned published version). Behavioral, SSR, hydration, and differential tests against realcmdkon React are included; active filter ranking is a documented divergence from physical DOM order.Reviewed by Cursor Bugbot for commit a548bfc. Bugbot is set up for automated code reviews on this repo. Configure here.