diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index 779f662e0b8d..cf3d14c05b0c 100644 --- a/apps/web/src/components/Sidebar.tsx +++ b/apps/web/src/components/Sidebar.tsx @@ -169,6 +169,7 @@ import { } from "../threadRoutes"; import { formatRelativeTimeLabel, parseTimestampDate } from "../timestampFormat"; import type { SidebarThreadSummary } from "../types"; +import { isScratchProject } from "@t3tools/client-runtime/state/projects"; import type { EnvironmentProject } from "@t3tools/client-runtime/state/shell"; import { cn } from "~/lib/utils"; import { EnvironmentMachineIcon } from "./EnvironmentMachineIcon"; @@ -1141,6 +1142,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: { currentEnvironmentId: string | null; environmentLabel: string | null; environmentMachine: EnvironmentMachineKind; + scratchMachineLabel: string | null; project: EnvironmentProject | null; projectDisplayName: string | null; providerEntryByInstanceId: ReadonlyMap; @@ -1370,6 +1372,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: { // that is every thread, which is the point: the glyph is what tells rows on // different machines apart. const isRemote = thread.environmentId !== props.currentEnvironmentId; + const showsScratchMachine = !thread.branch && props.scratchMachineLabel !== null; const detailsTooltip = ( + ) : showsScratchMachine ? ( + <> + + + {props.scratchMachineLabel} + + ) : ( )} @@ -2179,7 +2193,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: { aria-hidden className="pointer-events-none ml-auto inline-flex shrink-0 items-center gap-1" > - {isRemote ? ( + {isRemote && !showsScratchMachine ? ( projectGroupsSpanEnvironments(projectGroups), [projectGroups], ); + const scratchMachineLabelFor = useCallback( + (thread: Pick) => { + if (!showProjectEnvironments) return null; + const project = projectByKey.get(`${thread.environmentId}:${thread.projectId}`); + if ( + !project || + !isScratchProject(project, serverConfigs.get(thread.environmentId)?.scratchWorkspaceRoot) + ) { + return null; + } + return environmentLabelById.get(thread.environmentId) ?? null; + }, + [environmentLabelById, projectByKey, serverConfigs, showProjectEnvironments], + ); const projectGroupByScopeKey = useMemo( () => new Map(projectGroups.map((project) => [project.projectKey, project] as const)), [projectGroups], @@ -5299,6 +5327,7 @@ export default function Sidebar() { environmentMachine={ environmentMachineById.get(thread.environmentId) ?? "server" } + scratchMachineLabel={scratchMachineLabelFor(thread)} project={ projectByKey.get(`${thread.environmentId}:${thread.projectId}`) ?? null