Skip to content

feat: append default signature for mail send#1320

Open
oOvalm wants to merge 2 commits into
larksuite:mainfrom
oOvalm:feat/d9f2d23
Open

feat: append default signature for mail send#1320
oOvalm wants to merge 2 commits into
larksuite:mainfrom
oOvalm:feat/d9f2d23

Conversation

@oOvalm

@oOvalm oOvalm commented Jun 8, 2026

Copy link
Copy Markdown

Generated by the harness-coding skill.

  • Branch: feat/d9f2d23
  • Target: main

Sprints

ID Title Status Commit
S1 Implement default signature handling for mail +send passed 36401ba
S2 Synthesize transport contract for larksuite/cli passed 9d84544

Source specs

  • input/tech-design.md#CLI-larksuite-cli

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

Summary by CodeRabbit

  • New Features

    • Added a --no-signature option to skip default signatures.
    • Default signature selection now matches the actual sender; explicit signature IDs take precedence.
    • Plain-text mode appends signature text (without downloading signature images).
  • Tests

    • Expanded unit and integration tests covering signature selection, plain-text conversion, image handling, validation conflicts, and dry-run behavior.
  • Documentation

    • Updated mail composition docs and examples to document signature rules and --no-signature usage.

Resolve mail +send signatures from the actual sender address by default while keeping --signature-id explicit and adding --no-signature as the local opt-out. Plain-text send now appends a visible text rendering of the selected signature without downloading signature images.

sprint: S1
@coderabbitai

coderabbitai Bot commented Jun 8, 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: cda7cf7b-fb04-4536-8761-2cb8637a61bf

📥 Commits

Reviewing files that changed from the base of the PR and between 36401ba and 7d93b64.

📒 Files selected for processing (4)
  • shortcuts/mail/mail_send.go
  • shortcuts/mail/mail_send_signature_test.go
  • shortcuts/mail/signature_compose.go
  • shortcuts/mail/signature_compose_test.go
🚧 Files skipped from review as they are similar to previous changes (4)
  • shortcuts/mail/signature_compose_test.go
  • shortcuts/mail/mail_send_signature_test.go
  • shortcuts/mail/signature_compose.go
  • shortcuts/mail/mail_send.go

📝 Walkthrough

Walkthrough

Adds a --no-signature flag and two-phase signature handling to MailSend: select/interpolate a signature (or skip), optionally download inline signature images, convert signature HTML to plain text when needed, update MailSend flow and DryRun, add tests, and update docs.

Changes

Mail Signature Feature

Layer / File(s) Summary
Signature Provider and Default Selection
shortcuts/mail/signature/provider.go, shortcuts/mail/signature/provider_test.go
FindSendDefault locates the default send-mail signature by matching usages to signatures with case-insensitive email handling and nil-safe fallback.
Plain-Text Signature Conversion
shortcuts/mail/signature/plaintext.go, shortcuts/mail/signature/plaintext_test.go
PlainTextFromHTML parses HTML signatures, traverses the DOM iteratively, collapses whitespace, skips non-text elements, inserts block-boundary newlines, and falls back on parse failure.
Signature Composition Helpers
shortcuts/mail/signature_compose.go, shortcuts/mail/signature_compose_test.go
Adds resolveComposeSignature (selection & interpolation), resolveSignatureImages (download inline images), appendPlainTextSignature, and validateSignatureFlags (mutual-exclusivity and empty-ID validation).
MailSend Command Integration
shortcuts/mail/mail_send.go
Adds --no-signature, updates --plain-text help text, extends DryRun to resolve sender and conditionally fetch signatures, replaces signature validation with validateSignatureFlags, and reworks HTML vs plain-text body composition and signature wiring.
Signature Feature Integration Tests
shortcuts/mail/mail_send_signature_test.go
Adds extensive tests covering default insertion, --no-signature suppression, explicit --signature-id, alias-based default selection, no-default drafting, plain-text behavior without image downloads, API/image failures, validation tests, and dry-run plan checks.
Existing Test Updates
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 several MailSend test invocations to include --no-signature.
User Documentation
skill-template/domains/mail.md, skills/lark-mail/SKILL.md, skills/lark-mail/references/lark-mail-send.md
Documents default signature appending, --no-signature usage, --plain-text signature conversion without image downloads, alias matching, and flag mutual-exclusivity with examples.

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Possibly related PRs

    • larksuite/cli#595: Updates read-receipt integration tests and related MailSend invocation changes that overlap with --no-signature handling.
  • Suggested reviewers

    • chanthuang
    • infeng
    • haidaodashushu

"I hopped through HTML leaves to find the text,
I nudged images gently back to their nests,
A flag now whispers 'no signature, please',
Drafts sit tidy, their markup at rest,
— from a rabbit who mails with zest." 🐇✉️

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is incomplete relative to the template. It lacks a Summary section explaining motivation, a Changes section listing main modifications, and a Test Plan section with verification steps. Add a Summary (1-3 sentences on motivation), Changes section (listing key additions like --no-signature flag, signature resolution logic, tests), and Test Plan with completed checkboxes.
Docstring Coverage ⚠️ Warning Docstring coverage is 22.73% 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: append default signature for mail send' clearly and concisely summarizes the main feature addition, matching the extensive signature-handling changes 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/M Single-domain feat or fix with limited business impact labels Jun 8, 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.

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

338-347: ⚡ Quick win

Remove unused validation function.

validateSignatureWithPlainText is no longer called after mail_send.go line 107 switched to validateSignatureFlags. The new code allows --plain-text + --signature-id by converting signatures to plain text (as documented in the updated --plain-text flag description), making this old mutual-exclusivity check obsolete.

🧹 Proposed removal
-// validateSignatureWithPlainText returns an error if both --plain-text and --signature-id are set.
-func validateSignatureWithPlainText(plainText bool, signatureID string) error {
-	if plainText && signatureID != "" {
-		return mailValidationError("--plain-text and --signature-id are mutually exclusive: signatures require HTML mode").
-			WithParams(
-				mailInvalidParam("--plain-text", "mutually exclusive with --signature-id"),
-				mailInvalidParam("--signature-id", "requires HTML mode"),
-			)
-	}
-	return nil
-}
🤖 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 338 - 347, The function
validateSignatureWithPlainText is now obsolete and unused after mail_send.go
switched to validateSignatureFlags (which permits --plain-text with
--signature-id by converting signatures to plain text); remove the entire
validateSignatureWithPlainText function declaration from
shortcuts/mail/signature_compose.go and any related dead references so the
codebase does not contain this unused mutual-exclusion validator (search for
validateSignatureWithPlainText to ensure no callers remain).
🤖 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.

Nitpick comments:
In `@shortcuts/mail/signature_compose.go`:
- Around line 338-347: The function validateSignatureWithPlainText is now
obsolete and unused after mail_send.go switched to validateSignatureFlags (which
permits --plain-text with --signature-id by converting signatures to plain
text); remove the entire validateSignatureWithPlainText function declaration
from shortcuts/mail/signature_compose.go and any related dead references so the
codebase does not contain this unused mutual-exclusion validator (search for
validateSignatureWithPlainText to ensure no callers remain).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 31d660b3-0341-44d5-aea1-96e59cc0905a

📥 Commits

Reviewing files that changed from the base of the PR and between 9d84544 and 36401ba.

📒 Files selected for processing (15)
  • 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/plaintext.go
  • shortcuts/mail/signature/plaintext_test.go
  • shortcuts/mail/signature/provider.go
  • shortcuts/mail/signature/provider_test.go
  • shortcuts/mail/signature_compose.go
  • shortcuts/mail/signature_compose_test.go
  • skill-template/domains/mail.md
  • skills/lark-mail/SKILL.md
  • skills/lark-mail/references/lark-mail-send.md

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.

1 participant