Skip to content

feat(mail): append default signature when sending#1313

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

feat(mail): append default signature when sending#1313
bubbmon233 wants to merge 2 commits into
larksuite:mainfrom
bubbmon233:feat/e7ce758

Conversation

@bubbmon233

@bubbmon233 bubbmon233 commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

Generated by the harness-coding skill.

  • Branch: feat/e7ce758
  • Target: main

Sprints

ID Title Status Commit
S1 Implement default mail signature behavior for mail +send passed 4a66a9f
S2 Synthesize transport contract for larksuite/cli passed 4a66a9f

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 default signatures
    • Support for explicit --signature-id selection and richer HTML→plain-text signature rendering
    • Compose now appends plain-text signatures when appropriate
  • Validation

    • Enforced mutual-exclusivity between --no-signature and --signature-id
  • Tests

    • Added and updated unit/integration/e2e tests covering signature behaviors and dry-run requests
  • Documentation

    • Clarified signature behavior and command examples in mail docs

Automatically compose the user default mail signature into sent messages and add an opt-out flag for callers that need to skip it.
@coderabbitai

coderabbitai Bot commented Jun 7, 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: 70c78e5d-99ac-4bd0-a986-cb97beef1bcf

📥 Commits

Reviewing files that changed from the base of the PR and between 4a66a9f and ff0ede7.

📒 Files selected for processing (1)
  • skills/lark-mail/references/lark-mail-send.md
✅ Files skipped from review due to trivial changes (1)
  • skills/lark-mail/references/lark-mail-send.md

📝 Walkthrough

Walkthrough

Adds a --no-signature flag and validation, refactors compose-time signature resolution (explicit ID, default selection by sender, image fetching control), implements HTML→plain-text signature rendering and appending, integrates into MailSend dry-run/execute flows, adds tests (unit, e2e, dry-run) and updates docs.

Changes

Signature Control and Composition

Layer / File(s) Summary
Flag definition and validation setup
shortcuts/mail/signature_compose.go, shortcuts/mail/mail_send.go
Adds --no-signature flag to MailSend and enforces mutual exclusivity between --no-signature and --signature-id.
Signature resolution refactoring
shortcuts/mail/signature_compose.go
Adds compose-specific resolution with includeImages control, resolveComposeSignature, resolveDefaultSendSignatureID, and validSignatureUsageID for explicit/default selection and sender-based matching.
Plain-text signature rendering
shortcuts/mail/signature_compose.go
Adds regex-based HTML→plain-text conversion and appendPlainTextSignature to render signatures with image placeholders and normalized whitespace.
MailSend shortcut integration
shortcuts/mail/mail_send.go
Integrates signature fetching into DryRun when applicable, switches validation to validateSignatureFlags, calls resolveComposeSignature during execution, and appends plain-text signatures in text mode.
Signature behavior test suite
shortcuts/mail/mail_send_signature_test.go
New tests for HTML/plain-text signature injection, --no-signature skipping, explicit override via --signature-id, mutual-exclusivity validation, sender-based default selection, and plain-text rendering without truncation; includes EML decode helpers.
Existing test consistency 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
Adds --no-signature to existing MailSend test invocations to keep arguments consistent.
End-to-end dry-run signature tests
tests/cli_e2e/mail/mail_send_dryrun_test.go
Adds dry-run tests asserting whether signature settings API requests are made across flag combinations and validating mutual-exclusivity error behavior.
Documentation updates
skills/lark-mail/SKILL.md, skills/lark-mail/references/lark-mail-send.md
Documents default signature behavior, --no-signature and --signature-id, mutual exclusivity, selection algorithm, and HTML vs plaintext handling.
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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • larksuite/cli#318: Related changes touching compose/send sender resolution logic in shortcuts/mail/mail_send.go.

Suggested reviewers

  • chanthuang
  • infeng

Poem

🐰 I hopped through flags and HTML tags bright,
Added a switch to skip the sign by night.
Plain-text or rich, each signature's right,
Tests and docs now make the behavior light.
Happy sending — no signature in sight!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description does not follow the required template structure. It lacks Summary, Changes, Test Plan, and Related Issues sections that are specified in the template. Rewrite the description following the template: add a brief summary of the change, list the main changes, describe the test plan with checkboxes, and specify related issues.
Docstring Coverage ⚠️ Warning Docstring coverage is 25.81% 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 clearly and specifically describes the main change: adding default email signature functionality to the mail send command.
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
@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

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

@codecov

codecov Bot commented Jun 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.63830% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.18%. Comparing base (e1bb9db) to head (ff0ede7).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
shortcuts/mail/signature_compose.go 62.06% 24 Missing and 9 partials ⚠️
shortcuts/mail/mail_send.go 42.85% 4 Missing ⚠️
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.
📢 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.

@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)
tests/cli_e2e/mail/mail_send_dryrun_test.go (1)

102-106: ⚡ Quick win

Avoid 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

📥 Commits

Reviewing files that changed from the base of the PR and between e1bb9db and 4a66a9f.

📒 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_test.go
  • shortcuts/mail/mail_template_shortcut_test.go
  • shortcuts/mail/signature_compose.go
  • skills/lark-mail/SKILL.md
  • skills/lark-mail/references/lark-mail-send.md
  • tests/cli_e2e/mail/mail_send_dryrun_test.go

Comment thread skills/lark-mail/references/lark-mail-send.md Outdated
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