fix(tui): submit prompts with Kitty keypad Enter
This commit is contained in:
1 parent
d045285ced
commit
c20a0dad70
2 files changed
+33
No files matched your search
@@ -52,6 +52,35 @@ describe("NanobotTui composer", () => {
|
|||||||
expect(composer.plainText).toBe("next")
|
expect(composer.plainText).toBe("next")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("submits with keypad Enter and keeps its modified forms as newlines", async () => {
|
||||||
|
const sent: string[] = []
|
||||||
|
setup = await createRenderer({
|
||||||
|
width: 72,
|
||||||
|
height: 20,
|
||||||
|
screenMode: "alternate-screen",
|
||||||
|
kittyKeyboard: true,
|
||||||
|
})
|
||||||
|
const app = mount(setup, sent)
|
||||||
|
app.accept({ event: "attached", chat_id: "chat" })
|
||||||
|
await waitUntil(() => (app as unknown as { ready: boolean }).ready)
|
||||||
|
const composer = (app as unknown as { composer: TextareaRenderable }).composer
|
||||||
|
|
||||||
|
await setup.mockInput.typeText("11111")
|
||||||
|
await setup.mockInput.pressKeys(["\u001b[57414u"])
|
||||||
|
await waitUntil(() => sent.length === 1)
|
||||||
|
expect(sent).toEqual(["11111"])
|
||||||
|
|
||||||
|
app.accept({ event: "turn_end", chat_id: "chat" })
|
||||||
|
for (const modifier of [2, 3, 5]) {
|
||||||
|
composer.setText("first")
|
||||||
|
composer.cursorOffset = 5
|
||||||
|
await setup.mockInput.pressKeys([`\u001b[57414;${modifier}u`])
|
||||||
|
await setup.mockInput.typeText("second")
|
||||||
|
expect(composer.plainText).toBe("first\nsecond")
|
||||||
|
expect(sent).toEqual(["11111"])
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
test("inserts newlines with Shift+Enter and the universal Ctrl+J fallback", async () => {
|
test("inserts newlines with Shift+Enter and the universal Ctrl+J fallback", async () => {
|
||||||
const sent: string[] = []
|
const sent: string[] = []
|
||||||
setup = await createRenderer({
|
setup = await createRenderer({
|
||||||
|
|||||||
@@ -138,9 +138,13 @@ export function createAppLayout(
|
|||||||
{ name: "return", shift: true, action: "newline" },
|
{ name: "return", shift: true, action: "newline" },
|
||||||
{ name: "return", meta: true, action: "newline" },
|
{ name: "return", meta: true, action: "newline" },
|
||||||
{ name: "return", ctrl: true, action: "newline" },
|
{ name: "return", ctrl: true, action: "newline" },
|
||||||
|
{ name: "kpenter", shift: true, action: "newline" },
|
||||||
|
{ name: "kpenter", meta: true, action: "newline" },
|
||||||
|
{ name: "kpenter", ctrl: true, action: "newline" },
|
||||||
{ name: "j", ctrl: true, action: "newline" },
|
{ name: "j", ctrl: true, action: "newline" },
|
||||||
{ name: "linefeed", action: "newline" },
|
{ name: "linefeed", action: "newline" },
|
||||||
{ name: "return", action: "submit" },
|
{ name: "return", action: "submit" },
|
||||||
|
{ name: "kpenter", action: "submit" },
|
||||||
],
|
],
|
||||||
onCursorChange: handlers.onComposerCursorChange,
|
onCursorChange: handlers.onComposerCursorChange,
|
||||||
onContentChange: handlers.onComposerContentChange,
|
onContentChange: handlers.onComposerContentChange,
|
||||||
|
|||||||
Reference in new issue
Block a user