fix(tui): prioritize slash command name matches
This commit is contained in:
1 parent
33aa70e4a5
commit
5c71b87a3f
3 files changed
+85
-2
No files matched your search
@@ -5,6 +5,8 @@ import { NanobotTui } from "./app"
|
||||
import type { MessageOptions, SkillCandidate, SlashCommand } from "../client"
|
||||
import type { ClipboardImageReader } from "../composer/clipboard-image"
|
||||
import { options, client, mount, waitUntil, occurrences } from "./test-support"
|
||||
import { LOCAL_COMMANDS } from "./commands"
|
||||
import type { CommandMenu } from "../menus/command-menu"
|
||||
|
||||
describe("NanobotTui composer", () => {
|
||||
let setup: TestRendererSetup | undefined
|
||||
@@ -680,6 +682,37 @@ describe("NanobotTui composer", () => {
|
||||
expect(sent).toEqual([])
|
||||
})
|
||||
|
||||
test.each(["enter", "tab"])("completes /se to /sessions with %s", async (key) => {
|
||||
setup = await createRenderer({ width: 80, height: 24, screenMode: "alternate-screen" })
|
||||
const sent: string[] = []
|
||||
const app = mount(setup, sent)
|
||||
app.accept({ event: "attached", chat_id: "chat" })
|
||||
const ui = app as unknown as {
|
||||
ready: boolean
|
||||
composer: TextareaRenderable
|
||||
commandMenu: CommandMenu
|
||||
}
|
||||
await waitUntil(() => ui.ready)
|
||||
ui.commandMenu.setCommands([{
|
||||
command: "/model",
|
||||
title: "Switch model preset",
|
||||
description: "Show or switch the active model preset.",
|
||||
argHint: "[preset]",
|
||||
lifecycle: "side_channel",
|
||||
acceptsArgs: true,
|
||||
}], LOCAL_COMMANDS)
|
||||
|
||||
await setup.mockInput.typeText("/se")
|
||||
await setup.renderOnce()
|
||||
expect(setup.captureCharFrame()).toContain("› /sessions")
|
||||
if (key === "enter") setup.mockInput.pressEnter()
|
||||
else setup.mockInput.pressTab()
|
||||
await waitUntil(() => ui.composer.plainText !== "/se")
|
||||
|
||||
expect(ui.composer.plainText).toBe("/sessions")
|
||||
expect(sent).toEqual([])
|
||||
})
|
||||
|
||||
test("completes available skills with arrows, Enter, Tab, and Escape", async () => {
|
||||
setup = await createRenderer({ width: 80, height: 24, screenMode: "alternate-screen" })
|
||||
const sent: string[] = []
|
||||
|
||||
Reference in new issue
Block a user