Skip to content

Commit 674c5f4

Browse files
authored
Merge pull request #111 from BreakTheBeta/sync/upstream-20261103
chore(sync): merge upstream main through 5b9731c
2 parents 3d1ee48 + b8e87b1 commit 674c5f4

402 files changed

Lines changed: 19410 additions & 2012 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.

‎.github/workflows/release-desktop.yml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,14 @@ jobs:
203203
native/hyprland-snap-shot/target/${{ inputs.rust_target }}/release/t3-hyprland-snap-shot
204204
key: linux-capture-helpers-${{ inputs.rust_target }}-${{ hashFiles('native/kde-snap-shot/Cargo.lock', 'native/kde-snap-shot/Cargo.toml', 'native/kde-snap-shot/src/**', 'native/hyprland-snap-shot/Cargo.lock', 'native/hyprland-snap-shot/Cargo.toml', 'native/hyprland-snap-shot/src/**', 'native/hyprland-snap-shot/protocols/**') }}
205205

206+
- name: Ensure Rosetta for macOS x64 bytecode generation
207+
if: inputs.platform == 'mac' && inputs.arch == 'x64'
208+
shell: bash
209+
run: |
210+
if [[ "$(uname -m)" == "arm64" ]] && ! /usr/bin/arch -x86_64 /usr/bin/true; then
211+
sudo /usr/sbin/softwareupdate --install-rosetta --agree-to-license
212+
fi
213+
206214
- name: Setup Rust
207215
if: steps.resource_monitor_cache.outputs.cache-hit != 'true' || (inputs.platform == 'linux' && steps.capture_helper_cache.outputs.cache-hit != 'true')
208216
uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87 # stable

‎.github/workflows/release.yml‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,12 @@ jobs:
395395
(github.event_name != 'schedule' || needs.resolve_commit.outputs.has_changes == 'true')
396396
runs-on: blacksmith-8vcpu-ubuntu-2404
397397
timeout-minutes: 5
398+
# Previews build any branch, but production admits only main and v* tags.
399+
# The empty name runs previews with no environment, so their Clerk and relay
400+
# ids come from .env.example. Everything else matches nightly: the tracing
401+
# read below needs only repository-level Cloudflare credentials.
398402
environment:
399-
name: production
403+
name: ${{ inputs.channel != 'preview' && 'production' || '' }}
400404
outputs:
401405
clerk_publishable_key: ${{ steps.public_config.outputs.clerk_publishable_key }}
402406
clerk_jwt_template: ${{ steps.public_config.outputs.clerk_jwt_template }}
@@ -462,9 +466,19 @@ jobs:
462466
- id: public_config
463467
name: Resolve production relay public config
464468
shell: bash
469+
env:
470+
PREVIEW: ${{ inputs.channel == 'preview' }}
465471
run: |
466472
set -euo pipefail
467473
474+
if [[ "$PREVIEW" == "true" ]]; then
475+
env_example() { sed -n "s|^T3CODE_$1=||p" .env.example; }
476+
CLERK_PUBLISHABLE_KEY="$(env_example CLERK_PUBLISHABLE_KEY)"
477+
CLERK_JWT_TEMPLATE="$(env_example CLERK_JWT_TEMPLATE)"
478+
CLERK_CLI_OAUTH_CLIENT_ID="$(env_example CLERK_CLI_OAUTH_CLIENT_ID)"
479+
RELAY_DOMAIN="$(sed -n 's|^T3CODE_RELAY_URL=https://||p' .env.example)"
480+
fi
481+
468482
relay_domain="${RELAY_DOMAIN:-}"
469483
if [[ -z "$relay_domain" && -n "${RELAY_API_ZONE_NAME:-}" ]]; then
470484
relay_domain="relay.$RELAY_API_ZONE_NAME"

‎AGENTS.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# T3 Code
22

3-
T3 Code is a minimal GUI for coding agents. A Node WebSocket server wraps provider CLIs and agents (Codex, Claude Code, Cursor, Grok, OpenCode, Antigravity) and serves web, desktop, and mobile clients.
3+
T3 Code is a minimal GUI for coding agents. A Node WebSocket server wraps provider CLIs and agents (Codex, Claude Code, Cursor, Grok, OpenCode, Antigravity, Kiro) and serves web, desktop, and mobile clients.
44

55
You can think of T3 Code as an open source "bring-your-own-subscription" alternative to apps like Claude Desktop, Codex App, Cursor Glass and Conductor.
66

@@ -68,7 +68,7 @@ The most common defect in this repo is a change that works on the path you teste
6868

6969
- **Entry points.** A behavior reachable from the chat view is usually also reachable from Settings, the command palette, and a keybinding. Fixing one is not fixing the feature.
7070
- **Clients.** Web, desktop (wraps web, adds Electron shell/IPC), and mobile (React Native, separate navigation). Shared logic lives in `packages/client-runtime`
71-
- **Providers.** Codex, Claude, Cursor, Grok, OpenCode, and Antigravity each have an adapter. Provider-shaped features need a decision per adapter, even if the decision is "not supported here".
71+
- **Providers.** Codex, Claude, Cursor, Grok, OpenCode, Antigravity, and Kiro each have an adapter. Provider-shaped features need a decision per adapter, even if the decision is "not supported here".
7272
- **Agents.** A capability a user can trigger is usually one an agent should reach through MCP tools, and scheduled tasks run the same paths. That only works when it is a service method, not handler code.
7373
- **Contracts.** Anything crossing the wire is typed in `packages/contracts`. Change the schema and the server, web, mobile, and desktop all follow.
7474
- **Reverse states.** If you added a way in, add the way out and the way to see it. Snooze needs unsnooze. Close needs reopen. A one-way door is a bug.

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Paint splatter across the chat canvas in every theme's colours, on the unfolded
7373

7474
## More than upstream
7575

76-
Compared with upstream `main` at [e6e2ab05cc](https://github.com/pingdotgg/t3code/commit/e6e2ab05cc), synced **2 November 2026**, Fold adds the features below. They describe the code on Fold's `main`; an older published installer may not include every change.
76+
Compared with upstream `main` at [5b9731cedc](https://github.com/pingdotgg/t3code/commit/5b9731cedc), synced **3 November 2026**, Fold adds the features below. They describe the code on Fold's `main`; an older published installer may not include every change.
7777

7878
| Feature | What you get | Available in |
7979
| ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------- |

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,16 @@ const bootstrap = Effect.gen(function* () {
245245
}
246246
yield* primaryBackend.start;
247247
yield* logBootstrapInfo("bootstrap backend start requested");
248+
// WSL-only fallback can change the primary endpoint before readiness.
249+
const config = yield* primaryBackend.currentConfig;
250+
if (
251+
!environment.isDevelopment &&
252+
!settings.wslOnly &&
253+
Option.isSome(config) &&
254+
Option.isNone(config.value.preflightFailure)
255+
) {
256+
yield* desktopWindow.ensureMain;
257+
}
248258
yield* appActivation.start.pipe(
249259
Effect.tap(() => logBootstrapInfo("desktop app control socket ready")),
250260
Effect.catch((error) => logStartupError("desktop app control socket unavailable", { error })),

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

Lines changed: 131 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
import type { DesktopUpdateState } from "@t3tools/contracts";
2-
import { describe, expect, it } from "vite-plus/test";
2+
import { describe, expect, it } from "@effect/vitest";
3+
import * as Deferred from "effect/Deferred";
4+
import * as Effect from "effect/Effect";
5+
import * as FileSystem from "effect/FileSystem";
6+
import * as Layer from "effect/Layer";
7+
import * as Option from "effect/Option";
8+
import * as Ref from "effect/Ref";
9+
import * as Stream from "effect/Stream";
10+
import * as SubscriptionRef from "effect/SubscriptionRef";
11+
import * as DesktopEnvironment from "./DesktopEnvironment.ts";
12+
import * as DesktopState from "./DesktopState.ts";
13+
import * as ElectronApp from "../electron/ElectronApp.ts";
14+
import * as ElectronShell from "../electron/ElectronShell.ts";
15+
import * as ElectronTheme from "../electron/ElectronTheme.ts";
16+
import * as ElectronWindow from "../electron/ElectronWindow.ts";
17+
import * as DesktopUpdates from "../updates/DesktopUpdates.ts";
318

419
import { createInitialDesktopUpdateState } from "../updates/updateMachine.ts";
5-
import { resolveStartupRecoveryOffer } from "./DesktopStartupRecovery.ts";
20+
import { listen, resolveStartupRecoveryOffer } from "./DesktopStartupRecovery.ts";
621

722
const updateState = (patch: Partial<DesktopUpdateState>): DesktopUpdateState => ({
823
...createInitialDesktopUpdateState(
@@ -68,3 +83,117 @@ describe("resolveStartupRecoveryOffer", () => {
6883
});
6984
});
7085
});
86+
87+
it.effect.each([
88+
{ visible: false, started: false, closeMain: false },
89+
{ visible: true, started: false, closeMain: false },
90+
{ visible: true, started: true, closeMain: false },
91+
{ visible: true, started: false, closeMain: true },
92+
])("closes recovery safely with closeMain=$closeMain", ({ visible, started, closeMain }) =>
93+
Effect.scoped(
94+
Effect.gen(function* () {
95+
const checked = yield* Deferred.make<void>();
96+
const remembered = yield* Deferred.make<void>();
97+
const shouldRecover = !visible || !started;
98+
const closed = Promise.withResolvers<void>();
99+
const loaded: string[] = [];
100+
const appListeners = new Map<string, (...args: readonly unknown[]) => void>();
101+
const mainListeners = new Map<string, () => void>();
102+
let closeCount = 0;
103+
let mainVisible = visible;
104+
const main = {
105+
isDestroyed: () => false,
106+
isVisible: () => mainVisible,
107+
on: (event: string, listener: () => void) => mainListeners.set(event, listener),
108+
once: (event: string, listener: () => void) => mainListeners.set(event, listener),
109+
} as unknown as Electron.BrowserWindow;
110+
const mainRef = yield* Ref.make(Option.some(main));
111+
const recovery = {
112+
isDestroyed: () => false,
113+
close: () => {
114+
closeCount++;
115+
closed.resolve();
116+
},
117+
loadURL: (url: string) => {
118+
loaded.push(url);
119+
return Promise.resolve();
120+
},
121+
once: () => {},
122+
webContents: { setWindowOpenHandler: () => {}, on: () => {} },
123+
} as unknown as Electron.BrowserWindow;
124+
const state = yield* DesktopState.DesktopState;
125+
if (started) yield* SubscriptionRef.set(state.primaryBackendStartup, { _tag: "Ready" });
126+
yield* listen.pipe(
127+
Effect.provide(
128+
Layer.mergeAll(
129+
FileSystem.layerNoop({
130+
readFileString: () => Effect.succeed("0.1.2"),
131+
writeFileString: () => Deferred.succeed(remembered, undefined).pipe(Effect.asVoid),
132+
}),
133+
Layer.succeed(DesktopEnvironment.DesktopEnvironment, {
134+
appVersion: "0.1.3",
135+
stateDir: "/task/state",
136+
logDir: "/task/logs",
137+
path: { join: (...parts: string[]) => parts.join("/") },
138+
} as unknown as DesktopEnvironment.DesktopEnvironment["Service"]),
139+
Layer.succeed(ElectronApp.ElectronApp, {
140+
on: (event: string, listener: (...args: readonly unknown[]) => void) =>
141+
Effect.sync(() => {
142+
appListeners.set(event, listener);
143+
}),
144+
} as unknown as ElectronApp.ElectronApp["Service"]),
145+
Layer.succeed(
146+
ElectronShell.ElectronShell,
147+
{} as ElectronShell.ElectronShell["Service"],
148+
),
149+
Layer.succeed(ElectronTheme.ElectronTheme, {
150+
shouldUseDarkColors: Effect.succeed(false),
151+
} as ElectronTheme.ElectronTheme["Service"]),
152+
Layer.succeed(ElectronWindow.ElectronWindow, {
153+
main: Ref.get(mainRef),
154+
create: () => Effect.succeed(recovery),
155+
} as unknown as ElectronWindow.ElectronWindow["Service"]),
156+
Layer.succeed(DesktopUpdates.DesktopUpdates, {
157+
subscribe: Effect.succeed({
158+
latest: updateState({ status: "disabled" }),
159+
changes: Stream.empty,
160+
}),
161+
check: () => Deferred.succeed(checked, undefined),
162+
} as unknown as DesktopUpdates.DesktopUpdates["Service"]),
163+
),
164+
),
165+
);
166+
appListeners.get("browser-window-created")?.({}, main);
167+
if (started) yield* Deferred.await(remembered);
168+
yield* SubscriptionRef.set(state.primaryBackendStartup, {
169+
_tag: "Failing",
170+
reason: "Server failed before readiness",
171+
output: "Failure details",
172+
});
173+
yield* Deferred.await(checked);
174+
expect(loaded.length).toBe(shouldRecover ? 1 : 0);
175+
if (shouldRecover) {
176+
expect(decodeURIComponent(loaded[0]!)).toContain("Failure details");
177+
if (closeMain) yield* Ref.set(mainRef, Option.none());
178+
yield* SubscriptionRef.set(state.primaryBackendStartup, { _tag: "Ready" });
179+
yield* Deferred.await(remembered);
180+
if (closeMain || !visible) {
181+
expect(closeCount).toBe(0);
182+
if (closeMain) {
183+
yield* Ref.set(mainRef, Option.some(main));
184+
mainVisible = false;
185+
appListeners.get("browser-window-created")?.({}, main);
186+
}
187+
mainListeners.get("ready-to-show")?.();
188+
expect(closeCount).toBe(0);
189+
mainVisible = true;
190+
const show = mainListeners.get("show");
191+
expect(show).toBeDefined();
192+
show!();
193+
}
194+
yield* Effect.promise(() => closed.promise);
195+
expect(closeCount).toBe(1);
196+
}
197+
}),
198+
).pipe(Effect.provide(DesktopState.layer)),
199+
);

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

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ export const listen: Effect.Effect<
167167
const failureRef = yield* Ref.make(Option.none<BackendStartupFailure>());
168168
const renderedHtmlRef = yield* Ref.make("");
169169
const checkedRef = yield* Ref.make(false);
170+
let backendHasStarted = false;
170171
const { latest, changes: updateChanges } = yield* updates.subscribe;
171172
const updateStateRef = yield* Ref.make(latest);
172173

@@ -230,8 +231,15 @@ export const listen: Effect.Effect<
230231
const show = Effect.fn("desktop.startupRecovery.show")(
231232
function* () {
232233
if (yield* Ref.get(quitting)) return;
233-
// A backend that crashes after the app opened is reported by the app itself.
234-
if (Option.isSome(yield* electronWindow.main)) return;
234+
// A visible boot shell still needs recovery if the backend has never started.
235+
const main = yield* electronWindow.main;
236+
if (
237+
backendHasStarted &&
238+
Option.isSome(main) &&
239+
!main.value.isDestroyed() &&
240+
main.value.isVisible()
241+
)
242+
return;
235243
const existing = yield* Ref.get(windowRef);
236244
if (Option.isSome(existing) && !existing.value.isDestroyed()) {
237245
yield* electronWindow.reveal(existing.value);
@@ -285,6 +293,19 @@ export const listen: Effect.Effect<
285293
if (Option.isSome(window) && !window.value.isDestroyed()) window.value.close();
286294
});
287295

296+
const closeWhenMainReady = Effect.gen(function* () {
297+
if ((yield* SubscriptionRef.get(primaryBackendStartup))._tag !== "Ready") return;
298+
const main = yield* electronWindow.main;
299+
if (Option.isSome(main) && !main.value.isDestroyed() && main.value.isVisible()) yield* close;
300+
});
301+
302+
yield* electronApp.on(
303+
"browser-window-created",
304+
(_event: Electron.Event, window: Electron.BrowserWindow) => {
305+
window.on("show", () => runFork(closeWhenMainReady));
306+
},
307+
);
308+
288309
const rememberStartedVersion = Effect.gen(function* () {
289310
if (lastStartedVersion === environment.appVersion) return;
290311
yield* fileSystem.writeFileString(lastStartedVersionPath, environment.appVersion);
@@ -303,8 +324,9 @@ export const listen: Effect.Effect<
303324
Stream.runForEach(
304325
Effect.fn("desktop.startupRecovery.onStartupChange")(function* (startup) {
305326
if (startup._tag === "Ready") {
327+
backendHasStarted = true;
306328
yield* Ref.set(failureRef, Option.none());
307-
yield* close;
329+
yield* closeWhenMainReady;
308330
yield* rememberStartedVersion;
309331
return;
310332
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as NodeEvents from "node:events";
44
import * as Effect from "effect/Effect";
55
import * as Layer from "effect/Layer";
66

7+
import * as DesktopWindow from "../window/DesktopWindow.ts";
78
import * as ElectronWindow from "../electron/ElectronWindow.ts";
89
import { WEB_LINK_OPEN_CHANNEL } from "../ipc/channels.ts";
910
import * as DesktopWebLinks from "./DesktopWebLinks.ts";
@@ -21,6 +22,11 @@ const makeWindow = () => {
2122
const reload = () =>
2223
webContents.emit("did-start-navigation", { isMainFrame: true, isSameDocument: false });
2324
const layer = DesktopWebLinks.layer.pipe(
25+
Layer.provide(
26+
Layer.succeed(DesktopWindow.DesktopWindow, {
27+
activate: Effect.sync(() => void revealed.push(window)),
28+
} as unknown as DesktopWindow.DesktopWindow["Service"]),
29+
),
2430
Layer.provide(
2531
Layer.succeed(
2632
ElectronWindow.ElectronWindow,

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as Effect from "effect/Effect";
33
import * as Layer from "effect/Layer";
44
import * as Option from "effect/Option";
55

6+
import * as DesktopWindow from "../window/DesktopWindow.ts";
67
import * as ElectronWindow from "../electron/ElectronWindow.ts";
78
import { WEB_LINK_OPEN_CHANNEL } from "../ipc/channels.ts";
89

@@ -24,6 +25,7 @@ export class DesktopWebLinks extends Context.Service<
2425

2526
const make = Effect.gen(function* () {
2627
const electronWindow = yield* ElectronWindow.ElectronWindow;
28+
const desktopWindow = yield* DesktopWindow.DesktopWindow;
2729
const pending: Array<string> = [];
2830
let listening: Electron.WebContents | null = null;
2931
let detachListening: (() => void) | null = null;
@@ -43,7 +45,7 @@ const make = Effect.gen(function* () {
4345
return;
4446
}
4547
for (const url of pending.splice(0)) listening.send(WEB_LINK_OPEN_CHANNEL, url);
46-
yield* electronWindow.reveal(window.value);
48+
yield* desktopWindow.activate.pipe(Effect.ignore);
4749
});
4850

4951
const startListening = Effect.gen(function* () {

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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,49 @@ function makeTestInstance(input: MakeInstanceInput) {
192192
}
193193

194194
describe("DesktopBackendManager", () => {
195+
it.effect("notifies readiness waiters on HTTP readiness and stop without clock advancement", () =>
196+
Effect.scoped(
197+
Effect.gen(function* () {
198+
const probe = yield* Deferred.make<void>();
199+
const ready = yield* Deferred.make<void>();
200+
const exit = yield* Deferred.make<ChildProcessSpawner.ExitCode>();
201+
const instance = yield* makeTestInstance({
202+
spawnerLayer: Layer.succeed(
203+
ChildProcessSpawner.ChildProcessSpawner,
204+
ChildProcessSpawner.make(() =>
205+
Effect.acquireRelease(
206+
Effect.succeed(
207+
makeProcess({
208+
exitCode: Deferred.await(exit),
209+
kill: () =>
210+
Deferred.succeed(exit, ChildProcessSpawner.ExitCode(0)).pipe(Effect.asVoid),
211+
}),
212+
),
213+
() => Deferred.succeed(exit, ChildProcessSpawner.ExitCode(0)),
214+
),
215+
),
216+
),
217+
httpClientLayer: Layer.succeed(
218+
HttpClient.HttpClient,
219+
HttpClient.make((request) =>
220+
Deferred.succeed(probe, undefined).pipe(
221+
Effect.andThen(Deferred.await(ready)),
222+
Effect.as(HttpClientResponse.fromWeb(request, new Response("{}"))),
223+
),
224+
),
225+
),
226+
});
227+
yield* instance.start;
228+
yield* Deferred.await(probe);
229+
const waiter = yield* instance.waitForReady(Duration.seconds(15)).pipe(Effect.forkChild);
230+
yield* Deferred.succeed(ready, undefined);
231+
assert.isTrue(yield* Fiber.join(waiter));
232+
yield* instance.stop();
233+
assert.isFalse(yield* instance.waitForReady(Duration.seconds(15)));
234+
}),
235+
),
236+
);
237+
195238
it.effect("spawns the backend with fd3 bootstrap and fd4 telemetry", () =>
196239
Effect.scoped(
197240
Effect.gen(function* () {

0 commit comments

Comments
 (0)