quality(workspace): dedupe workspace_store_image and workspace_pick_and_store_image (R1.4) - #153
Open
juacker wants to merge 1 commit into
Open
quality(workspace): dedupe workspace_store_image and workspace_pick_and_store_image (R1.4)#153juacker wants to merge 1 commit into
juacker wants to merge 1 commit into
Conversation
…nd_store_image (R1.4) Both commands duplicated ~15 lines: workspace-root resolution from AppState plus an identical ContentPart::Image trailer. Extract two helpers in commands/workspace.rs: - resolve_agent_workspace_root(state, workspace_id) -> PathBuf - store_workspace_image(root, bytes, media_type, filename) -> ContentPart Addresses finding F4 of docs/arch-review-r1-workspace-rs.md. No behaviour change. Note: this is a re-land. The original commit 0aa9a16 was accidentally pushed straight to main and then reverted in d680a96.
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.
Implements R1.4 from the roadmap. Source: finding F4 of
docs/arch-review-r1-workspace-rs.md.Problem
workspace_store_imageandworkspace_pick_and_store_imageinsrc-tauri/src/commands/workspace.rsduplicated ~15 lines each:AppState(lookup + error mapping +PathBufclone),ContentPart::Imagereturn value (write bytes, build relative path, assemble the part).Change
Two helpers, both private to the module:
fn resolve_agent_workspace_root(state: &AppState, workspace_id: &str) -> Result<PathBuf, String>— owns the clone; returning&Pathwould tie the borrow to theAppStateguard.async fn store_workspace_image(root: &Path, bytes: &[u8], media_type: &str, filename: Option<String>) -> Result<ContentPart, String>Both commands now call them. No behaviour change; error strings and the returned
ContentPartshape are preserved.Net:
+50/-38, one file.Verification
Run from
src-tauri/:cargo fmt --check— cleancargo clippy --lib -- -D warnings— cleancargo test --lib— 941 passed, 0 failedNote: this is a re-land
The original commit
0aa9a16was accidentally pushed directly tomainon 2026-08-05 (agit checkout -b <new> origin/mainsetbranch.<new>.merge = refs/heads/main, so a latergit push -uresolved tomain). It was reverted ind680a96, which is inmain. This PR re-applies the same change as a fresh commit on top of75fd6a4. PR #151 was closed as unsalvageable — its head was an ancestor ofmain, so GitHub refused to retarget it.Branch protection on
mainhas since been tightened to require a pull request and passing status checks.