From 9abd9594de92ac331b8161bdf1abc97b35d33e7e Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Thu, 30 Jul 2026 16:03:21 -0400 Subject: [PATCH] fix(simulation): mirror kitty keyboard protocol (#39741) --- packages/simulation/src/frontend/renderer.ts | 1 + packages/simulation/test/actions.test.ts | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/packages/simulation/src/frontend/renderer.ts b/packages/simulation/src/frontend/renderer.ts index f10f0ec076a..b20860c1ca4 100644 --- a/packages/simulation/src/frontend/renderer.ts +++ b/packages/simulation/src/frontend/renderer.ts @@ -41,6 +41,7 @@ export const create = Effect.fn("SimulationRenderer.create")(function* ( ...options, width: cols, height: rows, + kittyKeyboard: Boolean(options.useKittyKeyboard), ...(recording ? { stdout: recording as unknown as NodeJS.WriteStream, diff --git a/packages/simulation/test/actions.test.ts b/packages/simulation/test/actions.test.ts index 6841393373d..c5f60c8f52b 100644 --- a/packages/simulation/test/actions.test.ts +++ b/packages/simulation/test/actions.test.ts @@ -43,6 +43,25 @@ test("normalizes named keys for OpenTUI", async () => { ]) }) +test("headless input mirrors the configured kitty keyboard protocol", async () => { + await Effect.runPromise( + Effect.scoped( + Effect.gen(function* () { + const renderer = yield* SimulationRenderer.create({ useKittyKeyboard: {} }) + const harness = createHarness(renderer) + let key: { readonly name: string; readonly source: string } | undefined + renderer.keyInput.once("keypress", (event) => { + key = event + }) + + yield* execute(harness, { type: "ui.press", key: "escape" }) + + expect(key).toMatchObject({ name: "escape", source: "kitty" }) + }), + ), + ) +}) + test("clicks a target at relative coordinates through descendant text", async () => { await Effect.runPromise( Effect.scoped(