@@ -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-
139128const 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) => ({
156145vi . mock ( "../lib/uuid" , ( ) => ( { uuidv4 : ( ) => "uuid" , randomHex : ( ) => "0000" } ) ) ;
157146vi . mock ( "./assets" , ( ) => ( { assetEnvironment : { } } ) ) ;
158147vi . 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 : { } } ) ) ;
171149vi . 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" ;
247219import { retainComposerAttachmentFileForPreview } from "../lib/composerAttachmentPreviewRetention" ;
248- import { selectThreadModel } from "./thread-model-selection" ;
249220
250221const 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" ) ;
0 commit comments