Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/desktop/src/design.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const SHAPED = /(?<![\w-])rounded-(?:md|lg|full)(?![\w-])/;
*/
const PILL_ALLOWED: [file: string, part: string, why: string][] = [
["ui/AttentionCards.tsx", "send([o])", "the answers are choice rows"],
["ui/CommandPalette.tsx", 'role="option"', "the palette's result rows: the fill marks the selected one"],
["ui/PanelToggle.tsx", "data-panel-toggle", "the side panel's toggle: its fill marks the panel open"],
["ui/Board.tsx", "Unsettle", "a 24px icon button"],
["ui/ChatView.tsx", "px-2 font-medium", "the plan pill is a popover trigger"],
Expand Down
19 changes: 14 additions & 5 deletions apps/desktop/src/ui/CommandPalette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// projects and this one.

import { Dialog } from "radix-ui";
import { useEffect, useMemo, useState } from "react";
import { useEffect, useMemo, useRef, useState } from "react";
import { modelName, projectName } from "../acp/types";
import { copyPromptLink, copyThreadLink } from "../state/deepLinks";
import { PREF, usePref, useSidebarSort } from "../state/sidebarPrefs";
Expand Down Expand Up @@ -317,6 +317,10 @@ export function CommandPalette() {
const [sort] = useSidebarSort();
const scope = onlyProject && projectCwd ? "project" : "all";
const [index, setIndex] = useState(0);
const listRef = useRef<HTMLDivElement>(null);
useEffect(() => {
listRef.current?.querySelectorAll('[role="option"]')[index]?.scrollIntoView({ block: "nearest" });
}, [index]);

// biome-ignore lint/correctness/useExhaustiveDependencies: a changed result order resets keyboard selection
useEffect(() => {
Expand Down Expand Up @@ -477,7 +481,12 @@ export function CommandPalette() {
<FilterMenu filtering={scope === "project"} />
</div>
</div>
<div className="max-h-[440px] overflow-y-auto p-2" role="listbox" aria-label="Results">
<div
ref={listRef}
className="max-h-[440px] overflow-y-auto p-2"
role="listbox"
aria-label="Results"
>
{!results.length && (
<div className="px-3 py-4 text-center text-callout text-fg-muted">Nothing matches “{q}”.</div>
)}
Expand All @@ -501,13 +510,13 @@ export function CommandPalette() {
className={cx(
"flex w-full items-center gap-3 rounded-lg px-3 text-left",
r.kind === "thread" ? "min-h-[48px] py-2" : "min-h-[36px] py-1.5",
i === index && "bg-accent/16",
i === index && "bg-fill",
r.kind === "action" && r.action.disabled && "opacity-45",
)}
>
{r.kind === "thread" ? (
<>
<MessageSquare size={13} className={i === index ? "text-accent" : "text-fg-muted"} />
<MessageSquare size={13} className={i === index ? "text-fg" : "text-fg-muted"} />
<span className="min-w-0 flex-1">
<span className="block truncate text-body">{highlight(r.title, q)}</span>
<span className="block truncate text-caption text-fg-muted">{r.detail}</span>
Expand All @@ -520,7 +529,7 @@ export function CommandPalette() {
</>
) : (
<>
<r.action.icon size={13} className={i === index ? "text-accent" : "text-fg-muted"} />
<r.action.icon size={13} className={i === index ? "text-fg" : "text-fg-muted"} />
<span className="min-w-0 flex-1 truncate text-body">
{highlight(r.action.label, q)}
{r.action.group && r.action.detail && (
Expand Down
Loading