11import { Context , InlineKeyboard } from "grammy" ;
22import { selectModel , getFavoriteModels , fetchCurrentModel } from "../../model/manager.js" ;
33import { formatModelForDisplay } from "../../model/types.js" ;
4- import type { ModelInfo } from "../../model/types.js" ;
4+ import type { FavoriteModel , ModelInfo } from "../../model/types.js" ;
55import { formatVariantForButton } from "../../variant/manager.js" ;
66import { logger } from "../../utils/logger.js" ;
77import { createMainKeyboard } from "../utils/keyboard.js" ;
88import { getStoredAgent } from "../../agent/manager.js" ;
99import { pinnedMessageManager } from "../../pinned/manager.js" ;
1010import { keyboardManager } from "../../keyboard/manager.js" ;
11+ import { config } from "../../config.js" ;
1112import {
1213 clearActiveInlineMenu ,
1314 ensureActiveInlineMenu ,
1415 replyWithInlineMenu ,
1516} from "./inline-menu.js" ;
1617import { t } from "../../i18n/index.js" ;
1718
19+ function isOnlyConfigDefaultModel ( models : FavoriteModel [ ] ) : boolean {
20+ if ( models . length !== 1 ) {
21+ return false ;
22+ }
23+
24+ const defaultProviderID = config . opencode . model . provider ;
25+ const defaultModelID = config . opencode . model . modelId ;
26+
27+ if ( ! defaultProviderID || ! defaultModelID ) {
28+ return false ;
29+ }
30+
31+ return models [ 0 ] . providerID === defaultProviderID && models [ 0 ] . modelID === defaultModelID ;
32+ }
33+
1834/**
1935 * Handle model selection callback
2036 * @param ctx grammY context
@@ -112,9 +128,12 @@ export async function handleModelSelect(ctx: Context): Promise<boolean> {
112128 * @param currentModel Current model for highlighting
113129 * @returns InlineKeyboard with model selection buttons
114130 */
115- export async function buildModelSelectionMenu ( currentModel ?: ModelInfo ) : Promise < InlineKeyboard > {
131+ export async function buildModelSelectionMenu (
132+ currentModel ?: ModelInfo ,
133+ favoriteModels ?: FavoriteModel [ ] ,
134+ ) : Promise < InlineKeyboard > {
116135 const keyboard = new InlineKeyboard ( ) ;
117- const favorites = await getFavoriteModels ( ) ;
136+ const favorites = favoriteModels ?? ( await getFavoriteModels ( ) ) ;
118137
119138 if ( favorites . length === 0 ) {
120139 logger . warn ( "[ModelHandler] No favorite models found" ) ;
@@ -145,7 +164,8 @@ export async function buildModelSelectionMenu(currentModel?: ModelInfo): Promise
145164export async function showModelSelectionMenu ( ctx : Context ) : Promise < void > {
146165 try {
147166 const currentModel = fetchCurrentModel ( ) ;
148- const keyboard = await buildModelSelectionMenu ( currentModel ) ;
167+ const favorites = await getFavoriteModels ( ) ;
168+ const keyboard = await buildModelSelectionMenu ( currentModel , favorites ) ;
149169
150170 if ( keyboard . inline_keyboard . length === 0 ) {
151171 await ctx . reply ( t ( "model.menu.empty" ) ) ;
@@ -161,6 +181,10 @@ export async function showModelSelectionMenu(ctx: Context): Promise<void> {
161181 text,
162182 keyboard,
163183 } ) ;
184+
185+ if ( isOnlyConfigDefaultModel ( favorites ) ) {
186+ await ctx . reply ( t ( "model.menu.favorites_hint" ) ) ;
187+ }
164188 } catch ( err ) {
165189 logger . error ( "[ModelHandler] Error showing model menu:" , err ) ;
166190 await ctx . reply ( t ( "model.menu.error" ) ) ;
0 commit comments