Skip to content

Commit d1e3629

Browse files
author
SqlRush
committed
Accept scripted keybinding config aliases
1 parent a1cb7f2 commit d1e3629

5 files changed

Lines changed: 18 additions & 6 deletions

File tree

docs/cc-100-roadmap.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ M7 补充:keybinding JSON loader 现在也递归解包 JSON:API/resource-style
190190

191191
M7 补充:keybinding JSON loader 现在接受 `keymap`/`keymaps``keyboardShortcuts``hotkeys``userKeybindings``customKeybindings` 等集合字段别名,并同时支持直接 object-map 和嵌套 `bindings` wrapper。
192192

193-
M7 补充:interaction script 的 per-step keybinding mutation 现在复用同一套 collection aliasobject-map 解析,脚本步骤可直接使用 `keymap``keyboardShortcuts``hotkeys` 临时改键位。
193+
M7 补充:interaction script 的 per-step keybinding mutation 现在复用同一套 collection aliasobject-map 和 JSON:API/resource wrapper 解析,脚本步骤可直接使用 `keymap``keyboardShortcuts``hotkeys``keyboard``preferences``keybindingConfig` 临时改键位。
194194

195195
M7 补充:interaction script 的 `keys` 字段现在支持 printable text chunk 和空格分隔 named-key sequence,例如 `ctrl-x ctrl-k`,减少官方脚本把连续输入拆成数组的改写成本。
196196

@@ -550,7 +550,7 @@ M7 补充:prompt history `LogEntry` 读取现在接受 `sessionID`/`session`/`
550550

551551
本轮补充:keybinding JSON loader 现在接受 `keymap`/`keymaps``keyboardShortcuts``hotkeys``userKeybindings``customKeybindings` 等集合字段别名,并同时支持直接 object-map 和嵌套 `bindings` wrapper。
552552

553-
本轮补充:interaction script 的 per-step keybinding mutation 现在复用同一套 collection aliasobject-map 解析,脚本步骤可直接使用 `keymap``keyboardShortcuts``hotkeys` 临时改键位。
553+
本轮补充:interaction script 的 per-step keybinding mutation 现在复用同一套 collection aliasobject-map 和 JSON:API/resource wrapper 解析,脚本步骤可直接使用 `keymap``keyboardShortcuts``hotkeys``keyboard``preferences``keybindingConfig` 临时改键位。
554554

555555
本轮补充:interaction script 的 `keys` 字段现在支持 printable text chunk 和空格分隔 named-key sequence,例如 `ctrl-x ctrl-k`,减少官方脚本把连续输入拆成数组的改写成本。
556556

docs/claude-code-go-rewrite-plan.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ test/parity/ # golden tests against TS/official behavior
289289
- 本轮补充:keybinding JSON loader 现在递归解包 `data`/`payload`/`settings`/`config`/`keyboard`/`keymap` 等外层 wrapper,嵌套 preference export 中的 `bindings`/`shortcuts` 不需要手工扁平化。
290290
- 本轮补充:keybinding JSON loader 现在也递归解包 JSON:API/resource-style `resource`/`attributes`/`properties`/`attrs` wrapper,API/preferences envelope 内的 `keybindings`/`keymap` 可直接加载。
291291
- 本轮补充:keybinding JSON loader 现在接受 `keymap`/`keymaps``keyboardShortcuts``hotkeys``userKeybindings``customKeybindings` 等集合字段别名,并同时支持直接 object-map 和嵌套 `bindings` wrapper。
292-
- 本轮补充:interaction script 的 per-step keybinding mutation 复用同一套 collection aliasobject-map 解析,脚本步骤可直接使用 `keymap``keyboardShortcuts``hotkeys` 临时改键位。
292+
- 本轮补充:interaction script 的 per-step keybinding mutation 复用同一套 collection aliasobject-map 和 resource wrapper 解析,脚本步骤可直接使用 `keymap``keyboardShortcuts``hotkeys``keyboard``preferences``keybindingConfig` 临时改键位。
293293
- 本轮补充:interaction script 的 `keys` 字段支持 printable text chunk 和空格分隔 named-key sequence,例如 `ctrl-x ctrl-k`,减少官方脚本把连续输入拆成数组的改写成本。
294294
- 本轮补充:interaction script key input 接受 press-style aliases,包括 `press``keyPress``keypress``shortcutKey``presses``keyPresses``shortcuts`
295295
- 本轮补充:interaction script action/type/kind/name/operation 动作判别字段接受 compact/camel fixture aliases,包括 `typeText``inputText``insertText``keyPress``pressKey``keySequence``pasteText``pastedText``clipboardText``setStatus``statusLine``terminalSize``screenSize`

docs/first-second-parity-audit.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ M7 progress now includes:
317317
- `internal/tui`: keybinding JSON loading now recurses through outer wrappers such as `data`, `payload`, `settings`, `config`, `keyboard`, and `keymap`, so nested official or third-party preference exports can expose `bindings`/`shortcuts` without manual flattening.
318318
- `internal/tui`: keybinding JSON loading now also recurses through JSON:API/resource-style `resource`, `attributes`, `properties`, and `attrs` wrappers so API/preference envelopes can expose `keybindings` or `keymap` without manual flattening.
319319
- `internal/tui`: keybinding JSON loading now accepts collection aliases such as `keymap`, `keymaps`, `keyboardShortcuts`, `hotkeys`, `userKeybindings`, and `customKeybindings`, including both direct object maps and nested `bindings` wrappers.
320-
- `internal/tui`: interaction script keybinding mutation fields now reuse the same collection aliases and object-map parsing, so scripted steps can set `keymap`, `keyboardShortcuts`, or `hotkeys` directly.
320+
- `internal/tui`: interaction script keybinding mutation fields now reuse the same collection aliases, object-map parsing, and JSON:API/resource wrapper handling, so scripted steps can set `keymap`, `keyboardShortcuts`, `hotkeys`, `keyboard`, `preferences`, or `keybindingConfig` directly.
321321
- `internal/tui`: mouse parsing now accepts legacy X10/normal tracking `ESC[M...` press/release/wheel sequences in addition to SGR mouse events.
322322
- `internal/tui`: mouse parsing now accepts urxvt/xterm 1015 numeric mouse `CSI button;x;yM` sequences and normalizes button codes to the existing SGR/X10 mouse surface.
323323
- `internal/tui`: interaction scripts now accept structured `mouse`/`mouse_event` steps with expanded button aliases such as `buttonMask`/`btn`/`code`, coordinate aliases such as `mouseX`/`clientX`/`screenX`/`pageX`/`offsetX`/`viewportX` and Y/row/line variants, release aliases such as `mouseUp`/`isRelease`/`mouseRelease`/`releaseEvent`, and dispatch them through the normal screen event path.

internal/tui/script_aliases.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,15 @@ func scriptKeybindingsJSONField(fields map[string]json.RawMessage) ([]BindingSpe
223223
"customKeybindings",
224224
"customKeyBindings",
225225
"custom_keybindings",
226+
"keybinding",
227+
"keyBinding",
228+
"keybinding_config",
229+
"keybindingConfig",
230+
"keyboard",
231+
"keyboard_config",
232+
"keyboardConfig",
233+
"preferences",
234+
"userPreferences",
226235
}
227236
for _, name := range names {
228237
raw, ok := fields[name]

internal/tui/tui_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5575,6 +5575,8 @@ func TestRunInteractionScriptAcceptsKeybindingCollectionAliases(t *testing.T) {
55755575
{"text":"first","key":"ctrl-r","expectEvent":{"type":"prompt_submitted","value":"first"},"expectPrompt":{"empty":true}},
55765576
{"keyboardShortcuts":{"bindings":[{"shortcut":"ctrl-w","commandName":"submitPrompt"}]}},
55775577
{"text":"second","key":"ctrl-w","expectEvent":{"type":"prompt_submitted","value":"second"},"expectPrompt":{"empty":true}},
5578+
{"keyboard":{"resource":{"attributes":{"keymap":{"ctrl-y":"submitPrompt"}}}}},
5579+
{"text":"third","key":"ctrl-y","expectEvent":{"type":"prompt_submitted","value":"third"},"expectPrompt":{"empty":true}},
55785580
{"hotkeys":{"ctrl-x ctrl-k":false}},
55795581
{"keys":"ctrl-x ctrl-k","expectNoEvent":true}
55805582
]`))
@@ -5586,9 +5588,10 @@ func TestRunInteractionScriptAcceptsKeybindingCollectionAliases(t *testing.T) {
55865588
if err != nil {
55875589
t.Fatal(err)
55885590
}
5589-
if len(result.Events) != 2 ||
5591+
if len(result.Events) != 3 ||
55905592
result.Events[0].Type != ScreenEventPromptSubmitted || result.Events[0].Value != "first" ||
5591-
result.Events[1].Type != ScreenEventPromptSubmitted || result.Events[1].Value != "second" {
5593+
result.Events[1].Type != ScreenEventPromptSubmitted || result.Events[1].Value != "second" ||
5594+
result.Events[2].Type != ScreenEventPromptSubmitted || result.Events[2].Value != "third" {
55925595
t.Fatalf("events = %#v", result.Events)
55935596
}
55945597
}

0 commit comments

Comments
 (0)