Skip to content

Commit a0e47b0

Browse files
committed
Merge remote-tracking branch 'upstream/main' into yordis/fix-disabled-claude-update-checks
Signed-off-by: Yordis Prieto <[email protected]>
2 parents 020be9a + d81afa0 commit a0e47b0

945 files changed

Lines changed: 56440 additions & 13697 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.coderabbit.config.ts‎

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
11
import { defineConfig, type CodeRabbitContext } from "@coderabbitai/config";
22

3-
const approvability = `Fail when a maintainer should read this pull request before CodeRabbit approves it, and name the rule and file. Fail if it:
4-
5-
- Changes a product default: a setting's default value, or what users get without opting in. Making a feature do what it already promises is a bug fix, not a default change.
6-
- Adds or broadens a directive that disables or suppresses a lint, type-checker, LSP, or other static-analysis diagnostic, including file-level, line-level, and configuration-level overrides.
7-
- Adds a subsystem or user workflow, or is a large refactor across apps or packages.
8-
- Changes packages/contracts or persisted data in a way that existing clients or stored data might not accept.
9-
- Changes authentication, pairing, credentials, secrets, or remote connection trust.
10-
- Adds or changes an external side effect, such as acting on GitHub, publishing a release, or calling a webhook.
11-
- Adds, upgrades, or patches a dependency.
12-
- Changes CI or release configuration, agent or contributor instructions, or any review tool's configuration, including .github/, AGENTS.md, CONTRIBUTING.md, .agents/, and .coderabbit.config.ts.
13-
14-
Otherwise pass. A focused bug fix, copy or layout fix, revert, or docs-only or test-only change passes unless a rule above applies. If you cannot decide, fail rather than report inconclusive. When failing, say that the pull request needs a maintainer's review.
15-
`;
16-
173
// Org members and collaborators merge their own pull requests. On anyone else's, CodeRabbit
18-
// requests changes until its comments are resolved and its checks pass, then approves.
4+
// requests changes until its comments are resolved, then approves.
195
const UNGATED_AUTHORS = new Set(["OWNER", "MEMBER", "COLLABORATOR"]);
206
const isGated = ({ pr }: CodeRabbitContext) => !UNGATED_AUTHORS.has(pr?.authorAssociation ?? "");
217

