Skip to content

Commit 1d4066b

Browse files
shivamhwpclaude
andcommitted
fix(desktop): SSH environments download the runtime from T3CODE_RELEASE_BASE_URL
The desktop SSH runner only passed the archive version, so the remote runtime always came from GitHub releases. Read T3CODE_RELEASE_BASE_URL into DesktopConfig and pass it to the archive runner; blank or unset still falls back to GitHub, and SHA256SUMS verification is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 337c585 commit 1d4066b

5 files changed

Lines changed: 78 additions & 17 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { CLI_RELEASE_BASE_URL_ENV } from "@t3tools/shared/cliRelease";
12
import { OtlpHeadersFromString, OtlpProtocol } from "@t3tools/shared/observability";
23
import * as Config from "effect/Config";
34
import * as ConfigProvider from "effect/ConfigProvider";
@@ -41,6 +42,7 @@ export const DesktopConfig = Config.all({
4142
devServerUrl: Config.URL("VITE_DEV_SERVER_URL").pipe(Config.option),
4243
appUserModelIdOverride: trimmedString("T3CODE_DESKTOP_APP_USER_MODEL_ID"),
4344
devRemoteT3ServerEntryPath: trimmedString("T3CODE_DEV_REMOTE_T3_SERVER_ENTRY_PATH"),
45+
releaseBaseUrl: trimmedString(CLI_RELEASE_BASE_URL_ENV),
4446
configuredBackendPort: Config.Port("T3CODE_PORT").pipe(Config.option),
4547
commitHashOverride: trimmedString("T3CODE_COMMIT_HASH"),
4648
desktopLanHostOverride: trimmedString("T3CODE_DESKTOP_LAN_HOST"),

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export class DesktopEnvironment extends Context.Service<
6363
readonly appUpdateYmlPath: string;
6464
readonly devServerUrl: Option.Option<URL>;
6565
readonly devRemoteT3ServerEntryPath: Option.Option<string>;
66+
readonly releaseBaseUrl: Option.Option<string>;
6667
readonly configuredBackendPort: Option.Option<number>;
6768
readonly commitHashOverride: Option.Option<string>;
6869
readonly otlpTracesUrl: Option.Option<string>;
@@ -217,6 +218,7 @@ const make = Effect.fn("desktop.environment.make")(function* (
217218
: path.join(input.appPath, "dev-app-update.yml"),
218219
devServerUrl,
219220
devRemoteT3ServerEntryPath: config.devRemoteT3ServerEntryPath,
221+
releaseBaseUrl: config.releaseBaseUrl,
220222
configuredBackendPort: config.configuredBackendPort,
221223
commitHashOverride: config.commitHashOverride,
222224
otlpTracesUrl: config.otlpTracesUrl,

‎apps/desktop/src/main.ts‎

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,11 @@ import * as NodeFS from "node:fs";
1414
import * as NodeOS from "node:os";
1515
import * as Effect from "effect/Effect";
1616
import * as Layer from "effect/Layer";
17-
import * as Option from "effect/Option";
1817

1918
import * as Electron from "electron";
2019

2120
import * as NetService from "@t3tools/shared/Net";
2221
import * as HostProcess from "@t3tools/shared/HostProcess";
23-
import type { RemoteT3RunnerOptions } from "@t3tools/ssh/tunnel";
24-
import serverPackageJson from "../../server/package.json" with { type: "json" };
2522

2623
import * as DesktopIpc from "./ipc/DesktopIpc.ts";
2724
import * as ElectronApp from "./electron/ElectronApp.ts";
@@ -106,24 +103,11 @@ const layerDesktopEnvironment = Layer.unwrap(
106103
}),
107104
);
108105

109-
const resolveDesktopSshCliRunner = (
110-
environment: DesktopEnvironment.DesktopEnvironment["Service"],
111-
): RemoteT3RunnerOptions => {
112-
const devRemoteEntryPath = Option.getOrUndefined(environment.devRemoteT3ServerEntryPath);
113-
if (environment.isDevelopment && devRemoteEntryPath !== undefined) {
114-
return {
115-
nodeScriptPath: devRemoteEntryPath,
116-
nodeEngineRange: serverPackageJson.engines.node,
117-
};
118-
}
119-
return { archiveVersion: environment.appVersion };
120-
};
121-
122106
const layerDesktopSshEnvironment = Layer.unwrap(
123107
Effect.gen(function* () {
124108
const environment = yield* DesktopEnvironment.DesktopEnvironment;
125109
return DesktopSshEnvironment.layer({
126-
resolveCliRunner: Effect.succeed(resolveDesktopSshCliRunner(environment)),
110+
resolveCliRunner: Effect.succeed(DesktopSshEnvironment.resolveCliRunner(environment)),
127111
});
128112
}),
129113
);
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import * as NodePath from "@effect/platform-node/NodePath";
2+
import * as NodeServices from "@effect/platform-node/NodeServices";
3+
import { assert, describe, it } from "@effect/vitest";
4+
import { buildRemoteT3RunnerScript } from "@t3tools/ssh/tunnel";
5+
import * as Effect from "effect/Effect";
6+
import * as Layer from "effect/Layer";
7+
8+
import * as DesktopConfig from "../app/DesktopConfig.ts";
9+
import * as DesktopEnvironment from "../app/DesktopEnvironment.ts";
10+
import * as DesktopSshEnvironment from "./DesktopSshEnvironment.ts";
11+
12+
const runnerScript = (env: Record<string, string | undefined>) =>
13+
DesktopEnvironment.DesktopEnvironment.pipe(
14+
Effect.map((environment) =>
15+
buildRemoteT3RunnerScript(DesktopSshEnvironment.resolveCliRunner(environment)),
16+
),
17+
Effect.provide(
18+
DesktopEnvironment.layer({
19+
dirname: "/repo/apps/desktop/dist-electron",
20+
homeDirectory: "/home/alice",
21+
platform: "linux",
22+
processArch: "x64",
23+
appVersion: "0.1.6",
24+
appPath: "/opt/t3code/resources/app.asar",
25+
isPackaged: true,
26+
resourcesPath: "/opt/t3code/resources",
27+
runningUnderArm64Translation: false,
28+
}).pipe(
29+
Layer.provide(
30+
Layer.mergeAll(NodeServices.layer, NodePath.layerPosix, DesktopConfig.layerTest(env)),
31+
),
32+
),
33+
),
34+
);
35+
36+
describe("resolveCliRunner", () => {
37+
it.effect("downloads the remote runtime from T3CODE_RELEASE_BASE_URL", () =>
38+
Effect.gen(function* () {
39+
const cases = [
40+
[{ T3CODE_RELEASE_BASE_URL: "https://mirror.example/t3/" }, "https://mirror.example/t3"],
41+
[
42+
{ T3CODE_RELEASE_BASE_URL: " " },
43+
"https://github.com/pingdotgg/t3code/releases/download",
44+
],
45+
[{}, "https://github.com/pingdotgg/t3code/releases/download"],
46+
] as const;
47+
for (const [env, expected] of cases) {
48+
const script = yield* runnerScript(env);
49+
assert.include(script, `T3_RELEASE_BASE_URL='${expected}'`);
50+
assert.include(script, `T3_ARCHIVE_VERSION='0.1.6'`);
51+
}
52+
}),
53+
);
54+
});

‎apps/desktop/src/ssh/DesktopSshEnvironment.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@ import type * as Digest from "effect/crypto/Digest";
2222
import * as Effect from "effect/Effect";
2323
import * as FileSystem from "effect/FileSystem";
2424
import * as Layer from "effect/Layer";
25+
import * as Option from "effect/Option";
2526
import * as Path from "effect/Path";
2627
import * as Schema from "effect/Schema";
2728
import * as HttpClient from "effect/http/HttpClient";
2829
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
2930

31+
import serverPackageJson from "../../../server/package.json" with { type: "json" };
32+
import type * as DesktopEnvironment from "../app/DesktopEnvironment.ts";
3033
import * as DesktopSshPasswordPrompts from "./DesktopSshPasswordPrompts.ts";
3134

3235
export type DesktopSshEnvironmentRuntimeServices =
@@ -71,6 +74,22 @@ export interface DesktopSshEnvironmentLayerOptions {
7174
readonly resolveCliRunner?: Effect.Effect<SshTunnel.RemoteT3RunnerOptions>;
7275
}
7376

77+
export const resolveCliRunner = (
78+
environment: DesktopEnvironment.DesktopEnvironment["Service"],
79+
): SshTunnel.RemoteT3RunnerOptions => {
80+
const devRemoteEntryPath = Option.getOrUndefined(environment.devRemoteT3ServerEntryPath);
81+
if (environment.isDevelopment && devRemoteEntryPath !== undefined) {
82+
return {
83+
nodeScriptPath: devRemoteEntryPath,
84+
nodeEngineRange: serverPackageJson.engines.node,
85+
};
86+
}
87+
return {
88+
archiveVersion: environment.appVersion,
89+
releaseBaseUrl: Option.getOrNull(environment.releaseBaseUrl),
90+
};
91+
};
92+
7493
function discoverDesktopSshHostsEffect(input?: { readonly homeDir?: string }) {
7594
return discoverSshHosts(input ?? {});
7695
}

0 commit comments

Comments
 (0)