feat: focus follows click, composer key intents

Remove focus reclaim (watchFocus/reclaim/timer), debug notice and the
Ctrl+C binding (Ctrl+C is copy). Add pure keyIntent (keys.js) and route
Enter/Escape/menu keys through it; bind ctrl-r, ctrl-enter, alt-enter,
escape. install.ps1: merge ctrl-shift-space into keys.json (backup),
relink wrong junction, warn on failed layout.switch.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
FactorandClaude Sonnet 5.5 committed 2026-11-19 11:10:01 +01:00
1 parent c05e252d79
commit 5761825ac8
4 files changed
+238 -129

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
// Pure key intents of the composer: what a key press means, given the state of
// the composer. No gpui, no herdr - main.js acts on the answer.
/**
* @typedef {"none"|"send"|"send_now"|"hold"|"newline"|"interrupt"|"close_menu"|"close_panel"|"open_panel"|"menu_up"|"menu_down"|"menu_accept"} Intent
*/
/**
* What a key press means.
*
* @param {{key:string, shift?:boolean, ctrl?:boolean, alt?:boolean, composing?:boolean}} e
* @param {{hasKeyboard:boolean, menuOpen:boolean, panelOpen:boolean, empty:boolean, status:string|null}} ctx
* @returns {Intent}
*/
export function keyIntent(e, ctx) {
// Only the copy whose own field has the keyboard acts; an IME in the middle
// of a composition owns the key.
if (!e || !ctx || !ctx.hasKeyboard || e.composing) return "none";
const key = String(e.key ?? "").toLowerCase();
if (key === "enter") {
if (e.ctrl) return "send_now";
if (e.alt) return "hold";
if (e.shift) return "newline";
return "send";
}
if (key === "escape") {
if (ctx.menuOpen) return "close_menu";
if (ctx.panelOpen) return "close_panel";
if (ctx.empty && ctx.status === "working") return "interrupt";
return "none";
}
if (key === "r" && e.ctrl && !e.alt && !e.shift) return "open_panel";
if (ctx.menuOpen) {
if (key === "tab") return "menu_accept";
if (key === "up" || key === "arrowup") return "menu_up";
if (key === "down" || key === "arrowdown") return "menu_down";
}
return "none";
}