Repository navigation
fix(sessions): preserve image attachment summaries on resume - #1152
Conversation
Vasanthdev2004
left a comment
There was a problem hiding this comment.
Thanks, this is the shape from the issue, and the tests hold up: taking out any one piece (the ACP event's attachments, the marker on load, the marker in live history, exec's attachments, the exec resume projection, the fractional-count check or the 64 bound) fails one of them.
One thing differs from the TUI, though. The TUI zeroes the image count when the model can't take images: model.go says "the sent user row must not claim the image was included", and the count it persists is that same value. Here ACP and exec take the count before the vision gate, so the ignored-by-model cases store images: 1 and resume as User: [1 image], for a turn where the model never got the image. In ACP the live turn at least carried the "ignoring 1 prompt image(s)" note, but that isn't persisted, so after a restart nothing says the image was dropped. The TUI reads the same field back through attachmentSummaryFromPayload, so it should mean the same thing whichever surface wrote it.
Could you take the count after the vision gate in both runTurn and runExec, and flip the two "ignored by model" cases to expect no marker? With exec's count moved below the gate, TestRunExecImageAttachmentHistory already fails on that case, so the test is in the right place.
The red Windows smoke job was TestACPSetModeUpdatesSession timing out at 5 s in set_config_option, which this PR doesn't touch. It passes 20 times in a row here and passed when I re-ran the job, so CI is green now. Otherwise internal/acp and internal/sessions pass under -race on Windows, internal/cli and internal/tui pass, and go vet is clean for linux, darwin and windows.
|
please rebase to main branch and fix conficts |
Persist TUI-compatible attachment counts for ACP and exec user events. Restore readable markers in live history, session replay and resumed prompts without storing or resending historical image data. Cover image-only and mixed prompts, restart recovery, malformed metadata and the aborted-turn boundary with regression tests. Fixes Twigpine#1135
Use github.com/Twigpine/zero/internal/gitsafe in the ignore scanner and its tests. The upstream module rename preceded the scanner's gitsafe change, leaving these two imports on the old path and preventing the rebased tree from compiling.
Take ACP and exec attachment counts after the vision capability gate, matching the TUI's persisted attachment semantics. Update the ignored-image regressions to require zero saved images and no historical image marker. Refs Twigpine#1135
51bb11f to
49f77f4
Compare
Vasanthdev2004
left a comment
There was a problem hiding this comment.
Thanks, 49f77f4 is exactly it. With the count moved back above the vision gate, the ignored-by-model cases fail in both TestACPImageAttachmentHistory and TestRunExecImageAttachmentHistory, and the ACP user event still goes in ahead of anything the run queues. The rebase only changed the import paths in the first commit.
d8a6f71 is the same two-line import fix as #1153, which main needs on its own, so whichever lands first, the other merges cleanly.
internal/acp, internal/cli, internal/sessions and internal/workspaceindex pass here, and CI is 10/10. Approving.
Summary
Image-only ACP and exec turns sent to vision-capable models were saved as empty user messages, so loading or resuming a session erased any indication that the turn included an image. This change records the existing TUI-compatible
attachments: {images, documents}counts and restores a short marker such as[1 image]beside the original text.session/loadtranscript replay.--imageinput before this check.For an image-only turn, resumed ACP context now contains
User: [1 image]instead ofUser:.Linked issue
Fixes #1135
Validation
Validated after rebasing onto
2ffe183on Linux with the Go version declared ingo.mod:make fmt-checkmake build-all(go build ./...)go vet ./...go test -p 1 ./...(full suite)go test ./internal/acp ./internal/cli ./internal/sessions ./internal/workspaceindex -race -count=1go run ./cmd/zero-release buildgo run ./cmd/zero-release smokemake vulncheck— no vulnerabilities foundgit diff HEAD --checkThe full test suite passed with packages run serially, in an isolated network namespace with ordinary user permissions and temporary user directories. On the host, two existing OAuth tests cannot bind their fixed port 1455 because another service already holds it. An initial parallel run also hit
TestBridgeBundleUploadRoundTripwhile a test-created worktree HEAD was changing; that case passed 10 consecutive isolated runs, and serial package execution avoids this interaction. The test implementations were not changed for either environment issue.make lint-staticreports four existing advisory findings in untouched files: QF1001 ininternal/installtest/workflow_permissions_test.go:20, and QF1008 ininternal/proxydial/proxydial.go:67,72andinternal/tools/web_fetch.go:315. No finding points to this change.Regression evidence
The regression tests were run before the fix. The ACP image-only case failed with:
The exec case also failed because its resumed prompt contained
message: userwith no image marker. Both paths pass with the fix. Coverage includes same-process follow-up, fresh-agent/store load and resume, text plus multiple images, non-vision model handling, combined stream/file input, absence of persisted or reattached image data, legacy events, malformed counts, and failed turns committing no history.The revised non-vision cases were also run before moving the counts after the capability check. They failed with
attachments.images=1where zero was expected, and the exec resume assertion reportedresume marker "[1 image]" present = true, want false. The same cases now pass, covering both the stored event and restored history/replay.Review follow-up
mainat2ffe183, retaining the upstream module rename togithub.com/Twigpine/zeroand the workspace-index safety changes.workspaceindex/gitignore.goand its test still importedgithub.com/Gitlawb/zero/internal/gitsafe, which prevented the rebased tree from compiling. This PR adapts those two import paths to the current module without changing workspace-index behavior.Checklist
issue-approvedlabel.go build ./...,go vet ./..., and the full test suite (go test -p 1 ./...) pass locally, with the test environment described above.gofmtclean.-racewhere relevant.Summary by CodeRabbit