Skip to content

[Website] Forward captured sendmail messages - #4103

Merged
mho22 merged 8 commits into
trunkfrom
bgrgicak/forward-sendmail-event
Aug 13, 2026
Merged

mho22 merged 8 commits into
trunkfrom
bgrgicak/forward-sendmail-event

Conversation

@bgrgicak

@bgrgicak bgrgicak commented Jul 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Forwards captured sendmail messages through the Playground client and stores parsed messages in each site's website state for the inbox UI planned in #4000 as part of #3994.

Rationale

Email capture currently stops inside the PHP worker. Website components need structured messages they can consume. This PR adds that plumbing only; it does not add an inbox UI or deliver mail to the internet.

Implementation details

  • Forwards sendmail.spawned from each PHP instance while avoiding duplicate forwarding listeners on reused instances.
  • Re-brands the event at the remote API boundary so its stdin stream crosses both Comlink hops, then parses messages with postal-mime.
  • Processes messages sequentially and prepends them to clientInfo.emails, preserving newest-first event order. Parse failures do not block later messages.
  • Prevents aborted sites from storing parsed messages and cancels queued streams as they are reached.
  • Initializes the runtime client state with emails and excludes parsed email objects from Redux serializability checks.

Capture starts after startPlaygroundWeb() completes, so mail sent during initial boot or Blueprint execution is not retained. Messages are held only in memory and are discarded when the client restarts, is removed, or the page reloads. Each source message is limited to 20 MiB, but aggregate retention remains unbounded until the inbox UI adds an eviction policy.

Testing Instructions

  • CI

@bgrgicak bgrgicak changed the title [Website] Forward captured emails to the UI thread [Website] Stop dropping captured emails at the worker boundary Jul 17, 2026
@bgrgicak bgrgicak self-assigned this Jul 17, 2026
@bgrgicak bgrgicak changed the title [Website] Stop dropping captured emails at the worker boundary [Website] Stop dropping captured emails Jul 17, 2026
@bgrgicak bgrgicak changed the title [Website] Stop dropping captured emails [Website] Forward captured sendmail messages Jul 20, 2026
@bgrgicak
bgrgicak requested review from a team and zaerl July 20, 2026 08:25
@bgrgicak
bgrgicak marked this pull request as ready for review July 20, 2026 08:25
Copilot AI review requested due to automatic review settings July 20, 2026 08:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR forwards captured sendmail events from PHP instances into the website client state and parses RFC 822 messages so website components can consume structured email data.

Changes:

  • Forward sendmail.spawned events through PlaygroundWorkerEndpoint.
  • Parse captured email streams with postal-mime and store parsed messages in per-site clientInfo.emails.
  • Relax Redux serializability checks for parsed email objects and wiring needed in tests.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/playground/website/src/lib/state/redux/store.ts Excludes email payload/state paths from serializability checks.
packages/playground/website/src/lib/state/redux/slice-clients.ts Adds emails to client state and introduces addClientEmail reducer.
packages/playground/website/src/lib/state/redux/boot-site-client.ts Listens for sendmail.spawned, parses stream, dispatches addClientEmail.
packages/playground/website/src/lib/state/redux/boot-site-client.spec.ts Updates test client stub with addEventListener.
packages/playground/remote/src/lib/sendmail-transport.spec.ts Updates PHP mock to include addEventListener.
packages/playground/remote/src/lib/playground-worker-endpoint.ts Re-dispatches sendmail.spawned from PHP to the worker endpoint.
package.json Adds postal-mime dependency.

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

Comment thread packages/playground/website/src/lib/state/redux/slice-clients.ts
Comment thread packages/playground/website/src/lib/state/redux/slice-clients.ts
Comment thread packages/playground/website/src/lib/state/redux/boot-site-client.ts Outdated
Comment thread packages/playground/website/src/lib/state/redux/boot-site-client.ts Outdated
@bgrgicak
bgrgicak removed the request for review from zaerl July 20, 2026 08:43
@bgrgicak
bgrgicak marked this pull request as draft July 20, 2026 08:43
@bgrgicak
bgrgicak marked this pull request as ready for review July 24, 2026 17:54
@mho22
mho22 merged commit 3c2cb1d into trunk Aug 13, 2026
113 of 114 checks passed
@mho22
mho22 deleted the bgrgicak/forward-sendmail-event branch August 13, 2026 14:45
mho22 added a commit that referenced this pull request Aug 13, 2026
## Summary

Adds an Email panel to the Playground Site Manager for viewing messages
captured from the active site, including message and attachment
previews.

## Motivation for the change, related issues

Builds on #4103 and #3996 to make captured `sendmail` messages available
in the Site Manager UI. Related issue: #3994.

## Implementation details

- Reads parsed messages from the active site's `clientInfo.emails` array
and selects the newest message by default.
- Displays message metadata and HTML or plain-text content. HTML and
attachment-bearing messages render in a no-referrer, sandboxed iframe;
links open outside the preview, while scripts and forms remain blocked.
- Resolves `cid:` images and attachments to temporary Blob URLs, with
image, video, and audio previews and downloads. URLs are revoked when no
longer needed.
- Uses `@wordpress/components` for the message list, empty state, and
metadata. Attachment cards use isolated styles in a declarative shadow
root.
- Keeps messages in memory for the site client's lifetime. Aggregate
retention is unbounded, there is no clear-mailbox action, and messages
are discarded when the client restarts or is removed, or the page
reloads.
- Adds Playwright coverage that sends mail through PHP and verifies the
captured subject and body in the Email panel.

## Testing Instructions

1. Start the website with `npm run dev`.
2. Open the [local Playground website with this
Blueprint](http://127.0.0.1:5400/website-server/?blueprint-url=https%3A%2F%2Fgist.githubusercontent.com%2Fbgrgicak%2Ff4d2cc7242fceef00bd0109fb8b81137%2Fraw%2Femail-test-blueprint.json).
3. Open **Email** in the Site Manager and confirm the empty state is
shown.
4. Select **Send test email** in the site's admin bar.
5. Confirm the message metadata, HTML, special characters, images, and
external links render correctly.
6. Confirm supported attachments can be previewed and all attachments
can be downloaded.

<img width="1839" height="1324" alt="Email panel showing a captured
message"
src="https://github.com/user-attachments/assets/9c560378-dac4-4fd3-8895-e87c7d1d76ba"
/>

---------

Co-authored-by: mho22 <yannick@capsules.codes>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants