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";
export const COMMAND_PALETTE_META_ICON_CLASS = "size-3 shrink-0 text-muted-foreground/70";
export function CommandPaletteMetaDot() {
return ยท;
}
function WorkspaceIcon(props: { variant: ThreadCommandSubtitleVariant; isWorktree: boolean }) {
if (props.isWorktree) {
return ;
}
if (props.variant === "favicon-branch-harness") {
return ;
}
return ;
}
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 (
{projectLabel ? (
{props.projectCwd ? (
) : null}
{projectLabel}
) : null}
{branchLabel ? (
<>
{projectLabel ? : null}
{branchLabel}
>
) : null}
{showHarness && props.driverKind ? (
<>
{projectLabel || branchLabel ? : null}
>
) : null}
{props.isCurrent ? (
<>
{projectLabel || branchLabel || showHarness ? : null}
Current thread
>
) : null}
);
}