Skip to content

Commit d4dc6a8

Browse files
committed
chore: merge main into project override fix
2 parents c580fb7 + 1fe8ddd commit d4dc6a8

3 files changed

Lines changed: 62 additions & 6 deletions

File tree

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
136136
yield* command.uninstall;
137137
expect(yield* fs.readFileString(theirs)).toBe("npm's t3\n");
138138
expect(yield* fs.readLink(path.join(home, "bin", "t3"))).toBe(path.join(home, "gone"));
139+
140+
const launcher = path.join(home, ".t3", "bin", "t3");
141+
yield* fs.writeFileString(launcher, "npm's t3\n");
142+
process.env.PATH = path.dirname(launcher);
143+
expect(yield* command.state).toMatchObject({ onPath: false, shadowedBy: launcher });
144+
expect((yield* Effect.flip(command.install)).message).toContain("Could not set up");
145+
yield* command.uninstall;
146+
expect(yield* fs.readFileString(launcher)).toBe("npm's t3\n");
139147
}).pipe(Effect.scoped),
140148
);
141149

@@ -217,6 +225,34 @@ it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
217225
}).pipe(Effect.scoped),
218226
);
219227

228+
it.effect("does not treat its own launcher as another t3 when its folder is first on PATH", () =>
229+
Effect.gen(function* () {
230+
const fs = yield* FileSystem.FileSystem;
231+
const path = yield* Path.Path;
232+
const home = yield* fs.makeTempDirectoryScoped();
233+
const launcher = path.join(home, ".t3", "bin", "t3");
234+
process.env.PATH = [path.dirname(launcher), path.join(home, ".local", "bin")].join(":");
235+
236+
const command = yield* commandIn({ home });
237+
const installed = yield* command.install;
238+
239+
expect(yield* fs.exists(launcher)).toBe(true);
240+
expect(installed).toMatchObject({
241+
onPath: true,
242+
installedPath: path.join(home, ".local", "bin", "t3"),
243+
});
244+
expect(installed.shadowedBy).toBeUndefined();
245+
expect(yield* command.state).toEqual(installed);
246+
247+
const removed = yield* command.uninstall;
248+
expect(removed.installedPath).toBeNull();
249+
expect(removed.onPath).toBe(true);
250+
expect(yield* command.state).toEqual(removed);
251+
expect(yield* fs.exists(installed.installedPath!)).toBe(false);
252+
expect(yield* fs.exists(launcher)).toBe(true);
253+
}).pipe(Effect.scoped),
254+
);
255+
220256
it.effect("leaves the Windows PATH alone when it cannot be read", () =>
221257
Effect.gen(function* () {
222258
const fs = yield* FileSystem.FileSystem;

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

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,19 @@ export const make = Effect.gen(function* () {
9292
Effect.orElseSucceed(() => false),
9393
);
9494

95+
// PATH can reach the regular launcher directly; removal still requires isOurLink.
96+
const runsOurLauncher = Effect.fn("DesktopCliCommand.runsOurLauncher")(
97+
function* (candidate: string) {
98+
if (yield* isOurLink(candidate)) return true;
99+
const [resolved, ours] = yield* Effect.all([fs.realPath(candidate), fs.realPath(launcher)]);
100+
if (resolved !== ours) return false;
101+
const info = yield* fs.stat(candidate);
102+
if (info.type !== "File" || Number(info.size) > 16_384) return false;
103+
return (yield* fs.readFileString(candidate)).includes(DesktopCliShim.MARKER);
104+
},
105+
Effect.orElseSucceed(() => false),
106+
);
107+
95108
const powershell = (env: Record<string, string>) =>
96109
Effect.scoped(
97110
Effect.gen(function* () {
@@ -141,7 +154,7 @@ export const make = Effect.gen(function* () {
141154
const foreignFirstOnPath = Effect.gen(function* () {
142155
if (windows) return Option.none<string>();
143156
const first = yield* firstOnPath;
144-
if (Option.isNone(first) || (yield* isOurLink(first.value))) return Option.none<string>();
157+
if (Option.isNone(first) || (yield* runsOurLauncher(first.value))) return Option.none<string>();
145158
return first;
146159
});
147160

@@ -168,12 +181,17 @@ export const make = Effect.gen(function* () {
168181
const installed = yield* installedAt;
169182
const shadowedBy = yield* foreignFirstOnPath;
170183
const shadow = Option.isSome(shadowedBy) ? { shadowedBy: shadowedBy.value } : {};
171-
if (Option.isNone(installed)) {
172-
return { supported: true, installedPath: null, onPath: false, launcherPath, ...shadow };
173-
}
174184
const first = yield* firstOnPath;
175-
const onPath = windows || (Option.isSome(first) && (yield* isOurLink(first.value)));
176-
return { supported: true, installedPath: installed.value, onPath, launcherPath, ...shadow };
185+
const onPath = windows
186+
? Option.isSome(installed)
187+
: Option.isSome(first) && (yield* runsOurLauncher(first.value));
188+
return {
189+
supported: true,
190+
installedPath: Option.getOrNull(installed),
191+
onPath,
192+
launcherPath,
193+
...shadow,
194+
};
177195
}).pipe(
178196
Effect.orElseSucceed(() => ({
179197
supported: false,

‎apps/mobile/src/features/threads/git/GitBranchesSheet.occupancy.test.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ vi.mock("../../../components/ui/AppText", () => ({
3030
AppTextInput: () => null,
3131
}));
3232
vi.mock("./gitSheetComponents", () => ({ SheetActionButton: () => null }));
33+
vi.mock("../../../state/entities", () => ({}));
34+
vi.mock("../../../state/threads", () => ({}));
3335
vi.mock("../../../state/use-thread-selection", () => ({
3436
useThreadSelection: () => ({
3537
selectedThread: { environmentId: "environment-1", worktreePath: checkout.worktreePath },

0 commit comments

Comments
 (0)