feat(web): projectless threads show their machine in the sidebar (#17022)
This commit is contained in:
1 parent
12865b4a73
commit
ff9eb8bd0c
1 file changed
+30
-1
@@ -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
|
||||
|
||||
Reference in new issue
Block a user