Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
✨ Let organizers run plain yes/no polls (#3256)
Luke Vella354a31b2cccf
diff --git a/apps/docs/administrators/editing-a-meeting-poll.mdx b/apps/docs/administrators/editing-a-meeting-poll.mdxindex 74cc422ee..e21916529 100644--- a/apps/docs/administrators/editing-a-meeting-poll.mdx+++ b/apps/docs/administrators/editing-a-meeting-poll.mdx@@ -20,6 +20,22 @@ To change these details of your poll:3. Enter the new details of your poll in to the form and click **Save**.+## Changing poll settings++1. Click **Manage**+2. Select **Edit settings** from the dropdown menu+3. Change the settings you want and click **Save**.++**Vote options** decides which answers participants can give. By default they+can answer **Yes**, **If need be** or **No**. Switch to **Yes** and **No** if+you want a straight answer with no maybes.++<Note>+ Once a participant has answered **If need be**, you can no longer switch that+ poll to **Yes** and **No**, so their response stays valid. Switching a poll+ back to offering **If need be** is always allowed.+</Note>+## Adding or removing dates or times1. Click **Manage**diff --git a/apps/docs/guide/participant-guide.mdx b/apps/docs/guide/participant-guide.mdxindex ad7378c06..9f2250cfd 100644--- a/apps/docs/guide/participant-guide.mdx+++ b/apps/docs/guide/participant-guide.mdx@@ -8,9 +8,11 @@ description: "How to respond to a Rallly poll"<Step title="Select your preferred dates">Click the button under each date to toggle through the answers:- 1. Yes- 2. If need be- 3. No+ - **Yes** - you're available+ - **If need be** - you can make it work if needed+ - **No** - you're not available++ Some polls only offer **Yes** and **No**.<Note>If you leave an option unselected, it will be counted as a **No** vote.</Note>diff --git a/apps/docs/workflow/create.mdx b/apps/docs/workflow/create.mdxindex 4672f4ff1..2923c6ed2 100644--- a/apps/docs/workflow/create.mdx+++ b/apps/docs/workflow/create.mdx@@ -37,6 +37,10 @@ straight to [app.rallly.co/new](https://app.rallly.co/new).**Time zones** - Times are automatically shown to each participant in their own time zone. This is useful for remote meetings where participants are in different locations. If everyone should see the same times regardless of where they are, turn on **Lock time zone**.+ **Vote options** - Participants can answer **Yes**, **If need be** or **No**.+ Change this to **Yes** and **No** under **Settings** if you'd rather not+ offer a maybe.+</Step><Step title="Create your poll">Click **Create poll**. Your poll opens with the **Share** dialog ready, sodiff --git a/apps/web/public/locales/en/app.json b/apps/web/public/locales/en/app.jsonindex 0ec75e13d..fb7a8475c 100644--- a/apps/web/public/locales/en/app.json+++ b/apps/web/public/locales/en/app.json@@ -591,6 +591,7 @@"optionCount": "{count, plural, one {# option} other {# options}}","optionsSelected": "{count, plural, =0 {None selected} one {# option selected} other {# options selected}}","optionVoteBreakdown": "{yesScore} yes, {ifNeedBeScore} if need be",+ "optionVoteBreakdownYesOnly": "{yesScore} yes","organizationName": "Organization name","organizationNamePlaceholder": "e.g. Acme Corp","organizationNameRequired": "Organization name is required",@@ -905,6 +906,9 @@"viewClosedPolls": "View closed polls","viewInvites": "View invites","viewResults": "View results",+ "voteOptionsLockedDescription": "Locked: participants have already answered \"if need be\".",+ "voteOptionsSettingDescription": "The answers participants can give for each option.",+ "voteOptionsSettingTitle": "Vote options","voteSummaryAvailable": "{availableCount} of {total} available","voteSummaryIfNeedBe": "{count} if need be","voteSummaryNotAvailable": "You're not available",diff --git a/apps/web/src/app/[locale]/(optional-space)/poll/[urlId]/edit-settings/page.tsx b/apps/web/src/app/[locale]/(optional-space)/poll/[urlId]/edit-settings/page.tsxindex 68ff95832..caa47a8ac 100644--- a/apps/web/src/app/[locale]/(optional-space)/poll/[urlId]/edit-settings/page.tsx+++ b/apps/web/src/app/[locale]/(optional-space)/poll/[urlId]/edit-settings/page.tsx@@ -9,10 +9,19 @@ import { useForm } from "react-hook-form";import { usePoll } from "@/features/poll/client";import { PollSettingsForm } from "@/features/poll/components/forms/poll-settings";import { useUpdatePollMutation } from "@/features/poll/components/mutations";+import { useParticipants } from "@/features/poll/components/participants-provider";import { Trans } from "@/i18n/client";const Page = () => {const poll = usePoll();+ const { participants } = useParticipants();++ // The answer set is locked once a response uses the tentative vote, so those+ // votes stay re-saveable by their owner. Derived from the participants the+ // layout already loads rather than a dedicated count query.+ const hasTentativeVotes = participants.some((participant) =>+ participant.votes.some((vote) => vote.type === "ifNeedBe"),+ );const router = useRouter();@@ -29,6 +38,7 @@ const Page = () => {hideParticipants: poll.hideParticipants,hideScores: poll.hideScores,enableComments: !poll.disableComments,+ allowTentativeVotes: poll.allowTentativeVotes,requireParticipantEmail: poll.requireParticipantEmail,},});@@ -47,7 +57,7 @@ const Page = () => {}})}>- <PollSettingsForm>+ <PollSettingsForm hasTentativeVotes={hasTentativeVotes}><CardFooter className="justify-between"><Link href={pollLink} className={buttonVariants()}><Trans i18nKey="cancel" />diff --git a/apps/web/src/app/api/private/[...route]/route.ts b/apps/web/src/app/api/private/[...route]/route.tsindex 1e59c7e66..7a8bf7346 100644--- a/apps/web/src/app/api/private/[...route]/route.ts+++ b/apps/web/src/app/api/private/[...route]/route.ts@@ -336,6 +336,7 @@ app.post(hideParticipants: input.hideParticipants,hideScores: input.hideScores,disableComments: poll.disableComments,+ allowTentativeVotes: poll.allowTentativeVotes,isGuest: false,},groups: {@@ -386,6 +387,7 @@ app.post(hideParticipants: input.hideParticipants,hideScores: input.hideScores,disableComments: input.disableComments,+ allowTentativeVotes: input.allowTentativeVotes,options,spaceId,});@@ -458,6 +460,7 @@ app.post(hideParticipants: input.hideParticipants,hideScores: input.hideScores,disableComments: input.disableComments,+ allowTentativeVotes: input.allowTentativeVotes,options,spaceId,});diff --git a/apps/web/src/app/api/private/schemas.ts b/apps/web/src/app/api/private/schemas.tsindex f5bdca861..dfdd54521 100644--- a/apps/web/src/app/api/private/schemas.ts+++ b/apps/web/src/app/api/private/schemas.ts@@ -105,6 +105,11 @@ export const createPollInputSchema = z"Disable the comments section. Defaults to true: new polls have comments disabled unless this is set to false.",example: false,}),+ allowTentativeVotes: z.boolean().optional().meta({+ description:+ 'Allow participants to answer "if need be" as well as yes and no. Defaults to true.',+ example: true,+ }),spaceId: z.string().optional().meta({description:"ID of the space to create the poll in. Defaults to user's most recently used space.",diff --git a/apps/web/src/app/api/v1/[...route]/route.test.ts b/apps/web/src/app/api/v1/[...route]/route.test.tsindex 46aa388e1..802411579 100644--- a/apps/web/src/app/api/v1/[...route]/route.test.ts+++ b/apps/web/src/app/api/v1/[...route]/route.test.ts@@ -175,6 +175,7 @@ describe("API v1 - /polls", () => {hideParticipants: false,hideScores: false,disableComments: true,+ allowTentativeVotes: true,participantCount: 0,user: {id: "test-user-id",@@ -535,6 +536,7 @@ describe("API v1 - /polls", () => {hideParticipants: true,hideScores: true,disableComments: false,+ allowTentativeVotes: true,participantCount: 0,user: {id: "test-user-id",@@ -569,6 +571,7 @@ describe("API v1 - /polls", () => {hideParticipants: true,hideScores: true,disableComments: false,+ allowTentativeVotes: true,participantCount: 0,updatedAt: "2025-01-10T12:00:00.000Z",organizer: {@@ -590,6 +593,54 @@ describe("API v1 - /polls", () => {);});+ it("should create a yes/no poll when tentative votes are turned off", async () => {+ mockCreatePoll.mockResolvedValueOnce({+ id: "test-poll-id",+ title: "Team offsite",+ description: null,+ location: null,+ timeZone: null,+ status: "open",+ kind: "date",+ createdAt: new Date("2025-01-10T12:00:00Z"),+ updatedAt: new Date("2025-01-10T12:00:00Z"),+ requireParticipantEmail: false,+ hideParticipants: false,+ hideScores: false,+ disableComments: true,+ allowTentativeVotes: false,+ participantCount: 0,+ user: {+ id: "test-user-id",+ name: "Test User",+ email: "[email protected]",+ image: null,+ },+ options: [],+ });++ const res = await app.request("/api/v1/polls", {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ Authorization: `Bearer ${testApiKey}`,+ },+ body: JSON.stringify({+ title: "Team offsite",+ dates: ["2025-01-15"],+ allowTentativeVotes: false,+ }),+ });++ expect(res.status).toBe(201);+ const json = await res.json();+ expectMatchesContract(pollResponseSchema, json);+ expect(json.data.allowTentativeVotes).toBe(false);+ expect(mockCreatePoll).toHaveBeenCalledWith(+ expect.objectContaining({ allowTentativeVotes: false }),+ );+ });+it("should track poll creation with source api and kind date", async () => {const res = await app.request("/api/v1/polls", {method: "POST",@@ -736,6 +787,7 @@ describe("API v1 - /polls", () => {hideParticipants: false,hideScores: false,disableComments: true,+ allowTentativeVotes: true,participantCount: 0,user: {id: "test-user-id",@@ -1320,6 +1372,7 @@ describe("API v1 - /polls", () => {"hideParticipants","hideScores","disableComments",+ "allowTentativeVotes",]) {expect(schemas.CreatePollInput.properties[key]).toBeDefined();expect(schemas.Poll.properties[key]).toBeDefined();@@ -1385,6 +1438,7 @@ describe("API v1 - /polls", () => {hideParticipants: false,hideScores: false,disableComments: true,+ allowTentativeVotes: true,participantCount: 4,user: {id: "test-user-id",@@ -1612,6 +1666,7 @@ describe("API v1 - /polls", () => {hideParticipants: false,hideScores: true,disableComments: false,+ allowTentativeVotes: true,participantCount: 5,user: {id: "user-1",@@ -1792,6 +1847,7 @@ describe("API v1 - /polls", () => {hideParticipants: false,hideScores: false,disableComments: true,+ allowTentativeVotes: true,user: {id: "user-1",name: "John Doe",diff --git a/apps/web/src/app/api/v1/[...route]/route.ts b/apps/web/src/app/api/v1/[...route]/route.tsindex 3e93f33fc..0261a8986 100644--- a/apps/web/src/app/api/v1/[...route]/route.ts+++ b/apps/web/src/app/api/v1/[...route]/route.ts@@ -108,6 +108,7 @@ function toPollResponseBody(poll: {hideParticipants: boolean;hideScores: boolean;disableComments: boolean;+ allowTentativeVotes: boolean;participantCount: number;user: {id: string;@@ -140,6 +141,7 @@ function toPollResponseBody(poll: {hideParticipants: poll.hideParticipants,hideScores: poll.hideScores,disableComments: poll.disableComments,+ allowTentativeVotes: poll.allowTentativeVotes,participantCount: poll.participantCount,options: poll.options.map((option) =>toOptionResponse(poll.kind, option),@@ -442,6 +444,7 @@ app.post(hideParticipants: input.hideParticipants,hideScores: input.hideScores,disableComments: poll.disableComments,+ allowTentativeVotes: poll.allowTentativeVotes,isGuest: false,},groups: {@@ -492,6 +495,7 @@ app.post(hideParticipants: input.hideParticipants,hideScores: input.hideScores,disableComments: input.disableComments,+ allowTentativeVotes: input.allowTentativeVotes,options,spaceId,});@@ -565,6 +569,7 @@ app.post(hideParticipants: input.hideParticipants,hideScores: input.hideScores,disableComments: input.disableComments,+ allowTentativeVotes: input.allowTentativeVotes,options,spaceId,});diff --git a/apps/web/src/app/api/v1/schemas.ts b/apps/web/src/app/api/v1/schemas.tsindex 729264c9f..c5d10c184 100644--- a/apps/web/src/app/api/v1/schemas.ts+++ b/apps/web/src/app/api/v1/schemas.ts@@ -113,6 +113,11 @@ export const createPollInputSchema = z"Disable the comments section. Defaults to true: new polls have comments disabled unless this is set to false.",example: false,}),+ allowTentativeVotes: z.boolean().optional().meta({+ description:+ 'Allow participants to answer "if need be" as well as yes and no. Defaults to true.',+ example: true,+ }),organizer: z.strictObject({email: z.email().meta({@@ -262,6 +267,11 @@ const pollSchema = zdescription: "Whether the comments section is disabled",example: true,}),+ allowTentativeVotes: z.boolean().meta({+ description:+ 'Whether participants may cast the tentative "if need be" vote',+ example: true,+ }),participantCount: z.int().nonnegative().meta({description: "Number of participants who have responded to the poll",example: 3,diff --git a/apps/web/src/features/poll/components/create-poll.tsx b/apps/web/src/features/poll/components/create-poll.tsxindex 6ee1aba69..c9f643bb1 100644--- a/apps/web/src/features/poll/components/create-poll.tsx+++ b/apps/web/src/features/poll/components/create-poll.tsx@@ -158,6 +158,7 @@ export const CreatePoll = ({ nav }: { nav?: React.ReactNode }) => {hideScores: false,hideParticipants: false,enableComments: false,+ allowTentativeVotes: true,duration: 60,lockTimeZone: false,allDay: false,@@ -224,6 +225,7 @@ export const CreatePoll = ({ nav }: { nav?: React.ReactNode }) => {hideParticipants: formData?.hideParticipants,disableComments: !formData?.enableComments,hideScores: formData?.hideScores,+ allowTentativeVotes: formData?.allowTentativeVotes,requireParticipantEmail: formData?.requireParticipantEmail,options: required(formData?.options).map((option) => ({startDate: option.type === "date" ? option.date : option.start,diff --git a/apps/web/src/features/poll/components/desktop-poll/participant-row-form.tsx b/apps/web/src/features/poll/components/desktop-poll/participant-row-form.tsxindex 9735b86c0..28c28e338 100644--- a/apps/web/src/features/poll/components/desktop-poll/participant-row-form.tsx+++ b/apps/web/src/features/poll/components/desktop-poll/participant-row-form.tsx@@ -34,7 +34,7 @@ const ParticipantRowForm = ({}: ParticipantRowFormProps) => {const { t } = useTranslation();- const { optionIds } = usePoll();+ const { optionIds, poll } = usePoll();const { options } = useOptions();const form = useVotingForm();@@ -133,6 +133,7 @@ const ParticipantRowForm = ({option ? getOptionDateTimeLabel(option) : undefined}value={field.value?.type}+ allowTentativeVotes={poll.allowTentativeVotes}onChange={(vote) => {field.onChange({ optionId, type: vote });}}diff --git a/apps/web/src/features/poll/components/event-card.tsx b/apps/web/src/features/poll/components/event-card.tsxindex 6dfad7b79..b86fc496f 100644--- a/apps/web/src/features/poll/components/event-card.tsx+++ b/apps/web/src/features/poll/components/event-card.tsx@@ -108,10 +108,12 @@ export function EventCard() {icon={<VoteIcon type="yes" />}label={<Trans i18nKey="yes" defaults="Yes" />}/>- <IconDescription- icon={<VoteIcon type="ifNeedBe" />}- label={<Trans i18nKey="ifNeedBe" defaults="If need be" />}- />+ {poll.allowTentativeVotes ? (+ <IconDescription+ icon={<VoteIcon type="ifNeedBe" />}+ label={<Trans i18nKey="ifNeedBe" defaults="If need be" />}+ />+ ) : null}<IconDescriptionicon={<VoteIcon type="no" />}label={<Trans i18nKey="no" defaults="No" />}diff --git a/apps/web/src/features/poll/components/forms/poll-settings.test.tsx b/apps/web/src/features/poll/components/forms/poll-settings.test.tsxindex d2645f6e6..197fb8184 100644--- a/apps/web/src/features/poll/components/forms/poll-settings.test.tsx+++ b/apps/web/src/features/poll/components/forms/poll-settings.test.tsx@@ -15,10 +15,19 @@ vi.mock("@/features/billing/client", () => ({showPayWall: vi.fn(),}));-function TestForm({ enableComments = false }: { enableComments?: boolean }) {+function TestForm({+ enableComments = false,+ allowTentativeVotes = true,+ hasTentativeVotes = false,+}: {+ enableComments?: boolean;+ allowTentativeVotes?: boolean;+ hasTentativeVotes?: boolean;+}) {const form = useForm<PollSettingsFormData>({defaultValues: {enableComments,+ allowTentativeVotes,requireParticipantEmail: false,hideParticipants: false,hideScores: false,@@ -26,7 +35,7 @@ function TestForm({ enableComments = false }: { enableComments?: boolean }) {});return (<Form {...form}>- <PollSettingsForm />+ <PollSettingsForm hasTentativeVotes={hasTentativeVotes} /></Form>);}@@ -50,3 +59,59 @@ describe("PollSettingsForm comments setting", () => {expect(screen.getByRole("switch", { name: /comments/i })).toBeChecked();});});++describe("PollSettingsForm vote options setting", () => {+ it("offers all three answers by default", () => {+ render(<TestForm />);+ expect(+ screen.getByRole("combobox", { name: /vote options/i }),+ ).toHaveTextContent(/if need be/i);+ });++ it("reflects polls that are already yes/no only", () => {+ render(<TestForm allowTentativeVotes={false} />);+ const trigger = screen.getByRole("combobox", { name: /vote options/i });+ expect(trigger).toHaveTextContent(/yes/i);+ expect(trigger).not.toHaveTextContent(/if need be/i);+ });++ it("can be changed to a plain yes/no poll", async () => {+ const user = userEvent.setup();+ render(<TestForm />);+ const trigger = screen.getByRole("combobox", { name: /vote options/i });+ await user.click(trigger);+ await user.click(await screen.findByRole("option", { name: "Yes No" }));+ expect(trigger).toHaveTextContent(/yes/i);+ expect(trigger).not.toHaveTextContent(/if need be/i);+ });+});++describe("PollSettingsForm vote options lock", () => {+ it("stays editable while no response uses the tentative vote", () => {+ render(<TestForm />);+ expect(+ screen.getByRole("combobox", { name: /vote options/i }),+ ).not.toBeDisabled();+ });++ it("locks the answer set once a response uses the tentative vote", () => {+ render(<TestForm hasTentativeVotes={true} />);+ expect(+ screen.getByRole("combobox", { name: /vote options/i }),+ ).toBeDisabled();+ });++ it("stays editable on a yes/no poll that still holds tentative votes", () => {+ // Only turning the option off is locked. A poll already set to yes/no has+ // nothing left to strand, so switching it back on must stay available.+ render(<TestForm allowTentativeVotes={false} hasTentativeVotes={true} />);+ expect(+ screen.getByRole("combobox", { name: /vote options/i }),+ ).not.toBeDisabled();+ });++ it("says why it is locked", () => {+ render(<TestForm hasTentativeVotes={true} />);+ expect(screen.getByText(/locked/i)).toBeInTheDocument();+ });+});diff --git a/apps/web/src/features/poll/components/forms/poll-settings.tsx b/apps/web/src/features/poll/components/forms/poll-settings.tsxindex 5fdf4a52b..0f29d5040 100644--- a/apps/web/src/features/poll/components/forms/poll-settings.tsx+++ b/apps/web/src/features/poll/components/forms/poll-settings.tsx@@ -10,9 +10,18 @@ import {FieldLabel,} from "@rallly/ui/field";import { FormField } from "@rallly/ui/form";+import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from "@rallly/ui/select";import { Switch } from "@rallly/ui/switch";+import { VoteIcon } from "@rallly/ui/vote-icon";import {BarChart2Icon,+ ListChecksIcon,MailIcon,MessageCircleIcon,VenetianMaskIcon,@@ -22,9 +31,46 @@ import { SettingIcon } from "@/components/setting-icon";import { showPayWall, useIsFree } from "@/features/billing/client";import { ProBadge } from "@/features/billing/components/pro-badge";import type { PollSettingsFormData } from "@/features/poll/components/forms/types";+import type { VoteType } from "@/features/poll/constants";import { Trans } from "@/i18n/client";-export const PollSettingsForm = ({ children }: React.PropsWithChildren) => {+/**+ * Each answer as its icon plus its name, so the choice shows exactly what a+ * participant will see. The icons separate the answers, so no punctuation is+ * needed between them. The base VoteIcon is used rather than the app wrapper+ * because that one always sets a <title>, which screen readers would announce+ * on top of the name beside it ("Yes Yes, If need be If need be").+ */+function VoteOptionLabel({ types }: { types: VoteType[] }) {+ const labels: Record<VoteType, React.ReactNode> = {+ yes: <Trans i18nKey="yes" defaults="Yes" />,+ ifNeedBe: <Trans i18nKey="ifNeedBe" defaults="If need be" />,+ no: <Trans i18nKey="no" defaults="No" />,+ };++ return (+ <span className="flex items-center gap-x-2.5">+ {types.map((type) => (+ <span key={type} className="flex items-center gap-x-1">+ <VoteIcon type={type} />+ {labels[type]}+ </span>+ ))}+ </span>+ );+}++export const PollSettingsForm = ({+ children,+ hasTentativeVotes = false,+}: React.PropsWithChildren<{+ /**+ * True when responses already use the tentative vote. Those votes stay+ * valid, so the answer set is locked to keep them re-saveable; the same+ * rule is enforced in the modify mutation.+ */+ hasTentativeVotes?: boolean;+}>) => {const form = useFormContext<PollSettingsFormData>();const isFree = useIsFree();@@ -186,6 +232,97 @@ export const PollSettingsForm = ({ children }: React.PropsWithChildren) => {</Field>)}/>+ <FormField+ control={form.control}+ name="allowTentativeVotes"+ render={({ field }) => {+ // Only turning the option off is locked, matching the server+ // guard: that is the direction that would strand existing+ // tentative votes. Turning it back on is always allowed, so a+ // poll already set to yes/no stays switchable even while it+ // still holds tentative votes cast earlier.+ const isLocked = hasTentativeVotes && !!field.value;++ return (+ // Responsive rather than horizontal: the select is far wider+ // than a switch, so below the field group's @md breakpoint it+ // stacks under the label instead of crushing it to one word+ // per line.+ <Field+ orientation="responsive"+ className="@md/field-group:gap-2 gap-4"+ >+ <SettingIcon>+ <ListChecksIcon />+ </SettingIcon>+ <FieldContent>+ <FieldLabel htmlFor="vote-options">+ <Trans+ i18nKey="voteOptionsSettingTitle"+ defaults="Vote options"+ />+ </FieldLabel>+ <FieldDescription>+ {isLocked ? (+ <Trans+ i18nKey="voteOptionsLockedDescription"+ defaults={+ 'Locked: participants have already answered "if need be".'+ }+ />+ ) : (+ <Trans+ i18nKey="voteOptionsSettingDescription"+ defaults="The answers participants can give for each option."+ />+ )}+ </FieldDescription>+ </FieldContent>+ {/* A choice between two answer sets rather than a toggle: the+ setting removes an answer rather than enabling a feature, so+ a switch would have to ship pre-enabled to keep existing+ polls unchanged, unlike every other switch in this card. */}+ {/* The wrapper takes the responsive orientation's `*:w-full`+ so the select inside sizes to its content rather than+ stretching across the row when stacked. */}+ <div>+ <Select+ items={{+ yesIfNeedBeNo: (+ <VoteOptionLabel types={["yes", "ifNeedBe", "no"]} />+ ),+ yesNo: <VoteOptionLabel types={["yes", "no"]} />,+ }}+ disabled={isLocked}+ value={field.value ? "yesIfNeedBeNo" : "yesNo"}+ onValueChange={(value) => {+ if (!value) {+ return;+ }+ const allowTentativeVotes = value === "yesIfNeedBeNo";+ field.onChange(allowTentativeVotes);+ posthog?.capture("poll_settings:vote_options_change", {+ allow_tentative_votes: allowTentativeVotes,+ });+ }}+ >+ <SelectTrigger id="vote-options">+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ <SelectItem value="yesIfNeedBeNo">+ <VoteOptionLabel types={["yes", "ifNeedBe", "no"]} />+ </SelectItem>+ <SelectItem value="yesNo">+ <VoteOptionLabel types={["yes", "no"]} />+ </SelectItem>+ </SelectContent>+ </Select>+ </div>+ </Field>+ );+ }}+ /></FieldGroup></CardContent>{children}diff --git a/apps/web/src/features/poll/components/forms/types.ts b/apps/web/src/features/poll/components/forms/types.tsindex 7b82fe874..abe12928b 100644--- a/apps/web/src/features/poll/components/forms/types.ts+++ b/apps/web/src/features/poll/components/forms/types.ts@@ -21,6 +21,7 @@ export type PollSettingsFormData = {hideParticipants: boolean;hideScores: boolean;enableComments: boolean;+ allowTentativeVotes: boolean;};export type NewEventData = PollDetailsData &diff --git a/apps/web/src/features/poll/components/manage-poll/schedule-poll-dialog.tsx b/apps/web/src/features/poll/components/manage-poll/schedule-poll-dialog.tsxindex d9ea617c4..bd7a15776 100644--- a/apps/web/src/features/poll/components/manage-poll/schedule-poll-dialog.tsx+++ b/apps/web/src/features/poll/components/manage-poll/schedule-poll-dialog.tsx@@ -198,6 +198,7 @@ export const SchedulePollForm = ({<VoteSummaryProgressBar{...scoreByOptionId[option.id]}total={participants.length}+ showTentative={poll.allowTentativeVotes}/></div></div>diff --git a/apps/web/src/features/poll/components/mobile-poll/poll-option.tsx b/apps/web/src/features/poll/components/mobile-poll/poll-option.tsxindex 6a620e21f..655cc6cc0 100644--- a/apps/web/src/features/poll/components/mobile-poll/poll-option.tsx+++ b/apps/web/src/features/poll/components/mobile-poll/poll-option.tsx@@ -34,6 +34,8 @@ export interface PollOptionProps {selectedParticipantId?: string;optionId: string;optionLabel: string;+ /** When false the segmented control offers yes and no only. */+ allowTentativeVotes?: boolean;}const PollOptionVoteSummary: React.FunctionComponent<{ optionId: string }> = ({@@ -88,6 +90,7 @@ const PollOption: React.FunctionComponent<PollOptionProps> = ({optionLabel,yesScore,ifNeedBeScore,+ allowTentativeVotes = true,}) => {const { t } = useTranslation();const dialog = useDialog();@@ -98,7 +101,10 @@ const PollOption: React.FunctionComponent<PollOptionProps> = ({<divclassName={cn("grid h-14 items-center px-2 text-left transition-[grid-template-columns] duration-300",- editable && "grid-cols-[0rem_1fr_3.5rem_8.875rem]",+ editable &&+ (allowTentativeVotes+ ? "grid-cols-[0rem_1fr_3.5rem_8.875rem]"+ : "grid-cols-[0rem_1fr_3.5rem_6.125rem]"),showVote && "grid-cols-[1.875rem_1fr_3.5rem_0rem]",!editable && !showVote && "grid-cols-[0rem_1fr_3.5rem_0rem]",)}@@ -114,11 +120,18 @@ const PollOption: React.FunctionComponent<PollOptionProps> = ({<IfScoresVisible><Button{...dialog.triggerProps}- aria-label={`${t("optionVoteBreakdown", {- defaultValue: "{yesScore} yes, {ifNeedBeScore} if need be",- yesScore,- ifNeedBeScore,- })}. ${t("showParticipantVotes", {+ aria-label={`${+ allowTentativeVotes+ ? t("optionVoteBreakdown", {+ defaultValue: "{yesScore} yes, {ifNeedBeScore} if need be",+ yesScore,+ ifNeedBeScore,+ })+ : t("optionVoteBreakdownYesOnly", {+ defaultValue: "{yesScore} yes",+ yesScore,+ })+ }. ${t("showParticipantVotes", {defaultValue: "Show participant votes",})}`}variant="ghost"@@ -150,6 +163,7 @@ const PollOption: React.FunctionComponent<PollOptionProps> = ({value={vote}onChange={onChange}optionLabel={optionLabel}+ allowTentativeVotes={allowTentativeVotes}/></m.div>) : null}diff --git a/apps/web/src/features/poll/components/mobile-poll/poll-options.tsx b/apps/web/src/features/poll/components/mobile-poll/poll-options.tsxindex 54b286316..13338192d 100644--- a/apps/web/src/features/poll/components/mobile-poll/poll-options.tsx+++ b/apps/web/src/features/poll/components/mobile-poll/poll-options.tsx@@ -21,7 +21,7 @@ const PollOptions: React.FunctionComponent<PollOptions> = ({selectedParticipantId,}) => {const { control } = useVotingForm();- const { getScore, getVote, optionIds } = usePoll();+ const { getScore, getVote, optionIds, poll } = usePoll();const { participants: allParticipants } = useParticipants();const selectedParticipant = selectedParticipantId? allParticipants.find(@@ -63,6 +63,7 @@ const PollOptions: React.FunctionComponent<PollOptions> = ({return (<TimeSlotOptiononChange={handleChange}+ allowTentativeVotes={poll.allowTentativeVotes}optionId={option.optionId}optionLabel={getOptionDateTimeLabel(option)}yesScore={score.yes}@@ -79,6 +80,7 @@ const PollOptions: React.FunctionComponent<PollOptions> = ({return (<DateOptiononChange={handleChange}+ allowTentativeVotes={poll.allowTentativeVotes}optionId={option.optionId}optionLabel={getOptionDateTimeLabel(option)}yesScore={score.yes}diff --git a/apps/web/src/features/poll/components/score-summary.tsx b/apps/web/src/features/poll/components/score-summary.tsxindex 77fc873a6..0db3d6248 100644--- a/apps/web/src/features/poll/components/score-summary.tsx+++ b/apps/web/src/features/poll/components/score-summary.tsx@@ -12,12 +12,17 @@ export interface PopularityScoreProps {ifNeedBeScore?: number;highlight?: boolean;highScore: number;+ /**+ * When false the amber tentative marker is dropped. Tentative votes cast+ * before the poll turned the option off still count toward the total.+ */+ showTentative?: boolean;}export const ConnectedScoreSummary: React.FunctionComponent<{optionId: string;}> = ({ optionId }) => {- const { getScore, highScore } = usePoll();+ const { getScore, highScore, poll } = usePoll();const { yes, ifNeedBe } = getScore(optionId);const score = yes + ifNeedBe;const highlight = score === highScore && score > 1;@@ -28,6 +33,7 @@ export const ConnectedScoreSummary: React.FunctionComponent<{ifNeedBeScore={ifNeedBe}highScore={highScore}highlight={highlight}+ showTentative={poll.allowTentativeVotes}/></IfScoresVisible>);@@ -65,6 +71,7 @@ const ScoreSummary: React.FunctionComponent<PopularityScoreProps> = React.memo(ifNeedBeScore = 0,highlight,highScore,+ showTentative = true,}) {const score = yesScore + ifNeedBeScore;@@ -82,7 +89,7 @@ const ScoreSummary: React.FunctionComponent<PopularityScoreProps> = React.memo(><User2Icon className="size-4 opacity-75" /><AnimatedNumber score={score} />- {highlight ? (+ {highlight && showTentative ? (ifNeedBeScore > 0 ? (<span className="inline-block size-1.5 rounded-full bg-amber-400" />) : nulldiff --git a/apps/web/src/features/poll/components/vote-segmented-control.tsx b/apps/web/src/features/poll/components/vote-segmented-control.tsxindex da4651e2a..1f14d0059 100644--- a/apps/web/src/features/poll/components/vote-segmented-control.tsx+++ b/apps/web/src/features/poll/components/vote-segmented-control.tsx@@ -5,23 +5,25 @@ import {SegmentedControlItem,} from "@rallly/ui/segmented-control";+import { getVoteTypes } from "@/features/poll/constants";import { useTranslation } from "@/i18n/client";import VoteIcon from "./vote-icon";type VoteType = "yes" | "ifNeedBe" | "no";-const voteTypes: VoteType[] = ["yes", "ifNeedBe", "no"];-export const VoteSegmentedControl = ({value,onChange,optionLabel,+ allowTentativeVotes = true,className,}: {value?: VoteType;onChange: (value: VoteType) => void;className?: string;+ /** When false only yes and no are offered. */+ allowTentativeVotes?: boolean;/*** Accessible description of the option being voted on (e.g. "Tue 30 Jun* 2026, 1:00 PM – 2:00 PM") so screen readers can tie the vote to its@@ -30,6 +32,7 @@ export const VoteSegmentedControl = ({optionLabel?: string;}) => {const { t } = useTranslation();+ const voteTypes = getVoteTypes(allowTentativeVotes);const voteLabels: Record<VoteType, string> = {yes: t("yes", { defaultValue: "Yes" }),diff --git a/apps/web/src/features/poll/components/vote-selector.tsx b/apps/web/src/features/poll/components/vote-selector.tsxindex 11176256e..d1677ac5c 100644--- a/apps/web/src/features/poll/components/vote-selector.tsx+++ b/apps/web/src/features/poll/components/vote-selector.tsx@@ -2,6 +2,7 @@ import type { VoteType } from "@rallly/database";import { buttonVariants, cn } from "@rallly/ui";import * as React from "react";+import { getVoteTypes } from "@/features/poll/constants";import { useTranslation } from "@/i18n/client";import VoteIcon from "./vote-icon";@@ -18,23 +19,39 @@ export interface VoteSelectorProps {onFocus?: React.FocusEventHandler<HTMLButtonElement>;onBlur?: React.FocusEventHandler<HTMLButtonElement>;onKeyDown?: React.KeyboardEventHandler<HTMLButtonElement>;+ /**+ * When false the tentative vote is dropped from the cycle, so clicking+ * alternates yes → no.+ */+ allowTentativeVotes?: boolean;className?: string;}-const orderedVoteTypes: VoteType[] = ["yes", "ifNeedBe", "no"];--export const toggleVote = (value?: VoteType) => {+export const toggleVote = (value?: VoteType, allowTentativeVotes = true) => {+ const orderedVoteTypes = getVoteTypes(allowTentativeVotes);if (!value) return orderedVoteTypes[0];- return orderedVoteTypes[- (orderedVoteTypes.indexOf(value) + 1) % orderedVoteTypes.length- ];+ const index = orderedVoteTypes.indexOf(value);+ // A vote cast before the tentative option was turned off is not in the+ // cycle; advancing from it starts over rather than landing on -1 + 1 = 0+ // by coincidence.+ if (index === -1) return orderedVoteTypes[0];+ return orderedVoteTypes[(index + 1) % orderedVoteTypes.length];};export const VoteSelector = React.forwardRef<HTMLButtonElement,VoteSelectorProps>(function VoteSelector(- { value, optionLabel, onChange, onFocus, onBlur, onKeyDown, className },+ {+ value,+ optionLabel,+ onChange,+ onFocus,+ onBlur,+ onKeyDown,+ allowTentativeVotes = true,+ className,+ },ref,) {const { t } = useTranslation();@@ -74,7 +91,7 @@ export const VoteSelector = React.forwardRef<className,)}onClick={() => {- onChange?.(value ? toggleVote(value) : orderedVoteTypes[0]);+ onChange?.(toggleVote(value, allowTentativeVotes));}}ref={ref}>diff --git a/apps/web/src/features/poll/components/vote-summary-progress-bar.tsx b/apps/web/src/features/poll/components/vote-summary-progress-bar.tsxindex ec466c5f5..36daf706b 100644--- a/apps/web/src/features/poll/components/vote-summary-progress-bar.tsx+++ b/apps/web/src/features/poll/components/vote-summary-progress-bar.tsx@@ -25,7 +25,16 @@ export const VoteSummaryProgressBar = (props: {yes: string[];ifNeedBe: string[];no: string[];+ /**+ * When false the tentative segment is dropped. A poll that turned the option+ * off after tentative votes were cast still has them, so the segment is kept+ * whenever there are any to show.+ */+ showTentative?: boolean;}) => {+ const showTentative =+ props.showTentative !== false || props.ifNeedBe.length > 0;+return (<div className="flex h-1.5 grow overflow-hidden rounded-sm bg-muted"><Tooltip>@@ -43,21 +52,23 @@ export const VoteSummaryProgressBar = (props: {<ListNames participantIds={props.yes} /></TooltipContent></Tooltip>- <Tooltip>- <TooltipTrigger- render={- <div- className="h-full bg-amber-400 opacity-75 hover:opacity-100"- style={{- width: `${(props.ifNeedBe.length / props.total) * 100}%`,- }}- />- }- />- <TooltipContent side="bottom">- <ListNames participantIds={props.ifNeedBe} />- </TooltipContent>- </Tooltip>+ {showTentative ? (+ <Tooltip>+ <TooltipTrigger+ render={+ <div+ className="h-full bg-amber-400 opacity-75 hover:opacity-100"+ style={{+ width: `${(props.ifNeedBe.length / props.total) * 100}%`,+ }}+ />+ }+ />+ <TooltipContent side="bottom">+ <ListNames participantIds={props.ifNeedBe} />+ </TooltipContent>+ </Tooltip>+ ) : null}<Tooltip><TooltipTriggerrender={diff --git a/apps/web/src/features/poll/constants.ts b/apps/web/src/features/poll/constants.tsindex b29c1aed1..9bc852347 100644--- a/apps/web/src/features/poll/constants.ts+++ b/apps/web/src/features/poll/constants.ts@@ -3,6 +3,18 @@ export const MAX_POLL_OPTIONS = 100;// Display order of the built-in vote types.export const VOTE_TYPES = ["yes", "ifNeedBe", "no"] as const;+export type VoteType = (typeof VOTE_TYPES)[number];++const YES_NO_VOTE_TYPES = ["yes", "no"] as const;++// The vote types a poll offers. Dropping the tentative option leaves a plain+// yes/no poll; existing "ifNeedBe" votes cast before the option was turned off+// are unaffected and still render.+export const getVoteTypes = (+ allowTentativeVotes: boolean,+): readonly VoteType[] =>+ allowTentativeVotes ? VOTE_TYPES : YES_NO_VOTE_TYPES;+// Flashed by the create page with the new poll's id; the poll page opens// the Share dialog when it matches.export const SHARE_POLL_FLASH_KEY = "share-poll";diff --git a/apps/web/src/features/poll/data.ts b/apps/web/src/features/poll/data.tsindex fb224e24d..c1a3cb2a5 100644--- a/apps/web/src/features/poll/data.ts+++ b/apps/web/src/features/poll/data.ts@@ -223,6 +223,7 @@ export async function listPolls({hideParticipants: true,hideScores: true,disableComments: true,+ allowTentativeVotes: true,user: {select: {id: true,@@ -553,6 +554,7 @@ export async function getPollWithOptions({hideParticipants: true,hideScores: true,disableComments: true,+ allowTentativeVotes: true,user: {select: {id: true,diff --git a/apps/web/src/features/poll/mutations.ts b/apps/web/src/features/poll/mutations.tsindex 4fc24c231..78fe3648f 100644--- a/apps/web/src/features/poll/mutations.ts+++ b/apps/web/src/features/poll/mutations.ts@@ -21,6 +21,7 @@ export type CreatePollParams = {hideParticipants?: boolean;hideScores?: boolean;disableComments?: boolean;+ allowTentativeVotes?: boolean;options: PollOption[];spaceId: AuthorizedSpaceId;};@@ -41,6 +42,7 @@ const pollResponseSelect = {hideParticipants: true,hideScores: true,disableComments: true,+ allowTentativeVotes: true,user: {select: {id: true,@@ -81,6 +83,7 @@ export const createPoll = async ({hideParticipants,hideScores,disableComments,+ allowTentativeVotes,options,spaceId,}: CreatePollParams) => {@@ -98,6 +101,7 @@ export const createPoll = async ({hideParticipants,hideScores,disableComments,+ allowTentativeVotes,userId,spaceId,kind,diff --git a/apps/web/src/trpc/client/types.ts b/apps/web/src/trpc/client/types.tsindex 679ff232a..ca74755b1 100644--- a/apps/web/src/trpc/client/types.ts+++ b/apps/web/src/trpc/client/types.ts@@ -13,6 +13,7 @@ export type GetPollApiResponse = {banned: boolean;} | null;timeZone: string | null;+ allowTentativeVotes: boolean;canManage: boolean;status: PollStatus;createdAt: Date;diff --git a/apps/web/src/trpc/routers/polls.ts b/apps/web/src/trpc/routers/polls.tsindex 2f09dc508..f41d18a2d 100644--- a/apps/web/src/trpc/routers/polls.ts+++ b/apps/web/src/trpc/routers/polls.ts@@ -107,6 +107,7 @@ export const polls = router({hideParticipants: z.boolean().optional(),hideScores: z.boolean().optional(),disableComments: z.boolean().optional(),+ allowTentativeVotes: z.boolean().optional(),requireParticipantEmail: z.boolean().optional(),options: z.object({@@ -212,6 +213,7 @@ export const polls = router({},hideParticipants: input.hideParticipants,disableComments: input.disableComments,+ allowTentativeVotes: input.allowTentativeVotes,hideScores: input.hideScores,requireParticipantEmail: input.requireParticipantEmail,spaceId,@@ -286,6 +288,7 @@ export const polls = router({hasDescription: !!description,timezone: input.timeZone,disableComments: poll.disableComments,+ allowTentativeVotes: poll.allowTentativeVotes,hideParticipants: poll.hideParticipants,hideScores: poll.hideScores,requireParticipantEmail: poll.requireParticipantEmail,@@ -316,6 +319,7 @@ export const polls = router({optionsToAdd: z.string().array().optional(),hideParticipants: z.boolean().optional(),disableComments: z.boolean().optional(),+ allowTentativeVotes: z.boolean().optional(),hideScores: z.boolean().optional(),requireParticipantEmail: z.boolean().optional(),}),@@ -401,6 +405,7 @@ export const polls = router({hideParticipants: true,hideScores: true,disableComments: true,+ allowTentativeVotes: true,requireParticipantEmail: true,},});@@ -409,6 +414,32 @@ export const polls = router({throw new TRPCError({ code: "NOT_FOUND" });}+ // Turning the tentative option off would strand votes already cast as+ // "if need be": they stay valid and visible, but their owner could no+ // longer re-save that response, since the vote type is then rejected.+ // Locked only in that direction and only when such votes exist, so a+ // poll whose responses are all yes/no can still be switched, and an+ // organizer who turned it off can always turn it back on.+ if (input.allowTentativeVotes === false && prior.allowTentativeVotes) {+ // Take the same row lock the vote writes take, so a tentative vote+ // committing concurrently either lands before this count sees it or+ // waits and then fails its own check. Without the lock, READ+ // COMMITTED lets one slip in between the count and the update.+ await tx.$queryRaw`SELECT id FROM polls WHERE id = ${pollId} FOR UPDATE`;++ const tentativeVoteCount = await tx.vote.count({+ where: { pollId, type: "ifNeedBe" },+ });++ if (tentativeVoteCount > 0) {+ throw new TRPCError({+ code: "BAD_REQUEST",+ message:+ "Tentative votes cannot be turned off once participants have used them",+ });+ }+ }+// Reopen an auto-closed poll when new future dates are added. Manually// closed polls stay closed — that was the organizer's decision. The// transition is conditional so concurrent modifies can't both record@@ -485,6 +516,7 @@ export const polls = router({hideScores: input.hideScores,hideParticipants: input.hideParticipants,disableComments: input.disableComments,+ allowTentativeVotes: input.allowTentativeVotes,requireParticipantEmail: input.requireParticipantEmail,kind,},@@ -512,6 +544,8 @@ export const polls = router({input.hideParticipants !== prior.hideParticipants) ||(input.disableComments !== undefined &&input.disableComments !== prior.disableComments) ||+ (input.allowTentativeVotes !== undefined &&+ input.allowTentativeVotes !== prior.allowTentativeVotes) ||(input.hideScores !== undefined &&input.hideScores !== prior.hideScores) ||(input.requireParticipantEmail !== undefined &&@@ -572,6 +606,7 @@ export const polls = router({location: true,description: true,disableComments: true,+ allowTentativeVotes: true,requireParticipantEmail: true,hideParticipants: true,hideScores: true,@@ -622,6 +657,7 @@ export const polls = router({input.timeZone !== undefined ||input.hideParticipants !== undefined ||input.disableComments !== undefined ||+ input.allowTentativeVotes !== undefined ||input.hideScores !== undefined ||input.requireParticipantEmail !== undefined;@@ -657,6 +693,7 @@ export const polls = router({event: "poll_update_settings",properties: {disable_comments: !!updatedPoll.disableComments,+ allow_tentative_votes: !!updatedPoll.allowTentativeVotes,hide_participants: !!updatedPoll.hideParticipants,hide_scores: !!updatedPoll.hideScores,require_participant_email: !!updatedPoll.requireParticipantEmail,@@ -719,6 +756,7 @@ export const polls = router({closedReason: true,hideParticipants: true,disableComments: true,+ allowTentativeVotes: true,hideScores: true,requireParticipantEmail: true,options: {@@ -1356,6 +1394,7 @@ export const polls = router({hideScores: true,requireParticipantEmail: true,disableComments: true,+ allowTentativeVotes: true,spaceId: true,kind: true,options: {@@ -1388,6 +1427,7 @@ export const polls = router({hideParticipants: poll.hideParticipants,hideScores: poll.hideScores,disableComments: poll.disableComments,+ allowTentativeVotes: poll.allowTentativeVotes,kind: poll.kind,options: {create: poll.options,diff --git a/apps/web/src/trpc/routers/polls/participants.ts b/apps/web/src/trpc/routers/polls/participants.tsindex f11a18e07..fd0564f26 100644--- a/apps/web/src/trpc/routers/polls/participants.ts+++ b/apps/web/src/trpc/routers/polls/participants.ts@@ -1,4 +1,4 @@-import type { Participant, VoteType } from "@rallly/database";+import type { Participant, Prisma, VoteType } from "@rallly/database";import { prisma } from "@rallly/database";import { sendNewParticipantEmail } from "@rallly/emails/templates/new-participant";import { sendNewParticipantConfirmationEmail } from "@rallly/emails/templates/new-participant-confirmation";@@ -108,6 +108,37 @@ async function sendNewResponseNotificationEmail({}}+/**+ * Rejects new tentative votes when the poll no longer allows them, locking the+ * poll row for the rest of the transaction.+ *+ * The check runs inside the writing transaction and takes a lock the+ * organizer's disable transition also takes. Under READ COMMITTED a plain read+ * would let a vote that passed an earlier check land after the organizer had+ * already counted zero tentative votes, stranding one on a poll that no longer+ * accepts them.+ */+const assertTentativeVotesAllowed = async (+ tx: Prisma.TransactionClient,+ pollId: string,+ votes: { type: VoteType }[],+) => {+ if (!votes.some((vote) => vote.type === "ifNeedBe")) {+ return;+ }++ const [poll] = await tx.$queryRaw<{ allow_tentative_votes: boolean }[]>`+ SELECT allow_tentative_votes FROM polls WHERE id = ${pollId} FOR UPDATE+ `;++ if (!poll?.allow_tentative_votes) {+ throw new TRPCError({+ code: "BAD_REQUEST",+ message: "This poll does not accept tentative votes",+ });+ }+};+export const participants = router({list: publicProcedure.input(@@ -311,7 +342,10 @@ export const participants = router({}) => {const poll = await prisma.poll.findUnique({where: { id: pollId },- select: { status: true, deleted: true },+ select: {+ status: true,+ deleted: true,+ },});// A deleted poll never accepts responses.@@ -366,6 +400,8 @@ export const participants = router({const { participant, editToken, viaInvite } = await prisma.$transaction(async (tx) => {+ await assertTentativeVotesAllowed(tx, pollId, validVotes);+// A response answering an emailed invite takes the invite's// token, so the link the invitee already holds names it.const invite = token@@ -409,6 +445,7 @@ export const participants = router({select: {id: true,title: true,+ allowTentativeVotes: true,space: {select: {id: true,@@ -478,6 +515,14 @@ export const participants = router({}),);+ const voteCounts = validVotes.reduce(+ (acc, { type }) => {+ acc[type] += 1;+ return acc;+ },+ { yes: 0, ifNeedBe: 0, no: 0 },+ );+track(ctx.user, {event: "poll_response_submit",properties: {@@ -492,6 +537,12 @@ export const participants = router({has_note: !!participant.note,note_length: participant.note?.length,total_responses: totalResponses,+ // Whether the tentative option is offered at all, so the counts+ // below can be read against the polls that actually had it.+ allow_tentative_votes: participant.poll.allowTentativeVotes,+ yes_count: voteCounts.yes,+ if_need_be_count: voteCounts.ifNeedBe,+ no_count: voteCounts.no,},groups: {poll: pollId,@@ -563,6 +614,8 @@ export const participants = router({const pollId = existingParticipant.pollId;const participant = await prisma.$transaction(async (tx) => {+ await assertTentativeVotesAllowed(tx, pollId, votes);+// Delete existing votesawait tx.vote.deleteMany({where: {diff --git a/packages/database/prisma/migrations/20260910120000_add_allow_tentative_votes/migration.sql b/packages/database/prisma/migrations/20260910120000_add_allow_tentative_votes/migration.sqlnew file mode 100644index 000000000..1bacba998--- /dev/null+++ b/packages/database/prisma/migrations/20260910120000_add_allow_tentative_votes/migration.sql@@ -0,0 +1,11 @@+-- Lets an organizer run a plain yes/no poll by turning off the tentative+-- "if need be" vote.+--+-- Stored as a positive flag rather than `disable_tentative_votes` so that a+-- later expansion of the vote types adds a column instead of inverting a+-- negative one.+--+-- Defaults to true so every existing poll keeps all three vote states. Turning+-- it off is forward-only: existing tentative votes are kept and stay visible,+-- the flag only stops new ones being cast.+ALTER TABLE "polls" ADD COLUMN "allow_tentative_votes" BOOLEAN NOT NULL DEFAULT true;diff --git a/packages/database/prisma/models/poll.prisma b/packages/database/prisma/models/poll.prismaindex 8792154e1..47dfb5532 100644--- a/packages/database/prisma/models/poll.prisma+++ b/packages/database/prisma/models/poll.prisma@@ -50,6 +50,11 @@ model Poll {hideScores Boolean @default(false) @map("hide_scores")disableComments Boolean @default(true) @map("disable_comments")requireParticipantEmail Boolean @default(false) @map("require_participant_email")+ /// Whether participants may cast the tentative "if need be" vote. Positive+ /// flag so a future vote-type expansion adds columns rather than inverting a+ /// negative. Turning it off only blocks new tentative votes; existing ones+ /// are kept and stay visible.+ allowTentativeVotes Boolean @default(true) @map("allow_tentative_votes")muted Boolean @default(false)user User? @relation(fields: [userId], references: [id], onDelete: Cascade)