Skip to content

Commit b74b5f6

Browse files
Julius Marmingeclaude
andcommitted
feat(environments): draw each environment as the machine it runs on
Every remote environment used to wear the same cloud or server glyph, so a Mac mini, a laptop, and a Hetzner VM were indistinguishable in the sidebar, the Run on picker, the pull request filters, and the mobile lists. In the hosted app, where every environment is remote, rows carried no marker at all. Servers now detect their hardware at startup (IOKit product name or hw.model on macOS, DMI chassis type and virtualization markers on Linux) and publish it as platform.machine. A nullable environmentIcon server setting lets the user override it from Settings -> Connections, stored on that server so every device agrees. resolveEnvironmentMachineKind in contracts holds the precedence so web and mobile cannot drift, and platform.machine decodes forward-compatibly so a kind from a newer server falls back to a server glyph instead of failing the descriptor. Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent 15fea6c commit b74b5f6

30 files changed

Lines changed: 1057 additions & 83 deletions

‎apps/mobile/src/components/AppSymbol.tsx‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import IconBox from "@tabler/icons-react-native/IconBox";
2222
import IconCamera from "@tabler/icons-react-native/IconCamera";
2323
import IconChartBar from "@tabler/icons-react-native/IconChartBar";
2424
import IconCheck from "@tabler/icons-react-native/IconCheck";
25+
import IconCloud from "@tabler/icons-react-native/IconCloud";
2526
import IconChevronDown from "@tabler/icons-react-native/IconChevronDown";
2627
import IconChevronLeft from "@tabler/icons-react-native/IconChevronLeft";
2728
import IconChevronRight from "@tabler/icons-react-native/IconChevronRight";
@@ -32,6 +33,7 @@ import IconClock from "@tabler/icons-react-native/IconClock";
3233
import IconCode from "@tabler/icons-react-native/IconCode";
3334
import IconCopy from "@tabler/icons-react-native/IconCopy";
3435
import IconDeviceDesktop from "@tabler/icons-react-native/IconDeviceDesktop";
36+
import IconDeviceLaptop from "@tabler/icons-react-native/IconDeviceLaptop";
3537
import IconDots from "@tabler/icons-react-native/IconDots";
3638
import IconDotsCircleHorizontal from "@tabler/icons-react-native/IconDotsCircleHorizontal";
3739
import IconEdit from "@tabler/icons-react-native/IconEdit";
@@ -110,6 +112,7 @@ const ANDROID_ICON_BY_SF_SYMBOL: Partial<Record<SFSymbol, Icon>> = {
110112
checkmark: IconCheck,
111113
"checkmark.circle": IconCircleCheck,
112114
clock: IconClock,
115+
cloud: IconCloud,
113116
cube: IconBox,
114117
"chevron.down": IconChevronDown,
115118
"chevron.left": IconChevronLeft,
@@ -129,9 +132,13 @@ const ANDROID_ICON_BY_SF_SYMBOL: Partial<Record<SFSymbol, Icon>> = {
129132
"folder.fill": IconFolder,
130133
gearshape: IconSettings,
131134
"info.circle": IconInfoCircle,
135+
laptopcomputer: IconDeviceLaptop,
132136
link: IconLink,
133137
"line.3.horizontal.decrease.circle": IconFilter,
134138
"line.3.horizontal.decrease.circle.fill": IconFilterFilled,
139+
// Tabler has no Apple desktops; the closest silhouettes stand in on Android.
140+
macmini: IconServer,
141+
macstudio: IconDeviceDesktop,
135142
magnifyingglass: IconSearch,
136143
paintbrush: IconPalette,
137144
"person.crop.circle": IconUserCircle,
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import type { EnvironmentMachineKind } from "@t3tools/contracts";
2+
import type { SFSymbol } from "expo-symbols";
3+
4+
import { SymbolView } from "./AppSymbol";
5+
6+
const SYMBOL_BY_KIND: Record<EnvironmentMachineKind, SFSymbol> = {
7+
server: "server.rack",
8+
cloud: "cloud",
9+
desktop: "desktopcomputer",
10+
laptop: "laptopcomputer",
11+
"mac-mini": "macmini",
12+
"mac-studio": "macstudio",
13+
};
14+
15+
export const ENVIRONMENT_MACHINE_KIND_LABELS: Record<EnvironmentMachineKind, string> = {
16+
server: "Server",
17+
cloud: "Cloud VM",
18+
desktop: "Desktop",
19+
laptop: "Laptop",
20+
"mac-mini": "Mac mini",
21+
"mac-studio": "Mac Studio",
22+
};
23+
24+
/** The glyph an environment wears in lists; SF Symbols on iOS, Tabler on Android. */
25+
export function EnvironmentMachineSymbol(props: {
26+
readonly kind: EnvironmentMachineKind;
27+
readonly size: number;
28+
readonly tintColorClassName: string;
29+
}) {
30+
return (
31+
<SymbolView
32+
accessibilityLabel={ENVIRONMENT_MACHINE_KIND_LABELS[props.kind]}
33+
name={SYMBOL_BY_KIND[props.kind]}
34+
size={props.size}
35+
tintColorClassName={props.tintColorClassName}
36+
type="monochrome"
37+
/>
38+
);
39+
}

‎apps/mobile/src/features/connection/CloudEnvironmentRows.tsx‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ import {
44
connectionStatusText,
55
type EnvironmentConnectionPhase,
66
} from "@t3tools/client-runtime/connection";
7-
import type { EnvironmentId } from "@t3tools/contracts";
7+
import {
8+
type EnvironmentId,
9+
type EnvironmentMachineKind,
10+
resolveEnvironmentMachineKind,
11+
} from "@t3tools/contracts";
12+
import { useAtomValue } from "@effect/atom-react";
813
import { useCallback, useState } from "react";
914
import {
1015
ActivityIndicator,
@@ -15,10 +20,12 @@ import {
1520
} from "react-native";
1621

1722
import { AppText as Text } from "../../components/AppText";
23+
import { EnvironmentMachineSymbol } from "../../components/EnvironmentMachineSymbol";
1824
import { ThemedSwitch } from "../../components/ThemedSwitch";
1925
import { cn } from "../../lib/cn";
2026
import { copyTextWithHaptic } from "../../lib/copyTextWithHaptic";
2127
import type { ConnectedEnvironmentSummary } from "../../state/remote-runtime-types";
28+
import { serverEnvironment } from "../../state/server";
2229
import { availableCloudEnvironmentPresentation } from "../cloud/cloudEnvironmentPresentation";
2330
import { hasCloudPublicConfig } from "../cloud/publicConfig";
2431
import { ConnectionStatusDot } from "./ConnectionStatusDot";
@@ -205,6 +212,9 @@ function ConnectedCloudEnvironmentRow(props: {
205212
readonly onDisconnect: () => void;
206213
readonly onToggleError: () => void;
207214
}) {
215+
const serverConfig = useAtomValue(
216+
serverEnvironment.configValueAtom(props.environment.environmentId),
217+
);
208218
return (
209219
<CloudEnvironmentRowShell
210220
borderTop={props.borderTop}
@@ -213,6 +223,7 @@ function ConnectedCloudEnvironmentRow(props: {
213223
connectionState={props.environment.connectionState}
214224
errorExpanded={props.errorExpanded}
215225
label={props.environment.environmentLabel}
226+
machine={resolveEnvironmentMachineKind(serverConfig)}
216227
onValueChange={(enabled) => {
217228
if (enabled) {
218229
props.onConnect();
@@ -268,6 +279,8 @@ function CloudEnvironmentRowShell(props: {
268279
readonly disabled?: boolean;
269280
readonly errorExpanded: boolean;
270281
readonly label: string;
282+
/** Absent for environments the relay lists but this device has not connected to. */
283+
readonly machine?: EnvironmentMachineKind;
271284
readonly onToggleError: () => void;
272285
readonly onValueChange: (enabled: boolean) => void;
273286
readonly statusText?: string;
@@ -323,6 +336,13 @@ function CloudEnvironmentRowShell(props: {
323336
<View className="min-w-0 flex-1 gap-0.5">
324337
<View className="min-w-0 flex-row items-center gap-2">
325338
<ConnectionStatusDot state={props.connectionState} pulse={shouldPulse} size={7} />
339+
{props.machine ? (
340+
<EnvironmentMachineSymbol
341+
kind={props.machine}
342+
size={14}
343+
tintColorClassName="accent-foreground-muted"
344+
/>
345+
) : null}
326346
<Text
327347
className="min-w-0 flex-shrink text-base font-t3-bold leading-snug text-foreground"
328348
numberOfLines={1}

‎apps/mobile/src/features/connection/ConnectionEnvironmentRow.tsx‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
import { SymbolView } from "../../components/AppSymbol";
22
import { connectionStatusText } from "@t3tools/client-runtime/connection";
33
import type { AtomCommandResult } from "@t3tools/client-runtime/state/runtime";
4-
import type { EnvironmentId } from "@t3tools/contracts";
4+
import { type EnvironmentId, resolveEnvironmentMachineKind } from "@t3tools/contracts";
5+
import { useAtomValue } from "@effect/atom-react";
56
import * as Cause from "effect/Cause";
67
import { AsyncResult } from "effect/unstable/reactivity";
78
import { useCallback, useState } from "react";
89
import { Alert, Pressable, View } from "react-native";
910
import Animated, { FadeIn, FadeOut, LinearTransition } from "react-native-reanimated";
1011

1112
import { AppText as Text, AppTextInput as TextInput } from "../../components/AppText";
13+
import { EnvironmentMachineSymbol } from "../../components/EnvironmentMachineSymbol";
1214
import { cn } from "../../lib/cn";
1315
import { copyTextWithHaptic } from "../../lib/copyTextWithHaptic";
1416
import type { ConnectedEnvironmentSummary } from "../../state/remote-runtime-types";
17+
import { serverEnvironment } from "../../state/server";
1518
import { ConnectionStatusDot } from "./ConnectionStatusDot";
1619

1720
function connectionStatusLabel(environment: ConnectedEnvironmentSummary): string | null {
@@ -35,6 +38,9 @@ export function ConnectionEnvironmentRow(props: {
3538
}) {
3639
const [label, setLabel] = useState(props.environment.environmentLabel);
3740
const [url, setUrl] = useState(props.environment.displayUrl);
41+
const serverConfig = useAtomValue(
42+
serverEnvironment.configValueAtom(props.environment.environmentId),
43+
);
3844
const statusLabel = connectionStatusLabel(props.environment);
3945
const statusTraceId = props.environment.connectionErrorTraceId;
4046
const hasConnectionFailure = props.environment.connectionError !== null;
@@ -70,9 +76,19 @@ export function ConnectionEnvironmentRow(props: {
7076
/>
7177

7278
<View className="flex-1 gap-0.5">
73-
<Text className="text-base font-t3-bold leading-snug text-foreground" numberOfLines={1}>
74-
{props.environment.environmentLabel}
75-
</Text>
79+
<View className="flex-row items-center gap-1.5">
80+
<EnvironmentMachineSymbol
81+
kind={resolveEnvironmentMachineKind(serverConfig)}
82+
size={14}
83+
tintColorClassName="accent-foreground-muted"
84+
/>
85+
<Text
86+
className="min-w-0 flex-shrink text-base font-t3-bold leading-snug text-foreground"
87+
numberOfLines={1}
88+
>
89+
{props.environment.environmentLabel}
90+
</Text>
91+
</View>
7692
<Text className="text-xs text-foreground-muted" numberOfLines={1}>
7793
{props.environment.displayUrl}
7894
</Text>

‎apps/mobile/src/features/home/HomeScreen.tsx‎

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ import {
1212
type EnvironmentThreadSearchMatch,
1313
} from "@t3tools/client-runtime/state/thread-search";
1414
import { sortPinnedThreadsByOrderKey } from "@t3tools/client-runtime/state/thread-sort";
15-
import type {
16-
EnvironmentId,
17-
SidebarProjectGroupingMode,
18-
SidebarThreadSortOrder,
15+
import {
16+
type EnvironmentId,
17+
resolveEnvironmentMachineKind,
18+
type SidebarProjectGroupingMode,
19+
type SidebarThreadSortOrder,
1920
} from "@t3tools/contracts";
2021
import { useAtomSet, useAtomValue } from "@effect/atom-react";
2122
import { AsyncResult } from "effect/unstable/reactivity";
@@ -612,6 +613,16 @@ export function HomeScreen(props: HomeScreenProps) {
612613
}
613614
return supported;
614615
}, [serverConfigs]);
616+
const machineByEnvironmentId = useMemo(
617+
() =>
618+
new Map(
619+
[...serverConfigs].map(
620+
([environmentId, config]) =>
621+
[environmentId, resolveEnvironmentMachineKind(config)] as const,
622+
),
623+
),
624+
[serverConfigs],
625+
);
615626
// Canonical arranged pinned order (reorder-capable threads only) for the
616627
// Move up/down position flags. Computed from all shells, not the rendered
617628
// list, so search/scope filtering never disables or misdirects a move.
@@ -740,6 +751,7 @@ export function HomeScreen(props: HomeScreenProps) {
740751
?.environmentLabel ?? null)
741752
: null
742753
}
754+
environmentMachine={machineByEnvironmentId.get(item.pendingTask.message.environmentId)}
743755
showPendingDivider={item.showPendingDivider}
744756
showTrailingDivider={showTrailingDivider}
745757
onSelectPendingTask={props.onSelectPendingTask}
@@ -797,6 +809,7 @@ export function HomeScreen(props: HomeScreenProps) {
797809
? (props.savedConnectionsById[thread.environmentId]?.environmentLabel ?? null)
798810
: null
799811
}
812+
environmentMachine={machineByEnvironmentId.get(thread.environmentId)}
800813
searchMatch={threadSearchMatchByKey.get(
801814
threadSearchMatchKey({
802815
environmentId: thread.environmentId,
@@ -847,6 +860,7 @@ export function HomeScreen(props: HomeScreenProps) {
847860
handleSwipeableWillOpen,
848861
handleUnsettleThread,
849862
pinningEnvironmentIds,
863+
machineByEnvironmentId,
850864
pinReorderEnvironmentIds,
851865
projectByKey,
852866
projectCwdByKey,
@@ -938,6 +952,9 @@ export function HomeScreen(props: HomeScreenProps) {
938952
props.savedConnectionsById[item.pendingTask.message.environmentId]
939953
?.environmentLabel ?? null
940954
}
955+
environmentMachine={machineByEnvironmentId.get(
956+
item.pendingTask.message.environmentId,
957+
)}
941958
isLast={item.isLast}
942959
onSelectPendingTask={props.onSelectPendingTask}
943960
onDeletePendingTask={props.onDeletePendingTask}
@@ -952,6 +969,7 @@ export function HomeScreen(props: HomeScreenProps) {
952969
environmentLabel={
953970
props.savedConnectionsById[thread.environmentId]?.environmentLabel ?? null
954971
}
972+
environmentMachine={machineByEnvironmentId.get(thread.environmentId)}
955973
projectCwd={
956974
projectCwdByKey.get(scopedProjectKey(thread.environmentId, thread.projectId)) ??
957975
null
@@ -990,6 +1008,7 @@ export function HomeScreen(props: HomeScreenProps) {
9901008
handleSwipeableClose,
9911009
handleSwipeableWillOpen,
9921010
handleRegenerateThreadTitle,
1011+
machineByEnvironmentId,
9931012
projectCwdByKey,
9941013
props.onArchiveThread,
9951014
props.onDeletePendingTask,

‎apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
import { LegendList } from "@legendapp/list/react-native";
1010
import type { MenuAction } from "@react-native-menu/menu";
1111
import { useAtomValue } from "@effect/atom-react";
12-
import type { EnvironmentId } from "@t3tools/contracts";
12+
import { type EnvironmentId, resolveEnvironmentMachineKind } from "@t3tools/contracts";
1313
import { sortPinnedThreadsByOrderKey } from "@t3tools/client-runtime/state/thread-sort";
1414
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
1515
import type { LayoutChangeEvent } from "react-native";
@@ -441,6 +441,16 @@ function ThreadNavigationSidebarPane(
441441
}
442442
return supported;
443443
}, [serverConfigs]);
444+
const machineByEnvironmentId = useMemo(
445+
() =>
446+
new Map(
447+
[...serverConfigs].map(
448+
([environmentId, config]) =>
449+
[environmentId, resolveEnvironmentMachineKind(config)] as const,
450+
),
451+
),
452+
[serverConfigs],
453+
);
444454
// Canonical arranged pinned order for Move up/down flags — computed from
445455
// all shells so search/scope filtering never disables a valid move.
446456
const arrangedPinnedKeys = useMemo(() => {
@@ -819,6 +829,9 @@ function ThreadNavigationSidebarPane(
819829
?.environmentLabel ?? null)
820830
: null
821831
}
832+
environmentMachine={machineByEnvironmentId.get(
833+
item.pendingTask.message.environmentId,
834+
)}
822835
pane="sidebar"
823836
showPendingDivider={item.showPendingDivider}
824837
onSelectPendingTask={openPendingTask}
@@ -853,6 +866,7 @@ function ThreadNavigationSidebarPane(
853866
? (savedConnectionsById[thread.environmentId]?.environmentLabel ?? null)
854867
: null
855868
}
869+
environmentMachine={machineByEnvironmentId.get(thread.environmentId)}
856870
searchMatch={threadSearchMatchByKey.get(
857871
threadSearchMatchKey({
858872
environmentId: thread.environmentId,
@@ -956,6 +970,9 @@ function ThreadNavigationSidebarPane(
956970
savedConnectionsById[item.pendingTask.message.environmentId]?.environmentLabel ??
957971
null
958972
}
973+
environmentMachine={machineByEnvironmentId.get(
974+
item.pendingTask.message.environmentId,
975+
)}
959976
isLast={item.isLast}
960977
onSelectPendingTask={openPendingTask}
961978
onDeletePendingTask={confirmDeletePendingTask}
@@ -970,6 +987,7 @@ function ThreadNavigationSidebarPane(
970987
environmentLabel={
971988
savedConnectionsById[thread.environmentId]?.environmentLabel ?? null
972989
}
990+
environmentMachine={machineByEnvironmentId.get(thread.environmentId)}
973991
projectCwd={
974992
projectCwdByKey.get(scopedProjectKey(thread.environmentId, thread.projectId)) ??
975993
null
@@ -1017,6 +1035,7 @@ function ThreadNavigationSidebarPane(
10171035
handleSelectThread,
10181036
handleSwipeableClose,
10191037
handleSwipeableWillOpen,
1038+
machineByEnvironmentId,
10201039
movePinnedThread,
10211040
openPendingTask,
10221041
pinReorderEnvironmentIds,

0 commit comments

Comments
 (0)