feat: event description support rich text#1975
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughCalendar shortcuts now support Markdown ChangesCalendar rich description flow
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: 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
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ 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 |
7e6ffce to
c1d8189
Compare
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@e188d8b8426f453d61265be4ff9db898e4c63257🧩 Skill updatenpx skills add larksuite/cli#feat/calendar_support_rich_text -y -g |
There was a problem hiding this comment.
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 winAdd
--description-richto the dangerous-char checkshortcuts/calendar/calendar_create.go:117-123—description-richis the unified Markdown input, but create still skips the sameRejectDangerousCharsTypedguard 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 valueReuse
unifyDescriptionRichhelper to consolidate logic.This duplicates the rich description unification logic introduced in
helpers.go. Sinceeventis 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
📒 Files selected for processing (13)
shortcuts/calendar/calendar_agenda.goshortcuts/calendar/calendar_create.goshortcuts/calendar/calendar_get.goshortcuts/calendar/calendar_test.goshortcuts/calendar/calendar_update.goshortcuts/calendar/description_rich_images.goshortcuts/calendar/description_rich_images_test.goshortcuts/calendar/helpers.goskills/lark-calendar/SKILL.mdskills/lark-calendar/references/lark-calendar-create.mdskills/lark-calendar/references/lark-calendar-recurring.mdskills/lark-calendar/references/lark-calendar-update.mdtests/cli_e2e/calendar/calendar_description_rich_dryrun_test.go
There was a problem hiding this comment.
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 winValidate
--description-richfor dangerous characters.The new
--description-richflag accepts Markdown input (which could be read from a file or stdin) and must be validated for terminal-breaking control characters (like\x1bor\x00), just like the deprecated--descriptionflag.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
📒 Files selected for processing (13)
shortcuts/calendar/calendar_agenda.goshortcuts/calendar/calendar_create.goshortcuts/calendar/calendar_get.goshortcuts/calendar/calendar_test.goshortcuts/calendar/calendar_update.goshortcuts/calendar/description_rich_images.goshortcuts/calendar/description_rich_images_test.goshortcuts/calendar/helpers.goskills/lark-calendar/SKILL.mdskills/lark-calendar/references/lark-calendar-create.mdskills/lark-calendar/references/lark-calendar-recurring.mdskills/lark-calendar/references/lark-calendar-update.mdtests/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
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
9584ed9 to
cfadc70
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 `@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
📒 Files selected for processing (14)
internal/registry/calendar_description_rich_test.goshortcuts/calendar/calendar_agenda.goshortcuts/calendar/calendar_create.goshortcuts/calendar/calendar_get.goshortcuts/calendar/calendar_test.goshortcuts/calendar/calendar_update.goshortcuts/calendar/description_rich_images.goshortcuts/calendar/description_rich_images_test.goshortcuts/calendar/helpers.goskills/lark-calendar/SKILL.mdskills/lark-calendar/references/lark-calendar-create.mdskills/lark-calendar/references/lark-calendar-recurring.mdskills/lark-calendar/references/lark-calendar-update.mdtests/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
cfadc70 to
312d247
Compare
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/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
📒 Files selected for processing (14)
internal/registry/calendar_description_rich_test.goshortcuts/calendar/calendar_agenda.goshortcuts/calendar/calendar_create.goshortcuts/calendar/calendar_get.goshortcuts/calendar/calendar_test.goshortcuts/calendar/calendar_update.goshortcuts/calendar/description_rich_images.goshortcuts/calendar/description_rich_images_test.goshortcuts/calendar/helpers.goskills/lark-calendar/SKILL.mdskills/lark-calendar/references/lark-calendar-create.mdskills/lark-calendar/references/lark-calendar-recurring.mdskills/lark-calendar/references/lark-calendar-update.mdtests/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
83e8efb to
8bd5165
Compare
Co-authored-by: Cursor <cursoragent@cursor.com>
8bd5165 to
e188d8b
Compare
Summary
Changes
Test Plan
lark-cli <domain> <command>flow works as expectedRelated Issues
Summary by CodeRabbit
--description-rich(Markdown) for calendarcreate,update, and recurring edits, including automatic upload of local images and rewritten preview URLs.--description;descriptionvsdescription_richis treated as mutually exclusive in write requests.descriptionanddescription_rich, backfillingdescription_richfrom plaindescriptionwhen needed.--description-rich, clarify mutual exclusivity, and document image/input rules.