feat(drive): add comment batch-query/resolve/reply shortcuts#1898
feat(drive): add comment batch-query/resolve/reply shortcuts#1898zzzchao123 wants to merge 1 commit into
Conversation
|
zchao.007 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
📝 WalkthroughWalkthroughAdds four Drive comment workflow shortcuts for batch querying, resolving/restoring, adding replies, and deleting replies. Shared input handling supports Drive URLs, tokens, resource types, and Wiki unwrapping, with dry-run plans, tests, registry updates, and documentation. ChangesDrive comment workflows
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant resolveDriveCommentTarget
participant WikiNodeAPI
participant DriveCommentAPI
CLI->>resolveDriveCommentTarget: resolve URL, token, and type
resolveDriveCommentTarget->>WikiNodeAPI: GET wiki node
WikiNodeAPI-->>resolveDriveCommentTarget: return obj_type and obj_token
resolveDriveCommentTarget->>DriveCommentAPI: query or mutate resolved comment target
DriveCommentAPI-->>CLI: return operation result
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
81c45ba to
e1e08b2
Compare
There was a problem hiding this comment.
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/drive/coverage.md`:
- Around line 32-35: Add a self-contained live E2E workflow test file covering
the shortcut flows in TestDrive_CommentOpsDryRun: +batch-query-comments,
+resolve-comment, +add-reply, and +delete-reply. Use the live API to create
required comments and replies, exercise each operation including both resolve
and restore behavior, verify responses and state changes, then clean up all
created resources even when assertions fail.
In `@tests/cli_e2e/drive/drive_comment_ops_dryrun_test.go`:
- Around line 18-181: Add a self-contained live E2E test alongside
TestDrive_CommentOpsDryRun covering +batch-query-comments, +resolve-comment,
+add-reply, and +delete-reply. Create the required document/comment fixture,
exercise each shortcut against the live service with assertions on the
round-trip results, and ensure cleanup runs reliably via test cleanup even when
assertions fail.
🪄 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: c98e4543-2937-4a11-9d83-f1381cd3423b
📒 Files selected for processing (23)
internal/qualitygate/diff/diff.gointernal/qualitygate/diff/diff_test.goshortcuts/base/base_resolve.goshortcuts/drive/drive_add_reply.goshortcuts/drive/drive_add_reply_test.goshortcuts/drive/drive_batch_query_comments.goshortcuts/drive/drive_batch_query_comments_test.goshortcuts/drive/drive_comment_common.goshortcuts/drive/drive_comment_common_test.goshortcuts/drive/drive_delete_reply.goshortcuts/drive/drive_delete_reply_test.goshortcuts/drive/drive_export.goshortcuts/drive/drive_import.goshortcuts/drive/drive_inspect.goshortcuts/drive/drive_list_comments.goshortcuts/drive/drive_resolve_comment.goshortcuts/drive/drive_resolve_comment_test.goshortcuts/drive/shortcuts.goshortcuts/drive/shortcuts_test.goskills/lark-drive/SKILL.mdskills/lark-drive/references/lark-drive-comments-guide.mdtests/cli_e2e/drive/coverage.mdtests/cli_e2e/drive/drive_comment_ops_dryrun_test.go
e1e08b2 to
3ea7e26
Compare
3ea7e26 to
11e1595
Compare
|
Current PR head is still For the apps regression check, I used the provided page URL: ./lark-cli drive +list-comments --url "https://bytedance.feishu.cn/page/N1BWmMrqndT5ZcamAIBcnvDLnOf/" --solved-status all --page-size 100 --as bot --format jsonThis succeeds as bot and returns |
11e1595 to
41a7462
Compare
There was a problem hiding this comment.
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`:
- Around line 104-105: 更新 SKILL.md 中关于评论文本转义的说明,明确使用 drive +add-comment 或 drive
+add-reply shortcut 时传入原始文本,由 shortcut 自动转义;直接调用 drive file.comments create_v2 或
drive file.comment.replys update 时,调用方必须先将文本中的 < 和 > 转义后再提交,避免 shortcut 调用方重复转义。
🪄 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: 7ec789d4-d494-456d-87e5-e38253e05dac
📒 Files selected for processing (16)
shortcuts/drive/drive_add_reply.goshortcuts/drive/drive_add_reply_test.goshortcuts/drive/drive_batch_query_comments.goshortcuts/drive/drive_batch_query_comments_test.goshortcuts/drive/drive_comment_common.goshortcuts/drive/drive_comment_common_test.goshortcuts/drive/drive_delete_reply.goshortcuts/drive/drive_delete_reply_test.goshortcuts/drive/drive_resolve_comment.goshortcuts/drive/drive_resolve_comment_test.goshortcuts/drive/shortcuts.goshortcuts/drive/shortcuts_test.goskills/lark-drive/SKILL.mdskills/lark-drive/references/lark-drive-comments-guide.mdtests/cli_e2e/drive/coverage.mdtests/cli_e2e/drive/drive_comment_ops_dryrun_test.go
🚧 Files skipped from review as they are similar to previous changes (15)
- shortcuts/drive/drive_delete_reply_test.go
- shortcuts/drive/shortcuts.go
- shortcuts/drive/drive_batch_query_comments.go
- shortcuts/drive/drive_delete_reply.go
- shortcuts/drive/drive_batch_query_comments_test.go
- shortcuts/drive/drive_resolve_comment_test.go
- shortcuts/drive/shortcuts_test.go
- shortcuts/drive/drive_comment_common.go
- tests/cli_e2e/drive/drive_comment_ops_dryrun_test.go
- shortcuts/drive/drive_resolve_comment.go
- tests/cli_e2e/drive/coverage.md
- shortcuts/drive/drive_comment_common_test.go
- shortcuts/drive/drive_add_reply.go
- shortcuts/drive/drive_add_reply_test.go
- skills/lark-drive/references/lark-drive-comments-guide.md
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1898 +/- ##
==========================================
+ Coverage 74.68% 74.83% +0.14%
==========================================
Files 878 891 +13
Lines 91894 93095 +1201
==========================================
+ Hits 68633 69664 +1031
- Misses 17941 18061 +120
- Partials 5320 5370 +50 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@a5e2d294f314ad353fcc1ca848584f5a23850732🧩 Skill updatenpx skills add larksuite/cli#feat/drive-comment-shortcuts -y -g |
41a7462 to
b7aea0b
Compare
Add four comment-operation shortcuts to the drive domain, all accepting --url / --token + --type with automatic wiki-node unwrapping: - +batch-query-comments: POST files/:token/comments/batch_query (--comment-ids CSV/repeated, max 100; --need-reaction) - +resolve-comment: PATCH files/:token/comments/:comment_id (--action resolve|restore -> is_solved true/false) - +add-reply: POST files/:token/comments/:comment_id/replies (--content reuses the +add-comment reply_elements JSON, its escaping and length preflight, mapped to text_run/person/docs_link) - +delete-reply: DELETE .../comments/:comment_id/replies/:reply_id (high-risk-write, requires --yes) Shared --url/--token/--type resolution and wiki unwrapping live in drive_comment_common.go, parameterized by each endpoint's supported file_type set. Supported targets follow the platform API metadata: doc/docx/sheet/file/slides plus bitable (base alias) on all four, and Miaoda apps (/page/<token> URLs or bare tokens with --type apps), matching the apps comment support +list-comments gained on main. Scopes follow the per-endpoint metadata: +add-reply requires docs:document.comment:create (the replies create endpoint does not accept docs:document.comment:write_only), while resolve/delete keep write_only and batch-query keeps docs:document.comment:read. Note on +add-reply: the documented alternative (POST .../comments with comment_id in the request body) does not reply in practice - verified live, it silently creates a new standalone comment - so the shortcut uses the dedicated replies endpoint instead. Verified live against a wiki->docx document with both user and bot identities: list -> batch-query -> add-reply -> resolve/restore -> delete-reply round trip. Coverage: dry-run e2e contract tests plus a self-contained opt-in live workflow (TestDriveCommentOpsWorkflow, gated by LARK_DRIVE_MD_COMMENT_E2E) that creates a Markdown-file comment fixture, exercises all four shortcuts, and cleans up.
b7aea0b to
a5e2d29
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
shortcuts/drive/drive_batch_query_comments_test.go (1)
1-1: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAPI-error propagation tests only assert on message substrings, not on typed error classification.
All four "PropagatesAPIError" tests share the same gap: they check
strings.Contains(err.Error(), "...")but never verify the error remains a typed API error (e.g., viaerrs.ProblemOf(err)→Category == errs.CategoryAPI). A regression whereruntime.CallAPITyped's typed error gets rewrapped as a plain error would pass all four tests silently.
shortcuts/drive/drive_batch_query_comments_test.go#L353-373: after the substring check, addif p, ok := errs.ProblemOf(err); !ok || p.Category != errs.CategoryAPI { t.Fatalf(...) }.shortcuts/drive/drive_add_reply_test.go#L261-282: add the sameerrs.ProblemOfCategory assertion after the substring check.shortcuts/drive/drive_resolve_comment_test.go#L266-287: add the sameerrs.ProblemOfCategory assertion after the substring check.shortcuts/drive/drive_delete_reply_test.go#L176-198: add the sameerrs.ProblemOfCategory assertion after the substring check.Based on learnings, in larksuite/cli Go test suites for shortcuts domain packages, when exercising error paths, tests should "assert
Category == errs.CategoryAPIand verifySubtypeis non-empty/populated" rather than relying only on message text. This is also consistent with the path instruction that "**/*_test.go... contract tests must assert the new field or behavior directly rather than relying only on happy-path substrings."🤖 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_batch_query_comments_test.go` at line 1, Update all four PropagatesAPIError tests in the drive shortcuts test suite to classify the returned error with errs.ProblemOf(err) after the existing message assertion. Fail unless extraction succeeds, Category equals errs.CategoryAPI, and Subtype is non-empty, preserving the current message checks while directly validating typed API-error propagation.Sources: Path instructions, Learnings
🤖 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_add_reply_test.go`:
- Around line 308-320: Update TestDriveAddReplyInvalidContent to call
assertDriveCommentValidationError(t, err, "--content") in addition to verifying
the invalid-JSON message, ensuring the returned error is typed and attributed to
the --content flag.
---
Nitpick comments:
In `@shortcuts/drive/drive_batch_query_comments_test.go`:
- Line 1: Update all four PropagatesAPIError tests in the drive shortcuts test
suite to classify the returned error with errs.ProblemOf(err) after the existing
message assertion. Fail unless extraction succeeds, Category equals
errs.CategoryAPI, and Subtype is non-empty, preserving the current message
checks while directly validating typed API-error propagation.
🪄 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: e8d2da51-2003-4953-8cf2-384b1db7f06a
📒 Files selected for processing (17)
shortcuts/drive/drive_add_reply.goshortcuts/drive/drive_add_reply_test.goshortcuts/drive/drive_batch_query_comments.goshortcuts/drive/drive_batch_query_comments_test.goshortcuts/drive/drive_comment_common.goshortcuts/drive/drive_comment_common_test.goshortcuts/drive/drive_delete_reply.goshortcuts/drive/drive_delete_reply_test.goshortcuts/drive/drive_resolve_comment.goshortcuts/drive/drive_resolve_comment_test.goshortcuts/drive/shortcuts.goshortcuts/drive/shortcuts_test.goskills/lark-drive/SKILL.mdskills/lark-drive/references/lark-drive-comments-guide.mdtests/cli_e2e/drive/coverage.mdtests/cli_e2e/drive/drive_comment_ops_dryrun_test.gotests/cli_e2e/drive/drive_comment_ops_workflow_test.go
🚧 Files skipped from review as they are similar to previous changes (12)
- shortcuts/drive/shortcuts.go
- shortcuts/drive/drive_delete_reply.go
- tests/cli_e2e/drive/drive_comment_ops_dryrun_test.go
- shortcuts/drive/drive_batch_query_comments.go
- shortcuts/drive/drive_comment_common_test.go
- shortcuts/drive/drive_resolve_comment.go
- tests/cli_e2e/drive/drive_comment_ops_workflow_test.go
- shortcuts/drive/drive_comment_common.go
- shortcuts/drive/drive_add_reply.go
- shortcuts/drive/shortcuts_test.go
- tests/cli_e2e/drive/coverage.md
- skills/lark-drive/references/lark-drive-comments-guide.md
Summary
Add four comment-operation shortcuts to the
drivedomain (+batch-query-comments,+resolve-comment,+add-reply,+delete-reply), covering the remaining comment APIs (batch_query / patch / reply create / reply delete) with the same URL-parsing + wiki-unwrapping UX as+list-comments.Changes
+batch-query-commentsPOST /drive/v1/files/:token/comments/batch_query—--comment-ids(CSV/repeated, max 100),--need-reaction+resolve-commentPATCH /drive/v1/files/:token/comments/:comment_id—--action resolve|restore→is_solved+add-replyPOST /drive/v1/files/:token/comments/:comment_id/replies—--contentreuses the+add-commentreply_elements JSON (same escaping and 10k-rune preflight), mapped totext_run/person/docs_link+delete-replyDELETE .../comments/:comment_id/replies/:reply_id— requires--yes--urlor--token+--typeand unwrap wiki nodes automatically; shared input resolution lives indrive_comment_common.go, parameterized by each endpoint's supportedfile_typeset.+list-comments: all four commands also accept apps targets (/page/<token>URLs or bare tokens with--type apps,file_type=apps), so the apps comment-management capabilities documented in the skill (batch query / resolve / reply / delete) route through these shortcuts consistently.file_typesets follow the platform API metadata (review feedback): all four commands acceptbitable(/base/URLs,basealias) in addition to doc/docx/sheet/file/slides/apps, pinned by direct-Base and wiki→bitable unit/dry-run cases.+add-replydeclaresdocs:document.comment:create— the replies create endpoint does not acceptdocs:document.comment:write_only, so declaring both would false-reject valid create-only tokens; resolve/delete keepwrite_only, batch-query keepscomment:read.+add-replydeliberately does not use the documented "POST .../comments withcomment_idin the body" form: verified live, that variant silently creates a new standalone comment instead of replying. The dedicated replies endpoint is used instead (noted in code and in the skill guide).wiki:node:readas the wiki-unwrap conditional scope: live verification with both identities showedget_nodeacceptswiki:wiki/wiki:wiki:readonly/wiki:node:read(a token carrying onlywiki:node:retrieveis rejected with 99991679), and the sheets/slides domains already declarewiki:node:readfor the same unwrap step. Existing drive/base commands that still declarewiki:node:retrieveare intentionally left unchanged in this PR; aligning them is a candidate follow-up.skills/lark-drive/SKILL.md,references/lark-drive-comments-guide.md) updated with routing rules and live-verified caveats (whole/solved comments reject replies; deleting a comment's root reply deletes the whole card; rapid resolve/restore flips can hit HTTP 429).Test Plan
make unit-test(-race) greenlark-cli drive +<command>flows work as expected — full live round trip on a real wiki→docx document with both--as userand--as bot: list → batch-query → add-reply → resolve/restore → delete-reply, document restored to its original state afterwardstests/cli_e2e/drive/drive_comment_ops_dryrun_test.go) pinning method/URL/params/body shapes incl. base/apps targets and the wiki 2-step plan;tests/cli_e2e/drive/coverage.mdupdated (32 → 36 leaf commands, coverage 41.7%)tests/cli_e2e/drive/drive_comment_ops_workflow_test.go, opt-in viaLARK_DRIVE_MD_COMMENT_E2E=1, same gate as the existing file-comment workflow): creates a Markdown file + file comment fixture, batch-queries it by ID, attaches a reply, resolves/restores with polling reads between state flips, deletes the reply, and cleans up — passed live in 13.8sgo vet ./...,gofmt -l .clean,go mod tidyno-op,golangci-lint run --new-from-rev=origin/main0 issuesRelated Issues