Skip to content

Commit 1038f87

Browse files
Merge origin/main into t3code/agent-tools-settings
Main moved per-thread MCP config into the McpProviderSessions service and the ACP adapter into packages/provider-acp. The user's tools now ride on that service's config, and the adapters read them from the session they are handed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
2 parents 54f5ab7 + 33806e7 commit 1038f87

1,003 files changed

Lines changed: 46271 additions & 13306 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.

‎apps/desktop/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"@t3tools/tailscale": "workspace:*",
2525
"dbus-next": "0.10.2",
2626
"effect": "catalog:",
27-
"electron": "44.4.2",
27+
"electron": "44.4.5",
2828
"electron-store": "^8.2.0",
2929
"electron-updater": "^6.8.9",
3030
"ffi-rs": "1.3.2",

‎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,

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

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as NodeServices from "@effect/platform-node/NodeServices";
2-
import { expect, it } from "@effect/vitest";
2+
import { afterEach, beforeEach, expect, it } from "@effect/vitest";
33
import * as Effect from "effect/Effect";
44
import * as FileSystem from "effect/FileSystem";
55
import * as Option from "effect/Option";
@@ -85,6 +85,15 @@ const fakePowerShell = (initial: string) => {
8585
return { registry, spawner };
8686
};
8787

88+
// The machine's own PATH may already hold a t3; each test sets the PATH it means.
89+
const machinePath = process.env.PATH;
90+
beforeEach(() => {
91+
process.env.PATH = "";
92+
});
93+
afterEach(() => {
94+
process.env.PATH = machinePath;
95+
});
96+
8897
it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
8998
it.effect("links the launcher onto PATH and removes only that link", () =>
9099
Effect.gen(function* () {
@@ -165,24 +174,31 @@ it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
165174
}).pipe(Effect.scoped),
166175
);
167176

168-
it.effect("reports when another t3 earlier on PATH would run instead", () =>
177+
it.effect("refuses to install behind another t3 that runs first", () =>
169178
Effect.gen(function* () {
170179
const fs = yield* FileSystem.FileSystem;
171180
const path = yield* Path.Path;
172181
const home = yield* fs.makeTempDirectoryScoped();
173182
const shadow = path.join(home, "shadow");
174183
yield* fs.makeDirectory(shadow);
175184
yield* fs.writeFileString(path.join(shadow, "t3"), "#!/bin/sh\n", { mode: 0o755 });
176-
const previous = process.env.PATH;
177185
process.env.PATH = [shadow, path.join(home, ".local", "bin")].join(":");
178-
yield* Effect.addFinalizer(() => Effect.sync(() => (process.env.PATH = previous)));
179186

180187
const command = yield* commandIn({ home });
188+
const theirs = path.join(shadow, "t3");
189+
expect((yield* command.state).shadowedBy).toBe(theirs);
190+
// A link behind it would never run, so nothing is created.
191+
const error = yield* Effect.flip(command.install);
192+
expect(error.message).toContain(theirs);
193+
expect(yield* fs.exists(path.join(home, ".local", "bin", "t3"))).toBe(false);
194+
195+
yield* fs.remove(theirs);
181196
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);
197+
expect(installed).toMatchObject({
198+
onPath: true,
199+
installedPath: path.join(home, ".local", "bin", "t3"),
200+
});
201+
expect(installed.shadowedBy).toBeUndefined();
186202
}).pipe(Effect.scoped),
187203
);
188204

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,14 @@ export const make = Effect.gen(function* () {
146146
return Option.none<string>();
147147
});
148148

149+
/** The `t3` a new shell runs when it is not this app's, on Unix. */
150+
const foreignFirstOnPath = Effect.gen(function* () {
151+
if (windows) return Option.none<string>();
152+
const first = yield* firstOnPath;
153+
if (Option.isNone(first) || (yield* isOurLink(first.value))) return Option.none<string>();
154+
return first;
155+
});
156+
149157
/** Where this app's command is installed now, if anywhere. */
150158
const installedAt = Effect.gen(function* () {
151159
if (windows) {
@@ -167,12 +175,16 @@ export const make = Effect.gen(function* () {
167175
return { supported: false, installedPath: null, onPath: false } as const;
168176
}
169177
const installed = yield* installedAt;
170-
if (Option.isNone(installed)) return { supported: true, installedPath: null, onPath: false };
178+
const shadowedBy = yield* foreignFirstOnPath;
179+
const shadow = Option.isSome(shadowedBy) ? { shadowedBy: shadowedBy.value } : {};
180+
if (Option.isNone(installed)) {
181+
return { supported: true, installedPath: null, onPath: false, ...shadow };
182+
}
171183
// On Windows only terminals opened after the change see it. On Unix the
172184
// first `t3` on PATH must be ours; a `t3` earlier on PATH would shadow it.
173185
const first = yield* firstOnPath;
174186
const onPath = windows || (Option.isSome(first) && (yield* isOurLink(first.value)));
175-
return { supported: true, installedPath: installed.value, onPath };
187+
return { supported: true, installedPath: installed.value, onPath, ...shadow };
176188
}).pipe(Effect.orElseSucceed(() => ({ supported: false, installedPath: null, onPath: false })));
177189

178190
/** Writes the launcher if the app has not yet, e.g. when no local backend runs. */
@@ -209,6 +221,13 @@ export const make = Effect.gen(function* () {
209221
.remove(existing.value)
210222
.pipe(Effect.mapError(() => fail(`Could not replace ${existing.value}.`)));
211223
}
224+
// A link behind another `t3` never runs, so installing one would only hide the problem.
225+
const shadowedBy = yield* foreignFirstOnPath;
226+
if (Option.isSome(shadowedBy)) {
227+
return yield* fail(
228+
`Another t3 at ${shadowedBy.value} runs first in a new terminal. Remove it, or run the launcher directly at ${launcher}.`,
229+
);
230+
}
212231
const onPath = pathEntries(process.env.PATH, ":");
213232
const candidates = unixCandidates(environment.homeDirectory, environment.platform);
214233
// Prefer a folder already on PATH that the user can write to without admin rights.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ function layerDesktopWindow(
9696
dispatchMenuAction: () => Effect.void,
9797
dispatchSnapShotEvent: () => Effect.void,
9898
zoomMain: () => Effect.void,
99+
runMainContentsCommand: () => Effect.void,
99100
syncAppearance: Effect.void,
100101
});
101102
}

‎apps/desktop/src/backend/DesktopBackendPool.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ function layerPool(labelRef: Ref.Ref<string>): Layer.Layer<DesktopBackendPool.De
100100
dispatchMenuAction: () => Effect.die("unexpected menu action"),
101101
dispatchSnapShotEvent: () => Effect.void,
102102
zoomMain: () => Effect.die("unexpected zoom"),
103+
runMainContentsCommand: () => Effect.die("unexpected main contents command"),
103104
syncAppearance: Effect.void,
104105
} satisfies DesktopWindow.DesktopWindow["Service"]),
105106
),

‎apps/desktop/src/electron/ElectronDialog.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,10 @@ export class ElectronDialog extends Context.Service<
9595
readonly pickFiles: (
9696
input: ElectronDialogPickFilesInput,
9797
) => Effect.Effect<readonly string[], ElectronDialogPickFilesError>;
98+
/** Pass `owner` to attach the box to that window so it cannot fall behind it. */
9899
readonly showMessageBox: (
99100
options: Electron.MessageBoxOptions,
101+
owner?: Electron.BrowserWindow,
100102
) => Effect.Effect<Electron.MessageBoxReturnValue, ElectronDialogShowMessageBoxError>;
101103
readonly showErrorBox: (title: string, content: string) => Effect.Effect<void>;
102104
}
@@ -164,9 +166,12 @@ export const make = ElectronDialog.of({
164166
});
165167
return result.canceled ? [] : result.filePaths;
166168
}),
167-
showMessageBox: (options) =>
169+
showMessageBox: (options, owner) =>
168170
Effect.tryPromise({
169-
try: () => Electron.dialog.showMessageBox(options),
171+
try: () =>
172+
owner === undefined
173+
? Electron.dialog.showMessageBox(options)
174+
: Electron.dialog.showMessageBox(owner, options),
170175
catch: (cause) =>
171176
new ElectronDialogShowMessageBoxError({
172177
type: options.type ?? null,

‎apps/desktop/src/electron/ElectronShell.test.ts‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,20 @@ describe("ElectronShell", () => {
106106
}).pipe(Effect.provide(ElectronShell.layer)),
107107
);
108108

109+
it.effect("opens the JetBrains Toolbox ssh deep link", () =>
110+
Effect.gen(function* () {
111+
openExternalMock.mockResolvedValue(undefined);
112+
113+
const url =
114+
"jetbrains://gateway/ssh/environment?h=example.com&launchIde=true&ideHint=IU&projectHint=%2Fhome%2Fuser%2Fproject";
115+
const electronShell = yield* ElectronShell.ElectronShell;
116+
const result = yield* electronShell.openExternal(url);
117+
118+
assert.equal(result, true);
119+
assert.deepEqual(openExternalMock.mock.calls, [[url]]);
120+
}).pipe(Effect.provide(ElectronShell.layer)),
121+
);
122+
109123
it.effect("does not open editor URLs that mix up link shapes", () =>
110124
Effect.gen(function* () {
111125
openExternalMock.mockResolvedValue(undefined);
@@ -114,9 +128,12 @@ describe("ElectronShell", () => {
114128
const results = yield* Effect.all([
115129
electronShell.openExternal("zed://extension/attacker"),
116130
electronShell.openExternal("vscode://ssh/example.com/home/user/project"),
131+
electronShell.openExternal("jetbrains://idea/navigate/reference?project=x&path=y"),
132+
electronShell.openExternal("jetbrains://gateway/ssh/environment?launchIde=true"),
133+
electronShell.openExternal("jetbrains://gateway/com.example.provider/connect?h=x"),
117134
]);
118135

119-
assert.deepEqual(results, [false, false]);
136+
assert.deepEqual(results, [false, false, false, false, false]);
120137
assert.equal(openExternalMock.mock.calls.length, 0);
121138
}).pipe(Effect.provide(ElectronShell.layer)),
122139
);
@@ -134,9 +151,10 @@ describe("ElectronShell", () => {
134151
"vscode://:secret@vscode-remote/ssh-remote+example.com/home/user/project",
135152
),
136153
electronShell.openExternal("zed://ssh/[email protected]/home/user/project"),
154+
electronShell.openExternal("jetbrains://user@gateway/ssh/environment?h=example.com"),
137155
]);
138156

139-
assert.deepEqual(results, [false, false, false]);
157+
assert.deepEqual(results, [false, false, false, false]);
140158
assert.equal(openExternalMock.mock.calls.length, 0);
141159
}).pipe(Effect.provide(ElectronShell.layer)),
142160
);

‎apps/desktop/src/electron/ElectronShell.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import * as Option from "effect/Option";
1212
import * as Electron from "electron";
1313

1414
// Remote open-in-editor deep links (`vscode://vscode-remote/ssh-remote+…`,
15-
// `zed://ssh/<host>/<path>`) must reach the OS handler; every other non-web
16-
// scheme stays blocked.
15+
// `zed://ssh/<host>/<path>`, `jetbrains://gateway/ssh/environment?h=…`) must
16+
// reach the OS handler; every other non-web scheme stays blocked.
1717
const SAFE_WEB_PROTOCOLS = new Set(["http:", "https:"]);
1818
const REMOTE_EDITOR_PROTOCOLS = new Set(
1919
REMOTE_CAPABLE_EDITOR_IDS.flatMap((id) => {
@@ -31,9 +31,13 @@ const isRemoteEditorUrl = (url: URL) =>
3131
url.password.length === 0 &&
3232
(url.protocol === "zed:"
3333
? url.host === "ssh" && ZED_SSH_PATHNAME.test(url.pathname)
34-
: url.host === "vscode-remote" &&
35-
url.pathname.startsWith("/ssh-remote+") &&
36-
url.pathname.length > "/ssh-remote+".length);
34+
: url.protocol === "jetbrains:"
35+
? url.host === "gateway" &&
36+
url.pathname === "/ssh/environment" &&
37+
(url.searchParams.get("h") ?? "").length > 0
38+
: url.host === "vscode-remote" &&
39+
url.pathname.startsWith("/ssh-remote+") &&
40+
url.pathname.length > "/ssh-remote+".length);
3741

3842
export function parseSafeExternalUrl(rawUrl: unknown): Option.Option<string> {
3943
if (typeof rawUrl !== "string") {

0 commit comments

Comments
 (0)