From 51a638fe8bfcb7781c649205f5181d562e89ca2d Mon Sep 17 00:00:00 2001 From: OmarAlex24 Date: Sat, 14 Nov 2026 00:56:42 +0000 Subject: [PATCH 1/5] test(server): tailscale script test no longer reaches the host's systemd and TUN On a host with systemd running and a tailscaled unit, the script took the systemd branch and restarted the real unit instead of the stubbed daemon, so it reported ERROR start. Stub systemctl in the harness and route the TUN check through the root prefix so the test pins it. Co-Authored-By: Claude Opus 5.5 --- apps/server/src/sandbox/sandboxSetup.test.ts | 13 ++++++++++--- apps/server/src/sandbox/sandboxSetup.ts | 3 ++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/server/src/sandbox/sandboxSetup.test.ts b/apps/server/src/sandbox/sandboxSetup.test.ts index 4596e2d108925..e75b89c4d537f 100644 --- a/apps/server/src/sandbox/sandboxSetup.test.ts +++ b/apps/server/src/sandbox/sandboxSetup.test.ts @@ -196,13 +196,16 @@ echo x >>"$HOME/curl.calls" ); }); -// Stand-ins for sudo and Tailscale's binaries, so the scripts run without root. The daemon never -// gets a TUN device, which is what a container gives tailscaled. `up` returns before the node has -// registered, as when its first register request hangs past the timeout and a retry succeeds. +// Stand-ins for sudo, systemctl, and Tailscale's binaries, so the scripts run without root and +// never touch the host's tailscaled unit. The daemon never gets a TUN device, which is what a +// container gives tailscaled. `up` returns before the node has registered, as when its first +// register request hangs past the timeout and a retry succeeds. const TAILSCALE_STUBS = { sudo: `#!/bin/sh [ "$1" = -n ] && shift exec "$@"`, + systemctl: `#!/bin/sh +exit 1`, tailscaled: `#!/bin/sh echo "$*" >"$T3_STUB/tailscaled.args" echo "$TS_ASSUME_NETWORK_UP_FOR_TEST" >"$T3_STUB/tailscaled.assume-up" @@ -277,6 +280,9 @@ describe("tailscaleScript", () => { Effect.gen(function* () { const fs = yield* FileSystem.FileSystem; const root = `${stub}/root`; + // Any character device passes the script's TUN check, so kernel mode is tried first. + yield* fs.makeDirectory(`${root}/dev/net`, { recursive: true }); + yield* fs.symlink("/dev/null", `${root}/dev/net/tun`); const authKey = "tskey-auth-'$(touch pwned)\""; const join = tailscaleScript({ authKey, hostname: "t3-sandbox-web", root }); expect(revealsSecret(join.command, authKey)).toBe(false); @@ -302,6 +308,7 @@ describe("tailscaleScript", () => { // A daemon that still answers in the recorded mode is left running. const starts = yield* fs.readFileString(`${stub}/starts`); + expect(starts).toBe("start\nstart\n"); const restart = tailscaleScript({ hostname: "t3-sandbox-web", root }); expect(restart.secrets).toBeUndefined(); const resumed = parseTailscaleReport(yield* run(restart)); diff --git a/apps/server/src/sandbox/sandboxSetup.ts b/apps/server/src/sandbox/sandboxSetup.ts index e874b0aabfe96..6b33dea2c4baa 100644 --- a/apps/server/src/sandbox/sandboxSetup.ts +++ b/apps/server/src/sandbox/sandboxSetup.ts @@ -269,6 +269,7 @@ const AS_ROOT = `as_root() { // `root` prefixes every system path, so tests can run the scripts without root. const tailscalePaths = (root: string) => ({ + tun: `${root}/dev/net/tun`, run: `${root}/run/tailscale`, socket: `${root}/run/tailscale/tailscaled.sock`, pidFile: `${root}/run/tailscale/t3-tailscaled.pid`, @@ -387,7 +388,7 @@ if answering; then fi fi if [ -z "$mode" ]; then - if [ -c /dev/net/tun ] && start kernel && has_tun; then + if [ -c ${paths.tun} ] && start kernel && has_tun; then mode=kernel else stop From a080ba39219b8cefac121890994e548634072d3a Mon Sep 17 00:00:00 2001 From: OmarAlex24 Date: Sat, 14 Nov 2026 00:57:40 +0000 Subject: [PATCH 2/5] test(web): remote-parent panel fixture carries a model selection The panel now checks whether the current thread is a sandbox mirror, which reads modelSelection.instanceId. The contracts require modelSelection on every thread shell, so the fixture, not the code, was incomplete. Co-Authored-By: Claude Opus 5.5 --- ...RelationshipsControl.remote-parent.browser.test.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/web/src/components/chat/ThreadRelationshipsControl.remote-parent.browser.test.tsx b/apps/web/src/components/chat/ThreadRelationshipsControl.remote-parent.browser.test.tsx index 08108cd835885..871dc16f89b80 100644 --- a/apps/web/src/components/chat/ThreadRelationshipsControl.remote-parent.browser.test.tsx +++ b/apps/web/src/components/chat/ThreadRelationshipsControl.remote-parent.browser.test.tsx @@ -1,4 +1,9 @@ -import { EnvironmentId, ThreadId, type OrchestrationV2ThreadShell } from "@t3tools/contracts"; +import { + EnvironmentId, + ProviderInstanceId, + ThreadId, + type OrchestrationV2ThreadShell, +} from "@t3tools/contracts"; import * as Cause from "effect/Cause"; import { expect, it, vi } from "vite-plus/test"; @@ -12,10 +17,11 @@ const { read, toast } = vi.hoisted(() => ({ const childEnvironmentId = EnvironmentId.make("child-environment"); const childThreadId = ThreadId.make("child-thread"); const parentEnvironmentId = EnvironmentId.make("parent-environment"); -// The panel reads only identity, lineage and delegation from the current thread. +// The panel reads only identity, model, lineage and delegation from the current thread. const child = { id: childThreadId, title: "Child", + modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5" }, lineage: { rootThreadId: childThreadId, parentThreadId: null, relationshipToParent: null }, forkedFrom: null, delegatedFrom: { From 4faf2f8177c4a3e93efd214c904982efef73f14d Mon Sep 17 00:00:00 2001 From: OmarAlex24 Date: Sun, 15 Nov 2026 18:15:30 +0000 Subject: [PATCH 3/5] test(mobile): composer permission tests mock the sandbox start queue b703713141 made useThreadComposerState read sandboxStartQueue from ./threads, but the test's ./threads mock never exported it, so 9 of 11 cases threw on render. Co-Authored-By: Claude Opus 5.5 --- apps/mobile/src/state/thread-task-permissions.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/mobile/src/state/thread-task-permissions.test.ts b/apps/mobile/src/state/thread-task-permissions.test.ts index d037ac106a025..41472d5cc76cc 100644 --- a/apps/mobile/src/state/thread-task-permissions.test.ts +++ b/apps/mobile/src/state/thread-task-permissions.test.ts @@ -132,6 +132,7 @@ vi.mock("./threads", async () => { sequenceAtom: () => Atom.make(0), pendingRequestsAtom: () => Atom.make(state.pendingRequests), }, + sandboxStartQueue: { sandboxStartRunId: () => Atom.make(null) }, threadEnvironment: { respondToApproval: state.approve, respondToUserInput: state.answer, From 9995ad250b0040b03e0e6dc1b07d15fe18e35c23 Mon Sep 17 00:00:00 2001 From: OmarAlex24 Date: Sun, 15 Nov 2026 18:28:24 +0000 Subject: [PATCH 4/5] fix(web): backport upstream fixes for two render-scenario regressions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The renders project (only run through scripts/render-metrics.ts, not CI) failed app-stream-assistant-turn (MarkdownParagraph 59, expected 30) and app-switch-thread (SidebarThreadRow 4, expected 2). Both fail identically on the upstream base the fork sits on (065aca4889) and pass on upstream main; the sandbox work did not cause them. - Streaming re-rendered each finished Markdown block once more when the next block arrived, because its `cache` prop flipped. Upstream dd5061364b (#33794, Lakshmi Tanmay) renders once and remembers the element in an effect. - Every sidebar row re-rendered on thread navigation through the `openPullRequestsInRightPanel` prop and an unstable `startThreadRename`. Upstream f968db10d7 (#33435, Dominik Zabcik) reads the flag at click time and stabilises the callback; bisected as the first upstream commit that passes app-switch-thread. (cherry picked from commit dd5061364bbf52f5008a16fb22e367c3680bdbd1) (cherry picked from commit f968db10d749b8ede49d5c8f35bd81cf4fb13681) Co-Authored-By: Lakshmi Tanmay Co-Authored-By: Dominik Žabčík <35886301+dominikzabcik@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 --- .../components/ChatMarkdown.browser.test.tsx | 24 ++++++++++- apps/web/src/components/ChatMarkdown.tsx | 10 +++-- apps/web/src/components/Sidebar.tsx | 8 ++-- .../components/chat/markdownRenderer.test.tsx | 15 ++++--- .../src/components/chat/markdownRenderer.ts | 13 ++++-- .../components/sidebar/SidebarThreadRow.tsx | 7 ++-- apps/web/test/appScenarios.renders.tsx | 42 ++++++++++++++----- 7 files changed, 87 insertions(+), 32 deletions(-) diff --git a/apps/web/src/components/ChatMarkdown.browser.test.tsx b/apps/web/src/components/ChatMarkdown.browser.test.tsx index 30f3bcdd32543..171c4d51c0ef8 100644 --- a/apps/web/src/components/ChatMarkdown.browser.test.tsx +++ b/apps/web/src/components/ChatMarkdown.browser.test.tsx @@ -255,7 +255,10 @@ it("reuses the parse of a streaming reply's finished blocks when it remounts", a ); { - await using _first = await render(message); + await using first = await render( + , + ); + await first.rerender(message); } await using screen = await render(message); await expect.element(screen.getByText("Still growing")).toBeVisible(); @@ -270,11 +273,28 @@ it("reuses the parse of a remounted message that has stable extra plugins", asyn ); { - await using _first = await render(message); + await using first = await render( + , + ); + 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( + () => 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 () => { diff --git a/apps/web/src/components/ChatMarkdown.tsx b/apps/web/src/components/ChatMarkdown.tsx index b19e815f5a8b0..7299136bc0c74 100644 --- a/apps/web/src/components/ChatMarkdown.tsx +++ b/apps/web/src/components/ChatMarkdown.tsx @@ -80,6 +80,7 @@ import React, { type MouseEvent as ReactMouseEvent, use, memo, + useEffect, useLayoutEffect, useRef, useState, @@ -1801,9 +1802,12 @@ const MarkdownSource = memo(function MarkdownSource({ components: CHAT_MARKDOWN_COMPONENTS, urlTransform: markdownUrlTransform, }); - return ( - {render(text, shared && cache)} - ); + const element = render(text); + // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- Caching during render would make React Compiler rebuild the element when `cache` flips. + useEffect(() => { + if (shared && cache) render.remember(text, element); + }, [render, text, element, shared, cache]); + return {element}; }); function ChatMarkdown({ diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index e4ee31aecb669..b5068864e202e 100644 --- a/apps/web/src/components/Sidebar.tsx +++ b/apps/web/src/components/Sidebar.tsx @@ -1584,12 +1584,13 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve } }; - const startThreadRename = (threadRef: ScopedThreadRef, title: string) => { + // The ref write stops the compiler memoizing this, and every row receives it. + const startThreadRename = useStableCallback((threadRef: ScopedThreadRef, title: string) => { if (!readEnvironmentScope(threadRef.environmentId, AuthOrchestrationOperateScope)) return; setRenamingThreadRef(threadRef); setRenamingTitle(title); renamingOriginalTitleRef.current = title; - }; + }); const cancelThreadRename = () => setRenamingThreadRef(null); const commitThreadRename = (threadRef: ScopedThreadRef, title: string) => { const originalTitle = renamingOriginalTitleRef.current; @@ -1619,6 +1620,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve })(); }; + const readOpensPullRequestsInRightPanel = useStableCallback(() => routeThreadRef !== null); const handleThreadClick = (event: ReactMouseEvent, threadRef: ScopedThreadRef) => { if (isSidebarNestedLinkClick(event.target)) return; const isMac = isMacPlatform(navigator.platform); @@ -3490,7 +3492,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve routeRowThreadKey === threadKey ? revealActiveRow : undefined } isRouteThread={routeThreadKey === threadKey} - openPullRequestsInRightPanel={routeThreadRef !== null} + readOpensPullRequestsInRightPanel={readOpensPullRequestsInRightPanel} jumpLabel={ showJumpHints ? (jumpLabelByKey.get(threadKey) ?? null) : null } diff --git a/apps/web/src/components/chat/markdownRenderer.test.tsx b/apps/web/src/components/chat/markdownRenderer.test.tsx index e5ba98d141f82..f15fe49584aea 100644 --- a/apps/web/src/components/chat/markdownRenderer.test.tsx +++ b/apps/web/src/components/chat/markdownRenderer.test.tsx @@ -45,9 +45,10 @@ describe("createMarkdownRenderer", () => { {source} , ); - const element = render(source, true); + const element = render(source); expect(renderToStaticMarkup(element)).toBe(expected); - expect(render(source, true)).toBe(element); + render.remember(source, element); + expect(render(source)).toBe(element); }); it("renders what react-markdown renders while a reply streams through the incremental parser", () => { @@ -62,7 +63,7 @@ describe("createMarkdownRenderer", () => { rehypePlugins: CHAT_MARKDOWN_REHYPE_PLUGINS, components: {}, urlTransform, - })(source, false); + })(source); expect(renderToStaticMarkup(streamed)).toBe( renderToStaticMarkup( { }); it("keeps cached messages when one far larger than the cache is rendered", () => { - const element = render("Kept *message*", true); - render("x".repeat(600_000), true); - expect(render("Kept *message*", true)).toBe(element); + const element = render("Kept *message*"); + render.remember("Kept *message*", element); + const large = "x".repeat(600_000); + render.remember(large, render(large)); + expect(render("Kept *message*")).toBe(element); }); }); diff --git a/apps/web/src/components/chat/markdownRenderer.ts b/apps/web/src/components/chat/markdownRenderer.ts index ab4083f2adf47..9637d68e8f158 100644 --- a/apps/web/src/components/chat/markdownRenderer.ts +++ b/apps/web/src/components/chat/markdownRenderer.ts @@ -82,7 +82,7 @@ export function createMarkdownRenderer({ } }; - return (text: string, cache: boolean): ReactElement => { + const render = (text: string): ReactElement => { const key = keyPrefix + text; const cached = rendered.get(key); if (cached !== undefined) { @@ -94,7 +94,7 @@ export function createMarkdownRenderer({ const file = new VFile(text); const tree = processor.runSync(processor.parse(file), file) as Root; prepare(tree); - const element = toJsxRuntime(tree, { + return toJsxRuntime(tree, { Fragment, components, ignoreInvalidStyle: true, @@ -103,7 +103,12 @@ export function createMarkdownRenderer({ passKeys: true, passNode: true, }); - if (cache) remember(key, element); - return element; }; + + return Object.assign(render, { + remember(text: string, element: ReactElement) { + const key = keyPrefix + text; + if (!rendered.has(key)) remember(key, element); + }, + }); } diff --git a/apps/web/src/components/sidebar/SidebarThreadRow.tsx b/apps/web/src/components/sidebar/SidebarThreadRow.tsx index 5b0e116f27a93..dca248759e920 100644 --- a/apps/web/src/components/sidebar/SidebarThreadRow.tsx +++ b/apps/web/src/components/sidebar/SidebarThreadRow.tsx @@ -612,7 +612,8 @@ type SidebarThreadRowProps = { // Unlike isActive, never true for the ancestor standing in for an open // subagent: drafts and PR clicks care about which composer is on screen. isRouteThread: boolean; - openPullRequestsInRightPanel: boolean; + // Read at click time; a prop would re-render every row on entering or leaving a thread route. + readOpensPullRequestsInRightPanel: () => boolean; jumpLabel: string | null; currentEnvironmentId: string | null; environmentLabel: string | null; @@ -709,7 +710,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP onUnsettle, onUnsnooze, onUnpin, - openPullRequestsInRightPanel, + readOpensPullRequestsInRightPanel, renamingTitle, thread, variant, @@ -1038,7 +1039,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP const handlePrClick = (event: ReactMouseEvent, targetUrl?: string) => { const url = targetUrl ?? pr?.url ?? currentLinkedPr?.url; if (!url) return; - const showInRightPanel = targetUrl !== undefined || openPullRequestsInRightPanel; + const showInRightPanel = targetUrl !== undefined || readOpensPullRequestsInRightPanel(); const openedInRightPanel = openPrLink(event, url, showInRightPanel ? threadRef : undefined); if (openedInRightPanel && showInRightPanel && !props.isRouteThread) { onThreadActivate(threadRef); diff --git a/apps/web/test/appScenarios.renders.tsx b/apps/web/test/appScenarios.renders.tsx index b3dad1041d7fe..8b3c8c473559f 100644 --- a/apps/web/test/appScenarios.renders.tsx +++ b/apps/web/test/appScenarios.renders.tsx @@ -3,7 +3,7 @@ // chat and settings routes, the sidebar and the right panel, through the same stores and // atoms the app reads. See renderScenarios.renders.tsx for the counting rules. import { createMemoryHistory } from "@tanstack/react-router"; -import { scopeThreadRef } from "@t3tools/client-runtime/environment"; +import { scopeProjectRef, scopeThreadRef } from "@t3tools/client-runtime/environment"; import type { ThreadId } from "@t3tools/contracts"; import { DEFAULT_CLIENT_SETTINGS } from "@t3tools/contracts/settings"; import type * as Context from "effect/Context"; @@ -14,6 +14,7 @@ import { commands, page, userEvent } from "vite-plus/test/browser"; import "~/index.css"; import { AppRoot } from "~/AppRoot"; +import { DraftId, useComposerDraftStore } from "~/composerDraftStore"; import { __setClientSettingsForTests } from "~/hooks/useSettings"; import { useRightPanelStore } from "~/rightPanelStore"; import { getRouter, type AppRouter } from "~/router"; @@ -21,6 +22,7 @@ import { appAtomRegistry } from "~/rpc/atomRegistry"; import { vcsEnvironment } from "~/state/vcs"; import { ENVIRONMENT_ID, + PROJECT_ID, assistantItem, emitTerminalMetadata, emitThreadEvent, @@ -120,6 +122,16 @@ async function openThread(threadId: ThreadId) { return app; } +const goToThread = (router: AppRouter, threadId: ThreadId) => async () => { + await act(() => + router.navigate({ + to: "/$environmentId/$threadId", + params: { environmentId: ENVIRONMENT_ID, threadId }, + }), + ); + await expect.element(lastAnswer(threadId)).toBeVisible(); +}; + async function measure(action: () => Promise): Promise { await quiet(); startCounting(); @@ -269,21 +281,29 @@ it("app-switch-thread", async () => { using _clock = frozenClock(); const { screen, router } = await openThread(A); await using _app = screen; - const go = (threadId: ThreadId) => async () => { - await act(() => - router.navigate({ - to: "/$environmentId/$threadId", - params: { environmentId: ENVIRONMENT_ID, threadId }, - }), - ); - await expect.element(lastAnswer(threadId)).toBeVisible(); - }; - const windows = [await measure(go(B)), await measure(go(A))]; + const windows = [await measure(goToThread(router, B)), await measure(goToThread(router, A))]; // Only the rows losing and gaining the active highlight change. for (const window of windows) expect(window.components.SidebarThreadRow).toBe(2); await report("app-switch-thread", windows); }); +// A row reads whether a thread is open only when its PR badge is clicked, so opening a thread +// from a draft changes only the row that gains the highlight. +it("app-open-thread-from-draft", async () => { + using _clock = frozenClock(); + const drafts = useComposerDraftStore.getState(); + const draftId = DraftId.make("draft-render"); + drafts.setProjectDraftThreadId(scopeProjectRef(ENVIRONMENT_ID, PROJECT_ID), draftId); + using _draft = { [Symbol.dispose]: () => drafts.clearDraftThread(draftId) }; + const { screen, router } = await mountApp(`/draft/${draftId}`); + await using _app = screen; + // The sidebar lists the project once the shell snapshot has arrived. + await expect.element(page.getByText("render", { exact: true }).first()).toBeVisible(); + const counted = await measure(goToThread(router, A)); + expect(counted.components.SidebarThreadRow).toBe(1); + await report("app-open-thread-from-draft", [counted], { commits: false }); +}); + // Through the diff.toggle shortcut, the same handler as the header's diff button. const toggleDiff = (to: "open" | "close") => async () => { await userEvent.keyboard("{Control>}d{/Control}"); From ff740f3fa5f6992f40ce6dfccd4bfc1820b4a5cc Mon Sep 17 00:00:00 2001 From: seancarnahan Date: Sat, 14 Nov 2026 22:27:23 -0800 Subject: [PATCH 5/5] test(web): ACP project picker test waits for the popup to take focus (#33061) Co-authored-by: Julius Marminge (cherry picked from commit 294a8418ce82b8f656b864178a5e11a81cbc50ff) Co-Authored-By: Claude Opus 5.5 --- .../settings/AcpSessionManagementSection.browser.test.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/web/src/components/settings/AcpSessionManagementSection.browser.test.tsx b/apps/web/src/components/settings/AcpSessionManagementSection.browser.test.tsx index 824d4a28f99a1..5277c93f491d5 100644 --- a/apps/web/src/components/settings/AcpSessionManagementSection.browser.test.tsx +++ b/apps/web/src/components/settings/AcpSessionManagementSection.browser.test.tsx @@ -282,8 +282,11 @@ it.each([true, false])( }); await using screen = await renderSection({ canList, projects: [project, second] }); await screen.getByRole("combobox").click(); - if (canList) await userEvent.keyboard("{ArrowDown}{Enter}"); - else await screen.getByRole("option", { name: "Second", exact: true }).click(); + if (canList) { + // Keys sent before the popup takes focus only move focus onto the selected option. + await expect.element(screen.getByRole("option", { name: "Antigravity" })).toHaveFocus(); + await userEvent.keyboard("{ArrowDown}{Enter}"); + } else await screen.getByRole("option", { name: "Second", exact: true }).click(); await expect .element( screen.getByRole("combobox", {