@@ -17,7 +17,6 @@ import { useComposerDraftStore } from "../../composerDraftStore";
1717import { useComposerSelection } from "./useComposerSelection" ;
1818
1919const environmentId = EnvironmentId . make ( "environment-local" ) ;
20- const threadRef = scopeThreadRef ( environmentId , ThreadId . make ( "thread-cursor" ) ) ;
2120const cursor = ProviderInstanceId . make ( "cursor" ) ;
2221const stored = createModelSelection ( cursor , "claude-opus-5-5" , [ { id : "effort" , value : "medium" } ] ) ;
2322
@@ -38,24 +37,25 @@ const providers: ReadonlyArray<ServerProvider> = [
3837] ;
3938
4039// The hook reads only the thread's identity and stored selection.
41- const activeThread = {
42- environmentId,
43- id : threadRef . threadId ,
44- modelSelection : stored ,
45- } as EnvironmentThreadShell ;
40+ function cursorThread ( id : string ) {
41+ return { environmentId, id : ThreadId . make ( id ) , modelSelection : stored } as EnvironmentThreadShell ;
42+ }
4643
47- function Picker ( ) {
44+ function Picker ( props : {
45+ thread : EnvironmentThreadShell ;
46+ runtime : Parameters < typeof useComposerSelection > [ 0 ] [ "activeRuntime" ] ;
47+ } ) {
4848 const { onProviderModelSelectStable } = useComposerSelection ( {
4949 environmentId,
50- composerDraftTarget : threadRef ,
50+ composerDraftTarget : scopeThreadRef ( environmentId , props . thread . id ) ,
5151 draftThread : null ,
52- activeThread,
53- activeRuntime : null ,
52+ activeThread : props . thread ,
53+ activeRuntime : props . runtime ,
5454 activeProjectSettings : { settings : { newWorktreesStartFromOrigin : false } } ,
5555 settings : DEFAULT_UNIFIED_SETTINGS ,
5656 providerStatuses : providers ,
5757 lockedProvider : null ,
58- supportsProviderSwitchingViaHandoff : false ,
58+ supportsProviderSwitchingViaHandoff : true ,
5959 multipleModelSelections : null ,
6060 runtimeMode : "full-access" ,
6161 interactionMode : "default" ,
@@ -73,12 +73,27 @@ function Picker() {
7373 ) ;
7474}
7575
76- it ( "keeps a Cursor thread's stored model when the user re-picks its unavailable row" , async ( ) => {
77- await using _screen = await render ( < Picker /> ) ;
76+ it ( "keeps a Cursor thread's stored model and options when the user re-picks its unavailable row" , async ( ) => {
77+ const thread = cursorThread ( "thread-cursor" ) ;
78+ await using _screen = await render ( < Picker thread = { thread } runtime = { null } /> ) ;
79+ await page . getByRole ( "button" , { name : "Pick the stored model" } ) . click ( ) ;
80+
81+ const draft = useComposerDraftStore
82+ . getState ( )
83+ . getComposerDraft ( scopeThreadRef ( environmentId , thread . id ) ) ;
84+ expect ( draft ?. modelSelectionByProvider [ cursor ] ?? thread . modelSelection ) . toEqual ( stored ) ;
85+ } ) ;
86+
87+ it ( "switches back to the thread's stored model while the session runs on another instance" , async ( ) => {
88+ const thread = cursorThread ( "thread-cursor-handoff" ) ;
89+ const runtime = { providerInstanceId : ProviderInstanceId . make ( "codex" ) } as Parameters <
90+ typeof useComposerSelection
91+ > [ 0 ] [ "activeRuntime" ] ;
92+ await using _screen = await render ( < Picker thread = { thread } runtime = { runtime } /> ) ;
7893 await page . getByRole ( "button" , { name : "Pick the stored model" } ) . click ( ) ;
7994
80- expect (
81- useComposerDraftStore . getState ( ) . getComposerDraft ( threadRef ) ?. modelSelectionByProvider [ cursor ]
82- ?. model ,
83- ) . toBe ( "claude-opus-5-5" ) ;
95+ const draft = useComposerDraftStore
96+ . getState ( )
97+ . getComposerDraft ( scopeThreadRef ( environmentId , thread . id ) ) ;
98+ expect ( draft ?. activeProvider ) . toBe ( cursor ) ;
8499} ) ;
0 commit comments