feat(doc): add --width/--height flags to docs +media-insert#832
feat(doc): add --width/--height flags to docs +media-insert#832songyoung77 wants to merge 7 commits into
Conversation
Extend buildBatchUpdateData signature with width and height int params. When mediaType is "image" and either dimension is positive, the value is included in the replace_image payload. Existing call sites pass 0, 0.
Add computeMissingDimension (pure ratio math) and detectImageDimensions (header-only image.DecodeConfig) with PNG/JPEG/GIF blank-import decoders, plus imageDimensions struct; drive with two new TDD tests.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds ChangesImage sizing feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@shortcuts/doc/doc_media_insert.go`:
- Around line 565-571: detectImageDimensionsFromPath opens an untrusted filePath
directly; call validate.SafeInputPath(filePath) at the start of
detectImageDimensionsFromPath (before fio.Open) and return any validation error
to prevent reading unsafe paths. Keep the existing signature and behavior
otherwise (open via fio.Open, defer Close, call detectImageDimensions), and
ensure the validation error is propagated so callers (e.g., DryRun/Execute)
receive the failure.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c198a35c-11cf-45cc-a55e-7bbcbcbfef84
📒 Files selected for processing (3)
shortcuts/doc/doc_media_insert.goshortcuts/doc/doc_media_insert_test.goskills/lark-doc/references/lark-doc-media-insert.md
Summary
Add
--widthand--heightflags todocs +media-insertso users and AI agents can control the display size of inserted images. When only one dimension is specified, the other is auto-calculated from the image's native aspect ratio.Changes
--widthand--heightint flags with validation inshortcuts/doc/doc_media_insert.gocomputeMissingDimension()anddetectImageDimensions()aspect-ratio helpers inshortcuts/doc/doc_media_insert.goshortcuts/doc/doc_media_insert.goshortcuts/doc/doc_media_insert_test.goskills/lark-doc/references/lark-doc-media-insert.mdTest Plan
make unit-testpassedmake validatepassedspace:document:deletescope for cleanup; skillave 6/6)lark-cli docs +media-insert --doc <token> --file img.png --width 600 --as bot— confirmed aspect-ratio auto-calc and output fieldsRelated Issues
Closes #489
Summary by CodeRabbit
New Features
Bug Fixes / Validation
Documentation