From ed856946c63e51861a8153d264856db0dbb677a4 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Tue, 22 Sep 2026 12:22:11 -0700 Subject: [PATCH] refactor(web): add an active prop to CommandItem (#13023) Co-authored-by: Claude Fable 5 --- apps/web/src/components/CommandPaletteResults.tsx | 7 ++----- .../web/src/components/chat/ComposerCommandMenu.tsx | 6 ++---- apps/web/src/components/ui/command.tsx | 13 ++++++++++++- scripts/lint-restyle-ceiling.ts | 2 +- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/apps/web/src/components/CommandPaletteResults.tsx b/apps/web/src/components/CommandPaletteResults.tsx index c66ab9a1cf..b9cb0c6269 100644 --- a/apps/web/src/components/CommandPaletteResults.tsx +++ b/apps/web/src/components/CommandPaletteResults.tsx @@ -15,7 +15,6 @@ import { CommandShortcut, } from "./ui/command"; import { ThreadSearchMatchExcerpt } from "./ThreadSearchMatch"; -import { cn } from "~/lib/utils"; interface CommandPaletteResultsProps { emptyStateMessage?: string; @@ -109,10 +108,8 @@ function CommandPaletteResultRow(props: { return ( { event.preventDefault(); }} diff --git a/apps/web/src/components/chat/ComposerCommandMenu.tsx b/apps/web/src/components/chat/ComposerCommandMenu.tsx index 9cdfc37a32..7c23a6059d 100644 --- a/apps/web/src/components/chat/ComposerCommandMenu.tsx +++ b/apps/web/src/components/chat/ComposerCommandMenu.tsx @@ -161,10 +161,8 @@ const ComposerCommandMenuItem = memo(function ComposerCommandMenuItem(props: { { if (!props.isActive) props.onHighlight(props.item.id); }} diff --git a/apps/web/src/components/ui/command.tsx b/apps/web/src/components/ui/command.tsx index f8e9b72b1b..83398a7f8f 100644 --- a/apps/web/src/components/ui/command.tsx +++ b/apps/web/src/components/ui/command.tsx @@ -160,13 +160,24 @@ function CommandCollection({ ...props }: React.ComponentProps; } -function CommandItem({ className, ...props }: React.ComponentProps) { +// Pass `active` when the palette tracks the highlighted row itself; the +// primitive's hover and keyboard highlight are then ignored so the two never +// disagree, and the row shows the active surface instead. +function CommandItem({ + className, + active, + ...props +}: React.ComponentProps & { active?: boolean }) { return ( diff --git a/scripts/lint-restyle-ceiling.ts b/scripts/lint-restyle-ceiling.ts index 78babaf740..353481ac64 100644 --- a/scripts/lint-restyle-ceiling.ts +++ b/scripts/lint-restyle-ceiling.ts @@ -8,7 +8,7 @@ import * as NodeURL from "node:url"; // components/ui exports are migrated to variants (see vite.config.ts). This gate keeps the // count from growing: CI fails when findings exceed the ceiling. Lower the ceiling when you // migrate a file, and delete this script when the rule becomes an error. -export const RESTYLE_CEILING = 1159; +export const RESTYLE_CEILING = 1143; const RULE = "shadcn(no-restyle)";