@devries-cameron20 / t3code Mirror · read-only / commits / 7fd2e09e38
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 18:15 UTC

fix(desktop): support Linux distro protocol launchers (#24591)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 24, 2026 at 16:19 UTC 7fd2e09e381a61f427da09dd7a8f2c9c1558fe59
6 files changed +48 -2
apps/desktop/src/app/DesktopConfig.ts
+1
@@ -55,6 +55,7 @@ export const DesktopConfig = Config.all({
55 otlpProtocol: Config.schema(OtlpProtocol, "T3CODE_OTLP_PROTOCOL").pipe(
56 Config.withDefault("http/json"),
57 ),
58 + desktopLauncherPath: trimmedString("T3CODE_DESKTOP_LAUNCHER_PATH"),
59 appImagePath: trimmedString("APPIMAGE"),
60 disableAutoUpdate: optionalBoolean("T3CODE_DISABLE_AUTO_UPDATE"),
61 mockUpdates: optionalBoolean("T3CODE_DESKTOP_MOCK_UPDATES"),
apps/desktop/src/app/DesktopEnvironment.ts
+2
@@ -77,6 +77,7 @@ export class DesktopEnvironment extends Context.Service<
77 readonly linuxDesktopEntryName: string;
78 readonly linuxWmClass: string;
79 readonly linuxApplicationsDir: string;
80 + readonly desktopLauncherPath: Option.Option<string>;
81 readonly appImagePath: Option.Option<string>;
82 readonly defaultDesktopSettings: DesktopAppSettings.DesktopSettings;
83 readonly runtimeInfo: DesktopRuntimeInfo;
@@ -233,6 +234,7 @@ const make = Effect.fn("desktop.environment.make")(function* (
234 linuxDesktopEntryName: resolveLinuxDesktopEntryName(isDevelopment),
235 linuxWmClass: isDevelopment ? "t3code-dev" : "t3code",
236 linuxApplicationsDir,
237 + desktopLauncherPath: config.desktopLauncherPath,
238 appImagePath: config.appImagePath,
239 defaultDesktopSettings: DesktopAppSettings.resolveDefaultDesktopSettings(input.appVersion),
240 runtimeInfo: resolveDesktopRuntimeInfo({
apps/desktop/src/app/DesktopLinuxUrlHandler.test.ts
+13
@@ -31,6 +31,7 @@ const makeEnvironment = (path: Path.Path, overrides: Record<string, unknown> = {
31 linuxDesktopEntryName: "com.t3tools.T3Code.desktop",
32 linuxWmClass: "t3code",
33 linuxApplicationsDir: "/home/alice/.local/share/applications",
34 + desktopLauncherPath: Option.none(),
35 appImagePath: Option.some("/home/alice/Applications/T3-Code.AppImage"),
36 path,
37 ...overrides,
@@ -228,6 +229,18 @@ describe("DesktopLinuxUrlHandler", () => {
229 });
230 });
231
232 + it.effect("launches a distribution package through its configured launcher", () => {
233 + const recorded = emptyRecording();
234 +
235 + return Effect.gen(function* () {
236 + yield* runRegister(recorded, {
237 + environment: { desktopLauncherPath: Option.some("/opt/T3 Code/t3code") },
238 + });
239 +
240 + assert.include(recorded.files[0]?.content, 'Exec="/opt/T3 Code/t3code" %U');
241 + });
242 + });
243 +
244 it.effect("does not rewrite the pre-ready entry while the portal can be reading it", () => {
245 const recorded = emptyRecording();
246
apps/desktop/src/app/DesktopLinuxUrlHandler.ts
+6 -1
@@ -141,9 +141,14 @@ export const make = Effect.gen(function* () {
141 const themeIconDir = environment.path.join(hicolorDir, LINUX_THEME_ICON_SIZE, "apps");
142
143 const writeDesktopEntry = Effect.gen(function* () {
144 + // Distribution packages that run on a shared Electron set
145 + // T3CODE_DESKTOP_LAUNCHER_PATH, because process.execPath is that Electron.
146 // Inside the mounted AppImage, process.execPath points at a transient
147 // /tmp/.mount_* path — the handler must launch the AppImage itself.
146 - const execTarget = Option.getOrElse(environment.appImagePath, () => process.execPath);
148 + const execTarget = environment.desktopLauncherPath.pipe(
149 + Option.orElse(() => environment.appImagePath),
150 + Option.getOrElse(() => process.execPath),
151 + );
152 const content = renderUrlHandlerDesktopEntry({
153 displayName: environment.displayName,
154 execTarget,
apps/desktop/src/app/DesktopPreReadyPlatform.test.ts
+22
@@ -166,6 +166,28 @@ describe("DesktopPreReadyPlatform", () => {
166 ).pipe(Effect.ensuring(Effect.sync(() => vi.unstubAllEnvs())));
167 });
168
169 + it.effect("points the early portal entry at a configured distribution launcher", () => {
170 + vi.stubEnv("VITE_DEV_SERVER_URL", "");
171 + vi.stubEnv("XDG_DATA_HOME", "/xdg");
172 + vi.stubEnv("APPIMAGE", "/Applications/current.AppImage");
173 + vi.stubEnv("T3CODE_DESKTOP_LAUNCHER_PATH", " /opt/T3 Code/t3code ");
174 + getSwitchValueMock.mockReturnValue("");
175 +
176 + return Effect.scoped(
177 + Effect.gen(function* () {
178 + yield* Layer.build(
179 + DesktopPreReadyPlatform.layer.pipe(
180 + Layer.provide(Layer.succeed(HostProcess.Platform, "linux")),
181 + ),
182 + );
183 + const entry = writeFileSyncMock.mock.calls.find(
184 + ([path]) => path === "/xdg/applications/com.t3tools.T3Code.desktop",
185 + )?.[1];
186 + assert.include(entry, 'Exec="/opt/T3 Code/t3code" %U');
187 + }),
188 + ).pipe(Effect.ensuring(Effect.sync(() => vi.unstubAllEnvs())));
189 + });
190 +
191 it.effect(
192 "acquires a synchronous pre-ready layer before an asynchronous Clerk-shaped layer",
193 () =>
apps/desktop/src/app/DesktopPreReadyPlatform.ts
+4 -1
@@ -109,7 +109,10 @@ export const make = Effect.gen(function* () {
109 isDevelopment: linux.isDevelopment,
110 appVersion: Electron.app.getVersion(),
111 }).displayName,
112 - execTarget: process.env.APPIMAGE?.trim() || process.execPath,
112 + execTarget:
113 + process.env.T3CODE_DESKTOP_LAUNCHER_PATH?.trim() ||
114 + process.env.APPIMAGE?.trim() ||
115 + process.execPath,
116 scheme: ElectronProtocol.getDesktopScheme(linux.isDevelopment),
117 ...(iconPath === undefined ? {} : { iconPath }),
118 }),