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:
@@ -1201,6 +1201,46 @@ export interface paths {
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/api/comments/{commentId}/poll/vote": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
get?: never;
|
||||
put?: never;
|
||||
/**
|
||||
* Vote in a comment's poll (members, viewers too)
|
||||
* @description option: its index; null takes the vote back.
|
||||
*/
|
||||
post: operations["CommentsController_votePoll"];
|
||||
delete?: never;
|
||||
options?: never;
|
||||
head?: never;
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/api/comments/{commentId}/poll/close": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
get?: never;
|
||||
put?: never;
|
||||
/**
|
||||
* Close a poll (whoever started it, or an admin)
|
||||
* @description With decide (default), the winner stays as a decision of the ticket.
|
||||
*/
|
||||
post: operations["CommentsController_closePoll"];
|
||||
delete?: never;
|
||||
options?: never;
|
||||
head?: never;
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/api/comments/{commentId}/resolution": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
@@ -3288,6 +3328,16 @@ export interface components {
|
||||
emoji: string;
|
||||
users: components["schemas"]["UserRefDto"][];
|
||||
};
|
||||
PollOptionDto: {
|
||||
text: string;
|
||||
voters: components["schemas"]["UserRefDto"][];
|
||||
};
|
||||
CommentPollDto: {
|
||||
options: components["schemas"]["PollOptionDto"][];
|
||||
closed: boolean;
|
||||
/** @description Index of the winning option once closed (null on a tie) */
|
||||
winner: number | null;
|
||||
};
|
||||
CommentDto: {
|
||||
/** Format: uuid */
|
||||
id: string;
|
||||
@@ -3311,6 +3361,7 @@ export interface components {
|
||||
decidedBy: components["schemas"]["UserRefDto"] | null;
|
||||
/** Format: date-time */
|
||||
decidedAt: string | null;
|
||||
poll: components["schemas"]["CommentPollDto"] | null;
|
||||
/** @description A conversation (top-level comment and its replies) that was settled */
|
||||
resolved: boolean;
|
||||
/** @description Who settled it */
|
||||
@@ -3339,6 +3390,14 @@ export interface components {
|
||||
* @description Comment it answers (one level: answering a reply joins its thread)
|
||||
*/
|
||||
replyTo?: string;
|
||||
/**
|
||||
* @description A quick poll: 2 to 6 options
|
||||
* @example [
|
||||
* "Stripe",
|
||||
* "Redsys"
|
||||
* ]
|
||||
*/
|
||||
poll?: string[];
|
||||
};
|
||||
AttachFileDto: {
|
||||
/**
|
||||
@@ -3381,6 +3440,17 @@ export interface components {
|
||||
/** @description true adds the reaction, false takes it back */
|
||||
on: boolean;
|
||||
};
|
||||
VotePollDto: {
|
||||
/** @description Option index; null takes the vote back */
|
||||
option: number | null;
|
||||
};
|
||||
ClosePollDto: {
|
||||
/**
|
||||
* @description Keep the winner as a decision of the ticket
|
||||
* @default true
|
||||
*/
|
||||
decide: boolean;
|
||||
};
|
||||
ResolveThreadDto: {
|
||||
/** @description What was settled: added as a reply marked as a decision before it closes */
|
||||
conclusion?: string;
|
||||
@@ -9646,6 +9716,164 @@ export interface operations {
|
||||
};
|
||||
};
|
||||
};
|
||||
CommentsController_votePoll: {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path: {
|
||||
commentId: string;
|
||||
};
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody: {
|
||||
content: {
|
||||
"application/json": components["schemas"]["VotePollDto"];
|
||||
};
|
||||
};
|
||||
responses: {
|
||||
200: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["CommandResultDto"];
|
||||
};
|
||||
};
|
||||
/** @description Invalid input */
|
||||
400: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["ApiErrorDto"];
|
||||
};
|
||||
};
|
||||
/** @description Missing or rejected Pireon token */
|
||||
401: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["ApiErrorDto"];
|
||||
};
|
||||
};
|
||||
/** @description Not a member of the project (or not allowed) */
|
||||
403: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["ApiErrorDto"];
|
||||
};
|
||||
};
|
||||
/** @description Not found */
|
||||
404: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["ApiErrorDto"];
|
||||
};
|
||||
};
|
||||
/** @description Someone changed it at the same time: retry */
|
||||
409: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["ApiErrorDto"];
|
||||
};
|
||||
};
|
||||
/** @description Business rule (e.g. a transition the workflow forbids) */
|
||||
422: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["ApiErrorDto"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
CommentsController_closePoll: {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path: {
|
||||
commentId: string;
|
||||
};
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody: {
|
||||
content: {
|
||||
"application/json": components["schemas"]["ClosePollDto"];
|
||||
};
|
||||
};
|
||||
responses: {
|
||||
200: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["CommandResultDto"];
|
||||
};
|
||||
};
|
||||
/** @description Invalid input */
|
||||
400: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["ApiErrorDto"];
|
||||
};
|
||||
};
|
||||
/** @description Missing or rejected Pireon token */
|
||||
401: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["ApiErrorDto"];
|
||||
};
|
||||
};
|
||||
/** @description Not a member of the project (or not allowed) */
|
||||
403: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["ApiErrorDto"];
|
||||
};
|
||||
};
|
||||
/** @description Not found */
|
||||
404: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["ApiErrorDto"];
|
||||
};
|
||||
};
|
||||
/** @description Someone changed it at the same time: retry */
|
||||
409: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["ApiErrorDto"];
|
||||
};
|
||||
};
|
||||
/** @description Business rule (e.g. a transition the workflow forbids) */
|
||||
422: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["ApiErrorDto"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
CommentsController_resolveThread: {
|
||||
parameters: {
|
||||
query?: never;
|
||||
|
||||
@@ -299,6 +299,17 @@ export class IssuesResolver {
|
||||
})),
|
||||
decision: c.decision || undefined,
|
||||
resolved: c.resolved || undefined,
|
||||
poll: c.poll
|
||||
? {
|
||||
options: c.poll.options.map((o, index) => ({
|
||||
index,
|
||||
text: o.text,
|
||||
votes: o.voters.length,
|
||||
})),
|
||||
closed: c.poll.closed,
|
||||
winner: c.poll.winner,
|
||||
}
|
||||
: undefined,
|
||||
}))
|
||||
: undefined;
|
||||
const decisions = (
|
||||
@@ -512,18 +523,77 @@ export class IssuesResolver {
|
||||
.string()
|
||||
.optional()
|
||||
.describe('Id of the comment it answers (see get_issue)'),
|
||||
poll: z
|
||||
.array(z.string().min(1).max(80))
|
||||
.min(2)
|
||||
.max(6)
|
||||
.optional()
|
||||
.describe('A quick poll in the comment: 2 to 6 options'),
|
||||
}),
|
||||
annotations: WRITE,
|
||||
})
|
||||
comment(
|
||||
{ issue, body, replyTo }: { issue: string; body: string; replyTo?: string },
|
||||
{
|
||||
issue,
|
||||
body,
|
||||
replyTo,
|
||||
poll,
|
||||
}: { issue: string; body: string; replyTo?: string; poll?: string[] },
|
||||
ctx: McpContext,
|
||||
) {
|
||||
return toolResult(() =>
|
||||
this.api.data(
|
||||
this.api.as(ctx).POST('/api/issues/{issue}/comments', {
|
||||
params: { path: { issue } },
|
||||
body: { body, replyTo },
|
||||
body: { body, replyTo, poll },
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@Tool({
|
||||
name: 'vote_poll',
|
||||
description:
|
||||
"Vote in a comment's poll (option index from get_issue), or take the vote back (option null).",
|
||||
paramsSchema: z.object({
|
||||
commentId: z.string().min(1),
|
||||
option: z.number().int().min(0).nullable(),
|
||||
}),
|
||||
annotations: { ...WRITE, idempotentHint: true },
|
||||
})
|
||||
votePoll(
|
||||
{ commentId, option }: { commentId: string; option: number | null },
|
||||
ctx: McpContext,
|
||||
) {
|
||||
return toolResult(() =>
|
||||
this.api.data(
|
||||
this.api.as(ctx).POST('/api/comments/{commentId}/poll/vote', {
|
||||
params: { path: { commentId } },
|
||||
body: { option },
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@Tool({
|
||||
name: 'close_poll',
|
||||
description:
|
||||
'Close a poll the user started (or as admin); with decide (default), the winner stays as a decision of the ticket.',
|
||||
paramsSchema: z.object({
|
||||
commentId: z.string().min(1),
|
||||
decide: z.boolean().default(true),
|
||||
}),
|
||||
annotations: WRITE,
|
||||
})
|
||||
closePoll(
|
||||
{ commentId, decide }: { commentId: string; decide: boolean },
|
||||
ctx: McpContext,
|
||||
) {
|
||||
return toolResult(() =>
|
||||
this.api.data(
|
||||
this.api.as(ctx).POST('/api/comments/{commentId}/poll/close', {
|
||||
params: { path: { commentId } },
|
||||
body: { decide },
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user