@@ -6,10 +6,19 @@ let createPromptSubmit: typeof import("./submit").createPromptSubmit
66const createdClients : string [ ] = [ ]
77const createdSessions : string [ ] = [ ]
88const enabledAutoAccept : Array < { sessionID : string ; directory : string } > = [ ]
9+ const optimistic : Array < {
10+ message : {
11+ agent : string
12+ model : { providerID : string ; modelID : string }
13+ variant ?: string
14+ }
15+ } > = [ ]
916const sentShell : string [ ] = [ ]
1017const syncedDirectories : string [ ] = [ ]
1118
19+ let params : { id ?: string } = { }
1220let selected = "/repo/worktree-a"
21+ let variant : string | undefined
1322
1423const promptValue : Prompt = [ { type : "text" , content : "ls" , start : 0 , end : 2 } ]
1524
@@ -26,6 +35,7 @@ const clientFor = (directory: string) => {
2635 return { data : undefined }
2736 } ,
2837 prompt : async ( ) => ( { data : undefined } ) ,
38+ promptAsync : async ( ) => ( { data : undefined } ) ,
2939 command : async ( ) => ( { data : undefined } ) ,
3040 abort : async ( ) => ( { data : undefined } ) ,
3141 } ,
@@ -40,7 +50,7 @@ beforeAll(async () => {
4050
4151 mock . module ( "@solidjs/router" , ( ) => ( {
4252 useNavigate : ( ) => ( ) => undefined ,
43- useParams : ( ) => ( { } ) ,
53+ useParams : ( ) => params ,
4454 } ) )
4555
4656 mock . module ( "@opencode-ai/sdk/v2/client" , ( ) => ( {
@@ -62,7 +72,7 @@ beforeAll(async () => {
6272 useLocal : ( ) => ( {
6373 model : {
6474 current : ( ) => ( { id : "model" , provider : { id : "provider" } } ) ,
65- variant : { current : ( ) => undefined } ,
75+ variant : { current : ( ) => variant } ,
6676 } ,
6777 agent : {
6878 current : ( ) => ( { name : "agent" } ) ,
@@ -118,7 +128,11 @@ beforeAll(async () => {
118128 data : { command : [ ] } ,
119129 session : {
120130 optimistic : {
121- add : ( ) => undefined ,
131+ add : ( value : {
132+ message : { agent : string ; model : { providerID : string ; modelID : string } ; variant ?: string }
133+ } ) => {
134+ optimistic . push ( value )
135+ } ,
122136 remove : ( ) => undefined ,
123137 } ,
124138 } ,
@@ -155,9 +169,12 @@ beforeEach(() => {
155169 createdClients . length = 0
156170 createdSessions . length = 0
157171 enabledAutoAccept . length = 0
172+ optimistic . length = 0
173+ params = { }
158174 sentShell . length = 0
159175 syncedDirectories . length = 0
160176 selected = "/repo/worktree-a"
177+ variant = undefined
161178} )
162179
163180describe ( "prompt submit worktree selection" , ( ) => {
@@ -219,4 +236,39 @@ describe("prompt submit worktree selection", () => {
219236
220237 expect ( enabledAutoAccept ) . toEqual ( [ { sessionID : "session-1" , directory : "/repo/worktree-a" } ] )
221238 } )
239+
240+ test ( "includes the selected variant on optimistic prompts" , async ( ) => {
241+ params = { id : "session-1" }
242+ variant = "high"
243+
244+ const submit = createPromptSubmit ( {
245+ info : ( ) => ( { id : "session-1" } ) ,
246+ imageAttachments : ( ) => [ ] ,
247+ commentCount : ( ) => 0 ,
248+ autoAccept : ( ) => false ,
249+ mode : ( ) => "normal" ,
250+ working : ( ) => false ,
251+ editor : ( ) => undefined ,
252+ queueScroll : ( ) => undefined ,
253+ promptLength : ( value ) => value . reduce ( ( sum , part ) => sum + ( "content" in part ? part . content . length : 0 ) , 0 ) ,
254+ addToHistory : ( ) => undefined ,
255+ resetHistoryNavigation : ( ) => undefined ,
256+ setMode : ( ) => undefined ,
257+ setPopover : ( ) => undefined ,
258+ onSubmit : ( ) => undefined ,
259+ } )
260+
261+ const event = { preventDefault : ( ) => undefined } as unknown as Event
262+
263+ await submit . handleSubmit ( event )
264+
265+ expect ( optimistic ) . toHaveLength ( 1 )
266+ expect ( optimistic [ 0 ] ) . toMatchObject ( {
267+ message : {
268+ agent : "agent" ,
269+ model : { providerID : "provider" , modelID : "model" } ,
270+ variant : "high" ,
271+ } ,
272+ } )
273+ } )
222274} )
0 commit comments