The best way to control Claude Code, Codex and more from any computer or phone
Propagate runtime approval and sandbox settings to turn startup
- Add `approvalPolicy` and `sandboxMode` to turn-start command and requested payload contracts - Pass runtime mode-derived values from `ChatView` when dispatching `thread.turn.start` - Thread provider options through decider/reactor into session startup, with tests updated
Julius Marminge committed
Feb 26, 2026 at 18:39 UTC
57dd091e05904dfe07721254863249305932c0b1
6 files changed
+43
-1
apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts
+4
@@ -171,6 +171,8 @@ describe("ProviderCommandReactor", () => {
171
text: "hello reactor",
172
attachments: [],
173
},
174
+ approvalPolicy: "on-request",
175
+ sandboxMode: "workspace-write",
176
createdAt: now,
177
}),
178
);
@@ -181,6 +183,8 @@ describe("ProviderCommandReactor", () => {
183
expect(harness.startSession.mock.calls[0]?.[1]).toMatchObject({
184
cwd: "/tmp/provider-project",
185
model: "gpt-5-codex",
186
+ approvalPolicy: "on-request",
187
+ sandboxMode: "workspace-write",
188
});
189
190
const readModel = await Effect.runPromise(harness.engine.getReadModel());
apps/server/src/orchestration/Layers/ProviderCommandReactor.ts
+16
-1
@@ -3,7 +3,9 @@ import {
3
CommandId,
4
EventId,
5
type OrchestrationEvent,
6
+ type ProviderApprovalPolicy,
7
type ProviderKind,
8
+ type ProviderSandboxMode,
9
type OrchestrationSession,
10
type ThreadId,
11
type TurnId,
@@ -128,6 +130,10 @@ const make = Effect.gen(function* () {
130
const ensureSessionForThread = Effect.fnUntraced(function* (
131
threadId: ThreadId,
132
createdAt: string,
133
+ options?: {
134
+ readonly approvalPolicy?: ProviderApprovalPolicy;
135
+ readonly sandboxMode?: ProviderSandboxMode;
136
+ },
137
) {
138
const readModel = yield* orchestrationEngine.getReadModel();
139
const thread = readModel.threads.find((entry) => entry.id === threadId);
@@ -153,6 +159,8 @@ const make = Effect.gen(function* () {
159
...(preferredProvider ? { provider: preferredProvider } : {}),
160
...(effectiveCwd ? { cwd: effectiveCwd } : {}),
161
...(thread.model ? { model: thread.model } : {}),
162
+ ...(options?.approvalPolicy !== undefined ? { approvalPolicy: options.approvalPolicy } : {}),
163
+ ...(options?.sandboxMode !== undefined ? { sandboxMode: options.sandboxMode } : {}),
164
});
165
166
yield* setThreadSession({
@@ -180,13 +188,18 @@ const make = Effect.gen(function* () {
188
readonly attachments?: ReadonlyArray<ChatAttachment>;
189
readonly model?: string;
190
readonly effort?: string;
191
+ readonly approvalPolicy?: ProviderApprovalPolicy;
192
+ readonly sandboxMode?: ProviderSandboxMode;
193
readonly createdAt: string;
194
}) {
195
const thread = yield* resolveThread(input.threadId);
196
if (!thread) {
197
return;
198
}
189
- const sessionId = yield* ensureSessionForThread(input.threadId, input.createdAt);
199
+ const sessionId = yield* ensureSessionForThread(input.threadId, input.createdAt, {
200
+ ...(input.approvalPolicy !== undefined ? { approvalPolicy: input.approvalPolicy } : {}),
201
+ ...(input.sandboxMode !== undefined ? { sandboxMode: input.sandboxMode } : {}),
202
+ });
203
const normalizedInput = toNonEmptyProviderInput(input.messageText);
204
const normalizedAttachments = input.attachments ?? [];
205
@@ -232,6 +245,8 @@ const make = Effect.gen(function* () {
245
...(event.payload.model !== undefined ? { model: event.payload.model } : {}),
246
...(event.payload.effort !== undefined ? { effort: event.payload.effort } : {}),
247
createdAt: event.payload.createdAt,
248
+ approvalPolicy: event.payload.approvalPolicy,
249
+ sandboxMode: event.payload.sandboxMode,
250
});
251
});
252
apps/server/src/orchestration/decider.projectScripts.test.ts
+10
@@ -152,6 +152,8 @@ describe("decider project scripts", () => {
152
},
153
model: "gpt-5",
154
effort: "high",
155
+ approvalPolicy: "on-request",
156
+ sandboxMode: "workspace-write",
157
createdAt: now,
158
},
159
readModel,
@@ -169,5 +171,13 @@ describe("decider project scripts", () => {
171
return;
172
}
173
expect(turnStartEvent.payload.assistantDeliveryMode).toBe("buffered");
174
+ expect(turnStartEvent.payload).toMatchObject({
175
+ threadId: ThreadId.makeUnsafe("thread-1"),
176
+ messageId: asMessageId("message-user-1"),
177
+ model: "gpt-5",
178
+ effort: "high",
179
+ approvalPolicy: "on-request",
180
+ sandboxMode: "workspace-write",
181
+ });
182
});
183
});
apps/server/src/orchestration/decider.ts
+4
@@ -254,6 +254,10 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
254
...(command.model !== undefined ? { model: command.model } : {}),
255
...(command.effort !== undefined ? { effort: command.effort } : {}),
256
assistantDeliveryMode: command.assistantDeliveryMode ?? DEFAULT_ASSISTANT_DELIVERY_MODE,
257
+ ...(command.approvalPolicy !== undefined
258
+ ? { approvalPolicy: command.approvalPolicy }
259
+ : {}),
260
+ ...(command.sandboxMode !== undefined ? { sandboxMode: command.sandboxMode } : {}),
261
createdAt: command.createdAt,
262
},
263
};
apps/web/src/components/ChatView.tsx
+5
@@ -1522,6 +1522,9 @@ export default function ChatView({ threadId }: ChatViewProps) {
1522
),
1523
);
1524
attemptedTurnStart = true;
1525
+ const approvalPolicy = state.runtimeMode === "full-access" ? "never" : "on-request";
1526
+ const sandboxMode =
1527
+ state.runtimeMode === "full-access" ? "danger-full-access" : "workspace-write";
1528
await api.orchestration.dispatchCommand({
1529
type: "thread.turn.start",
1530
commandId: newCommandId(),
@@ -1535,6 +1538,8 @@ export default function ChatView({ threadId }: ChatViewProps) {
1538
model: selectedModel || undefined,
1539
effort: selectedEffort || undefined,
1540
assistantDeliveryMode: settings.enableAssistantStreaming ? "streaming" : "buffered",
1541
+ approvalPolicy,
1542
+ sandboxMode,
1543
createdAt: messageCreatedAt,
1544
});
1545
} catch (err) {
packages/contracts/src/orchestration.ts
+4
@@ -282,6 +282,8 @@ export const ThreadTurnStartCommand = Schema.Struct({
282
model: Schema.optional(TrimmedNonEmptyString),
283
effort: Schema.optional(TrimmedNonEmptyString),
284
assistantDeliveryMode: Schema.optional(AssistantDeliveryMode),
285
+ approvalPolicy: Schema.optional(ProviderApprovalPolicy),
286
+ sandboxMode: Schema.optional(ProviderSandboxMode),
287
createdAt: IsoDateTime,
288
});
289
@@ -496,6 +498,8 @@ export const ThreadTurnStartRequestedPayload = Schema.Struct({
498
model: Schema.optional(TrimmedNonEmptyString),
499
effort: Schema.optional(TrimmedNonEmptyString),
500
assistantDeliveryMode: Schema.optional(AssistantDeliveryMode),
501
+ approvalPolicy: Schema.optional(ProviderApprovalPolicy),
502
+ sandboxMode: Schema.optional(ProviderSandboxMode),
503
createdAt: IsoDateTime,
504
});
505