Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
✨ Add participant response note, visible to the host only (#2789)
Luke Vellae1b1ef5d256f
diff --git a/apps/landing/public/locales/en/common.json b/apps/landing/public/locales/en/common.jsonindex 54ae4de87..bee30542c 100644--- a/apps/landing/public/locales/en/common.json+++ b/apps/landing/public/locales/en/common.json@@ -22,12 +22,10 @@"login": "Login","notFoundDescription": "We couldn't find the page you're looking for.","notFoundTitle": "404 not found",- "openSource": "We're Open Source!","pricing": "Pricing","privacyPolicy": "Privacy Policy","signUp": "Sign Up","solutions": "Solutions",- "starOnGitHub": "Star us on GitHub","status": "Status","support": "Support","termsOfUse": "Terms of Use",diff --git a/apps/web/public/locales/en/app.json b/apps/web/public/locales/en/app.jsonindex c4b2dfd91..5392e83bb 100644--- a/apps/web/public/locales/en/app.json+++ b/apps/web/public/locales/en/app.json@@ -441,7 +441,10 @@"newParticipantDialogCreatePollPrompt": "Need to schedule something yourself?","newParticipantDialogSuccessDescription": "The organizer can now see your availability.","newParticipantDialogSuccessTitle": "Your response has been saved",+ "newParticipantFormAddNote": "Add a note","newParticipantFormDescription": "Fill in the form below to submit your votes.",+ "newParticipantFormNoteDescription": "Only the organizer will see this note.",+ "newParticipantFormNoteLabel": "Note for the organizer","newParticipantFormSubmit": "Save availability","newPassword": "New Password","newPoll": "New Poll",@@ -497,6 +500,7 @@"paginationPage": "Page {currentPage, number} of {totalPages, number}","paginationPrevious": "Previous","participantCount": "{count, plural, =0 {No participants} one {1 participant} other {# participants}}",+ "participantNoteButton": "Read note from {name}","participants": "Participants","password": "Password","passwordChangedSuccess": "Your password has been changed successfully",diff --git a/apps/web/src/features/poll/components/desktop-poll.tsx b/apps/web/src/features/poll/components/desktop-poll.tsxindex 0ae166b5a..d55e270d3 100644--- a/apps/web/src/features/poll/components/desktop-poll.tsx+++ b/apps/web/src/features/poll/components/desktop-poll.tsx@@ -359,6 +359,8 @@ const DesktopPoll: React.FunctionComponent = () => {name: participant.name,userId: participant.userId ?? undefined,email: participant.email ?? undefined,+ note: participant.note,+ createdAt: participant.createdAt,image: participant.image,votes: participant.votes,}}diff --git a/apps/web/src/features/poll/components/desktop-poll/participant-row.tsx b/apps/web/src/features/poll/components/desktop-poll/participant-row.tsxindex 3461cc44d..1deb6912f 100644--- a/apps/web/src/features/poll/components/desktop-poll/participant-row.tsx+++ b/apps/web/src/features/poll/components/desktop-poll/participant-row.tsx@@ -14,6 +14,7 @@ import {ParticipantName,} from "@/features/poll/components/participant";import { ParticipantDropdown } from "@/features/poll/components/participant-dropdown";+import { ParticipantNote } from "@/features/poll/components/participant-note";import { usePoll } from "@/features/poll/components/poll-context";import { useUser } from "@/features/user/client";import { Trans, useTranslation } from "@/i18n/client";@@ -28,6 +29,8 @@ export interface ParticipantRowProps {name: string;userId?: string;email?: string;+ note?: string | null;+ createdAt: Date;image?: string | null;votes: Vote[];};@@ -40,11 +43,21 @@ export const ParticipantRowView: React.FunctionComponent<{name: string;image?: string | null;action?: React.ReactNode;+ note?: React.ReactNode;votes: Array<VoteType | undefined>;className?: string;isYou?: boolean;participantId: string;-}> = ({ name, image, action, votes, className, isYou, participantId }) => {+}> = ({+ name,+ image,+ action,+ note,+ votes,+ className,+ isYou,+ participantId,+}) => {return (<trdata-testid="participant-row"@@ -70,6 +83,7 @@ export const ParticipantRowView: React.FunctionComponent<{<Trans i18nKey="you" /></Badge>) : null}+ {note}{action}</div></div>@@ -129,6 +143,16 @@ const ParticipantRow: React.FunctionComponent<ParticipantRowProps> = ({return getVote(participant.id, optionId);})}participantId={participant.id}+ note={+ // The server only includes notes the viewer may see (host or author).+ participant.note ? (+ <ParticipantNote+ note={participant.note}+ participantName={participant.name}+ createdAt={participant.createdAt}+ />+ ) : null+ }action={canEdit ? (<ParticipantDropdowndiff --git a/apps/web/src/features/poll/components/mobile-poll.tsx b/apps/web/src/features/poll/components/mobile-poll.tsxindex 13fd05103..6540b2148 100644--- a/apps/web/src/features/poll/components/mobile-poll.tsx+++ b/apps/web/src/features/poll/components/mobile-poll.tsx@@ -9,7 +9,7 @@ import {SelectTrigger,SelectValue,} from "@rallly/ui/select";-import { MoreVerticalIcon, PlusIcon, UsersIcon } from "lucide-react";+import { MoreHorizontalIcon, PlusIcon, UsersIcon } from "lucide-react";import { AnimatePresence } from "motion/react";import * as m from "motion/react-m";import type * as React from "react";@@ -23,6 +23,7 @@ import {ParticipantName,} from "@/features/poll/components/participant";import { ParticipantDropdown } from "@/features/poll/components/participant-dropdown";+import { ParticipantNote } from "@/features/poll/components/participant-note";import { useOptions, usePoll } from "@/features/poll/components/poll-context";import { useVisibleParticipants } from "@/features/poll/components/visibility";import { useVotingForm } from "@/features/poll/components/voting-form";@@ -148,26 +149,38 @@ const MobilePoll: React.FunctionComponent = () => {{t("cancel")}</Button>) : selectedParticipant ? (- <ParticipantDropdown- align="end"- disabled={!canEditParticipant(selectedParticipant.id)}- participant={{- name: selectedParticipant.name,- userId: selectedParticipant.userId ?? undefined,- email: selectedParticipant.email ?? undefined,- id: selectedParticipant.id,- }}- onEdit={() => {- votingForm.setEditingParticipantId(selectedParticipant.id);- }}- >- <Button- aria-label={t("moreOptions", { defaultValue: "More options" })}- size="icon"+ <>+ {selectedParticipant.note ? (+ <ParticipantNote+ note={selectedParticipant.note}+ participantName={selectedParticipant.name}+ createdAt={selectedParticipant.createdAt}+ size="icon"+ />+ ) : null}+ <ParticipantDropdown+ align="end"+ disabled={!canEditParticipant(selectedParticipant.id)}+ participant={{+ name: selectedParticipant.name,+ userId: selectedParticipant.userId ?? undefined,+ email: selectedParticipant.email ?? undefined,+ id: selectedParticipant.id,+ }}+ onEdit={() => {+ votingForm.setEditingParticipantId(selectedParticipant.id);+ }}>- <MoreVerticalIcon />- </Button>- </ParticipantDropdown>+ <Button+ aria-label={t("moreOptions", {+ defaultValue: "More options",+ })}+ size="icon"+ >+ <MoreHorizontalIcon />+ </Button>+ </ParticipantDropdown>+ </>) : canAddNewParticipant ? (<Buttonaria-label={t("addParticipant", {diff --git a/apps/web/src/features/poll/components/new-participant-modal.tsx b/apps/web/src/features/poll/components/new-participant-modal.tsxindex b51dcf14b..217a86a72 100644--- a/apps/web/src/features/poll/components/new-participant-modal.tsx+++ b/apps/web/src/features/poll/components/new-participant-modal.tsx@@ -5,12 +5,14 @@ import { buttonVariants, cn } from "@rallly/ui";import { Button } from "@rallly/ui/button";import {DialogDescription,+ DialogFooter,DialogHeader,DialogTitle,} from "@rallly/ui/dialog";import {Form,FormControl,+ FormDescription,FormField,FormItem,FormLabel,@@ -18,15 +20,19 @@ import {} from "@rallly/ui/form";import { Input } from "@rallly/ui/input";import { Label } from "@rallly/ui/label";+import { MaxCharLength } from "@rallly/ui/max-char-length";+import { Textarea } from "@rallly/ui/textarea";import { TRPCClientError } from "@trpc/client";-import { CircleCheckIcon } from "lucide-react";+import { CircleCheckIcon, PlusIcon } from "lucide-react";import Link from "next/link";+import * as React from "react";import { useForm } from "react-hook-form";import * as z from "zod";import { IfCloudHosted } from "@/components/environment";import { usePoll } from "@/features/poll/client";import { useAddParticipantMutation } from "@/features/poll/components/mutations";import VoteIcon from "@/features/poll/components/vote-icon";+import { MAX_RESPONSE_NOTE_LENGTH } from "@/features/poll/schema";import { useUser } from "@/features/user/client";import { Trans, useTranslation } from "@/i18n/client";import { useDateTimeConfig } from "@/lib/datetime/client";@@ -35,12 +41,14 @@ const requiredEmailSchema = z.object({requireEmail: z.literal(true),name: z.string().trim().min(1).max(100),email: z.email(),+ note: z.string().max(MAX_RESPONSE_NOTE_LENGTH).optional(),});const optionalEmailSchema = z.object({requireEmail: z.literal(false),name: z.string().trim().min(1).max(100),email: z.email().or(z.literal("")),+ note: z.string().max(MAX_RESPONSE_NOTE_LENGTH).optional(),});const schema = z.union([requiredEmailSchema, optionalEmailSchema]);@@ -126,6 +134,7 @@ export const NewParticipantForm = (props: NewParticipantModalProps) => {resolver: zodResolver(schema),defaultValues: {requireEmail: isEmailRequired,+ note: "",...(isLoggedIn? { name: user.name, email: user.email ?? "" }: {@@ -135,7 +144,9 @@ export const NewParticipantForm = (props: NewParticipantModalProps) => {},});- const { setError, formState, handleSubmit } = form;+ const { setError, formState, handleSubmit, watch } = form;+ const noteLength = watch("note")?.length ?? 0;+ const [showNote, setShowNote] = React.useState(false);const addParticipant = useAddParticipantMutation();if (formState.isSubmitSuccessful) {@@ -219,6 +230,7 @@ export const NewParticipantForm = (props: NewParticipantModalProps) => {</DialogHeader><Form {...form}><form+ id="new-participant-form"onSubmit={handleSubmit(async (data) => {try {await createGuestIfNeeded();@@ -226,6 +238,7 @@ export const NewParticipantForm = (props: NewParticipantModalProps) => {name: data.name,votes: props.votes,email: data.email,+ note: data.note,pollId: poll.id,timeZone,});@@ -287,33 +300,113 @@ export const NewParticipantForm = (props: NewParticipantModalProps) => {<VoteSummary votes={props.votes} /></div>- {formState.errors.root?.message ? (- <FormMessage>{formState.errors.root.message}</FormMessage>- ) : null}- <div className="mt-6 flex gap-2">+ {showNote ? (+ <FormField+ control={form.control}+ name="note"+ render={({ field }) => (+ <FormItem>+ <div className="flex items-center justify-between">+ <FormLabel>+ {t("newParticipantFormNoteLabel", {+ defaultValue: "Note for the organizer",+ })}+ </FormLabel>+ <Button+ type="button"+ variant="link"+ size="sm"+ className="h-auto p-0 text-muted-foreground hover:text-foreground"+ disabled={formState.isSubmitting}+ onClick={() => {+ form.setValue("note", "");+ setShowNote(false);+ }}+ >+ <Trans i18nKey="remove" defaults="Remove" />+ </Button>+ </div>+ <FormControl>+ <Textarea+ className="w-full"+ autoFocus={true}+ disabled={formState.isSubmitting}+ maxLength={MAX_RESPONSE_NOTE_LENGTH}+ {...field}+ />+ </FormControl>+ <div className="flex items-center justify-between gap-2">+ <FormDescription>+ <Trans+ i18nKey="newParticipantFormNoteDescription"+ defaults="Only the organizer will see this note."+ />+ </FormDescription>+ <MaxCharLength+ length={noteLength}+ maxLength={MAX_RESPONSE_NOTE_LENGTH}+ label={t("charactersRemaining", {+ defaultValue:+ "{count, plural, one {# character remaining} other {# characters remaining}}",+ count: MAX_RESPONSE_NOTE_LENGTH - noteLength,+ })}+ />+ </div>+ <FormMessage />+ </FormItem>+ )}+ />+ ) : (<Button- className="flex-1"+ size="sm"+ className="rounded-full"type="button"- size="lg"- onClick={props.onCancel}- >- {t("back")}- </Button>- <Button- className="flex-1"- type="submit"- size="lg"- variant="primary"- loading={formState.isSubmitting}+ disabled={formState.isSubmitting}+ onClick={() => {+ setShowNote(true);+ posthog?.capture(+ "new_participant_dialog:add_note_button_click",+ {+ pollId: poll.id,+ spaceId: poll.spaceId,+ tier: poll.space?.tier,+ $groups: {+ poll: poll.id,+ ...(poll.spaceId ? { space: poll.spaceId } : {}),+ },+ },+ );+ }}>+ <PlusIcon data-icon="inline-start" /><Trans- i18nKey="newParticipantFormSubmit"- defaults="Save availability"+ i18nKey="newParticipantFormAddNote"+ defaults="Add a note"/></Button>- </div>+ )}++ {formState.errors.root?.message ? (+ <FormMessage>{formState.errors.root.message}</FormMessage>+ ) : null}</form></Form>+ <DialogFooter>+ <Button type="button" onClick={props.onCancel}>+ {t("back")}+ </Button>+ <Button+ type="submit"+ form="new-participant-form"+ variant="primary"+ loading={formState.isSubmitting}+ >+ <Trans+ i18nKey="newParticipantFormSubmit"+ defaults="Save availability"+ />+ </Button>+ </DialogFooter></>);};diff --git a/apps/web/src/features/poll/components/participant-note.tsx b/apps/web/src/features/poll/components/participant-note.tsxnew file mode 100644index 000000000..ab37c3752--- /dev/null+++ b/apps/web/src/features/poll/components/participant-note.tsx@@ -0,0 +1,52 @@+"use client";++import { Button } from "@rallly/ui/button";+import { Icon } from "@rallly/ui/icon";+import { Popover, PopoverContent, PopoverTrigger } from "@rallly/ui/popover";+import { MessageSquareTextIcon } from "lucide-react";+import TruncatedLinkify from "@/features/poll/components/truncated-linkify";+import { useTranslation } from "@/i18n/client";+import { RelativeTime } from "@/lib/datetime/relative-time";++export function ParticipantNote({+ note,+ participantName,+ createdAt,+ size = "icon-xs",+}: {+ note: string;+ participantName: string;+ createdAt: Date;+ size?: "icon" | "icon-xs";+}) {+ const { t } = useTranslation();+ return (+ <Popover>+ <PopoverTrigger+ render={+ <Button+ aria-label={t("participantNoteButton", {+ defaultValue: "Read note from {name}",+ name: participantName,+ })}+ size={size}+ variant="ghost"+ >+ <Icon>+ <MessageSquareTextIcon />+ </Icon>+ </Button>+ }+ />+ <PopoverContent>+ <div className="max-h-48 overflow-y-auto whitespace-pre-wrap break-words text-sm">+ <TruncatedLinkify>{note}</TruncatedLinkify>+ </div>+ <RelativeTime+ value={createdAt}+ className="text-muted-foreground text-xs"+ />+ </PopoverContent>+ </Popover>+ );+}diff --git a/apps/web/src/features/poll/schema.ts b/apps/web/src/features/poll/schema.tsindex af5e275af..c4f1633a2 100644--- a/apps/web/src/features/poll/schema.ts+++ b/apps/web/src/features/poll/schema.ts@@ -14,6 +14,10 @@ export const MAX_COMMENT_LENGTH = 2000;// Flows into the email subject line.export const MAX_COMMENT_AUTHOR_NAME_LENGTH = 100;+// Response notes ship in the new-participant notification email, so they must+// be bounded. A note is short context alongside a response, not discussion.+export const MAX_RESPONSE_NOTE_LENGTH = 500;+export const pollStatusSchema = z.enum(["open","closed",diff --git a/apps/web/src/trpc/routers/polls/participants.ts b/apps/web/src/trpc/routers/polls/participants.tsindex c6a92af53..894351113 100644--- a/apps/web/src/trpc/routers/polls/participants.ts+++ b/apps/web/src/trpc/routers/polls/participants.ts@@ -17,6 +17,7 @@ import {requireUserMiddleware,router,} from "../../trpc";+import { responseNoteInput } from "./schema";import {createParticipantEditToken,resolveActor,@@ -70,11 +71,15 @@ async function sendNewResponseNotificationEmail({pollId,pollTitle,participantName,+ participantEmail,+ note,excludeUserId,}: {pollId: string;pollTitle: string;participantName: string;+ participantEmail: string | null;+ note: string | null;excludeUserId: string;}) {try {@@ -92,8 +97,11 @@ async function sendNewResponseNotificationEmail({to: recipient.email,locale: recipient.locale ?? undefined,branding: await getInstanceBranding(),+ replyTo: participantEmail ?? undefined,props: {participantName,+ note: note ?? undefined,+ canReply: !!participantEmail,pollUrl: absoluteUrl(`/poll/${pollId}`),disableNotificationsUrl: absoluteUrl("/settings/notifications"),title: pollTitle,@@ -155,19 +163,33 @@ export const participants = router({],});- const participants = rawParticipants.map(createParticipantFullDTO);+ // Admin check is intentionally bound to ctx.user only — an edit+ // token must never unlock the admin view of other participants.+ const isAdmin = ctx.user+ ? await hasPollAdminAccess(pollId, ctx.user.id)+ : false;++ // Fall back to the edit token so a guest can still see their own+ // response when opening the email link in a fresh browser.+ const viewerId = isAdmin ? null : await tryResolveUserId(token, ctx.user);++ // Response notes are visible to the host and their author only: strip+ // them from every other payload rather than hiding them in the UI.+ const participants = rawParticipants.map((participant) => {+ const dto = createParticipantFullDTO(participant);+ if (+ isAdmin ||+ (participant.userId && participant.userId === viewerId)+ ) {+ return dto;+ }+ return { ...dto, note: null };+ });// Hide participants if the poll has hideParticipants enabled// and the current user is not an adminif (poll.hideParticipants) {- // Admin check is intentionally bound to ctx.user only — an edit- // token must never unlock the admin view of other participants.- const isAdmin =- ctx.user && (await hasPollAdminAccess(pollId, ctx.user.id));if (!isAdmin) {- // Fall back to the edit token so a guest can still see their own- // response when opening the email link in a fresh browser.- const viewerId = await tryResolveUserId(token, ctx.user);return participants.map((participant) => {if (viewerId && participant.userId === viewerId) {return participant;@@ -230,6 +252,7 @@ export const participants = router({pollId: z.string(),name: z.string().trim().min(1, "Participant name is required").max(100),email: z.string().optional(),+ note: responseNoteInput,timeZone: z.string().optional(),votes: z.object({@@ -240,7 +263,10 @@ export const participants = router({}),).mutation(- async ({ ctx, input: { pollId, votes, name, email, timeZone } }) => {+ async ({+ ctx,+ input: { pollId, votes, name, email, note, timeZone },+ }) => {const participantCount = await prisma.participant.count({where: {pollId,@@ -275,6 +301,7 @@ export const participants = router({pollId: pollId,name: name,email,+ note,timeZone,userId: ctx.user.id,locale: ctx.locale,@@ -345,6 +372,8 @@ export const participants = router({pollId,pollTitle: participant.poll.title,participantName: participant.name,+ participantEmail: participant.email,+ note: participant.note,excludeUserId: ctx.user.id,}),);@@ -356,6 +385,8 @@ export const participants = router({properties: {participant_id: participant.id,has_email: !!email,+ has_note: !!participant.note,+ note_length: participant.note?.length,total_responses: totalResponses,},groups: {diff --git a/apps/web/src/trpc/routers/polls/schema.test.ts b/apps/web/src/trpc/routers/polls/schema.test.tsindex fe13611ed..8f1d33481 100644--- a/apps/web/src/trpc/routers/polls/schema.test.ts+++ b/apps/web/src/trpc/routers/polls/schema.test.ts@@ -1,5 +1,6 @@import { describe, expect, it } from "vitest";-import { timeZoneInput } from "./schema";+import { MAX_RESPONSE_NOTE_LENGTH } from "@/features/poll/schema";+import { responseNoteInput, timeZoneInput } from "./schema";describe("timeZoneInput", () => {it("normalizes an empty string to null", () => {@@ -18,3 +19,28 @@ describe("timeZoneInput", () => {expect(timeZoneInput.parse(null)).toBeNull();});});++describe("responseNoteInput", () => {+ it("trims surrounding whitespace", () => {+ expect(responseNoteInput.parse(" running late ")).toBe("running late");+ });++ it("collapses a whitespace only note to undefined", () => {+ expect(responseNoteInput.parse(" \n ")).toBeUndefined();+ });++ it("keeps undefined as undefined", () => {+ expect(responseNoteInput.parse(undefined)).toBeUndefined();+ });++ it("rejects notes over the maximum length", () => {+ expect(() =>+ responseNoteInput.parse("a".repeat(MAX_RESPONSE_NOTE_LENGTH + 1)),+ ).toThrow();+ });++ it("accepts a note at the maximum length", () => {+ const note = "a".repeat(MAX_RESPONSE_NOTE_LENGTH);+ expect(responseNoteInput.parse(note)).toBe(note);+ });+});diff --git a/apps/web/src/trpc/routers/polls/schema.ts b/apps/web/src/trpc/routers/polls/schema.tsindex 88c82d168..6cf9db431 100644--- a/apps/web/src/trpc/routers/polls/schema.ts+++ b/apps/web/src/trpc/routers/polls/schema.ts@@ -1,4 +1,5 @@import * as z from "zod";+import { MAX_RESPONSE_NOTE_LENGTH } from "@/features/poll/schema";// A falsy poll timeZone means "floating". Clients historically sent "" for// floating time polls; normalize it to null at the boundary so it can never@@ -8,3 +9,11 @@ export const timeZoneInput = z.string().transform((value) => value || null).nullish();++// Whitespace-only notes collapse to undefined so no empty string is persisted.+export const responseNoteInput = z+ .string()+ .trim()+ .max(MAX_RESPONSE_NOTE_LENGTH)+ .optional()+ .transform((value) => value || undefined);diff --git a/packages/database/prisma/migrations/20260730000000_add_participant_note/migration.sql b/packages/database/prisma/migrations/20260730000000_add_participant_note/migration.sqlnew file mode 100644index 000000000..c3ac25df7--- /dev/null+++ b/packages/database/prisma/migrations/20260730000000_add_participant_note/migration.sql@@ -0,0 +1,2 @@+-- AlterTable+ALTER TABLE "participants" ADD COLUMN "note" TEXT;diff --git a/packages/database/prisma/models/poll.prisma b/packages/database/prisma/models/poll.prismaindex f1838981f..894cefcc5 100644--- a/packages/database/prisma/models/poll.prisma+++ b/packages/database/prisma/models/poll.prisma@@ -70,6 +70,7 @@ model Participant {id String @id @default(cuid())name Stringemail String?+ note String?userId String? @map("user_id")pollId String @map("poll_id")locale String?diff --git a/packages/emails/locales/en/emails.json b/packages/emails/locales/en/emails.jsonindex 25e30fc19..38095d30a 100644--- a/packages/emails/locales/en/emails.json+++ b/packages/emails/locales/en/emails.json@@ -62,6 +62,7 @@"newParticipant_content2": "Go to your poll to see the new response.","newParticipant_heading": "New Response","newParticipant_preview": "Go to your poll to see the new response.",+ "newParticipant_replyGuidance": "You can reply to this email to respond to {name}.","newParticipant_subject": "{name} has responded to {title}","newParticipantConfirmation_button": "Review response on {domain}","newParticipantConfirmation_content": "Your response to <b>{title}</b> has been submitted.",diff --git a/packages/emails/package.json b/packages/emails/package.jsonindex c62b4054e..931daf4a3 100644--- a/packages/emails/package.json+++ b/packages/emails/package.json@@ -5,6 +5,7 @@"scripts": {"dev": "email dev --dir ./src/templates","type-check": "tsc --pretty --noEmit",+ "test:unit": "vitest run","i18n:scan": "i18next-cli extract"},"exports": {@@ -34,7 +35,10 @@"@types/nodemailer": "^6.4.14","@types/react": "19.2.13","@types/react-dom": "19.2.3",+ "@vitejs/plugin-react": "^5.0.0","i18next-cli": "^1.58.1",- "react-email": "^6.6.3"+ "jsdom": "^26.1.0",+ "react-email": "^6.6.3",+ "vitest": "^4.0.16"}}diff --git a/packages/emails/src/send.tsx b/packages/emails/src/send.tsxindex 91e657af9..17555ff6c 100644--- a/packages/emails/src/send.tsx+++ b/packages/emails/src/send.tsx@@ -18,6 +18,7 @@ export type SendArgs<P> = {branding: EmailBranding;props: Omit<P, "locale" | "chrome">;from?: From;+ replyTo?: string;attachments?: EmailAttachments;icalEvent?: IcalEvent;};@@ -80,6 +81,7 @@ export async function sendRenderedEmail(options: {element: React.ReactNode;subject: string;from?: From;+ replyTo?: string;attachments?: EmailAttachments;icalEvent?: IcalEvent;}) {@@ -91,6 +93,7 @@ export async function sendRenderedEmail(options: {await dispatch({to: options.to,from: options.from,+ replyTo: options.replyTo,subject: options.subject,html,text,diff --git a/packages/emails/src/templates/new-participant.test.tsx b/packages/emails/src/templates/new-participant.test.tsxnew file mode 100644index 000000000..471076f21--- /dev/null+++ b/packages/emails/src/templates/new-participant.test.tsx@@ -0,0 +1,45 @@+import { render } from "@react-email/render";+import { describe, expect, it } from "vitest";+import { previewChrome } from "../components/preview-chrome";+import NewParticipantEmail from "./new-participant";++const baseProps = {+ title: "Team Meeting",+ participantName: "Jane Doe",+ pollUrl: "https://rallly.co/poll/abc",+ disableNotificationsUrl: "https://rallly.co/settings",+ chrome: previewChrome,+};++// i18n interpolation does not run under vitest (ICU backend quirk), so+// assertions target default copy substrings and prop content only.+async function renderEmail(props: { note?: string; canReply?: boolean } = {}) {+ return render(await NewParticipantEmail({ ...baseProps, ...props }));+}++describe("NewParticipantEmail", () => {+ it("renders the note as a quote block", async () => {+ const html = await renderEmail({ note: "Running 15 minutes late" });+ expect(html).toContain("Running 15 minutes late");+ expect(html).toContain("border-left");+ });++ it("escapes user provided note content", async () => {+ const html = await renderEmail({ note: '<script>alert("xss")</script>' });+ expect(html).not.toContain("<script>");+ expect(html).toContain("<script>");+ });++ it("renders no quote block without a note", async () => {+ const html = await renderEmail();+ expect(html).not.toContain("border-left");+ });++ it("shows reply guidance only when a reply address exists", async () => {+ const withReply = await renderEmail({ note: "A note", canReply: true });+ expect(withReply).toContain("You can reply to this email");++ const withoutReply = await renderEmail({ note: "A note" });+ expect(withoutReply).not.toContain("You can reply to this email");+ });+});diff --git a/packages/emails/src/templates/new-participant.tsx b/packages/emails/src/templates/new-participant.tsxindex 34859edea..2383b773b 100644--- a/packages/emails/src/templates/new-participant.tsx+++ b/packages/emails/src/templates/new-participant.tsx@@ -7,9 +7,11 @@ import { previewChrome } from "../components/preview-chrome";import {Body,Button,+ borderColor,Container,Heading,Link,+ Section,Text,} from "../components/styled-components";import { createEmailI18n } from "../i18n";@@ -22,27 +24,36 @@ type NewParticipantEmailProps = {chrome: EmailChrome;title: string;participantName: string;+ note?: string;+ canReply?: boolean;pollUrl: string;disableNotificationsUrl: string;};+const PREVIEW_LENGTH = 140;+async function NewParticipantEmail({title,participantName,+ note,+ canReply,pollUrl,disableNotificationsUrl,locale = "en",chrome,}: NewParticipantEmailProps) {const { t, i18n } = await createEmailI18n(locale);+ const previewText = note+ ? note.length > PREVIEW_LENGTH+ ? `${note.slice(0, PREVIEW_LENGTH)}…`+ : note+ : t("newParticipant_preview", {+ defaultValue: "Go to your poll to see the new response.",+ });return (<Html><Head />- <Preview>- {t("newParticipant_preview", {- defaultValue: "Go to your poll to see the new response.",- })}- </Preview>+ <Preview>{previewText}</Preview><Body><Container><Img@@ -71,6 +82,28 @@ async function NewParticipantEmail({values={{ name: participantName, title }}/></Text>+ {note ? (+ <Section+ style={{+ borderLeft: `3px solid ${borderColor}`,+ paddingLeft: "16px",+ }}+ >+ <Text style={{ margin: 0, whiteSpace: "pre-wrap" }}>{note}</Text>+ </Section>+ ) : null}+ {note && canReply ? (+ <Text small light={true}>+ <Trans+ t={t}+ i18n={i18n}+ ns="emails"+ i18nKey="newParticipant_replyGuidance"+ defaults="You can reply to this email to respond to {name}."+ values={{ name: participantName }}+ />+ </Text>+ ) : null}<Text><Transt={t}@@ -118,6 +151,8 @@ async function NewParticipantEmail({NewParticipantEmail.PreviewProps = {participantName: "John Doe",+ note: "I can only make it after 2pm on Tuesday.\nLooking forward to it!",+ canReply: true,title: "Untitled Poll",pollUrl: "https://rallly.co",disableNotificationsUrl: "https://rallly.co",diff --git a/packages/emails/vitest.config.mts b/packages/emails/vitest.config.mtsnew file mode 100644index 000000000..32cb08157--- /dev/null+++ b/packages/emails/vitest.config.mts@@ -0,0 +1,10 @@+import react from "@vitejs/plugin-react";+import { defineConfig } from "vitest/config";++export default defineConfig({+ plugins: [react()],+ test: {+ environment: "jsdom",+ include: ["src/**/*.test.{ts,tsx}"],+ },+});diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 5e9f1c362..c9fb042d4 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -621,12 +621,21 @@ importers:'@types/react-dom':specifier: 19.2.3version: 19.2.3(@types/[email protected])+ '@vitejs/plugin-react':+ specifier: ^5.0.0+ version: 5.1.3([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))i18next-cli:specifier: ^1.58.1version: 1.58.1(@types/[email protected])([email protected]([email protected]))([email protected]([email protected]))([email protected])+ jsdom:+ specifier: ^26.1.0+ version: 26.1.0react-email:specifier: ^6.6.3+ vitest:+ specifier: ^4.0.16+ version: 4.0.18(@opentelemetry/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])packages/languages:dependencies: