Skip to content

Commit ad3a5d3

Browse files
t3dotggclaude
andcommitted
fix(desktop): Settings offers Install for our t3 link into another T3 home, and Remove sticks
- A t3 link into another T3 home showed as installed, so Settings offered only Remove, and Install could not update it in place. The state now reports it as not installed and not "another t3", so Settings offers Install, which updates it where it is. - Remove marks the first launch as done, so a first launch put off for the shell PATH cannot bring back a command the user removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 3481d84 commit ad3a5d3

2 files changed

Lines changed: 23 additions & 6 deletions

File tree

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,14 @@ it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
142142
// Removed stays removed: first launch never installs again.
143143
yield* command.installOnFirstLaunch;
144144
expect(yield* fs.exists(link)).toBe(false);
145+
146+
// Also when first launch was put off (no shell PATH yet) and the user removed it meanwhile.
147+
const laterHome = yield* fs.makeTempDirectoryScoped();
148+
const later = yield* commandIn({ home: laterHome });
149+
yield* later.install;
150+
yield* later.uninstall;
151+
yield* later.installOnFirstLaunch;
152+
expect(yield* fs.exists(path.join(laterHome, ".local", "bin", "t3"))).toBe(false);
145153
}).pipe(Effect.scoped),
146154
);
147155

@@ -185,15 +193,16 @@ it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
185193
// A first launch leaves another home's command alone; only Install takes it over.
186194
yield* after.installOnFirstLaunch;
187195
expect(yield* fs.readLink(link!)).toBe(path.join(home, "old-t3", "bin", "t3"));
188-
// On PATH, but it runs the other home's launcher, not this one.
196+
// On PATH, it runs the other home's launcher. Settings offers Install (not Remove, and not
197+
// "another t3 runs first"), which updates that link in place.
189198
process.env.PATH = path.dirname(link!);
190-
expect((yield* after.state).onPath).toBe(false);
199+
expect(yield* after.state).toMatchObject({ installedPath: null, onPath: false });
200+
expect((yield* after.state).shadowedBy).toBeUndefined();
191201
process.env.PATH = "";
192202
// Off PATH, Add to PATH would expose the other home's command, not this one.
193203
expect((yield* after.state).pathSetup).toBeUndefined();
194204
yield* Effect.flip(after.addToPath);
195205
expect(yield* fs.exists(path.join(home, ".zshrc"))).toBe(false);
196-
expect((yield* after.state).installedPath).toBe(link);
197206
// Behind another t3 the install fails, and the old link still works.
198207
const shadow = path.join(home, "shadow");
199208
yield* fs.makeDirectory(shadow);

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,15 @@ export const make = Effect.gen(function* () {
231231
return { supported: false, installedPath: null, onPath: false, launcherPath: null } as const;
232232
}
233233
const launcherPath = (yield* exists(launcher)) ? launcher : null;
234-
const installed = yield* installedAt;
235-
const shadowedBy = yield* foreignFirstOnPath;
234+
const found = yield* installedAt;
235+
// Our link into another T3 home is not this app's command; Install updates it in place.
236+
const installed =
237+
windows || (Option.isSome(found) && (yield* leadsHere(found.value)))
238+
? found
239+
: Option.none<string>();
240+
const shadowedBy = (yield* foreignFirstOnPath).pipe(
241+
Option.filter((first) => first !== Option.getOrUndefined(found)),
242+
);
236243
const shadow = Option.isSome(shadowedBy) ? { shadowedBy: shadowedBy.value } : {};
237244
const first = yield* firstOnPath;
238245
const onPath = windows
@@ -244,7 +251,6 @@ export const make = Effect.gen(function* () {
244251
onPath ||
245252
Option.isSome(shadowedBy) ||
246253
Option.isNone(installed) ||
247-
!(yield* leadsHere(installed.value)) ||
248254
(yield* folderOnPath(installed.value))
249255
? undefined
250256
: startupLine(installed.value);
@@ -356,6 +362,8 @@ export const make = Effect.gen(function* () {
356362
}).pipe(Effect.withSpan("desktop.cliCommand.install"));
357363

358364
const uninstall: DesktopCliCommand["Service"]["uninstall"] = Effect.gen(function* () {
365+
// A first launch put off for the shell PATH must not bring back what the user removed.
366+
yield* fs.writeFileString(firstLaunchMarker, "").pipe(Effect.ignore);
359367
if (windows) {
360368
if (yield* exists(ownedPathMarker)) {
361369
const entries = pathEntries(yield* readUserPath, ";");

0 commit comments

Comments
 (0)