Skip to content

feat: event description support rich text#1975

Open
zhangjun-bytedance wants to merge 1 commit into
mainfrom
feat/calendar_support_rich_text
Open

feat: event description support rich text#1975
zhangjun-bytedance wants to merge 1 commit into
mainfrom
feat/calendar_support_rich_text

Conversation

@zhangjun-bytedance

@zhangjun-bytedance zhangjun-bytedance commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

Changes

  • Change 1
  • Change 2

Test Plan

  • Unit tests pass
  • Manual local verification confirms the lark-cli <domain> <command> flow works as expected

Related Issues

  • None

Summary by CodeRabbit

  • New Features
    • Added --description-rich (Markdown) for calendar create, update, and recurring edits, including automatic upload of local images and rewritten preview URLs.
    • Deprecated/hidden --description; description vs description_rich is treated as mutually exclusive in write requests.
  • Bug Fixes
    • Calendar read output now consistently returns both description and description_rich, backfilling description_rich from plain description when needed.
  • Documentation
    • Updated skill and command references to prefer --description-rich, clarify mutual exclusivity, and document image/input rules.
  • Tests
    • Added unit + e2e dry-run coverage for payload generation, image handling, and read/write unification plus meta contract checks.

@github-actions github-actions Bot added domain/calendar PR touches the calendar domain size/M Single-domain feat or fix with limited business impact labels Jul 20, 2026
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

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

Calendar shortcuts now support Markdown description-rich input, local image upload and rewriting, unified rich-description output, updated create/update payloads, metadata validation, tests, and documentation.

Changes

Calendar rich description flow

