feat: support base record comments#1043
Conversation
📝 WalkthroughWalkthroughThe ChangesBase Comment Feature
Sequence DiagramsequenceDiagram
participant CLI as CLI User
participant Parser as parseBaseCommentAnchor
participant Builder as buildBaseCommentCreateV2Request
participant DriveAPI as Drive API (POST /files/:file_token/new_comments)
CLI->>Parser: parse `--block-id` TABLE!RECORD!VIEW
Parser->>Builder: return base anchor {block_id, base_record_id, base_view_id}
Builder->>DriveAPI: POST new_comments (file_type=bitable, anchor)
DriveAPI-->>CLI: response {comment_id, reply_id, created_at, ...}
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1043 +/- ##
==========================================
+ Coverage 67.75% 67.79% +0.04%
==========================================
Files 590 590
Lines 55188 55293 +105
==========================================
+ Hits 37392 37487 +95
- Misses 14684 14688 +4
- Partials 3112 3118 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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_comment.go`:
- Around line 151-154: When docRef.Kind == "base" in drive_add_comment.go the
code currently returns early after calling parseBaseCommentAnchor(runtime) and
skips validation of Base-incompatible flags; update the block around docRef.Kind
== "base" (the parseBaseCommentAnchor(runtime) call) to first check the boolean
flags corresponding to --full-comment and --selection-with-ellipsis (the fields
used later by Execute) and return a clear error if either is set, then call
parseBaseCommentAnchor(runtime) and return its error as before so Base targets
are rejected when incompatible flags are provided.
In `@skill-template/domains/drive.md`:
- Line 128: Update the guidance sentence "如果 wiki 解析后不是
`doc`/`docx`/`bitable`,不要用 `+add-comment`。" so it matches actual +add-comment
support: include `file`/`sheet`/`slides` (or replace the explicit list with a
statement saying "仅当解析类型支持评论(例如 doc/docx/bitable/file/sheet/slides)时使用
+add-comment") so the documented resolved-type list aligns with the +add-comment
command behavior; locate and edit that exact sentence in
skill-template/domains/drive.md.
In `@skills/lark-drive/references/lark-drive-add-comment.md`:
- Line 6: The overview currently states that omitting --block-id creates a
full-document comment for all supported types; update this to scope the
full-comment default only to types that support it (e.g., docs, docx, sheets,
slides, whitelisted Drive files) and explicitly call out that Base (bitable)
requires --block-id and does not support full-document comments. Edit the
sentence referencing "--block-id" to note the exception for Base (bitable) and
enumerate which URL/token types can use full comments versus which always
require a block id.
🪄 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: 0bca2319-4f20-4f5a-9d1f-5c800111c8de
📒 Files selected for processing (7)
shortcuts/drive/drive_add_comment.goshortcuts/drive/drive_add_comment_test.goskill-template/domains/drive.mdskills/lark-drive/SKILL.mdskills/lark-drive/references/lark-drive-add-comment.mdtests/cli_e2e/drive/coverage.mdtests/cli_e2e/drive/drive_add_comment_dryrun_test.go
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@cc4983ab4266ad53173efd314da0aec0ca6f26f3🧩 Skill updatenpx skills add zgz2048/cli#codex/base-comment-support -y -g |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
shortcuts/drive/drive_add_comment.go (1)
608-616:⚠️ Potential issue | 🟠 Major | ⚡ Quick winReject base-only incompatibilities after wiki resolution.
Wiki targets that resolve to
bitable/basereturn here before re-running the base-specific checks added for direct targets. That means--selection-with-ellipsisis effectively ignored on the wiki path, and missing--block-id/explicit--full-commentfall through to later, less accurate errors inexecuteBaseComment/dry-run.Suggested fix
if objType == "bitable" || objType == "base" { + if runtime.Bool("full-comment") { + return resolvedCommentTarget{}, output.ErrValidation("--full-comment is not applicable for base(bitable) comments; use --block-id <table-id>!<record-id>!<view-id>") + } + if strings.TrimSpace(runtime.Str("selection-with-ellipsis")) != "" { + return resolvedCommentTarget{}, output.ErrValidation("--selection-with-ellipsis is not applicable for base(bitable) comments; use --block-id <table-id>!<record-id>!<view-id>") + } + if _, err := parseBaseCommentAnchor(runtime); err != nil { + return resolvedCommentTarget{}, err + } fmt.Fprintf(runtime.IO().ErrOut, "Resolved wiki to base: %s\n", common.MaskToken(objToken)) return resolvedCommentTarget{ DocID: objToken, FileToken: objToken, FileType: "base",🤖 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_add_comment.go` around lines 608 - 616, The wiki-resolution path currently returns a resolvedCommentTarget for objType "bitable"/"base" before applying the same base-only validation that executeBaseComment expects, so re-run the base-specific compatibility checks (the selection-with-ellipsis validation and checks for presence of --block-id or explicit --full-comment) after wiki resolution and before returning the resolvedCommentTarget; i.e., invoke the same validation helper or inline the checks used by executeBaseComment (or call the helper that enforces base-only constraints) for the resolvedCommentTarget and return an error if they fail, then only return the resolvedCommentTarget when those validations pass.
🤖 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.
Outside diff comments:
In `@shortcuts/drive/drive_add_comment.go`:
- Around line 608-616: The wiki-resolution path currently returns a
resolvedCommentTarget for objType "bitable"/"base" before applying the same
base-only validation that executeBaseComment expects, so re-run the
base-specific compatibility checks (the selection-with-ellipsis validation and
checks for presence of --block-id or explicit --full-comment) after wiki
resolution and before returning the resolvedCommentTarget; i.e., invoke the same
validation helper or inline the checks used by executeBaseComment (or call the
helper that enforces base-only constraints) for the resolvedCommentTarget and
return an error if they fail, then only return the resolvedCommentTarget when
those validations pass.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 615b1602-0364-425a-af99-798a2c1a2cdb
📒 Files selected for processing (4)
shortcuts/drive/drive_add_comment.goshortcuts/drive/drive_add_comment_test.goskill-template/domains/drive.mdskills/lark-drive/references/lark-drive-add-comment.md
Summary
Add Base record-local comment support to
drive +add-comment. Base targets can now be addressed via/base/,/bitable/, wiki links resolving tobitable, or a bare token with--type bitable/--type base.Changes
drive +add-commentparsing, validation, dry-run, and execution for Base record comments.--block-id <table-id>!<record-id>!<view-id>as the public Base locator and send the OpenAPI wire payload withfile_type=bitableplus Base anchor fields.Test Plan
go test ./shortcuts/drivemake build && go test ./tests/cli_e2e/drive -run 'TestDriveAddCommentDryRun_(File|Base)'make unit-testfile_type=bitable.Related Issues
Summary by CodeRabbit
New Features
Behavior
Documentation
Tests