Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
feat(web): project favicon and workspace icons in command subtitles (#6330)
Gianmarcoac1264e2cab1
diff --git a/apps/web/src/components/CommandPalette.logic.test.ts b/apps/web/src/components/CommandPalette.logic.test.tsindex 4d591500f..06dabc5e8 100644--- a/apps/web/src/components/CommandPalette.logic.test.ts+++ b/apps/web/src/components/CommandPalette.logic.test.ts@@ -264,6 +264,20 @@ describe("buildThreadActionItems", () => {expect(item?.description).toBe("T3 Code · #feat/search");});+ it("prefers renderDescription when provided", () => {+ const [item] = buildThreadActionItems({+ threads: [makeThread({ branch: "feat/search", worktreePath: "/tmp/wt" })],+ projectTitleById: new Map([[PROJECT_ID, "T3 Code"]]),+ sortOrder: "updated_at",+ icon: null,+ renderDescription: (thread, { projectTitle }) =>+ `${projectTitle}:${thread.branch}:${thread.worktreePath ? "wt" : "local"}`,+ runThread: async (_thread) => undefined,+ });++ expect(item?.description).toBe("T3 Code:feat/search:wt");+ });+it("filters archived threads out of thread search items", () => {const items = buildThreadActionItems({threads: [diff --git a/apps/web/src/components/CommandPalette.logic.ts b/apps/web/src/components/CommandPalette.logic.tsindex c9ded5e7e..07e0e520d 100644--- a/apps/web/src/components/CommandPalette.logic.ts+++ b/apps/web/src/components/CommandPalette.logic.ts@@ -154,7 +154,16 @@ export function buildProjectActionItems(input: {export type BuildThreadActionItemsThread = Pick<SidebarThreadSummary,- "archivedAt" | "branch" | "createdAt" | "environmentId" | "id" | "projectId" | "title"+ | "archivedAt"+ | "branch"+ | "createdAt"+ | "environmentId"+ | "id"+ | "modelSelection"+ | "projectId"+ | "session"+ | "title"+ | "worktreePath"> & {updatedAt: string;latestUserMessageAt?: string | null;@@ -170,6 +179,8 @@ export function buildThreadActionItems<TThread extends BuildThreadActionItemsThrrenderLeadingContent?: (thread: TThread) => ReactNode;/** Optional content rendered inline after the title text per-thread. */renderTrailingContent?: (thread: TThread) => ReactNode;+ /** Optional rich description (e.g. favicon + workspace icons). Falls back to text. */+ renderDescription?: (thread: TThread, meta: { projectTitle: string | undefined }) => ReactNode;getContentMatch?: (thread: TThread) => CommandPaletteThreadContentMatch | undefined;runThread: (thread: Pick<SidebarThreadSummary, "environmentId" | "id">) => Promise<void>;limit?: number;@@ -198,6 +209,9 @@ export function buildThreadActionItems<TThread extends BuildThreadActionItemsThrconst leadingContent = input.renderLeadingContent?.(thread);const trailingContent = input.renderTrailingContent?.(thread);const contentMatch = input.getContentMatch?.(thread);+ const description = input.renderDescription+ ? input.renderDescription(thread, { projectTitle })+ : descriptionParts.join(` · `);return Object.assign({@@ -210,7 +224,7 @@ export function buildThreadActionItems<TThread extends BuildThreadActionItemsThrcontentMatch?.snippet ?? ``,],title: thread.title,- description: descriptionParts.join(` · `),+ description,timestamp: formatRelativeTimeLabel(thread.latestUserMessageAt ?? thread.updatedAt ?? thread.createdAt,),diff --git a/apps/web/src/components/CommandPalette.tsx b/apps/web/src/components/CommandPalette.tsxindex ad9099629..48471accb 100644--- a/apps/web/src/components/CommandPalette.tsx+++ b/apps/web/src/components/CommandPalette.tsx@@ -124,9 +124,14 @@ import { ProjectFavicon } from "./ProjectFavicon";import { ProjectFilePicker } from "./files/ProjectFilePicker";import { ProjectContentSearchDialog } from "./search/ProjectContentSearchDialog";import { toggleThemeEditorForTheme } from "./settings/themeEditorStore";+import { ThreadCommandSubtitle } from "./ThreadCommandSubtitle";import { ThreadRowLeadingStatus, ThreadRowTrailingStatus } from "./ThreadStatusIndicators";import { primaryServerKeybindingsAtom, primaryServerProvidersAtom } from "../state/server";-import { resolveDefaultProviderModelSelection } from "../providerInstances";+import {+ deriveProviderInstanceEntries,+ resolveDefaultProviderModelSelection,+ type ProviderInstanceEntry,+} from "../providerInstances";import { resolveShortcutCommand, threadJumpIndexFromCommand } from "../keybindings";import { CommandDialog, CommandDialogPopup } from "./ui/command";import { Button } from "./ui/button";@@ -584,6 +589,18 @@ function OpenCommandPaletteDialog(props: {const keybindings = useAtomValue(primaryServerKeybindingsAtom);const { theme, themeHalves, resolvedTheme } = useTheme();const providers = useAtomValue(primaryServerProvidersAtom);+ const providerEntryByEnvironmentAndInstanceId = useMemo(() => {+ const map = new Map<string, ProviderInstanceEntry>();+ for (const environment of environments) {+ const environmentProviders =+ environment.serverConfig?.providers ??+ (environment.environmentId === primaryEnvironmentId ? providers : []);+ for (const entry of deriveProviderInstanceEntries(environmentProviders)) {+ map.set(`${environment.environmentId}:${entry.instanceId}`, entry);+ }+ }+ return map;+ }, [environments, primaryEnvironmentId, providers]);const [viewStack, setViewStack] = useState<CommandPaletteView[]>([]);const currentView = viewStack.at(-1) ?? null;const environmentIds = useMemo(@@ -816,6 +833,10 @@ function OpenCommandPaletteDialog(props: {new Map<ProjectId, string>(projects.map((project) => [project.id, project.workspaceRoot])),[projects],);+ const projectFaviconPathById = useMemo(+ () => new Map(projects.map((project) => [project.id, project.faviconPath ?? null] as const)),+ [projects],+ );const projectTitleById = useMemo(() => new Map<ProjectId, string>(projects.map((project) => [project.id, project.title])),[projects],@@ -1000,6 +1021,29 @@ function OpenCommandPaletteDialog(props: {icon: <MessageSquareIcon className={ITEM_ICON_CLASS} />,renderLeadingContent: (thread) => <ThreadRowLeadingStatus thread={thread} />,renderTrailingContent: (thread) => <ThreadRowTrailingStatus thread={thread} />,+ renderDescription: (thread, { projectTitle }) => {+ const modelInstanceId =+ thread.session?.providerInstanceId ?? thread.modelSelection.instanceId;+ const providerEntry =+ providerEntryByEnvironmentAndInstanceId.get(+ `${thread.environmentId}:${modelInstanceId}`,+ ) ?? null;+ return (+ <ThreadCommandSubtitle+ environmentId={thread.environmentId}+ projectCwd={projectCwdById.get(thread.projectId) ?? null}+ projectFaviconPath={projectFaviconPathById.get(thread.projectId) ?? null}+ projectTitle={projectTitle ?? null}+ branch={thread.branch}+ worktreePath={thread.worktreePath}+ isCurrent={thread.id === activeThreadId}+ driverKind={providerEntry?.driverKind ?? null}+ providerDisplayName={+ thread.session?.providerName ?? providerEntry?.displayName ?? modelInstanceId+ }+ />+ );+ },getContentMatch: (thread) => {const match = threadContentMatchByKey.get(threadSearchMatchKey({@@ -1026,7 +1070,10 @@ function OpenCommandPaletteDialog(props: {activeThreadId,clientSettings.sidebarThreadSortOrder,navigate,+ projectCwdById,+ projectFaviconPathById,projectTitleById,+ providerEntryByEnvironmentAndInstanceId,threadContentMatchByKey,threadSearchQuery,threads,diff --git a/apps/web/src/components/CommandPaletteResults.tsx b/apps/web/src/components/CommandPaletteResults.tsxindex 2ab4ef8f3..bbdbc28b0 100644--- a/apps/web/src/components/CommandPaletteResults.tsx+++ b/apps/web/src/components/CommandPaletteResults.tsx@@ -142,7 +142,7 @@ function DisabledCommandPaletteResultRow(props: {<ThreadContentMatch match={props.item.threadContentMatch} />) : null}{props.item.description ? (- <span className="truncate text-muted-foreground/70 text-xs">+ <span className="min-w-0 text-muted-foreground/70 text-xs">{props.item.description}</span>) : null}@@ -193,7 +193,7 @@ function CommandPaletteResultRow(props: {<ThreadContentMatch match={props.item.threadContentMatch} />) : null}{props.item.description ? (- <span className="truncate text-muted-foreground/70 text-xs">+ <span className="min-w-0 text-muted-foreground/70 text-xs">{props.item.description}</span>) : null}diff --git a/apps/web/src/components/ThreadCommandSubtitle.tsx b/apps/web/src/components/ThreadCommandSubtitle.tsxnew file mode 100644index 000000000..b190384a6--- /dev/null+++ b/apps/web/src/components/ThreadCommandSubtitle.tsx@@ -0,0 +1,112 @@+import type { EnvironmentId, ProviderDriverKind } from "@t3tools/contracts";+import { FolderGit2Icon, FolderIcon, GitBranchIcon } from "lucide-react";+import { ProjectFavicon } from "./ProjectFavicon";+import { ProviderInstanceIcon } from "./chat/ProviderInstanceIcon";+import { cn } from "~/lib/utils";++/**+ * Flip this while reviewing command-palette thread subtitles.+ * - favicon-workspace-harness: favicon + Folder/FolderGit2 + branch + harness (default)+ * - favicon-workspace: same without harness+ * - favicon-branch-harness: GitBranch for local, FolderGit2 for worktrees, + harness+ */+export type ThreadCommandSubtitleVariant =+ | "favicon-workspace-harness"+ | "favicon-workspace"+ | "favicon-branch-harness";++export const THREAD_COMMAND_SUBTITLE_VARIANT: ThreadCommandSubtitleVariant =+ "favicon-workspace-harness";++const META_ICON_CLASS = "size-3 shrink-0 text-muted-foreground/70";++function Dot() {+ return <span className="shrink-0 text-muted-foreground/50">·</span>;+}++function WorkspaceIcon(props: { variant: ThreadCommandSubtitleVariant; isWorktree: boolean }) {+ if (props.isWorktree) {+ return <FolderGit2Icon className={META_ICON_CLASS} aria-hidden />;+ }+ if (props.variant === "favicon-branch-harness") {+ return <GitBranchIcon className={META_ICON_CLASS} aria-hidden />;+ }+ return <FolderIcon className={META_ICON_CLASS} aria-hidden />;+}++export function ThreadCommandSubtitle(props: {+ environmentId: EnvironmentId;+ projectCwd: string | null;+ projectFaviconPath?: string | null;+ projectTitle: string | null;+ branch: string | null;+ worktreePath: string | null;+ isCurrent: boolean;+ driverKind?: ProviderDriverKind | null;+ providerDisplayName?: string | null;+ variant?: ThreadCommandSubtitleVariant;+ className?: string;+}) {+ const variant = props.variant ?? THREAD_COMMAND_SUBTITLE_VARIANT;+ const isWorktree = props.worktreePath != null && props.worktreePath.trim().length > 0;+ const showHarness =+ variant !== "favicon-workspace" && props.driverKind != null && props.providerDisplayName;++ const projectLabel = props.projectTitle?.trim() || null;+ const branchLabel = props.branch?.trim() || null;++ if (!projectLabel && !branchLabel && !props.isCurrent && !showHarness) {+ return null;+ }++ return (+ <span+ className={cn(+ "inline-flex min-w-0 max-w-full items-center gap-1 text-xs text-muted-foreground/70",+ props.className,+ )}+ >+ {projectLabel ? (+ <span className="inline-flex min-w-0 items-center gap-1">+ {props.projectCwd ? (+ <ProjectFavicon+ environmentId={props.environmentId}+ cwd={props.projectCwd}+ faviconPath={props.projectFaviconPath}+ className="size-3 shrink-0"+ />+ ) : null}+ <span className="min-w-0 truncate">{projectLabel}</span>+ </span>+ ) : null}++ {branchLabel ? (+ <>+ {projectLabel ? <Dot /> : null}+ <span className="inline-flex min-w-0 items-center gap-1">+ <WorkspaceIcon variant={variant} isWorktree={isWorktree} />+ <span className="min-w-0 truncate">{branchLabel}</span>+ </span>+ </>+ ) : null}++ {showHarness && props.driverKind ? (+ <>+ {projectLabel || branchLabel ? <Dot /> : null}+ <ProviderInstanceIcon+ driverKind={props.driverKind}+ displayName={props.providerDisplayName ?? props.driverKind}+ iconClassName="size-3 shrink-0 opacity-70"+ />+ </>+ ) : null}++ {props.isCurrent ? (+ <>+ {projectLabel || branchLabel || showHarness ? <Dot /> : null}+ <span className="shrink-0">Current thread</span>+ </>+ ) : null}+ </span>+ );+}