feat(mail): append default signature when sending#1313
Conversation
Automatically compose the user default mail signature into sent messages and add an opt-out flag for callers that need to skip it.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughAdds a ChangesSignature Control and Composition
sequenceDiagram
participant User
participant CLI as MailSend
participant SigAPI as SignatureAPI
participant DraftAPI
User->>CLI: +send with flags
CLI->>CLI: validateSignatureFlags
alt --no-signature not set
CLI->>SigAPI: GET /settings/signatures
SigAPI-->>CLI: signatures + usages
end
CLI->>CLI: resolveComposeSignature
alt plain-text
CLI->>CLI: appendPlainTextSignature
end
CLI->>DraftAPI: POST draft with raw EML
DraftAPI-->>User: draft created
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 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 |
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@ff0ede7eb4ac65bda4e7d29f518017faac36c3eb🧩 Skill updatenpx skills add bubbmon233/cli#feat/e7ce758 -y -g |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1313 +/- ##
==========================================
+ Coverage 71.14% 71.18% +0.03%
==========================================
Files 685 685
Lines 65770 65847 +77
==========================================
+ Hits 46793 46872 +79
+ Misses 15326 15315 -11
- Partials 3651 3660 +9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/cli_e2e/mail/mail_send_dryrun_test.go (1)
102-106: ⚡ Quick winAvoid hard-coding the signature API index in dry-run assertions.
Line 104/Line 105 assumes the signature call is always at
api.1. That makes the test fragile if dry-run planning inserts or reorders steps. Match by URL first, then assert method on the matched entry.♻️ Suggested refactor
import ( "context" + "strconv" "testing" "time" @@ - if tt.wantSignaturesGET { - idx := tt.wantSignatureIndex - assert.Equal(t, "GET", gjson.Get(result.Stdout, "api."+string(rune('0'+idx))+".method").String(), "stdout:\n%s", result.Stdout) - assert.Equal(t, "/open-apis/mail/v1/user_mailboxes/me/settings/signatures", gjson.Get(result.Stdout, "api."+string(rune('0'+idx))+".url").String(), "stdout:\n%s", result.Stdout) - } + if tt.wantSignaturesGET { + idx := -1 + apis := gjson.Get(result.Stdout, "api").Array() + for i, api := range apis { + if gjson.Get(api.Raw, "url").String() == "/open-apis/mail/v1/user_mailboxes/me/settings/signatures" { + idx = i + break + } + } + require.GreaterOrEqual(t, idx, 0, "stdout:\n%s", result.Stdout) + path := "api." + strconv.Itoa(idx) + assert.Equal(t, "GET", gjson.Get(result.Stdout, path+".method").String(), "stdout:\n%s", result.Stdout) + }🤖 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 `@tests/cli_e2e/mail/mail_send_dryrun_test.go` around lines 102 - 106, The test currently assumes the signature API call appears at a fixed index using tt.wantSignatureIndex and gjson.Get(... "api."+string(rune('0'+idx))...), which is fragile; update the assertion to locate the API entry by matching its URL first (search the "api" array in result.Stdout for an element whose "url" equals "/open-apis/mail/v1/user_mailboxes/me/settings/signatures" using gjson or by unmarshalling into a struct/slice), then assert that the matched entry's "method" equals "GET" and that tt.wantSignaturesGET controls this check; keep references to tt.wantSignaturesGET, tt.wantSignatureIndex (if still used for logging), result.Stdout and gjson.Get to help locate where to change the code.
🤖 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-mail/references/lark-mail-send.md`:
- Around line 85-86: Update the documentation row for the `--signature-id` flag
to reflect runtime validation: state that `--signature-id` requires HTML mode
and cannot be used together with `--plain-text` (i.e., `--plain-text` +
`--signature-id` is mutually exclusive), and clarify that the default signature
conversion into plain-text still occurs when `--signature-id` is not provided;
also keep the mutually-exclusive note with `--no-signature`.
---
Nitpick comments:
In `@tests/cli_e2e/mail/mail_send_dryrun_test.go`:
- Around line 102-106: The test currently assumes the signature API call appears
at a fixed index using tt.wantSignatureIndex and gjson.Get(...
"api."+string(rune('0'+idx))...), which is fragile; update the assertion to
locate the API entry by matching its URL first (search the "api" array in
result.Stdout for an element whose "url" equals
"/open-apis/mail/v1/user_mailboxes/me/settings/signatures" using gjson or by
unmarshalling into a struct/slice), then assert that the matched entry's
"method" equals "GET" and that tt.wantSignaturesGET controls this check; keep
references to tt.wantSignaturesGET, tt.wantSignatureIndex (if still used for
logging), result.Stdout and gjson.Get to help locate where to change the code.
🪄 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: 04b5d208-dc11-41af-b3f1-8655c6b69162
📒 Files selected for processing (10)
shortcuts/mail/mail_lint_writepath_test.goshortcuts/mail/mail_request_receipt_integration_test.goshortcuts/mail/mail_send.goshortcuts/mail/mail_send_confirm_output_test.goshortcuts/mail/mail_send_signature_test.goshortcuts/mail/mail_template_shortcut_test.goshortcuts/mail/signature_compose.goskills/lark-mail/SKILL.mdskills/lark-mail/references/lark-mail-send.mdtests/cli_e2e/mail/mail_send_dryrun_test.go
Change-Type: ci-fix
Generated by the harness-coding skill.
Sprints
This MR was created autonomously. Quality gates were enforced by the repo's own pre-commit hooks.
Summary by CodeRabbit
New Features
--no-signatureto skip default signatures--signature-idselection and richer HTML→plain-text signature renderingValidation
--no-signatureand--signature-idTests
Documentation