refactor(command-palette): extract groups into declarative registry

This commit is contained in:
simosmik
2026-04-30 07:56:26 +00:00
parent 384cee2995
commit 9179ca2f00
10 changed files with 397 additions and 231 deletions

View File

@@ -0,0 +1,28 @@
import { GitCommit } from 'lucide-react';
import { useCommitsSource } from '../../sources/useCommitsSource';
import type { GroupConfig } from '../types';
export const commitsGroup: GroupConfig = {
id: 'commits',
heading: 'Commits',
modes: ['mixed', 'commits'],
prefix: { char: '#', mode: 'commits' },
requiresProject: true,
useItems: (ctx) => {
const { items: commits } = useCommitsSource(ctx.projectId, ctx.enabled);
return commits.map((c) => ({
key: `commit-${c.hash}`,
value: `${c.shortHash} ${c.message} ${c.author}`,
onSelect: () => ctx.run(() => ctx.onShowTab?.('git')),
node: (
<>
<GitCommit className="h-4 w-4 shrink-0 text-muted-foreground" aria-hidden />
<span className="font-mono text-xs text-muted-foreground">{c.shortHash}</span>
<span className="flex-1 truncate">{c.message}</span>
<span className="truncate text-xs text-muted-foreground">{c.author}</span>
</>
),
}));
},
};