Skip to content

Commit 75d9034

Browse files
refactor(mobile): drop server queue pick now covered on main, trim tests
Main's queue-tail model selection (#33591) already gives an unpicked queued message the model picked ahead of it, for every sender, so the orchestrator hunk and its integration test are redundant. The composer keeps main's unavailable-model check, since the send button already gates on the shown model; only the enqueued payload changes. Tests fold the picked round trip into the existing one and assert that a delivered pick releases the draft's pick. AI-assisted; verified with the tests and tools listed above. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 36bf904 commit 75d9034

5 files changed

Lines changed: 8 additions & 243 deletions

File tree

‎apps/mobile/src/state/thread-outbox.test.ts‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,10 @@ function queuedMessage(input: {
112112
}
113113

114114
describe("thread outbox", () => {
115-
it("retains structured context through a persisted offline queue round trip", () => {
115+
it("retains structured context and a model pick through a persisted offline queue round trip", () => {
116116
const message: QueuedThreadMessage = {
117117
...queuedMessage({ messageId: "context-message", createdAt: "2026-09-06T12:00:00.000Z" }),
118+
modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.6-sol" },
118119
text: "[Build](t3-context://v1/terminal/build-output)",
119120
context: {
120121
version: 1,
@@ -137,16 +138,6 @@ describe("thread outbox", () => {
137138
decodeQueuedThreadMessage(JSON.parse(JSON.stringify(encodeQueuedThreadMessage(message)))),
138139
).toEqual(message);
139140
});
140-
it("keeps a picked follow-up model through a persisted round trip", () => {
141-
const message: QueuedThreadMessage = {
142-
...queuedMessage({ messageId: "picked-model", createdAt: "2026-10-23T23:00:00.000Z" }),
143-
modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.6-sol" },
144-
};
145-
146-
expect(
147-
decodeQueuedThreadMessage(JSON.parse(JSON.stringify(encodeQueuedThreadMessage(message)))),
148-
).toEqual(message);
149-
});
150141

151142
it("drops the model an older build stored on a follow-up, so the server keeps the thread's own", () => {
152143
const stale = { instanceId: "claudeAgent", model: "claude-opus-5-5" };

‎apps/mobile/src/state/thread-task-permissions.test.ts‎

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -507,43 +507,9 @@ describe("mobile task permissions", () => {
507507
});
508508

509509
describe("queued follow-up model", () => {
510-
it("queues an unpicked follow-up despite an unavailable cached thread model", async () => {
511-
state.grantedEnvironments.add("secondary");
512-
state.serverConfig = {
513-
...state.serverConfig,
514-
providers: [{ instanceId: "codex", driver: "codex", enabled: false }],
515-
} as unknown as ServerConfig;
516-
517-
expect(await useThreadComposerState().onSendMessage()).toBe("message");
518-
519-
expect(state.enqueue).toHaveBeenCalledExactlyOnceWith(
520-
expect.objectContaining({ text: "Keep my draft", threadId: "thread" }),
521-
);
522-
const [queued] = state.enqueue.mock.calls[0] as unknown as [object];
523-
expect(queued).not.toHaveProperty("modelSelection");
524-
expect(state.clearDraft).toHaveBeenCalledOnce();
525-
});
526-
527-
it("preserves an explicit unavailable pick instead of queueing it", async () => {
528-
state.grantedEnvironments.add("secondary");
529-
state.serverConfig = {
530-
...state.serverConfig,
531-
providers: [{ instanceId: "codex", driver: "codex", enabled: false }],
532-
} as unknown as ServerConfig;
533-
state.draft.modelSelection = {
534-
instanceId: ProviderInstanceId.make("codex"),
535-
model: "gpt-5.4",
536-
};
537-
538-
expect(await useThreadComposerState().onSendMessage()).toBeNull();
539-
540-
expect(state.enqueue).not.toHaveBeenCalled();
541-
expect(state.clearDraft).not.toHaveBeenCalled();
542-
});
543-
544510
it("queues a follow-up with no model when the user picked none", async () => {
545511
state.grantedEnvironments.add("secondary");
546-
const composer = useThreadComposerState();
512+
const composer = useThreadComposerState(NO_SIDE_CHATS);
547513

548514
expect(await composer.onSendMessage()).toBe("message");
549515

‎apps/mobile/src/state/threadOutboxDelivery.permissions.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ import { appAtomRegistry } from "./atom-registry";
164164
import { environmentSession } from "./session";
165165
import { dispatchingQueuedMessageIdAtom, editingQueuedMessageIdsAtom } from "./use-thread-outbox";
166166
import { createThreadOutboxDelivery } from "./threadOutboxDelivery";
167+
import { releaseDeliveredComposerModelPick } from "./use-composer-drafts";
167168

168169
const message = (overrides: Partial<QueuedThreadMessage> = {}): QueuedThreadMessage => ({
169170
environmentId: EnvironmentId.make("secondary"),
@@ -359,6 +360,10 @@ describe("queued follow-up model", () => {
359360

360361
expect(state.start).toHaveBeenCalledOnce();
361362
expect(state.start.mock.calls[0]?.[0].input.modelSelection).toEqual(picked);
363+
expect(releaseDeliveredComposerModelPick).toHaveBeenCalledExactlyOnceWith(
364+
"secondary:thread",
365+
picked,
366+
);
362367
});
363368
});
364369

‎apps/server/src/orchestration-v2/Orchestrator.ts‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7039,21 +7039,6 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
70397039
command.createdBy === "user" &&
70407040
(command.creationSource === "web" || command.creationSource === "mobile") &&
70417041
command.scheduledTaskId === undefined;
7042-
// A queued pick reaches the thread only when its run starts; unpicked messages behind it follow it.
7043-
// Monitor updates follow whatever runs before them; goal commands stay on the provider validated above.
7044-
const newestQueuedPick =
7045-
shouldQueue &&
7046-
sentByUserFromClient &&
7047-
command.modelSelection === undefined &&
7048-
parsedGoalCommand === null
7049-
? queuedRunsInDeliveryOrder(projection).findLast(
7050-
(run) =>
7051-
!followsCurrentConversation(
7052-
projection.messages.find((message) => message.id === run.userMessageId),
7053-
),
7054-
)
7055-
: undefined;
7056-
if (newestQueuedPick) modelSelection = newestQueuedPick.modelSelection;
70577042
const heldRunsToRelease =
70587043
sentByUserFromClient && startsOrQueuesRun && !worktreeSetupUnresolved
70597044
? projection.runs.filter((run) => run.status === "queued" && run.queueHeld === true)

‎apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts‎

Lines changed: 0 additions & 182 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,188 +2020,6 @@ describe("orchestration v2 provider switching", () => {
20202020
),
20212021
);
20222022

2023-
it.live("queues an unpicked follow-up on the newest queued pick", () =>
2024-
Effect.scoped(
2025-
Effect.gen(function* () {
2026-
const cwd = yield* checkpointWorkspace("queued-unpicked-follow-up");
2027-
const capturedTurns = yield* Ref.make<ReadonlyArray<CapturedTurn>>([]);
2028-
const started = yield* Deferred.make<void>();
2029-
const threadId = ThreadId.make("thread:queued-unpicked-follow-up");
2030-
const layerRegistry = ProviderAdapterRegistry.layerFromAdapters([
2031-
makeTestAdapter({
2032-
instanceId: CODEX_MODEL_SELECTION.instanceId,
2033-
driver: CODEX_DRIVER,
2034-
capabilities: CodexProviderCapabilitiesV2,
2035-
modelSelection: CODEX_MODEL_SELECTION,
2036-
responseByRunOrdinal: {},
2037-
capturedTurns,
2038-
holdFirstTurn: started,
2039-
}),
2040-
makeTestAdapter({
2041-
instanceId: CLAUDE_MODEL_SELECTION.instanceId,
2042-
driver: CLAUDE_DRIVER,
2043-
capabilities: ClaudeProviderCapabilitiesV2,
2044-
modelSelection: CLAUDE_MODEL_SELECTION,
2045-
responseByRunOrdinal: {},
2046-
capturedTurns,
2047-
}),
2048-
]);
2049-
yield* Effect.gen(function* () {
2050-
const orchestrator = yield* Orchestrator.OrchestratorV2;
2051-
const worker = yield* EffectWorker.OrchestrationEffectWorkerV2;
2052-
yield* orchestrator.dispatch({
2053-
type: "thread.create",
2054-
createdBy: "user",
2055-
creationSource: "web",
2056-
commandId: CommandId.make("command:queued-unpicked-follow-up:create"),
2057-
threadId,
2058-
projectId: ProjectId.make("project:queued-unpicked-follow-up"),
2059-
title: "Queued unpicked follow-up",
2060-
modelSelection: CODEX_MODEL_SELECTION,
2061-
runtimeMode: "full-access",
2062-
interactionMode: "default",
2063-
branch: null,
2064-
worktreePath: cwd,
2065-
});
2066-
yield* orchestrator.dispatch({
2067-
type: "message.dispatch",
2068-
createdBy: "user",
2069-
creationSource: "web",
2070-
commandId: CommandId.make("command:queued-unpicked-follow-up:first"),
2071-
threadId,
2072-
messageId: MessageId.make("message:queued-unpicked-follow-up:first"),
2073-
text: "Current Codex turn",
2074-
attachments: [],
2075-
modelSelection: CODEX_MODEL_SELECTION,
2076-
dispatchMode: { type: "start_immediately" },
2077-
});
2078-
yield* Deferred.await(started);
2079-
yield* worker.drain();
2080-
yield* orchestrator.dispatch({
2081-
type: "message.dispatch",
2082-
createdBy: "user",
2083-
creationSource: "mobile",
2084-
commandId: CommandId.make("command:queued-unpicked-follow-up:pick"),
2085-
threadId,
2086-
messageId: MessageId.make("message:queued-unpicked-follow-up:pick"),
2087-
text: "Picked Claude",
2088-
attachments: [],
2089-
modelSelection: CLAUDE_MODEL_SELECTION,
2090-
dispatchMode: { type: "queue_after_active" },
2091-
});
2092-
yield* orchestrator.dispatch({
2093-
type: "message.dispatch",
2094-
createdBy: "user",
2095-
creationSource: "mobile",
2096-
commandId: CommandId.make("command:queued-unpicked-follow-up:follow-up"),
2097-
threadId,
2098-
messageId: MessageId.make("message:queued-unpicked-follow-up:follow-up"),
2099-
text: "Follow-up without a pick",
2100-
attachments: [],
2101-
dispatchMode: { type: "queue_after_active" },
2102-
});
2103-
const projection = yield* orchestrator.getThreadProjection(threadId);
2104-
assert.deepEqual(
2105-
projection.runs.map((run) => [run.status, run.modelSelection.instanceId]),
2106-
[
2107-
["running", CODEX_MODEL_SELECTION.instanceId],
2108-
["queued", CLAUDE_MODEL_SELECTION.instanceId],
2109-
["queued", CLAUDE_MODEL_SELECTION.instanceId],
2110-
],
2111-
);
2112-
yield* orchestrator.dispatch({
2113-
type: "message.dispatch",
2114-
createdBy: "agent",
2115-
creationSource: "server",
2116-
commandId: CommandId.make("command:queued-unpicked-follow-up:monitor"),
2117-
threadId,
2118-
messageId: MessageId.make("message:queued-unpicked-follow-up:monitor"),
2119-
text: "Monitor update",
2120-
attachments: [],
2121-
dispatchMode: { type: "queue_after_active" },
2122-
notification: { source: { kind: "monitor" }, outcome: "updated", summary: "Update" },
2123-
});
2124-
yield* orchestrator.dispatch({
2125-
type: "message.dispatch",
2126-
createdBy: "user",
2127-
creationSource: "mobile",
2128-
commandId: CommandId.make("command:queued-unpicked-follow-up:after-monitor"),
2129-
threadId,
2130-
messageId: MessageId.make("message:queued-unpicked-follow-up:after-monitor"),
2131-
text: "Follow-up after a monitor update",
2132-
attachments: [],
2133-
dispatchMode: { type: "queue_after_active" },
2134-
});
2135-
const afterMonitor = yield* orchestrator.getThreadProjection(threadId);
2136-
assert.equal(
2137-
afterMonitor.runs.find(
2138-
(run) => run.userMessageId === "message:queued-unpicked-follow-up:after-monitor",
2139-
)?.modelSelection.instanceId,
2140-
CLAUDE_MODEL_SELECTION.instanceId,
2141-
);
2142-
yield* orchestrator.dispatch({
2143-
type: "message.dispatch",
2144-
createdBy: "user",
2145-
creationSource: "server",
2146-
commandId: CommandId.make("command:queued-unpicked-follow-up:server"),
2147-
threadId,
2148-
messageId: MessageId.make("message:queued-unpicked-follow-up:server"),
2149-
text: "Server-created answer",
2150-
attachments: [],
2151-
dispatchMode: { type: "queue_after_active" },
2152-
});
2153-
const withServerMessage = yield* orchestrator.getThreadProjection(threadId);
2154-
assert.equal(
2155-
withServerMessage.runs.find(
2156-
(run) => run.userMessageId === "message:queued-unpicked-follow-up:server",
2157-
)?.modelSelection.instanceId,
2158-
CODEX_MODEL_SELECTION.instanceId,
2159-
);
2160-
yield* orchestrator.dispatch({
2161-
type: "thread.stop",
2162-
commandId: CommandId.make("command:queued-unpicked-follow-up:stop"),
2163-
threadId,
2164-
});
2165-
yield* worker.drain();
2166-
yield* orchestrator.dispatch({
2167-
type: "message.dispatch",
2168-
createdBy: "user",
2169-
creationSource: "mobile",
2170-
commandId: CommandId.make("command:queued-unpicked-follow-up:continue"),
2171-
threadId,
2172-
messageId: MessageId.make("message:queued-unpicked-follow-up:continue"),
2173-
text: "Continue without a pick",
2174-
attachments: [],
2175-
dispatchMode: { type: "start_immediately" },
2176-
});
2177-
const continued = yield* orchestrator.getThreadProjection(threadId);
2178-
const continuation = continued.runs.find(
2179-
(run) => run.userMessageId === "message:queued-unpicked-follow-up:continue",
2180-
);
2181-
assert.equal(continuation?.modelSelection.instanceId, CODEX_MODEL_SELECTION.instanceId);
2182-
}).pipe(
2183-
Effect.provide(
2184-
ProviderReplayHarness.layerWithRegistry(
2185-
{
2186-
name: "queued-unpicked-follow-up",
2187-
runtimePolicyOverride: {
2188-
cwd,
2189-
approvalPolicy: "never",
2190-
sandboxPolicy: {
2191-
type: "readOnly",
2192-
access: { type: "fullAccess" },
2193-
networkAccess: false,
2194-
},
2195-
},
2196-
},
2197-
layerRegistry,
2198-
),
2199-
),
2200-
);
2201-
}),
2202-
),
2203-
);
2204-
22052023
it.live("hands completed Grok steering context to earlier queued Codex and later Claude", () =>
22062024
Effect.scoped(
22072025
Effect.gen(function* () {

0 commit comments

Comments
 (0)