Skip to content

fix(slides): add agent-friendly aliases for screenshot flags - #2156

Merged
BD-ZERO merged 7 commits into
mainfrom
fix/slides-screenshot-parameter-robustness
Aug 4, 2026
Merged

fix(slides): add agent-friendly aliases for screenshot flags#2156
BD-ZERO merged 7 commits into
mainfrom
fix/slides-screenshot-parameter-robustness

Conversation

@BD-ZERO

@BD-ZERO BD-ZERO commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Improve slides +screenshot compatibility for common AI-generated presentation and slide selector flags while preserving the canonical interface.

Changes

  • Add hidden --presentation-id alias for --presentation
  • Add hidden --slide alias:
    • positive integer routes to slide number
    • SXSD short slide ID matching p[A-Za-z]{2,} routes to slide ID
  • Add hidden comma-separated aliases:
    • --slide-ids
    • --slide-numbers
    • --slides
  • Keep canonical flags authoritative when canonical and alias forms are both present
  • Reject invalid or ambiguous --slide values with typed validation metadata
  • Add unit, dry-run E2E, and self-contained bot live E2E coverage

Test Plan

  • GOTOOLCHAIN=go1.23.12 make build
  • GOTOOLCHAIN=go1.23.12 make unit-test
  • GOTOOLCHAIN=go1.23.12 go vet ./...
  • gofmt -l . produces no output
  • GOTOOLCHAIN=go1.23.12 go mod tidy leaves go.mod and go.sum unchanged
  • golangci-lint reports 0 issues
  • Screenshot alias dry-run E2E passes locally
  • Bot screenshot alias live E2E passes in PR CI

Related Issues

  • None

Summary by CodeRabbit

  • New Features

    • Added convenient aliases for selecting presentations and slides in screenshot commands.
    • Supports positive slide numbers, slide IDs, and comma-separated selections.
    • Added presentation selection through --presentation-id.
  • Bug Fixes

    • Improved validation and guidance for invalid, duplicate, empty, or ambiguous selectors.
    • Ensured consistent selector behavior across validation, dry runs, and execution.
    • Preserved canonical option precedence when aliases are combined.
    • Empty slide IDs now correctly fall back to content-based rendering.

@github-actions github-actions Bot added the size/M Single-domain feat or fix with limited business impact label Aug 3, 2026
@coderabbitai

coderabbitai Bot commented Aug 3, 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
📝 Walkthrough

Walkthrough

The Slides screenshot shortcut adds hidden slide aliases. Shared parsing handles slide numbers and IDs across validation, dry-run, and execution. Tests cover precedence, invalid values, request generation, and live screenshot output.

Changes

Slides screenshot aliases

Layer / File(s) Summary
Selector aliases and normalization
shortcuts/slides/slides_screenshot.go, shortcuts/slides/slides_add_slide.go, shortcuts/slides/slides_delete_slide.go, shortcuts/slides/shortcuts_alias_test.go
Adds hidden slide aliases and shared presentation-reference flag configuration. The --slide alias routes numeric values to slide numbers and other values to slide IDs.
Screenshot flow integration
shortcuts/slides/slides_screenshot.go
Uses centralized selectors in validation, dry-run, execution, and content-render paths.
Alias validation and request coverage
shortcuts/slides/slides_screenshot_test.go, tests/cli_e2e/slides/slides_screenshot_dryrun_test.go, tests/cli_e2e/slides/slides_screenshot_workflow_test.go
Tests alias metadata, merging, precedence, invalid values, generated requests, dry-run output, and live screenshot properties.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant SlidesScreenshot
  participant SelectorHelpers
  participant ScreenshotAPI
  CLI->>SlidesScreenshot: pass presentation and slide selectors
  SlidesScreenshot->>SelectorHelpers: parse and normalize selectors
  SelectorHelpers-->>SlidesScreenshot: return effective selectors
  SlidesScreenshot->>ScreenshotAPI: build screenshot request
  ScreenshotAPI-->>CLI: emit dry-run request or execute request
Loading

Possibly related PRs

  • larksuite/cli#2120: Modifies the same Slides add/delete flag definitions used by this change.
  • larksuite/cli#2164: Overlaps on shared presentation aliases for Slides add/delete commands.
  • larksuite/cli#2168: Updates the same Slides files and shared presentation-reference alias checks.

Suggested labels: domain/im, bugfix

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% 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 and concisely describes the main change: adding agent-friendly aliases for Slides screenshot flags.
Description check ✅ Passed The description includes the required summary, changes, test plan, and related issues sections with specific implementation and verification details.
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 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/slides-screenshot-parameter-robustness

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.

@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_screenshot_test.go`:
- Around line 157-166: Update the error assertions in the slide validation test
to capture the metadata returned by errs.ProblemOf(err) and assert category is
errs.CategoryValidation, subtype is errs.SubtypeInvalidArgument, and param is
"--slide". Keep the existing *errs.ValidationError type assertion if needed, but
ensure all required typed metadata is verified through errs.ProblemOf.

In `@tests/cli_e2e/slides/slides_screenshot_dryrun_test.go`:
- Around line 51-78: Add a live E2E workflow alongside
TestSlidesScreenshotAliasesDryRunE2E that creates the required presentation and
slides, invokes slides +screenshot using the aliases with bot credentials,
verifies the saved screenshot output, and cleans up all created resources via
test cleanup. Keep the existing dry-run request-generation assertions unchanged
and make the live test self-contained.
🪄 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 Plus

Run ID: 4d78c342-a02e-48db-bfeb-d43f185994c8

📥 Commits

Reviewing files that changed from the base of the PR and between 2dafa03 and 1fbfb41.

📒 Files selected for processing (3)
  • shortcuts/slides/slides_screenshot.go
  • shortcuts/slides/slides_screenshot_test.go
  • tests/cli_e2e/slides/slides_screenshot_dryrun_test.go

Comment thread shortcuts/slides/slides_screenshot_test.go Outdated
Comment thread tests/cli_e2e/slides/slides_screenshot_dryrun_test.go
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@806616b12ab08ac8671d133bcf216b22990d3ba8

🧩 Skill update

npx skills add larksuite/cli#fix/slides-screenshot-parameter-robustness -y -g

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.50704% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.70%. Comparing base (0f29e03) to head (806616b).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
shortcuts/slides/slides_screenshot.go 84.50% 7 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2156      +/-   ##
==========================================
+ Coverage   75.69%   75.70%   +0.01%     
==========================================
  Files         942      944       +2     
  Lines      100079   100284     +205     
==========================================
+ Hits        75750    75922     +172     
- Misses      18537    18565      +28     
- Partials     5792     5797       +5     

☔ 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.

@BD-ZERO
BD-ZERO force-pushed the fix/slides-screenshot-parameter-robustness branch from 82a83d0 to 9dece89 Compare August 3, 2026 12:14

@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 `@tests/cli_e2e/slides/slides_screenshot_workflow_test.go`:
- Around line 48-53: Move the parentT.Cleanup registration in the slide
screenshot workflow to immediately after extracting and validating
presentationID, before extracting or asserting slideID. Ensure cleanup still
targets the created presentation so failures in slideID validation cannot leave
tenant data behind.
- Around line 95-97: Update the image inspection in the screenshot workflow test
to open imagePath through the repository’s internal/vfs API instead of os.Open,
while preserving the existing error assertion and deferred close. Remove the
now-unused os import; the fixture setup exception does not apply here.
🪄 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 Plus

Run ID: a5425750-f3b2-40e6-9b90-1f04f3b67dea

📥 Commits

Reviewing files that changed from the base of the PR and between 1fbfb41 and 9dece89.

📒 Files selected for processing (4)
  • shortcuts/slides/slides_screenshot.go
  • shortcuts/slides/slides_screenshot_test.go
  • tests/cli_e2e/slides/slides_screenshot_dryrun_test.go
  • tests/cli_e2e/slides/slides_screenshot_workflow_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • tests/cli_e2e/slides/slides_screenshot_dryrun_test.go
  • shortcuts/slides/slides_screenshot_test.go
  • shortcuts/slides/slides_screenshot.go

Comment thread tests/cli_e2e/slides/slides_screenshot_workflow_test.go
Comment thread tests/cli_e2e/slides/slides_screenshot_workflow_test.go Outdated

@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

🤖 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_screenshot.go`:
- Around line 288-291: The mixed-selector validation error must include its
parameter metadata and the E2E test must verify it. In
shortcuts/slides/slides_screenshot.go lines 288-291, update the error built in
the slideIDs/slideNumbers validation branch with a consistent WithParam value;
in tests/cli_e2e/slides/slides_screenshot_dryrun_test.go lines 97-100, assert
that result.Stderr contains the expected error.param value.
🪄 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 Plus

