From 70b8daaee63a7b770a52159c7462f2cef39b186f Mon Sep 17 00:00:00 2001 From: Xubin Ren Date: Tue, 12 May 2026 11:08:52 +0000 Subject: [PATCH] fix(command): show default as current model preset Co-authored-by: Cursor --- nanobot/command/builtin.py | 18 ++++++++++++++---- tests/command/test_model_command.py | 4 ++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/nanobot/command/builtin.py b/nanobot/command/builtin.py index 2310be181..c1e8e4fdd 100644 --- a/nanobot/command/builtin.py +++ b/nanobot/command/builtin.py @@ -203,13 +203,23 @@ def _format_preset_names(names: list[str]) -> str: return ", ".join(f"`{name}`" for name in names) if names else "(none configured)" +def _model_preset_names(loop) -> list[str]: + names = set(loop.model_presets) + names.add("default") + return ["default", *sorted(name for name in names if name != "default")] + + +def _active_model_preset_name(loop) -> str: + return loop.model_preset or "default" + + def _model_command_status(loop) -> str: - names = sorted(loop.model_presets) - active = loop.model_preset or "(none)" + names = _model_preset_names(loop) + active = _active_model_preset_name(loop) return "\n".join([ "## Model", f"- Current model: `{loop.model}`", - f"- Active preset: `{active}`", + f"- Current preset: `{active}`", f"- Available presets: {_format_preset_names(names)}", ]) @@ -241,7 +251,7 @@ async def cmd_model(ctx: CommandContext) -> OutboundMessage: try: loop.set_model_preset(name) except (KeyError, ValueError) as exc: - names = sorted(loop.model_presets) + names = _model_preset_names(loop) return OutboundMessage( channel=ctx.msg.channel, chat_id=ctx.msg.chat_id, diff --git a/tests/command/test_model_command.py b/tests/command/test_model_command.py index f81fb0226..610b13d33 100644 --- a/tests/command/test_model_command.py +++ b/tests/command/test_model_command.py @@ -61,8 +61,8 @@ async def test_model_command_lists_current_and_available_presets(tmp_path) -> No out = await cmd_model(_ctx(loop, "/model")) assert "Current model: `base-model`" in out.content - assert "Active preset: `(none)`" in out.content - assert "`default`" in out.content + assert "Current preset: `default`" in out.content + assert "Available presets: `default`, `fast`" in out.content assert "`fast`" in out.content assert out.metadata == {"render_as": "text"}