Skip to content

feat(drive): extend +add-comment to support slides targets#674

Open
ethan-zhx wants to merge 1 commit intomainfrom
feat/slide_comment
Open

feat(drive): extend +add-comment to support slides targets#674
ethan-zhx wants to merge 1 commit intomainfrom
feat/slide_comment

Conversation

@ethan-zhx
Copy link
Copy Markdown
Collaborator

@ethan-zhx ethan-zhx commented Apr 27, 2026

Summary

Extend drive +add-comment to support slides targets in addition to existing doc/docx flows. This also improves wiki target resolution, validation, dry-run behavior, and skill
documentation so agents can call the command with clearer and more reliable inputs.

Changes

  • Add slides support to drive +add-comment
  • Support resolving wiki URLs to doc / docx / slides targets before creating comments
  • Add validation for slides-specific anchor format:
    • slides require --block-id <slide-block-type>!<xml-id>
    • slides do not allow --full-comment or --selection-with-ellipsis
  • Improve dry-run request generation so it reflects resolved target type and actual API flow
  • Expand unit tests for doc parsing, mode resolution, locate-doc fallback, reply element parsing, and slides comment flows
  • Update lark-drive skill docs and examples for doc/docx/slides comment creation

Test Plan

  • Added/updated unit tests in shortcuts/drive/drive_add_comment_test.go
  • Unit tests pass
  • Manual local verification confirms the lark xxx command works as expected

Related Issues

  • None

Summary by CodeRabbit

  • New Features

    • Add-comment now supports Slides; slide comments require a compound --block-id (!) and include slide_block_type in outputs and requests. Dry-run and execution route slide-specific flows and wiki-resolved slides.
  • Documentation

    • CLI docs, examples, and flag help updated to include slides, allowed --doc/--type inputs, required block-id format, and unsupported flags (--full-comment, --selection-with-ellipsis) for slides.
  • Tests

    • Added unit and end-to-end tests for slide parsing, validation, dry-run, execution, responses, and error cases.
  • Bug Fixes

    • Dry-run now computes comment mode earlier and surfaces wiki resolution errors instead of continuing silently.

@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 Apr 27, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 27, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds Feishu Slides support to the drive +add-comment shortcut: CLI metadata, URL/token parsing, validation, dry-run, execution, and request building extended to handle slides and slide-specific --block-id format; tests and docs updated accordingly.

Changes

Cohort / File(s) Summary
Core implementation
shortcuts/drive/drive_add_comment.go
Add slides handling: update CLI flags/help (--type, --doc, --block-id), parse /slides/ URLs and slide tokens, require compound <slide-block-type>!<xml-id>, disallow --full-comment and --selection-with-ellipsis for slides, add slides dry-run & execution paths, and extend buildCommentCreateV2Request signature to accept slideBlockType.
Tests
shortcuts/drive/drive_add_comment_test.go
Add JSON stdout helpers; extend doc-ref parsing tests for slides and /slides/ URLs; update unit tests for new buildCommentCreateV2Request signature; add slide block-id parsing tests and end-to-end dry-run/execution tests (including wiki→slides resolution); update expected error messages.
Documentation
skills/lark-drive/SKILL.md, skills/lark-drive/references/lark-drive-add-comment.md
Document slides as supported --doc/--type; add examples for slide block-id patterns (<slide-block-type>!<xml-id> like slide!, img!, shape!); describe mapping to anchor.block_id and anchor.slide_block_type; note unsupported flags for slides and wiki-resolution guidance.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as CLI (+add-comment)
    participant Resolver as Wiki/URL Resolver
    participant Validator as Validator
    participant Builder as Request Builder
    participant DriveAPI as Drive File API

    CLI->>Resolver: resolve `--doc` (URL, token, or explicit `--type`)
    Resolver-->>CLI: returns target.Kind (e.g., slides) and file token
    CLI->>Validator: validate flags and `--block-id` format for slides
    Validator-->>CLI: ok / error
    CLI->>Builder: buildCommentCreateV2Request(fileType=slides, blockID, slideBlockType)
    Builder-->>DriveAPI: POST /file/comments.create_v2 (anchor.block_id + anchor.slide_block_type)
    DriveAPI-->>CLI: response (comment_id / error)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~55 minutes

Possibly related PRs

Suggested reviewers

  • fangshuyu-768
  • liangshuo-1

Poem

🐰 I hopped through slides and tokens bright,

