Skip to content

Commit ddc5fd5

Browse files
committed
fix(mobile): let unpicked follow-ups pass model preflight
1 parent 2158a34 commit ddc5fd5

2 files changed

Lines changed: 37 additions & 2 deletions

File tree

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,40 @@ describe("mobile task permissions", () => {
320320
});
321321

322322
describe("queued follow-up model", () => {
323+
it("queues an unpicked follow-up despite an unavailable cached thread model", async () => {
324+
state.grantedEnvironments.add("secondary");
325+
state.serverConfig = {
326+
...state.serverConfig,
327+
providers: [{ instanceId: "codex", driver: "codex", enabled: false }],
328+
} as unknown as ServerConfig;
329+
330+
expect(await useThreadComposerState().onSendMessage()).toBe("message");
331+
332+
expect(state.enqueue).toHaveBeenCalledExactlyOnceWith(
333+
expect.objectContaining({ text: "Keep my draft", threadId: "thread" }),
334+
);
335+
const [queued] = state.enqueue.mock.calls[0] as unknown as [object];
336+
expect(queued).not.toHaveProperty("modelSelection");
337+
expect(state.clearDraft).toHaveBeenCalledOnce();
338+
});
339+
340+
it("preserves an explicit unavailable pick instead of queueing it", async () => {
341+
state.grantedEnvironments.add("secondary");
342+
state.serverConfig = {
343+
...state.serverConfig,
344+
providers: [{ instanceId: "codex", driver: "codex", enabled: false }],
345+
} as unknown as ServerConfig;
346+
state.draft.modelSelection = {
347+
instanceId: ProviderInstanceId.make("codex"),
348+
model: "gpt-5.4",
349+
};
350+
351+
expect(await useThreadComposerState().onSendMessage()).toBeNull();
352+
353+
expect(state.enqueue).not.toHaveBeenCalled();
354+
expect(state.clearDraft).not.toHaveBeenCalled();
355+
});
356+
323357
it("queues a follow-up with no model when the user picked none", async () => {
324358
state.grantedEnvironments.add("secondary");
325359
const composer = useThreadComposerState();

‎apps/mobile/src/state/use-thread-composer-state.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,11 +550,12 @@ export function useThreadComposerState() {
550550
const serverConfig = selectedEnvironmentRuntime?.serverConfig;
551551
if (
552552
selectedEnvironmentRuntime?.connectionState === "connected" &&
553-
isModelSelectionUnavailable(serverConfig, modelSelection, thread.projectId)
553+
draft.modelSelection !== undefined &&
554+
isModelSelectionUnavailable(serverConfig, draft.modelSelection, thread.projectId)
554555
) {
555556
const { title, detail } = describeUnavailableModelSelection(
556557
serverConfig,
557-
modelSelection,
558+
draft.modelSelection,
558559
thread.projectId,
559560
);
560561
Dialog.alert(title, detail);

0 commit comments

Comments
 (0)