Skip to content

Commit b6a1984

Browse files
committed
fix(desktop): --version segfaults without a display
Headless `t3code --version` walked DesktopApp.startup into ElectronApp.whenReady, so Ozone crashed before any version printed. Match whole-token --version/-V in isVersionRequest and print+exit in main.ts before DesktopApp.program. Implemented with grok-4.5 in T3 Code.
1 parent fee10de commit b6a1984

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎apps/desktop/src/app/DesktopPreReadyPlatform.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@ describe("DesktopPreReadyPlatform", () => {
7878
assert.isNull(value);
7979
});
8080

81+
it("detects --version and -V as whole-token version requests", () => {
82+
assert.isTrue(DesktopPreReadyPlatform.isVersionRequest(["--version"]));
83+
assert.isTrue(DesktopPreReadyPlatform.isVersionRequest(["-V"]));
84+
assert.isFalse(DesktopPreReadyPlatform.isVersionRequest(["--no-sandbox"]));
85+
assert.isFalse(DesktopPreReadyPlatform.isVersionRequest(["--version=1"]));
86+
assert.isFalse(DesktopPreReadyPlatform.isVersionRequest(["--version-foo"]));
87+
assert.isFalse(DesktopPreReadyPlatform.isVersionRequest(["-v"]));
88+
assert.isFalse(DesktopPreReadyPlatform.isVersionRequest([]));
89+
});
90+
8191
it.effect(
8292
"acquires a synchronous pre-ready layer before an asynchronous Clerk-shaped layer",
8393
() =>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ export function readCommandLineSwitchValue(
2929
return value.length > 0 ? value : null;
3030
}
3131

32+
export function isVersionRequest(argv: ReadonlyArray<string>): boolean {
33+
return argv.includes("--version") || argv.includes("-V");
34+
}
35+
3236
export const resolveEarlyLinuxElectronOptionsFromProcess =
3337
(): DesktopEarlyElectronStartup.EarlyLinuxElectronOptions =>
3438
DesktopEarlyElectronStartup.resolveEarlyLinuxElectronOptions({

‎apps/desktop/src/main.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,10 @@ const desktopRuntimeLayer = desktopClerkLayer.pipe(
216216
Layer.provideMerge(DesktopPreReadyPlatform.layer),
217217
);
218218

219+
if (DesktopPreReadyPlatform.isVersionRequest(process.argv)) {
220+
// @effect-diagnostics-next-line globalConsole:off - print and exit before the Effect runtime exists.
221+
console.log(Electron.app.getVersion());
222+
process.exit(0);
223+
}
224+
219225
DesktopApp.program.pipe(Effect.provide(desktopRuntimeLayer), NodeRuntime.runMain);

0 commit comments

Comments
 (0)