split block and id beneath the light,
slide_block_type and anchor align,
tiny notes now land on each design,
carrots cheer the feature's flight.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.36% 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 clearly and concisely summarizes the main change: extending the +add-comment command to support slides targets, which aligns with the core objective of the PR.
Description check ✅ Passed The PR description covers all required template sections with clear summary, comprehensive changes list, test plan with status indicators, and related issues. It provides sufficient detail about slides validation, wiki resolution, and documentation updates.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/slide_comment

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
Copy link
Copy Markdown

github-actions Bot commented Apr 27, 2026

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#feat/slide_comment -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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
skills/lark-drive/references/lark-drive-add-comment.md (1)

134-148: ⚠️ Potential issue | 🟡 Minor

Refresh general bullets to reflect slides support.

The slides-specific block at lines 143–148 is good, but a few earlier statements are now stale and could mislead readers (including agents):

  • Line 134: --full-comment description says "(不适用于 sheet)" — slides also rejects --full-comment, per the validation added in drive_add_comment.go.
  • Line 135: --block-id row only documents the sheet format; consider mentioning the slides <slide-block-type>!<xml-id> format alongside.
  • Line 141: "传 --block-id 时,shortcut 创建局部评论(划词评论);该模式仅支持 docx..." — both sheet (line 142) and slides (lines 143–148) also rely on --block-id, so the "仅支持 docx" claim contradicts the next two bullets.
📝 Proposed wording refresh
-| `--full-comment` | 否 | 显式指定创建全文评论;未传 `--block-id` 时也会默认走全文评论(不适用于 sheet) |
-| `--block-id` | 局部评论时必填 | 目标块 ID,可通过 `docs +fetch --api-version v2 --detail with-ids` 获取。**Sheet 评论**:格式为 `<sheetId>!<cell>`(如 `a281f9!D6`) |
+| `--full-comment` | 否 | 显式指定创建全文评论;未传 `--block-id` 时也会默认走全文评论(不适用于 sheet 或 slides) |
+| `--block-id` | 局部评论时必填 | 目标块 ID,可通过 `docs +fetch --api-version v2 --detail with-ids` 获取。**Sheet 评论**:格式为 `<sheetId>!<cell>`(如 `a281f9!D6`)。**Slide 评论**:格式为 `<slide-block-type>!<xml-id>`(如 `shape!bPq`) |
@@
-- 传 `--block-id` 时,shortcut 创建**局部评论(划词评论)**;该模式仅支持 `docx`,以及最终可解析为 `docx` 的 wiki URL。
+- 传 `--block-id` 时,shortcut 创建**局部评论**;`docx` 模式下相当于划词评论,并支持最终可解析为 `docx` 的 wiki URL。Sheet/slides 的局部评论详见下文专门说明。
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@skills/lark-drive/references/lark-drive-add-comment.md` around lines 134 -
148, Update the docs to reflect slides support and flag validation: change the
`--full-comment` description to note it is not valid for sheet or slides, update
the `--block-id` table row to mention both sheet format (`<sheetId>!<cell>`) and
slides format (`<slide-block-type>!<xml-id>`), and reword the paragraph that
currently says "仅支持 docx" (reference the comment about `--block-id`) so it
clarifies that using `--block-id` creates a local/block comment for docx,
sheets, and slides (with slides requiring the `<slide-block-type>!<xml-id>`
form); ensure consistency with the validation logic implemented in
drive_add_comment.go and with the Slide Parameters Mapping section.
shortcuts/drive/drive_add_comment.go (1)

146-187: ⚠️ Potential issue | 🔴 Critical

Critical: hard-coded commentModeFull breaks wiki → slides dry-run.

When resolving a wiki URL in DryRun (line 148), resolveCommentTarget is called with hard-coded commentModeFull regardless of the user's --block-id or --full-comment flags. However, resolveCommentTarget rejects objType == "slides" with mode == commentModeFull (line 454), returning an error for any wiki URL that resolves to slides—even with a valid --block-id "shape!<id>".

Because the error is silently swallowed (if err == nil, line 149), resolvedKind stays "wiki" and the slides dry-run branch (line 172) is never entered. The code falls through to the doc/docx path, emitting a "create local comment" or "create full comment" description instead of "slide block comment".

This breaks the intent of TestDryRunWikiResolvesToSlides, which expects stdout to contain "slide block comment" when passing --block-id "shape!shape_2" with a wiki URL that resolves to slides.

Compute the actual mode once and pass it through:

🔧 Proposed fix
 	DryRun: func(ctx context.Context, runtime *common.RuntimeContext) *common.DryRunAPI {
 		docRef, _ := parseCommentDocRef(runtime.Str("doc"), runtime.Str("type"))
 		replyElements, _ := parseCommentReplyElements(runtime.Str("content"))
 		blockID := strings.TrimSpace(runtime.Str("block-id"))
+		selection := runtime.Str("selection-with-ellipsis")
+		mode := resolveCommentMode(runtime.Bool("full-comment"), selection, blockID)
 
 		// For wiki URLs, resolve the actual target type via API so dry-run
 		// matches real execution behavior instead of guessing from --block-id.
 		resolvedKind := docRef.Kind
 		resolvedToken := docRef.Token
 		isWiki := false
 		if docRef.Kind == "wiki" {
 			isWiki = true
-			target, err := resolveCommentTarget(ctx, runtime, runtime.Str("doc"), commentModeFull)
+			target, err := resolveCommentTarget(ctx, runtime, runtime.Str("doc"), mode)
 			if err == nil {
 				resolvedKind = target.FileType
 				resolvedToken = target.FileToken
 			}
 		}
@@
 		// Doc/docx comment dry-run.
-		selection := runtime.Str("selection-with-ellipsis")
-		mode := resolveCommentMode(runtime.Bool("full-comment"), selection, blockID)
-
 		createPath := "/open-apis/drive/v1/files/:file_token/new_comments"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@shortcuts/drive/drive_add_comment.go` around lines 146 - 187, The dry-run
