Skip to content

feat(slides): return presentation URL in slides +create output#425

Merged
fangshuyu-768 merged 1 commit intomainfrom
feat/slides-create-return-url
Apr 11, 2026
Merged

feat(slides): return presentation URL in slides +create output#425
fangshuyu-768 merged 1 commit intomainfrom
feat/slides-create-return-url

Conversation

@ViperCai
Copy link
Copy Markdown
Collaborator

@ViperCai ViperCai commented Apr 11, 2026

Summary

  • slides +create now returns a url field containing the presentation's web link, consistent with docs +create (returns doc_url) and sheets +create (returns url)
  • After creating the presentation, the shortcut calls POST /open-apis/drive/v1/metas/batch_query with with_url: true to fetch the document URL
  • The URL fetch is best-effort: if the API call fails (e.g. missing scope), the shortcut still succeeds — only the url field is omitted
  • Updated the skill reference doc (lark-slides-create.md) to document the new url return field

Details

The slides AI creation API (POST /open-apis/slides_ai/v1/xml_presentations) only returns xml_presentation_id — no web URL. Unlike the Sheets API which includes url directly in its creation response, or the Docs MCP tool which returns doc_url, the slides shortcut had no way to give users a clickable link.

The fix uses the drive meta batch_query endpoint. Key finding: the with_url body parameter must be set to true, otherwise the url field in the response is always empty for slides documents.

Test plan

  • All 15 slides create tests pass (including new TestSlidesCreateURLFetchBestEffort)
  • Verified real API calls in user mode, user mode with --slides, and bot mode — all return correct URL
  • Verified graceful degradation when batch_query returns an error (no crash, url field simply omitted)

Summary by CodeRabbit

  • New Features

    • Slides create command now returns an online link (url) for newly created presentations when available (best-effort).
  • Documentation

    • Added optional url field to slides create output; noted it may be omitted if retrieval fails or permissions are insufficient.
  • Tests

    • Added/updated tests to cover successful URL retrieval and cases where URL fetching fails.

@github-actions github-actions bot added the size/M Single-domain feat or fix with limited business impact label Apr 11, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 11, 2026

📝 Walkthrough

Walkthrough

A best-effort metadata fetch to Drive’s /open-apis/drive/v1/metas/batch_query was added after creating a presentation; if the call returns a non-empty metas[0].url, the shortcut sets result["url"]. Errors or missing URL data are ignored and do not change existing behavior.

Changes

Cohort / File(s) Summary
Core Implementation
shortcuts/slides/slides_create.go
After creating the presentation (and optional slides), perform a best-effort POST /open-apis/drive/v1/metas/batch_query with doc_token=presentationID, doc_type:"slides"; set result["url"] only if response contains a non-empty metas[0].url. Failures are ignored.
Tests
shortcuts/slides/slides_create_test.go
Added registerBatchQueryStub helper; updated multiple tests to register the batch_query stub and expect data["url"]; added TestSlidesCreateURLFetchBestEffort which stubs batch_query failure and asserts url is omitted while shortcut succeeds.
Documentation
skills/lark-slides/references/lark-slides-create.md
Documented an optional url (string) field in the slides +create JSON response, noting it is returned only when metadata retrieval succeeds and permissions allow; otherwise omitted.

Sequence Diagram

sequenceDiagram
    actor Client
    participant Shortcut as Shortcut Handler
    participant SlidesAPI as Slides API
    participant DriveAPI as Drive API

    Client->>Shortcut: Create presentation
    Shortcut->>SlidesAPI: Create presentation (xml_presentations)
    SlidesAPI-->>Shortcut: presentationID
    Shortcut->>DriveAPI: batch_query metas (doc_token=presentationID, doc_type=slides)
    alt Metadata fetch succeeds
        DriveAPI-->>Shortcut: metas[0].url
        Shortcut->>Shortcut: set result["url"]
    else Metadata fetch fails or empty
        DriveAPI-->>Shortcut: error or empty metas
        Shortcut->>Shortcut: leave result without url
    end
    Shortcut-->>Client: Return result (includes url if available)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 I hopped to fetch a link so fine,

Created slides then sniffed a line.
Best-effort peeks through Drive's way,
If found, a URL will bright the day. 🎈

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: adding a URL field to the slides +create command output.
Description check ✅ Passed The description fully covers all required template sections: Summary, Changes, Test Plan, and Related Issues. It provides comprehensive detail about the implementation, API interactions, and verification.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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/slides-create-return-url

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

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 11, 2026

Greptile Summary

This PR adds a best-effort url field to the slides +create output by calling POST /open-apis/drive/v1/metas/batch_query with with_url: true after the presentation (and any slides) are created. The implementation is clean: the URL fetch is fully fire-and-forget, failures are silently ignored, and the documentation correctly marks url as optional with a note that it may be absent when drive permissions are insufficient.

Confidence Score: 5/5

Safe to merge — implementation is correct, best-effort error handling is properly applied, and all 15 tests pass.

No P0 or P1 findings. The URL fetch correctly runs after all slides are added, CallAPI already extracts the data envelope so GetSlice(metaData, metas) resolves correctly, and the mock stubs round-trip through JSON so the []map[string]interface{} type is unmarshalled back as []interface{} as expected by GetSlice. The previously flagged doc concern (url appearing required) is resolved — the field is now marked 可选 with a clear caveat.

No files require special attention.

Important Files Changed

Filename Overview
shortcuts/slides/slides_create.go Adds best-effort batch_query call after slide creation to populate url; ordering (after slides are added, before bot grant) is correct, error handling is idiomatic, and response parsing via GetSlice/GetString correctly operates on the data-extracted map returned by CallAPI.
shortcuts/slides/slides_create_test.go All existing tests updated to register batch_query stubs; new TestSlidesCreateURLFetchBestEffort test confirms graceful degradation when the endpoint returns an error code.
skills/lark-slides/references/lark-slides-create.md Documents url as optional (可选) with a clear note that it may be omitted when drive permissions are insufficient — previous thread concern addressed.

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as slides +create
    participant SlidesAPI as slides_ai API
    participant DriveAPI as drive meta API

    User->>CLI: slides +create --title "..." [--slides [...]]
    CLI->>SlidesAPI: POST /open-apis/slides_ai/v1/xml_presentations
    SlidesAPI-->>CLI: xml_presentation_id, revision_id

    opt --slides provided
        loop for each slide XML
            CLI->>SlidesAPI: POST /xml_presentations/{id}/slide
            SlidesAPI-->>CLI: slide_id
        end
    end

    CLI->>DriveAPI: POST /open-apis/drive/v1/metas/batch_query (with_url: true)
    alt batch_query succeeds
        DriveAPI-->>CLI: metas[0].url
        CLI-->>User: { xml_presentation_id, title, revision_id, url, ... }
    else batch_query fails (e.g. missing scope)
        DriveAPI-->>CLI: error
        CLI-->>User: { xml_presentation_id, title, revision_id } (url omitted)
    end

    opt --as bot
        CLI->>CLI: AutoGrantCurrentUserDrivePermission
        CLI-->>User: + permission_grant
    end
Loading

Reviews (2): Last reviewed commit: "feat(slides): return presentation URL in..." | Re-trigger Greptile

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

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

625-639: Strengthen batch_query tests by asserting request payload, not only response.

The stub currently matches only method+URL, so regressions in request construction (with_url, doc_token, doc_type) may go undetected. Other tests in the codebase already validate request bodies using json.Unmarshal on the stub's CapturedBody field; consider extending the registerBatchQueryStub helper to validate that the inbound request includes the required fields with correct values.

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@skills/lark-slides/references/lark-slides-create.md`:
- Line 33: Update the return schema documentation to mark the `url` field as
optional/best-effort rather than required; specifically, change the description
of `url` in the return schema for larkSlidesCreate (or the "return
schema"/"response" section) to indicate it may be omitted when drive
`batch_query` fails or other external retrieval errors occur, and include a
short note about the omission conditions so callers know to handle its absence.
🪄 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: 703b7926-ed46-4183-adb4-4c34f766362b

📥 Commits

Reviewing files that changed from the base of the PR and between a9c07ce and 535f21a.

📒 Files selected for processing (3)
  • shortcuts/slides/slides_create.go
  • shortcuts/slides/slides_create_test.go
  • skills/lark-slides/references/lark-slides-create.md

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 11, 2026

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#feat/slides-create-return-url -y -g

After creating the presentation, call drive batch_query (with_url=true)
to fetch the document URL and include it in the output. The fetch is
best-effort so it won't break creation if the API call fails.

Also update the skill reference doc to document the new optional url
return field.
@ViperCai ViperCai force-pushed the feat/slides-create-return-url branch from e24bb43 to d11c5e9 Compare April 11, 2026 13:09
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.

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

625-639: Assert batch_query request payload using CapturedBody.

registerBatchQueryStub currently mocks only the response, not the request contract. Other tests in the codebase (e.g., wiki_node_create_test.go, minutes_search_test.go) validate request payloads via json.Unmarshal(stub.CapturedBody, ...). This helper should similarly validate that the request contains with_url: true and the expected request_docs structure to prevent construction regressions.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@shortcuts/slides/slides_create_test.go` around lines 625 - 639, The helper
registerBatchQueryStub currently only sets the mocked response; update it to
capture and assert the incoming request payload by creating the httpmock.Stub
(keep the existing Method/URL/response body) and after registering, inspect
stub.CapturedBody (or set a ReplyFunc that records the request body) and
json.Unmarshal(stub.CapturedBody, &payload) to assert payload["with_url"] ==
true and that payload["request_docs"] matches the expected slice containing the
doc_token/token and doc_type "slides"; modify registerBatchQueryStub to perform
these validations before returning so tests will fail on request-construction
regressions (refer to symbols: registerBatchQueryStub, httpmock.Stub,
stub.CapturedBody, json.Unmarshal).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@shortcuts/slides/slides_create_test.go`:
- Around line 625-639: The helper registerBatchQueryStub currently only sets the
mocked response; update it to capture and assert the incoming request payload by
creating the httpmock.Stub (keep the existing Method/URL/response body) and
after registering, inspect stub.CapturedBody (or set a ReplyFunc that records
the request body) and json.Unmarshal(stub.CapturedBody, &payload) to assert
payload["with_url"] == true and that payload["request_docs"] matches the
expected slice containing the doc_token/token and doc_type "slides"; modify
registerBatchQueryStub to perform these validations before returning so tests
will fail on request-construction regressions (refer to symbols:
registerBatchQueryStub, httpmock.Stub, stub.CapturedBody, json.Unmarshal).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 24e34476-0132-4a11-95d6-7191289c9197

📥 Commits

Reviewing files that changed from the base of the PR and between e24bb43 and d11c5e9.

📒 Files selected for processing (3)
  • shortcuts/slides/slides_create.go
  • shortcuts/slides/slides_create_test.go
  • skills/lark-slides/references/lark-slides-create.md
✅ Files skipped from review due to trivial changes (1)
  • skills/lark-slides/references/lark-slides-create.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • shortcuts/slides/slides_create.go

@fangshuyu-768 fangshuyu-768 merged commit e07842d into main Apr 11, 2026
17 checks passed
@fangshuyu-768 fangshuyu-768 deleted the feat/slides-create-return-url branch April 11, 2026 13:19
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