refactor(command): remove history command
This commit is contained in:
1 parent
efec4a608d
commit
c927808aff
30 files changed
+58
-278
No files matched your search
@@ -198,7 +198,6 @@ if DISCORD_AVAILABLE:
|
||||
("stop", "Stop the current task", "/stop"),
|
||||
("restart", "Restart the bot", "/restart"),
|
||||
("status", "Show bot status", "/status"),
|
||||
("history", "Show recent conversation messages", "/history"),
|
||||
)
|
||||
|
||||
for name, description, command_text in commands:
|
||||
|
||||
@@ -1180,7 +1180,7 @@ async def test_slash_new_is_blocked_for_disallowed_user() -> None:
|
||||
assert handled == []
|
||||
|
||||
|
||||
@pytest.mark.parametrize("slash_name", ["stop", "restart", "status", "history", "model"])
|
||||
@pytest.mark.parametrize("slash_name", ["stop", "restart", "status", "model"])
|
||||
@pytest.mark.asyncio
|
||||
async def test_slash_commands_forward_via_handle_message(slash_name: str) -> None:
|
||||
channel = DiscordChannel(DiscordConfig(enabled=True, allow_from=["*"]), MessageBus())
|
||||
|
||||
@@ -576,7 +576,6 @@ class TelegramChannel(BaseChannel):
|
||||
BotCommand("stop", "Stop the current task"),
|
||||
BotCommand("restart", "Restart the bot"),
|
||||
BotCommand("status", "Show bot status"),
|
||||
BotCommand("history", "Show recent conversation messages"),
|
||||
BotCommand("goal", "Start a sustained objective (long-running task)"),
|
||||
BotCommand("trigger", "Create a named local trigger"),
|
||||
BotCommand("pairing", "Manage DM pairing (approve/deny/list)"),
|
||||
@@ -594,7 +593,7 @@ class TelegramChannel(BaseChannel):
|
||||
# Telegram-safe aliases are normalized before reaching the core router.
|
||||
# Canonical hyphenated commands stay on a separate handler (below).
|
||||
TELEGRAM_BUS_SLASH_COMMAND_RE = re.compile(
|
||||
rf"^/(?:new|compact|stop|restart|status|dream|history|goal|trigger|pairing|model|skill"
|
||||
rf"^/(?:new|compact|stop|restart|status|dream|goal|trigger|pairing|model|skill"
|
||||
rf"|{_command_alternation(_TELEGRAM_COMMAND_ALIASES)}"
|
||||
rf"|{_command_alternation(_TELEGRAM_BUS_CANONICAL_COMMANDS)})(?:@\w+)?(?:\s+[\s\S]*)?$"
|
||||
)
|
||||
|
||||
@@ -374,7 +374,6 @@ async def test_start_creates_separate_pools_with_proxy(monkeypatch) -> None:
|
||||
assert builder.get_updates_request_value.inner is poll_req
|
||||
assert callable(app.updater.start_polling_kwargs["error_callback"])
|
||||
assert any(cmd.command == "status" for cmd in app.bot.commands)
|
||||
assert any(cmd.command == "history" for cmd in app.bot.commands)
|
||||
assert any(cmd.command == "skill" for cmd in app.bot.commands)
|
||||
assert any(cmd.command == "dream" for cmd in app.bot.commands)
|
||||
assert any(cmd.command == "dream_log" for cmd in app.bot.commands)
|
||||
@@ -2532,8 +2531,8 @@ async def test_forward_command_normalizes_telegram_safe_dream_aliases() -> None:
|
||||
|
||||
def test_telegram_bus_slash_command_regex_matches_agent_loop_commands() -> None:
|
||||
pat = TelegramChannel.TELEGRAM_BUS_SLASH_COMMAND_RE
|
||||
assert pat.fullmatch("/history")
|
||||
assert pat.fullmatch("/history 5")
|
||||
assert pat.fullmatch("/dream_log")
|
||||
assert pat.fullmatch("/dream_log abc123")
|
||||
assert pat.fullmatch("/goal ship the feature")
|
||||
assert pat.fullmatch("/trigger")
|
||||
assert pat.fullmatch("/trigger PR review")
|
||||
|
||||
@@ -5034,9 +5034,8 @@ async def test_commands_api_returns_slash_command_metadata(bus: MagicMock, start
|
||||
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["/dream-log"]["lifecycle"] == "side_channel"
|
||||
assert commands["/dream-log"]["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"])
|
||||
|
||||
@@ -6,7 +6,7 @@ import subprocess
|
||||
import sys
|
||||
from contextlib import suppress
|
||||
from dataclasses import replace
|
||||
from typing import TYPE_CHECKING, Any, cast
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from loguru import logger
|
||||
|
||||
@@ -71,14 +71,6 @@ CORE_COMMAND_SPECS: tuple[BuiltinCommandSpec, ...] = (
|
||||
"[preset]",
|
||||
accepts_args=True,
|
||||
),
|
||||
BuiltinCommandSpec(
|
||||
"/history",
|
||||
"Show conversation history",
|
||||
"Print the last N persisted conversation messages.",
|
||||
"history",
|
||||
"[n]",
|
||||
accepts_args=True,
|
||||
),
|
||||
BuiltinCommandSpec(
|
||||
"/trigger",
|
||||
"Create named local trigger",
|
||||
@@ -765,71 +757,6 @@ async def cmd_dream_restore(ctx: CommandContext) -> OutboundMessage:
|
||||
)
|
||||
|
||||
|
||||
_HISTORY_DEFAULT_COUNT = 10
|
||||
_HISTORY_MAX_COUNT = 50
|
||||
_HISTORY_MAX_CONTENT_CHARS = 200
|
||||
|
||||
|
||||
def _format_history_message(msg: dict[str, Any]) -> str | None:
|
||||
role = msg.get("role")
|
||||
if role not in ("user", "assistant"):
|
||||
return None
|
||||
content = msg.get("content") or ""
|
||||
if isinstance(content, list):
|
||||
parts = [
|
||||
text
|
||||
for block in cast(list[object], content)
|
||||
if (item := cast(dict[str, Any], block) if isinstance(block, dict) else None)
|
||||
and item.get("type") == "text"
|
||||
and isinstance(text := item.get("text"), str)
|
||||
]
|
||||
content = " ".join(parts)
|
||||
content = str(content).strip()
|
||||
if not content:
|
||||
return None
|
||||
if len(content) > _HISTORY_MAX_CONTENT_CHARS:
|
||||
content = content[:_HISTORY_MAX_CONTENT_CHARS] + "…"
|
||||
label = "👤 You" if role == "user" else "🤖 Bot"
|
||||
return f"{label}: {content}"
|
||||
|
||||
|
||||
async def cmd_history(ctx: CommandContext) -> OutboundMessage:
|
||||
"""Show the last N messages of the current session (default 10, max 50).
|
||||
|
||||
Usage: /history [count]
|
||||
"""
|
||||
count = _HISTORY_DEFAULT_COUNT
|
||||
if ctx.args.strip():
|
||||
try:
|
||||
count = max(1, min(int(ctx.args.strip()), _HISTORY_MAX_COUNT))
|
||||
except ValueError:
|
||||
return OutboundMessage(
|
||||
channel=ctx.msg.channel, chat_id=ctx.msg.chat_id,
|
||||
content="Usage: /history [count] — e.g. /history 5 (default: 10, max: 50)",
|
||||
metadata=dict(ctx.msg.metadata or {}),
|
||||
)
|
||||
|
||||
session = ctx.session or await ctx.loop.sessions.state.get(ctx.key)
|
||||
history = session.get_history(max_messages=0, include_runtime_context=False)
|
||||
visible = [_format_history_message(m) for m in history]
|
||||
visible = [m for m in visible if m is not None]
|
||||
recent = visible[-count:]
|
||||
|
||||
if not recent:
|
||||
return OutboundMessage(
|
||||
channel=ctx.msg.channel, chat_id=ctx.msg.chat_id,
|
||||
content="No conversation history yet.",
|
||||
metadata=dict(ctx.msg.metadata or {}),
|
||||
)
|
||||
|
||||
header = f"Last {len(recent)} message(s):\n"
|
||||
return OutboundMessage(
|
||||
channel=ctx.msg.channel, chat_id=ctx.msg.chat_id,
|
||||
content=header + "\n".join(recent),
|
||||
metadata={**dict(ctx.msg.metadata or {}), "render_as": "text"},
|
||||
)
|
||||
|
||||
|
||||
async def cmd_pairing(ctx: CommandContext) -> OutboundMessage:
|
||||
"""List, approve, deny or revoke pairing requests."""
|
||||
from nanobot.pairing import PAIRING_COMMAND_META_KEY, handle_pairing_command
|
||||
@@ -941,8 +868,6 @@ def register_core_commands(router: CommandRouter) -> None:
|
||||
router.exact("/status", cmd_status)
|
||||
router.exact("/model", cmd_model)
|
||||
router.prefix("/model ", cmd_model)
|
||||
router.exact("/history", cmd_history)
|
||||
router.prefix("/history ", cmd_history)
|
||||
router.exact("/trigger", cmd_trigger)
|
||||
router.prefix("/trigger ", cmd_trigger)
|
||||
router.exact("/dream", cmd_dream)
|
||||
|
||||
@@ -58,4 +58,4 @@ async def cmd_goal(ctx: CommandInput) -> CommandExpansion | OutboundMessage:
|
||||
def register_goal_command(router: CommandRouter) -> None:
|
||||
"""Register the exact usage and task-bearing forms of /goal."""
|
||||
router.input_command(GOAL_COMMAND, cmd_goal)
|
||||
router.add_spec(GOAL_COMMAND_SPEC, after="/history")
|
||||
router.add_spec(GOAL_COMMAND_SPEC, after="/model")
|
||||
@@ -347,93 +347,6 @@ class TestRestartCommand:
|
||||
assert "Context: 1k/200k (0% of input budget)" in response.content
|
||||
assert "Tasks: 0 active" in response.content
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_history_shows_recent_messages(self):
|
||||
loop, _bus = _make_loop()
|
||||
session = MagicMock()
|
||||
session.get_history.return_value = [
|
||||
{"role": "user", "content": "Hello"},
|
||||
{"role": "assistant", "content": "Hi there!"},
|
||||
{"role": "tool", "content": "tool result"},
|
||||
{"role": "user", "content": "How are you?"},
|
||||
{"role": "assistant", "content": "I am doing well."},
|
||||
]
|
||||
loop.sessions.state.get = AsyncMock(return_value=session)
|
||||
|
||||
msg = InboundMessage(channel="telegram", sender_id="u1", chat_id="c1", content="/history")
|
||||
response = await loop._process_message(msg)
|
||||
|
||||
assert response is not None
|
||||
assert "👤 You: Hello" in response.content
|
||||
assert "🤖 Bot: Hi there!" in response.content
|
||||
assert "tool result" not in response.content
|
||||
assert response.metadata == {"render_as": "text"}
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_history_respects_count_argument(self):
|
||||
loop, _bus = _make_loop()
|
||||
session = MagicMock()
|
||||
session.get_history.return_value = [
|
||||
{"role": "user", "content": f"message {i}"} for i in range(20)
|
||||
]
|
||||
loop.sessions.state.get = AsyncMock(return_value=session)
|
||||
|
||||
msg = InboundMessage(channel="telegram", sender_id="u1", chat_id="c1", content="/history 3")
|
||||
response = await loop._process_message(msg)
|
||||
|
||||
assert response is not None
|
||||
assert "Last 3 message(s)" in response.content
|
||||
assert "message 19" in response.content
|
||||
assert "message 0" not in response.content
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_history_clamps_count_and_extracts_text_blocks(self):
|
||||
loop, _bus = _make_loop()
|
||||
session = MagicMock()
|
||||
session.get_history.return_value = [
|
||||
{
|
||||
"role": "user",
|
||||
"content": [
|
||||
{"type": "text", "text": "visible text"},
|
||||
{"type": "image_url", "image_url": {"url": "data:image/png;base64,..."}},
|
||||
],
|
||||
},
|
||||
*({"role": "assistant", "content": f"reply {i}"} for i in range(60)),
|
||||
]
|
||||
loop.sessions.state.get = AsyncMock(return_value=session)
|
||||
|
||||
msg = InboundMessage(channel="telegram", sender_id="u1", chat_id="c1", content="/history 999")
|
||||
response = await loop._process_message(msg)
|
||||
|
||||
assert response is not None
|
||||
assert "Last 50 message(s)" in response.content
|
||||
assert "visible text" not in response.content
|
||||
assert "reply 59" in response.content
|
||||
assert "reply 9" not in response.content
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_history_invalid_count_returns_usage(self):
|
||||
loop, _bus = _make_loop()
|
||||
|
||||
msg = InboundMessage(channel="telegram", sender_id="u1", chat_id="c1", content="/history nope")
|
||||
response = await loop._process_message(msg)
|
||||
|
||||
assert response is not None
|
||||
assert response.content.startswith("Usage: /history [count]")
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_history_empty_session(self):
|
||||
loop, _bus = _make_loop()
|
||||
session = MagicMock()
|
||||
session.get_history.return_value = []
|
||||
loop.sessions.state.get = AsyncMock(return_value=session)
|
||||
|
||||
msg = InboundMessage(channel="telegram", sender_id="u1", chat_id="c1", content="/history")
|
||||
response = await loop._process_message(msg)
|
||||
|
||||
assert response is not None
|
||||
assert "No conversation history yet." in response.content
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_process_direct_preserves_render_metadata(self):
|
||||
loop, _bus = _make_loop()
|
||||
|
||||
@@ -391,5 +391,5 @@ def test_goal_command_in_help_and_palette() -> None:
|
||||
}
|
||||
commands = [item["command"] for item in palette]
|
||||
goal_index = commands.index("/goal")
|
||||
assert commands[goal_index - 1:goal_index + 2] == ["/history", "/goal", "/trigger"]
|
||||
assert commands[goal_index - 1:goal_index + 2] == ["/model", "/goal", "/trigger"]
|
||||
assert "/goal <goal>" in build_help_text()
|
||||
@@ -80,7 +80,7 @@ class TestIsDispatchableCommand:
|
||||
("content", "expected"),
|
||||
[
|
||||
("/status", False),
|
||||
("/history 5", False),
|
||||
("/dream-log abc123", False),
|
||||
("/goal", False),
|
||||
("/goal migrate the database", True),
|
||||
("regular prompt", True),
|
||||
|
||||
@@ -840,9 +840,9 @@ describe("NanobotTui composer", () => {
|
||||
}
|
||||
}
|
||||
ui.commandMenu.setCommands([{
|
||||
command: "/history",
|
||||
command: "/inspect",
|
||||
title: "History",
|
||||
description: "Show recent messages",
|
||||
description: "Inspect a session",
|
||||
argHint: "[n]",
|
||||
lifecycle: "side_channel",
|
||||
acceptsArgs: true,
|
||||
@@ -852,7 +852,7 @@ describe("NanobotTui composer", () => {
|
||||
expect(ui.commandMenu.visible).toBe(true)
|
||||
setup.mockInput.pressTab()
|
||||
|
||||
expect(ui.composer.plainText).toBe("/history ")
|
||||
expect(ui.composer.plainText).toBe("/inspect ")
|
||||
expect(ui.commandMenu.visible).toBe(false)
|
||||
expect(sent).toEqual([])
|
||||
})
|
||||
|
||||
@@ -1218,9 +1218,9 @@ describe("gateway protocol", () => {
|
||||
return Promise.resolve(new Response(JSON.stringify({
|
||||
commands: [
|
||||
{
|
||||
command: "/history",
|
||||
command: "/inspect",
|
||||
title: "History",
|
||||
description: "Show recent messages",
|
||||
description: "Inspect a session",
|
||||
arg_hint: "[n]",
|
||||
accepts_args: true,
|
||||
lifecycle: "side_channel",
|
||||
@@ -1232,9 +1232,9 @@ describe("gateway protocol", () => {
|
||||
|
||||
try {
|
||||
expect(await fetchSlashCommands("http://nanobot.test", "secret")).toEqual([{
|
||||
command: "/history",
|
||||
command: "/inspect",
|
||||
title: "History",
|
||||
description: "Show recent messages",
|
||||
description: "Inspect a session",
|
||||
argHint: "[n]",
|
||||
lifecycle: "side_channel",
|
||||
acceptsArgs: true,
|
||||
|
||||
@@ -15,9 +15,9 @@ const commands: SlashCommand[] = [
|
||||
acceptsArgs: false,
|
||||
},
|
||||
{
|
||||
command: "/history",
|
||||
command: "/inspect",
|
||||
title: "History",
|
||||
description: "Show recent messages",
|
||||
description: "Inspect a session",
|
||||
argHint: "[n]",
|
||||
lifecycle: "side_channel",
|
||||
acceptsArgs: true,
|
||||
@@ -54,11 +54,11 @@ describe("CommandMenu", () => {
|
||||
|
||||
const frame = setup.captureCharFrame()
|
||||
expect(frame).toContain("› /help")
|
||||
expect(frame).toContain("/history [n]")
|
||||
expect(frame).toContain("/inspect [n]")
|
||||
expect(menu.completion("/h")).toBe("/help")
|
||||
|
||||
expect(menu.move(1)).toBe(true)
|
||||
expect(menu.complete()).toBe("/history ")
|
||||
expect(menu.complete()).toBe("/inspect ")
|
||||
expect(menu.visible).toBe(false)
|
||||
})
|
||||
|
||||
@@ -100,7 +100,7 @@ describe("CommandMenu", () => {
|
||||
menu.setCommands(commands)
|
||||
menu.update("explain /help")
|
||||
expect(menu.visible).toBe(false)
|
||||
menu.update("/history 5")
|
||||
menu.update("/inspect 5")
|
||||
expect(menu.visible).toBe(false)
|
||||
})
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ export function installSubagentDockApi() {
|
||||
if (url.origin !== location.origin || !url.pathname.startsWith("/api/")) return original(input, init);
|
||||
if (url.pathname === "/api/settings") return Response.json(settings);
|
||||
if (url.pathname === "/api/commands") return Response.json({ commands: [
|
||||
{ command: "/history", title: "Chat history", description: "Show recent messages", icon: "history", lifecycle: "side_channel", accepts_args: true },
|
||||
{ command: "/inspect", title: "Inspect session", description: "Inspect a session", icon: "history", lifecycle: "side_channel", accepts_args: true },
|
||||
] });
|
||||
if (url.pathname.endsWith("/subagents")) return Response.json({ tasks: url.pathname.includes(encodeURIComponent(`websocket:${chatId}`)) ? tasks : [] });
|
||||
if (url.pathname.includes("/subagents/") && url.pathname.endsWith("/webui-thread")) {
|
||||
|
||||
@@ -702,7 +702,7 @@ for (const width of [1440, 390]) {
|
||||
await trigger.click();
|
||||
await settledMotion(page.getByTestId("subagent-task-dock"));
|
||||
const input = page.getByRole("textbox").first();
|
||||
for (const [query, inserted] of [["/", "/history"], ["@ref", "@reference "]]) {
|
||||
for (const [query, inserted] of [["/", "/inspect"], ["@ref", "@reference "]]) {
|
||||
await input.fill(query);
|
||||
const option = page.getByRole("option").first();
|
||||
await expect(option).toBeVisible();
|
||||
|
||||
@@ -296,7 +296,7 @@ const COMMAND_ICONS: Record<string, LucideIcon> = {
|
||||
const BUILTIN_COMMAND_ICONS: Record<string, LucideIcon> = {
|
||||
"/new": NewChatIcon, "/compact": CompactIcon, "/stop": StopIcon,
|
||||
"/restart": RestartIcon, "/status": StatusIcon, "/model": ModelsIcon,
|
||||
"/history": HistoryIcon, "/goal": GoalIcon, "/trigger": TriggerIcon,
|
||||
"/goal": GoalIcon, "/trigger": TriggerIcon,
|
||||
"/dream": DreamIcon, "/dream-log": DreamLogIcon, "/dream-restore": RestoreMemoryIcon,
|
||||
"/dream-prompt": PromptTemplateIcon, "/evaluator-prompt": PromptTemplateIcon,
|
||||
"/skill": SkillsIcon, "/help": HelpIcon, "/pairing": PairingIcon,
|
||||
@@ -1007,8 +1007,6 @@ export function ThreadComposer({
|
||||
: t("thread.composer.slash.details.goalReady");
|
||||
} else if (command.command === "/stop" && isStreaming) {
|
||||
detail = t("thread.composer.slash.details.stopRunning");
|
||||
} else if (command.command === "/history") {
|
||||
detail = t("thread.composer.slash.details.history");
|
||||
}
|
||||
return {
|
||||
...command,
|
||||
|
||||
@@ -2215,7 +2215,6 @@
|
||||
"details": {
|
||||
"goalActive": "Goal is running",
|
||||
"goalReady": "Start a sustained objective",
|
||||
"history": "Show recent messages",
|
||||
"stopRunning": "Running now"
|
||||
},
|
||||
"commands": {
|
||||
@@ -2243,10 +2242,6 @@
|
||||
"title": "Model",
|
||||
"description": "View or switch the current model preset."
|
||||
},
|
||||
"history": {
|
||||
"title": "Chat history",
|
||||
"description": "Show the last N saved messages."
|
||||
},
|
||||
"dream": {
|
||||
"title": "Run Dream",
|
||||
"description": "Organize memory now."
|
||||
|
||||
@@ -2051,10 +2051,6 @@
|
||||
"title": "Modelo",
|
||||
"description": "Consulta o cambia el preajuste de modelo actual."
|
||||
},
|
||||
"history": {
|
||||
"title": "Historial del chat",
|
||||
"description": "Muestra los últimos N mensajes guardados."
|
||||
},
|
||||
"dream": {
|
||||
"title": "Ejecutar Dream",
|
||||
"description": "Organiza la memoria ahora."
|
||||
@@ -2095,7 +2091,6 @@
|
||||
"details": {
|
||||
"goalActive": "El objetivo está en curso",
|
||||
"goalReady": "Iniciar un objetivo sostenido",
|
||||
"history": "Mostrar mensajes recientes",
|
||||
"stopRunning": "En ejecución"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -2051,10 +2051,6 @@
|
||||
"title": "Modèle",
|
||||
"description": "Consultez ou changez le préréglage de modèle actuel."
|
||||
},
|
||||
"history": {
|
||||
"title": "Historique de discussion",
|
||||
"description": "Affichez les N derniers messages enregistrés."
|
||||
},
|
||||
"dream": {
|
||||
"title": "Lancer Dream",
|
||||
"description": "Organisez la mémoire maintenant."
|
||||
@@ -2095,7 +2091,6 @@
|
||||
"details": {
|
||||
"goalActive": "L’objectif est en cours",
|
||||
"goalReady": "Démarrer un objectif durable",
|
||||
"history": "Afficher les messages récents",
|
||||
"stopRunning": "En cours"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -2051,10 +2051,6 @@
|
||||
"title": "Model",
|
||||
"description": "Lihat atau ganti preset model saat ini."
|
||||
},
|
||||
"history": {
|
||||
"title": "Riwayat chat",
|
||||
"description": "Tampilkan N pesan terakhir yang tersimpan."
|
||||
},
|
||||
"dream": {
|
||||
"title": "Jalankan Dream",
|
||||
"description": "Atur memori sekarang."
|
||||
@@ -2095,7 +2091,6 @@
|
||||
"details": {
|
||||
"goalActive": "Tujuan sedang berjalan",
|
||||
"goalReady": "Mulai tujuan berkelanjutan",
|
||||
"history": "Tampilkan pesan terbaru",
|
||||
"stopRunning": "Sedang berjalan"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -2051,10 +2051,6 @@
|
||||
"title": "モデル",
|
||||
"description": "現在のモデルプリセットを確認・切り替えます。"
|
||||
},
|
||||
"history": {
|
||||
"title": "会話の履歴",
|
||||
"description": "保存済みメッセージの直近 N 件を表示します。"
|
||||
},
|
||||
"dream": {
|
||||
"title": "Dream を実行",
|
||||
"description": "メモリーを今すぐ整理します。"
|
||||
@@ -2095,7 +2091,6 @@
|
||||
"details": {
|
||||
"goalActive": "目標が実行中",
|
||||
"goalReady": "継続的な目標を開始",
|
||||
"history": "最近のメッセージを表示",
|
||||
"stopRunning": "実行中"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -2051,10 +2051,6 @@
|
||||
"title": "모델",
|
||||
"description": "현재 모델 프리셋을 확인하거나 전환합니다."
|
||||
},
|
||||
"history": {
|
||||
"title": "대화 기록",
|
||||
"description": "저장된 최근 N개 메시지를 표시합니다."
|
||||
},
|
||||
"dream": {
|
||||
"title": "Dream 실행",
|
||||
"description": "메모리를 지금 정리합니다."
|
||||
@@ -2095,7 +2091,6 @@
|
||||
"details": {
|
||||
"goalActive": "목표 실행 중",
|
||||
"goalReady": "지속 목표 시작",
|
||||
"history": "최근 메시지 보기",
|
||||
"stopRunning": "실행 중"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -2035,7 +2035,6 @@
|
||||
"details": {
|
||||
"goalActive": "Objetivo em execução",
|
||||
"goalReady": "Iniciar um objetivo sustentado",
|
||||
"history": "Mostrar mensagens recentes",
|
||||
"stopRunning": "Executando agora"
|
||||
},
|
||||
"commands": {
|
||||
@@ -2063,10 +2062,6 @@
|
||||
"title": "Modelo",
|
||||
"description": "Veja ou troque o preset de modelo atual."
|
||||
},
|
||||
"history": {
|
||||
"title": "Histórico da conversa",
|
||||
"description": "Mostre as últimas N mensagens salvas."
|
||||
},
|
||||
"dream": {
|
||||
"title": "Executar Dream",
|
||||
"description": "Organize a memória agora."
|
||||
|
||||
@@ -2051,10 +2051,6 @@
|
||||
"title": "Mô hình",
|
||||
"description": "Xem hoặc đổi bộ thiết lập mô hình hiện tại."
|
||||
},
|
||||
"history": {
|
||||
"title": "Lịch sử trò chuyện",
|
||||
"description": "Hiện N tin nhắn đã lưu gần nhất."
|
||||
},
|
||||
"dream": {
|
||||
"title": "Chạy Dream",
|
||||
"description": "Sắp xếp bộ nhớ ngay."
|
||||
@@ -2095,7 +2091,6 @@
|
||||
"details": {
|
||||
"goalActive": "Mục tiêu đang chạy",
|
||||
"goalReady": "Bắt đầu mục tiêu duy trì",
|
||||
"history": "Hiển thị tin nhắn gần đây",
|
||||
"stopRunning": "Đang chạy"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -2215,7 +2215,6 @@
|
||||
"details": {
|
||||
"goalActive": "目标正在运行",
|
||||
"goalReady": "开始一个持续目标",
|
||||
"history": "查看最近消息",
|
||||
"stopRunning": "正在运行"
|
||||
},
|
||||
"commands": {
|
||||
@@ -2243,10 +2242,6 @@
|
||||
"title": "模型",
|
||||
"description": "查看或切换当前模型预设"
|
||||
},
|
||||
"history": {
|
||||
"title": "对话记录",
|
||||
"description": "查看最近 N 条已保存的消息"
|
||||
},
|
||||
"dream": {
|
||||
"title": "运行 Dream",
|
||||
"description": "手动整理记忆"
|
||||
|
||||
@@ -2051,10 +2051,6 @@
|
||||
"title": "模型",
|
||||
"description": "檢視或切換當前模型預設"
|
||||
},
|
||||
"history": {
|
||||
"title": "對話記錄",
|
||||
"description": "檢視最近 N 條已儲存的訊息"
|
||||
},
|
||||
"dream": {
|
||||
"title": "執行 Dream",
|
||||
"description": "手動整理記憶"
|
||||
@@ -2095,7 +2091,6 @@
|
||||
"details": {
|
||||
"goalActive": "目標正在執行",
|
||||
"goalReady": "開始一個持續目標",
|
||||
"history": "檢視最近訊息",
|
||||
"stopRunning": "正在執行"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1399,9 +1399,9 @@ describe("webui API helpers", () => {
|
||||
accepts_args: false,
|
||||
},
|
||||
{
|
||||
command: "/history",
|
||||
title: "Show conversation history",
|
||||
description: "Print the last N messages.",
|
||||
command: "/inspect",
|
||||
title: "Inspect session",
|
||||
description: "Inspect a session.",
|
||||
icon: "history",
|
||||
arg_hint: "[n]",
|
||||
lifecycle: "side_channel",
|
||||
@@ -1437,9 +1437,9 @@ describe("webui API helpers", () => {
|
||||
acceptsArgs: false,
|
||||
},
|
||||
{
|
||||
command: "/history",
|
||||
title: "Show conversation history",
|
||||
description: "Print the last N messages.",
|
||||
command: "/inspect",
|
||||
title: "Inspect session",
|
||||
description: "Inspect a session.",
|
||||
icon: "history",
|
||||
argHint: "[n]",
|
||||
lifecycle: "side_channel",
|
||||
|
||||
@@ -28,7 +28,6 @@ const SLASH_COMMAND_KEYS = [
|
||||
"restart",
|
||||
"status",
|
||||
"model",
|
||||
"history",
|
||||
"dream",
|
||||
"dream_log",
|
||||
"dream_restore",
|
||||
@@ -629,7 +628,6 @@ describe("webui i18n", () => {
|
||||
expect(slash.badges.recent).toBeTruthy();
|
||||
expect(slash.details.goalActive).toBeTruthy();
|
||||
expect(slash.details.goalReady).toBeTruthy();
|
||||
expect(slash.details.history).toBeTruthy();
|
||||
expect(slash.details.stopRunning).toBeTruthy();
|
||||
for (const key of SLASH_COMMAND_KEYS) {
|
||||
const command = slash.commands[key as keyof typeof slash.commands];
|
||||
|
||||
@@ -50,9 +50,9 @@ const COMMANDS: SlashCommand[] = [
|
||||
acceptsArgs: false,
|
||||
},
|
||||
{
|
||||
command: "/history",
|
||||
title: "Show conversation history",
|
||||
description: "Print the last N persisted messages.",
|
||||
command: "/inspect",
|
||||
title: "Inspect session",
|
||||
description: "Inspect a session.",
|
||||
icon: "history",
|
||||
argHint: "[n]",
|
||||
lifecycle: "side_channel",
|
||||
@@ -490,13 +490,13 @@ describe("ThreadComposer", () => {
|
||||
|
||||
const input = screen.getByLabelText("Message input");
|
||||
fireEvent.change(input, { target: { value: "/" } });
|
||||
expect(screen.getByRole("option", { name: /\/history/i })).toHaveAttribute(
|
||||
expect(screen.getByRole("option", { name: /\/inspect/i })).toHaveAttribute(
|
||||
"aria-selected",
|
||||
"true",
|
||||
);
|
||||
fireEvent.keyDown(input, { key: "Enter" });
|
||||
|
||||
expect(input).toHaveValue("/history ");
|
||||
expect(input).toHaveValue("/inspect ");
|
||||
expect(onSend).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -1714,15 +1714,15 @@ describe("ThreadComposer", () => {
|
||||
expect(palette).toBeInTheDocument();
|
||||
expect(palette).toHaveStyle({ maxHeight: "288px" });
|
||||
expect(screen.queryByRole("option", { name: /\/stop/i })).not.toBeInTheDocument();
|
||||
expect(screen.getByRole("option", { name: /\/history/i })).toHaveAttribute(
|
||||
expect(screen.getByRole("option", { name: /\/inspect/i })).toHaveAttribute(
|
||||
"aria-selected",
|
||||
"true",
|
||||
);
|
||||
fireEvent.keyDown(input, { key: "Enter" });
|
||||
|
||||
expect(input).toHaveValue("/history ");
|
||||
expect(screen.getByTestId("composer-slash-command")).toHaveTextContent("/history");
|
||||
expect(input.previousElementSibling?.textContent).toBe("/history ");
|
||||
expect(input).toHaveValue("/inspect ");
|
||||
expect(screen.getByTestId("composer-slash-command")).toHaveTextContent("/inspect");
|
||||
expect(input.previousElementSibling?.textContent).toBe("/inspect ");
|
||||
expect(onSend).not.toHaveBeenCalled();
|
||||
expect(screen.queryByRole("listbox", { name: "Slash commands" })).not.toBeInTheDocument();
|
||||
});
|
||||
@@ -1807,7 +1807,7 @@ describe("ThreadComposer", () => {
|
||||
});
|
||||
|
||||
it("orders recent slash commands first for the blank slash menu", () => {
|
||||
window.localStorage.setItem("nanobot.webui.slashCommandRecents", JSON.stringify(["/history"]));
|
||||
window.localStorage.setItem("nanobot.webui.slashCommandRecents", JSON.stringify(["/inspect"]));
|
||||
render(
|
||||
<ThreadComposer
|
||||
onSend={vi.fn()}
|
||||
@@ -1820,7 +1820,7 @@ describe("ThreadComposer", () => {
|
||||
target: { value: "/" },
|
||||
});
|
||||
|
||||
expect(screen.getByRole("option", { name: /\/history/i })).toHaveAttribute(
|
||||
expect(screen.getByRole("option", { name: /\/inspect/i })).toHaveAttribute(
|
||||
"aria-selected",
|
||||
"true",
|
||||
);
|
||||
@@ -2419,12 +2419,12 @@ describe("ThreadComposer", () => {
|
||||
const onSend = vi.fn();
|
||||
render(<ThreadComposer onSend={onSend} slashCommands={COMMANDS} />);
|
||||
const input = screen.getByLabelText("Message input") as HTMLTextAreaElement;
|
||||
const text = "/history $workflow 中文 English";
|
||||
const text = "/inspect $workflow 中文 English";
|
||||
fireEvent.change(input, { target: { value: text, selectionStart: text.length } });
|
||||
|
||||
const command = screen.getByTestId("composer-slash-command");
|
||||
const skill = screen.getByTestId("composer-skill-reference-workflow");
|
||||
expect(command).toHaveTextContent("/history");
|
||||
expect(command).toHaveTextContent("/inspect");
|
||||
expect(command.className).toBe(skill.className);
|
||||
expect(command.getAttribute("style")).toBe(skill.getAttribute("style"));
|
||||
expect(input.previousElementSibling).toHaveAttribute("aria-hidden", "true");
|
||||
@@ -2433,15 +2433,15 @@ describe("ThreadComposer", () => {
|
||||
input.setSelectionRange(1, 4);
|
||||
const setData = vi.fn();
|
||||
fireEvent.copy(input, { clipboardData: { setData } });
|
||||
expect(setData).toHaveBeenCalledWith("text/plain", "his");
|
||||
expect(setData).toHaveBeenCalledWith("text/plain", "ins");
|
||||
fireEvent.cut(input, { clipboardData: { setData } });
|
||||
expect(input).toHaveValue("/tory $workflow 中文 English");
|
||||
expect(input).toHaveValue("/pect $workflow 中文 English");
|
||||
expect(screen.queryByTestId("composer-slash-command")).not.toBeInTheDocument();
|
||||
fireEvent.keyDown(input, { key: "z", ctrlKey: true });
|
||||
expect(input).toHaveValue(text);
|
||||
expect(input.selectionStart).toBe(1);
|
||||
expect(input.selectionEnd).toBe(4);
|
||||
expect(screen.getByTestId("composer-slash-command")).toHaveTextContent("/history");
|
||||
expect(screen.getByTestId("composer-slash-command")).toHaveTextContent("/inspect");
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "Send message" }));
|
||||
expect(onSend).toHaveBeenCalledWith(text, undefined, { sideChannel: true });
|
||||
@@ -2495,14 +2495,14 @@ describe("ThreadComposer", () => {
|
||||
expect(onSend).toHaveBeenCalledWith(command.trim(), undefined, { sideChannel: true, userShell: true });
|
||||
});
|
||||
|
||||
it.each(["", "/history "])("mirrors inline references during composition without submitting the IME confirmation: %s", (prefix) => {
|
||||
it.each(["", "/inspect "])("mirrors inline references during composition without submitting the IME confirmation: %s", (prefix) => {
|
||||
const onSend = vi.fn();
|
||||
render(<ThreadComposer onSend={onSend} slashCommands={COMMANDS} />);
|
||||
const input = screen.getByLabelText("Message input") as HTMLTextAreaElement;
|
||||
fireEvent.change(input, { target: { value: `${prefix}$workflow ` } });
|
||||
fireEvent.compositionStart(input);
|
||||
fireEvent.change(input, { target: { value: `${prefix}$workflow zhong` } });
|
||||
if (prefix) expect(screen.getByTestId("composer-slash-command")).toHaveTextContent("/history");
|
||||
if (prefix) expect(screen.getByTestId("composer-slash-command")).toHaveTextContent("/inspect");
|
||||
expect(screen.getByTestId("composer-skill-reference-workflow")).toHaveTextContent(/^\$workflow$/);
|
||||
expect(input.previousElementSibling?.textContent).toBe(input.value);
|
||||
expect(input.previousElementSibling).toHaveClass("z-20");
|
||||
@@ -3237,10 +3237,10 @@ describe("ThreadComposer", () => {
|
||||
);
|
||||
|
||||
const input = screen.getByLabelText("Message input");
|
||||
fireEvent.change(input, { target: { value: "/history" } });
|
||||
fireEvent.change(input, { target: { value: "/inspect" } });
|
||||
fireEvent.click(screen.getByRole("button", { name: "Send message" }));
|
||||
|
||||
expect(onSend).toHaveBeenCalledWith("/history", undefined, { sideChannel: true });
|
||||
expect(onSend).toHaveBeenCalledWith("/inspect", undefined, { sideChannel: true });
|
||||
});
|
||||
|
||||
it("does not infer side-channel behavior before command metadata loads", () => {
|
||||
@@ -3497,10 +3497,10 @@ describe("ThreadComposer", () => {
|
||||
it("does not mark side-channel commands as guidance during an active turn", () => {
|
||||
const onSend = vi.fn();
|
||||
render(<ThreadComposer onSend={onSend} onStop={vi.fn()} isStreaming slashCommands={COMMANDS} />);
|
||||
fireEvent.change(screen.getByLabelText("Message input"), { target: { value: "/history 5" } });
|
||||
fireEvent.change(screen.getByLabelText("Message input"), { target: { value: "/inspect 5" } });
|
||||
fireEvent.click(screen.getByRole("button", { name: "Send message" }));
|
||||
|
||||
expect(onSend).toHaveBeenCalledWith("/history 5", undefined, { sideChannel: true });
|
||||
expect(onSend).toHaveBeenCalledWith("/inspect 5", undefined, { sideChannel: true });
|
||||
});
|
||||
|
||||
it("keeps Stop available while a draft attachment is encoding", () => {
|
||||
@@ -3574,7 +3574,7 @@ describe("ThreadComposer", () => {
|
||||
},
|
||||
);
|
||||
|
||||
it.each(["/history 5", "/stop now", "/STOP@nanobot now"])(
|
||||
it.each(["/inspect 5", "/stop now", "/STOP@nanobot now"])(
|
||||
"sends registered command %s to the gateway without queuing it",
|
||||
(content) => {
|
||||
const onSend = vi.fn();
|
||||
|
||||
@@ -5478,9 +5478,9 @@ describe("ThreadShell", () => {
|
||||
return httpJson({
|
||||
commands: [
|
||||
{
|
||||
command: "/history",
|
||||
title: "Show conversation history",
|
||||
description: "Print the last N persisted messages.",
|
||||
command: "/inspect",
|
||||
title: "Inspect session",
|
||||
description: "Inspect a session.",
|
||||
icon: "history",
|
||||
arg_hint: "[n]",
|
||||
lifecycle: "side_channel",
|
||||
@@ -5520,7 +5520,7 @@ describe("ThreadShell", () => {
|
||||
});
|
||||
|
||||
expect(screen.getByRole("listbox", { name: "Slash commands" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("option", { name: /\/history/i })).toBeInTheDocument();
|
||||
expect(screen.getByRole("option", { name: /\/inspect/i })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("surfaces a dismissible banner for an uncorrelated message_too_big error", async () => {
|
||||
|
||||
Reference in new issue
Block a user