@@ -129,10 +129,7 @@ const modelCommandMocks = vi.hoisted(() => ({
129129 setModelSelection : Symbol ( "set-model-selection" ) ,
130130 canOperate : true ,
131131 thread : null as unknown ,
132- runs : [ ] as Array < {
133- readonly value : unknown ;
134- readonly settle : ( result : { readonly _tag : "Success" | "Failure" } ) => void ;
135- } > ,
132+ runs : [ ] as Array < unknown > ,
136133} ) ) ;
137134
138135const incomingShareStorageMocks = vi . hoisted ( ( ) => ( {
@@ -175,7 +172,8 @@ vi.mock("@t3tools/client-runtime/state/runtime", () => ({
175172 if ( command !== modelCommandMocks . setModelSelection ) {
176173 throw new Error ( "Unexpected network command in the inline read test" ) ;
177174 }
178- return new Promise ( ( settle ) => modelCommandMocks . runs . push ( { value, settle } ) ) ;
175+ modelCommandMocks . runs . push ( value ) ;
176+ return Promise . resolve ( ) ;
179177 } ,
180178 squashAtomCommandFailure : ( result : { readonly error : unknown } ) => result . error ,
181179} ) ) ;
@@ -525,57 +523,33 @@ describe("mobile composer drafts", () => {
525523 expect ( appAtomRegistry . get ( composerDraftsAtom ) [ key ] ) . toBeUndefined ( ) ;
526524 } ) ;
527525
528- it ( "applies an existing thread's pick now and releases only the latest accepted pick" , async ( ) => {
526+ it ( "sets an existing thread's pick on the thread only within its instance and with operate access" , ( ) => {
529527 const environmentId = EnvironmentId . make ( "environment-1" ) ;
530528 const threadId = ThreadId . make ( "thread-1" ) ;
531529 const key = `${ environmentId } :${ threadId } ` ;
532530 const codex = ProviderInstanceId . make ( "codex" ) ;
533531 modelCommandMocks . runs . length = 0 ;
534532 modelCommandMocks . canOperate = true ;
535- const initialThread = {
533+ modelCommandMocks . thread = {
536534 ...v2ThreadShell ,
537535 id : threadId ,
538536 environmentId,
539537 modelSelection : { instanceId : codex , model : "gpt-5.4" } ,
540538 } ;
541- modelCommandMocks . thread = initialThread ;
542- setComposerDraftText ( key , "keep this unsent follow-up" ) ;
543- const first = { instanceId : codex , model : "gpt-5.5" } ;
544- const latest = { ...first } ;
545- selectThreadModel ( { environmentId, threadId } , first , [ ] ) ;
546- modelCommandMocks . thread = { ...initialThread , modelSelection : first } ;
547- selectThreadModel ( { environmentId, threadId } , latest , [ ] ) ;
548- expect ( modelCommandMocks . runs . map ( ( run ) => run . value ) ) . toEqual ( [
549- { environmentId, input : { threadId, modelSelection : first } } ,
550- { environmentId, input : { threadId, modelSelection : latest } } ,
539+ const pick = { instanceId : codex , model : "gpt-5.5" } ;
540+ selectThreadModel ( { environmentId, threadId } , pick , [ ] ) ;
541+ expect ( modelCommandMocks . runs ) . toEqual ( [
542+ { environmentId, input : { threadId, modelSelection : pick } } ,
551543 ] ) ;
552544
553- modelCommandMocks . runs [ 0 ] ! . settle ( { _tag : "Failure" } ) ;
554- await Promise . resolve ( ) ;
555- expect ( getComposerDraftSnapshot ( key ) . modelSelection ) . toEqual ( latest ) ;
556- modelCommandMocks . runs [ 1 ] ! . settle ( { _tag : "Success" } ) ;
557- await Promise . resolve ( ) ;
558- expect ( getComposerDraftSnapshot ( key ) . text ) . toBe ( "keep this unsent follow-up" ) ;
559- expect ( getComposerDraftSnapshot ( key ) . modelSelection ) . toBeUndefined ( ) ;
560-
561- // A rejected pick stays the composer's choice, as before.
562- modelCommandMocks . thread = {
563- ...initialThread ,
564- modelSelection : { instanceId : codex , model : "gpt-5.4" } ,
565- } ;
566- selectThreadModel ( { environmentId, threadId } , first , [ ] ) ;
567- modelCommandMocks . runs [ 2 ] ! . settle ( { _tag : "Failure" } ) ;
568- await Promise . resolve ( ) ;
569- expect ( getComposerDraftSnapshot ( key ) . modelSelection ) . toEqual ( first ) ;
570-
571- // Another provider instance would replace the live session, and a read-only
572- // connection cannot change the thread: both picks wait for a sent message.
545+ // Another instance would replace the live session, and a read-only connection cannot
546+ // change the thread: both picks wait for a sent message.
573547 const claude = { instanceId : ProviderInstanceId . make ( "claudeAgent" ) , model : "claude-opus-5-5" } ;
574548 selectThreadModel ( { environmentId, threadId } , claude , [ ] ) ;
575549 modelCommandMocks . canOperate = false ;
576- selectThreadModel ( { environmentId, threadId } , latest , [ ] ) ;
577- expect ( modelCommandMocks . runs ) . toHaveLength ( 3 ) ;
578- expect ( getComposerDraftSnapshot ( key ) . modelSelection ) . toEqual ( latest ) ;
550+ selectThreadModel ( { environmentId, threadId } , pick , [ ] ) ;
551+ expect ( modelCommandMocks . runs ) . toHaveLength ( 1 ) ;
552+ expect ( getComposerDraftSnapshot ( key ) . modelSelection ) . toEqual ( pick ) ;
579553 } ) ;
580554
581555 it ( "releases an inactive thread pick only after its queued model becomes durable" , ( ) => {
0 commit comments