Skip to content

feat: support base record comments#1043

Open
zgz2048 wants to merge 2 commits into
larksuite:mainfrom
zgz2048:codex/base-comment-support
Open

feat: support base record comments#1043
zgz2048 wants to merge 2 commits into
larksuite:mainfrom
zgz2048:codex/base-comment-support

Conversation

@zgz2048
Copy link
Copy Markdown
Collaborator

@zgz2048 zgz2048 commented May 22, 2026

Summary

Add Base record-local comment support to drive +add-comment. Base targets can now be addressed via /base/, /bitable/, wiki links resolving to bitable, or a bare token with --type bitable/--type base.

Changes

  • Extend drive +add-comment parsing, validation, dry-run, and execution for Base record comments.
  • Use --block-id <table-id>!<record-id>!<view-id> as the public Base locator and send the OpenAPI wire payload with file_type=bitable plus Base anchor fields.
  • Update drive skills/reference docs and add unit plus dry-run E2E coverage for Base comment request shapes.

Test Plan

  • go test ./shortcuts/drive
  • make build && go test ./tests/cli_e2e/drive -run 'TestDriveAddCommentDryRun_(File|Base)'
  • make unit-test
  • Manual pre verification for Base comment create/list/reply list/reply update/reply delete/comment solve+restore using file_type=bitable.

Related Issues

  • None

Summary by CodeRabbit

  • New Features

    • Added support for commenting on Base (bitable) records in the drive +add-comment command.
    • --type now accepts base (alias) / bitable and --block-id supports !!.
  • Behavior

    • Dry-run and execute flows now produce/send bitable comments (file_type=bitable) and include base anchor fields; wiki resolutions can map to Base targets.
  • Documentation

    • Updated CLI and Drive docs/guides to explain Base usage, block-id format, and file_type expectations.
  • Tests

    • Added unit and e2e dry-run coverage for Base (bitable) comment scenarios.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

📝 Walkthrough

Walkthrough

The drive +add-comment shortcut gains Base (bitable) record-local comment support: /base/ and /bitable/ URLs and --type base/bitable are recognized, --block-id must be <table-id>!<record-id>!<view-id>, dry-run/execute build file_type=bitable create requests with base anchors, and tests/docs updated.

Changes

Base Comment Feature

Layer / File(s) Summary
Base comment target type: definitions and input parsing
shortcuts/drive/drive_add_comment.go, shortcuts/drive/drive_add_comment_test.go
Shortcut metadata (Description, --doc, --type, --block-id) advertise base(bitable). parseCommentDocRef recognizes /base/ and /bitable/ URL forms and bare tokens with --type base/bitable, mapping to Kind="base".
Base target resolution and validation
shortcuts/drive/drive_add_comment.go, shortcuts/drive/drive_add_comment_test.go
resolveCommentTarget fast-paths docRef.Kind=="base" and maps wiki obj_type=="bitable" to FileType: "base". Validate enforces required --block-id, rejects incompatible flags for base, and updates error messages. CLI validation tests added/updated.
Base anchor parsing and comment request building
shortcuts/drive/drive_add_comment.go, shortcuts/drive/drive_add_comment_test.go
Introduces baseAnchor and parsing helpers to split <table-id>!<record-id>!<view-id>. buildBaseCommentCreateV2Request produces a file_type:"bitable" payload with anchor.block_id, anchor.base_record_id, and anchor.base_view_id. Unit test validates payload shape.
Base comment execution and dry-run orchestration
shortcuts/drive/drive_add_comment.go, shortcuts/drive/drive_add_comment_test.go, tests/cli_e2e/drive/drive_add_comment_dryrun_test.go
DryRun previews a single POST to .../files/:file_token/new_comments for base targets. Execute fast-paths docRef.Kind=="base" and routes resolved wiki base targets to executeBaseComment. executeBaseComment posts create_v2, parses reply, and outputs comment_mode:"base_record" plus base identifiers. Execution and dry-run tests verify request/response behavior and printed outputs.
Documentation and E2E test coverage
skill-template/domains/drive.md, skills/lark-drive/SKILL.md, skills/lark-drive/references/lark-drive-add-comment.md, tests/cli_e2e/drive/coverage.md
Docs updated to include bitable mapping, Base anchor/block-id format and constraints (record-local only), guidance to use file_type=bitable, and examples. E2E dry-run coverage added for Base dry-run preview.

Sequence Diagram

sequenceDiagram
  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, ...}
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • larksuite/cli#975: Modifies the same drive +add-comment paths for adding a new target kind and related routing/validation.
  • larksuite/cli#674: Also changes parseCommentDocRef/resolveCommentTarget and dry-run/execute routing for a different local-comment kind (slides).
  • larksuite/cli#518: Extended anchor/--block-id handling for another comment target kind (sheet cells).

Suggested labels

domain/base

Suggested reviewers

  • fangshuyu-768
  • wittam-01
  • kongenpei

Poem

🐰 Hopping through tables with cheer,

Table!Record!View — anchor clear,
Bitable comments now take flight,
Tiny notes in each record's sight,
A rabbit's nibble makes review light.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.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 'feat: support base record comments' directly and clearly summarizes the main change—adding Base record comment support to the drive command.
Description check ✅ Passed The description follows the template structure with complete Summary, Changes, Test Plan, and Related Issues sections; all required information is present and detailed.
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 unit tests (beta)
  • Create PR with unit tests

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 22, 2026
@zgz2048 zgz2048 marked this pull request as ready for review May 22, 2026 09:07
@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

❌ Patch coverage is 87.73585% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.79%. Comparing base (d5d2fee) to head (cc4983a).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
shortcuts/drive/drive_add_comment.go 87.73% 8 Missing and 5 partials ⚠️
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.
📢 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.

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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between d5d2fee and a0586d7.

📒 Files selected for processing (7)
  • shortcuts/drive/drive_add_comment.go
  • shortcuts/drive/drive_add_comment_test.go
  • skill-template/domains/drive.md
  • skills/lark-drive/SKILL.md
  • skills/lark-drive/references/lark-drive-add-comment.md
  • tests/cli_e2e/drive/coverage.md
  • tests/cli_e2e/drive/drive_add_comment_dryrun_test.go

Comment thread shortcuts/drive/drive_add_comment.go
Comment thread skill-template/domains/drive.md Outdated
Comment thread skills/lark-drive/references/lark-drive-add-comment.md Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 22, 2026

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add zgz2048/cli#codex/base-comment-support -y -g

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.

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 win

Reject base-only incompatibilities after wiki resolution.

Wiki targets that resolve to bitable/base return here before re-running the base-specific checks added for direct targets. That means --selection-with-ellipsis is effectively ignored on the wiki path, and missing --block-id/explicit --full-comment fall through to later, less accurate errors in executeBaseComment/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

📥 Commits

Reviewing files that changed from the base of the PR and between a0586d7 and cc4983a.

📒 Files selected for processing (4)
  • shortcuts/drive/drive_add_comment.go
  • shortcuts/drive/drive_add_comment_test.go
  • skill-template/domains/drive.md
  • skills/lark-drive/references/lark-drive-add-comment.md

@zgz2048 zgz2048 added the domain/base PR touches the base domain label May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

1 participant