Skip to content

Commit 807a2af

Browse files
Merge commit 'c274a251510e4bb035f8479a7f1e96443cd2503c' into upstream-pr-checkout-keep-local-work
2 parents b82c169 + c274a25 commit 807a2af

15 files changed

Lines changed: 565 additions & 143 deletions

‎apps/desktop/src/wsl/DesktopWslEnvironment.test.ts‎

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,30 @@
22
import { describe, it } from "@effect/vitest";
33
import { afterAll, expect } from "vite-plus/test";
44
import * as NodeChildProcess from "node:child_process";
5+
import * as Deferred from "effect/Deferred";
56
import * as Duration from "effect/Duration";
67
import * as Effect from "effect/Effect";
78
import * as Fiber from "effect/Fiber";
9+
import * as FileSystem from "effect/FileSystem";
810
import * as Layer from "effect/Layer";
11+
import * as Option from "effect/Option";
12+
import * as Path from "effect/Path";
913
import * as Sink from "effect/Sink";
1014
import * as Stream from "effect/Stream";
1115
import * as TestClock from "effect/testing/TestClock";
1216
import { ChildProcessSpawner } from "effect/process";
1317

18+
import * as DesktopConfig from "../app/DesktopConfig.ts";
19+
import * as DesktopEnvironment from "../app/DesktopEnvironment.ts";
1420
import {
1521
buildWslRuntimeInstallScript,
1622
buildWslRuntimeInvalidateScript,
1723
buildWslRuntimePruneScript,
1824
buildWslRuntimeProbeScript,
1925
DesktopWslDistroListError,
26+
DesktopWslEnvironment,
2027
formatMissingToolsReason,
28+
layer as wslEnvironmentLayer,
2129
parseNodePath,
2230
parseNodeVersion,
2331
parseResolvedPath,
@@ -158,6 +166,102 @@ describe("probeWslDistros", () => {
158166
});
159167
});
160168

169+
describe("WSL command deadlines", () => {
170+
const makeControlledEnvironment = Effect.gen(function* () {
171+
const started = yield* Deferred.make<void>();
172+
const exited = yield* Deferred.make<ChildProcessSpawner.ExitCode>();
173+
const released = yield* Deferred.make<void>();
174+
const spawner = ChildProcessSpawner.make(() =>
175+
Effect.acquireRelease(
176+
Deferred.succeed(started, undefined).pipe(
177+
Effect.as(
178+
ChildProcessSpawner.makeHandle({
179+
pid: ChildProcessSpawner.ProcessId(1),
180+
exitCode: Deferred.await(exited),
181+
isRunning: Deferred.isDone(exited).pipe(Effect.map((done) => !done)),
182+
kill: () => Effect.void,
183+
unref: Effect.succeed(Effect.void),
184+
stdin: Sink.drain,
185+
stdout: Stream.empty,
186+
stderr: Stream.empty,
187+
all: Stream.empty,
188+
getInputFd: () => Sink.drain,
189+
getOutputFd: () => Stream.empty,
190+
}),
191+
),
192+
),
193+
() => Deferred.succeed(released, undefined),
194+
),
195+
);
196+
const environment = yield* DesktopWslEnvironment.pipe(
197+
Effect.provide(
198+
wslEnvironmentLayer.pipe(
199+
Layer.provide([
200+
DesktopEnvironment.layer({
201+
dirname: "/repo/apps/desktop",
202+
homeDirectory: "/home/test",
203+
platform: "win32",
204+
processArch: "x64",
205+
appVersion: "1.2.3",
206+
appPath: "/repo",
207+
isPackaged: true,
208+
resourcesPath: "/repo/resources",
209+
runningUnderArm64Translation: false,
210+
}).pipe(Layer.provide([Path.layer, DesktopConfig.layerTest({})])),
211+
FileSystem.layerNoop({ exists: () => Effect.succeed(true) }),
212+
Layer.succeed(ChildProcessSpawner.ChildProcessSpawner, spawner),
213+
]),
214+
),
215+
),
216+
);
217+
return { environment, started, exited, released };
218+
});
219+
220+
it.effect("waits for a cold distro to finish starting after 15 seconds", () =>
221+
Effect.gen(function* () {
222+
const { environment, started, exited, released } = yield* makeControlledEnvironment;
223+
const fiber = yield* environment.preWarm("Ubuntu").pipe(Effect.forkScoped);
224+
yield* Deferred.await(started);
225+
yield* TestClock.adjust(Duration.seconds(15));
226+
expect(yield* Deferred.isDone(released)).toBe(false);
227+
228+
yield* Deferred.succeed(exited, ChildProcessSpawner.ExitCode(0));
229+
yield* Fiber.join(fiber);
230+
expect(yield* Deferred.isDone(released)).toBe(true);
231+
}),
232+
);
233+
234+
it.effect("releases a stalled warmup process at the 30-second deadline", () =>
235+
Effect.gen(function* () {
236+
const { environment, started, released } = yield* makeControlledEnvironment;
237+
const fiber = yield* environment.preWarm("Ubuntu").pipe(Effect.forkScoped);
238+
yield* Deferred.await(started);
239+
yield* TestClock.adjust(Duration.seconds(29));
240+
expect(yield* Deferred.isDone(released)).toBe(false);
241+
242+
yield* TestClock.adjust(Duration.seconds(1));
243+
yield* Fiber.join(fiber);
244+
expect(yield* Deferred.isDone(released)).toBe(true);
245+
}),
246+
);
247+
248+
it.effect("still gives path conversion only 10 seconds and releases its process", () =>
249+
Effect.gen(function* () {
250+
const { environment, started, released } = yield* makeControlledEnvironment;
251+
const fiber = yield* environment
252+
.windowsToWslPath("Ubuntu", "C:\\project")
253+
.pipe(Effect.forkScoped);
254+
yield* Deferred.await(started);
255+
yield* TestClock.adjust(Duration.seconds(9));
256+
expect(yield* Deferred.isDone(released)).toBe(false);
257+
258+
yield* TestClock.adjust(Duration.seconds(1));
259+
expect(yield* Fiber.join(fiber)).toEqual(Option.none());
260+
expect(yield* Deferred.isDone(released)).toBe(true);
261+
}),
262+
);
263+
});
264+
161265
describe("WSL runtime cache", () => {
162266
it.each([
163267
[

‎apps/desktop/src/wsl/DesktopWslEnvironment.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import { parseWslDistroList, type WslDistro } from "./wslPathParsing.ts";
1717

1818
const PROCESS_TERMINATE_GRACE = Duration.seconds(1);
1919
const LIST_TIMEOUT = Duration.seconds(8);
20-
const PRE_WARM_TIMEOUT = Duration.seconds(10);
20+
// Booting a stopped distro needs more time than converting paths in a running one.
21+
const PRE_WARM_TIMEOUT = Duration.seconds(30);
2122
const WSLPATH_TIMEOUT = Duration.seconds(10);
2223
const PROBE_TIMEOUT = Duration.seconds(10);
2324
const TOOLCHAIN_TIMEOUT = Duration.seconds(10);

‎apps/mobile/src/features/settings/SettingsEnvironmentDetailRouteScreen.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ function EnvironmentDetail({ environmentId }: { readonly environmentId: Environm
248248
: "You are up to date."}
249249
</Text>
250250
) : null}
251-
{!supportsEnvironmentUpdate(config.environment.capabilities) ? (
251+
{checkedRelease?.targetVersion &&
252+
!supportsEnvironmentUpdate(config.environment.capabilities) ? (
252253
<Text className="text-sm text-foreground-muted">
253254
{capabilities?.serverSelfUpdate === "desktop-managed"
254255
? "Update the desktop app on this machine."

‎apps/mobile/src/features/threads/git/GitOverviewSheet.tsx‎

Lines changed: 56 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import {
2626
AndroidSheetHeader,
2727
} from "../../../components/ui/AndroidScreenHeader";
2828
import { AndroidAnchoredMenu } from "../../../components/ui/AndroidAnchoredMenu";
29+
import { ListRow } from "../../../components/ui/ListRow";
30+
import { ListSection } from "../../../components/ui/ListSection";
2931
import { ScreenContent } from "../../../components/ui/ScreenContent";
3032
import { useAdaptiveWorkspaceLayout } from "../../layout/AdaptiveWorkspaceLayout";
3133
import { AppText as Text } from "../../../components/ui/AppText";
@@ -40,7 +42,7 @@ import { useSelectedThreadGitState } from "../../../state/use-selected-thread-gi
4042
import { useSelectedThreadWorktree } from "../../../state/use-selected-thread-worktree";
4143
import { vcsEnvironment } from "../../../state/vcs";
4244
import { resolveGitOverviewReviewNavigationAction } from "./git-overview-navigation";
43-
import { MetaCard, SheetListRow, menuItemIconName, statusSummary } from "./gitSheetComponents";
45+
import { menuItemIconName, statusSummary } from "./gitSheetComponents";
4446
import {
4547
LinkedPullRequestRow,
4648
linkedPullRequestKey,
@@ -245,46 +247,34 @@ function GitOverviewSheetContent(props: GitOverviewSheetProps) {
245247
) : undefined
246248
}
247249
>
248-
<View
249-
className={`overflow-hidden bg-card android:rounded-[20px] ios:border ios:border-border ${
250-
isInspector ? "ios:rounded-2xl ios:px-3 ios:py-1" : "ios:rounded-[22px] ios:px-4 ios:py-1"
251-
}`}
252-
>
253-
{sheetMenuItems.map(({ item, disabledReason }, index) => (
254-
<View key={`${item.id}-${item.label}`}>
255-
{index > 0 && Platform.OS !== "android" ? (
256-
<View className="ml-12 h-px bg-border" />
257-
) : null}
258-
<SheetListRow
259-
icon={menuItemIconName(item.icon)}
260-
title={item.label}
261-
subtitle={disabledReason ?? rowStatusDetail(item)}
262-
disabled={item.disabled}
263-
onPress={() => void onPressMenuItem(item)}
264-
/>
265-
</View>
250+
<ListSection>
251+
{sheetMenuItems.map(({ item, disabledReason }) => (
252+
<ListRow
253+
key={`${item.id}-${item.label}`}
254+
icon={menuItemIconName(item.icon)}
255+
label={item.label}
256+
description={disabledReason ?? rowStatusDetail(item)}
257+
disabled={item.disabled}
258+
onPress={() => void onPressMenuItem(item)}
259+
/>
266260
))}
267261
{behindCount > 0 ? (
268-
<>
269-
{Platform.OS !== "android" ? <View className="ml-12 h-px bg-border" /> : null}
270-
<SheetListRow
271-
icon="arrow.down.circle"
272-
title="Pull latest"
273-
subtitle={
274-
canWriteSourceControl
275-
? `${behindCount} commit${behindCount === 1 ? "" : "s"} behind upstream`
276-
: "This connection cannot change source control."
277-
}
278-
disabled={!canWriteSourceControl || busy || !isRepo}
279-
onPress={() => void gitActions.onPullSelectedThreadBranch()}
280-
/>
281-
</>
262+
<ListRow
263+
icon="arrow.down.circle"
264+
label="Pull latest"
265+
description={
266+
canWriteSourceControl
267+
? `${behindCount} commit${behindCount === 1 ? "" : "s"} behind upstream`
268+
: "This connection cannot change source control."
269+
}
270+
disabled={!canWriteSourceControl || busy || !isRepo}
271+
onPress={() => void gitActions.onPullSelectedThreadBranch()}
272+
/>
282273
) : null}
283-
{Platform.OS !== "android" ? <View className="ml-12 h-px bg-border" /> : null}
284-
<SheetListRow
274+
<ListRow
285275
icon="text.bubble"
286-
title="Review changes"
287-
subtitle="Inspect changes, uncommitted edits, and turn diffs"
276+
label="Review changes"
277+
description="Inspect changes, uncommitted edits, and turn diffs"
288278
disabled={busy || !isRepo}
289279
onPress={() => {
290280
const params = { environmentId, threadId };
@@ -295,11 +285,10 @@ function GitOverviewSheetContent(props: GitOverviewSheetProps) {
295285
);
296286
}}
297287
/>
298-
{Platform.OS !== "android" ? <View className="ml-12 h-px bg-border" /> : null}
299-
<SheetListRow
288+
<ListRow
300289
icon="point.topleft.down.curvedto.point.bottomright.up"
301-
title="Branches & worktrees"
302-
subtitle={
290+
label="Branches & worktrees"
291+
description={
303292
canChangeThreadBranch
304293
? "Switch branch, create branch, or move to a worktree"
305294
: "View branches and worktrees"
@@ -313,39 +302,37 @@ function GitOverviewSheetContent(props: GitOverviewSheetProps) {
313302
}
314303
/>
315304
{linkedPrActions.canLink ? (
316-
<>
317-
{Platform.OS !== "android" ? <View className="ml-12 h-px bg-border" /> : null}
318-
<SheetListRow
319-
icon="link"
320-
title="Link pull request"
321-
subtitle="Attach a pull request by URL or number"
322-
onPress={linkedPrActions.promptLink}
323-
/>
324-
</>
305+
<ListRow
306+
icon="link"
307+
label="Link pull request"
308+
description="Attach a pull request by URL or number"
309+
onPress={linkedPrActions.promptLink}
310+
/>
325311
) : null}
326-
</View>
312+
</ListSection>
327313

328314
{linkedPrLines.length > 0 ? (
329-
<View className="gap-2">
330-
<Text className="px-1 text-xs font-t3-bold text-foreground-muted">
331-
Linked pull requests
332-
</Text>
333-
<View className="overflow-hidden bg-card android:rounded-[20px] ios:rounded-2xl ios:border ios:border-border">
334-
{linkedPrLines.map((line, index) => (
335-
<LinkedPullRequestRow
336-
key={linkedPullRequestKey(line)}
337-
line={line}
338-
separator={index < linkedPrLines.length - 1}
339-
surfaceClassName="text-card"
340-
openPullRequest={openPullRequest}
341-
actions={linkedPrActions}
342-
/>
343-
))}
344-
</View>
345-
</View>
315+
<ListSection title="Linked pull requests">
316+
{linkedPrLines.map((line, index) => (
317+
<LinkedPullRequestRow
318+
key={linkedPullRequestKey(line)}
319+
line={line}
320+
separator={index < linkedPrLines.length - 1}
321+
surfaceClassName="text-grouped-card"
322+
openPullRequest={openPullRequest}
323+
actions={linkedPrActions}
324+
/>
325+
))}
326+
</ListSection>
346327
) : null}
347328

348-
{currentWorktreePath ? <MetaCard label="Worktree" value={currentWorktreePath} /> : null}
329+
{currentWorktreePath ? (
330+
<ListSection title="Worktree">
331+
<Text selectable textRole="footnote" className="p-4 text-foreground-muted">
332+
{currentWorktreePath}
333+
</Text>
334+
</ListSection>
335+
) : null}
349336
</ScrollView>
350337
);
351338

‎apps/mobile/src/features/threads/git/gitSheetComponents.tsx‎

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -69,61 +69,6 @@ export function SheetActionButton(props: {
6969
);
7070
}
7171

72-
export function MetaCard(props: { readonly label: string; readonly value: string }) {
73-
return (
74-
<View className="bg-card px-4 py-3 android:rounded-[20px] ios:rounded-[18px] ios:border ios:border-border">
75-
<Text className="text-foreground-muted text-2xs font-t3-bold tracking-[0.9px] uppercase">
76-
{props.label}
77-
</Text>
78-
<Text selectable className="text-foreground text-sm font-medium" numberOfLines={1}>
79-
{props.value}
80-
</Text>
81-
</View>
82-
);
83-
}
84-
85-
export function SheetListRow(props: {
86-
readonly icon: ComponentProps<typeof SymbolView>["name"];
87-
readonly iconTintClassName?: string | undefined;
88-
readonly title: string;
89-
readonly subtitle?: string | null;
90-
readonly disabled?: boolean;
91-
readonly onPress: () => void;
92-
}) {
93-
return (
94-
<Pressable
95-
className="flex-row items-center py-3 disabled:opacity-[0.45] android:min-h-16 android:gap-4 android:px-4 android:active:bg-subtle ios:gap-3 ios:px-1"
96-
disabled={props.disabled}
97-
onPress={props.onPress}
98-
>
99-
<View className="items-center justify-center android:size-6 ios:bg-subtle ios:h-9 ios:w-9 ios:rounded-full">
100-
<SymbolView
101-
name={props.icon}
102-
size={Platform.OS === "android" ? 24 : 16}
103-
tintColorClassName={props.iconTintClassName ?? "accent-icon"}
104-
type="monochrome"
105-
/>
106-
</View>
107-
<View className="flex-1 gap-0.5">
108-
<Text className="text-foreground text-base android:font-t3-medium ios:font-t3-bold">
109-
{props.title}
110-
</Text>
111-
{props.subtitle ? (
112-
<Text className="text-foreground-muted text-xs leading-snug">{props.subtitle}</Text>
113-
) : null}
114-
</View>
115-
{Platform.OS !== "android" ? (
116-
<SymbolView
117-
name="chevron.right"
118-
size={13}
119-
tintColorClassName="accent-icon-subtle"
120-
type="monochrome"
121-
/>
122-
) : null}
123-
</Pressable>
124-
);
125-
}
126-
12772
export function menuItemIconName(
12873
icon: "commit" | "push" | "pr",
12974
): ComponentProps<typeof SymbolView>["name"] {

0 commit comments

Comments
 (0)