Skip to content

Commit b84f59e

Browse files
committed
Merge remote-tracking branch 'github/main' into fix/forge-diff-renames
2 parents f1956f5 + 9f63268 commit b84f59e

78 files changed

Lines changed: 3032 additions & 348 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
import { assert, it } from "@effect/vitest";
2+
import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
3+
import * as Deferred from "effect/Deferred";
4+
import * as Effect from "effect/Effect";
5+
import * as Layer from "effect/Layer";
6+
import * as FileSystem from "effect/FileSystem";
7+
import * as Path from "effect/Path";
8+
import * as HttpClient from "effect/http/HttpClient";
9+
import * as NetService from "@t3tools/shared/Net";
10+
import * as Fiber from "effect/Fiber";
11+
import * as Option from "effect/Option";
12+
import * as Ref from "effect/Ref";
13+
import * as Stream from "effect/Stream";
14+
import { vi } from "vite-plus/test";
15+
16+
vi.mock("electron", () => ({}));
17+
vi.mock("@clerk/electron", () => ({ createClerkBridge: vi.fn() }));
18+
vi.mock("@clerk/electron/storage", () => ({ storage: vi.fn() }));
19+
vi.mock("../ipc/DesktopIpcHandlers.ts", () => ({
20+
installDesktopIpcHandlers: () => Effect.void,
21+
}));
22+
vi.mock("../updates/DesktopRemoteUpdates.ts", () => ({ listen: Effect.void }));
23+
vi.mock("./DesktopStartupRecovery.ts", () => ({ listen: Effect.void }));
24+
25+
import * as DesktopApp from "./DesktopApp.ts";
26+
import * as DesktopAppActivation from "./DesktopAppActivation.ts";
27+
import * as DesktopAppIdentity from "./DesktopAppIdentity.ts";
28+
import * as DesktopClerk from "./DesktopClerk.ts";
29+
import * as DesktopEnvironment from "./DesktopEnvironment.ts";
30+
import * as DesktopLegacyLocalStorage from "./DesktopLegacyLocalStorage.ts";
31+
import * as DesktopLifecycle from "./DesktopLifecycle.ts";
32+
import * as DesktopLinuxUrlHandler from "./DesktopLinuxUrlHandler.ts";
33+
import * as DesktopPreReadyPlatform from "./DesktopPreReadyPlatform.ts";
34+
import * as DesktopShutdown from "./DesktopShutdown.ts";
35+
import * as DesktopState from "./DesktopState.ts";
36+
import * as DesktopBackendPool from "../backend/DesktopBackendPool.ts";
37+
import * as DesktopServerExposure from "../backend/DesktopServerExposure.ts";
38+
import * as ElectronApp from "../electron/ElectronApp.ts";
39+
import * as ElectronDialog from "../electron/ElectronDialog.ts";
40+
import * as ElectronProtocol from "../electron/ElectronProtocol.ts";
41+
import * as ElectronSafeStorage from "../electron/ElectronSafeStorage.ts";
42+
import * as PreviewPasskeys from "../preview/Passkeys.ts";
43+
import * as DesktopAppSettings from "../settings/DesktopAppSettings.ts";
44+
import * as DesktopShellEnvironment from "../shell/DesktopShellEnvironment.ts";
45+
import * as DesktopSnapShot from "../snapShot/DesktopSnapShot.ts";
46+
import * as DesktopRendererHistory from "../telemetry/DesktopRendererHistory.ts";
47+
import * as DesktopUpdates from "../updates/DesktopUpdates.ts";
48+
import * as DesktopApplicationMenu from "../window/DesktopApplicationMenu.ts";
49+
import * as DesktopWindow from "../window/DesktopWindow.ts";
50+
import * as DesktopWslBackend from "../wsl/DesktopWslBackend.ts";
51+
52+
import * as BrowserImport from "../preview/BrowserImport/BrowserImport.ts";
53+
import * as DesktopBackendConfiguration from "../backend/DesktopBackendConfiguration.ts";
54+
import * as DesktopCliCommand from "./DesktopCliCommand.ts";
55+
import * as DesktopClientSettings from "../settings/DesktopClientSettings.ts";
56+
import * as DesktopConnectionCatalogStore from "./DesktopConnectionCatalogStore.ts";
57+
import * as DesktopIpc from "../ipc/DesktopIpc.ts";
58+
import * as DesktopLocalEnvironmentAuth from "../backend/DesktopLocalEnvironmentAuth.ts";
59+
import * as DesktopManagedPolicy from "./DesktopManagedPolicy.ts";
60+
import * as DesktopSshEnvironment from "../ssh/DesktopSshEnvironment.ts";
61+
import * as DesktopSshPasswordPrompts from "../ssh/DesktopSshPasswordPrompts.ts";
62+
import * as DesktopTelemetryPublisher from "../telemetry/DesktopTelemetryPublisher.ts";
63+
import * as DesktopWebLinks from "./DesktopWebLinks.ts";
64+
import * as DesktopWslEnvironment from "../wsl/DesktopWslEnvironment.ts";
65+
import * as ElectronMenu from "../electron/ElectronMenu.ts";
66+
import * as ElectronShell from "../electron/ElectronShell.ts";
67+
import * as ElectronTheme from "../electron/ElectronTheme.ts";
68+
import * as ElectronWindow from "../electron/ElectronWindow.ts";
69+
import * as MacPermissions from "../permissions/MacPermissions.ts";
70+
import * as PreviewManager from "../preview/Manager.ts";
71+
72+
it.effect(
73+
"starts the backend and window while Linux registration is stalled and cancels it on shutdown",
74+
() =>
75+
Effect.gen(function* () {
76+
const registrationStarted = yield* Deferred.make<void>();
77+
const releaseRegistration = yield* Deferred.make<void>();
78+
const registrationStopped = yield* Deferred.make<void>();
79+
const windowStarted = yield* Deferred.make<void>();
80+
const quitting = yield* Ref.make(false);
81+
const events: string[] = [];
82+
const record = (event: string) =>
83+
Effect.sync(() => {
84+
events.push(event);
85+
});
86+
const runApp = DesktopApp.program
87+
.pipe(
88+
Effect.provide(NodeCrypto.layer),
89+
Effect.provideService(DesktopAppIdentity.DesktopAppIdentity, {
90+
resolveUserDataPath: Effect.succeed("/isolated/userdata"),
91+
configure: record("identity"),
92+
} as DesktopAppIdentity.DesktopAppIdentity["Service"]),
93+
Effect.provideService(ElectronApp.ElectronApp, {
94+
setPath: () => Effect.void,
95+
whenReady: record("ready"),
96+
} as unknown as ElectronApp.ElectronApp["Service"]),
97+
Effect.provideService(ElectronDialog.ElectronDialog, {
98+
showErrorBox: () => Effect.die("unexpected fatal startup error"),
99+
} as unknown as ElectronDialog.ElectronDialog["Service"]),
100+
Effect.provideService(DesktopEnvironment.DesktopEnvironment, {
101+
platform: "linux",
102+
isDevelopment: false,
103+
isPackaged: true,
104+
configuredBackendPort: Option.some(3773),
105+
defaultDesktopSettings: { serverExposureMode: "local-only" },
106+
} as unknown as DesktopEnvironment.DesktopEnvironment["Service"]),
107+
Effect.provideService(DesktopPreReadyPlatform.DesktopPreReadyElectronOptions, {
108+
linux: null,
109+
linuxPasswordStoreCommandLine: "basic",
110+
}),
111+
Effect.provideService(DesktopShellEnvironment.DesktopShellEnvironment, {
112+
installIntoProcess: Effect.succeed(true),
113+
awaitDiscovery: Effect.succeed(true),
114+
updates: Stream.empty,
115+
}),
116+
Effect.provideService(DesktopAppSettings.DesktopAppSettings, {
117+
load: Effect.void,
118+
get: Effect.succeed({
119+
localEnvironmentEnabled: true,
120+
serverExposureMode: "local-only",
121+
}),
122+
} as unknown as DesktopAppSettings.DesktopAppSettings["Service"]),
123+
Effect.provideService(DesktopLifecycle.DesktopLifecycle, {
124+
register: Effect.void,
125+
relaunch: () => Effect.void,
126+
}),
127+
Effect.provideService(DesktopClerk.DesktopClerk, {
128+
configure: Effect.void,
129+
} as DesktopClerk.DesktopClerk["Service"]),
130+
Effect.provideService(ElectronSafeStorage.ElectronSafeStorage, {
131+
selectedStorageBackend: Effect.succeedNone,
132+
} as unknown as ElectronSafeStorage.ElectronSafeStorage["Service"]),
133+
Effect.provideService(PreviewPasskeys.PreviewPasskeys, {
134+
configure: Effect.void,
135+
} as PreviewPasskeys.PreviewPasskeys["Service"]),
136+
Effect.provideService(DesktopApplicationMenu.DesktopApplicationMenu, {
137+
configure: Effect.void,
138+
}),
139+
Effect.provideService(DesktopUpdates.DesktopUpdates, {
140+
configure: Effect.void,
141+
} as unknown as DesktopUpdates.DesktopUpdates["Service"]),
142+
Effect.provideService(DesktopLinuxUrlHandler.DesktopLinuxUrlHandler, {
143+
register: Deferred.succeed(registrationStarted, undefined).pipe(
144+
Effect.andThen(Deferred.await(releaseRegistration)),
145+
Effect.ensuring(Deferred.succeed(registrationStopped, undefined)),
146+
),
147+
}),
148+
)
149+
.pipe(
150+
Effect.provideService(ElectronProtocol.ElectronProtocol, {
151+
registerDesktopProtocol: () => Effect.void,
152+
} as unknown as ElectronProtocol.ElectronProtocol["Service"]),
153+
Effect.provideService(DesktopLegacyLocalStorage.DesktopLegacyLocalStorage, {
154+
load: () => Effect.void,
155+
} as unknown as DesktopLegacyLocalStorage.DesktopLegacyLocalStorage["Service"]),
156+
Effect.provideService(DesktopSnapShot.DesktopSnapShot, {
157+
initialize: Effect.void,
158+
} as DesktopSnapShot.DesktopSnapShot["Service"]),
159+
Effect.provideService(DesktopState.DesktopState, {
160+
quitting,
161+
} as DesktopState.DesktopState["Service"]),
162+
Effect.provideService(DesktopWindow.DesktopWindow, {
163+
ensureMain: record("window").pipe(
164+
Effect.andThen(Deferred.succeed(windowStarted, undefined)),
165+
),
166+
} as unknown as DesktopWindow.DesktopWindow["Service"]),
167+
Effect.provideService(DesktopBackendPool.DesktopBackendPool, {
168+
primary: Effect.succeed({
169+
start: record("backend"),
170+
currentConfig: Effect.succeedSome({ preflightFailure: Option.none() }),
171+
}),
172+
list: Effect.succeed([]),
173+
} as unknown as DesktopBackendPool.DesktopBackendPool["Service"]),
174+
Effect.provideService(DesktopServerExposure.DesktopServerExposure, {
175+
configureFromSettings: () => Effect.succeed({ mode: "local-only" }),
176+
backendConfig: Effect.succeed({ httpBaseUrl: new URL("http://127.0.0.1:3773") }),
177+
} as unknown as DesktopServerExposure.DesktopServerExposure["Service"]),
178+
Effect.provideService(DesktopWslBackend.DesktopWslBackend, {
179+
reconcile: Effect.void,
180+
} as DesktopWslBackend.DesktopWslBackend["Service"]),
181+
Effect.provideService(DesktopAppActivation.DesktopAppActivation, {
182+
start: Effect.void,
183+
} as unknown as DesktopAppActivation.DesktopAppActivation["Service"]),
184+
Effect.provideService(DesktopRendererHistory.DesktopRendererHistory, {
185+
shutdown: Effect.void,
186+
} as DesktopRendererHistory.DesktopRendererHistory["Service"]),
187+
);
188+
const app = yield* runApp.pipe(
189+
Effect.provide(
190+
Layer.mergeAll(
191+
Layer.mock(BrowserImport.BrowserImport, {}),
192+
Layer.mock(DesktopBackendConfiguration.DesktopBackendConfiguration, {}),
193+
Layer.mock(DesktopCliCommand.DesktopCliCommand, {}),
194+
Layer.mock(DesktopClientSettings.DesktopClientSettings, {}),
195+
Layer.mock(DesktopConnectionCatalogStore.DesktopConnectionCatalogStore, {}),
196+
Layer.mock(DesktopIpc.DesktopIpc, {}),
197+
Layer.mock(DesktopLocalEnvironmentAuth.DesktopLocalEnvironmentAuth, {}),
198+
Layer.mock(DesktopManagedPolicy.DesktopManagedPolicy, {}),
199+
Layer.mock(DesktopSshEnvironment.DesktopSshEnvironment, {}),
200+
Layer.mock(DesktopSshPasswordPrompts.DesktopSshPasswordPrompts, {}),
201+
Layer.mock(DesktopTelemetryPublisher.DesktopTelemetryPublisher, {}),
202+
Layer.mock(DesktopWebLinks.DesktopWebLinks, {}),
203+
Layer.mock(DesktopWslEnvironment.DesktopWslEnvironment, {}),
204+
Layer.mock(ElectronMenu.ElectronMenu, {}),
205+
Layer.mock(ElectronShell.ElectronShell, {}),
206+
Layer.mock(ElectronTheme.ElectronTheme, {}),
207+
Layer.mock(ElectronWindow.ElectronWindow, {}),
208+
Layer.mock(MacPermissions.MacPermissions, {}),
209+
Layer.mock(PreviewManager.PreviewManager, {
210+
isBrowserPartition: () => {
211+
throw new Error("unexpected browser partition lookup");
212+
},
213+
}),
214+
FileSystem.layerNoop({}),
215+
Layer.mock(NetService.NetService, {}),
216+
Path.layer,
217+
Layer.succeed(
218+
HttpClient.HttpClient,
219+
HttpClient.make(() => Effect.die("unexpected HTTP request")),
220+
),
221+
),
222+
),
223+
Effect.forkScoped,
224+
);
225+
yield* Deferred.await(registrationStarted);
226+
yield* Deferred.await(windowStarted);
227+
assert.deepEqual(events, ["identity", "ready", "identity", "backend", "window"]);
228+
assert.isFalse(yield* Deferred.isDone(registrationStopped));
229+
yield* (yield* DesktopShutdown.DesktopShutdown).request;
230+
yield* Fiber.join(app);
231+
assert.isTrue(yield* Deferred.isDone(registrationStopped));
232+
}).pipe(Effect.provide(DesktopShutdown.layer)),
233+
);

