|
5 | 5 | replaceDescriptorCurrentValue, |
6 | 6 | selectableProviderOptionChoices, |
7 | 7 | REASONING_SELECT_DESCRIPTOR_IDS, |
8 | | - ULTRATHINK_PROMPT_PREFIX, |
9 | 8 | } from "@t3tools/client-runtime/model-traits"; |
10 | 9 | import { |
11 | 10 | type ModelSelection, |
@@ -261,36 +260,21 @@ export function getReasoningTraitStep(input: { |
261 | 260 | const descriptor = selected.selectDescriptors.find((entry) => |
262 | 261 | REASONING_SELECT_DESCRIPTOR_IDS.has(entry.id), |
263 | 262 | ); |
264 | | - if (!descriptor || descriptor.options.length < 2) return null; |
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 | | - const ordered = input.direction > 0 ? descriptor.options : descriptor.options.toReversed(); |
| 263 | + const choices = descriptor ? selectableProviderOptionChoices(descriptor) : []; |
| 264 | + 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(); |
275 | 271 | const position = |
276 | 272 | [current, getDescriptorStringValue(descriptor)] |
277 | 273 | .map((value) => ordered.findIndex((option) => option.id === value)) |
278 | 274 | .find((index) => index >= 0) ?? -1; |
279 | | - for (const option of [ |
280 | | - ...ordered.slice(position + 1), |
281 | | - ...ordered.slice(0, Math.max(position, 0)), |
282 | | - ]) { |
283 | | - const change = getTraitSelectChange(selected, descriptor, input.prompt, option.id); |
284 | | - if (!change) return null; |
285 | | - if ("modelOptions" in change) { |
286 | | - return change.modelOptions |
287 | | - ? { prompt: change.prompt, modelOptions: change.modelOptions } |
288 | | - : null; |
289 | | - } |
290 | | - // A slash command refuses the Ultrathink prefix, so skip that level. |
291 | | - if (change.prompt.startsWith(ULTRATHINK_PROMPT_PREFIX)) return change; |
292 | | - } |
293 | | - return null; |
| 275 | + const next = ordered[(position + 1) % ordered.length]; |
| 276 | + const change = next && getTraitSelectChange(selected, descriptor, input.prompt, next.id); |
| 277 | + return change?.modelOptions ? { prompt: change.prompt, modelOptions: change.modelOptions } : null; |
294 | 278 | } |
295 | 279 |
|
296 | 280 | export function shouldRenderTraitsControls(input: { |
@@ -393,7 +377,7 @@ export const TraitsMenuContent = memo(function TraitsMenuContentImpl({ |
393 | 377 | onPromptEdit?.( |
394 | 378 | (prompt) => getTraitSelectChange(selected, descriptor, prompt, value)?.prompt ?? prompt, |
395 | 379 | ); |
396 | | - if ("modelOptions" in change) updateModelOptions(change.modelOptions); |
| 380 | + updateModelOptions(change.modelOptions); |
397 | 381 | }; |
398 | 382 |
|
399 | 383 | if (!hasAnyControls) { |
|
0 commit comments