Skip to content

Commit 0bcff2a

Browse files
committed
feat(plugin): clarify release binding requirements
Address review: release bindings register but only fire when the terminal reports key releases, which the TUI does not enable today. Document that on bind, and reject ID-less object binds with a clear error instead of the misleading inline message.
1 parent 598f2e4 commit 0bcff2a

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎packages/plugin/src/tui/context.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,11 @@ export interface KeymapCommand {
415415
readonly group?: string
416416
/** Enables or disables the command. */
417417
readonly enabled?: boolean | (() => boolean)
418-
/** Configures automatic binding, or disables it for a named command. */
418+
/**
419+
* Configures automatic binding, or disables it for a named command.
420+
* Release bindings only fire when the terminal reports key releases;
421+
* the TUI does not enable release reporting today.
422+
*/
419423
readonly bind?: false | string | { key: string; event?: "press" | "release" }
420424
/** Adds a named command to the command palette. */
421425
readonly palette?: true

‎packages/tui/src/context/keymap.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ function groupCommands(commands: readonly KeymapCommand[] = []) {
272272
}
273273
if (command.palette) throw new Error("Palette commands require an ID")
274274
if (command.slash) throw new Error("Slash commands require an ID")
275+
if (typeof command.bind === "object") throw new Error("Object keymap bindings require an ID")
275276
if (typeof command.bind !== "string") throw new Error("Inline keymap commands require bind")
276277
if (!command.bind) throw new Error("Keymap command bindings cannot be empty")
277278
result.inline.push({ ...command, id: undefined, bind: command.bind })

‎packages/tui/test/keymap.test.tsx‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,9 @@ test("layer object bindings carry release events", async () => {
168168
app.renderer.destroy()
169169
}
170170
})
171+
172+
test("object bindings without an ID fail validation", () => {
173+
expect(() => Keymap.validateCommands([{ bind: { key: "f9", event: "release" }, run() {} }])).toThrow(
174+
"Object keymap bindings require an ID",
175+
)
176+
})

0 commit comments

Comments
 (0)