Skip to content

Add control for completed-document email attachments#1

Open
Copilot wants to merge 5 commits into
mainfrom
copilot/add-email-settings-for-documents
Open

Add control for completed-document email attachments#1
Copilot wants to merge 5 commits into
mainfrom
copilot/add-email-settings-for-documents

Conversation

Copilot AI commented May 18, 2026

Copy link
Copy Markdown

Description

Healthcare and other high-confidentiality workflows need signing emails without exposing document contents via inbox attachments. This change adds a document-level email setting to suppress completed PDF attachments while still sending completion/signing links.

  • Email settings model

    • Adds attachCompletedDocument to document email settings with a default of true
    • Keeps the setting available anywhere document email preferences are created, inherited, or overridden
    • Updates admin/global settings consumers to account for the expanded email-settings shape
  • Completion email behavior

    • Updates completed-email delivery to only fetch and attach finalized PDFs when attachCompletedDocument is enabled
    • Skips attachment loading entirely when no completion emails will be sent
    • Preserves completion notifications and signing/completion links when attachments are disabled
  • UI / API surface

    • Exposes the new toggle in existing document email settings controls used by document/template/editor flows
    • Normalizes legacy persisted email settings before rendering the checkbox so older records still default to enabled
    • Carries the setting through persisted document meta so API-created and UI-created documents behave consistently
emailSettings: {
  documentCompleted: true,
  ownerDocumentCompleted: true,
  attachCompletedDocument: false,
}

Related Issue

Handled separately by automation.

Test Details

  • Test Name: completed document attachment setting propagation and delivery behavior
  • Type: Unit / E2E
  • Description: Verifies the new email setting is persisted through document settings flows, normalizes legacy saved values in the UI, suppresses completion-email attachments when disabled, and avoids attachment work when completion emails are fully disabled
  • Inputs: Document email settings with attachCompletedDocument enabled and disabled across editor/API/default-setting paths, plus completion-email settings with both completion email types disabled
  • Expected Output: Completion emails continue to be sent, finalized PDFs are only attached when attachCompletedDocument is true, legacy settings render the toggle as enabled by default, and no completed PDFs are fetched when no completion emails will be sent

Checklist

  • I have written the new test and ensured it works as intended.
  • I have added necessary documentation to explain the purpose of the test.
  • I have followed the project's testing guidelines and coding style.
  • I have addressed any review feedback from previous submissions, if applicable.

Additional Notes

This remains intentionally scoped to completed-document attachments. It does not change signing-link generation or recipient access via signing/completion routes, but it now also includes follow-up fixes for legacy setting normalization and for avoiding unnecessary PDF loading on completion.

@Xusifob Xusifob marked this pull request as ready for review May 18, 2026 09:18
Copilot AI review requested due to automatic review settings May 18, 2026 09:18

Copilot AI 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.

Pull request overview

Adds a document-level email setting to control whether finalized PDFs are attached to completion emails while preserving completion notifications and links.

Changes:

  • Adds attachCompletedDocument to document email settings defaults, schema, UI, webhook sample data, and tests.
  • Updates completion email sending to conditionally include finalized PDF attachments.
  • Extends E2E expectations for document/team/API settings propagation.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/ui/components/document/document-email-checkboxes.tsx Adds the new attachment toggle to shared email settings UI.
packages/lib/types/document-email.ts Adds schema/default/derived-setting support for the new setting.
packages/lib/types/document-email.test.ts Adds unit coverage for default and explicit false parsing.
packages/lib/server-only/webhooks/trigger/generate-sample-data.ts Includes the new setting in sample webhook metadata.
packages/lib/server-only/document/send-completed-email.ts Uses the setting to decide whether completion email attachments are generated/sent.
packages/app-tests/e2e/organisations/organisation-team-preferences.spec.ts Updates expected persisted organisation/team email settings.
packages/app-tests/e2e/envelope-editor-v2/envelope-settings.spec.ts Adds UI persistence checks for the new toggle.
packages/app-tests/e2e/document-flow/autosave-subject-step.spec.ts Adds autosave assertions for the new setting.
packages/app-tests/e2e/api/v2/envelopes-api.spec.ts Updates API-created envelope email settings expectations.
package-lock.json Contains unrelated dependency lock metadata changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/lib/types/document-email.ts
Comment thread packages/ui/components/document/document-email-checkboxes.tsx Outdated
Comment on lines +83 to +86
const completedDocumentEmailAttachments = emailSettings.attachCompletedDocument
? await Promise.all(
envelope.envelopeItems.map(async (envelopeItem) => {
const file = await getFileServerSide(envelopeItem.documentData);
Comment thread packages/lib/types/document-email.test.ts
@Xusifob

Xusifob commented May 18, 2026

Copy link
Copy Markdown
Member

@copilot apply changes based on the comments in this thread

Copilot AI commented May 18, 2026

Copy link
Copy Markdown
Author

@copilot apply changes based on the comments in this thread

Addressed in b16cf43. I updated the admin settings label map for the new key, normalized legacy persisted values before rendering/toggling the checkbox, avoided fetching completed PDFs when no completion emails will be sent, and added focused sendCompletedEmail tests covering attachment suppression and the early-return path. Screenshot: https://github.com/user-attachments/assets/581c0b80-ba44-45f3-b433-20804a0c1259

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cli.inngest.com
    • Triggering command: /usr/local/bin/node node postinstall.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from Xusifob May 18, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants