The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 04:30 UTC
test(web): linked-environment subagents keep opening in their own thread (#26492)
Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>
Sebastian Pugliese committed
Nov 5, 2026 at 21:19 UTC
bf5485c2e9e69adff803b20725df60a94f5f4aea
1 file changed
+41
-1
apps/web/src/components/chat/useThreadLifecycle.browser.test.tsx
+41
-1
@@ -1,10 +1,12 @@
1
import * as Cause from "effect/Cause";
2
import { scopedThreadKey, scopeThreadRef } from "@t3tools/client-runtime/environment";
3
+import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
4
import { EnvironmentId, ThreadId } from "@t3tools/contracts";
5
import { expect, it, vi } from "vite-plus/test";
6
import { page } from "vite-plus/test/browser";
7
8
const state = vi.hoisted(() => ({
9
+ childThreadInputs: [] as EnvironmentThreadShell[],
10
switchRef: (async () => undefined) as (input: unknown) => Promise<unknown>,
11
}));
12
@@ -32,7 +34,7 @@ vi.mock(import("../../hooks/useThreadActions"), async (importOriginal) => ({
34
35
vi.mock(import("../../state/entities"), async (importOriginal) => ({
36
...(await importOriginal()),
35
- useChildThreadInputs: (() => []) as never,
37
+ useChildThreadInputs: (() => state.childThreadInputs) as never,
38
}));
39
40
import { render } from "../../../test/render";
@@ -41,6 +43,7 @@ import { useThreadLifecycle } from "./useThreadLifecycle";
43
const environmentId = EnvironmentId.make("environment:test");
44
45
function setup() {
46
+ state.childThreadInputs = [];
47
state.switchRef = async () => undefined;
48
}
49
@@ -60,6 +63,41 @@ function threadInput(threadId: string, branch: string) {
63
64
type ThreadInput = ReturnType<typeof threadInput>;
65
66
+it.each([
67
+ { remote: false, approval: false, link: "Open question" },
68
+ { remote: true, approval: false, link: "Open question" },
69
+ { remote: true, approval: false, link: "Child" },
70
+ { remote: true, approval: true, link: "Open approval" },
71
+])("opens the child in its environment ($remote, $link)", async ({ remote, approval, link }) => {
72
+ setup();
73
+ const parent = threadInput("parent", "main");
74
+ const childEnvironmentId = remote ? EnvironmentId.make("remote") : environmentId;
75
+ state.childThreadInputs = [
76
+ {
77
+ id: ThreadId.make("child"),
78
+ environmentId: childEnvironmentId,
79
+ title: "Child",
80
+ hasPendingApprovals: approval,
81
+ lineage: { sideChat: false },
82
+ } as EnvironmentThreadShell,
83
+ ];
84
+ await using screen = await render(
85
+ <RestoreBranchHarness
86
+ thread={parent}
87
+ currentRouteThreadKeyRef={{ current: parent.routeThreadKey }}
88
+ refreshGitStatus={() => undefined}
89
+ focusComposer={() => undefined}
90
+ />,
91
+ { router: "/environment:test/parent" },
92
+ );
93
+ await screen.getByRole("button", { name: link, exact: true }).click();
94
+ await vi.waitFor(() =>
95
+ expect(screen.router?.state.location.pathname).toBe(
96
+ `/${encodeURIComponent(childEnvironmentId)}/child`,
97
+ ),
98
+ );
99
+});
100
+
101
function RestoreBranchHarness(props: {
102
readonly thread: ThreadInput;
103
readonly currentRouteThreadKeyRef: { readonly current: string | null };
@@ -97,6 +135,8 @@ function RestoreBranchHarness(props: {
135
});
136
return (
137
<>
138
+ {lifecycle.childInputNow?.description}
139
+ {lifecycle.childInputNow?.actions}
140
{lifecycle.workNow?.actions}
141
<button
142
type="button"