feat: quick polls in comments that end in a decision

«📊 Añadir una encuesta» adds 2 to 6 options to a new comment. Members,
viewers too, vote by clicking an option (one vote each, which they can
change or take back) and see each option's votes as a bar. Whoever
started it, or an admin, closes it with «Cerrar y decidir»: the most
voted wins (none on a tie) and a «Decidido: …» reply marked as a
decision shows above the ticket. Events of the comment (voted, closed).

API: addComment(…, poll), votePoll, closePoll, Comment.poll;
POST /api/comments/{id}/poll/vote and …/poll/close. MCP: add_comment
poll, vote_poll, close_poll.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-20 20:48:12 +02:00
parent 93d028e870
commit 3a46a236e4
41 changed files with 2144 additions and 77 deletions

View File

@@ -47,7 +47,11 @@ export const issuePageEvents = eventGroup({
files?: File[];
/** Comment it answers (one level of replies). */
replyTo?: string | null;
/** A quick poll's options. */
poll?: string[] | null;
}>(),
pollVoteRequested: type<{ commentId: string; option: number | null }>(),
pollCloseRequested: type<{ commentId: string; decide: boolean }>(),
watchRequested: type<{ issueId: string; watching: boolean }>(),
pinRequested: type<{ issueId: string; pinned: boolean }>(),
followTreeRequested: type<{ issueId: string; on: boolean }>(),

View File

@@ -101,12 +101,29 @@ export class IssueFacade {
body: string,
files: File[] = [],
replyTo: string | null = null,
poll: string[] | null = null,
): void {
this.withIssue((issueId) =>
this.dispatch.commentAddRequested({ issueId, body, files, replyTo }),
this.dispatch.commentAddRequested({
issueId,
body,
files,
replyTo,
poll,
}),
);
}
/** Votes in a comment's poll (null takes the vote back). */
votePoll(commentId: string, option: number | null): void {
this.dispatch.pollVoteRequested({ commentId, option });
}
/** Closes a poll; with `decide`, its winner stays as a decision. */
closePoll(commentId: string, decide = true): void {
this.dispatch.pollCloseRequested({ commentId, decide });
}
/** To the trash (true) or back from it (false). */
setTrashed(trashed: boolean): void {
this.withIssue((issueId) =>

View File

@@ -381,6 +381,32 @@ export const IssueStore = signalStore(
),
),
),
events.on(issuePageEvents.pollVoteRequested).pipe(
mergeMap(({ payload }) =>
comments.votePoll(payload.commentId, payload.option).pipe(
// A vote is not worth a toast, like a reaction.
mapResponse({
next: () => issueApiEvents.checklistSaved(),
error: (error) =>
issueApiEvents.commandFailed(describeError(error)),
}),
),
),
),
events
.on(issuePageEvents.pollCloseRequested)
.pipe(
mergeMap(({ payload }) =>
runCommand(
comments.closePoll(payload.commentId, payload.decide),
payload.decide
? 'Encuesta cerrada: el resultado queda como decisión'
: 'Encuesta cerrada',
done,
failed,
),
),
),
events
.on(issuePageEvents.reviewRequested)
.pipe(
@@ -698,7 +724,12 @@ export const IssueStore = signalStore(
mergeMap(({ payload }) =>
runCommand(
comments
.add(payload.issueId, payload.body, payload.replyTo ?? null)
.add(
payload.issueId,
payload.body,
payload.replyTo ?? null,
payload.poll ?? null,
)
.pipe(
concatMap((comment) =>
payload.files?.length