@@ -31,13 +17,6 @@ export default defineConfig((ctx) => ({
3117
pre_merge_checks: {
3218
docstrings: { mode: "off" },
3319
override_requested_reviewers_only: isGated(ctx),
34-
custom_checks: [
35-
{
36-
name: "Approvability",
37-
mode: isGated(ctx) ? "error" : "off",
38-
instructions: approvability,
39-
},
40-
],
4120
},
4221
path_filters: [
4322
// Vendored read-only reference checkouts of upstream Effect and Alchemy

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

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ describe("DesktopAppIdentity", () => {
217217
const identity = yield* DesktopAppIdentity.DesktopAppIdentity;
218218
yield* identity.configure;
219219

220-
assert.deepEqual(calls.setName, ["T3 Code (Alpha)"]);
220+
assert.deepEqual(calls.setName, ["T3 Code Alpha"]);
221221
assert.equal(calls.setAboutPanelOptions[0]?.applicationName, "T3 Code (Alpha)");
222222
assert.equal(calls.setAboutPanelOptions[0]?.applicationVersion, "1.2.3");
223223
assert.equal(calls.setAboutPanelOptions[0]?.version, "0123456789ab");
@@ -237,6 +237,39 @@ describe("DesktopAppIdentity", () => {
237237
);
238238
});
239239

240+
it.effect.each([
241+
{ stage: "Alpha", environment: {} },
242+
{
243+
stage: "Nightly",
244+
environment: { appVersion: "0.0.43-nightly.20260929.2428" },
245+
},
246+
{
247+
stage: "Dev",
248+
environment: { env: { VITE_DEV_SERVER_URL: "http://localhost:5173" } },
249+
},
250+
])("uses a valid native User-Agent product name for $stage", ({ stage, environment }) => {
251+
const calls: ElectronAppCalls = {
252+
setAboutPanelOptions: [],
253+
setDockIcon: [],
254+
setName: [],
255+
};
256+
257+
return withIdentity(
258+
Effect.gen(function* () {
259+
const identity = yield* DesktopAppIdentity.DesktopAppIdentity;
260+
yield* identity.configure;
261+
262+
const runtimeName = calls.setName[0];
263+
assert.isDefined(runtimeName);
264+
assert.equal(runtimeName, `T3 Code ${stage}`);
265+
// RFC 9110's token grammar, after Electron removes ASCII spaces.
266+
assert.match(runtimeName.replaceAll(" ", ""), /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/);
267+
assert.equal(calls.setAboutPanelOptions[0]?.applicationName, `T3 Code (${stage})`);
268+
}),
269+
{ calls, environment },
270+
);
271+
});
272+
240273
it.effect("sets the dock icon only when running unpackaged", () => {
241274
const calls: ElectronAppCalls = {
242275
setAboutPanelOptions: [],

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,12 @@ export const make = Effect.gen(function* () {
9191

9292
const configure = Effect.gen(function* () {
9393
const commitHash = yield* resolveAboutCommitHash;
94-
yield* electronApp.setName(environment.displayName);
94+
// Electron removes spaces from this name to build the native User-Agent
95+
// product token, but leaves parentheses intact. Keep the runtime name valid
96+
// without rewriting preview sessions (which breaks Turnstile, #7110).
97+
yield* electronApp.setName(
98+
`${environment.branding.baseName} ${environment.branding.stageLabel}`,
99+
);
95100
yield* electronApp.setAboutPanelOptions({
96101
applicationName: environment.displayName,
97102
applicationVersion: environment.appVersion,
Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
import * as NodeServices from "@effect/platform-node/NodeServices";
2+
import { expect, it } from "@effect/vitest";
3+
import * as Effect from "effect/Effect";
4+
import * as FileSystem from "effect/FileSystem";
5+
import * as Option from "effect/Option";
6+
import * as Path from "effect/Path";
7+
import * as Sink from "effect/Sink";
8+
import * as Stream from "effect/Stream";
9+
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
10+
11+
import * as DesktopCliCommand from "./DesktopCliCommand.ts";
12+
import * as DesktopCliShim from "./DesktopCliShim.ts";
13+
import * as DesktopEnvironment from "./DesktopEnvironment.ts";
14+
15+
const environmentFor = (
16+
path: Path.Path,
17+
input: { home: string; baseDir: string; platform?: NodeJS.Platform; isPackaged?: boolean },
18+
) =>
19+
DesktopEnvironment.DesktopEnvironment.of({
20+
path,
21+
platform: input.platform ?? "linux",
22+
isPackaged: input.isPackaged ?? true,
23+
homeDirectory: input.home,
24+
baseDir: input.baseDir,
25+
stateDir: path.join(input.baseDir, "userdata"),
26+
serverRoot: "/opt/T3 Code/resources/app.asar",
27+
appImagePath: Option.none(),
28+
} as unknown as DesktopEnvironment.DesktopEnvironment["Service"]);
29+
30+
/** The service for a packaged app; the launcher is written on Install. */
31+
const commandIn = (
32+
input: { home: string; baseDir?: string; platform?: NodeJS.Platform; isPackaged?: boolean },
33+
spawner?: ChildProcessSpawner.ChildProcessSpawner["Service"],
34+
) =>
35+
Effect.gen(function* () {
36+
const path = yield* Path.Path;
37+
const fs = yield* FileSystem.FileSystem;
38+
const baseDir = input.baseDir ?? path.join(input.home, ".t3");
39+
yield* fs.makeDirectory(path.join(baseDir, "userdata"), { recursive: true });
40+
const make = DesktopCliCommand.make.pipe(
41+
Effect.provideService(
42+
DesktopEnvironment.DesktopEnvironment,
43+
environmentFor(path, { ...input, baseDir }),
44+
),
45+
);
46+
return yield* spawner
47+
? make.pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner))
48+
: make;
49+
});
50+
51+
/** A PowerShell that keeps the user's PATH in memory and can be told to fail reads. */
52+
const fakePowerShell = (initial: string) => {
53+
const registry = { path: initial, failReads: false, writes: 0 };
54+
const spawner = ChildProcessSpawner.make((command) =>
55+
Effect.sync(() => {
56+
const { options } = command as unknown as {
57+
readonly options: { readonly env?: Record<string, string> };
58+
};
59+
const env = options.env ?? {};
60+
let exitCode = 0;
61+
let stdout = "";
62+
if (env.T3_SET === "1") {
63+
registry.path = env.T3_PATH ?? "";
64+
registry.writes += 1;
65+
} else if (registry.failReads) {
66+
exitCode = 1;
67+
} else {
68+
stdout = Buffer.from(registry.path, "utf8").toString("base64");
69+
}
70+
return ChildProcessSpawner.makeHandle({
71+
pid: ChildProcessSpawner.ProcessId(1),
72+
exitCode: Effect.succeed(ChildProcessSpawner.ExitCode(exitCode)),
73+
isRunning: Effect.succeed(false),
74+
kill: () => Effect.void,
75+
unref: Effect.succeed(Effect.void),
76+
stdin: Sink.drain,
77+
stdout: Stream.make(new TextEncoder().encode(stdout)),
78+
stderr: Stream.empty,
79+
all: Stream.empty,
80+
getInputFd: () => Sink.drain,
81+
getOutputFd: () => Stream.empty,
82+
});
83+
}),
84+
);
85+
return { registry, spawner };
86+
};
87+
88+
it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
89+
it.effect("links the launcher onto PATH and removes only that link", () =>
90+
Effect.gen(function* () {
91+
const fs = yield* FileSystem.FileSystem;
92+
const path = yield* Path.Path;
93+
const home = yield* fs.makeTempDirectoryScoped();
94+
const command = yield* commandIn({ home });
95+
const link = path.join(home, ".local", "bin", "t3");
96+
97+
expect(yield* command.state).toEqual({ supported: true, installedPath: null, onPath: false });
98+
// Install writes the launcher itself, even when no local backend ever did.
99+
const installed = yield* command.install;
100+
expect(installed.installedPath).toBe(link);
101+
expect(yield* fs.readLink(link)).toBe(path.join(home, ".t3", "bin", "t3"));
102+
expect((yield* command.install).installedPath).toBe(link);
103+
104+
expect((yield* command.uninstall).installedPath).toBeNull();
105+
expect(yield* fs.exists(link)).toBe(false);
106+
// The launcher itself stays for setup commands.
107+
expect(yield* fs.exists(path.join(home, ".t3", "bin", "t3"))).toBe(true);
108+
}).pipe(Effect.scoped),
109+
);
110+
111+
it.effect("never replaces or removes a t3 it did not create", () =>
112+
Effect.gen(function* () {
113+
const fs = yield* FileSystem.FileSystem;
114+
const path = yield* Path.Path;
115+
const home = yield* fs.makeTempDirectoryScoped();
116+
const command = yield* commandIn({ home });
117+
const theirs = path.join(home, ".local", "bin", "t3");
118+
yield* fs.makeDirectory(path.dirname(theirs), { recursive: true });
119+
yield* fs.writeFileString(theirs, "npm's t3\n");
120+
// Even a broken link in the next folder is someone else's.
121+
yield* fs.makeDirectory(path.join(home, "bin"), { recursive: true });
122+
yield* fs.symlink(path.join(home, "gone"), path.join(home, "bin", "t3"));
123+
124+
const error = yield* Effect.flip(command.install);
125+
expect(error.message).toContain("Another t3 command is already installed");
126+
yield* command.uninstall;
127+
expect(yield* fs.readFileString(theirs)).toBe("npm's t3\n");
128+
expect(yield* fs.readLink(path.join(home, "bin", "t3"))).toBe(path.join(home, "gone"));
129+
}).pipe(Effect.scoped),
130+
);
131+
132+
it.effect("finds and removes a link left by a previous T3 home", () =>
133+
Effect.gen(function* () {
134+
const fs = yield* FileSystem.FileSystem;
135+
const path = yield* Path.Path;
136+
const home = yield* fs.makeTempDirectoryScoped();
137+
const before = yield* commandIn({ home, baseDir: path.join(home, "old-t3") });
138+
const link = (yield* before.install).installedPath;
139+
140+
const after = yield* commandIn({ home, baseDir: path.join(home, "new-t3") });
141+
expect((yield* after.state).installedPath).toBe(link);
142+
// Installing again points the link at this home's launcher.
143+
expect((yield* after.install).installedPath).toBe(link);
144+
expect(yield* fs.readLink(link!)).toBe(path.join(home, "new-t3", "bin", "t3"));
145+
yield* after.uninstall;
146+
expect(yield* fs.exists(path.join(home, ".local", "bin", "t3"))).toBe(false);
147+
expect(yield* fs.exists(path.join(home, "bin", "t3"))).toBe(false);
148+
}).pipe(Effect.scoped),
149+
);
150+
151+
it.effect("does not read a large binary another t3 links to", () =>
152+
Effect.gen(function* () {
153+
const fs = yield* FileSystem.FileSystem;
154+
const path = yield* Path.Path;
155+
const home = yield* fs.makeTempDirectoryScoped();
156+
// A big executable that happens to contain the marker text is still not ours.
157+
const binary = path.join(home, "native-t3");
158+
yield* fs.writeFileString(binary, `${"\0".repeat(64 * 1024)}${DesktopCliShim.MARKER}`);
159+
yield* fs.makeDirectory(path.join(home, ".local", "bin"), { recursive: true });
160+
yield* fs.symlink(binary, path.join(home, ".local", "bin", "t3"));
161+
const command = yield* commandIn({ home });
162+
expect((yield* command.state).installedPath).toBeNull();
163+
yield* command.uninstall;
164+
expect(yield* fs.readLink(path.join(home, ".local", "bin", "t3"))).toBe(binary);
165+
}).pipe(Effect.scoped),
166+
);
167+
168+
it.effect("reports when another t3 earlier on PATH would run instead", () =>
169+
Effect.gen(function* () {
170+
const fs = yield* FileSystem.FileSystem;
171+
const path = yield* Path.Path;
172+
const home = yield* fs.makeTempDirectoryScoped();
173+
const shadow = path.join(home, "shadow");
174+
yield* fs.makeDirectory(shadow);
175+
yield* fs.writeFileString(path.join(shadow, "t3"), "#!/bin/sh\n", { mode: 0o755 });
176+
const previous = process.env.PATH;
177+
process.env.PATH = [shadow, path.join(home, ".local", "bin")].join(":");
178+
yield* Effect.addFinalizer(() => Effect.sync(() => (process.env.PATH = previous)));
179+
180+
const command = yield* commandIn({ home });
181+
const installed = yield* command.install;
182+
expect(installed.installedPath).toBe(path.join(home, ".local", "bin", "t3"));
183+
expect(installed.onPath).toBe(false);
184+
yield* fs.remove(path.join(shadow, "t3"));
185+
expect((yield* command.state).onPath).toBe(true);
186+
}).pipe(Effect.scoped),
187+
);
188+
189+
it.effect("leaves the Windows PATH alone when it cannot be read", () =>
190+
Effect.gen(function* () {
191+
const fs = yield* FileSystem.FileSystem;
192+
const home = yield* fs.makeTempDirectoryScoped();
193+
const userPath = "C:\\Users\\Me\\npm;%USERPROFILE%\\tools";
194+
const { registry, spawner } = fakePowerShell(userPath);
195+
const command = yield* commandIn({ home, platform: "win32" }, spawner);
196+
197+
registry.failReads = true;
198+
const error = yield* Effect.flip(command.install);
199+
expect(error.message).toContain("left unchanged");
200+
expect(registry).toMatchObject({ path: userPath, writes: 0 });
201+
202+
registry.failReads = false;
203+
const launcherDir = DesktopCliShim.launcherPath(
204+
environmentFor(yield* Path.Path, { home, baseDir: `${home}/.t3`, platform: "win32" }),
205+
).replace(/[\\/]t3\.cmd$/, "");
206+
yield* command.install;
207+
expect(registry.path).toBe(`${userPath};${launcherDir}`);
208+
yield* command.uninstall;
209+
expect(registry.path).toBe(userPath);
210+
}).pipe(Effect.scoped),
211+
);
212+
213+
it.effect("does not claim or remove a Windows PATH entry the user added", () =>
214+
Effect.gen(function* () {
215+
const fs = yield* FileSystem.FileSystem;
216+
const path = yield* Path.Path;
217+
const home = yield* fs.makeTempDirectoryScoped();
218+
const launcherDir = path.dirname(
219+
DesktopCliShim.launcherPath(
220+
environmentFor(path, { home, baseDir: path.join(home, ".t3"), platform: "win32" }),
221+
),
222+
);
223+
const userPath = `C:\\Tools;${launcherDir}`;
224+
const { registry, spawner } = fakePowerShell(userPath);
225+
const command = yield* commandIn({ home, platform: "win32" }, spawner);
226+
227+
expect((yield* command.state).installedPath).toBeNull();
228+
yield* command.uninstall;
229+
expect(registry.path).toBe(userPath);
230+
}).pipe(Effect.scoped),
231+
);
232+
233+
it.effect("offers nothing for a development build", () =>
234+
Effect.gen(function* () {
235+
const fs = yield* FileSystem.FileSystem;
236+
const command = yield* commandIn({
237+
home: yield* fs.makeTempDirectoryScoped(),
238+
isPackaged: false,
239+
});
240+
expect((yield* command.state).supported).toBe(false);
241+
}).pipe(Effect.scoped),
242+
);
243+
});

0 commit comments

Comments
 (0)