Skip to content

Reapply "feat: mail support scheduled send (#449)"#534

Merged
infeng merged 4 commits intomainfrom
revert-03ba542a
Apr 17, 2026
Merged

Reapply "feat: mail support scheduled send (#449)"#534
infeng merged 4 commits intomainfrom
revert-03ba542a

Conversation

@infeng
Copy link
Copy Markdown
Collaborator

@infeng infeng commented Apr 17, 2026

Summary

  • Reapply the mail scheduled send feature that was reverted in Revert "feat: mail support scheduled send (#449)" #492 (reverts commit 03ba542)
  • Restores --send-time support across mail send/reply/reply-all/forward shortcuts with shared helper in shortcuts/mail/helpers.go
  • Updates lark-mail skill docs and references to document the scheduled send flow

Test plan

  • lark-cli mail +send --send-time <future-ts> ... schedules a draft correctly
  • lark-cli mail +reply / +reply-all / +forward --send-time <future-ts> ... schedule as expected
  • Omitting --send-time preserves existing immediate-send behavior

@github-actions github-actions bot added domain/mail PR touches the mail domain size/M Single-domain feat or fix with limited business impact labels Apr 17, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 17, 2026

📝 Walkthrough

Walkthrough

Add scheduled-send support: new --send-time flag (Unix seconds, >= now+5min, requires --confirm-send), validate it during shortcut validation, thread sendTime into draftpkg.Send(...), include send_time in POST body when present, and add docs/tests.

Changes

Cohort / File(s) Summary
Core service logic
shortcuts/mail/draft/service.go
Updated Send signature to accept sendTime and conditionally include {"send_time": sendTime} in the POST body when sendTime is non-empty.
Validation helper & tests
shortcuts/mail/helpers.go, shortcuts/mail/helpers_test.go
Added validateSendTime(runtime *common.RuntimeContext) enforcing --confirm-send, parsing Unix-seconds timestamp, and requiring timestamp >= now+5 minutes; added tests for empty, missing confirm, parse error, too-soon, and valid cases.
Mail shortcuts wiring
shortcuts/mail/mail_send.go, shortcuts/mail/mail_forward.go, shortcuts/mail/mail_reply.go, shortcuts/mail/mail_reply_all.go
Added --send-time flag, call validateSendTime() in Validate, read send-time in Execute, and pass sendTime to draftpkg.Send(...) on the --confirm-send path.
Integration tests
shortcuts/mail/mail_send_time_integration_test.go
New integration tests asserting too-soon rejects and missing --confirm-send rejection for --send-time; includes test factory with required scope.
Documentation
skill-template/domains/mail.md, skills/lark-mail/SKILL.md, skills/lark-mail/references/.../lark-mail-*.md
Documented scheduled-send mode, --send-time usage/constraints, status-check differences for scheduled sends, and cancellation via user_mailbox.drafts.cancel_scheduled_send.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested reviewers

  • chanthuang

Poem

🐰 I hop on the keys with a timestamp in paw,
Five minutes of patience — I wait without flaw,
A scheduled little letter tucked safe in a crate,
Later it flies when the clock strikes its date,
✨📬

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: reapplying a mail scheduled send feature that was previously reverted.
Description check ✅ Passed The PR description covers all required sections: Summary clearly states the feature being reapplied, Changes implicitly described through the summary, and Test plan section is complete with checkmarks.

✏️ 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 revert-03ba542a

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.

@infeng infeng requested a review from chanthuang April 17, 2026 06:19
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 17, 2026

Codecov Report

❌ Patch coverage is 70.58824% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.09%. Comparing base (0d50616) to head (a9c1c3e).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
shortcuts/mail/draft/service.go 0.00% 5 Missing ⚠️
shortcuts/mail/mail_send.go 50.00% 2 Missing ⚠️
shortcuts/mail/mail_forward.go 75.00% 1 Missing ⚠️
shortcuts/mail/mail_reply.go 75.00% 1 Missing ⚠️
shortcuts/mail/mail_reply_all.go 75.00% 1 Missing ⚠️
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.
📢 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.

🧹 Nitpick comments (1)
shortcuts/mail/helpers.go (1)

1910-1929: validateSendTime looks correct; one small robustness suggestion.

Validation logic (non-empty → require --confirm-send → parse int64 → enforce ≥ now+5min) is sound, and per prior learning strconv.ParseInt already rejects whitespace-padded inputs, so no explicit TrimSpace is 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

📥 Commits

Reviewing files that changed from the base of the PR and between 0d50616 and 4404b05.

📒 Files selected for processing (12)
  • shortcuts/mail/draft/service.go
  • shortcuts/mail/helpers.go
  • shortcuts/mail/mail_forward.go
  • shortcuts/mail/mail_reply.go
  • shortcuts/mail/mail_reply_all.go
  • shortcuts/mail/mail_send.go
  • skill-template/domains/mail.md
  • skills/lark-mail/SKILL.md
  • skills/lark-mail/references/lark-mail-forward.md
  • skills/lark-mail/references/lark-mail-reply-all.md
  • skills/lark-mail/references/lark-mail-reply.md
  • skills/lark-mail/references/lark-mail-send.md

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 17, 2026

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#revert-03ba542a -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.

🧹 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*60 lead 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 in shortcuts/mail/helpers_test.go would 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

📥 Commits

Reviewing files that changed from the base of the PR and between 4404b05 and 797ef83.

📒 Files selected for processing (12)
  • shortcuts/mail/draft/service.go
  • shortcuts/mail/helpers.go
  • shortcuts/mail/mail_forward.go
  • shortcuts/mail/mail_reply.go
  • shortcuts/mail/mail_reply_all.go
  • shortcuts/mail/mail_send.go
  • skill-template/domains/mail.md
  • skills/lark-mail/SKILL.md
  • skills/lark-mail/references/lark-mail-forward.md
  • skills/lark-mail/references/lark-mail-reply-all.md
  • skills/lark-mail/references/lark-mail-reply.md
  • skills/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

@infeng infeng merged commit be79485 into main Apr 17, 2026
23 checks passed
@infeng infeng deleted the revert-03ba542a branch April 17, 2026 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/mail PR touches the mail 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.

2 participants