The best way to control Claude Code, Codex and more from any computer or phone
fix(desktop): a settings relaunch no longer replays the link that launched the app (#28464)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Victor Vogel committed
Nov 1, 2026 at 16:07 UTC
6014358bcf3e320949cb182663505824c779e014
2 files changed
+56
-3
apps/desktop/src/app/DesktopLifecycle.test.ts
+48
-1
@@ -5,6 +5,8 @@ import * as Layer from "effect/Layer";
5
import * as Ref from "effect/Ref";
6
import * as TestClock from "effect/testing/TestClock";
7
8
+import * as HostProcess from "@t3tools/shared/HostProcess";
9
+
10
import type * as Electron from "electron";
11
12
import * as ElectronApp from "../electron/ElectronApp.ts";
@@ -20,6 +22,7 @@ function layerElectronApp(
22
appListeners: Map<string, (...args: readonly unknown[]) => void>,
23
quit: Effect.Effect<void> = Effect.void,
24
exit: (code: number) => Effect.Effect<void> = () => Effect.void,
25
+ relaunch: (options: Electron.RelaunchOptions) => Effect.Effect<void> = () => Effect.void,
26
) {
27
const registerListener = (eventName: string, listener: (...args: readonly unknown[]) => void) =>
28
Effect.acquireRelease(
@@ -40,7 +43,7 @@ function layerElectronApp(
43
requestSingleInstanceLock: Effect.succeed(true),
44
quit,
45
exit,
43
- relaunch: () => Effect.void,
46
+ relaunch,
47
setPath: () => Effect.void,
48
setName: () => Effect.void,
49
setAboutPanelOptions: () => Effect.void,
@@ -223,6 +226,50 @@ describe("DesktopLifecycle", () => {
226
}),
227
);
228
229
+ it.effect("relaunches without the app link that launched it", () =>
230
+ Effect.gen(function* () {
231
+ const relaunched = yield* Deferred.make<Electron.RelaunchOptions>();
232
+ const layerEnvironment = Layer.succeed(DesktopEnvironment.DesktopEnvironment, {
233
+ platform: "linux",
234
+ isDevelopment: false,
235
+ } as DesktopEnvironment.DesktopEnvironment["Service"]);
236
+ const layer = DesktopLifecycle.layer.pipe(
237
+ Layer.provideMerge(
238
+ layerElectronApp(
239
+ new Map(),
240
+ Effect.void,
241
+ () => Effect.void,
242
+ (options) => Deferred.succeed(relaunched, options).pipe(Effect.asVoid),
243
+ ),
244
+ ),
245
+ Layer.provideMerge(layerElectronTheme),
246
+ Layer.provideMerge(layerElectronWindow()),
247
+ Layer.provideMerge(layerDesktopWindow()),
248
+ Layer.provideMerge(layerEnvironment),
249
+ Layer.provideMerge(DesktopShutdown.layer),
250
+ Layer.provideMerge(DesktopState.layer),
251
+ );
252
+
253
+ const options = yield* Effect.gen(function* () {
254
+ const lifecycle = yield* DesktopLifecycle.DesktopLifecycle;
255
+ yield* (yield* DesktopShutdown.DesktopShutdown).markComplete;
256
+ yield* lifecycle.relaunch("network access changed");
257
+ return yield* Deferred.await(relaunched);
258
+ }).pipe(
259
+ Effect.provide(layer),
260
+ Effect.provideService(HostProcess.ExecutablePath, "/opt/T3 Code/t3code"),
261
+ Effect.provideService(HostProcess.Arguments, [
262
+ "/opt/T3 Code/t3code",
263
+ "--no-sandbox",
264
+ "T3CODE://pair?token=spent",
265
+ "t3code://new?prompt=hello",
266
+ ]),
267
+ );
268
+
269
+ assert.deepEqual(options, { execPath: "/opt/T3 Code/t3code", args: ["--no-sandbox"] });
270
+ }),
271
+ );
272
+
273
it.effect("exits on a repeated quit only once shutdown has stalled", () =>
274
Effect.gen(function* () {
275
const appListeners = new Map<string, (...args: readonly unknown[]) => void>();
apps/desktop/src/app/DesktopLifecycle.ts
+8
-2
@@ -9,10 +9,13 @@ import * as Scope from "effect/Scope";
9
10
import type * as Electron from "electron";
11
12
+import * as HostProcess from "@t3tools/shared/HostProcess";
13
+
14
import * as DesktopEnvironment from "./DesktopEnvironment.ts";
15
import { makeComponentLogger } from "./DesktopObservability.ts";
16
import * as DesktopShutdown from "./DesktopShutdown.ts";
17
import * as ElectronApp from "../electron/ElectronApp.ts";
18
+import * as ElectronProtocol from "../electron/ElectronProtocol.ts";
19
import * as ElectronTheme from "../electron/ElectronTheme.ts";
20
import * as ElectronWindow from "../electron/ElectronWindow.ts";
21
import * as DesktopState from "./DesktopState.ts";
@@ -223,9 +226,12 @@ export const make = DesktopLifecycle.of({
226
yield* electronApp.exit(75);
227
return;
228
}
229
+ // Startup already acted on the app link that launched it; passing it on replays it.
230
+ const appLinkPrefix = `${ElectronProtocol.getDesktopScheme(environment.isDevelopment)}:`;
231
+ const args = yield* HostProcess.Arguments;
232
yield* electronApp.relaunch({
227
- execPath: process.execPath,
228
- args: process.argv.slice(1),
233
+ execPath: yield* HostProcess.ExecutablePath,
234
+ args: args.slice(1).filter((arg) => !arg.toLowerCase().startsWith(appLinkPrefix)),
235
});
236
yield* electronApp.exit(0);
237
}).pipe(