Run ID: 9d4ea7e5-2977-410b-9fce-bbaf80ec9fde

📥 Commits

Reviewing files that changed from the base of the PR and between 9dece89 and ba04bd4.

📒 Files selected for processing (6)
  • shortcuts/slides/shortcuts_alias_test.go
  • shortcuts/slides/slides_add_slide.go
  • shortcuts/slides/slides_delete_slide.go
  • shortcuts/slides/slides_screenshot.go
  • shortcuts/slides/slides_screenshot_test.go
  • tests/cli_e2e/slides/slides_screenshot_dryrun_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • shortcuts/slides/slides_screenshot_test.go

Comment thread shortcuts/slides/slides_screenshot.go

@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

🤖 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 `@tests/cli_e2e/slides/slides_screenshot_dryrun_test.go`:
- Around line 119-123: Update the dry-run validation assertions in the slides
screenshot test to verify the complete typed error envelope from result.Stderr:
assert the expected error.type, error.subtype, error.param, and error.message,
while preserving the exit-code 2 assertion. Also assert that result.Stdout is
empty.
🪄 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 Plus

Run ID: 1201b473-e85f-42f6-b7d3-764257f6b278

📥 Commits

Reviewing files that changed from the base of the PR and between ba04bd4 and 6f42b5d.

📒 Files selected for processing (3)
  • shortcuts/slides/slides_screenshot.go
  • shortcuts/slides/slides_screenshot_test.go
  • tests/cli_e2e/slides/slides_screenshot_dryrun_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • shortcuts/slides/slides_screenshot.go
  • shortcuts/slides/slides_screenshot_test.go

Comment thread tests/cli_e2e/slides/slides_screenshot_dryrun_test.go
BD-ZERO added 5 commits August 4, 2026 10:51
Accept common presentation and slide selector aliases while keeping canonical flags authoritative. Validate the ambiguous --slide alias using the SXSD short slide ID format and cover the behavior with unit and dry-run E2E tests.
Assert the full typed validation contract for ambiguous --slide values and add a self-contained bot workflow that creates a presentation, exercises screenshot aliases, verifies the saved image, and cleans up the resource.
@BD-ZERO
BD-ZERO force-pushed the fix/slides-screenshot-parameter-robustness branch from a0f1a84 to a340d43 Compare August 4, 2026 02:52
Comment thread shortcuts/slides/slides_screenshot.go
Comment thread shortcuts/slides/slides_screenshot.go
fangshuyu-768
fangshuyu-768 previously approved these changes Aug 4, 2026
Comment thread shortcuts/slides/slides_screenshot.go Outdated
@BD-ZERO
BD-ZERO merged commit b299794 into main Aug 4, 2026
27 checks passed
@BD-ZERO
BD-ZERO deleted the fix/slides-screenshot-parameter-robustness branch August 4, 2026 04:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants