ui(redstone): dismiss /model keyboard on selection
selectModel was re-rendering the full picker with the ✅ moved to the new pick. Per design feedback, drop the keyboard once a choice is made — the callback toast plus a confirmation body is enough. Keeps the chat tidy after the switch. editMessageText without reply_markup clears the inline keyboard. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
31
bot/bot.ts
31
bot/bot.ts
@@ -684,31 +684,16 @@ async function selectModel(ctx: Context, modelId: string) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
kvSet("llm_model", modelId);
|
kvSet("llm_model", modelId);
|
||||||
await ctx.answerCallbackQuery({ text: `model: ${modelId}` });
|
await ctx.answerCallbackQuery({ text: `model set: ${modelId}` });
|
||||||
// Re-render the picker so the ✅ moves to the new pick.
|
// Dismiss the keyboard and replace the picker body with a confirmation.
|
||||||
|
// editMessageText with no reply_markup clears the inline keyboard.
|
||||||
try {
|
try {
|
||||||
const models = await fetchOpenRouterModels();
|
await ctx.editMessageText(
|
||||||
const usable = models.filter((m) => m.supported_parameters?.includes("tools"));
|
`<b>🧠 LLM model</b>\n\nActive: <code>${escape(modelId)}</code>\n\n<i>Switched. The new model takes effect on the next message.</i>`,
|
||||||
const ROUTER_RE = /^openrouter\/(free|auto)\b/;
|
{ parse_mode: "HTML" },
|
||||||
const routers = usable.filter((m) => ROUTER_RE.test(m.id));
|
);
|
||||||
const rest = usable.filter((m) => !ROUTER_RE.test(m.id))
|
|
||||||
.sort((a, b) => {
|
|
||||||
const af = isFreeModel(a), bf = isFreeModel(b);
|
|
||||||
if (af !== bf) return af ? -1 : 1;
|
|
||||||
return (a.name || a.id).localeCompare(b.name || b.id);
|
|
||||||
});
|
|
||||||
const list = [...routers, ...rest].slice(0, 20);
|
|
||||||
const kb = new InlineKeyboard();
|
|
||||||
for (const m of list) {
|
|
||||||
kb.text(modelButtonLabel(m, m.id === modelId), `model:${m.id}`).row();
|
|
||||||
}
|
|
||||||
const header =
|
|
||||||
`<b>🧠 LLM model picker</b>\n\n` +
|
|
||||||
`Active: <code>${escape(modelId)}</code>\n\n` +
|
|
||||||
`🟢 free · 💰 paid · 🛠 tools · 🧠 thinking`;
|
|
||||||
await ctx.editMessageText(header, { parse_mode: "HTML", reply_markup: kb });
|
|
||||||
} catch {
|
} catch {
|
||||||
/* leave keyboard as-is if refresh fails */
|
/* edit can fail if the original message is too old; the toast already confirmed */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user