Skip to content

feat(slides): export slides#988

Open
ethan-zhx wants to merge 1 commit into
mainfrom
feat/export_slides
Open

feat(slides): export slides#988
ethan-zhx wants to merge 1 commit into
mainfrom
feat/export_slides

Conversation

@ethan-zhx
Copy link
Copy Markdown
Collaborator

@ethan-zhx ethan-zhx commented May 20, 2026

Summary

Add Slides export support to drive +export, allowing Feishu/Lark slides documents to be exported as pptx or pdf.
Improve resilience by providing actionable follow-up commands when async export polling times out or download
fails, and update docs/tests accordingly.

Changes

  • Add --doc-type slides support and enable Slides export formats (pptx for slides-only, and pdf) in drive
    +export (shortcuts/drive/drive_export.go).
  • Strengthen shared export validation and filename/output handling to ensure valid doc-type and file-extension
    combinations (shortcuts/drive/drive_export_common.go).
  • Add/extend unit tests for Drive export flows (shortcuts/drive/drive_export_test.go) and update the Drive skill
    documentation (skills/lark-drive/*).

Test Plan

[✓] Unit tests pass (make unit-test)
[ ] Manual local verification confirms the lark xxx command works as expected

Related Issues

• None

Summary by CodeRabbit

  • New Features

    • Drive export now supports slides as a doc type and adds pptx as an export option; pptx maps to .pptx filenames. Validation enforces slides → pptx/pdf and only allows pptx when doc type is slides.
  • Documentation

    • User docs and examples updated to include slides export, allowed doc types, and extensions.
  • Tests

    • Tests updated/added for slides + pptx/pdf validation and filename-extension handling.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

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

This PR adds Slides export support to the Drive shortcut: CLI description and flag enums include slides and pptx; validation enforces pptx ↔ slides constraints and maps pptx to .pptx; tests and documentation are updated to cover the new cases.

Changes

Drive Slides Export Feature

Layer / File(s) Summary
Slides Export Flag and Enum Setup
shortcuts/drive/drive_export.go
DriveExport description now advertises slides; --doc-type enum includes slides; --file-extension enum includes pptx with updated flag description.
Slides Export Validation & Suffix Mapping
shortcuts/drive/drive_export_common.go
validateDriveExportSpec permits slides and pptx, adds cross-field rules: pptx requires --doc-type slides, and --doc-type slides only allows pptx or pdf. exportFileSuffix returns .pptx for pptx.
Filename & Validation Tests
shortcuts/drive/drive_export_common_test.go, shortcuts/drive/drive_export_test.go
Added assertions to ensure .pptx is appended/preserved and extended validation tests to accept slides with pptx/pdf and reject invalid combinations.
User Documentation
skills/lark-drive/SKILL.md, skills/lark-drive/references/lark-drive-export.md
SKILL.md and reference doc updated to list slides as supported, include examples exporting slides to pptx/pdf, and update parameter table and constraint notes (pptx ↔ slides rules).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • larksuite/cli#599: Modifies the same Drive export plumbing (flag enums, validation, suffix mapping) for a different doc-type/extension pair.

Suggested reviewers

  • fangshuyu-768
  • SunPeiYang996

Poem

🐰 A hoppy hop, the slides take flight,
PPTX and PDF gleam in soft light.
Flags and tests hop in tidy rows,
Docs nod yes — the export grows. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% 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 summarizes the main feature being added—Slides export support—which aligns with the primary changes across all modified files.
Description check ✅ Passed The PR description covers all required template sections: Summary, Changes, Test Plan, and Related Issues. It provides specific details about what was added and modified, though manual verification remains pending.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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/export_slides

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 and usage tips.

@github-actions github-actions Bot added domain/ccm PR touches the ccm domain size/L Large or sensitive change across domains or core paths labels May 20, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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/drive/drive_export_common.go`:
- Around line 140-143: The validation allows "pptx" but
ensureExportFileExtension/exportFileSuffix lacks a mapping for it, so add a
branch in the exportFileSuffix function (the switch/if that returns suffix
strings) to return ".pptx" for the "pptx" spec.FileExtension case and ensure
ensureExportFileExtension uses that suffix when appending an extension to
spec.FileName; this restores the auto-add-extension behavior for inputs like
"slides-report".
🪄 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: 3c9b3851-da3b-4515-a4a8-1ba2e7722628

📥 Commits

Reviewing files that changed from the base of the PR and between 9272b9d and 734463a.

📒 Files selected for processing (5)
  • shortcuts/drive/drive_export.go
  • shortcuts/drive/drive_export_common.go
  • shortcuts/drive/drive_export_test.go
  • skills/lark-drive/SKILL.md
  • skills/lark-drive/references/lark-drive-export.md

Comment thread shortcuts/drive/drive_export_common.go
@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.76%. Comparing base (fbe4cc6) to head (898fdbf).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #988      +/-   ##
==========================================
- Coverage   67.76%   67.76%   -0.01%     
==========================================
  Files         590      590              
  Lines       55188    55194       +6     
==========================================
+ Hits        37398    37400       +2     
- Misses      14679    14682       +3     
- Partials     3111     3112       +1     

☔ View full report in Codecov by Sentry.
📢 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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 20, 2026

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@898fdbf06698bc8cc99343bdbadcea5aac50e950

🧩 Skill update

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

@ethan-zhx ethan-zhx force-pushed the feat/export_slides branch from 734463a to 63210de Compare May 20, 2026 07:57
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
shortcuts/drive/drive_export_common.go (1)

140-143: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

pptx is validated but not normalized to .pptx for local filenames.

--file-extension pptx is now accepted, but exportFileSuffix still has no pptx mapping, so ensureExportFileExtension(...) won’t append .pptx for names like --file-name slides-report.

Suggested fix
func exportFileSuffix(fileExtension string) string {
	switch fileExtension {
	case "markdown":
		return ".md"
	case "docx":
		return ".docx"
	case "pdf":
		return ".pdf"
	case "xlsx":
		return ".xlsx"
	case "csv":
		return ".csv"
	case "base":
		return ".base"
+	case "pptx":
+		return ".pptx"
	default:
		return ""
	}
}

Also applies to: 153-159

🤖 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/drive/drive_export_common.go` around lines 140 - 143, The
file-extension handling validates "pptx" but never normalizes it to a filename
suffix; update the mapping used by ensureExportFileExtension (look for
exportFileSuffix and the function ensureExportFileExtension) to include "pptx"
-> ".pptx" so that when spec.FileExtension == "pptx" a missing extension is
appended; mirror the same change in the other mapping area noted around the
second block (the additional mapping at lines 153-159) so both validation and
filename-normalization are consistent.
🧹 Nitpick comments (1)
shortcuts/drive/drive_export_test.go (1)

53-80: ⚡ Quick win

Add a regression test for .pptx filename auto-suffixing.

These new cases validate doc-type/extension compatibility, but they don’t verify that --file-name gets normalized to *.pptx for slides exports. A focused test would prevent this regression from reappearing.

🤖 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/drive/drive_export_test.go` around lines 53 - 80, Add a regression
test in drive_export_test.go that verifies filename auto-suffixing to .pptx for
slides exports: extend the table-driven tests for driveExportSpec by adding a
case (e.g. name "slides pptx filename auto-suffix") with DocType "slides",
FileExtension "pptx" and a FileName value without ".pptx" and assert the command
succeeds and the resulting exported filename (or returned path from the export
function) ends with ".pptx"; also add a complementary case where FileName
already ends with ".pptx" to ensure it is not double-suffixed. Use the existing
driveExportSpec struct and the same test harness/assertion helpers used by the
other cases to locate where to verify the normalized filename.
🤖 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.

Duplicate comments:
In `@shortcuts/drive/drive_export_common.go`:
- Around line 140-143: The file-extension handling validates "pptx" but never
normalizes it to a filename suffix; update the mapping used by
ensureExportFileExtension (look for exportFileSuffix and the function
ensureExportFileExtension) to include "pptx" -> ".pptx" so that when
spec.FileExtension == "pptx" a missing extension is appended; mirror the same
change in the other mapping area noted around the second block (the additional
mapping at lines 153-159) so both validation and filename-normalization are
consistent.

---

Nitpick comments:
In `@shortcuts/drive/drive_export_test.go`:
- Around line 53-80: Add a regression test in drive_export_test.go that verifies
filename auto-suffixing to .pptx for slides exports: extend the table-driven
tests for driveExportSpec by adding a case (e.g. name "slides pptx filename
auto-suffix") with DocType "slides", FileExtension "pptx" and a FileName value
without ".pptx" and assert the command succeeds and the resulting exported
filename (or returned path from the export function) ends with ".pptx"; also add
a complementary case where FileName already ends with ".pptx" to ensure it is
not double-suffixed. Use the existing driveExportSpec struct and the same test
harness/assertion helpers used by the other cases to locate where to verify the
normalized filename.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 068fabfb-6d12-4a2a-a60d-242fb7394dec

📥 Commits

Reviewing files that changed from the base of the PR and between 734463a and 63210de.

📒 Files selected for processing (5)
  • shortcuts/drive/drive_export.go
  • shortcuts/drive/drive_export_common.go
  • shortcuts/drive/drive_export_test.go
  • skills/lark-drive/SKILL.md
  • skills/lark-drive/references/lark-drive-export.md
✅ Files skipped from review due to trivial changes (2)
  • skills/lark-drive/SKILL.md
  • skills/lark-drive/references/lark-drive-export.md

Copy link
Copy Markdown
Collaborator

@fangshuyu-768 fangshuyu-768 left a comment

Choose a reason for hiding this comment

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

Review Summary

Overall the PR is clean and well-structured. The validation logic for slides/pptx is correct, docs are updated, and test coverage is reasonable.

However, there is one Major issue that should be fixed before merging: exportFileSuffix is missing a pptx branch, which will cause the filename auto-suffixing to fail for pptx exports.

See inline comments for details.

Comment thread shortcuts/drive/drive_export_common.go
Comment thread shortcuts/drive/drive_export_test.go
Comment thread shortcuts/drive/drive_export.go
@ethan-zhx ethan-zhx force-pushed the feat/export_slides branch from 63210de to f934436 Compare May 20, 2026 09:31
Copy link
Copy Markdown
Collaborator

@fangshuyu-768 fangshuyu-768 left a comment

Choose a reason for hiding this comment

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

All previously raised issues have been addressed:

  1. [Major] exportFileSuffix missing pptx — Fixed. case "pptx": return ".pptx" added.
  2. [Minor] Missing regression test for .pptx filename auto-suffixing — Fixed. Two test cases added in drive_export_common_test.go covering both auto-suffixing and double-suffix prevention.
  3. [Nit] Redundant validation — No change needed, style observation only.

LGTM.

Copy link
Copy Markdown
Collaborator

@fangshuyu-768 fangshuyu-768 left a comment

Choose a reason for hiding this comment

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

Blocking Issue: drive/v1/export_tasks API does not support slides type

After testing the built binary against the real API, the export call fails with:

field validation failed: type is optional, options: [doc,sheet,bitable,docx]

I also checked the official Feishu OpenAPI docs for Create Export Task. The type parameter only accepts doc, sheet, bitable, docxslides is not a valid value.

This means the core feature of this PR (exporting slides via drive +export) cannot work with the current drive/v1/export_tasks API. The CLI correctly passes type: "slides" to the API, but the API rejects it.

Possible paths forward:

  1. If Feishu has a separate API for slides export (e.g., a slides-specific endpoint), the code needs to route slides exports through that API instead of drive/v1/export_tasks.
  2. If the drive/v1/export_tasks API is being updated to support slides, this PR should wait until that API change is live.
  3. If neither is the case, the slides doc-type should be removed from this PR to avoid shipping a broken feature.

The previous issues (missing exportFileSuffix branch, missing tests) are fixed, but this API compatibility issue is a blocker.

Copy link
Copy Markdown
Collaborator

@fangshuyu-768 fangshuyu-768 left a comment

Choose a reason for hiding this comment

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

Update: slides export works on feishu-pre

I previously flagged that drive/v1/export_tasks rejects type=slides. After testing against the feishu-pre environment (open.feishu-pre.cn), the API does accept slides and both PDF and PPTX exports succeed:

  • PDF: 1.7 MB, downloaded successfully
  • PPTX: 96 KB, downloaded successfully

The production environment (open.feishu.cn) still rejects slides, so this feature will only work once the API change rolls out to production. This is expected for a pre-release feature.

With the previous issues (missing exportFileSuffix branch, missing tests) already fixed, and the API confirmed working on feishu-pre, I'm changing my stance — this PR is ready to merge once the API is live in production.

fangshuyu-768
fangshuyu-768 previously approved these changes May 20, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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 `@skills/lark-drive/SKILL.md`:
- Line 267: The table row for the `+sync` command is broken by unescaped pipe
characters inside the code span for the conflict options; update the
`--on-conflict` fragment (the code span currently split across the row) so the
entire option list is a single inline code span or escape each pipe (e.g. make
it one backtick-wrapped string like
`--on-conflict=remote-wins|local-wins|keep-both|ask` or use
`--on-conflict=remote-wins\|local-wins\|keep-both\|ask`) to prevent Markdown
from treating those pipes as column separators and restore the two-column table
row.
🪄 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: dbe30d4f-bc88-4abb-891d-dc11acc0a883

📥 Commits

Reviewing files that changed from the base of the PR and between f934436 and 7282333.

📒 Files selected for processing (6)
  • shortcuts/drive/drive_export.go
  • shortcuts/drive/drive_export_common.go
  • shortcuts/drive/drive_export_common_test.go
  • shortcuts/drive/drive_export_test.go
  • skills/lark-drive/SKILL.md
  • skills/lark-drive/references/lark-drive-export.md
✅ Files skipped from review due to trivial changes (1)
  • skills/lark-drive/references/lark-drive-export.md

Comment thread skills/lark-drive/SKILL.md Outdated
Change-Id: Ice3e8784e78986d427c4c94664e1e5edff2a4fcd
@ethan-zhx ethan-zhx force-pushed the feat/export_slides branch from 7282333 to 898fdbf Compare May 22, 2026 04:00
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
skills/lark-drive/SKILL.md (1)

267-267: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Escape pipe characters in the +sync table row to prevent Markdown table corruption.

This row still renders as extra columns because unescaped | appears inside the description cell.

💡 Minimal doc fix
-| `+sync` | Two-way local ↔ Drive sync. Reuses `+status` diff buckets, pulls `new_remote`, pushes `new_local`, and resolves `modified` via `--on-conflict=remote-wins|local-wins|keep-both|ask`. `--quick` enables best-effort modified-time diffing (timestamp mismatches can still trigger real pull/push actions), `--on-duplicate-remote` supports `fail|newest|oldest`, and the command is intentionally non-destructive (no delete on either side). |
+| `+sync` | Two-way local ↔ Drive sync. Reuses `+status` diff buckets, pulls `new_remote`, pushes `new_local`, and resolves `modified` via `--on-conflict=remote-wins\|local-wins\|keep-both\|ask`. `--quick` enables best-effort modified-time diffing (timestamp mismatches can still trigger real pull/push actions), `--on-duplicate-remote` supports `fail\|newest\|oldest`, and the command is intentionally non-destructive (no delete on either side). |
🤖 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 `@skills/lark-drive/SKILL.md` at line 267, The `+sync` table row contains
unescaped pipe characters inside flag examples which break the Markdown table;
update that row by escaping each pipe with a backslash (e.g. change
--on-conflict=remote-wins|local-wins|keep-both|ask to
--on-conflict=remote-wins\|local-wins\|keep-both\|ask and --on-duplicate-remote
fail|newest|oldest to --on-duplicate-remote fail\|newest\|oldest), and escape
any other literal '|' characters in the same cell so the table renders as a
single description cell for `+sync`.
🤖 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.

Duplicate comments:
In `@skills/lark-drive/SKILL.md`:
- Line 267: The `+sync` table row contains unescaped pipe characters inside flag
examples which break the Markdown table; update that row by escaping each pipe
with a backslash (e.g. change --on-conflict=remote-wins|local-wins|keep-both|ask
to --on-conflict=remote-wins\|local-wins\|keep-both\|ask and
--on-duplicate-remote fail|newest|oldest to --on-duplicate-remote
fail\|newest\|oldest), and escape any other literal '|' characters in the same
cell so the table renders as a single description cell for `+sync`.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 11fe3806-1a46-4a5d-9c88-52ba997643a4

📥 Commits

Reviewing files that changed from the base of the PR and between 7282333 and 898fdbf.

📒 Files selected for processing (6)
  • shortcuts/drive/drive_export.go
  • shortcuts/drive/drive_export_common.go
  • shortcuts/drive/drive_export_common_test.go
  • shortcuts/drive/drive_export_test.go
  • skills/lark-drive/SKILL.md
  • skills/lark-drive/references/lark-drive-export.md
✅ Files skipped from review due to trivial changes (1)
  • skills/lark-drive/references/lark-drive-export.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/ccm PR touches the ccm domain 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