fix(tui): expose /exit in command menu

This commit is contained in:
Kail Tian
2026-08-19 20:43:57 +08:00
committed by chengyongru
parent ac13ad65cd
commit 1018bdb7fe
4 changed files with 68 additions and 3 deletions
+26
View File
@@ -93,6 +93,32 @@ describe("CommandMenu", () => {
})
})
test("discovers and completes the local exit action", async () => {
setup = await createTestRenderer({ width: 60, height: 12, screenMode: "alternate-screen" })
const menu = new CommandMenu(setup.renderer, {
text: "#FFFFFF",
muted: "#999999",
border: "#555555",
})
setup.renderer.root.add(menu.root)
menu.setCommands([], [{
command: "/exit",
title: "Exit",
description: "Close this terminal UI",
action: "exit",
}])
menu.update("/ex")
await setup.renderOnce()
expect(setup.captureCharFrame()).toContain("/exit")
expect(menu.completion("/ex")).toBe("/exit")
expect(menu.resolve("/exit")).toMatchObject({
source: "tui",
command: { action: "exit" },
})
})
test("resolves argument-sensitive command lifecycles", () => {
const goal: SlashCommand = {
command: "/goal",