@devries-cameron20 / t3code-1 / commits / 725cfc9c3d
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(threads): side chats inherit parent permissions by default (#31114)

Exotic committed Nov 5, 2026 at 19:40 UTC 725cfc9c3d9182075af602056746c319b5eb47e0
7 files changed +71 -25
apps/server/src/orchestration-v2/ProviderTurnStartService.test.ts
+12 -6
@@ -302,6 +302,7 @@ function makeLocalCommandHarness(input: {
302 readonly contextRun: "current" | "failed" | "cancelled" | "delivered";
303 readonly nativeForkFrom?: "idle" | "busy";
304 readonly switchedProvider?: boolean;
305 + readonly threadRuntimeMode?: OrchestrationV2ThreadProjection["thread"]["runtimeMode"];
306 };
307 }) {
308 const settledRuns: Array<string> = [];
@@ -566,7 +567,7 @@ function makeLocalCommandHarness(input: {
567 ...projection,
568 thread: {
569 ...projection.thread,
569 - runtimeMode: "full-access",
570 + runtimeMode: input.sideChat.threadRuntimeMode ?? "full-access",
571 lineage: {
572 parentThreadId,
573 relationshipToParent: "fork",
@@ -1260,16 +1261,22 @@ effectIt.effect("recovers an abandoned failed turn before continuing its native
1261 );
1262
1263 effectIt.effect.each([
1263 - { contextRun: "current", runtimeMode: "approval-required", context: "SIDE_CHAT_CONTEXT" },
1264 - { contextRun: "failed", runtimeMode: "approval-required", context: "SIDE_CHAT_CONTEXT" },
1265 - { contextRun: "cancelled", runtimeMode: "approval-required", context: "SIDE_CHAT_CONTEXT" },
1264 + { contextRun: "current", runtimeMode: "full-access", context: "SIDE_CHAT_CONTEXT" },
1265 + { contextRun: "failed", runtimeMode: "full-access", context: "SIDE_CHAT_CONTEXT" },
1266 + { contextRun: "cancelled", runtimeMode: "full-access", context: "SIDE_CHAT_CONTEXT" },
1267 {
1268 contextRun: "failed",
1269 switchedProvider: true,
1269 - runtimeMode: "approval-required",
1270 + runtimeMode: "full-access",
1271 context: "SIDE_CHAT_CONTEXT",
1272 },
1273 { contextRun: "delivered", runtimeMode: "full-access", context: "" },
1274 + {
1275 + contextRun: "current",
1276 + threadRuntimeMode: "approval-required",
1277 + runtimeMode: "approval-required",
1278 + context: "SIDE_CHAT_CONTEXT",
1279 + },
1280 ] as const)(
1281 "sends side chat context inline once, for the first turn that reaches the provider: %j",
1282 ({ runtimeMode, context, ...sideChat }) =>
@@ -1281,7 +1288,6 @@ effectIt.effect.each([
1288
1289 yield* harness.start;
1290
1284 - // The turn that delivers the context is clamped; a later one follows the thread's mode.
1291 expect(harness.open).toHaveBeenCalledWith(
1292 expect.objectContaining({ runtimePolicy: expect.objectContaining({ runtimeMode }) }),
1293 );
apps/server/src/orchestration-v2/ProviderTurnStartService.ts
+1 -7
@@ -699,15 +699,9 @@ export const layer: Layer.Layer<
699 });
700 const { isCurrentAttemptInStatus } = runControls;
701
702 - // A side chat shares its parent's worktree; the turn that gets its context asks before acting.
702 const resolvedPolicy = yield* runtimePolicy
703 .resolve({
705 - thread:
706 - projection.thread.lineage.sideChat === true &&
707 - (sideChatHandoff !== undefined ||
708 - !projection.runs.some((previous) => previous.ordinal < run.ordinal))
709 - ? { ...projection.thread, runtimeMode: "approval-required" }
710 - : projection.thread,
704 + thread: projection.thread,
705 modelSelection: run.modelSelection,
706 })
707 .pipe(Effect.result);
apps/server/src/orchestration-v2/ThreadFork.execution.test.ts
+26 -1
@@ -959,12 +959,37 @@ it.effect("a side chat of an idle parent still starts with the framing note", ()
959 query.includes("FROM orchestration_v2_projection_context_transfers"),
960 ),
961 );
962 + assert.equal(
963 + (yield* orchestrator.getThreadProjection(sideChatId)).thread.runtimeMode,
964 + "full-access",
965 + );
966 + yield* orchestrator.dispatch({
967 + type: "thread.runtime-mode.set",
968 + commandId: CommandId.make("side-chat-parent-mode-change"),
969 + threadId: parentId,
970 + runtimeMode: "approval-required",
971 + });
972 + assert.equal(
973 + (yield* orchestrator.getThreadProjection(sideChatId)).thread.runtimeMode,
974 + "full-access",
975 + );
976 + yield* orchestrator.dispatch({
977 + type: "thread.runtime-mode.set",
978 + commandId: CommandId.make("side-chat-child-mode-change"),
979 + threadId: sideChatId,
980 + runtimeMode: "auto",
981 + });
982 yield* askSideChat(sideChatId, "side-chat-idle-first-message", {
983 ...forkCases[0]!.modelSelection,
984 model: "side-chat-model",
985 });
986
987 const started = yield* orchestrator.getThreadProjection(sideChatId);
988 + assert.equal(started.thread.runtimeMode, "auto");
989 + assert.equal(
990 + (yield* orchestrator.getThreadProjection(parentId)).thread.runtimeMode,
991 + "approval-required",
992 + );
993 assert.isNotNull(started.providerThreads[0]?.forkedFrom);
994 // The side chat does not show the parent's run, so it is no baseline.
995 assert.isFalse(
@@ -1110,7 +1135,7 @@ it.effect("a side chat opened during the parent's first turn starts from a diges
1135 yield* fork("side-chat-busy-fork", parentId, sideChatId);
1136 const created = yield* orchestrator.getThreadProjection(sideChatId);
1137 assert.isTrue(created.thread.lineage.sideChat);
1113 - assert.equal(created.thread.runtimeMode, "approval-required");
1138 + assert.equal(created.thread.runtimeMode, "full-access");
1139 assert.isNull(created.thread.forkedFrom);
1140 assert.deepEqual(created.contextTransfers[0]?.sourcePoint, { threadId: parentId });
1141
apps/server/src/orchestration-v2/ThreadForkService.test.ts
+19 -2
@@ -293,14 +293,31 @@ it.effect("rejects in-progress and rolled-back fork sources", () =>
293 }),
294 );
295
296 -it.effect("marks only requested forks as supervised side chats", () =>
296 +it.effect("marks only requested forks as side chats and inherits parent permissions", () =>
297 Effect.gen(function* () {
298 const sourceRun = makeSourceRun("completed");
299 const sideChat = yield* planFork(sourceRun, makeSourceProjection(sourceRun), {
300 sideChat: true,
301 });
302 assert.isTrue(sideChat.targetThread.lineage.sideChat);
303 - assert.equal(sideChat.targetThread.runtimeMode, "approval-required");
303 + assert.equal(sideChat.targetThread.runtimeMode, "full-access");
304 + for (const runtimeMode of [
305 + "approval-required",
306 + "auto-accept-edits",
307 + "auto",
308 + "full-access",
309 + ] as const) {
310 + const source = makeSourceProjection(sourceRun);
311 + const inherited = yield* planFork(
312 + sourceRun,
313 + {
314 + ...source,
315 + thread: { ...source.thread, runtimeMode },
316 + },
317 + { sideChat: true },
318 + );
319 + assert.equal(inherited.targetThread.runtimeMode, runtimeMode);
320 + }
321
322 const sideChatSource = makeSourceProjection(sourceRun);
323 const sideChatProjection = {
apps/server/src/orchestration-v2/ThreadForkService.ts
-2
@@ -113,8 +113,6 @@ export const layer: Layer.Layer<ThreadForkServiceV2> = Layer.succeed(
113 title: input.title ?? `${input.sourceProjection.thread.title} fork`,
114 // The source's title job completes only on the source thread.
115 titleRegeneration: null,
116 - // Side chats share the parent's worktree, so they start supervised.
117 - ...(input.sideChat ? { runtimeMode: "approval-required" as const } : {}),
116 activeProviderThreadId: null,
117 lineage: {
118 parentThreadId: input.sourceProjection.thread.id,
apps/web/src/components/chat/useSideChat.ts
+10 -4
@@ -11,7 +11,7 @@ import { useRef } from "react";
11 import { newMessageId, newThreadId } from "~/lib/utils";
12 import { useStableCallback } from "../../hooks/useStableCallback";
13 import { useRightPanelStore } from "../../rightPanelStore";
14 -import { waitForThreadShell } from "../../state/entities";
14 +import { readThreadShell, waitForThreadShell } from "../../state/entities";
15 import { threadEnvironment } from "../../state/threads";
16 import { useAtomCommand } from "../../state/use-atom-command";
17 import { useOrchestrationCommand } from "../../state/use-orchestration-command";
@@ -55,22 +55,28 @@ export function useSideChat(input: {
55 environmentId: threadRef.environmentId,
56 input: { threadId: targetThreadId, onlyIfUnused: true },
57 });
58 - if (!(await waitForThreadShell(scopeThreadRef(threadRef.environmentId, targetThreadId)))) {
58 + const targetRef = scopeThreadRef(threadRef.environmentId, targetThreadId);
59 + if (!(await waitForThreadShell(targetRef))) {
60 input.onError("The side chat was created, but it did not reach this client.");
61 discard();
62 return false;
63 }
64 + const sideChat = readThreadShell(targetRef);
65 + if (sideChat === null) {
66 + input.onError("The side chat is no longer available.");
67 + discard();
68 + return false;
69 + }
70 const text = prompt?.trim();
71 // Send before showing the tab: closing a tab whose side chat has no run deletes it.
72 if (text) {
66 - // The server asks before edits on a side chat's first turn whatever mode is sent.
73 const turn = await startThreadTurn({
74 environmentId: threadRef.environmentId,
75 input: {
76 threadId: targetThreadId,
77 message: { messageId: newMessageId(), role: "user", text, attachments: [] },
78 titleSeed: deriveThreadTitleSeed({ text, attachments: [] }),
73 - runtimeMode: "approval-required",
79 + runtimeMode: sideChat.runtimeMode,
80 interactionMode: "default",
81 createdAt: new Date().toISOString(),
82 },
docs/user/thread-sidebar.md
+3 -3
@@ -300,9 +300,9 @@ You can also choose **Side chat** from the **+** menu in the right panel. The si
300 chat opens as a tab there, with its own composer. Side chats do not show in the
301 sidebar. Find one again under **Side chats** in thread details.
302
303 -A side chat works in the same folder as the thread. Its first reply asks before it
304 -edits files or runs commands. After that, it uses the permission mode you choose
305 -in its composer.
303 +A side chat works in the same folder as the thread and inherits its permissions
304 +when created, including for its first reply. Change permissions for an individual
305 +side chat in its composer. Later changes to the parent do not change existing side chats.
306
307 To use what you learned, choose **Bring back**. The thread gets the side chat with
308 your next message there. Bring back is available while the thread is idle.