Skip to content

feat: add default signatures to mail send#1303

Open
bubbmon233 wants to merge 2 commits into
larksuite:mainfrom
bubbmon233:feat/ea59764
Open

feat: add default signatures to mail send#1303
bubbmon233 wants to merge 2 commits into
larksuite:mainfrom
bubbmon233:feat/ea59764

Conversation

@bubbmon233

@bubbmon233 bubbmon233 commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator

Generated by the harness-coding skill (recovery run - original attempt crashed before PR open).

  • Branch: feat/ea59764
  • Target: main

The commits below were produced by a prior coding run on this branch. The current resume run regenerated the sprint plan from tech-specs and confirmed those commits already implement the work. Any sprint with status passed in the table below represents work this resume run added on top.

Commits on branch (ahead of main)

Commit Subject
f58852a feat: add default signatures to mail send

This resume run

ID Title Status Commit
S3 Apply review comment feedback passed -
S1 Add default signature handling to lark-cli mail +send passed f58852a
S2 Synthesize transport contract for larksuite/cli passed 8c3cba1

Source specs


This PR was created autonomously. Quality gates were enforced by the repository pre-commit hooks.

Summary by CodeRabbit

  • New Features

    • Added --no-signature CLI flag to skip default signature; improved signature handling for both HTML and plain-text sends; explicit signature selection honored.
  • Documentation

    • Updated reference docs and examples to describe --no-signature and signature-related options.
  • Tests

    • Added comprehensive tests covering signature lookup, flag validation, plain-text injection, HTML rendering, and localized image placeholders.

Append the sender's default send signature in +send while keeping --signature-id as an explicit override and adding --no-signature for opt-out. Plain-text bodies now receive a rendered text signature without upgrading to HTML.

sprint: S1
@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5aabf2ce-e854-462a-8b18-39109f76d367

📥 Commits

Reviewing files that changed from the base of the PR and between f58852a and 08c31c5.

📒 Files selected for processing (1)
  • shortcuts/mail/mail_send_signature_test.go

📝 Walkthrough

Walkthrough

Adds a --no-signature option to MailSend, exports HTML→plain-text conversion, refactors signature resolution to support HTML and plain-text signatures (including default selection and image placeholders), injects plain-text signatures into composed bodies, and adds tests and docs.

Changes

Mail Send Signature Feature

Layer / File(s) Summary
Plain-text conversion utility export
shortcuts/mail/draft/htmltext.go
Exposes PlainTextFromHTML function for compose helpers to convert HTML signatures to plain-text representation.
Signature composition helpers and plain-text support
shortcuts/mail/signature_compose.go, shortcuts/mail/signature_compose_test.go
Adds --no-signature flag, refactors signature resolution into resolveSignatureWithImages and send-oriented resolveSignatureForSend; introduces selectDefaultSendSignatureID for email-based default matching, injectSignatureIntoPlainText for appending signatures with spacing, and renderSignatureText for locale-specific image placeholders. Validates mutual exclusivity of --no-signature and --signature-id.
MailSend flag wiring and execution flow
shortcuts/mail/mail_send.go
Integrates new signature infrastructure: adds noSignatureFlag to CLI flags, gates dry-run signature lookup on !no-signature, updates validation, refactors execution to compute signature HTML mode and inject signatures into plain-text and non-HTML bodies.
MailSend signature behavior tests
shortcuts/mail/mail_send_signature_test.go
Comprehensive test suite covering default signature insertion into HTML, plain-text body handling without wrapper, --no-signature suppression, explicit --signature-id override, and dry-run signature lookup control.
Existing test invocations updated with --no-signature
shortcuts/mail/mail_lint_writepath_test.go, shortcuts/mail/mail_request_receipt_integration_test.go, shortcuts/mail/mail_send_confirm_output_test.go, shortcuts/mail/mail_template_shortcut_test.go
Updates lint, request-receipt, confirm-output, and template tests to pass --no-signature flag for compatibility.
Documentation updates for --no-signature support
skills/lark-mail/references/lark-mail-send.md
Adds feature list entry, command example, and parameters table entry documenting the new --no-signature flag and its mutual exclusivity with --signature-id.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • larksuite/cli#318: Overlaps at MailSend sender-resolution and related execution flow changes.

Suggested labels

enhancement

Suggested reviewers

  • chanthuang
  • infeng

Poem

🐰 I stitched a signature, neat and spry,
Now you can send it — or let it lie.
HTML glows, plain text gets a line,
Or use --no-signature and skip it fine.
Hop, click, send — the rabbit signs goodbye.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete compared to the template. It lacks a proper Summary section explaining motivation/scope, a Changes section listing the main modifications, a Test Plan section with verification checkboxes, and Related Issues section. Provide a Summary explaining the motivation for default signatures, list the main changes (exported function, flag additions, validation logic), detail how signatures are tested, and specify related issues or mark as None.
Docstring Coverage ⚠️ Warning Docstring coverage is 31.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main feature addition: default signatures are now appended during mail send operations, which is the core change across all modified files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@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 Jun 6, 2026
@codecov

