Skip to content

Commit dcf0cf4

Browse files
shivamhwpclaude
andcommitted
test(composer): drop model pick tests other layers already cover
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 66bab50 commit dcf0cf4

2 files changed

Lines changed: 3 additions & 101 deletions

File tree

‎apps/mobile/src/state/use-composer-drafts.test.ts‎

Lines changed: 3 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,6 @@ const composerAttachmentCleanupMocks = vi.hoisted(() => ({
125125
releaseUploads: vi.fn(async () => undefined),
126126
}));
127127

128-
const modelCommandMocks = vi.hoisted(() => ({
129-
setModelSelection: Symbol("set-model-selection"),
130-
alert: vi.fn(),
131-
canOperate: true,
132-
thread: null as unknown,
133-
runs: [] as Array<unknown>,
134-
replies: [] as Array<
135-
ReturnType<typeof Promise.withResolvers<{ _tag: "Success" | "Failure"; error?: Error }>>
136-
>,
137-
}));
138-
139128
const incomingShareStorageMocks = vi.hoisted(() => ({
140129
load: vi.fn<typeof import("../features/sharing/incoming-share-storage").loadIncomingShareDrafts>(
141130
async () => [],
@@ -156,31 +145,14 @@ vi.mock("../lib/composerImages", async (importOriginal) => ({
156145
vi.mock("../lib/uuid", () => ({ uuidv4: () => "uuid", randomHex: () => "0000" }));
157146
vi.mock("./assets", () => ({ assetEnvironment: {} }));
158147
vi.mock("./attachments", () => ({ attachmentEnvironment: {} }));
159-
vi.mock("../components/ui/Dialog", () => ({ alert: modelCommandMocks.alert }));
160-
vi.mock("./session", () => ({
161-
environmentSession: {},
162-
readEnvironmentScope: () => modelCommandMocks.canOperate,
163-
}));
164-
vi.mock("./threads", async () => {
165-
const { Atom } = await import("effect/reactivity");
166-
return {
167-
threadEnvironment: { setModelSelection: modelCommandMocks.setModelSelection },
168-
environmentThreadShells: { threadShellAtom: () => Atom.make(modelCommandMocks.thread) },
169-
};
170-
});
148+
vi.mock("./session", () => ({ environmentSession: {} }));
171149
vi.mock("@t3tools/client-runtime/state/runtime", () => ({
172150
createEnvironmentRpcCommand: () => Symbol("rpc-command"),
173151
executeAtomQuery: () => {
174152
throw new Error("Unexpected network query in the inline read test");
175153
},
176-
runAtomCommand: (_registry: unknown, command: unknown, value: unknown) => {
177-
if (command !== modelCommandMocks.setModelSelection) {
178-
throw new Error("Unexpected network command in the inline read test");
179-
}
180-
modelCommandMocks.runs.push(value);
181-
const reply = Promise.withResolvers<{ _tag: "Success" | "Failure"; error?: Error }>();
182-
modelCommandMocks.replies.push(reply);
183-
return reply.promise;
154+
runAtomCommand: () => {
155+
throw new Error("Unexpected network command in the inline read test");
184156
},
185157
squashAtomCommandFailure: (result: { readonly error: unknown }) => result.error,
186158
}));
@@ -245,7 +217,6 @@ import {
245217
updateComposerDraftSettings,
246218
} from "./use-composer-drafts";
247219
import { retainComposerAttachmentFileForPreview } from "../lib/composerAttachmentPreviewRetention";
248-
import { selectThreadModel } from "./thread-model-selection";
249220

250221
const DRAFT: ComposerDraft = {
251222
text: "hello",
@@ -530,68 +501,6 @@ describe("mobile composer drafts", () => {
530501
expect(appAtomRegistry.get(composerDraftsAtom)[key]).toBeUndefined();
531502
});
532503

533-
it("sets allowed picks and releases accepted intent even when the shell skips that model", async () => {
534-
const environmentId = EnvironmentId.make("environment-1");
535-
const threadId = ThreadId.make("thread-1");
536-
const key = `${environmentId}:${threadId}`;
537-
const codex = ProviderInstanceId.make("codex");
538-
modelCommandMocks.runs.length = 0;
539-
modelCommandMocks.replies.length = 0;
540-
modelCommandMocks.alert.mockClear();
541-
modelCommandMocks.canOperate = true;
542-
modelCommandMocks.thread = {
543-
...v2ThreadShell,
544-
id: threadId,
545-
environmentId,
546-
modelSelection: { instanceId: codex, model: "gpt-5.4" },
547-
};
548-
const pick = { instanceId: codex, model: "gpt-5.5" };
549-
selectThreadModel({ environmentId, threadId }, pick);
550-
expect(modelCommandMocks.runs).toEqual([
551-
{ environmentId, input: { threadId, modelSelection: pick } },
552-
]);
553-
554-
setComposerDraftText(key, "keep this prompt");
555-
modelCommandMocks.thread = {
556-
...v2ThreadShell,
557-
id: threadId,
558-
environmentId,
559-
modelSelection: { instanceId: codex, model: "another-client-model" },
560-
};
561-
modelCommandMocks.replies[0]!.resolve({ _tag: "Success" });
562-
await modelCommandMocks.replies[0]!.promise;
563-
expect(getComposerDraftSnapshot(key).modelSelection).toBeUndefined();
564-
expect(getComposerDraftSnapshot(key).text).toBe("keep this prompt");
565-
566-
selectThreadModel({ environmentId, threadId }, pick);
567-
selectThreadModel({ environmentId, threadId }, pick);
568-
const latest = getComposerDraftSnapshot(key).modelSelection;
569-
modelCommandMocks.replies[1]!.resolve({ _tag: "Success" });
570-
await modelCommandMocks.replies[1]!.promise;
571-
expect(getComposerDraftSnapshot(key).modelSelection).toBe(latest);
572-
expect(modelCommandMocks.alert).not.toHaveBeenCalled();
573-
modelCommandMocks.replies[2]!.resolve({
574-
_tag: "Failure",
575-
error: new Error("The connection was lost."),
576-
});
577-
await modelCommandMocks.replies[2]!.promise;
578-
expect(getComposerDraftSnapshot(key).modelSelection).toBe(latest);
579-
expect(getComposerDraftSnapshot(key).text).toBe("keep this prompt");
580-
expect(modelCommandMocks.alert).toHaveBeenCalledExactlyOnceWith(
581-
"Could not apply model selection",
582-
"This model pick was not saved. The connection was lost.",
583-
);
584-
585-
// Another instance would replace the live session, and a read-only connection cannot
586-
// change the thread: both picks wait for a sent message.
587-
const claude = { instanceId: ProviderInstanceId.make("claudeAgent"), model: "claude-opus-5-5" };
588-
selectThreadModel({ environmentId, threadId }, claude);
589-
modelCommandMocks.canOperate = false;
590-
selectThreadModel({ environmentId, threadId }, pick);
591-
expect(modelCommandMocks.runs).toHaveLength(3);
592-
expect(getComposerDraftSnapshot(key).modelSelection).toEqual(pick);
593-
});
594-
595504
it("releases an inactive thread pick only after its queued model becomes durable", () => {
596505
const environmentId = EnvironmentId.make("environment-1");
597506
const threadId = ThreadId.make("thread-1");

‎packages/client-runtime/src/state/threadCommands.test.ts‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ const USER_INPUT = {
4646
kind: "user_input" as const,
4747
createdAt: NOW,
4848
};
49-
const PICKED_MODEL = {
50-
instanceId: ProviderInstanceId.make("codex"),
51-
model: "gpt-5.5",
52-
options: [{ id: "reasoningEffort", value: "high" }],
53-
};
5449
const SNAPSHOT: OrchestrationV2ShellSnapshot = {
5550
snapshotSequence: 1,
5651
schemaVersion: 2,
@@ -271,7 +266,6 @@ describe("remote thread lifecycle commands", () => {
271266
["setAutoSettle", { enabled: false }, { autoSettleDisabledAt: expect.any(Object) }],
272267
["reorderPin", { orderKey: "b" }, { pinOrderKey: "b" }],
273268
["reorderActive", { orderKey: "b" }, { activeOrderKey: "b" }],
274-
["setModelSelection", {}, { modelSelection: PICKED_MODEL }],
275269
] as const;
276270

277271
it.effect.each(actions)(
@@ -307,7 +301,6 @@ describe("remote thread lifecycle commands", () => {
307301
enabled: false,
308302
orderKey: "a",
309303
snoozedUntil: "2099-01-01T00:00:00.000Z",
310-
modelSelection: PICKED_MODEL,
311304
...input,
312305
},
313306
});

0 commit comments

Comments
 (0)