Skip to content

feat(mail): apply default send signatures#1312

Open
oOvalm wants to merge 5 commits into
larksuite:mainfrom
oOvalm:feat/70d8de8
Open

feat(mail): apply default send signatures#1312
oOvalm wants to merge 5 commits into
larksuite:mainfrom
oOvalm:feat/70d8de8

Conversation

@oOvalm

@oOvalm oOvalm commented Jun 7, 2026

Copy link
Copy Markdown

Generated by the harness-coding skill.

  • Branch: feat/70d8de8
  • Target: main

Sprints

ID Title Status Commit
S1 Implement mail +send default signature behavior passed 1864b55
S2 Synthesize transport contract for larksuite/cli passed 7c50b3d

Source specs


This MR was created autonomously. Quality gates were enforced by the repo's own pre-commit hooks.

Summary by CodeRabbit

  • New Features

    • Added --no-signature to skip appending the sender’s signature and --signature-id to choose an explicit signature; signatures remain appended by default. Plain-text sends append a plain-text signature without upgrading to HTML.
  • Documentation

    • Updated mail send docs with signature behavior, examples, mutual-exclusion rules, and plain-text handling.
  • Tests

    • Added and updated unit and end-to-end tests and dry-run coverage for signature selection, rendering, validation, and workflow scenarios.

@CLAassistant

CLAassistant commented Jun 7, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b0e55032-e1d2-44f7-ad7b-c2a78686e5e0

📥 Commits

Reviewing files that changed from the base of the PR and between 02ffe03 and 112344d.

📒 Files selected for processing (1)
  • shortcuts/mail/mail_send_signature.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • shortcuts/mail/mail_send_signature.go

📝 Walkthrough

Walkthrough

Adds explicit signature control to mail +send via --signature-id and --no-signature; implements resolution (explicit/default/alias/skip), HTML-to-plaintext signature rendering and appending, dry-run conditional behavior, tests (unit, integration, dry-run), and docs updates.

Changes

Mail +send Signature Support

Layer / File(s) Summary
Signature flags and validation
shortcuts/mail/mail_send_signature.go, shortcuts/mail/mail_send.go
New --signature-id and --no-signature flags; MailSend flags updated and validation enforces mutual exclusivity.
Dry-run conditional signature fetches
shortcuts/mail/mail_send.go, tests/cli_e2e/mail/*
Dry-run planning reads no-signature and conditionally skips signature/send-as GET requests; includes dry-run e2e tests and validation test helper.
Signature resolution and integration
shortcuts/mail/mail_send_signature.go, shortcuts/mail/mail_send.go
Resolve signature by explicit ID, default selection by sender (with alias fallback), or nil when skipped; integrated into MailSend execution path and exercised by end-to-end tests.
Plaintext append and compose integration
shortcuts/mail/mail_send_signature.go, shortcuts/mail/mail_send.go
For text/plain sends, render and append plaintext signature; HTML path injects rich signature when resolved.
HTML-to-plaintext signature renderer
shortcuts/mail/mail_send_signature.go
Parses signature HTML/XHTML, traverses DOM, inserts block/<br> breaks, replaces images with localized placeholders, detects nested fragments, normalizes and compacts lines.
Signature unit and integration tests
shortcuts/mail/mail_send_signature_test.go
Unit tests for default-ID selection and plaintext rendering; many end-to-end tests for alias/default behavior, explicit override, --no-signature skipping, plaintext append, lookup/missing-target hints, send-as degradation, and non-send compose validation; includes test scaffolding and HTTP stubs.
CLI dry-run e2e tests
tests/cli_e2e/mail/mail_send_dryrun_test.go
Dry-run scenarios for default/explicit/skip flows and validation test for conflicting flags; includes CLI env helper.
Existing test updates
shortcuts/mail/*_test.go, tests/cli_e2e/mail/mail_send_workflow_test.go
Multiple existing +send test invocations updated to pass --no-signature.
Signature behavior documentation
skills/lark-mail/references/lark-mail-send.md
Docs updated to explain default append behavior, --signature-id and --no-signature semantics, plaintext rules, and failure hints.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • larksuite/cli#642: Overlaps MailSend compose/input handling and dry-run planning changes.

Suggested labels

feature

Suggested reviewers

  • chanthuang
  • infeng

"🐰 A signature suite takes flight,
HTML to plaintext, rendered just right.
Flags choose to add or skip the line,
Send with style—or leave it fine. ✨"

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is largely incomplete. It lacks a meaningful Summary section, a detailed Changes list, a documented Test Plan, and Related Issues section as specified in the template. Add a Summary explaining the motivation for default signatures, itemize the main changes (flag additions, signature selection logic, plain-text rendering, tests), document the test coverage approach, and clarify any related issues or links.
Docstring Coverage ⚠️ Warning Docstring coverage is 9.62% 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 "feat(mail): apply default send signatures" directly and clearly summarizes the main feature added: implementing default signature behavior for the mail +send command across the codebase.
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/L Large or sensitive change across domains or core paths labels Jun 7, 2026

@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: 2

🤖 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.go`:
- Around line 189-201: The current appendMailSendSignatureText function always
inserts a separator between the existing buffer and the next text node because
it uses strings.Fields (which discards source leading/trailing whitespace) and
then unconditionally inserts a space when buf isn't empty; instead, preserve
source whitespace semantics: get s := stdhtml.UnescapeString(raw), return if
strings.TrimSpace(s)==""; collapse internal runs of whitespace to a single space
(but do not drop leading/trailing whitespace), then determine whether to write
an extra separator by checking the buffer's last byte for unicode.IsSpace and
the unescaped s's first rune for unicode.IsSpace — only write a space if buf is
non-empty AND neither the buffer ends with whitespace nor s begins with
whitespace — finally write the collapsed-but-trimmed-for-internal-whitespace
text to buf; update appendMailSendSignatureText to use these checks (refer to
appendMailSendSignatureText, stdhtml.UnescapeString, and buf.Bytes()) to fix
inline-markup accidental spacing.

In `@shortcuts/mail/mail_send.go`:
- Around line 209-212: The call to resolveMailSendComposeSignature is passing an
empty senderEmail when --from is omitted, causing
selectMailSendDefaultSignatureID to misapply defaults for mailboxes with
aliases; fix by resolving the actual sender address from the mailbox/profile
before calling resolveMailSendComposeSignature (or update
resolveMailSendComposeSignature to perform that lookup internally) so that
senderEmail is never empty — locate the call site using
resolveMailSendComposeSignature(ctx, runtime, mailboxID, senderEmail,
mailSendSignatureOptions{...}) and ensure you populate senderEmail from the
mailbox/profile primary address (or invoke a helper that does this) prior to
selecting the default via selectMailSendDefaultSignatureID.
🪄 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: ad2c5d69-1138-4475-960a-9994a1e27d2e

📥 Commits

Reviewing files that changed from the base of the PR and between 7c50b3d and 1864b55.

📒 Files selected for processing (10)
  • 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.go
  • shortcuts/mail/mail_send_signature_test.go
  • shortcuts/mail/mail_template_shortcut_test.go
  • skills/lark-mail/references/lark-mail-send.md
  • tests/cli_e2e/mail/mail_send_dryrun_test.go
  • tests/cli_e2e/mail/mail_send_workflow_test.go

Comment thread shortcuts/mail/mail_send_signature.go
Comment thread shortcuts/mail/mail_send.go
@oOvalm

oOvalm commented Jun 7, 2026

Copy link
Copy Markdown
Author

recheck

@oOvalm

oOvalm commented Jun 7, 2026

Copy link
Copy Markdown
Author

/recheck

1 similar comment
@oOvalm

oOvalm commented Jun 7, 2026

Copy link
Copy Markdown
Author

/recheck

@oOvalm

oOvalm commented Jun 7, 2026

Copy link
Copy Markdown
Author

recheck

2 similar comments
@oOvalm

oOvalm commented Jun 7, 2026

Copy link
Copy Markdown
Author

recheck

@oOvalm

oOvalm commented Jun 7, 2026

Copy link
Copy Markdown
Author

recheck

oOvalm and others added 2 commits June 8, 2026 00:02
Decode escaped HTML fragments inside rendered mail signatures before converting them to text so text/plain sends keep visible text and localized image placeholders instead of tag literals.

sprint: S1

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Avoid treating ordinary text that starts with a tag-name prefix as escaped signature HTML while preserving the second-pass parsing needed for real HTML fragments.

sprint: S1

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@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

🤖 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.go`:
- Around line 189-198: The code double-unescapes entities by calling
stdhtml.UnescapeString in appendMailSendSignatureTextNode and then again inside
appendMailSendSignatureText; change appendMailSendSignatureTextNode to only use
the unescaped string for the mailSendSignatureLooksLikeHTMLFragment check but
pass the original raw string to appendMailSendSignatureText (both in the
non-HTML branch and the error branch) so appendMailSendSignatureText is solely
responsible for unescaping; refer to appendMailSendSignatureTextNode,
mailSendSignatureLooksLikeHTMLFragment, and appendMailSendSignatureText when
making the change.
🪄 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: 01d41ad4-35fc-42ff-bc5e-e561f45e6b56

📥 Commits

Reviewing files that changed from the base of the PR and between 1864b55 and 19d6a38.

📒 Files selected for processing (2)
  • shortcuts/mail/mail_send_signature.go
  • shortcuts/mail/mail_send_signature_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • shortcuts/mail/mail_send_signature_test.go

Comment thread shortcuts/mail/mail_send_signature.go
When the owning mailbox signature usage list omits a send_as alias, probe the alias mailbox before concluding there is no default signature. The selector still requires EmailAddress to match the final sender, and explicit/no-signature behavior is unchanged.

sprint: S1
@oOvalm

oOvalm commented Jun 8, 2026

Copy link
Copy Markdown
Author

recheck

@oOvalm

oOvalm commented Jun 8, 2026

Copy link
Copy Markdown
Author

/recheck

1 similar comment
@oOvalm

oOvalm commented Jun 8, 2026

Copy link
Copy Markdown
Author

/recheck

appendMailSendSignatureTextNode and appendMailSendSignatureText both
called stdhtml.UnescapeString on text that xhtml.Parse had already
unescaped, corrupting double-encoded entities (e.g. &amp;amp;).

Change-Type: ci-fix
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/L Large or sensitive change across domains or core paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants