Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix(tui): submit prompts with Kitty keypad Enter
dajiaohuangc20a0dad70ac
diff --git a/tui/src/app/composer.test.ts b/tui/src/app/composer.test.tsindex 033f90e5e..ef8c3c484 100644--- a/tui/src/app/composer.test.ts+++ b/tui/src/app/composer.test.ts@@ -52,6 +52,35 @@ describe("NanobotTui composer", () => {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 () => {const sent: string[] = []setup = await createRenderer({diff --git a/tui/src/app/layout.ts b/tui/src/app/layout.tsindex 027d1fd58..b99d16c16 100644--- a/tui/src/app/layout.ts+++ b/tui/src/app/layout.ts@@ -138,9 +138,13 @@ export function createAppLayout({ name: "return", shift: true, action: "newline" },{ name: "return", meta: 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: "linefeed", action: "newline" },{ name: "return", action: "submit" },+ { name: "kpenter", action: "submit" },],onCursorChange: handlers.onComposerCursorChange,onContentChange: handlers.onComposerContentChange,