Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion apps/web/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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>;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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" />
)}
Expand All @@ -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
Expand Down Expand Up @@ -2595,6 +2609,20 @@ export default function Sidebar() {
() => projectGroupsSpanEnvironments(projectGroups),
[projectGroups],
);
const scratchMachineLabelFor = useCallback(
(thread: Pick<SidebarThreadSummary, "environmentId" | "projectId">) => {
if (!showProjectEnvironments) return null;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
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],
Expand Down Expand Up @@ -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
Expand Down
Loading