feat(mail): support scheduled send via --send-time#449
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:
📝 WalkthroughWalkthroughAdds scheduled-send support: CLI shortcuts accept a Unix Changes
Sequence DiagramsequenceDiagram
actor User
participant CLI as "CLI Command"
participant Service as "draft.Send()"
participant API as "Backend API"
User->>CLI: Run command with --send-time
CLI->>CLI: Parse & validate send_time
CLI->>Service: Send(runtime, mailboxID, draftID, sendTime)
Service->>Service: Build request body (include send_time if set)
Service->>API: POST /drafts/{draftID}/send (body includes {"send_time": timestamp})
API->>API: Schedule delivery or send immediately
API-->>Service: Return result/status
Service-->>CLI: Return response
CLI-->>User: Confirm scheduled send
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 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 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 |
Greptile SummaryThis PR adds Two bugs need to be fixed before merging:
Confidence Score: 4/5Two P1 bugs prevent the scheduled-send feature from working correctly; existing (non-scheduled) send paths are unaffected. The
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Shortcut as +send / +reply / +reply-all / +forward
participant DraftSvc as draft.Send()
participant LarkAPI as Lark Mail API
User->>Shortcut: --confirm-send --send-time <timestamp>
Shortcut->>Shortcut: CreateWithRaw() → draft_id
Shortcut->>DraftSvc: Send(mailboxID, draftID, sendTime string)
Note over DraftSvc: ⚠ bodyParams["send_time"] = sendTime (string)<br/>API expects integer
DraftSvc->>LarkAPI: POST .../drafts/{id}/send<br/>{"send_time": "1744608000"}
LarkAPI-->>DraftSvc: Error / ignores field (type mismatch)
DraftSvc-->>Shortcut: error or unscheduled send
Note over User,Shortcut: If --send-time used WITHOUT --confirm-send:<br/>sendTime is read but silently discarded → plain draft saved
|
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@4c2c0c8dfdda29a016e24b739bf9c6f4343f258d🧩 Skill updatenpx skills add larksuite/cli#feat/mail-scheduled-send -y -g |
There was a problem hiding this comment.
Actionable comments posted: 10
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@shortcuts/mail/mail_reply.go`:
- Line 35: Validate the "--send-time" flag locally before proceeding to send: in
the mail send/reply/forward handlers in shortcuts/mail/mail_reply.go (the code
paths around the existing send handling and the locations referenced by the
review: ~line 35, ~72, ~186), ensure you check that if a send-time value is
provided then "--confirm-send" is also set and the timestamp is at least 5
minutes in the future; if either check fails, return a clear user-facing error
instead of proceeding (apply the same validation pattern to the +send,
+reply-all and +forward handlers).
In `@skill-template/domains/mail.md`:
- Line 75: The example Unix timestamp `1744608000` in the note about scheduled
sends is stale and violates the "now + 5 minutes" requirement; update the
example to a future timestamp (e.g., pick a value at least 5 minutes ahead of
the current time) and ensure the text around `--send-time`, `--confirm-send`,
and `send_time` still clearly states the requirement that `--send-time` must be
used with `--confirm-send` and represent a Unix timestamp in seconds (now + 5
minutes minimum).
In `@skills/lark-mail/references/lark-mail-forward.md`:
- Line 70: The example Unix timestamp for `--send-time <timestamp>` is wrong and
in the past (uses 1744608000); update the example to the correct Unix timestamp
for "2026-04-14 15:00" (1776178800) or replace examples with a clear placeholder
like `<unix_timestamp>`; apply the same change to the other occurrences
referenced (the block around the current example and the instances noted at
lines 123-127) so the narrative time and example timestamps are consistent.
In `@skills/lark-mail/references/lark-mail-reply-all.md`:
- Around line 161-164: The paragraph about scheduled sending with `--send-time`
is self-contradictory: it first says there will be no `message_id` immediately
and then implies `send_status` can be queried immediately; change the text to
consistently instruct callers not to call `send_status` when `message_id` is
absent (i.e., for scheduled sends), and instead state they should either wait
until the scheduled send time or wait until a `message_id` is returned before
calling `send_status`; keep references to `--send-time`, `message_id`, and
`send_status` to make the behavior clear.
- Around line 127-131: The human-readable send time "2026-04-14 15:00" and the
example Unix timestamp (1744608000) are inconsistent; update the example in the
lark-cli mail user_mailbox.drafts send snippet so the send_time matches the
displayed time (e.g., replace the incorrect 1744608000 with the correct Unix
seconds for 2026-04-14 15:00 UTC: 1776178800) and add a brief note that
send_time should be in seconds and at least current_time + 5 minutes; target the
send_time field and the lark-cli mail user_mailbox.drafts send example to make
this change.
In `@skills/lark-mail/references/lark-mail-reply.md`:
- Line 77: Update the inconsistent example for the `--send-time <timestamp>`
option: either replace the hardcoded Unix timestamp `1744608000` with one that
matches the displayed datetime "2026-04-14 15:00" (or vice versa), or swap both
to a clear placeholder like `<unix_timestamp>`; apply the same fix to the other
occurrences referencing `--send-time <timestamp>` (the block around the
additional examples mentioned) so the human-readable datetime and Unix timestamp
are consistent throughout.
In `@skills/lark-mail/references/lark-mail-send.md`:
- Around line 129-133: The example uses a human-readable send time "2026-04-14
15:00" but supplies a mismatched Unix timestamp 1744608000 for send_time; update
the send_time value in the lark-cli example (the JSON --data
'{"send_time":...}') to the correct Unix timestamp that corresponds to
"2026-04-14 15:00" (or change the human-readable text to match the existing
timestamp), ensuring the --data send_time matches the displayed time and still
satisfies the "current time + 5 minutes" requirement; refer to the lark-cli mail
user_mailbox.drafts send command and the send_time field/draft_id placeholder
when making the correction.
- Around line 156-157: Clarify the documentation to remove the logical conflict
between "message_id is not generated immediately" and "`send_status` returns
'pending'": state explicitly that send_status can only be queried when a
message_id is available, and for scheduled sends the system may return a
'pending' send_status without a message_id until the scheduled job is
created/executed; update the paragraph to say: for scheduled sends, do not query
send_status immediately—wait until a message_id is returned (or until after the
scheduled send time), then use that message_id to query send_status.
In `@skills/lark-mail/SKILL.md`:
- Line 89: Update the example for `--send-time` in SKILL.md so the sample Unix
timestamp matches the 2026 example date used elsewhere (or replace the hardcoded
`1744608000` with a note to compute the Unix seconds dynamically), and ensure
the surrounding text referencing `--send-time`, `--confirm-send`, and
`send_time` still states that the timestamp is in seconds and must be at least
current time + 5 minutes.
- Around line 136-137: The scheduled-send paragraph mentioning "--send-time",
"message_id", and "send_status" is ambiguous; update the SKILL.md paragraph to
explicitly state that when a scheduled send does not immediately return a
message_id you must not query send_status (i.e., wait until you have a
message_id or until the scheduled send time has passed), and add a clear
sentence such as "If no message_id is returned for a scheduled send, do not
query send_status until a message_id is obtained or the scheduled time has
passed" to close the loop.
🪄 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: f900c828-6446-4983-b946-3307d21f0c2e
📒 Files selected for processing (11)
shortcuts/mail/draft/service.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
- Pass nil body instead of empty map when sendTime is absent in draft.Send() - Add validateSendTime() to check timestamp format and >=now+5min constraint - Call validateSendTime in all 4 handler Validate funcs (send/reply/reply-all/forward) - Replace hardcoded 1744608000 with <unix_timestamp> placeholder in all docs Co-Authored-By: AI
There was a problem hiding this comment.
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-mail/references/lark-mail-send.md`:
- Line 129: The example confirmation string contains a stale hardcoded schedule
"2026-04-14 15:00" which conflicts with the "当前时间 + 5 分钟" rule; update the
example in the confirmation text (the line showing: 邮件草稿已创建:收件人
alice@example.com,主题「周报」,定时 2026-04-14 15:00 发送。确认吗?) to either use a relative
placeholder like "定时 当前时间 + 5 分钟 发送" or a template token (e.g.,
"{{now_plus_5min}}") so the example stays correct and consistent with the
scheduling rule.
🪄 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: 724e668c-6253-40ff-b0bf-90a8a216677b
📒 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 as they are similar to previous changes (9)
- shortcuts/mail/mail_reply.go
- shortcuts/mail/mail_reply_all.go
- shortcuts/mail/draft/service.go
- skills/lark-mail/references/lark-mail-forward.md
- skills/lark-mail/references/lark-mail-reply.md
- shortcuts/mail/mail_send.go
- skills/lark-mail/references/lark-mail-reply-all.md
- shortcuts/mail/mail_forward.go
- skills/lark-mail/SKILL.md
Replace "2026-04-14 15:00" with "<目标时间>" placeholder in all scheduled-send scenario examples to avoid stale dates. Co-Authored-By: AI
…d for scheduled sends - validateSendTime now rejects --send-time without --confirm-send - Scheduled send output includes draft_id, scheduled_send_time, and cancel_tip so users can cancel via cancel_scheduled_send - Applied to all 4 handlers (send/reply/reply-all/forward)
Scheduled sends do return message_id; cancellation also uses message_id. The only limitation is send_status cannot be queried immediately. The extra draft_id/cancel_tip output was unnecessary.
There was a problem hiding this comment.
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 `@shortcuts/mail/mail_reply_all.go`:
- Line 77: The code reads the raw --send-time into sendTime using
runtime.Str("send-time") without trimming, so untrimmed values can be validated
but later passed to draftpkg.Send()/output with surrounding whitespace; change
the source to trim whitespace once (e.g., replace the raw assignment of sendTime
in mail_reply_all.go with a trimmed value) and ensure the trimmed variable is
used everywhere thereafter (including where validateSendTime is called and where
draftpkg.Send() is invoked); apply the same single-source trim fix to the
analogous variables in mail_reply.go and mail_forward.go so all send-time values
are normalized before any validation or sending.
🪄 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: 06bd459b-9ede-45bb-907b-f7d3e828bede
📒 Files selected for processing (5)
shortcuts/mail/helpers.goshortcuts/mail/mail_forward.goshortcuts/mail/mail_reply.goshortcuts/mail/mail_reply_all.goshortcuts/mail/mail_send.go
✅ Files skipped from review due to trivial changes (1)
- shortcuts/mail/helpers.go
🚧 Files skipped from review as they are similar to previous changes (1)
- shortcuts/mail/mail_send.go
chanthuang
left a comment
There was a problem hiding this comment.
LGTM. Conflict resolution is clean — recall feature (buildSendResult) preserved correctly across all 4 shortcuts. The --confirm-send dependency check in validateSendTime addresses the earlier must-fix.
Summary
+send、+reply、+reply-all、+forward四个 shortcut 新增--send-time参数,支持定时发送邮件draft.Send函数增加sendTime参数,透传至 API 请求体Test plan
+send --confirm-send --send-time <timestamp>定时发送新邮件+reply --confirm-send --send-time <timestamp>定时发送回复+reply-all --confirm-send --send-time <timestamp>定时发送回复全部+forward --confirm-send --send-time <timestamp>定时发送转发cancel_scheduled_send取消定时发送后邮件恢复为草稿状态Summary by CodeRabbit
New Features
Behavior Changes
Documentation