Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(forms): remove the show results option from polls (#9627)
Wolf Mermelstein8a17d5bec554
diff --git a/apps/web/src/features/block-form/components/poll/poll-bars.tsx b/apps/web/src/features/block-form/components/poll/poll-bars.tsxindex 7561f18142..5247146dbc 100644--- a/apps/web/src/features/block-form/components/poll/poll-bars.tsx+++ b/apps/web/src/features/block-form/components/poll/poll-bars.tsx@@ -25,7 +25,7 @@ function moveFocus(event: KeyboardEvent, list: HTMLElement | null) {/*** A poll's options as bars: each is the vote button for that option, with- * its count when results show. The viewer's own vote is marked.+ * its count once the tally loads. The viewer's own vote is marked.*/export function PollBars(props: {question: string;@@ -38,7 +38,7 @@ export function PollBars(props: {/** Keep keyboard focus while saving, and reject repeated votes. */pending?: boolean;summary: string;- /** What shows instead of the summary while counts aren't shown. */+ /** What shows instead of the summary until the counts load. */hiddenNote: string;onVote: (optionId: string) => void;/** The results door: `expanded` when it shows them in place. */diff --git a/apps/web/src/features/block-form/components/poll/poll-composer.test.tsx b/apps/web/src/features/block-form/components/poll/poll-composer.test.tsxindex 8763894f24..32a253bda1 100644--- a/apps/web/src/features/block-form/components/poll/poll-composer.test.tsx+++ b/apps/web/src/features/block-form/components/poll/poll-composer.test.tsx@@ -25,6 +25,7 @@ describe('PollComposer', () => {screen.getByRole<HTMLButtonElement>('button', { name: 'Post poll' }).disabled).toBe(true);+ expect(screen.queryByText(/show results/i)).toBeNull();fireEvent.input(screen.getByLabelText('Question'), {target: { value: 'Where should we meet?' },});@@ -42,7 +43,6 @@ describe('PollComposer', () => {target: { value: 'Online' },});fireEvent.click(screen.getByLabelText('Multiple answers'));- fireEvent.click(screen.getByLabelText('Show results to respondents'));fireEvent.click(screen.getByLabelText('Share responses with team'));fireEvent.click(screen.getByLabelText('Anonymous'));fireEvent.submit(screen.getByRole('form', { name: 'New poll' }));@@ -50,7 +50,6 @@ describe('PollComposer', () => {question: 'Where should we meet?',options: ['Office', 'Cafe', 'Online'],multi: true,- showResults: false,shareResponses: true,anonymous: true,});diff --git a/apps/web/src/features/block-form/components/poll/poll-composer.tsx b/apps/web/src/features/block-form/components/poll/poll-composer.tsxindex 504c58cc73..c2485c0b96 100644--- a/apps/web/src/features/block-form/components/poll/poll-composer.tsx+++ b/apps/web/src/features/block-form/components/poll/poll-composer.tsx@@ -9,15 +9,13 @@ export type PollComposerDraft = {question: string;options: string[];multi: boolean;- showResults: boolean;shareResponses: boolean;anonymous: boolean;};/*** The `/poll` composer: a question, two options to start with and Add- * option, Multiple answers, Show results to respondents (on by default),- * Share responses with team, and Anonymous.+ * option, Multiple answers, Share responses with team, and Anonymous.*/export function PollComposer(props: {pending: boolean;@@ -28,7 +26,6 @@ export function PollComposer(props: {const [question, setQuestion] = createSignal('');const [options, setOptions] = createSignal(['', '']);const [multi, setMulti] = createSignal(false);- const [showResults, setShowResults] = createSignal(true);const [shareResponses, setShareResponses] = createSignal(false);const [anonymous, setAnonymous] = createSignal(false);const optionInputs: HTMLInputElement[] = [];@@ -50,7 +47,6 @@ export function PollComposer(props: {question: question(),options: options(),multi: multi(),- showResults: showResults(),shareResponses: shareResponses(),anonymous: anonymous(),});@@ -145,19 +141,6 @@ export function PollComposer(props: {<Checkbox.Control /><Checkbox.Label class="text-sm">Multiple answers</Checkbox.Label></Checkbox>- <div class="flex flex-col gap-1.5">- <Checkbox checked={showResults()} onChange={setShowResults}>- <Checkbox.Control />- <Checkbox.Label class="text-sm">- Show results to respondents- </Checkbox.Label>- </Checkbox>- <p class="pl-6 text-xs leading-5 text-ink-muted">- {showResults()- ? 'Voters can see the counts before and after voting.'- : 'Only you and other editors can see the counts.'}- </p>- </div><div class="flex flex-col gap-1.5"><Checkbox checked={shareResponses()} onChange={setShareResponses}><Checkbox.Control />diff --git a/apps/web/src/features/block-form/context/form-context.tsx b/apps/web/src/features/block-form/context/form-context.tsxindex 2ce9f3941d..0d57218db4 100644--- a/apps/web/src/features/block-form/context/form-context.tsx+++ b/apps/web/src/features/block-form/context/form-context.tsx@@ -181,7 +181,6 @@ export type FormMetadataPatch = {audience?: FormAudience;status?: FormStatus;closesAt?: string | null;- tallyVisible?: boolean;responsesVisible?: boolean;anonymous?: boolean;/** A static file id, or `null` to remove it. */@@ -365,10 +364,7 @@ export type FormContext = {formId: Accessor<string>,enabled: Accessor<boolean>) => ReadSource<ResponseCounts>;- createTally: (- formId: Accessor<string>,- enabled: Accessor<boolean>- ) => ReadSource<QuestionTally[]>;+ createTally: (formId: Accessor<string>) => ReadSource<QuestionTally[]>;/** People in the channels a form was posted to, its owner excluded. */createInvited: (formId: Accessor<string>,diff --git a/apps/web/src/features/block-form/queries/form-sources.test.ts b/apps/web/src/features/block-form/queries/form-sources.test.tsindex 93e9836b3e..99cf60a04f 100644--- a/apps/web/src/features/block-form/queries/form-sources.test.ts+++ b/apps/web/src/features/block-form/queries/form-sources.test.ts@@ -229,10 +229,7 @@ describe('createTallySource', () => {{ value: { kind: 'option', option: 'option-1' }, count: 1 },{ value: JSON.parse('{"kind":"rating","stars":5}'), count: 1 },];- const source = createTallySource(- () => 'form-1',- () => true- );+ const source = createTallySource(() => 'form-1');expect(source.value()).toEqual([{questionId: 'question-1',diff --git a/apps/web/src/features/block-form/queries/form-sources.ts b/apps/web/src/features/block-form/queries/form-sources.tsindex 0e49a0be79..d94628c2f9 100644--- a/apps/web/src/features/block-form/queries/form-sources.ts+++ b/apps/web/src/features/block-form/queries/form-sources.ts@@ -269,10 +269,9 @@ export function createSummarySource(}export function createTallySource(- formId: Accessor<string>,- enabled: Accessor<boolean>+ formId: Accessor<string>): ReadSource<QuestionTally[]> {- const query = useTallyQuery(() => formId() || undefined, enabled);+ const query = useTallyQuery(() => formId() || undefined);return {value: () =>query.isSuccessdiff --git a/apps/web/src/features/block-form/queries/publish-poll.test.ts b/apps/web/src/features/block-form/queries/publish-poll.test.tsindex ea86eb4253..7ce11e564e 100644--- a/apps/web/src/features/block-form/queries/publish-poll.test.ts+++ b/apps/web/src/features/block-form/queries/publish-poll.test.ts@@ -37,7 +37,6 @@ const draft = {question: 'Lunch?',options: ['Pizza', 'Salad'],multi: false,- showResults: true,shareResponses: false,anonymous: false,};@@ -97,7 +96,6 @@ it('creates an anonymous poll anonymous and patches tally and shared responses aquestion: 'Lunch?',options: ['Pizza', 'Salad'],multi: false,- showResults: false,shareResponses: true,anonymous: true,},@@ -112,7 +110,7 @@ it('creates an anonymous poll anonymous and patches tally and shared responses a'poll');expect(storage.updateForm).toHaveBeenCalledWith('form-1', {- tallyVisible: false,+ tallyVisible: true,responsesVisible: true,});});@@ -123,7 +121,6 @@ it('rejects duplicate options without creating a form or silently dropping a choquestion: 'Lunch?',options: ['Pizza', ' pizza ', 'Salad'],multi: false,- showResults: true,shareResponses: false,anonymous: false,},diff --git a/apps/web/src/features/block-form/queries/publish-poll.ts b/apps/web/src/features/block-form/queries/publish-poll.tsindex fbfe50facd..0a74df02bc 100644--- a/apps/web/src/features/block-form/queries/publish-poll.ts+++ b/apps/web/src/features/block-form/queries/publish-poll.ts@@ -1,9 +1,9 @@/*** `/poll` (RFC 03 §3): a poll is a form with one required choice question.* Create the form (and its database), add the Select column with the options- * under ids minted here, place it as the only question, and set whether- * respondents see the results. An anonymous poll is anonymous from creation,- * so its table never gets a Respondent column.+ * under ids minted here, place it as the only question, and show its results+ * to respondents. An anonymous poll is anonymous from creation, so its table+ * never gets a Respondent column.*/import { createDatabaseColumn } from '@block-database/queries/columns';import { createForm, putFormLayout, updateForm } from '@queries/storage/forms';@@ -19,7 +19,6 @@ export type PollDraft = {question: string;options: string[];multi: boolean;- showResults: boolean;shareResponses: boolean;anonymous: boolean;};@@ -108,7 +107,7 @@ export function publishPoll().andThen(() =>updateForm(formId, {- tallyVisible: draft.showResults,+ tallyVisible: true,responsesVisible: draft.shareResponses,}).mapErr(writeFailureOf))diff --git a/apps/web/src/features/block-form/views/form-card-view.test.tsx b/apps/web/src/features/block-form/views/form-card-view.test.tsxindex 6866ace8bc..994ab6b41b 100644--- a/apps/web/src/features/block-form/views/form-card-view.test.tsx+++ b/apps/web/src/features/block-form/views/form-card-view.test.tsx@@ -168,10 +168,7 @@ describe('FormCardView poll', () => {it('expands Results in place when the voters arrive after the card first renders', () => {const [loaded, setLoaded] = createSignal(false);- const named = tallyOf(namedVoters)(- () => 'poll-1',- () => true- );+ const named = tallyOf(namedVoters)(() => 'poll-1');const late: FormContext['responses']['createTally'] = () => ({value: () => (loaded() ? named.value() : undefined),failure: () => undefined,diff --git a/apps/web/src/features/block-form/views/form-card-view.tsx b/apps/web/src/features/block-form/views/form-card-view.tsxindex 96e49c58e3..ead99b90bd 100644--- a/apps/web/src/features/block-form/views/form-card-view.tsx+++ b/apps/web/src/features/block-form/views/form-card-view.tsx@@ -30,10 +30,7 @@ function PollCardBody(props: {formAvailability(props.detail.form, props.detail.tableGone, new Date());const open = () => availability().kind === 'open';const mine = context.responses.createMine(() => props.detail.form.id);- const tally = context.responses.createTally(- () => props.detail.form.id,- () => props.detail.form.tallyVisible || isEditor()- );+ const tally = context.responses.createTally(() => props.detail.form.id);const voting = createPollVoting({poll: () => props.poll,anonymous: () => props.detail.form.anonymous,@@ -57,11 +54,7 @@ function PollCardBody(props: {pending={voting.pending()}summary={voting.summary()}hiddenNote={- tally.failure()- ? 'Results couldn’t be loaded.'- : props.detail.form.tallyVisible || isEditor()- ? 'Loading results…'- : 'Only the poll’s editors see the counts.'+ tally.failure() ? 'Results couldn’t be loaded.' : 'Loading results…'}onVote={(optionId) =>fireAndForget(voting.vote(optionId), 'poll-voting')diff --git a/apps/web/src/features/block-form/views/share-tab-view.tsx b/apps/web/src/features/block-form/views/share-tab-view.tsxindex 6e9d966302..2d24ca027e 100644--- a/apps/web/src/features/block-form/views/share-tab-view.tsx+++ b/apps/web/src/features/block-form/views/share-tab-view.tsx@@ -165,19 +165,6 @@ export function ShareTabView(props: {</Show></span></label>- <ToggleSwitch- size="md"- label="Show results to respondents"- labelClass="text-sm text-ink"- checked={form().tallyVisible}- disabled={!isOwner() || pending()}- onChange={(tallyVisible) =>- fireAndForget(- update({ tallyVisible }, 'Showing results'),- 'form-share'- )- }- /><ToggleSwitchsize="md"label="Share responses with team"diff --git a/apps/web/src/lib/queries/storage/forms.ts b/apps/web/src/lib/queries/storage/forms.tsindex c735b3e76d..107e67d6ea 100644--- a/apps/web/src/lib/queries/storage/forms.ts+++ b/apps/web/src/lib/queries/storage/forms.ts@@ -296,25 +296,22 @@ export function useResponseSummaryQuery(return useQuery(() => responseSummaryQueryOptions(formId(), enabled()));}-function tallyQueryOptions(id: string | undefined, enabled: boolean) {+function tallyQueryOptions(id: string | undefined) {return queryOptions({queryKey: formsKeys.tally(id ?? '').queryKey,queryFn: () =>throwOnErr(async () =>storageServiceClient.forms.getTally({ id: id ?? '' })),- enabled: !!id && enabled,+ enabled: !!id,// Poll cards and respondents do not join the editor presence roster.refetchInterval: RESPONDENT_REFRESH_INTERVAL,retry: false,});}-export function useTallyQuery(- formId: Accessor<string | undefined>,- enabled: Accessor<boolean>-) {- return useQuery(() => tallyQueryOptions(formId(), enabled()));+export function useTallyQuery(formId: Accessor<string | undefined>) {+ return useQuery(() => tallyQueryOptions(formId()));}function formSharePermissionsQueryOptions(diff --git a/docs/agent-guide/forms.md b/docs/agent-guide/forms.mdindex ed5fdabdf2..bb19e88425 100644--- a/docs/agent-guide/forms.md+++ b/docs/agent-guide/forms.md@@ -26,11 +26,10 @@ decides who may respond.- In a channel composer, `/form` creates a form and opens the builder besidethe channel; its card joins the draft once the builder saves a question.`/poll` opens the poll dialog (question, at least two options, **Multiple- answers**, **Show results to respondents**, **Share responses with team**,- **Anonymous**); **Post poll** puts the poll's card in the message and sends- it. Closing the dialog while it posts sends nothing and trashes the poll.- With results hidden, respondents answer without counts and editors review- votes in the Responses tab. **Share responses with team** lets everyone who+ answers**, **Share responses with team**, **Anonymous**); **Post poll** puts+ the poll's card in the message and sends it. Closing the dialog while it+ posts sends nothing and trashes the poll. Everyone who can vote sees the+ counts. **Share responses with team** lets everyone whocan vote open that table. **Anonymous** makes votes anonymous to everyonein Macro, the poll's owner included: the server keeps who voted apart fromwhat they chose, so each person still votes once, but no vote can be@@ -151,8 +150,8 @@ submitting are not recorded; answers stay in the browser until Submit.**Who can respond**: Invited people (sign in, one response each, editablewhile open) or Anyone with the link (anonymous; no file questions). The-respond link with Copy, Accepting responses, Close automatically, Show results-to respondents, Share responses with team, Anonymous (locked, with a tooltip+respond link with Copy, Accepting responses, Close automatically, Share+responses with team, Anonymous (locked, with a tooltipsaying why, once anyone has responded), Confirmation message, **Branding**, and **Manage access** (theshare dialog, which also shows the audience panel). Branding (editors) sets alogo (**Upload**/**Replace**/**Remove**, shown above the title), a cover imagediff --git a/packages/sdk/src/entities/channels/namespace.ts b/packages/sdk/src/entities/channels/namespace.tsindex 83d6883443..8efc4ec56d 100644--- a/packages/sdk/src/entities/channels/namespace.ts+++ b/packages/sdk/src/entities/channels/namespace.ts@@ -20,7 +20,7 @@ const CHANNEL_PAGE_SIZE = 100;* @agent* ## Polls*- * A form for a channel is a poll: one required single- or multi-select question (`widget: "choice"`, or `"checkboxes"` for several answers), `status: "open"`, `tallyVisible: true` unless asked to hide results, and `channelGrants: []`. Post it as one message with its live card on its own line:+ * A form for a channel is a poll: one required single- or multi-select question (`widget: "choice"`, or `"checkboxes"` for several answers), `status: "open"`, `tallyVisible: true`, and `channelGrants: []`. Post it as one message with its live card on its own line:** `<m-document-card>{"documentId":"{form_id}","documentName":"{question}","blockName":"form","previewData":{"poll":{"optionCount":2}}}</m-document-card>`*