fix(webui): drive slash command routing from metadata

This commit is contained in:
chengyongru
2026-07-07 15:42:04 +08:00
committed by Xubin Ren
parent 8a231b6e4d
commit fa73448f6f
10 changed files with 243 additions and 68 deletions
+6
View File
@@ -2072,7 +2072,13 @@ async def test_commands_api_returns_slash_command_metadata(bus: MagicMock) -> No
body = response.json()
commands = {row["command"]: row for row in body["commands"]}
assert commands["/stop"]["title"] == "Stop current task"
assert commands["/new"]["lifecycle"] == "finalize_active_turn"
assert commands["/stop"]["lifecycle"] == "stop_active_turn"
assert commands["/history"]["lifecycle"] == "side_channel"
assert commands["/history"]["arg_hint"] == "[n]"
assert commands["/history"]["accepts_args"] is True
assert commands["/goal"]["lifecycle"] == "agent_turn_with_args"
assert commands["/goal"]["accepts_args"] is True
assert all("description" in row for row in body["commands"])
finally:
await channel.stop()
+4 -4
View File
@@ -345,11 +345,11 @@ async def test_dream_prompt_init_recreates_empty_prompt(tmp_path) -> None:
def test_dream_prompt_command_in_help_and_palette() -> None:
palette = builtin_command_palette()
dream_prompt = next(item for item in palette if item["command"] == "/dream-prompt")
assert any(
item["command"] == "/dream-prompt" and item["arg_hint"] == "[init]"
for item in palette
)
assert dream_prompt["arg_hint"] == "[init]"
assert dream_prompt["lifecycle"] == "side_channel"
assert dream_prompt["accepts_args"] is True
assert "/dream-prompt [init]" in build_help_text()
+8 -2
View File
@@ -149,7 +149,10 @@ async def test_model_command_registered_as_exact_and_prefix(tmp_path) -> None:
def test_model_command_in_help_and_palette() -> None:
palette = builtin_command_palette()
assert any(item["command"] == "/model" and item["arg_hint"] == "[preset]" for item in palette)
model = next(item for item in palette if item["command"] == "/model")
assert model["arg_hint"] == "[preset]"
assert model["lifecycle"] == "side_channel"
assert model["accepts_args"] is True
assert "/model [preset]" in build_help_text()
@@ -204,5 +207,8 @@ async def test_goal_command_registered_on_router(tmp_path) -> None:
def test_goal_command_in_help_and_palette() -> None:
palette = builtin_command_palette()
assert any(item["command"] == "/goal" and item["arg_hint"] == "<goal>" for item in palette)
goal = next(item for item in palette if item["command"] == "/goal")
assert goal["arg_hint"] == "<goal>"
assert goal["lifecycle"] == "agent_turn_with_args"
assert goal["accepts_args"] is True
assert "/goal <goal>" in build_help_text()