@@ -262,17 +262,24 @@ export function getReasoningTraitStep(input: {
262262 ) ;
263263 const choices = descriptor ? selectableProviderOptionChoices ( descriptor ) : [ ] ;
264264 if ( ! descriptor || choices . length < 2 ) return null ;
265- const current = getDescriptorStringValue (
266- descriptor ,
267- { instanceId : input . instanceId , model : input . model , options : input . modelOptions ?? [ ] } ,
268- input . reportedModelSelection ,
269- ) ;
270- const ordered = input . direction > 0 ? choices : choices . toReversed ( ) ;
265+ const isPrimary = descriptor . id === selected . primarySelectDescriptor ?. id ;
266+ const current =
267+ isPrimary && selected . ultrathinkPromptControlled
268+ ? "ultrathink"
269+ : getDescriptorStringValue (
270+ descriptor ,
271+ { instanceId : input . instanceId , model : input . model , options : input . modelOptions ?? [ ] } ,
272+ input . reportedModelSelection ,
273+ ) ;
274+ // Walk the full catalog order so a typed Ultrathink keeps its place, then land on a pickable level.
275+ const ordered = input . direction > 0 ? descriptor . options : descriptor . options . toReversed ( ) ;
271276 const position =
272277 [ current , getDescriptorStringValue ( descriptor ) ]
273278 . map ( ( value ) => ordered . findIndex ( ( option ) => option . id === value ) )
274279 . find ( ( index ) => index >= 0 ) ?? - 1 ;
275- const next = ordered [ ( position + 1 ) % ordered . length ] ;
280+ const next = [ ...ordered . slice ( position + 1 ) , ...ordered . slice ( 0 , Math . max ( position , 0 ) ) ] . find (
281+ ( option ) => choices . includes ( option ) ,
282+ ) ;
276283 const change = next && getTraitSelectChange ( selected , descriptor , input . prompt , next . id ) ;
277284 return change ?. modelOptions ? { prompt : change . prompt , modelOptions : change . modelOptions } : null ;
278285}
0 commit comments