Skip to content

feat: add slides replace-pages and xml-get shortcuts - #1585

Merged
fangshuyu-768 merged 4 commits into
mainfrom
feat/slides_shortcut
Jun 26, 2026
Merged

feat: add slides replace-pages and xml-get shortcuts#1585
fangshuyu-768 merged 4 commits into
mainfrom
feat/slides_shortcut

Conversation

@ethan-zhx

@ethan-zhx ethan-zhx commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add new Slides shortcuts for replacing pages and fetching presentation XML, and tighten related Slides UX/output behavior.

Changes

  • Add shortcut and tests
  • Add shortcut and tests
  • Stop advertising unusable screenshot auth scope
  • Update references to match the new workflows

Test Plan

  • Unit tests added/updated
  • Unit tests pass
  • Manual local verification confirms the flow works as expected

Related Issues

  • None

Summary by CodeRabbit

  • New Features
    • Added +replace-pages for multi-page slide rebuilds (supports dry-run, validate-only, and continue-on-error with partial results).
    • Added +xml-get to download full Slides XML to a local file (supports revision and XML attribute stripping).
  • Bug Fixes
    • Slide creation now uses the service-provided presentation URL when available, with a local fallback.
    • Scope handling was adjusted to reflect actual availability/needs (screenshot and wiki-based inputs).
  • Documentation
    • Updated slide workflow guides and references to cover +replace-pages and +xml-get, including updated screenshot usage guidance.

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 925f1764-c4e8-454d-8ad6-465f2859e316

📥 Commits

Reviewing files that changed from the base of the PR and between 8688d7a and 6ddbbaf.

📒 Files selected for processing (15)
  • shortcuts/slides/shortcuts.go
  • shortcuts/slides/slides_create.go
  • shortcuts/slides/slides_create_test.go
  • shortcuts/slides/slides_replace_pages.go
  • shortcuts/slides/slides_replace_pages_test.go
  • shortcuts/slides/slides_replace_slide.go
  • shortcuts/slides/slides_replace_slide_test.go
  • shortcuts/slides/slides_screenshot.go
  • shortcuts/slides/slides_screenshot_test.go
  • shortcuts/slides/slides_xml_get.go
  • shortcuts/slides/slides_xml_get_test.go
  • skills/lark-slides/SKILL.md
  • skills/lark-slides/references/lark-slides-edit-workflows.md
  • skills/lark-slides/references/lark-slides-replace-pages.md
  • skills/lark-slides/references/lark-slides-screenshot.md
✅ Files skipped from review due to trivial changes (4)
  • skills/lark-slides/references/lark-slides-screenshot.md
  • skills/lark-slides/references/lark-slides-edit-workflows.md
  • skills/lark-slides/references/lark-slides-replace-pages.md
  • skills/lark-slides/SKILL.md
🚧 Files skipped from review as they are similar to previous changes (8)
  • shortcuts/slides/shortcuts.go
  • shortcuts/slides/slides_create.go
  • shortcuts/slides/slides_screenshot_test.go
  • shortcuts/slides/slides_xml_get_test.go
  • shortcuts/slides/slides_create_test.go
  • shortcuts/slides/slides_xml_get.go
  • shortcuts/slides/slides_replace_pages.go
  • shortcuts/slides/slides_replace_pages_test.go

📝 Walkthrough

Walkthrough

The PR adds +replace-pages and +xml-get, updates SlidesCreate to prefer API-returned URLs with a local fallback, and changes screenshot scope declarations plus related tests and documentation.

Changes

Slides shortcut updates

