Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2669a8b
test(desktop): reproduce #12689 topology polling blocking on sendSync
juliusmarminge Oct 22, 2026
0427a89
fix(desktop): stop blocking the renderer during topology polling
juliusmarminge Oct 22, 2026
60084db
test(desktop): stub window listeners so the preload test loads on macOS
juliusmarminge Oct 22, 2026
fc73657
Merge remote-tracking branch 'origin/main' into fix/issue-12689
juliusmarminge Oct 22, 2026
51a48ac
test(client-runtime): reproduce #25823, one shell update rebuilds the…
juliusmarminge Oct 27, 2026
6fd4cfc
fix(client-runtime): the quiet thread list rebuilds once per shell up…
juliusmarminge Oct 27, 2026
da9db8b
Merge remote-tracking branch 'origin/main' into fix/issue-25823
juliusmarminge Oct 27, 2026
d1c7b1a
fix(mobile): keep thread lists stable during streaming
PixPMusic Oct 25, 2026
b1094d0
test(client-runtime): takeover tests for stable navigation thread shells
juliusmarminge Oct 27, 2026
17e450d
fix(client-runtime): navigation thread shells reuse the quiet per-thr…
juliusmarminge Oct 27, 2026
e8a926a
fix(client-runtime): keep the contributor's positional navigation reuse
juliusmarminge Oct 27, 2026
ecafd4e
perf(web): typing no longer re-renders the composer's footer controls
OmarAlex24 Nov 7, 2026
31cf4b5
Merge remote-tracking branch 'github/main' into pr-32323
maria-rcks Nov 10, 2026
684c3ab
perf(web): completed Markdown blocks no longer render twice
voltcrash Nov 10, 2026
99eacfe
Merge remote-tracking branch 'origin/main' into fix/issue-25823
juliusmarminge Nov 11, 2026
3a4a1c8
test(client-runtime): the quiet thread list still leaves out tag-hidd…
juliusmarminge Nov 11, 2026
28cb743
Merge remote-tracking branch 'origin/main' into fix/issue-12689
juliusmarminge Nov 11, 2026
692eb7a
test(desktop): keep the topology polling regression test loading afte…
juliusmarminge Nov 11, 2026
fb9d42b
Merge remote-tracking branch 'origin/main' into fix/issue-25823
juliusmarminge Nov 13, 2026
43cf7bc
perf(web): batch first-send composer updates
StiensWout Nov 13, 2026
03d66f0
Merge upstream pingdotgg/t3code#23601: fix(desktop): typing no longer…
eyeveil Nov 13, 2026
f8931f9
Merge upstream pingdotgg/t3code#24651: fix(mobile): keep thread lists…
eyeveil Nov 13, 2026
58c743e
Merge upstream pingdotgg/t3code#35848: fix(client-runtime): opening a…
eyeveil Nov 13, 2026
f2b5928
Merge upstream pingdotgg/t3code#36166: perf(web): batch first-send co…
eyeveil Nov 13, 2026
b36c0df
Merge upstream pingdotgg/t3code#33794: perf(web): completed Markdown …
eyeveil Nov 13, 2026
3715e72
Merge upstream pingdotgg/t3code#32323: perf(web): typing no longer re…
eyeveil Nov 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/desktop/src/ipc/DesktopIpcHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
import {
getAppBranding,
getLocalEnvironmentBootstraps,
getLocalEnvironmentBootstrapsAsync,
getLocalEnvironmentBearerToken,
installRelayTelemetryEnabled,
getSystemLocale,
Expand Down Expand Up @@ -105,6 +106,7 @@ export const installDesktopIpcHandlers = Effect.fn("desktop.ipc.installHandlers"
yield* ipc.handleSync(getPrimaryPasteEnabled);
yield* ipc.handleSync(getWindowFullscreenState);
yield* ipc.handleSync(getLocalEnvironmentBootstraps);
yield* ipc.handle(getLocalEnvironmentBootstrapsAsync);
yield* ipc.handleSync(getLocalEnvironmentEnabled);
yield* ipc.handle(setLocalEnvironmentEnabled);
yield* ipc.handle(getHostEnvironmentId);
Expand Down
101 changes: 56 additions & 45 deletions apps/desktop/src/ipc/methods/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,55 +135,66 @@ export const getWindowFullscreenState = DesktopIpc.makeSyncIpcMethod({
}),
});

export const getLocalEnvironmentBootstraps = DesktopIpc.makeSyncIpcMethod({
channel: IpcChannels.GET_LOCAL_ENVIRONMENT_BOOTSTRAPS_CHANNEL,
result: Schema.Array(DesktopEnvironmentBootstrapSchema),
handler: Effect.fn("desktop.ipc.window.getLocalEnvironmentBootstraps")(function* () {
const pool = yield* DesktopBackendPool.DesktopBackendPool;
const configuration = yield* DesktopBackendConfiguration.DesktopBackendConfiguration;
const instances = yield* pool.list;
const bootstraps: DesktopEnvironmentBootstrap[] = [];
for (const instance of instances) {
const isPrimary = instance.id === PRIMARY_LOCAL_ENVIRONMENT_ID;
const config = yield* instance.currentConfig;
const snapshot = yield* instance.snapshot;
if (Option.isNone(config) || Option.isSome(config.value.preflightFailure)) {
const fatalPreflight =
Option.isSome(config) &&
Option.isSome(config.value.preflightFailure) &&
config.value.preflightFailure.value.fatal;
const stoppedPreflight =
Option.isSome(config) &&
Option.isSome(config.value.preflightFailure) &&
(!snapshot.desiredRunning || !snapshot.restartScheduled);
if (isPrimary || fatalPreflight || stoppedPreflight) continue;
bootstraps.push({
id: instance.id,
label: yield* instance.label,
runningDistro: null,
httpBaseUrl: null,
wsBaseUrl: null,
});
continue;
}
const { bootstrap, httpBaseUrl } = config.value;
const runningDistro = config.value.runningDistro ?? null;
const readLocalEnvironmentBootstrapSnapshot = Effect.fn(
"desktop.ipc.window.getLocalEnvironmentBootstraps",
)(function* () {
const pool = yield* DesktopBackendPool.DesktopBackendPool;
const configuration = yield* DesktopBackendConfiguration.DesktopBackendConfiguration;
const instances = yield* pool.list;
const bootstraps: DesktopEnvironmentBootstrap[] = [];
for (const instance of instances) {
const isPrimary = instance.id === PRIMARY_LOCAL_ENVIRONMENT_ID;
const config = yield* instance.currentConfig;
const snapshot = yield* instance.snapshot;
if (Option.isNone(config) || Option.isSome(config.value.preflightFailure)) {
const fatalPreflight =
Option.isSome(config) &&
Option.isSome(config.value.preflightFailure) &&
config.value.preflightFailure.value.fatal;
const stoppedPreflight =
Option.isSome(config) &&
Option.isSome(config.value.preflightFailure) &&
(!snapshot.desiredRunning || !snapshot.restartScheduled);
if (isPrimary || fatalPreflight || stoppedPreflight) continue;
bootstraps.push({
id: instance.id,
label: runningDistro === null ? yield* instance.label : `WSL (${runningDistro})`,
runningDistro,
httpBaseUrl: httpBaseUrl.href,
wsBaseUrl: toWebSocketBaseUrl(httpBaseUrl),
// Use the current window's derived token; the launch config's token may be stale.
...(bootstrap.desktopBootstrapSecret
? { bootstrapToken: yield* configuration.currentBootstrapToken }
: bootstrap.desktopBootstrapToken
? { bootstrapToken: bootstrap.desktopBootstrapToken }
: {}),
label: yield* instance.label,
runningDistro: null,
httpBaseUrl: null,
wsBaseUrl: null,
});
continue;
}
return bootstraps;
}),
const { bootstrap, httpBaseUrl } = config.value;
const runningDistro = config.value.runningDistro ?? null;
bootstraps.push({
id: instance.id,
label: runningDistro === null ? yield* instance.label : `WSL (${runningDistro})`,
runningDistro,
httpBaseUrl: httpBaseUrl.href,
wsBaseUrl: toWebSocketBaseUrl(httpBaseUrl),
// Use the current window's derived token; the launch config's token may be stale.
...(bootstrap.desktopBootstrapSecret
? { bootstrapToken: yield* configuration.currentBootstrapToken }
: bootstrap.desktopBootstrapToken
? { bootstrapToken: bootstrap.desktopBootstrapToken }
: {}),
});
}
return bootstraps;
});

export const getLocalEnvironmentBootstraps = DesktopIpc.makeSyncIpcMethod({
channel: IpcChannels.GET_LOCAL_ENVIRONMENT_BOOTSTRAPS_CHANNEL,
result: Schema.Array(DesktopEnvironmentBootstrapSchema),
handler: readLocalEnvironmentBootstrapSnapshot,
});

export const getLocalEnvironmentBootstrapsAsync = DesktopIpc.makeIpcMethod({
channel: IpcChannels.GET_LOCAL_ENVIRONMENT_BOOTSTRAPS_CHANNEL,
payload: Schema.Void,
result: Schema.Array(DesktopEnvironmentBootstrapSchema),
handler: readLocalEnvironmentBootstrapSnapshot,
});

function extractWslDistroFromEnvironmentId(envId: string): string | null {
Expand Down
67 changes: 67 additions & 0 deletions apps/desktop/src/preload.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import type { DesktopBridge } from "@t3tools/contracts";
import { ipcRenderer } from "electron";
import { expect, it, vi } from "vite-plus/test";

import * as IpcChannels from "./ipc/channels.ts";

const { exposed, sendSync } = vi.hoisted(() => ({
exposed: new Map<string, unknown>(),
sendSync: vi.fn((channel: string): unknown =>
channel === "desktop:get-local-environment-enabled" ? true : [],
),
}));

vi.mock("electron", () => ({
contextBridge: {
exposeInMainWorld: (key: string, api: unknown) => exposed.set(key, api),
},
ipcRenderer: {
sendSync,
invoke: vi.fn(async () => undefined),
on: vi.fn(),
removeListener: vi.fn(),
},
webFrame: { getZoomFactor: () => 1 },
webUtils: { getPathForFile: () => "" },
}));
vi.mock("@clerk/electron/preload", () => ({ exposeClerkBridge: vi.fn() }));

it("topology polling reads the cache and refreshes it without synchronous IPC", async () => {
vi.stubGlobal("window", {
addEventListener: () => {},
localStorage: { getItem: () => null, setItem: () => {} },
});
vi.stubGlobal("document", {
addEventListener: () => {},
fullscreenElement: null,
documentElement: { style: { setProperty: () => {} } },
});
await import("./preload.ts");
const bridge = exposed.get("desktopBridge") as DesktopBridge;
sendSync.mockClear();

// sendSync freezes the renderer until main answers; only the first read may use it.
for (let poll = 0; poll < 5; poll += 1) {
bridge.getLocalEnvironmentBootstraps();
bridge.getLocalEnvironmentEnabled();
}
const syncCalls = (channel: string) =>
sendSync.mock.calls.filter(([called]) => called === channel).length;
expect(syncCalls(IpcChannels.GET_LOCAL_ENVIRONMENT_BOOTSTRAPS_CHANNEL)).toBeLessThanOrEqual(1);
expect(syncCalls(IpcChannels.GET_LOCAL_ENVIRONMENT_ENABLED_CHANNEL)).toBeLessThanOrEqual(1);

const wsl = {
id: "wsl:Ubuntu",
label: "WSL (Ubuntu)",
runningDistro: "Ubuntu",
httpBaseUrl: "http://127.0.0.1:4000/",
wsBaseUrl: "ws://127.0.0.1:4000/",
};
vi.mocked(ipcRenderer.invoke).mockResolvedValueOnce([wsl]).mockResolvedValueOnce([]);
sendSync.mockClear();
await bridge.refreshLocalEnvironmentBootstraps?.();
expect(bridge.getLocalEnvironmentBootstraps()).toEqual([wsl]);
await bridge.refreshLocalEnvironmentBootstraps?.();
expect(bridge.getLocalEnvironmentBootstraps()).toEqual([]);
expect(sendSync).not.toHaveBeenCalled();
});
30 changes: 22 additions & 8 deletions apps/desktop/src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ function unwrapEnsureSshEnvironmentResult(result: unknown) {
return result as Awaited<ReturnType<DesktopBridge["ensureSshEnvironment"]>>;
}

const readBootstraps = (
result: unknown,
): ReturnType<DesktopBridge["getLocalEnvironmentBootstraps"]> =>
Array.isArray(result) ? result : [];
// sendSync blocks the renderer until the main process answers, so it runs once for the first
// paint; topology polling refreshes this cache over async IPC instead.
let localEnvironmentBootstraps:
| ReturnType<DesktopBridge["getLocalEnvironmentBootstraps"]>
| undefined;
// Changes take effect on relaunch, so renderer reads can reuse the startup value.
let localEnvironmentEnabled: boolean | undefined;

contextBridge.exposeInMainWorld("desktopBridge", {
getAppBranding: () => {
const result = ipcRenderer.sendSync(IpcChannels.GET_APP_BRANDING_CHANNEL);
Expand Down Expand Up @@ -146,17 +158,19 @@ contextBridge.exposeInMainWorld("desktopBridge", {
);
return Array.isArray(result) ? result.filter((tag) => typeof tag === "string") : [];
},
getLocalEnvironmentBootstraps: () => {
const result = ipcRenderer.sendSync(IpcChannels.GET_LOCAL_ENVIRONMENT_BOOTSTRAPS_CHANNEL);
if (!Array.isArray(result)) {
return [];
}
return result as ReturnType<DesktopBridge["getLocalEnvironmentBootstraps"]>;
},
getLocalEnvironmentBootstraps: () =>
(localEnvironmentBootstraps ??= readBootstraps(
ipcRenderer.sendSync(IpcChannels.GET_LOCAL_ENVIRONMENT_BOOTSTRAPS_CHANNEL),
)),
refreshLocalEnvironmentBootstraps: async () =>
(localEnvironmentBootstraps = readBootstraps(
await ipcRenderer.invoke(IpcChannels.GET_LOCAL_ENVIRONMENT_BOOTSTRAPS_CHANNEL),
)),
getLocalEnvironmentBearerToken: () =>
ipcRenderer.invoke(IpcChannels.GET_LOCAL_ENVIRONMENT_BEARER_TOKEN_CHANNEL),
getLocalEnvironmentEnabled: () =>
ipcRenderer.sendSync(IpcChannels.GET_LOCAL_ENVIRONMENT_ENABLED_CHANNEL) !== false,
(localEnvironmentEnabled ??=
ipcRenderer.sendSync(IpcChannels.GET_LOCAL_ENVIRONMENT_ENABLED_CHANNEL) !== false),
setLocalEnvironmentEnabled: (enabled) =>
ipcRenderer.invoke(IpcChannels.SET_LOCAL_ENVIRONMENT_ENABLED_CHANNEL, enabled),
getHostEnvironmentId: () => ipcRenderer.invoke(IpcChannels.GET_HOST_ENVIRONMENT_ID_CHANNEL),
Expand Down
24 changes: 22 additions & 2 deletions apps/web/src/components/ChatMarkdown.browser.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,10 @@ it("reuses the parse of a streaming reply's finished blocks when it remounts", a
<ChatMarkdown cwd="/tmp/project" text={"Finished block\n\nStill growing"} isStreaming />
);
{
await using _first = await render(message);
await using first = await render(
<ChatMarkdown cwd="/tmp/project" text={"Finished block\n\n"} isStreaming />,
);
await first.rerender(message);
}
await using screen = await render(message);
await expect.element(screen.getByText("Still growing")).toBeVisible();
Expand All @@ -269,11 +272,28 @@ it("reuses the parse of a remounted message that has stable extra plugins", asyn
<ChatMarkdown cwd="/tmp/project" text="Cached text" extraRemarkPlugins={countingPlugins} />
);
{
await using _first = await render(message);
await using first = await render(
<ChatMarkdown
cwd="/tmp/project"
text="Cached text"
extraRemarkPlugins={countingPlugins}
isStreaming
/>,
);
await first.rerender(message);
}
await using screen = await render(message);
await expect.element(screen.getByText("Cached text")).toBeVisible();
expect(parsed).toHaveBeenCalledTimes(1);
const changed = vi.fn();
await screen.rerender(
<ChatMarkdown
cwd="/tmp/project"
text="Cached text"
extraRemarkPlugins={[() => () => void changed()]}
/>,
);
expect(changed).toHaveBeenCalledTimes(1);
});

it("highlights a code block's own source when an earlier block of the same length was cached", async () => {
Expand Down
10 changes: 7 additions & 3 deletions apps/web/src/components/ChatMarkdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import React, {
type MouseEvent as ReactMouseEvent,
use,
memo,
useEffect,
useLayoutEffect,
useRef,
useState,
Expand Down Expand Up @@ -1801,9 +1802,12 @@ const MarkdownSource = memo(function MarkdownSource({
components: CHAT_MARKDOWN_COMPONENTS,
urlTransform: markdownUrlTransform,
});
return (
<ChatMarkdownTextContext value={text}>{render(text, shared && cache)}</ChatMarkdownTextContext>
);
const element = render(text, false);
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- Promote the committed element into the shared parse cache when its block finishes.
useEffect(() => {
if (shared && cache) render.remember(text, element);
}, [render, text, element, shared, cache]);
return <ChatMarkdownTextContext value={text}>{element}</ChatMarkdownTextContext>;
});

function ChatMarkdown({
Expand Down
4 changes: 3 additions & 1 deletion apps/web/src/components/chat/ChatComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -910,13 +910,15 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
? providerInstanceEntries.find((entry) => hasProviderSetup(entry.snapshot))?.instanceId
: undefined))
: undefined;
// Called before the derivation below: a hook between it and its uses stops React Compiler
// from caching the mode options, and the footer then re-renders on every keystroke.
const managedPolicy = useManagedPolicy(environmentId);
const { modes: compatibleRuntimeModes, mode: compatibleRuntimeMode } =
resolveCompatibleRuntimeMode(
runtimeMode,
selectedProviderEntry?.snapshot.supportedRuntimeModes,
);
// Modes above an administrator's ceiling stay listed, disabled with the reason.
const managedPolicy = useManagedPolicy(environmentId);
const compatibleRuntimeModeOptions = resolveRuntimeModeOptions(
compatibleRuntimeModes,
managedPolicy,
Expand Down
Loading
Loading