ui: fix thinking menu never appearing in single-model mode (#25637)
In MODEL mode, modelPropsCache is never populated: fetchModelProps call sites are gated on router-only state (isRouterMode checks, routerModels always empty), so supportsThinking always reads an empty chat template once a model is auto-selected. Read serverStore.props.chat_template directly in non-router mode, since the global /props already describes the single loaded model.
This commit is contained in:
@@ -245,21 +245,20 @@ class ModelsStore {
|
|||||||
* Whether the selected model's chat template supports thinking/reasoning.
|
* Whether the selected model's chat template supports thinking/reasoning.
|
||||||
* Uses heuristic detection on the model's chat_template from /props.
|
* Uses heuristic detection on the model's chat_template from /props.
|
||||||
*
|
*
|
||||||
* - MODEL mode: uses serverStore.props.chat_template (single loaded model)
|
* - MODEL mode: the global /props already describes the single loaded model,
|
||||||
* - ROUTER mode: fetches /props?model=<id> for the selected model (cached)
|
* so its chat_template is used directly and no per-model cache is involved
|
||||||
*
|
* - ROUTER mode: fetches /props?model=<id> for the selected model (cached),
|
||||||
* Triggers an async fetch of model props if not yet cached in ROUTER mode.
|
* triggering an async fetch if not yet cached
|
||||||
*/
|
*/
|
||||||
get supportsThinking(): boolean {
|
get supportsThinking(): boolean {
|
||||||
const modelId = this.selectedModelName;
|
if (!isRouterMode()) {
|
||||||
if (!modelId) {
|
return detectThinkingSupport(serverStore.props?.chat_template ?? '');
|
||||||
if (!isRouterMode()) {
|
|
||||||
return detectThinkingSupport(serverStore.props?.chat_template ?? '');
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRouterMode() && !this.modelPropsCache.get(modelId)) {
|
const modelId = this.selectedModelName;
|
||||||
|
if (!modelId) return false;
|
||||||
|
|
||||||
|
if (!this.modelPropsCache.get(modelId)) {
|
||||||
this.fetchModelProps(modelId);
|
this.fetchModelProps(modelId);
|
||||||
}
|
}
|
||||||
const props = this.getModelProps(modelId);
|
const props = this.getModelProps(modelId);
|
||||||
@@ -268,12 +267,17 @@ class ModelsStore {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a specific model supports thinking.
|
* Check if a specific model supports thinking.
|
||||||
* Fetches model props if not cached (in router mode).
|
* In MODEL mode the global /props describes the single loaded model.
|
||||||
|
* In ROUTER mode, fetches model props if not cached.
|
||||||
*/
|
*/
|
||||||
checkModelSupportsThinking(modelId: string): boolean {
|
checkModelSupportsThinking(modelId: string): boolean {
|
||||||
|
if (!isRouterMode()) {
|
||||||
|
return detectThinkingSupport(serverStore.props?.chat_template ?? '');
|
||||||
|
}
|
||||||
|
|
||||||
if (!modelId) return false;
|
if (!modelId) return false;
|
||||||
|
|
||||||
if (isRouterMode() && !this.modelPropsCache.get(modelId)) {
|
if (!this.modelPropsCache.get(modelId)) {
|
||||||
this.fetchModelProps(modelId);
|
this.fetchModelProps(modelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,14 +289,16 @@ class ModelsStore {
|
|||||||
* Detailed thinking support detection result with reason for debugging/UI.
|
* Detailed thinking support detection result with reason for debugging/UI.
|
||||||
*/
|
*/
|
||||||
get thinkingSupportDetails(): { supported: boolean; reason: string } {
|
get thinkingSupportDetails(): { supported: boolean; reason: string } {
|
||||||
|
if (!isRouterMode()) {
|
||||||
|
return detectThinkingSupportWithReason(serverStore.props?.chat_template ?? '');
|
||||||
|
}
|
||||||
|
|
||||||
const modelId = this.selectedModelName;
|
const modelId = this.selectedModelName;
|
||||||
if (!modelId) {
|
if (!modelId) {
|
||||||
if (!isRouterMode()) {
|
|
||||||
return detectThinkingSupportWithReason(serverStore.props?.chat_template ?? '');
|
|
||||||
}
|
|
||||||
return { supported: false, reason: 'No model selected' };
|
return { supported: false, reason: 'No model selected' };
|
||||||
}
|
}
|
||||||
if (isRouterMode() && !this.modelPropsCache.get(modelId)) {
|
|
||||||
|
if (!this.modelPropsCache.get(modelId)) {
|
||||||
this.fetchModelProps(modelId);
|
this.fetchModelProps(modelId);
|
||||||
}
|
}
|
||||||
const props = this.getModelProps(modelId);
|
const props = this.getModelProps(modelId);
|
||||||
|
|||||||
Reference in New Issue
Block a user