The best way to control Claude Code, Codex and more from any computer or phone
fix(web): a side chat's subagent opens its parent as a side chat tab, not a bare page (#32907)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Andrei committed
Nov 15, 2026 at 14:59 UTC
4fa5f0e0e64f782b6efe52e1aa0043e7ad147128
5 files changed
+60
-18
apps/web/src/components/ChatView.tsx
+8
-2
@@ -208,7 +208,11 @@ import { COLLAPSED_SIDEBAR_TITLEBAR_INSET_CLASS } from "~/workspaceTitlebar";
208
import { toastManager } from "./ui/toast";
209
import { projectScriptIdFromCommand } from "~/projectScripts";
210
import { newMessageId } from "~/lib/utils";
211
-import { isInSideChatPane, type SideChatParentPanel } from "~/lib/sideChatPane";
211
+import {
212
+ isInSideChatPane,
213
+ resolveThreadOpenRoute,
214
+ type SideChatParentPanel,
215
+} from "~/lib/sideChatPane";
216
import {
217
NO_PROVIDER_MODEL_SELECTION,
218
providerInstanceEntriesFor,
@@ -928,7 +932,9 @@ export default function ChatView(props: ChatViewProps) {
932
open: (): void => {
933
void navigate({
934
to: "/$environmentId/$threadId",
931
- params: buildThreadRouteParams(parentSubagentThreadRef),
935
+ params: buildThreadRouteParams(
936
+ resolveThreadOpenRoute(parentSubagentThreadRef, parentSubagentThread),
937
+ ),
938
});
939
},
940
};
apps/web/src/components/chat/ThreadRelationshipsControl.tsx
+7
-3
@@ -82,7 +82,7 @@ import { useEnvironmentQuery } from "../../state/query";
82
import { AgentElapsed } from "./AgentElapsed";
83
import { ThreadRelationshipIcon, threadRelationshipStatusLabel } from "./ThreadRelationshipIcon";
84
import { ThreadLineageWorkflowRow } from "./ThreadLineageWorkflowRow";
85
-import { openSideChatTab } from "../../lib/sideChatPane";
85
+import { resolveThreadOpenRoute } from "../../lib/sideChatPane";
86
87
import { Menu, MenuItem, MenuPopup, MenuTrigger } from "../ui/menu";
88
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
@@ -638,10 +638,14 @@ export function ThreadRelationshipsPanel(props: {
638
639
// Idle children can be omitted from the shell; opening one loads its own detail.
640
const openThread = (threadId: ThreadId) => {
641
- if (openSideChatTab(ref, graph.nodes.get(threadId)?.thread ?? null)) return;
641
+ const routeRef = resolveThreadOpenRoute(
642
+ scopeThreadRef(props.environmentId, threadId),
643
+ graph.nodes.get(threadId)?.thread ?? null,
644
+ );
645
+ if (routeRef.threadId === ref.threadId) return;
646
void navigate({
647
to: "/$environmentId/$threadId",
644
- params: buildThreadRouteParams(scopeThreadRef(props.environmentId, threadId)),
648
+ params: buildThreadRouteParams(routeRef),
649
});
650
};
651
apps/web/src/components/chat/useThreadLifecycle.tsx
+4
-3
@@ -76,7 +76,7 @@ import { useAtomValue } from "@effect/atom-react";
76
import type { RunStopPresentation } from "@t3tools/client-runtime/state/thread-execution";
77
import { Atom } from "effect/reactivity";
78
import { environmentThreadDetails } from "../../state/threads";
79
-import { openSideChatTab } from "../../lib/sideChatPane";
79
+import { resolveThreadOpenRoute } from "../../lib/sideChatPane";
80
import type { useLocalDispatchState } from "./useLocalDispatchState";
81
const RELATED_THREAD_SHELL_WAIT_MS = 1_000;
82
const NO_RUN_STOP_ATOM = Atom.make<RunStopPresentation | null>(null).pipe(
@@ -495,10 +495,11 @@ export function useThreadLifecycle(input: ThreadLifecycleInput) {
495
toastManager.add({ type: "info", title: "This thread is no longer available" });
496
return;
497
}
498
- if (activeThreadRef && openSideChatTab(activeThreadRef, shell)) return;
498
+ const routeRef = resolveThreadOpenRoute(threadRef, shell);
499
+ if (scopedThreadKey(routeRef) === routeThreadKey) return;
500
void navigate({
501
to: "/$environmentId/$threadId",
501
- params: buildThreadRouteParams(threadRef),
502
+ params: buildThreadRouteParams(routeRef),
503
});
504
};
505
const onOpenRelatedThreadStable = useStableCallback(onOpenRelatedThread);
apps/web/src/lib/sideChatPane.test.ts
new
+27
@@ -0,0 +1,27 @@
1
+import { scopeThreadRef } from "@t3tools/client-runtime/environment";
2
+import { EnvironmentId, ThreadId } from "@t3tools/contracts";
3
+import { expect, it } from "vite-plus/test";
4
+
5
+import { selectActiveRightPanelSurface, useRightPanelStore } from "../rightPanelStore";
6
+import { resolveThreadOpenRoute } from "./sideChatPane";
7
+
8
+const environmentId = EnvironmentId.make("environment:test");
9
+const mainRef = scopeThreadRef(environmentId, ThreadId.make("main"));
10
+const sideChatRef = scopeThreadRef(environmentId, ThreadId.make("side-chat"));
11
+
12
+it("routes a side chat to its parent with the side chat tab active", () => {
13
+ useRightPanelStore.setState(useRightPanelStore.getInitialState());
14
+ const route = resolveThreadOpenRoute(sideChatRef, {
15
+ lineage: { sideChat: true, parentThreadId: mainRef.threadId } as never,
16
+ });
17
+
18
+ expect(route).toEqual(mainRef);
19
+ expect(
20
+ selectActiveRightPanelSurface(useRightPanelStore.getState().byThreadKey, mainRef)?.id,
21
+ ).toBe("side-chat:side-chat");
22
+ expect(
23
+ resolveThreadOpenRoute(mainRef, {
24
+ lineage: { sideChat: false, parentThreadId: null } as never,
25
+ }),
26
+ ).toBe(mainRef);
27
+});
apps/web/src/lib/sideChatPane.ts
+14
-10
@@ -1,3 +1,4 @@
1
+import { scopeThreadRef } from "@t3tools/client-runtime/environment";
2
import type { OrchestrationV2ThreadShell, ScopedThreadRef } from "@t3tools/contracts";
3
4
import type { ToolCallDiffTarget } from "../diffPanelStore";
@@ -18,14 +19,17 @@ export interface SideChatParentPanel {
19
readonly runShellCommand: (command: string) => void;
20
}
21
21
-/** Opens `thread` in its tab when it is a side chat of `parentRef`; false for any other thread. */
22
-export function openSideChatTab(
23
- parentRef: ScopedThreadRef,
24
- thread: Pick<OrchestrationV2ThreadShell, "id" | "lineage"> | null,
25
-): boolean {
26
- if (thread?.lineage.sideChat !== true || thread.lineage.parentThreadId !== parentRef.threadId) {
27
- return false;
28
- }
29
- useRightPanelStore.getState().openSideChat(parentRef, thread.id);
30
- return true;
22
+/**
23
+ * Where opening `threadRef` should route. A side chat shows as a tab of its parent, so this opens
24
+ * that tab and returns the parent; any other thread returns `threadRef`.
25
+ */
26
+export function resolveThreadOpenRoute(
27
+ threadRef: ScopedThreadRef,
28
+ thread: Pick<OrchestrationV2ThreadShell, "lineage"> | null,
29
+): ScopedThreadRef {
30
+ const parentThreadId = thread?.lineage.sideChat === true ? thread.lineage.parentThreadId : null;
31
+ if (parentThreadId === null) return threadRef;
32
+ const parentRef = scopeThreadRef(threadRef.environmentId, parentThreadId);
33
+ useRightPanelStore.getState().openSideChat(parentRef, threadRef.threadId);
34
+ return parentRef;
35
}