docs: fix kitty Ctrl+C exit handling in plan

- useInput now calls app.exit() for kitty Ctrl+C when exitOnCtrlC=true
- Add PTY test and fixture branch for kittyCtrlCExit scenario

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Yunfei He
2026-05-27 14:21:48 +08:00
parent 95b14d4b48
commit df8d74a91e
@@ -389,7 +389,10 @@ Replace the entire `listener` function body in `packages/runtime/src/composables
key.shift = true;
}
// exitOnCtrlC: intercept kitty Ctrl+C (\x1b[3;5u). Legacy \x03 is caught
// by emitInput in createStdinController and never reaches useInput.
if (input === "c" && key.ctrl && stdin?.internal_exitOnCtrlC) {
app!.exit();
return;
}
@@ -1208,10 +1211,21 @@ const KittyInput = defineComponent({
},
});
const app = createApp(KittyInput, { test: process.argv[2] });
app.mount();
await app.waitUntilExit();
console.log("exited");
const testName = process.argv[2];
// kittyCtrlCExit: exitOnCtrlC=true (default), kitty Ctrl+C should trigger exit
// The useInput handler should NOT be called because the exitOnCtrlC guard fires first
if (testName === "kittyCtrlCExit") {
const app = createApp(KittyInput, { test: testName });
app.mount({ exitOnCtrlC: true });
await app.waitUntilExit();
console.log("exited");
} else {
const app = createApp(KittyInput, { test: testName });
app.mount({ exitOnCtrlC: false });
await app.waitUntilExit();
console.log("exited");
}
```
- [ ] **Step 2: Commit**
@@ -1380,6 +1394,16 @@ it("useInput - kitty protocol ctrl+letter via codepoint 1-26 produces input", as
expect(ps.output).toContain("exited");
});
// --- Kitty Ctrl+C with exitOnCtrlC ---
it("useInput - kitty Ctrl+C exits app when exitOnCtrlC is true", async () => {
// Default exitOnCtrlC=true, kitty Ctrl+C should exit the app
const ps = term("use-input-kitty", ["kittyCtrlCExit"]);
ps.write(kittyKey(3, 5)); // codepoint 3, modifier 5 = ctrl(4)+1
await ps.waitForExit();
expect(ps.output).toContain("exited");
});
// --- Query response suppression ---
it("useInput - query response is silently ignored, next real key works", async () => {