fix(tui): preserve current keybind behavior

This commit is contained in:
Sebastian Herrlinger
2026-08-12 00:26:12 +00:00
committed by opencode-agent[bot]
parent eda6b3eb51
commit bf61c972a1
4 changed files with 17 additions and 18 deletions
+1 -1
View File
@@ -89,12 +89,12 @@ test("migrates tui and kv config into cli.json", async () => {
terminal: { title: false },
prompt: { editor: false, paste: "full" },
session: { sidebar: "hide", scrollbar: true, thinking: "show", grouping: "none" },
hints: { onboarding: false },
animations: false,
mouse: false,
})
expect(config).not.toHaveProperty("skipped_version")
expect(config).not.toHaveProperty("which_key")
expect(config).not.toHaveProperty("hints")
expect((await Bun.file(path.join(directory, "cli.json")).json()).keybinds).toEqual({
leader: "ctrl+o",
"app.exit": "ctrl+q",
+3 -1
View File
@@ -114,6 +114,7 @@ export const Definitions = {
"session.compact": keybind("<leader>c", "Compact the session"),
"session.cd": keybind("none", "Change working directory"),
"session.queued_prompts": keybind("<leader>q", "Manage queued prompts"),
"queued_prompt.delete": keybind("ctrl+d", "Delete queued prompt"),
"session.toggle.exploration_grouping": keybind("none", "Toggle related tool call grouping"),
"session.child.first": keybind("down", "Toggle subagent picker"),
"session.child.next": keybind("right", "Go to next child session"),
@@ -174,6 +175,7 @@ export const Definitions = {
"session.toggle.thinking": keybind("none", "Toggle thinking blocks visibility"),
"prompt.submit": keybind("none", "Submit prompt"),
"prompt.queue": keybind("alt+return", "Queue prompt"),
"prompt.editor_context.clear": keybind("none", "Clear editor context"),
"prompt.skills": keybind("none", "Open skill selector"),
"prompt.stash": keybind("none", "Stash prompt"),
@@ -183,7 +185,7 @@ export const Definitions = {
"prompt.clear": keybind("ctrl+c", "Clear input field"),
"prompt.paste": keybind({ key: "ctrl+v", preventDefault: false }, "Paste from clipboard"),
"input.submit": keybind("return", "Submit input"),
"input.newline": keybind("shift+return,ctrl+return,alt+return,ctrl+j", "Insert newline in input"),
"input.newline": keybind("shift+return,ctrl+return,ctrl+j", "Insert newline in input"),
"input.move.left": keybind("left,ctrl+b", "Move cursor left in input"),
"input.move.right": keybind("right,ctrl+f", "Move cursor right in input"),
"input.move.up": keybind("up", "Move cursor up in input"),
@@ -78,7 +78,6 @@ test("brackets navigate diff hunks", async () => {
await viewer.app.waitForFrame((frame) => frame.includes("const first"))
await viewer.app.waitFor(() => Boolean(findScrollBox(viewer.app.renderer.root)))
await viewer.app.flush()
expect(viewer.app.captureCharFrame()).toContain("@@ -20,3 +20,3 @@")
expect(countDiffs(viewer.app.renderer.root)).toBe(3)
const scroll = findScrollBox(viewer.app.renderer.root)!
const initial = scroll.scrollTop
+13 -15
View File
@@ -67,19 +67,19 @@ test("uses command IDs as keybind keys", () => {
).toBe(true)
})
test("preserves supported v1 keybind defaults", () => {
const legacy = Object.fromEntries(
Object.entries(Definitions).flatMap(([name, item]) => {
const command = CommandMap[name as keyof typeof CommandMap] ?? name
if (command === "app.heap_snapshot") return []
return [[command, item.default]]
}),
)
const current = Object.fromEntries(
Object.entries(TuiKeybind.Definitions).map(([name, item]) => [name, item.default]),
)
test("preserves migrated v1 keybind defaults", () => {
const pairs = [
["app.exit", "app_exit"],
["prompt.paste", "input_paste"],
["session.delete", "session_delete"],
["session.list", "session_list"],
["agent.list", "agent_list"],
] as const
expect(current).toMatchObject(legacy)
pairs.forEach(([command, name]) => {
expect(CommandMap[name]).toBe(command)
expect(TuiKeybind.Definitions[command].default).toEqual(Definitions[name].default)
})
})
test("accepts every v2-only named command ID", () => {
@@ -128,9 +128,7 @@ test("centralizes named command defaults and resolves explicit none", () => {
"diff.mark_reviewed": "m",
}
const config = resolve({}, { terminalSuspend: true })
Object.entries(defaults).forEach(([command, key]) =>
expect(config.keybinds.get(command)).toMatchObject([{ key }]),
)
Object.entries(defaults).forEach(([command, key]) => expect(config.keybinds.get(command)).toMatchObject([{ key }]))
const disabled = resolve(
decodeInfo({ keybinds: Object.fromEntries(Object.keys(defaults).map((command) => [command, "none"])) }),