Skip to content

Commit bf5cc13

Browse files
feat(environments): add Linux/WSL icon
1 parent 8c50438 commit bf5cc13

14 files changed

Lines changed: 50 additions & 67 deletions

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { SymbolView } from "./AppSymbol";
66
const SYMBOL_BY_KIND: Record<EnvironmentMachineKind, SFSymbol> = {
77
server: "server.rack",
88
cloud: "cloud",
9+
linux: "terminal",
910
desktop: "desktopcomputer",
1011
laptop: "laptopcomputer",
1112
"mac-mini": "macmini",
@@ -15,6 +16,7 @@ const SYMBOL_BY_KIND: Record<EnvironmentMachineKind, SFSymbol> = {
1516
export const ENVIRONMENT_MACHINE_KIND_LABELS: Record<EnvironmentMachineKind, string> = {
1617
server: "Server",
1718
cloud: "Cloud VM",
19+
linux: "Linux/WSL",
1820
desktop: "Desktop",
1921
laptop: "Laptop",
2022
"mac-mini": "Mac mini",

‎apps/server/src/environment/ServerEnvironmentMachine.test.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,26 @@ describe("detectServerEnvironmentMachineKind", () => {
202202
}),
203203
);
204204

205+
it.effect("recognizes WSL before its Hyper-V DMI identity", () =>
206+
Effect.gen(function* () {
207+
const result = yield* detectServerEnvironmentMachineKind().pipe(
208+
Effect.provide(
209+
withPlatform(
210+
"linux",
211+
dmiFileSystem({
212+
osrelease: "5.15.153.1-microsoft-standard-WSL2\n",
213+
chassis_type: "3\n",
214+
sys_vendor: "Microsoft Corporation\n",
215+
product_name: "Virtual Machine\n",
216+
}),
217+
),
218+
),
219+
);
220+
221+
expect(result).toBe("linux");
222+
}),
223+
);
224+
205225
it.effect("returns null on Linux without DMI (containers, ARM boards)", () =>
206226
Effect.gen(function* () {
207227
const result = yield* detectServerEnvironmentMachineKind().pipe(

‎apps/server/src/environment/ServerEnvironmentMachine.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import * as ProcessRunner from "../processRunner.ts";
1212
*/
1313

1414
const DMI_ROOT = "/sys/class/dmi/id";
15+
const KERNEL_RELEASE_PATH = "/proc/sys/kernel/osrelease";
1516

1617
// SMBIOS 3.x System Enclosure types (table 17). Codes that describe a shape
1718
// rather than a machine (docking stations, blades enclosures, IoT gateways)
@@ -144,11 +145,17 @@ const detectDarwinMachineKind = Effect.fn("detectDarwinMachineKind")(function* (
144145
});
145146

146147
const detectLinuxMachineKind = Effect.fn("detectLinuxMachineKind")(function* () {
147-
const [chassisType, sysVendor, productName] = yield* Effect.all([
148+
const [kernelRelease, chassisType, sysVendor, productName] = yield* Effect.all([
149+
readOptionalFile(KERNEL_RELEASE_PATH),
148150
readOptionalFile(`${DMI_ROOT}/chassis_type`),
149151
readOptionalFile(`${DMI_ROOT}/sys_vendor`),
150152
readOptionalFile(`${DMI_ROOT}/product_name`),
151153
]);
154+
// WSL exposes Microsoft in its kernel release on both WSL 1 and WSL 2.
155+
// Check it before DMI because WSL 2 presents as a Hyper-V VM.
156+
if (kernelRelease?.toLowerCase().includes("microsoft")) {
157+
return "linux";
158+
}
152159
return machineKindFromDmi({ chassisType, sysVendor, productName });
153160
});
154161

‎apps/web/src/components/BranchToolbar.logic.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export interface EnvironmentOption {
1212
label: string;
1313
isPrimary: boolean;
1414
machine: EnvironmentMachineKind;
15-
isWsl: boolean;
1615
}
1716

1817
export const EnvMode = Schema.Literals(["local", "worktree"]);

‎apps/web/src/components/BranchToolbar.tsx‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ const MobileRunContextSelector = memo(function MobileRunContextSelector({
116116
<span className="inline-flex shrink-0 items-center gap-0.5">
117117
<EnvironmentMachineIcon
118118
kind={activeEnvironment?.machine ?? "server"}
119-
wsl={activeEnvironment?.isWsl ?? false}
120119
className="size-3 shrink-0 mx-0!"
121120
/>
122121
<WorkspaceIcon className="size-3 shrink-0 mx-0!" />
@@ -178,11 +177,7 @@ const MobileRunContextSelector = memo(function MobileRunContextSelector({
178177
value={env.environmentId}
179178
>
180179
<span className="flex min-w-0 items-center gap-1.5">
181-
<EnvironmentMachineIcon
182-
kind={env.machine}
183-
wsl={env.isWsl}
184-
className="size-3"
185-
/>
180+
<EnvironmentMachineIcon kind={env.machine} className="size-3" />
186181
<span className="min-w-0 truncate">{env.label}</span>
187182
</span>
188183
</MenuRadioItem>

‎apps/web/src/components/BranchToolbarEnvironmentSelector.tsx‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ export const BranchToolbarEnvironmentSelector = memo(function BranchToolbarEnvir
5555
>
5656
<EnvironmentMachineIcon
5757
kind={activeEnvironment?.machine ?? "server"}
58-
wsl={activeEnvironment?.isWsl ?? false}
5958
className="size-3 shrink-0"
6059
/>
6160
<span
@@ -89,7 +88,6 @@ export const BranchToolbarEnvironmentSelector = memo(function BranchToolbarEnvir
8988
>
9089
<EnvironmentMachineIcon
9190
kind={activeEnvironment?.machine ?? "server"}
92-
wsl={activeEnvironment?.isWsl ?? false}
9391
className="size-3 shrink-0"
9492
/>
9593
<span
@@ -110,7 +108,7 @@ export const BranchToolbarEnvironmentSelector = memo(function BranchToolbarEnvir
110108
{availableEnvironments.map((env) => (
111109
<SelectItem key={env.environmentId} value={env.environmentId}>
112110
<span className="inline-flex items-center gap-1.5">
113-
<EnvironmentMachineIcon kind={env.machine} wsl={env.isWsl} className="size-3" />
111+
<EnvironmentMachineIcon kind={env.machine} className="size-3" />
114112
{env.label}
115113
</span>
116114
</SelectItem>

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ import * as Cause from "effect/Cause";
8585
import * as Schema from "effect/Schema";
8686
import { AsyncResult } from "effect/unstable/reactivity";
8787
import { isElectron } from "../env";
88-
import { isWslConnectionTarget } from "../connection/desktopLocal";
8988
import { readLocalApi } from "../localApi";
9089
import { useDiffPanelStore } from "../diffPanelStore";
9190
import {
@@ -2135,7 +2134,6 @@ export default function ChatView(props: ChatViewProps) {
21352134
label: environment?.label ?? p.environmentId,
21362135
isPrimary,
21372136
machine: resolveEnvironmentMachineKind(environment?.serverConfig ?? null),
2138-
isWsl: environment !== null && isWslConnectionTarget(environment.entry.target),
21392137
});
21402138
}
21412139
// Sort: primary first, then alphabetical

‎apps/web/src/components/EnvironmentMachineIcon.tsx‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export function MacStudioIcon(props: SVGProps<SVGSVGElement>) {
4646
const ICON_BY_KIND: Record<EnvironmentMachineKind, FunctionComponent<LucideProps>> = {
4747
server: ServerIcon,
4848
cloud: CloudIcon,
49+
linux: LinuxIcon,
4950
desktop: MonitorIcon,
5051
laptop: LaptopIcon,
5152
"mac-mini": MacMiniIcon,
@@ -55,6 +56,7 @@ const ICON_BY_KIND: Record<EnvironmentMachineKind, FunctionComponent<LucideProps
5556
export const ENVIRONMENT_MACHINE_KIND_LABELS: Record<EnvironmentMachineKind, string> = {
5657
server: "Server",
5758
cloud: "Cloud VM",
59+
linux: "Linux/WSL",
5860
desktop: "Desktop",
5961
laptop: "Laptop",
6062
"mac-mini": "Mac mini",
@@ -69,9 +71,8 @@ export function environmentMachineIcon(
6971

7072
export function EnvironmentMachineIcon({
7173
kind,
72-
wsl = false,
7374
...props
74-
}: LucideProps & { readonly kind: EnvironmentMachineKind; readonly wsl?: boolean }) {
75-
const Icon = wsl ? LinuxIcon : ICON_BY_KIND[kind];
75+
}: LucideProps & { readonly kind: EnvironmentMachineKind }) {
76+
const Icon = ICON_BY_KIND[kind];
7677
return <Icon {...props} />;
7778
}

‎apps/web/src/components/Icons.tsx‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { type SVGProps, useId } from "react";
2-
import { CloudIcon, MonitorIcon } from "lucide-react";
32
import { cn } from "~/lib/utils";
43
export type Icon = React.FC<SVGProps<SVGSVGElement>>;
54

@@ -9,16 +8,6 @@ export const LinuxIcon: Icon = ({ className, ...props }) => (
98
</svg>
109
);
1110

12-
export function getEnvironmentIcon(input: {
13-
isPrimary: boolean;
14-
isWsl: boolean;
15-
remoteIcon?: Icon;
16-
}): Icon {
17-
if (input.isPrimary) return MonitorIcon;
18-
if (input.isWsl) return LinuxIcon;
19-
return input.remoteIcon ?? CloudIcon;
20-
}
21-
2211
export const GitHubIcon: Icon = (props) => (
2312
<svg {...props} viewBox="0 0 1024 1024" fill="none">
2413
<path

‎apps/web/src/components/LegacySidebar.tsx‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ import {
22
ArchiveIcon,
33
ArrowUpDownIcon,
44
ChevronRightIcon,
5-
CloudIcon,
65
FolderPlusIcon,
76
Globe2Icon,
8-
LaptopIcon,
97
LoaderIcon,
108
SearchIcon,
119
SquarePenIcon,
@@ -24,7 +22,6 @@ import {
2422
} from "./ThreadStatusIndicators";
2523
import { EnvironmentMachineIcon } from "./EnvironmentMachineIcon";
2624
import { ProjectFavicon } from "./ProjectFavicon";
27-
import { getEnvironmentIcon } from "./Icons";
2825
import { useAtomValue } from "@effect/atom-react";
2926
import { autoAnimate } from "@formkit/auto-animate";
3027
import React, { useCallback, useEffect, memo, useMemo, useRef, useState } from "react";
@@ -1153,11 +1150,11 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
11531150
isManualProjectSorting,
11541151
dragHandleProps,
11551152
} = props;
1156-
const EnvironmentIcon = getEnvironmentIcon({
1157-
isPrimary: false,
1158-
isWsl: project.allRemoteMembersAreWsl,
1159-
remoteIcon: project.allRemoteMembersAreDesktopLocal ? LaptopIcon : CloudIcon,
1160-
});
1153+
const environmentMachine = project.allRemoteMembersAreWsl
1154+
? "linux"
1155+
: project.allRemoteMembersAreDesktopLocal
1156+
? "laptop"
1157+
: "cloud";
11611158
const threadSortOrder = useClientSettings<SidebarThreadSortOrder>(
11621159
(settings) => settings.sidebarThreadSortOrder,
11631160
);
@@ -2399,7 +2396,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
23992396
/>
24002397
}
24012398
>
2402-
<EnvironmentIcon className="size-3" />
2399+
<EnvironmentMachineIcon kind={environmentMachine} className="size-3" />
24032400
</TooltipTrigger>
24042401
<TooltipPopup side="top">
24052402
{project.allRemoteMembersAreDesktopLocal

0 commit comments

Comments
 (0)