Reapply "feat: mail support scheduled send (#449)"#534
Conversation
📝 WalkthroughWalkthroughAdd scheduled-send support: new Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as Client (lark-cli)
participant Shortcut as Mail Shortcut (Validate/Execute)
participant DraftSvc as drafts service (draftpkg.Send)
participant API as Mail API (user_mailbox.drafts)
CLI->>Shortcut: run command with --send-time & --confirm-send
Shortcut->>Shortcut: validateSendTime(runtime)
Shortcut->>DraftSvc: Send(runtime, mailboxID, draftID, sendTime)
DraftSvc->>API: POST /drafts/{draftID}/send body {"send_time": sendTime}
API-->>DraftSvc: 200 OK (scheduled or immediate response)
DraftSvc-->>Shortcut: return response map
Shortcut-->>CLI: output result
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #534 +/- ##
==========================================
+ Coverage 59.05% 59.09% +0.03%
==========================================
Files 384 384
Lines 32637 32673 +36
==========================================
+ Hits 19275 19308 +33
- Misses 11554 11556 +2
- Partials 1808 1809 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
shortcuts/mail/helpers.go (1)
1910-1929:validateSendTimelooks correct; one small robustness suggestion.Validation logic (non-empty → require
--confirm-send→ parse int64 → enforce ≥ now+5min) is sound, and per prior learningstrconv.ParseIntalready rejects whitespace-padded inputs, so no explicitTrimSpaceis needed.Optional: the error at Line 1926 reports the minimum as a raw Unix epoch, which is not very user-friendly. Formatting the minimum as an RFC3339/local time alongside the numeric value would make failures self-explanatory in CLI output without changing behavior.
♻️ Optional readability tweak
- minTime := time.Now().Unix() + 5*60 - if ts < minTime { - return fmt.Errorf("--send-time must be at least 5 minutes in the future (minimum: %d, got: %d)", minTime, ts) - } + minTime := time.Now().Unix() + 5*60 + if ts < minTime { + return fmt.Errorf("--send-time must be at least 5 minutes in the future (minimum: %d / %s, got: %d)", + minTime, time.Unix(minTime, 0).Format(time.RFC3339), ts) + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@shortcuts/mail/helpers.go` around lines 1910 - 1929, The current validateSendTime function reports the minimum as a raw Unix epoch, which is hard to read; update the error message in validateSendTime (same function and the minTime variable) to include a human-readable timestamp alongside the numeric epoch (e.g., format time.Unix(minTime, 0) with time.RFC3339 or local time) so the returned fmt.Errorf shows both the numeric minimum and a friendly date/time string when ts < minTime.
🤖 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/mail/helpers.go`:
- Around line 1910-1929: The current validateSendTime function reports the
minimum as a raw Unix epoch, which is hard to read; update the error message in
validateSendTime (same function and the minTime variable) to include a
human-readable timestamp alongside the numeric epoch (e.g., format
time.Unix(minTime, 0) with time.RFC3339 or local time) so the returned
fmt.Errorf shows both the numeric minimum and a friendly date/time string when
ts < minTime.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2f23fb55-8448-4f43-ab97-14485f64a19f
📒 Files selected for processing (12)
shortcuts/mail/draft/service.goshortcuts/mail/helpers.goshortcuts/mail/mail_forward.goshortcuts/mail/mail_reply.goshortcuts/mail/mail_reply_all.goshortcuts/mail/mail_send.goskill-template/domains/mail.mdskills/lark-mail/SKILL.mdskills/lark-mail/references/lark-mail-forward.mdskills/lark-mail/references/lark-mail-reply-all.mdskills/lark-mail/references/lark-mail-reply.mdskills/lark-mail/references/lark-mail-send.md
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@a9c1c3e666bf9808a222f71b59a4f1a653d6a37b🧩 Skill updatenpx skills add larksuite/cli#revert-03ba542a -y -g |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
shortcuts/mail/helpers.go (1)
1910-1929: Optional: extract the 5-minute minimum as a named constant and add a unit test.The logic is correct and matches the documented scheduled-send contract. Two small nits worth considering:
- The
5*60lead time is duplicated in the flag help text for all four shortcuts. Promoting it to a package-level constant (e.g.,minScheduledSendLeadSeconds = 5 * 60) would keep the validator and docs in sync if the policy ever changes.- This helper is pure and trivially testable (empty input, missing
--confirm-send, non-numeric input, past timestamp, just-under/over the 5-minute boundary). As per coding guidelines "Every behavior change must have an accompanying test", a small table-driven test inshortcuts/mail/helpers_test.gowould lock in the boundary behavior.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@shortcuts/mail/helpers.go` around lines 1910 - 1929, Extract the hardcoded 5*60 lead time in validateSendTime into a package-level named constant (e.g., minScheduledSendLeadSeconds = 5 * 60) and replace the inline expression in validateSendTime with that constant to keep docs and validator consistent; then add a table-driven unit test in shortcuts/mail/helpers_test.go that exercises validateSendTime for empty input, missing --confirm-send, non-numeric send-time, past timestamp, and timestamps just below and above the minScheduledSendLeadSeconds boundary to lock in behavior.
🤖 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/mail/helpers.go`:
- Around line 1910-1929: Extract the hardcoded 5*60 lead time in
validateSendTime into a package-level named constant (e.g.,
minScheduledSendLeadSeconds = 5 * 60) and replace the inline expression in
validateSendTime with that constant to keep docs and validator consistent; then
add a table-driven unit test in shortcuts/mail/helpers_test.go that exercises
validateSendTime for empty input, missing --confirm-send, non-numeric send-time,
past timestamp, and timestamps just below and above the
minScheduledSendLeadSeconds boundary to lock in behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: dc5a0e71-1616-469b-8921-8daf944eea48
📒 Files selected for processing (12)
shortcuts/mail/draft/service.goshortcuts/mail/helpers.goshortcuts/mail/mail_forward.goshortcuts/mail/mail_reply.goshortcuts/mail/mail_reply_all.goshortcuts/mail/mail_send.goskill-template/domains/mail.mdskills/lark-mail/SKILL.mdskills/lark-mail/references/lark-mail-forward.mdskills/lark-mail/references/lark-mail-reply-all.mdskills/lark-mail/references/lark-mail-reply.mdskills/lark-mail/references/lark-mail-send.md
✅ Files skipped from review due to trivial changes (1)
- skills/lark-mail/references/lark-mail-send.md
🚧 Files skipped from review as they are similar to previous changes (7)
- shortcuts/mail/mail_reply.go
- shortcuts/mail/draft/service.go
- skill-template/domains/mail.md
- skills/lark-mail/references/lark-mail-reply.md
- skills/lark-mail/references/lark-mail-reply-all.md
- skills/lark-mail/references/lark-mail-forward.md
- skills/lark-mail/SKILL.md
Summary
03ba542)--send-timesupport across mail send/reply/reply-all/forward shortcuts with shared helper inshortcuts/mail/helpers.golark-mailskill docs and references to document the scheduled send flowTest plan
lark-cli mail +send --send-time <future-ts> ...schedules a draft correctlylark-cli mail +reply / +reply-all / +forward --send-time <future-ts> ...schedule as expected--send-timepreserves existing immediate-send behavior