‎apps/desktop/src/app/DesktopApp.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,8 @@ const startup = Effect.gen(function* () {
337337
yield* updates.configure;
338338
yield* DesktopRemoteUpdates.listen;
339339
yield* DesktopStartupRecovery.listen;
340-
yield* linuxUrlHandler.register;
340+
// Portal identity is prepared pre-ready; MIME helpers must not gate the backend or window.
341+
yield* linuxUrlHandler.register.pipe(Effect.forkScoped);
341342
yield* bootstrap.pipe(Effect.catchCause((cause) => fatalStartupCause("bootstrap", cause)));
342343
}).pipe(Effect.withSpan("desktop.startup"));
343344

‎apps/mobile/src/components/ui/Button.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface ButtonProps {
1414
readonly loading?: boolean;
1515
readonly tone?: "primary" | "secondary" | "danger" | "text" | "contrast";
1616
readonly fullWidth?: boolean;
17+
readonly size?: "default" | "compact";
1718
}
1819

1920
const TONE_CLASS_NAMES = {
@@ -36,7 +37,8 @@ export function Button(props: ButtonProps) {
3637
disabled={disabled}
3738
onPress={props.onPress}
3839
className={cn(
39-
"min-h-12 flex-row items-center justify-center gap-2 rounded-full px-6 active:opacity-70",
40+
"flex-row items-center justify-center gap-2 rounded-full active:opacity-70",
41+
props.size === "compact" ? "min-h-10 px-5" : "min-h-12 px-6",
4042
props.fullWidth ? "w-full" : "self-start",
4143
disabled ? "bg-subtle-strong" : containerClassName,
4244
)}

‎apps/mobile/src/components/ui/Toast.tsx‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { cn } from "../../lib/cn";
12
import { MOBILE_MOTION, MOBILE_SHAPE } from "../../lib/designTokens";
23
import { useCallback, useEffect, useLayoutEffect, useState } from "react";
34
import { AccessibilityInfo, Platform, StyleSheet, View, useWindowDimensions } from "react-native";
@@ -45,15 +46,19 @@ export function Toast(props: ToastProps) {
4546
function ToastContent(props: ToastProps & { readonly glassReady?: boolean }) {
4647
const { fontScale } = useWindowDimensions();
4748
const { colorScheme } = useControlTheme();
48-
const borderRadius = Platform.OS === "ios" ? 31 : MOBILE_SHAPE.toast;
49+
const borderRadius = Platform.OS === "ios" ? 28 : MOBILE_SHAPE.toast;
4950
// Explicit single-line notices reserve the action's width and truncate the text.
5051
const inlineAction = props.singleLine || (!props.description && fontScale < 1.5);
5152
const message =
5253
props.singleLine && props.description
5354
? `${props.message}: ${props.description}`
5455
: props.message;
5556
const action = props.action ? (
56-
<Button label={props.action.label} onPress={props.action.onPress} />
57+
<Button
58+
label={props.action.label}
59+
onPress={props.action.onPress}
60+
size={Platform.OS === "ios" ? "compact" : "default"}
61+
/>
5762
) : null;
5863
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- announces the toast message to VoiceOver through AccessibilityInfo
5964
useEffect(() => {
@@ -64,10 +69,16 @@ function ToastContent(props: ToastProps & { readonly glassReady?: boolean }) {
6469
key={props.glassReady === false ? "entering" : "settled"}
6570
chrome={Platform.OS === "ios" && colorScheme === "dark" ? "none" : undefined}
6671
tintColor={Platform.OS === "ios" ? null : undefined}
67-
className={Platform.OS === "ios" ? "bg-transparent p-3" : "p-3"}
72+
className={Platform.OS === "ios" ? "bg-transparent p-2" : "p-3"}
6873
style={{ borderRadius }}
6974
>
70-
<View className="flex-row items-center gap-3">
75+
<View
76+
className={cn(
77+
"flex-row items-center gap-3",
78+
// Match the leading inset to the action label's, which sits inside the button's padding.
79+
Platform.OS === "ios" && inlineAction && action && "pl-5",
80+
)}
81+
>
7182
{props.busy ? (
7283
<AppActivityIndicator />
7384
) : (

‎apps/server/src/checkpointing/CheckpointStore.test.ts‎

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,21 +153,23 @@ it.layer(layerTest)("CheckpointStore.layer", (it) => {
153153
}),
154154
);
155155

156-
it.effect("keeps a/ and b/ patch prefixes when the repository disables them", () =>
156+
it.effect("keeps the patch format clients parse when the repository changes it", () =>
157157
Effect.gen(function* () {
158158
const tmp = yield* makeTmpDir();
159159
yield* initRepoWithCommit(tmp);
160160
yield* git(tmp, ["config", "diff.noprefix", "true"]);
161+
yield* git(tmp, ["config", "diff.suppressBlankEmpty", "true"]);
161162
const checkpointStore = yield* CheckpointStore.CheckpointStore;
162163
const threadId = ThreadId.make("thread-checkpoint-store-noprefix");
163164
const fromCheckpointRef = checkpointRefForThreadTurn(threadId, 0);
164165
const toCheckpointRef = checkpointRefForThreadTurn(threadId, 1);
165166

167+
yield* writeTextFile(NodePath.join(tmp, "README.md"), "# test\n\nbefore\n");
166168
yield* checkpointStore.captureCheckpoint({
167169
cwd: tmp,
168170
checkpointRef: fromCheckpointRef,
169171
});
170-
yield* writeTextFile(NodePath.join(tmp, "README.md"), "# changed\n");
172+
yield* writeTextFile(NodePath.join(tmp, "README.md"), "# test\n\nafter\n");
171173
yield* checkpointStore.captureCheckpoint({
172174
cwd: tmp,
173175
checkpointRef: toCheckpointRef,
@@ -181,6 +183,7 @@ it.layer(layerTest)("CheckpointStore.layer", (it) => {
181183
});
182184

183185
expect(diff).toContain("diff --git a/README.md b/README.md");
186+
expect(diff).toContain(" # test\n \n-before\n+after\n");
184187
}),
185188
);
186189

@@ -522,5 +525,40 @@ it.layer(layerTest)("CheckpointStore.layer", (it) => {
522525
);
523526
}),
524527
);
528+
529+
it.effect("keeps paths from signed commits under log.showSignature", () =>
530+
Effect.gen(function* () {
531+
const tmp = yield* makeTmpDir();
532+
yield* initRepoWithCommit(tmp);
533+
const signingKey = NodePath.join(yield* makeTmpDir("checkpoint-signing-key-"), "key");
534+
yield* (yield* VcsProcess.VcsProcess).run({
535+
operation: "CheckpointStore.test.sshKeygen",
536+
command: "ssh-keygen",
537+
cwd: tmp,
538+
args: ["-q", "-t", "ed25519", "-N", "", "-f", signingKey],
539+
timeoutMs: 10_000,
540+
});
541+
yield* git(tmp, ["config", "gpg.format", "ssh"]);
542+
yield* git(tmp, ["config", "user.signingkey", `${signingKey}.pub`]);
543+
yield* git(tmp, ["config", "log.showSignature", "true"]);
544+
const checkpointStore = yield* CheckpointStore.CheckpointStore;
545+
const threadId = ThreadId.make("checkpoint-authored-paths-signed");
546+
const refs = {
547+
cwd: tmp,
548+
fromCheckpointRef: checkpointRefForThreadTurn(threadId, 0),
549+
toCheckpointRef: checkpointRefForThreadTurn(threadId, 1),
550+
};
551+
yield* checkpointStore.captureCheckpoint({
552+
cwd: tmp,
553+
checkpointRef: refs.fromCheckpointRef,
554+
});
555+
yield* writeTextFile(NodePath.join(tmp, "kept.txt"), "kept\n");
556+
yield* git(tmp, ["add", "kept.txt"]);
557+
yield* git(tmp, ["commit", "-S", "-m", "kept"]);
558+
yield* checkpointStore.captureCheckpoint({ cwd: tmp, checkpointRef: refs.toCheckpointRef });
559+
560+
expect(yield* checkpointStore.listAuthoredPaths(refs)).toEqual(new Set(["kept.txt"]));
561+
}),
562+
);
525563
});
526564
});

0 commit comments

Comments
 (0)