feat(slides): return presentation URL in slides +create output#425
feat(slides): return presentation URL in slides +create output#425fangshuyu-768 merged 1 commit intomainfrom
Conversation
📝 WalkthroughWalkthroughA best-effort metadata fetch to Drive’s Changes
Sequence DiagramsequenceDiagram
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)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Greptile SummaryThis PR adds a best-effort Confidence Score: 5/5Safe 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
Sequence DiagramsequenceDiagram
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
Reviews (2): Last reviewed commit: "feat(slides): return presentation URL in..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
shortcuts/slides/slides_create_test.go (1)
625-639: Strengthenbatch_querytests 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 usingjson.Unmarshalon the stub'sCapturedBodyfield; consider extending theregisterBatchQueryStubhelper 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
📒 Files selected for processing (3)
shortcuts/slides/slides_create.goshortcuts/slides/slides_create_test.goskills/lark-slides/references/lark-slides-create.md
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@d11c5e9f9e68ba648275b12390e3bfe6e1d564a2🧩 Skill updatenpx 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.
e24bb43 to
d11c5e9
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
shortcuts/slides/slides_create_test.go (1)
625-639: Assertbatch_queryrequest payload usingCapturedBody.
registerBatchQueryStubcurrently 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 viajson.Unmarshal(stub.CapturedBody, ...). This helper should similarly validate that the request containswith_url: trueand the expectedrequest_docsstructure 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
📒 Files selected for processing (3)
shortcuts/slides/slides_create.goshortcuts/slides/slides_create_test.goskills/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
Summary
slides +createnow returns aurlfield containing the presentation's web link, consistent withdocs +create(returnsdoc_url) andsheets +create(returnsurl)POST /open-apis/drive/v1/metas/batch_querywithwith_url: trueto fetch the document URLurlfield is omittedlark-slides-create.md) to document the newurlreturn fieldDetails
The slides AI creation API (
POST /open-apis/slides_ai/v1/xml_presentations) only returnsxml_presentation_id— no web URL. Unlike the Sheets API which includesurldirectly in its creation response, or the Docs MCP tool which returnsdoc_url, the slides shortcut had no way to give users a clickable link.The fix uses the drive meta
batch_queryendpoint. Key finding: thewith_urlbody parameter must be set totrue, otherwise theurlfield in the response is always empty for slides documents.Test plan
TestSlidesCreateURLFetchBestEffort)--slides, and bot mode — all return correct URLbatch_queryreturns an error (no crash,urlfield simply omitted)Summary by CodeRabbit
New Features
Documentation
Tests