Skip to content

Commit 30536dd

Browse files
author
SqlRush
committed
Accept wrapped image fields
1 parent af65449 commit 30536dd

5 files changed

Lines changed: 66 additions & 0 deletions

File tree

docs/cc-100-roadmap.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,8 @@ M7 补充:prompt history `LogEntry` 读取现在接受 `sessionID`/`session`/`
642642

643643
本轮补充:interaction script 的 direct dialog 字段现在改为 raw payload 解析;`dialog`/`Dialog` 可递归解包 `resource.attributes``edge.node.attrs` 和单元素数组,`showDialog` action payload 也复用同一解析路径,避免 wrapper-only dialog 被解码成空弹窗。
644644

645+
本轮补充:interaction script 的 direct image 字段现在改为 raw payload 解析;`image`/`Image` 可复用 pasteImage action 的 wrapper 解析,递归解包 `resource.attributes``edge.node.attrs` 和单元素数组,保留 filename/media/content/source-path 后再生成 prompt pasted-image。
646+
645647
本轮补充:interaction script 的 runtime mutation action 现在也递归解包 wrapped `removeTask`/`cancelPermission` ID 和 `cancelTasks` cancellation detail;`payload.resource.attributes``edge.node` 和相邻 API envelope 可直接驱动 task removal、permission cancellation 与 task bulk-cancel。
646648

647649
本轮补充:interaction script 的 direct runtime mutation alias 字段现在接受 object payload;`removeTask: {resource:{id}}``cancelPermission: {edge:{node:{id}}}``cancelTasks: {resource:{attributes:{reasonText}}}` 会走同一递归解析路径,不再被 string/bool alias 字段提前拒绝。

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ test/parity/ # golden tests against TS/official behavior
331331
- 本轮补充:interaction script 的 direct message list 字段现在改为 raw payload 解析;`messages`/`appendMessages`/`transcriptMessages` 可递归解包 `resource.attributes``data[]``edge.node.attrs` 等 API/GraphQL wrapper,并保留 image paste id 等 message metadata。
332332
- 本轮补充:interaction script 的 direct single message 字段现在也复用 raw message parser;`message`/`Message` 可递归解包 `resource.attributes``edge.node.attrs`,并在数组形态下回退为多条 message 追加,避免单条消息 wrapper 被基础解码成空消息。
333333
- 本轮补充:interaction script 的 direct dialog 字段现在改为 raw payload 解析;`dialog`/`Dialog` 可递归解包 `resource.attributes``edge.node.attrs` 和单元素数组,`showDialog` action payload 也复用同一解析路径,避免 wrapper-only dialog 被解码成空弹窗。
334+
- 本轮补充:interaction script 的 direct image 字段现在改为 raw payload 解析;`image`/`Image` 可复用 pasteImage action 的 wrapper 解析,递归解包 `resource.attributes``edge.node.attrs` 和单元素数组,保留 filename/media/content/source-path 后再生成 prompt pasted-image。
334335
- 本轮补充:terminal CSI-u/kitty keyboard parser 接受 `codepoint:alternate``modifier:event-type` 冒号字段,按主 codepoint/modifier 解析 ctrl/alt/shift/rune 键,覆盖 kitty progressive keyboard protocol 的常见变体。
335336
- 本轮补充:terminal CSI-u/kitty keyboard parser 接受无 modifier 字段或 modifier `1` 的 base key 序列,覆盖 printable rune、Enter、Tab、Esc 和 Backspace,避免 extended-key 模式下普通键序列被解析成 unknown。
336337
- 本轮补充:terminal input parser 接受 xterm modified arrow 序列(如 `CSI 1;2D``CSI 1;6C``CSI 1;7D`),把 shift-arrow 降级为方向键、alt-arrow 映射到 word-motion key、ctrl/ctrl+alt-arrow 映射到 ctrl word-motion key,避免 extended navigation 序列落入 unknown。

docs/first-second-parity-audit.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ M7 progress now includes:
385385
- `internal/tui`: interaction script direct message-list fields now use raw payload parsing, so `messages`/`appendMessages`/`transcriptMessages` can unwrap API/GraphQL envelopes such as `resource.attributes`, `data[]`, and `edge.node.attrs` while preserving message metadata such as image paste IDs.
386386
- `internal/tui`: interaction script direct single-message fields now reuse the raw message parser, so `message`/`Message` can unwrap `resource.attributes` or `edge.node.attrs`, and array-shaped single-message payloads fall back to appending multiple messages instead of producing an empty decoded message.
387387
- `internal/tui`: interaction script direct dialog fields now use raw payload parsing, so `dialog`/`Dialog` and `showDialog` action payloads can unwrap `resource.attributes`, `edge.node.attrs`, and single-element arrays instead of decoding wrapper-only dialogs as empty popups.
388+
- `internal/tui`: interaction script direct image fields now use raw payload parsing, so `image`/`Image` can reuse pasteImage action wrapper parsing for `resource.attributes`, `edge.node.attrs`, and single-element arrays while preserving filename/media/content/source-path metadata before prompt image insertion.
388389
- `internal/contracts`/`internal/session`: image content blocks now normalize source aliases such as `mediaType`/`mimeType`/`contentType` and `base64`/`payload`, including top-level image block fields, into canonical `ImageSource` values during transcript resume.
389390
- `internal/tui`: interaction script single-step JSON now unwraps `step`/`scriptStep`/`interactionStep`/`record`/`entry`/`item`/`event` objects in arrays, JSONL records, and wrapper-object step lists.
390391
- `internal/tui`: interaction script single-step JSON now also unwraps JSON:API/resource-style `resource`/`node`/`attributes`/`properties`/`attrs` step items, so API fixture arrays and JSONL records can keep step resource envelopes.

internal/tui/script_aliases.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,9 @@ func (step *ScriptStep) UnmarshalJSON(data []byte) error {
822822
if dialog := scriptDialogJSONField(rawFieldMap, "Dialog", "dialog"); dialog != nil {
823823
step.Dialog = dialog
824824
}
825+
if image := scriptImageJSONField(rawFieldMap, "Image", "image"); image != nil {
826+
step.Image = image
827+
}
825828
if fields.Keybindings != nil {
826829
step.Keybindings = fields.Keybindings
827830
}
@@ -3254,6 +3257,8 @@ func stripScriptStepRawScalarAliasFields(data []byte) []byte {
32543257
"mouseEvent",
32553258
"Dialog",
32563259
"dialog",
3260+
"Image",
3261+
"image",
32573262
"SnapshotName",
32583263
"snapshotName",
32593264
"RequestPermission",

internal/tui/tui_test.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5211,6 +5211,63 @@ func TestRunInteractionScriptAcceptsImageFieldAliases(t *testing.T) {
52115211
}
52125212
}
52135213

5214+
func TestRunInteractionScriptAcceptsWrappedImageField(t *testing.T) {
5215+
steps, err := ParseInteractionScript([]byte(`[
5216+
{
5217+
"image": {
5218+
"resource": {
5219+
"type": "image",
5220+
"attributes": {
5221+
"fileName": "wrapped.png",
5222+
"mimeType": "image/png",
5223+
"data": "AAAA",
5224+
"sourcePath": "/tmp/wrapped.png"
5225+
}
5226+
}
5227+
},
5228+
"expectPrompt": {
5229+
"text": "[Image #1]",
5230+
"pastedContentCount": 1,
5231+
"nextPastedID": 2,
5232+
"pastedContents": {"id": 1, "type": "image", "fileName": "wrapped.png", "contentType": "image/png", "value": "AAAA", "sourcePath": "/tmp/wrapped.png"}
5233+
}
5234+
},
5235+
{
5236+
"image": [
5237+
{
5238+
"edge": {
5239+
"node": {
5240+
"attrs": {
5241+
"name": "wrapped-array.webp",
5242+
"mime_type": "image/webp",
5243+
"base64": "BBBB"
5244+
}
5245+
}
5246+
}
5247+
}
5248+
],
5249+
"expectPrompt": {
5250+
"text": "[Image #1] [Image #2]",
5251+
"pastedContentCount": 2,
5252+
"nextPastedID": 3,
5253+
"pastedContents": {"id": 2, "kind": "image", "fileName": "wrapped-array.webp", "mimeType": "image/webp", "content": "BBBB"}
5254+
}
5255+
}
5256+
]`))
5257+
if err != nil {
5258+
t.Fatal(err)
5259+
}
5260+
if len(steps) != 2 ||
5261+
steps[0].Image == nil || steps[0].Image.Filename != "wrapped.png" || steps[0].Image.MediaType != "image/png" || steps[0].Image.Content != "AAAA" || steps[0].Image.SourcePath != "/tmp/wrapped.png" ||
5262+
steps[1].Image == nil || steps[1].Image.Filename != "wrapped-array.webp" || steps[1].Image.MediaType != "image/webp" || steps[1].Image.Content != "BBBB" {
5263+
t.Fatalf("steps = %#v", steps)
5264+
}
5265+
screen := NewREPLScreen(40, 8, nil)
5266+
if _, err := RunInteractionScriptChecked(&screen, steps); err != nil {
5267+
t.Fatal(err)
5268+
}
5269+
}
5270+
52145271
func TestRunInteractionScriptAcceptsPastedContentAliases(t *testing.T) {
52155272
steps, err := ParseInteractionScript([]byte(`[
52165273
{

0 commit comments

Comments
 (0)