Skip to content

feat(docs): add layout-preserving image replacement#858

Merged
steipete merged 1 commit into
mainfrom
feat/docs-replace-image
Jun 19, 2026
Merged

feat(docs): add layout-preserving image replacement#858
steipete merged 1 commit into
mainfrom
feat/docs-replace-image

Conversation

@steipete

Copy link
Copy Markdown
Collaborator

Summary

  • add docs replace-image with exact object-ID, case-insensitive alt substring, or implicit single-image selection
  • support public HTTPS URLs and local PNG/JPEG/GIF uploads with temporary Drive sharing cleanup
  • preserve object position and rendered bounds through ReplaceImageRequest with CENTER_CROP
  • retain tab targeting and document revision control
  • document the command and add changelog credit for @sebsnyk

Closes #853.

Verification

  • go test ./internal/cmd -run 'Docs.*Image|DocsImages|DocsSed'
  • go test ./internal/docssed ./internal/docsedit
  • make ci
  • Codex autoreview: clean, no actionable findings
  • live Google Docs proof on exact branch head: inserted a public Docs logo, replaced it by exact object ID with a Sheets logo, verified the same object ID and 72×72 PT bounds plus the changed source URI, then replaced it again through implicit single-image selection; disposable document moved to trash

The local-file path has full mocked Drive upload, public-share, Docs replacement, and permission-revoke coverage. No additional external image upload was performed during live proof.

@clawsweeper

clawsweeper Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 19, 2026, 1:41 PM ET / 17:41 UTC.

Summary
The branch adds gog docs replace-image, refactors Docs image upload public-share cleanup for reuse, adds generated/user docs and changelog text, and covers URL, local-file, selector, and dry-run paths with tests.

Reproducibility: not applicable. this is a feature PR, not a reported current-main bug. Source inspection shows current main lacks the dedicated command while the related issue describes the desired workflow.

Review metrics: 3 noteworthy metrics.

  • Diff Scope: 11 files, +681/-19. The change is bounded but touches command code, generated docs, docs prose, tests, and an existing upload helper.
  • Command Surface: 1 command added. A new user-facing CLI command should be reviewed for help text, output shape, and docs consistency.
  • Existing Helper Touched: 1 insert-image cleanup path refactored. The shared public-share cleanup helper affects the pre-existing Docs insert-image local-file path as well as the new command.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #853
Summary: This PR is the candidate implementation for the open Docs replace-image command issue it closes.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Wait for the remaining CI jobs to complete before merge.

Risk before merge

  • The latest PR check rollup still had some CI jobs in progress during review, so merge should wait for the normal required checks.
  • [P1] The PR body reports live proof for public-URL replacement and mocked coverage for local-file upload/share/revoke; the local-file path was not live-tested externally in the posted proof.

Maintainer options:

  1. Decide the mitigation before merge
    Review and land this PR if the remaining CI and maintainer validation are acceptable, keeping the related issue open until the candidate fix merges.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P2] No repair lane is needed because the review found no narrow actionable code defect; this PR needs normal CI and maintainer review.

Security
Cleared: The diff touches temporary Drive public sharing for local image uploads, but it reuses the existing confirm-and-revoke pattern and adds cleanup coverage; no concrete security regression was found.

Review details

Best possible solution:

Review and land this PR if the remaining CI and maintainer validation are acceptable, keeping the related issue open until the candidate fix merges.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this is a feature PR, not a reported current-main bug. Source inspection shows current main lacks the dedicated command while the related issue describes the desired workflow.

Is this the best way to solve the issue?

Yes: the PR takes a narrow path by adding a dedicated command while reusing existing image enumeration and upload helpers. The remaining question is ordinary merge validation, not a different implementation direction.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against ab9a331d4c07.

Label changes

Label changes:

  • add P2: This is a normal-priority Docs automation feature with useful layout-preserving behavior and limited blast radius.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-contributor proof gate does not apply to this collaborator-authored PR; the body nevertheless includes live Google Docs proof for URL/object-id/single-image replacement and mocked Drive coverage for local-file cleanup.

Label justifications:

  • P2: This is a normal-priority Docs automation feature with useful layout-preserving behavior and limited blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-contributor proof gate does not apply to this collaborator-authored PR; the body nevertheless includes live Google Docs proof for URL/object-id/single-image replacement and mocked Drive coverage for local-file cleanup.
Evidence reviewed

What I checked:

Likely related people:

  • steipete: Current-main blame/log history ties the existing Docs insert-image, image enumerator, and sed image replacement surface to Peter Steinberger, and this branch continues that same area. (role: recent Docs image area contributor; confidence: high; commits: 508a4d3cd368, 87029ed0507c; files: internal/cmd/docs_insert_image.go, internal/cmd/docs_enumerators.go, internal/cmd/docs_sed_images.go)
  • sebsnyk: Sebastian Roth authored the linked feature request and adjacent Docs workflow reports that define the user-facing replace-image need. (role: workflow reporter; confidence: low; commits: ab9a331d4c07; files: docs/docs-editing.md, internal/cmd/docs_edit.go, internal/cmd/docs_mutation.go)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal priority bug or improvement with limited blast radius. labels Jun 19, 2026
@steipete
steipete merged commit 91c0bcb into main Jun 19, 2026
11 checks passed
@steipete

Copy link
Copy Markdown
Collaborator Author

Landed as 91c0bcb.

Verification:

  • go test ./internal/cmd -run 'Docs.*Image|DocsImages|DocsSed'
  • go test ./internal/docssed ./internal/docsedit
  • make ci
  • Codex autoreview on local and final branch diffs: clean, no actionable findings.
  • Exact-head live Google Docs proof: inserted a public Docs logo, replaced it by exact object ID with a Sheets logo, and confirmed through docs images list plus docs raw that the object ID and 72×72 PT bounds stayed unchanged while the source URI changed. Replaced it again with no selector to prove implicit single-image selection. The disposable document was moved to trash.
  • Exact-head GitHub checks: both push and pull-request test, Windows, worker, and Darwin CGO jobs passed; Docker image and Socket checks also passed.

Caveat: the local-file path was not externally uploaded during live proof. Its Drive upload, temporary public permission, Docs replacement, and permission revocation sequence is covered end-to-end with mocked Drive and Docs services.

@steipete
steipete deleted the feat/docs-replace-image branch June 19, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(docs): replace-image command (replaceImage) — swap image bytes in place without losing position/size

1 participant