wiki→slides path is broken because resolveCommentTarget is called with the
hard-coded commentModeFull; compute the actual comment mode used for this
invocation (based on the user's flags/--block-id/--full-comment logic already
used elsewhere in this routine) into a local variable (e.g., mode) and pass that
variable to resolveCommentTarget instead of commentModeFull; update the call in
the wiki branch (where resolveCommentTarget is invoked) to use that computed
mode so slides targets are not rejected and the slides dry-run branch can be
taken (refer to resolveCommentTarget and commentModeFull to locate the change).
🧹 Nitpick comments (3)
shortcuts/drive/drive_add_comment.go (3)

688-704: parseSlidesBlockRef accepts ! inside the xml-id.

SplitN(blockID, "!", 2) keeps any additional ! inside the second part, so "shape!foo!bar" parses as type=shape, id=foo!bar. PPT XML element ids in this codebase don't appear to legitimately contain !, so silently accepting it can mask user typos (e.g. accidentally pasting two anchors). Consider rejecting more than one separator.

♻️ Proposed tightening
-	parts := strings.SplitN(blockID, "!", 2)
-	if len(parts) != 2 {
+	parts := strings.Split(blockID, "!")
+	if len(parts) != 2 {
 		return "", "", output.ErrValidation("slide --block-id must be <slide-block-type>!<xml-id> (e.g. shape!bPq), got %q", blockID)
 	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@shortcuts/drive/drive_add_comment.go` around lines 688 - 704, The function
parseSlidesBlockRef currently allows extra '!' characters inside the xml-id;
update it to validate there is exactly one '!' separator by checking the count
of '!' in blockID and returning the same validation error if the count is not
exactly 1, then split on that single separator to populate parsedType and
parsedID (still trimming and ensuring neither is empty). Keep the error messages
and returned values consistent with existing output.ErrValidation usage and
reference parseSlidesBlockRef, blockID, parsedType, and parsedID when making the
change.

670-678: Optional: tidy the anchor mutation.

The chained type assertion body["anchor"].(map[string]interface{})["slide_block_type"] = ... works but is a bit awkward; binding the map to a local makes the intent clearer and avoids re-asserting.

♻️ Proposed refactor
 	} else if strings.TrimSpace(blockID) != "" {
-		body["anchor"] = map[string]interface{}{
+		anchor := map[string]interface{}{
 			"block_id": blockID,
 		}
-		if strings.TrimSpace(slideBlockType) != "" {
-			body["anchor"].(map[string]interface{})["slide_block_type"] = strings.TrimSpace(slideBlockType)
-		}
+		if t := strings.TrimSpace(slideBlockType); t != "" {
+			anchor["slide_block_type"] = t
+		}
+		body["anchor"] = anchor
 	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@shortcuts/drive/drive_add_comment.go` around lines 670 - 678, The anchor map
mutation in the block handling is awkwardly done via a chained type assertion on
body["anchor"]; instead, after creating/assigning body["anchor"] =
map[string]interface{}{ "block_id": blockID }, cast body["anchor"] to a local
variable (e.g., anchor := body["anchor"].(map[string]interface{})) and then set
anchor["slide_block_type"] = strings.TrimSpace(slideBlockType) when
slideBlockType is non-empty; update the code paths that reference body["anchor"]
accordingly (look for the block handling around blockID/slideBlockType in
drive_add_comment.go).

425-435: resolveCommentTarget for direct slides/sheet is unreachable but keeps a stale message.

With Execute fast-pathing both sheet and slides via dedicated functions, and DryRun only invoking resolveCommentTarget for kind == "wiki", the early-return branch for docRef.Kind == "sheet" || "slides" here is currently dead. That's fine as defensive code, but the inner check mode == commentModeLocal && docRef.Kind != "docx" && docRef.Kind != "sheet" && docRef.Kind != "slides" can now only be true when docRef.Kind == "doc", which makes the broad type list misleading. Consider simplifying to make the contract explicit:

♻️ Proposed simplification
-	if docRef.Kind == "docx" || docRef.Kind == "doc" || docRef.Kind == "sheet" || docRef.Kind == "slides" {
-		if mode == commentModeLocal && docRef.Kind != "docx" && docRef.Kind != "sheet" && docRef.Kind != "slides" {
-			return resolvedCommentTarget{}, output.ErrValidation("local comments only support docx, sheet, and slides; old doc format only supports full comments")
-		}
+	if docRef.Kind == "docx" || docRef.Kind == "doc" || docRef.Kind == "sheet" || docRef.Kind == "slides" {
+		if mode == commentModeLocal && docRef.Kind == "doc" {
+			return resolvedCommentTarget{}, output.ErrValidation("local comments only support docx, sheet, and slides; old doc format only supports full comments")
+		}
 		return resolvedCommentTarget{
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@shortcuts/drive/drive_add_comment.go` around lines 425 - 435, In
resolveCommentTarget simplify the misleading inner condition: replace the
compound check (mode == commentModeLocal && docRef.Kind != "docx" && docRef.Kind
!= "sheet" && docRef.Kind != "slides") with an explicit check for the only
remaining case (mode == commentModeLocal && docRef.Kind == "doc"), and update
the returned validation error message to clearly state that the old "doc" format
only supports full comments; keep the existing resolvedCommentTarget return and
references to docRef.Token/FileType/ResolvedBy intact.
🤖 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-drive/SKILL.md`:
- Line 119: Fix the typo and update the table row for local comments: remove the
duplicated Chinese comma after `block_id` and add `sheet` to the list of
supported types, noting that `sheet` also supports local comments via
`--block-id <sheetId>!<cell>` (same as existing `file_token`/`drive
+add-comment` behavior); reference the row mentioning `添加局部评论(划词评论)`,
`file_token`, and the `drive +add-comment`/`--block-id` usage to locate and
apply this change.

---

Outside diff comments:
In `@shortcuts/drive/drive_add_comment.go`:
- Around line 146-187: The dry-run wiki→slides path is broken because
resolveCommentTarget is called with the hard-coded commentModeFull; compute the
actual comment mode used for this invocation (based on the user's
flags/--block-id/--full-comment logic already used elsewhere in this routine)
into a local variable (e.g., mode) and pass that variable to
resolveCommentTarget instead of commentModeFull; update the call in the wiki
branch (where resolveCommentTarget is invoked) to use that computed mode so
slides targets are not rejected and the slides dry-run branch can be taken
(refer to resolveCommentTarget and commentModeFull to locate the change).

In `@skills/lark-drive/references/lark-drive-add-comment.md`:
- Around line 134-148: Update the docs to reflect slides support and flag
validation: change the `--full-comment` description to note it is not valid for
sheet or slides, update the `--block-id` table row to mention both sheet format
(`<sheetId>!<cell>`) and slides format (`<slide-block-type>!<xml-id>`), and
reword the paragraph that currently says "仅支持 docx" (reference the comment about
`--block-id`) so it clarifies that using `--block-id` creates a local/block
comment for docx, sheets, and slides (with slides requiring the
`<slide-block-type>!<xml-id>` form); ensure consistency with the validation
logic implemented in drive_add_comment.go and with the Slide Parameters Mapping
section.

---

Nitpick comments:
In `@shortcuts/drive/drive_add_comment.go`:
- Around line 688-704: The function parseSlidesBlockRef currently allows extra
'!' characters inside the xml-id; update it to validate there is exactly one '!'
separator by checking the count of '!' in blockID and returning the same
validation error if the count is not exactly 1, then split on that single
separator to populate parsedType and parsedID (still trimming and ensuring
neither is empty). Keep the error messages and returned values consistent with
existing output.ErrValidation usage and reference parseSlidesBlockRef, blockID,
parsedType, and parsedID when making the change.
- Around line 670-678: The anchor map mutation in the block handling is
awkwardly done via a chained type assertion on body["anchor"]; instead, after
creating/assigning body["anchor"] = map[string]interface{}{ "block_id": blockID
}, cast body["anchor"] to a local variable (e.g., anchor :=
body["anchor"].(map[string]interface{})) and then set anchor["slide_block_type"]
= strings.TrimSpace(slideBlockType) when slideBlockType is non-empty; update the
code paths that reference body["anchor"] accordingly (look for the block
handling around blockID/slideBlockType in drive_add_comment.go).
- Around line 425-435: In resolveCommentTarget simplify the misleading inner
condition: replace the compound check (mode == commentModeLocal && docRef.Kind
!= "docx" && docRef.Kind != "sheet" && docRef.Kind != "slides") with an explicit
check for the only remaining case (mode == commentModeLocal && docRef.Kind ==
"doc"), and update the returned validation error message to clearly state that
the old "doc" format only supports full comments; keep the existing
resolvedCommentTarget return and references to docRef.Token/FileType/ResolvedBy
intact.
🪄 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: 32fc27e0-096b-44a5-8c5d-dfe2b0f4a0f0

📥 Commits

Reviewing files that changed from the base of the PR and between 1e2144e and fa8f5cc.

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

Comment thread skills/lark-drive/SKILL.md Outdated
@ethan-zhx ethan-zhx force-pushed the feat/slide_comment branch from fa8f5cc to 093fb20 Compare April 27, 2026 06:40
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)

146-153: ⚠️ Potential issue | 🔴 Critical

Hardcoded commentModeFull breaks wiki→slides dry-run.

The new guard at lines 454-456 (objType=="slides" && mode==commentModeFull) errors out, but DryRun always passes commentModeFull to resolveCommentTarget. For a wiki URL that resolves to slides (even with a valid --block-id), the resolution silently fails (if err == nil at line 149 short-circuits), so resolvedKind stays "wiki" and the slides branch at line 172 never fires. The dry-run output then incorrectly shows file_type:"wiki" and "create local comment" instead of the slides path.

This will cause TestDryRunWikiResolvesToSlides (added in this PR) to fail — its assertion strings.Contains(stdout.String(), "slide block comment") won't match.

Execute (line 279) already does this correctly by computing mode from user flags before calling resolveCommentTarget. The same should apply here.

🐛 Proposed fix: pass the user-derived mode into wiki resolution
 	DryRun: func(ctx context.Context, runtime *common.RuntimeContext) *common.DryRunAPI {
 		docRef, _ := parseCommentDocRef(runtime.Str("doc"), runtime.Str("type"))
 		replyElements, _ := parseCommentReplyElements(runtime.Str("content"))
 		blockID := strings.TrimSpace(runtime.Str("block-id"))
+		selection := runtime.Str("selection-with-ellipsis")
+		mode := resolveCommentMode(runtime.Bool("full-comment"), selection, blockID)
 
 		// For wiki URLs, resolve the actual target type via API so dry-run
 		// matches real execution behavior instead of guessing from --block-id.
 		resolvedKind := docRef.Kind
 		resolvedToken := docRef.Token
 		isWiki := false
 		if docRef.Kind == "wiki" {
 			isWiki = true
-			target, err := resolveCommentTarget(ctx, runtime, runtime.Str("doc"), commentModeFull)
+			target, err := resolveCommentTarget(ctx, runtime, runtime.Str("doc"), mode)
 			if err == nil {
 				resolvedKind = target.FileType
 				resolvedToken = target.FileToken
 			}
 		}

Then drop the duplicate selection/mode declarations later in the function (around line 190-191).

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

In `@shortcuts/drive/drive_add_comment.go` around lines 146 - 153, The dry-run
uses a hardcoded commentModeFull when calling resolveCommentTarget which
prevents wiki URLs that resolve to slides from being recognized; change the
DryRun path to compute the comment mode the same way as Execute (derive mode
from user flags/selection) and pass that variable into resolveCommentTarget
instead of commentModeFull (update the call in the block that sets
isWiki/resolvedKind/resolvedToken), then remove the duplicate selection/mode
declarations later in the function so there’s a single source of truth for mode
used in both DryRun and Execute.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@shortcuts/drive/drive_add_comment.go`:
- Around line 146-153: The dry-run uses a hardcoded commentModeFull when calling
resolveCommentTarget which prevents wiki URLs that resolve to slides from being
recognized; change the DryRun path to compute the comment mode the same way as
Execute (derive mode from user flags/selection) and pass that variable into
resolveCommentTarget instead of commentModeFull (update the call in the block
that sets isWiki/resolvedKind/resolvedToken), then remove the duplicate
selection/mode declarations later in the function so there’s a single source of
truth for mode used in both DryRun and Execute.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5df5cf9f-26c7-4208-9c52-a416186a3821

📥 Commits

Reviewing files that changed from the base of the PR and between fa8f5cc and 093fb20.

📒 Files selected for processing (4)
  • shortcuts/drive/drive_add_comment.go
  • shortcuts/drive/drive_add_comment_test.go
  • skills/lark-drive/SKILL.md
  • skills/lark-drive/references/lark-drive-add-comment.md
✅ Files skipped from review due to trivial changes (1)
  • skills/lark-drive/SKILL.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • skills/lark-drive/references/lark-drive-add-comment.md

@ethan-zhx ethan-zhx force-pushed the feat/slide_comment branch from 093fb20 to 1e89d3b Compare April 27, 2026 06:58
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 27, 2026

Codecov Report

❌ Patch coverage is 89.10891% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.02%. Comparing base (6f444c5) to head (e434177).
⚠️ Report is 17 commits behind head on main.

Files with missing lines Patch % Lines
shortcuts/drive/drive_add_comment.go 89.10% 7 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #674      +/-   ##
==========================================
+ Coverage   62.50%   63.02%   +0.52%     
==========================================
  Files         432      436       +4     
  Lines       37758    38685     +927     
==========================================
+ Hits        23599    24381     +782     
- Misses      12033    12153     +120     
- Partials     2126     2151      +25     

☔ 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
skills/lark-drive/references/lark-drive-add-comment.md (1)

134-141: ⚠️ Potential issue | 🟡 Minor

Stale docx-only descriptions in the parameter table and behavior bullets — please update for slides.

Three small spots still describe the pre-slides world and contradict the new slides bullets at Lines 143–147:

  • Line 134 says --full-comment is "不适用于 sheet"; slides also disallows it.
  • Line 135's --block-id row only documents the sheet format; the slides format <slide-block-type>!<xml-id> (e.g. shape!bPq) should be listed alongside it for symmetry with the help text.
  • Line 141 says local comments "仅支持 docx,以及最终可解析为 docx 的 wiki URL"; sheet/slides comments are also --block-id-driven local comments.

Since AI agents typically read the parameter table and behavior bullets first, these inconsistencies are worth tightening up.

📝 Suggested doc tweaks
-| `--block-id` | 局部评论时必填 | 目标块 ID,可通过 `docs +fetch --api-version v2 --detail with-ids` 获取。**Sheet 评论**:格式为 `<sheetId>!<cell>`(如 `a281f9!D6`) |
+| `--block-id` | 局部评论时必填 | 目标块 ID。**Docx**:可通过 `docs +fetch --api-version v2 --detail with-ids` 获取。**Sheet**:格式为 `<sheetId>!<cell>`(如 `a281f9!D6`)。**Slides**:格式为 `<slide-block-type>!<xml-id>`(如 `shape!bPq`) |
-| `--full-comment` | 否 | 显式指定创建全文评论;未传 `--block-id` 时也会默认走全文评论(不适用于 sheet) |
+| `--full-comment` | 否 | 显式指定创建全文评论;未传 `--block-id` 时也会默认走全文评论(不适用于 sheet 和 slides) |
-- 未传 `--block-id` 时,shortcut 默认创建**全文评论**;也可以显式传 `--full-comment`。全文评论支持 `docx`、旧版 `doc` URL,以及最终可解析为 `doc`/`docx` 的 wiki URL。
-- 传 `--block-id` 时,shortcut 创建**局部评论(划词评论)**;该模式仅支持 `docx`,以及最终可解析为 `docx` 的 wiki URL。
+- 未传 `--block-id` 时,shortcut 默认创建**全文评论**;也可以显式传 `--full-comment`。全文评论支持 `docx`、旧版 `doc` URL,以及最终可解析为 `doc`/`docx` 的 wiki URL(sheet 和 slides 不支持全文评论)。
+- 传 `--block-id` 时,shortcut 创建**局部评论**:docx 是划词评论(仅支持 `docx` 或解析为 `docx` 的 wiki URL),sheet/slides 走各自的锚点格式(见下方说明)。
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@skills/lark-drive/references/lark-drive-add-comment.md` around lines 134 -
141, The parameter table and behavior bullets still reference pre-slides rules:
update the `--full-comment` row to explicitly state it is not applicable to
sheet or slide local comments (so it remains disallowed for sheets/slides),
extend the `--block-id` row to document both sheet format `<sheetId>!<cell>` and
slide format `<slide-block-type>!<xml-id>` (example: `shape!bPq`) alongside
existing guidance, and revise the behavior bullets (the "局部评论需要先获取 block ID" and
the paragraph that currently limits local comments to `docx`) to state that
`--block-id` drives local (in‑place) comments for docx, sheets, and slides (and
for wiki URLs that resolve to those types) instead of saying local comments only
support `docx`. Ensure the help text and table entries are consistent and
symmetric about sheets vs slides and include the slide example `shape!bPq`.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@skills/lark-drive/references/lark-drive-add-comment.md`:
- Around line 134-141: The parameter table and behavior bullets still reference
pre-slides rules: update the `--full-comment` row to explicitly state it is not
applicable to sheet or slide local comments (so it remains disallowed for
sheets/slides), extend the `--block-id` row to document both sheet format
`<sheetId>!<cell>` and slide format `<slide-block-type>!<xml-id>` (example:
`shape!bPq`) alongside existing guidance, and revise the behavior bullets (the
"局部评论需要先获取 block ID" and the paragraph that currently limits local comments to
`docx`) to state that `--block-id` drives local (in‑place) comments for docx,
sheets, and slides (and for wiki URLs that resolve to those types) instead of
saying local comments only support `docx`. Ensure the help text and table
entries are consistent and symmetric about sheets vs slides and include the
slide example `shape!bPq`.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8923d65e-e298-4e81-af4a-4bd5d9ca56aa

📥 Commits

Reviewing files that changed from the base of the PR and between 093fb20 and 1e89d3b.

📒 Files selected for processing (4)
  • shortcuts/drive/drive_add_comment.go
  • shortcuts/drive/drive_add_comment_test.go
  • skills/lark-drive/SKILL.md
  • skills/lark-drive/references/lark-drive-add-comment.md
✅ Files skipped from review due to trivial changes (1)
  • skills/lark-drive/SKILL.md

Copy link
Copy Markdown
Collaborator

@fangshuyu-768 fangshuyu-768 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One real concern about a flag-validation gap on the wiki→slides path; rest looks solid.

Comment thread shortcuts/drive/drive_add_comment.go
@ethan-zhx ethan-zhx force-pushed the feat/slide_comment branch from 1e89d3b to 212f7ce Compare April 27, 2026 09:53
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

🤖 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-drive/references/lark-drive-add-comment.md`:
- Around line 129-135: Update the parameters table to match the Go validator and
prose: change the `--full-comment` row to state it is not applicable to sheet OR
slides (matching Validate), and update the `--block-id` row to document formats
for docx, sheet (`<sheetId>!<cell>`), and slides (`<slide-block-type>!<xml-id>`)
as required for slides comments; ensure the table text aligns with the prose
around line 143 and the Validate logic that rejects `--full-comment` for slides
and requires the slide block-id format.
🪄 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: 7c258fdb-3dd8-4d4f-b570-4ce37cc27ad4

📥 Commits

Reviewing files that changed from the base of the PR and between 1e89d3b and 212f7ce.

📒 Files selected for processing (4)
  • shortcuts/drive/drive_add_comment.go
  • shortcuts/drive/drive_add_comment_test.go
  • skills/lark-drive/SKILL.md
  • skills/lark-drive/references/lark-drive-add-comment.md
✅ Files skipped from review due to trivial changes (1)
  • shortcuts/drive/drive_add_comment_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • skills/lark-drive/SKILL.md

Comment thread skills/lark-drive/references/lark-drive-add-comment.md
Change-Id: Id87ecce098d87f7db82389a73f3134b66fcd4814
@ethan-zhx ethan-zhx force-pushed the feat/slide_comment branch from 212f7ce to e434177 Compare April 27, 2026 11:06
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 (2)
shortcuts/drive/drive_add_comment.go (1)

286-290: Wiki resolution metadata is dropped when redirecting to executeSlidesComment.

When a wiki URL resolves to slides, only target.FileToken is forwarded. target.WikiToken and target.ResolvedBy are discarded, so the output of executeSlidesComment (lines 826-833) lacks wiki_token and resolved_by — fields that the docx flow preserves (lines 346, 353). This makes it harder for agents/users to confirm which wiki node was resolved. The same pre-existing gap applies to the sheet redirect at lines 285-287, so this can be addressed consistently for both.

♻️ Suggested approach

Pass the full resolvedCommentTarget (or at least WikiToken/ResolvedBy) into executeSlidesComment and include them in the output map when set:

if target.FileType == "slides" {
    return executeSlidesComment(runtime, commentDocRef{Kind: "slides", Token: target.FileToken}, target.WikiToken, target.ResolvedBy)
}

And in executeSlidesComment, conditionally add:

if wikiToken != "" {
    out["wiki_token"] = wikiToken
}
if resolvedBy != "" {
    out["resolved_by"] = resolvedBy
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@shortcuts/drive/drive_add_comment.go` around lines 286 - 290, The redirect to
executeSlidesComment (and executeSheetComment) drops wiki resolution metadata:
instead of forwarding only commentDocRef{Kind:"slides", Token:
target.FileToken}, pass the full resolvedCommentTarget fields (or at least
target.WikiToken and target.ResolvedBy) into
executeSlidesComment/executeSheetComment so those functions can include
wiki_token and resolved_by in their output map; update the executeSlidesComment
signature to accept wikiToken and resolvedBy (or the resolvedCommentTarget) and
conditionally add out["wiki_token"] and out["resolved_by"] when non-empty,
matching the docx flow behavior.
shortcuts/drive/drive_add_comment_test.go (1)

793-827: Consider asserting wiki resolution metadata in stdout.

TestSlidesCommentViaWikiResolve only checks for comment_id in stdout. If the slides output is updated to preserve wiki_token/resolved_by (see comment on lines 286-290 of drive_add_comment.go), extending this test to assert those fields would lock in the contract and prevent silent regressions. As-is, the test passes regardless of whether wiki metadata is preserved or dropped.

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

In `@shortcuts/drive/drive_add_comment_test.go` around lines 793 - 827,
TestSlidesCommentViaWikiResolve currently only asserts the presence of
"wikiSlideComment" (comment_id) in stdout; update the test
(TestSlidesCommentViaWikiResolve) to also assert that the wiki resolution
metadata (e.g., "wiki_token" and "resolved_by") emitted by the DriveAddComment
command is present in stdout so regressions that drop wiki metadata are caught.
Locate the test's stdout checks and add assertions that stdout contains the
expected wiki_token value (presResolved or the token key) and the resolved_by
identifier (or whichever field DriveAddComment emits), using the same stub
inputs (wikiSlidesToken/presResolved/wikiSlideComment) to form the expected
substrings.
🤖 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/drive/drive_add_comment_test.go`:
- Around line 793-827: TestSlidesCommentViaWikiResolve currently only asserts
the presence of "wikiSlideComment" (comment_id) in stdout; update the test
(TestSlidesCommentViaWikiResolve) to also assert that the wiki resolution
metadata (e.g., "wiki_token" and "resolved_by") emitted by the DriveAddComment
command is present in stdout so regressions that drop wiki metadata are caught.
Locate the test's stdout checks and add assertions that stdout contains the
expected wiki_token value (presResolved or the token key) and the resolved_by
identifier (or whichever field DriveAddComment emits), using the same stub
inputs (wikiSlidesToken/presResolved/wikiSlideComment) to form the expected
substrings.

In `@shortcuts/drive/drive_add_comment.go`:
- Around line 286-290: The redirect to executeSlidesComment (and
executeSheetComment) drops wiki resolution metadata: instead of forwarding only
commentDocRef{Kind:"slides", Token: target.FileToken}, pass the full
resolvedCommentTarget fields (or at least target.WikiToken and
target.ResolvedBy) into executeSlidesComment/executeSheetComment so those
functions can include wiki_token and resolved_by in their output map; update the
executeSlidesComment signature to accept wikiToken and resolvedBy (or the
resolvedCommentTarget) and conditionally add out["wiki_token"] and
out["resolved_by"] when non-empty, matching the docx flow behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 70dfe367-abbc-46cd-b4db-7a61f4f022e3

📥 Commits

Reviewing files that changed from the base of the PR and between 212f7ce and e434177.

📒 Files selected for processing (4)
  • shortcuts/drive/drive_add_comment.go
  • shortcuts/drive/drive_add_comment_test.go
  • skills/lark-drive/SKILL.md
  • skills/lark-drive/references/lark-drive-add-comment.md
✅ Files skipped from review due to trivial changes (1)
  • skills/lark-drive/references/lark-drive-add-comment.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • skills/lark-drive/SKILL.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

2 participants