@@ -74,6 +74,11 @@ import {
7474 loadDesktopState ,
7575 projectFromWorkspace ,
7676} from "./store" ;
77+ import {
78+ normalizeThinkingLevel ,
79+ thinkingLevelDescription ,
80+ thinkingLevelsForModel ,
81+ } from "./modelControls" ;
7782import type {
7883 AccountUsage ,
7984 AgentChatEvent ,
@@ -589,30 +594,6 @@ function omitSessionKeys<T>(
589594 return changed ? next : current ;
590595}
591596
592- const THINKING_LEVELS = [ "low" , "medium" , "high" ] as const ;
593-
594- function thinkingLevelsForModel ( model ?: Model ) : string [ ] {
595- if ( ! model ?. supportEfforts . length ) return [ ...THINKING_LEVELS ] ;
596- const supported = THINKING_LEVELS . filter ( ( level ) =>
597- model . supportEfforts . includes ( level ) ,
598- ) ;
599- return supported . length ? supported : [ ...THINKING_LEVELS ] ;
600- }
601-
602- function normalizeThinkingLevel (
603- level : string | undefined ,
604- model ?: Model ,
605- ) : string {
606- const supported = thinkingLevelsForModel ( model ) ;
607- if ( level && supported . includes ( level ) ) return level ;
608- if ( model ?. defaultEffort && supported . includes ( model . defaultEffort ) ) {
609- return model . defaultEffort ;
610- }
611- return supported . includes ( "medium" )
612- ? "medium"
613- : supported [ Math . floor ( supported . length / 2 ) ] ;
614- }
615-
616597export default function App ( ) {
617598 const [ desktop , setDesktop ] = useState < DesktopState > ( { projects : [ ] } ) ;
618599 const [ auth , setAuth ] = useState < AuthStatus > ( {
@@ -681,6 +662,7 @@ export default function App() {
681662 model . id === activeConversation ?. modelId ||
682663 model . model === activeConversation ?. modelId ,
683664 ) ?? defaultModel ;
665+ const supportedThinkingLevels = thinkingLevelsForModel ( selectedModel ) ;
684666 const effort = normalizeThinkingLevel (
685667 activeConversation ?. thinkingLevel ,
686668 selectedModel ,
@@ -1510,7 +1492,8 @@ export default function App() {
15101492 } ;
15111493
15121494 const chooseEffort = ( level : string ) : void => {
1513- if ( ! activeConversation || ! activeProject ) return ;
1495+ if ( ! activeConversation || ! activeProject || modelBusy ) return ;
1496+ if ( ! thinkingLevelsForModel ( selectedModel ) . includes ( level ) ) return ;
15141497 if ( activeAgentScope ?. sessionId !== activeConversation . id ) {
15151498 showNotice ( "The conversation is still preparing. Try again in a moment." ) ;
15161499 return ;
@@ -2358,28 +2341,23 @@ export default function App() {
23582341 < RefreshCw size = { 14 } />
23592342 </ button >
23602343 ) }
2361- { selectedModel ?. supportsReasoning && (
2362- < ToolbarSelect
2363- className = "effort-select"
2364- ariaLabel = "选择思考强度"
2365- icon = { < BrainCircuit size = { 15 } /> }
2366- value = { effort }
2367- label = { `思考 · ${ effort } ` }
2368- options = { thinkingLevelsForModel ( selectedModel ) . map (
2369- ( value ) => ( {
2344+ { selectedModel ?. supportsReasoning &&
2345+ supportedThinkingLevels . length > 0 && (
2346+ < ToolbarSelect
2347+ className = "effort-select"
2348+ ariaLabel = "选择思考强度"
2349+ icon = { < BrainCircuit size = { 15 } /> }
2350+ value = { effort }
2351+ label = { `思考 · ${ effort } ` }
2352+ disabled = { modelBusy || ! activeAgentScope }
2353+ options = { supportedThinkingLevels . map ( ( value ) => ( {
23702354 value,
23712355 label : `思考 · ${ value } ` ,
2372- description :
2373- value === "low"
2374- ? "快速响应,适合简单任务"
2375- : value === "high"
2376- ? "更深入分析复杂问题"
2377- : "速度与推理深度平衡" ,
2378- } ) ,
2379- ) }
2380- onChange = { chooseEffort }
2381- />
2382- ) }
2356+ description : thinkingLevelDescription ( value ) ,
2357+ } ) ) }
2358+ onChange = { chooseEffort }
2359+ />
2360+ ) }
23832361 < ToolbarSelect
23842362 className = { `permission-select ${
23852363 permissionMode === "yolo"
0 commit comments