Freestyle mock#814
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
apps/e2e/tests/backend/endpoints/api/v1/auth/otp/send-sign-in-code.test.ts
Show resolved
Hide resolved
|
😱 Found 2 issues. Time to roll up your sleeves! 😱 🗒️ View all ignored comments in this repo
Need help? Join our Discord for support! |
There was a problem hiding this comment.
Greptile Summary
This PR implements a comprehensive email rendering emulation system that transitions from mock email rendering to a production-like email processing pipeline. The core change introduces a "Freestyle mock" system that uses Bun-based sandboxes to actually execute React email templates and render proper HTML emails, rather than returning mock template strings.
The implementation includes several key components:
Freestyle Integration: The apps/backend/src/lib/freestyle.tsx file now detects development/test environments with the mock API key (mock_stack_freestyle_key) and redirects to a local mock server at localhost:8119. This allows offline development and testing without external API dependencies.
Docker Mock Service: A complete rewrite of the freestyle mock server from Deno to Bun (docker/dependencies/freestyle-mock/Dockerfile) provides a more sophisticated execution environment that supports React email components and proper Node.js ecosystem compatibility.
Email Rendering Pipeline: The apps/backend/src/lib/email-rendering.tsx file removes the previous mock functionality that returned simple debug strings. Now all email rendering goes through the full FreestyleSandboxes execution path, even in test environments, with React 19.1.1 explicitly configured.
Template Format Updates: Email templates now require specific formats with named exports (EmailTemplate function and variablesSchema using arktype), and themes must export named EmailTheme functions with proper TypeScript interfaces.
Enhanced Email Features: The default email themes now include unsubscribe functionality with proper Link component integration and ThemeProps interface support.
All test files have been updated to expect properly rendered email content (subjects like "Reset your password at Stack Dashboard") instead of raw template syntax, demonstrating that the email rendering pipeline now processes templates correctly with variable substitution and HTML generation.
Confidence score: 2/5
• This PR introduces significant complexity and potential reliability issues that could cause production problems
• The Docker service rewrite from Deno to Bun adds multiple layers of process spawning and JSON parsing that could fail unpredictably
• The docker/dependencies/freestyle-mock/Dockerfile needs more attention due to complex child process handling and potential race conditions in stdout/stderr parsing
17 files reviewed, 3 comments
5fd9ab2
into
email-sending-and-unsubscribes
Important
Enhance email functionality by updating mock server setup, email templates, and tests, and switching Freestyle mock to Bun.
renderEmailWithTemplate()inemail-rendering.tsx.Freestyleclass infreestyle.tsxto setbaseUrlfor mock environments.docker.compose.yamlandindex.html.freestyle-mock/Dockerfileto use Bun instead of Deno.docker.compose.yamlto reflect new Freestyle mock setup.send-email.test.ts,render-email.test.ts, and others to reflect changes in email handling.esbuild.tsxto use a new URL foresbuild.wasm.server-app-impl.tsfor email sending logic.This description was created by
for 4137933. You can customize this summary. It will automatically update as commits are pushed.