Layer / File(s) Summary
Normalize calendar description output
shortcuts/calendar/helpers.go, shortcuts/calendar/calendar_agenda.go, shortcuts/calendar/calendar_get.go, shortcuts/calendar/calendar_test.go
Agenda and get outputs retain description and ensure description_rich is populated from the rich value or plain-text fallback.
Add rich description create and update contracts
shortcuts/calendar/calendar_create.go, shortcuts/calendar/calendar_update.go, tests/cli_e2e/calendar/*
Create and update add --description-rich, send description_rich, retain hidden deprecated plain-text compatibility, resolve images before requests, and verify dry-run payloads.
Upload and rewrite local description images
shortcuts/calendar/description_rich_images.go, shortcuts/calendar/description_rich_images_test.go
Local Markdown images are classified, normalized, validated, uploaded to Drive, converted to preview URLs, deduplicated, and tested with remote, data, and image-dimension cases.
Validate and document description contracts
internal/registry/calendar_description_rich_test.go, skills/lark-calendar/*
Metadata tests verify both description fields across calendar methods, and documentation describes rich Markdown input, image handling, formatting rules, and field exclusivity.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

  • larksuite/cli#678: Modifies the calendar update shortcut extended here with rich-description support.
  • larksuite/cli#1768: Introduces the calendar get flow extended here with rich-description output handling.

Suggested reviewers: liangshuo-1

Sequence Diagram(s)

sequenceDiagram
  participant CalendarCreate
  participant DescriptionImageResolver
  participant Drive
  participant CalendarAPI
  CalendarCreate->>DescriptionImageResolver: resolve description-rich images
  DescriptionImageResolver->>Drive: upload local image
  Drive-->>DescriptionImageResolver: return file token
  DescriptionImageResolver-->>CalendarCreate: rewrite Markdown preview URL
  CalendarCreate->>CalendarAPI: submit description_rich event payload
Loading
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is just the template with placeholder text and no real summary, changes, tests, or issue links. Replace placeholders with a 1-3 sentence summary, concrete change bullets, actual test or verification results, and any related issue links.
Docstring Coverage ⚠️ Warning Docstring coverage is 37.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding rich text support for event descriptions.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/calendar_support_rich_text

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.

@zhangjun-bytedance
zhangjun-bytedance force-pushed the feat/calendar_support_rich_text branch from 7e6ffce to c1d8189 Compare July 20, 2026 13:13
@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#feat/calendar_support_rich_text -y -g

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 (1)
shortcuts/calendar/calendar_create.go (1)

117-123: 🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

Add --description-rich to the dangerous-char check shortcuts/calendar/calendar_create.go:117-123description-rich is the unified Markdown input, but create still skips the same RejectDangerousCharsTyped guard applied to --description. The helper only rejects control/dangerous Unicode, so normal Markdown syntax is unaffected.

🤖 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/calendar/calendar_create.go` around lines 117 - 123, Extend the
validation flag list in the calendar create flow to include "description-rich",
so its runtime value is passed through RejectDangerousCharsTyped just like
"description" and the other fields. Keep the existing non-empty check and error
propagation unchanged.
🧹 Nitpick comments (1)
shortcuts/calendar/calendar_update.go (1)

367-372: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Reuse unifyDescriptionRich helper to consolidate logic.

This duplicates the rich description unification logic introduced in helpers.go. Since event is an isolated map instance that is discarded afterward, you can safely apply the helper directly to it.

♻️ Proposed refactor
-	descriptionRich, _ := event["description_rich"].(string)
-	if descriptionRich == "" {
-		descriptionRich, _ = event["description"].(string)
-	}
-	if descriptionRich != "" {
-		result["description_rich"] = descriptionRich
-	}
+	unifyDescriptionRich(event)
+	if descriptionRich, _ := event["description_rich"].(string); descriptionRich != "" {
+		result["description_rich"] = descriptionRich
+	}
🤖 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/calendar/calendar_update.go` around lines 367 - 372, Replace the
local descriptionRich extraction and fallback logic in the event update flow
with the existing unifyDescriptionRich helper, applying it directly to the
isolated event map before reading the unified value. Preserve the current
behavior of setting result["description_rich"] only when the resulting
description is non-empty.
🤖 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/calendar/description_rich_images.go`:
- Around line 147-152: Update the file URL handling around the `url.Parse`
branch so a successfully parsed `file://` URL with a non-empty `u.Path` returns
or resolves that path directly, bypassing the later `url.PathUnescape(s)` call.
Preserve the existing unescape behavior for non-file URLs and invalid or
pathless file URLs.

---

Outside diff comments:
In `@shortcuts/calendar/calendar_create.go`:
- Around line 117-123: Extend the validation flag list in the calendar create
flow to include "description-rich", so its runtime value is passed through
RejectDangerousCharsTyped just like "description" and the other fields. Keep the
existing non-empty check and error propagation unchanged.

---

Nitpick comments:
In `@shortcuts/calendar/calendar_update.go`:
- Around line 367-372: Replace the local descriptionRich extraction and fallback
logic in the event update flow with the existing unifyDescriptionRich helper,
applying it directly to the isolated event map before reading the unified value.
Preserve the current behavior of setting result["description_rich"] only when
the resulting description is non-empty.
🪄 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: 5194fbaa-f7b0-4c93-a2d5-04f8f6333917

📥 Commits

Reviewing files that changed from the base of the PR and between 4cdfa2f and 7e6ffce.

📒 Files selected for processing (13)
  • shortcuts/calendar/calendar_agenda.go
  • shortcuts/calendar/calendar_create.go
  • shortcuts/calendar/calendar_get.go
  • shortcuts/calendar/calendar_test.go
  • shortcuts/calendar/calendar_update.go
  • shortcuts/calendar/description_rich_images.go
  • shortcuts/calendar/description_rich_images_test.go
  • shortcuts/calendar/helpers.go
  • skills/lark-calendar/SKILL.md
  • skills/lark-calendar/references/lark-calendar-create.md
  • skills/lark-calendar/references/lark-calendar-recurring.md
  • skills/lark-calendar/references/lark-calendar-update.md
  • tests/cli_e2e/calendar/calendar_description_rich_dryrun_test.go

Comment thread shortcuts/calendar/description_rich_images.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

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

⚠️ Outside diff range comments (1)
shortcuts/calendar/calendar_update.go (1)

56-57: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Validate --description-rich for dangerous characters.

The new --description-rich flag accepts Markdown input (which could be read from a file or stdin) and must be validated for terminal-breaking control characters (like \x1b or \x00), just like the deprecated --description flag.

Add "description-rich" to the flag list to prevent terminal injection when the saved payload is echoed back to the user.

🛡️ Proposed fix
-	for _, flag := range []string{"event-id", "summary", "description", "rrule", "calendar-id", "start", "end", "add-attendee-ids", "remove-attendee-ids"} {
+	for _, flag := range []string{"event-id", "summary", "description", "description-rich", "rrule", "calendar-id", "start", "end", "add-attendee-ids", "remove-attendee-ids"} {
		if val := runtime.Str(flag); val != "" {
🤖 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/calendar/calendar_update.go` around lines 56 - 57, Update the
validation loop in the calendar update command to include "description-rich"
alongside the existing validated flags, ensuring Markdown input from files or
stdin is checked for dangerous control characters before the saved payload is
echoed.
🤖 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/calendar/calendar_update.go`:
- Around line 118-121: Update the description flag handling in the calendar
update flow to detect when both "description" and "description-rich" are
explicitly provided, and return the established typed validation error before
populating or sending either conflicting field. Preserve the existing behavior
when only one flag is supplied.

In `@skills/lark-calendar/references/lark-calendar-update.md`:
- Line 46: Update the --description-rich Markdown syntax text in the update
documentation to describe headings as ranging from “# ” to “### ”, removing the
stray “~” and matching the corresponding create documentation.

---

Outside diff comments:
In `@shortcuts/calendar/calendar_update.go`:
- Around line 56-57: Update the validation loop in the calendar update command
to include "description-rich" alongside the existing validated flags, ensuring
Markdown input from files or stdin is checked for dangerous control characters
before the saved payload is echoed.
🪄 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: b15b2ae0-5008-4e9e-a923-3665996eeb22

📥 Commits

Reviewing files that changed from the base of the PR and between 7e6ffce and c1d8189.

📒 Files selected for processing (13)
  • shortcuts/calendar/calendar_agenda.go
  • shortcuts/calendar/calendar_create.go
  • shortcuts/calendar/calendar_get.go
  • shortcuts/calendar/calendar_test.go
  • shortcuts/calendar/calendar_update.go
  • shortcuts/calendar/description_rich_images.go
  • shortcuts/calendar/description_rich_images_test.go
  • shortcuts/calendar/helpers.go
  • skills/lark-calendar/SKILL.md
  • skills/lark-calendar/references/lark-calendar-create.md
  • skills/lark-calendar/references/lark-calendar-recurring.md
  • skills/lark-calendar/references/lark-calendar-update.md
  • tests/cli_e2e/calendar/calendar_description_rich_dryrun_test.go
🚧 Files skipped from review as they are similar to previous changes (10)
  • tests/cli_e2e/calendar/calendar_description_rich_dryrun_test.go
  • shortcuts/calendar/calendar_agenda.go
  • shortcuts/calendar/helpers.go
  • skills/lark-calendar/references/lark-calendar-recurring.md
  • skills/lark-calendar/SKILL.md
  • shortcuts/calendar/description_rich_images_test.go
  • shortcuts/calendar/calendar_get.go
  • shortcuts/calendar/calendar_test.go
  • shortcuts/calendar/calendar_create.go
  • shortcuts/calendar/description_rich_images.go

Comment thread shortcuts/calendar/calendar_update.go
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.88406% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.14%. Comparing base (5a54bc0) to head (e188d8b).

Files with missing lines Patch % Lines
shortcuts/calendar/description_rich_images.go 87.25% 7 Missing and 6 partials ⚠️
shortcuts/calendar/calendar_update.go 50.00% 5 Missing and 5 partials ⚠️
shortcuts/calendar/helpers.go 80.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #1975    +/-   ##
========================================
  Coverage   75.13%   75.14%            
========================================
  Files         905      906     +1     
  Lines       96130    96261   +131     
========================================
+ Hits        72224    72331   +107     
- Misses      18348    18361    +13     
- Partials     5558     5569    +11     

☔ View full report in Codecov by Harness.
📢 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.

@zhangjun-bytedance
zhangjun-bytedance force-pushed the feat/calendar_support_rich_text branch from 9584ed9 to cfadc70 Compare July 21, 2026 06:28

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 `@skills/lark-calendar/references/lark-calendar-create.md`:
- Line 35: Rewrite the heading and quote Markdown examples in
skills/lark-calendar/references/lark-calendar-create.md:35-35 so code spans
contain no trailing spaces, explaining the required space in surrounding prose.
Apply the same MD038-safe wording in
skills/lark-calendar/references/lark-calendar-update.md:46-46 and remove the
separate stray ~ there.

In `@skills/lark-calendar/references/lark-calendar-update.md`:
- Line 46: Update the --description-rich Markdown syntax documentation to avoid
trailing spaces inside inline code spans: rephrase the heading and quote
examples to state that #, ##, ###, and > are followed by a space, without
including that space within the code spans. Preserve the documented Markdown
behavior.
🪄 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: 18499d3b-76f5-4ce5-8ccf-5bb99c33201a

📥 Commits

Reviewing files that changed from the base of the PR and between 9584ed9 and cfadc70.

📒 Files selected for processing (14)
  • internal/registry/calendar_description_rich_test.go
  • shortcuts/calendar/calendar_agenda.go
  • shortcuts/calendar/calendar_create.go
  • shortcuts/calendar/calendar_get.go
  • shortcuts/calendar/calendar_test.go
  • shortcuts/calendar/calendar_update.go
  • shortcuts/calendar/description_rich_images.go
  • shortcuts/calendar/description_rich_images_test.go
  • shortcuts/calendar/helpers.go
  • skills/lark-calendar/SKILL.md
  • skills/lark-calendar/references/lark-calendar-create.md
  • skills/lark-calendar/references/lark-calendar-recurring.md
  • skills/lark-calendar/references/lark-calendar-update.md
  • tests/cli_e2e/calendar/calendar_description_rich_dryrun_test.go
🚧 Files skipped from review as they are similar to previous changes (11)
  • skills/lark-calendar/SKILL.md
  • shortcuts/calendar/helpers.go
  • tests/cli_e2e/calendar/calendar_description_rich_dryrun_test.go
  • shortcuts/calendar/calendar_get.go
  • shortcuts/calendar/calendar_agenda.go
  • skills/lark-calendar/references/lark-calendar-recurring.md
  • shortcuts/calendar/calendar_test.go
  • shortcuts/calendar/calendar_update.go
  • shortcuts/calendar/description_rich_images.go
  • shortcuts/calendar/description_rich_images_test.go
  • shortcuts/calendar/calendar_create.go

Comment thread skills/lark-calendar/references/lark-calendar-create.md
Comment thread skills/lark-calendar/references/lark-calendar-update.md
@zhangjun-bytedance
zhangjun-bytedance force-pushed the feat/calendar_support_rich_text branch from cfadc70 to 312d247 Compare July 21, 2026 11:14

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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/calendar/calendar_test.go`:
- Around line 1274-1279: Update the CalendarAgenda test at
shortcuts/calendar/calendar_test.go:1274-1279 and the CalendarGet tests at
shortcuts/calendar/calendar_test.go:3331 and 3363 to include the --format=json
argument, ensuring their JSON assertions match the CLI output.

In `@shortcuts/calendar/helpers.go`:
- Around line 43-49: The descriptionRichToSend helper currently prioritizes
description-rich and silently ignores description when both flags are supplied.
Validate the mutually exclusive flags using runtime.Cmd.Flags().Changed, return
an errs.NewValidationError when both are set, and update the helper or calling
command Validate functions to propagate the error without changing valid
single-flag behavior.
- Around line 33-42: Refactor backfillDescriptionRich to operate on the typed
CalendarEvent struct instead of map[string]interface{}. Parse the API JSON
response into CalendarEvent at the boundary, add the description-rich fallback
as a CalendarEvent method, and update callers to use the typed value without
loose-map mutation.
🪄 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: 76ad552c-5b2b-45f9-a237-d08eba70792a

📥 Commits

Reviewing files that changed from the base of the PR and between cfadc70 and 312d247.

📒 Files selected for processing (14)
  • internal/registry/calendar_description_rich_test.go
  • shortcuts/calendar/calendar_agenda.go
  • shortcuts/calendar/calendar_create.go
  • shortcuts/calendar/calendar_get.go
  • shortcuts/calendar/calendar_test.go
  • shortcuts/calendar/calendar_update.go
  • shortcuts/calendar/description_rich_images.go
  • shortcuts/calendar/description_rich_images_test.go
  • shortcuts/calendar/helpers.go
  • skills/lark-calendar/SKILL.md
  • skills/lark-calendar/references/lark-calendar-create.md
  • skills/lark-calendar/references/lark-calendar-recurring.md
  • skills/lark-calendar/references/lark-calendar-update.md
  • tests/cli_e2e/calendar/calendar_description_rich_dryrun_test.go
🚧 Files skipped from review as they are similar to previous changes (7)
  • shortcuts/calendar/calendar_agenda.go
  • skills/lark-calendar/SKILL.md
  • tests/cli_e2e/calendar/calendar_description_rich_dryrun_test.go
  • shortcuts/calendar/calendar_get.go
  • shortcuts/calendar/description_rich_images_test.go
  • shortcuts/calendar/description_rich_images.go
  • shortcuts/calendar/calendar_update.go

Comment thread shortcuts/calendar/calendar_test.go
Comment thread shortcuts/calendar/helpers.go
Comment thread shortcuts/calendar/helpers.go
@zhangjun-bytedance
zhangjun-bytedance force-pushed the feat/calendar_support_rich_text branch 3 times, most recently from 83e8efb to 8bd5165 Compare July 21, 2026 12:38
Co-authored-by: Cursor <cursoragent@cursor.com>
@zhangjun-bytedance
zhangjun-bytedance force-pushed the feat/calendar_support_rich_text branch from 8bd5165 to e188d8b Compare July 24, 2026 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/calendar PR touches the calendar domain size/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant