Skip to content

feat: auto-append default signatures in mail send#1310

Open
bubbmon233 wants to merge 1 commit into
larksuite:mainfrom
bubbmon233:feat/d6fb95d
Open

feat: auto-append default signatures in mail send#1310
bubbmon233 wants to merge 1 commit into
larksuite:mainfrom
bubbmon233:feat/d6fb95d

Conversation

@bubbmon233
Copy link
Copy Markdown
Collaborator

@bubbmon233 bubbmon233 commented Jun 7, 2026

Generated by the harness-coding skill.

  • Branch: feat/d6fb95d
  • Target: main

Sprints

ID Title Status Commit
S1 Update mail +send to append default signatures passed 06827a7
S2 Synthesize transport contract for larksuite/cli passed 7c50b3d

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

Summary by CodeRabbit

Release Notes

  • New Features

    • Added --no-signature flag to disable automatic signature insertion when sending mail
    • Improved automatic signature selection to match sender aliases with optimized lookups
    • Enhanced plain-text mode to properly render and append signatures to email bodies
  • Tests

    • Added integration tests validating signature behavior and dry-run scenarios

Align mail +send with mailbox defaults so compose flows pick the sender
configured send signature unless callers explicitly opt out. Preserve the
plain-text path by rendering signatures as text instead of upgrading MIME.

sprint: S1
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 7, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds a --no-signature flag to the mail send shortcut, enabling users to skip signature lookup and insertion. The change implements a clear resolution policy (flag > explicit ID > auto default by sender email > none), validates mutual exclusivity between --no-signature and --signature-id, and adds HTML-to-plain-text rendering for plain-text email bodies.

Changes

Mail send signature feature

Layer / File(s) Summary
Signature compose core and validation
shortcuts/mail/signature_compose.go, shortcuts/mail/signature_compose_test.go
Adds --no-signature flag, implements resolveComposeSignature with ordered policy, resolveDefaultSendSignature that matches sender email to signature usage entries, validateSignatureFlags to reject conflicting flags, and HTML parsing utilities to render signatures as plain text (renderPlainTextSignature, appendPlainTextSignature).
MailSend shortcut integration
shortcuts/mail/mail_send.go, shortcuts/mail/mail_shortcut_validation_test.go
Integrates signature compose logic: adds noSignatureFlag to MailSend.Flags, conditionally fetches signature and send-as settings in DryRun when --no-signature is not set, uses validateSignatureFlags for validation, calls resolveComposeSignature in Execute, and appends plain-text signature to plain-text bodies.
Integration tests for signature behavior
shortcuts/mail/mail_request_receipt_integration_test.go
Refactors draft capture helpers to be mailbox-parameterized and adds three new tests: plain-text signature stays text (no HTML), auto default signature matches sender alias with cached lookups, and --no-signature skips signature lookups entirely.
E2E dry-run signature tests
tests/cli_e2e/mail/mail_send_workflow_test.go
Adds CLI-level tests verifying that dry-run with auto signature includes four endpoints (profile, signatures, send-as, drafts) and that --no-signature reduces the plan to two endpoints (profile, drafts).
Existing test updates
shortcuts/mail/mail_lint_writepath_test.go, shortcuts/mail/mail_send_confirm_output_test.go, shortcuts/mail/mail_template_shortcut_test.go
Updates six existing tests to include --no-signature flag in MailSend invocations for consistent coverage.
User-facing documentation
skills/lark-mail/references/lark-mail-send.md
Documents default signature auto-append behavior, --no-signature usage and examples, flag mutual exclusivity, and default signature selection rules for sender aliases.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

domain/mail, size/M

Suggested reviewers

  • chanthuang
  • infeng

Poem

A signature befits each mail we send,
With --no-signature we transcend,
Auto defaults match the sender's name,
Plain-text rendering keeps its claim,
Flags work in harmony, no conflict's way!
🐰✉️

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is largely incomplete against the template. It lacks explicit Summary, Changes, and Test Plan sections with required details. Restructure the description to include: Summary (1-3 sentences explaining motivation), Changes (bulleted list of main changes), and Test Plan (checklist with unit tests and manual verification steps).
Docstring Coverage ⚠️ Warning Docstring coverage is 27.27% 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 accurately summarizes the main change: auto-appending default signatures in mail send, which aligns with the primary objective across multiple 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 7, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 7, 2026

Codecov Report

❌ Patch coverage is 79.59184% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.06%. Comparing base (7c50b3d) to head (06827a7).

Files with missing lines Patch % Lines
shortcuts/mail/signature_compose.go 82.35% 15 Missing and 9 partials ⚠️
shortcuts/mail/mail_send.go 45.45% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1310      +/-   ##
==========================================
+ Coverage   71.01%   71.06%   +0.04%     
==========================================
  Files         681      681              
  Lines       65435    65575     +140     
==========================================
+ Hits        46470    46601     +131     
+ Misses      15320    15317       -3     
- Partials     3645     3657      +12     

☔ 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
Copy link
Copy Markdown

github-actions Bot commented Jun 7, 2026

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add bubbmon233/cli#feat/d6fb95d -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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
shortcuts/mail/mail_send.go (1)

208-241: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Skip signature image downloads on the plain-text path.

Line 208 resolves the full signature before the plainText branch, and resolveSignature eagerly downloads inline images. Lines 239-241 then render the signature as text only, while the plain-text renderer drops <img> nodes and the builder never uses sigResult.Images. That makes plain-text sends depend on external image downloads they never emit, so an expired or broken signature image URL can now fail an otherwise valid plain-text send. Please gate image downloads on HTML mode only, and add a regression for a plain-text send whose signature image fetch fails.

Possible fix
- sigResult, err := resolveComposeSignature(ctx, runtime, mailboxID, senderEmail)
+ sigResult, err := resolveComposeSignature(ctx, runtime, mailboxID, senderEmail, !plainText)
-func resolveComposeSignature(ctx context.Context, runtime *common.RuntimeContext, mailboxID, senderEmail string) (*signatureResult, error) {
+func resolveComposeSignature(ctx context.Context, runtime *common.RuntimeContext, mailboxID, senderEmail string, includeImages bool) (*signatureResult, error) {
 	if runtime.Bool("no-signature") {
 		return nil, nil
 	}
 	if signatureID := runtime.Str("signature-id"); signatureID != "" {
-		return resolveSignature(ctx, runtime, mailboxID, signatureID, senderEmail)
+		return resolveSignature(ctx, runtime, mailboxID, signatureID, senderEmail, includeImages)
 	}
 	defaultID, err := resolveDefaultSendSignature(runtime, mailboxID, senderEmail)
 	if err != nil {
 		return nil, err
 	}
 	if defaultID == "" {
 		return nil, nil
 	}
-	return resolveSignature(ctx, runtime, mailboxID, defaultID, senderEmail)
+	return resolveSignature(ctx, runtime, mailboxID, defaultID, senderEmail, includeImages)
 }
-func resolveSignature(ctx context.Context, runtime *common.RuntimeContext, mailboxID, signatureID, fromEmail string) (*signatureResult, error) {
+func resolveSignature(ctx context.Context, runtime *common.RuntimeContext, mailboxID, signatureID, fromEmail string, includeImages bool) (*signatureResult, error) {
 	...
-	var images []draftpkg.SignatureImage
-	for _, img := range sig.Images {
-		if img.DownloadURL == "" || img.CID == "" {
-			continue
-		}
-		data, ct, err := downloadSignatureImage(runtime, img.DownloadURL, img.ImageName)
-		if err != nil {
-			return nil, mailDecorateProblemMessage(err, "failed to download signature image %s", img.ImageName)
-		}
-		images = append(images, draftpkg.SignatureImage{
-			CID:         img.CID,
-			ContentType: ct,
-			FileName:    img.ImageName,
-			Data:        data,
-		})
-	}
+	var images []draftpkg.SignatureImage
+	if includeImages {
+		for _, img := range sig.Images {
+			if img.DownloadURL == "" || img.CID == "" {
+				continue
+			}
+			data, ct, err := downloadSignatureImage(runtime, img.DownloadURL, img.ImageName)
+			if err != nil {
+				return nil, mailDecorateProblemMessage(err, "failed to download signature image %s", img.ImageName)
+			}
+			images = append(images, draftpkg.SignatureImage{
+				CID:         img.CID,
+				ContentType: ct,
+				FileName:    img.ImageName,
+				Data:        data,
+			})
+		}
+	}

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fb09c5ef-a778-4d45-b626-82e3c6dcc06c

📥 Commits

Reviewing files that changed from the base of the PR and between 7c50b3d and 06827a7.

📒 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_shortcut_validation_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
  • tests/cli_e2e/mail/mail_send_workflow_test.go

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