Layer / File(s) Summary
Registry and screenshot scopes
shortcuts/slides/shortcuts.go, shortcuts/slides/slides_screenshot.go, shortcuts/slides/slides_screenshot_test.go, skills/lark-slides/references/lark-slides-screenshot.md
Shortcuts() includes the new slide identifiers, and screenshot scope declarations, tests, and guidance no longer advertise slides:presentation:screenshot.
Create URL sourcing
shortcuts/slides/slides_create.go, shortcuts/slides/slides_create_test.go
SlidesCreate.Execute now prefers data["url"] from presentation.create and falls back to a local URL only when that field is empty; tests cover both cases.
Replace-pages command
shortcuts/slides/slides_replace_pages.go
+replace-pages validates --pages, checks complete <slide> XML, builds create-before-delete plans, runs sequential replacements, and emits per-page results plus summary output.
Replace-pages tests and docs
shortcuts/slides/slides_replace_pages_test.go, skills/lark-slides/SKILL.md, skills/lark-slides/references/lark-slides-edit-workflows.md, skills/lark-slides/references/lark-slides-replace-pages.md
The new shortcut tests cover scope declarations, ordering, partial failures, dry runs, and validation errors, and the slide docs add the batch rebuild workflow, page JSON shape, and output schema.
XML fetch command and tests
shortcuts/slides/slides_xml_get.go, shortcuts/slides/slides_xml_get_test.go
+xml-get resolves presentation references, fetches XML presentation content, writes it to disk, and the tests cover direct fetches, wiki resolution, and unsafe output rejection.

Sequence Diagram(s)

Replace-pages flow

sequenceDiagram
  participant SlidesReplacePages
  participant runtime.CallAPITyped
  participant Slides API
  SlidesReplacePages->>runtime.CallAPITyped: create replacement slide with before_slide_id
  runtime.CallAPITyped->>Slides API: POST replacement content
  Slides API-->>runtime.CallAPITyped: slide_id and revision_id
  SlidesReplacePages->>runtime.CallAPITyped: delete old slide_id
  runtime.CallAPITyped->>Slides API: DELETE old slide
  Slides API-->>SlidesReplacePages: per-page result
Loading

XML fetch flow

sequenceDiagram
  participant User
  participant SlidesXMLGet
  participant Wiki API
  participant Slides API
  participant FileSystem
  User->>SlidesXMLGet: --presentation + --output
  alt wiki presentation reference
    SlidesXMLGet->>Wiki API: resolve wiki node
    Wiki API-->>SlidesXMLGet: slides presentation token
  end
  SlidesXMLGet->>Slides API: GET xml_presentation with revision_id and remove_attr_id
  Slides API-->>SlidesXMLGet: xml_presentation.content
  SlidesXMLGet->>FileSystem: write XML to --output
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • larksuite/cli#1329 — Also changes SlidesCreate URL population around presentation.create.
  • larksuite/cli#425 — Updates the slides create flow and related tests for data["url"].
  • larksuite/cli#516 — Touches the shared slides shortcut registry where new shortcut entries are added.

Suggested labels

feature

Suggested reviewers

  • fangshuyu-768
  • liangshuo-1

Poem

🐇 I hop through slides with pages new,
and fetch the XML bright and true.
I swap, I save, I leave a trace,
with urls, scopes, and tidy pace.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.76% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change by naming the new Slides shortcuts added in this PR.
Description check ✅ Passed The description follows the required template and covers summary, changes, test plan, and related issues, though some change bullets are sparse.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/slides_shortcut

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 OpenGrep (1.23.0)
shortcuts/slides/shortcuts.go

┌──────────────┐
│ Opengrep CLI │
└──────────────┘

�[32m✔�[39m �[1mOpengrep OSS�[0m
�[32m✔�[39m Basic security coverage for first-party code vulnerabilities.

[00.14][ERROR]: unable to find a config; path .coderabbit-opengrep-fallback.yml does not exist

shortcuts/slides/slides_create.go

┌──────────────┐
│ Opengrep CLI │
└──────────────┘

�[32m✔�[39m �[1mOpengrep OSS�[0m
�[32m✔�[39m Basic security coverage for first-party code vulnerabilities.

[00.14][ERROR]: unable to find a config; path .coderabbit-opengrep-fallback.yml does not exist

shortcuts/slides/slides_create_test.go

┌──────────────┐
│ Opengrep CLI │
└──────────────┘

�[32m✔�[39m �[1mOpengrep OSS�[0m
�[32m✔�[39m Basic security coverage for first-party code vulnerabilities.

[00.13][ERROR]: unable to find a config; path .coderabbit-opengrep-fallback.yml does not exist

  • 8 others
🔧 markdownlint-cli2 (0.22.1)
skills/lark-slides/SKILL.md

markdownlint-cli2 wrapper config was not available before execution

skills/lark-slides/references/lark-slides-edit-workflows.md

markdownlint-cli2 wrapper config was not available before execution

skills/lark-slides/references/lark-slides-replace-pages.md

markdownlint-cli2 wrapper config was not available before execution

  • 1 others

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the size/L Large or sensitive change across domains or core paths label Jun 25, 2026
@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@6ddbbafc4f9560eb6bd28caa83be3a8e8858d2ec

🧩 Skill update

npx skills add larksuite/cli#feat/slides_shortcut -y -g

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
shortcuts/slides/slides_create.go (1)

207-213: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

URL selection logic is correct.

Prefer API-returned url, fall back to local build. data is guaranteed non-nil by the earlier presentationID check, so common.GetString(data, "url") is safe.

Optional: the unchanged NB comment at lines 36-38 ("the presentation URL is built locally (see Execute)") is now slightly stale since Execute prefers the API-returned url and only falls back to a local build. The "no drive scope" justification still holds, but consider tweaking the wording to avoid confusion.

🤖 Prompt for 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.

In `@shortcuts/slides/slides_create.go` around lines 207 - 213, Update the stale
NB comment in the slides creation flow to match the current URL selection
behavior. In the slides shortcut’s Execute path, the code now prefers the
API-returned url from presentation.create and only falls back to
BuildResourceURL when it is missing, so revise the comment to reflect that logic
while keeping the existing no-drive-scope justification clear. Use the Execute
method and the presentation URL comment near the earlier NB note as the anchor
points for the edit.
🤖 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/slides/slides_xml_get_test.go`:
- Around line 150-156: The test in slides_xml_get_test.go is accessing a
non-existent Param field on the result of errs.ProblemOf, which returns
*errs.Problem and cannot satisfy the assertion as written. Update the check to
unwrap the original error with errors.As into *errs.ValidationError, then assert
on ve.Param instead, following the same pattern used in
slides_replace_pages_test.go, and add the errors import if it is not already
present.

---

Nitpick comments:
In `@shortcuts/slides/slides_create.go`:
- Around line 207-213: Update the stale NB comment in the slides creation flow
to match the current URL selection behavior. In the slides shortcut’s Execute
path, the code now prefers the API-returned url from presentation.create and
only falls back to BuildResourceURL when it is missing, so revise the comment to
reflect that logic while keeping the existing no-drive-scope justification
clear. Use the Execute method and the presentation URL comment near the earlier
NB note as the anchor points for the edit.
🪄 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: a2760669-cbca-4234-8f41-85358bacf7da

📥 Commits

Reviewing files that changed from the base of the PR and between 806e867 and a9ae0d1.

📒 Files selected for processing (14)
  • cmd/auth/login_test.go
  • shortcuts/slides/shortcuts.go
  • shortcuts/slides/slides_create.go
  • shortcuts/slides/slides_create_test.go
  • shortcuts/slides/slides_replace_pages.go
  • shortcuts/slides/slides_replace_pages_test.go
  • shortcuts/slides/slides_screenshot.go
  • shortcuts/slides/slides_screenshot_test.go
  • shortcuts/slides/slides_xml_get.go
  • shortcuts/slides/slides_xml_get_test.go
  • skills/lark-slides/SKILL.md
  • skills/lark-slides/references/lark-slides-edit-workflows.md
  • skills/lark-slides/references/lark-slides-replace-pages.md
  • skills/lark-slides/references/lark-slides-screenshot.md

Comment thread shortcuts/slides/slides_xml_get_test.go
@ethan-zhx
ethan-zhx force-pushed the feat/slides_shortcut branch from a9ae0d1 to e1efbb7 Compare June 25, 2026 13:53

@fangshuyu-768 fangshuyu-768 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found two issues while reviewing the Slides shortcut changes.

Comment thread shortcuts/slides/slides_screenshot.go
Comment thread shortcuts/slides/slides_replace_pages.go Outdated
@ethan-zhx
ethan-zhx force-pushed the feat/slides_shortcut branch from e1efbb7 to bfdc175 Compare June 26, 2026 04:58

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 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/slides/slides_replace_pages_test.go`:
- Around line 296-302: The validation-path tests in the slide page replacement
cases only assert *errs.ValidationError and ve.Param, so they can miss
regressions in typed metadata and wrapped causes. Update the relevant subtests
to also assert errs.ProblemOf(err) for the problem fields, especially Category
and Subtype, while keeping errors.As for ve.Param since errs.ProblemOf does not
expose Param. For the branches that use .WithCause(...), add checks with
errors.Unwrap or equivalent cause assertions to confirm the original cause is
preserved.
- Around line 37-107: The Slides replace-pages test currently only checks the
final response and does not verify the POST→DELETE sequencing or that DELETE
uses the revision returned by the create call. Update the test around
runSlidesShortcut, createStub, and deleteStub to capture/assert request order
and validate the DELETE payload includes the expected slide_id and revision_id
from the POST response. Keep the existing output assertions, but add explicit
checks that the replacement is created before the old slide is deleted and that
the delete request targets the created revision.
🪄 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: fbf72046-03a5-456c-954c-fffb0567b393

📥 Commits

Reviewing files that changed from the base of the PR and between e1efbb7 and bfdc175.

📒 Files selected for processing (14)
  • cmd/auth/login_test.go
  • shortcuts/slides/shortcuts.go
  • shortcuts/slides/slides_create.go
  • shortcuts/slides/slides_create_test.go
  • shortcuts/slides/slides_replace_pages.go
  • shortcuts/slides/slides_replace_pages_test.go
  • shortcuts/slides/slides_screenshot.go
  • shortcuts/slides/slides_screenshot_test.go
  • shortcuts/slides/slides_xml_get.go
  • shortcuts/slides/slides_xml_get_test.go
  • skills/lark-slides/SKILL.md
  • skills/lark-slides/references/lark-slides-edit-workflows.md
  • skills/lark-slides/references/lark-slides-replace-pages.md
  • skills/lark-slides/references/lark-slides-screenshot.md
✅ Files skipped from review due to trivial changes (3)
  • skills/lark-slides/references/lark-slides-screenshot.md
  • skills/lark-slides/references/lark-slides-edit-workflows.md
  • skills/lark-slides/references/lark-slides-replace-pages.md
🚧 Files skipped from review as they are similar to previous changes (10)
  • shortcuts/slides/slides_screenshot.go
  • shortcuts/slides/slides_xml_get_test.go
  • cmd/auth/login_test.go
  • shortcuts/slides/slides_screenshot_test.go
  • shortcuts/slides/shortcuts.go
  • shortcuts/slides/slides_xml_get.go
  • shortcuts/slides/slides_create.go
  • skills/lark-slides/SKILL.md
  • shortcuts/slides/slides_create_test.go
  • shortcuts/slides/slides_replace_pages.go

Comment thread shortcuts/slides/slides_replace_pages_test.go
Comment thread shortcuts/slides/slides_replace_pages_test.go
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.78652% with 104 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.64%. Comparing base (806e867) to head (6ddbbaf).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
shortcuts/slides/slides_replace_pages.go 79.16% 35 Missing and 20 partials ⚠️
shortcuts/slides/slides_xml_get.go 46.34% 34 Missing and 10 partials ⚠️
shortcuts/slides/slides_replace_slide.go 40.00% 1 Missing and 2 partials ⚠️
shortcuts/slides/shortcuts.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1585      +/-   ##
==========================================
- Coverage   74.74%   74.64%   -0.11%     
==========================================
  Files         799      806       +7     
  Lines       80380    81386    +1006     
==========================================
+ Hits        60084    60752     +668     
- Misses      15849    16101     +252     
- Partials     4447     4533      +86     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ethan-zhx
ethan-zhx force-pushed the feat/slides_shortcut branch from bfdc175 to 8688d7a Compare June 26, 2026 05:19
@ethan-zhx
ethan-zhx force-pushed the feat/slides_shortcut branch from 8688d7a to 6ddbbaf Compare June 26, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Large or sensitive change across domains or core paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants