quality(workspace): dedupe workspace_store_image and workspace_pick_and_store_image (R1.4) - #151
Closed
juacker wants to merge 1 commit into
Closed
Conversation
…nd_store_image (R1.4) Both commands duplicated the same preamble (resolve descriptor, refuse non-agent workspaces) and the same ContentPart::Image literal trailer. Extract the preamble into resolve_agent_workspace_root and the disk write + ContentPart::Image construction into store_workspace_image so both commands reduce to acquiring bytes + media type + filename. Before: 38 + 47 lines in the two command bodies (plus an unused 'moved variable' state from the picked variant). After: 12 + 33 lines, with the duplicated parts hoisted into two named helpers (resolve_agent_workspace_root, store_workspace_image). Width/height: None is now defined in one place instead of two, so the store_image and pick-and-store_image paths can never drift. Source: docs/arch-review-r1-workspace-rs.md finding F4. Local evidence: - cargo fmt -- --check: clean - cargo clippy --lib -- -D warnings: clean - cargo test --lib: 932 passed, 0 failed
Collaborator
Author
|
Superseded: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Extract the duplicated preamble (resolve descriptor + refuse non-agent workspace) and the duplicated
ContentPart::Imageliteral trailer shared byworkspace_store_image(paste path) andworkspace_pick_and_store_image(file picker path) into two named helpers:resolve_agent_workspace_root(state, workspace_id) -> Result<PathBuf, String>store_workspace_image(root, bytes, media_type, filename) -> Result<ContentPart, String>Why
Both commands had the same ~6-line preamble and the same 7-line
ContentPart::Imageliteral (width: None, height: None). Two paths defining the same shape is exactly how they drift — one gets anid, the other doesn't, etc. F4 indocs/arch-review-r1-workspace-rs.md.Diff at a glance
The commands shrink; the helpers carry the doc comments explaining why each step exists (one-liner comments at the call sites).
Local evidence
cargo fmt -- --check: cleancargo clippy --lib -- -D warnings: cleancargo test --lib: 932 passed, 0 failed (was 932 onmaintoo — no test churn, pure refactor)Source
Roadmap item R1.4 (file finding F4 of
docs/arch-review-r1-workspace-rs.md).Important note about base ref
This PR targets branch
clai/quality/pre-r1-4-main-snapshot(a temporary snapshot ofmainat74261a0, the previous tip before this branch was pushed), not the current tip ofmain(d680a96). The currentmaincontains an extra revert commit (d680a96) that is byte-identical to74261a0for the only file this branch touches; it's a leftover artifact of a botchedgit push -uearlier in this session. See.clai/memory/journal/2026-08-05.mdfor the full timeline.To merge cleanly:
74261a0is the real R1.4 change.main(or mergeclai/quality/pre-r1-4-main-snapshotforward tomainfirst). Merging into the snapshot branch leavesmainunchanged.Merge
🛑 Do not merge yet. Per the hard rule added 2026-08-04 ("never merge a PR — this is done by me"), this PR waits for CI green and then human merge.