codecov Bot commented Jun 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.93023% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.09%. Comparing base (8c3cba1) to head (08c31c5).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
shortcuts/mail/signature_compose.go 74.64% 14 Missing and 4 partials ⚠️
shortcuts/mail/mail_send.go 61.53% 2 Missing and 3 partials ⚠️
shortcuts/mail/draft/htmltext.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1303      +/-   ##
==========================================
+ Coverage   70.97%   71.09%   +0.11%     
==========================================
  Files         680      681       +1     
  Lines       65318    65498     +180     
==========================================
+ Hits        46362    46567     +205     
+ Misses      15316    15273      -43     
- Partials     3640     3658      +18     

☔ View full report in Codecov by Harness.
📢 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.

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add bubbmon233/cli#feat/ea59764 -y -g

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

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

114-136: 💤 Low value

Optional: Redundant case normalization.

Line 118 uses strings.ToLower on senderEmail, but line 126 uses strings.EqualFold which already performs case-insensitive comparison. The ToLower call is redundant.

♻️ Proposed simplification
-	sender := strings.ToLower(strings.TrimSpace(senderEmail))
+	sender := strings.TrimSpace(senderEmail)
🤖 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/mail/signature_compose.go` around lines 114 - 136, In
selectDefaultSendSignatureID, the sender variable is unnecessarily normalized
with strings.ToLower before using strings.EqualFold; change sender :=
strings.ToLower(strings.TrimSpace(senderEmail)) to just sender :=
strings.TrimSpace(senderEmail) (or otherwise ensure you use the same
normalization on both sides) so the case normalization is not duplicated, keep
the existing strings.EqualFold(strings.TrimSpace(usage.EmailAddress), sender)
comparison and leave the remaining logic unchanged.
🤖 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/mail/mail_send_signature_test.go`:
- Around line 216-244: The test
TestMailSendDryRunShowsSignatureLookupUnlessDisabled reuses the same stdout
buffer between two runMountedMailShortcut calls causing the first run's
"/settings/signatures" output to leak into the second assertion; fix by
resetting or replacing the captured output before the second dry-run (e.g., call
stdout.Reset() or recreate f and stdout via
mailShortcutTestFactoryWithSendScope) so the second invocation of
runMountedMailShortcut and its assertion accurately reflect only that run's
output.

---

Nitpick comments:
In `@shortcuts/mail/signature_compose.go`:
- Around line 114-136: In selectDefaultSendSignatureID, the sender variable is
unnecessarily normalized with strings.ToLower before using strings.EqualFold;
change sender := strings.ToLower(strings.TrimSpace(senderEmail)) to just sender
:= strings.TrimSpace(senderEmail) (or otherwise ensure you use the same
normalization on both sides) so the case normalization is not duplicated, keep
the existing strings.EqualFold(strings.TrimSpace(usage.EmailAddress), sender)
comparison and leave the remaining logic unchanged.
🪄 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: 8146579b-e3f5-4a4b-9ee0-40231da5a339

📥 Commits

Reviewing files that changed from the base of the PR and between bd07859 and f58852a.

📒 Files selected for processing (10)
  • shortcuts/mail/draft/htmltext.go
  • shortcuts/mail/mail_lint_writepath_test.go
  • shortcuts/mail/mail_request_receipt_integration_test.go
  • shortcuts/mail/mail_send.go
  • shortcuts/mail/mail_send_confirm_output_test.go
  • shortcuts/mail/mail_send_signature_test.go
  • shortcuts/mail/mail_template_shortcut_test.go
  • shortcuts/mail/signature_compose.go
  • shortcuts/mail/signature_compose_test.go
  • skills/lark-mail/references/lark-mail-send.md

Comment thread shortcuts/mail/mail_send_signature_test.go
if strings.TrimSpace(runtime.Str("signature-id")) != "" {
desc = "Resolve explicit signature by ID."
}
api = api.GET(mailboxPath(mailboxID, "settings", "signatures")).Desc(desc)

@qiooo qiooo Jun 6, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Review | [P2 正确性] DryRun 少展示签名插值会调用的 send_as 请求

mail +send --dry-run 在非 --no-signature 分支只展示了 /settings/signatures,但真实执行在选中显式签名或默认签名后还会进入 resolveSenderInfo,调用 GET /settings/send_as 来解析签名模板中的 sender 变量。AI/脚本用 dry-run 预判权限、接口计划或准备 mock 时,会少配这个接口,导致 dry-run 与实际执行不一致。

修复建议: 在这个签名分支中补充 GET /settings/send_as,描述为用于签名模板 sender 变量插值;至少对 --signature-id 场景无条件展示,对默认签名场景说明命中默认签名后会调用。

如有疑问或认为判断不准确,欢迎直接回复讨论。

@qiooo

qiooo commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

🤖 AI Review | CR 汇总 | 有风险(1 个 P2)

增量审查:已读取既有 CodeRabbit 评论,测试缓冲区问题已由后续提交修复,未重复提出。本次新增 1 条 P2 正确性问题:+send --dry-run 未展示实际执行中用于签名 sender 变量解析的 GET /settings/send_as 请求。

验证:go test -count=1 -timeout 5m ./shortcuts/mail/... 通过;新增签名相关定向测试通过。

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