Skip to content
TypeScript

feat(web): projectless threads show their machine in the sidebar (#17022)

oliverff9eb8bd0c8e
diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx
index 779f662e0b8..cf3d14c05b0 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<string, ProviderInstanceEntry>;
@@ -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 = (
<SidebarThreadTooltip
@@ -2164,6 +2167,17 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
<MiddleTruncate value={thread.branch} showTitle={false} />
</span>
</>
+ ) : showsScratchMachine ? (
+ <>
+ <EnvironmentMachineIcon
+ aria-hidden
+ kind={props.environmentMachine}
+ className="size-3 shrink-0 text-muted-foreground/40"
+ />
+ <span className="min-w-0 flex-1 truncate text-muted-foreground/40">
+ {props.scratchMachineLabel}
+ </span>
+ </>
) : (
<span className="flex-1" />
)}
@@ -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 ? (
<span className="inline-flex shrink-0 items-center text-sidebar-muted-foreground/70">
<EnvironmentMachineIcon
aria-hidden
@@ -2595,6 +2609,20 @@ export default function Sidebar() {
() => projectGroupsSpanEnvironments(projectGroups),
[projectGroups],
);
+ const scratchMachineLabelFor = useCallback(
+ (thread: Pick<SidebarThreadSummary, "environmentId" | "projectId">) => {
+ 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