fix(tui): preserve slash command semantics

This commit is contained in:
Xubin Ren
2026-08-17 20:56:10 +08:00
parent 2b666934ba
commit b3c3a82075
9 changed files with 349 additions and 57 deletions
+19
View File
@@ -238,6 +238,7 @@ describe("gateway protocol", () => {
title: "History",
description: "Show recent messages",
argHint: "[n]",
lifecycle: "side_channel",
acceptsArgs: true,
}])
expect(authorization).toBe("Bearer secret")
@@ -246,6 +247,24 @@ describe("gateway protocol", () => {
}
})
test("drops slash commands with unknown lifecycle metadata", async () => {
const original = globalThis.fetch
globalThis.fetch = (() => Promise.resolve(new Response(JSON.stringify({
commands: [{
command: "/future",
title: "Future",
description: "Unknown lifecycle",
lifecycle: "future_mode",
}],
})))) as unknown as typeof fetch
try {
expect(await fetchSlashCommands("http://nanobot.test", "secret")).toEqual([])
} finally {
globalThis.fetch = original
}
})
test("loads and normalizes WebUI sessions", async () => {
const original = globalThis.fetch
globalThis.fetch = (() => Promise.resolve(new Response(JSON.stringify({