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

@@ -8216,6 +8216,226 @@
]
}
},
"/api/comments/{commentId}/poll/vote": {
"post": {
"description": "option: its index; null takes the vote back.",
"operationId": "CommentsController_votePoll",
"parameters": [
{
"name": "commentId",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/VotePollDto"
}
}
}
},
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CommandResultDto"
}
}
}
},
"400": {
"description": "Invalid input",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
},
"401": {
"description": "Missing or rejected Pireon token",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
},
"403": {
"description": "Not a member of the project (or not allowed)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
},
"404": {
"description": "Not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
},
"409": {
"description": "Someone changed it at the same time: retry",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
},
"422": {
"description": "Business rule (e.g. a transition the workflow forbids)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
}
},
"security": [
{
"pireon-oauth": []
},
{
"pireon": []
}
],
"summary": "Vote in a comment's poll (members, viewers too)",
"tags": [
"Comments"
]
}
},
"/api/comments/{commentId}/poll/close": {
"post": {
"description": "With decide (default), the winner stays as a decision of the ticket.",
"operationId": "CommentsController_closePoll",
"parameters": [
{
"name": "commentId",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ClosePollDto"
}
}
}
},
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CommandResultDto"
}
}
}
},
"400": {
"description": "Invalid input",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
},
"401": {
"description": "Missing or rejected Pireon token",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
},
"403": {
"description": "Not a member of the project (or not allowed)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
},
"404": {
"description": "Not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
},
"409": {
"description": "Someone changed it at the same time: retry",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
},
"422": {
"description": "Business rule (e.g. a transition the workflow forbids)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiErrorDto"
}
}
}
}
},
"security": [
{
"pireon-oauth": []
},
{
"pireon": []
}
],
"summary": "Close a poll (whoever started it, or an admin)",
"tags": [
"Comments"
]
}
},
"/api/comments/{commentId}/resolution": {
"put": {
"description": "Whoever can change the ticket. A conclusion is added as a reply marked as a decision. The web folds a settled conversation.",
@@ -17618,6 +17838,48 @@
"users"
]
},
"PollOptionDto": {
"type": "object",
"properties": {
"text": {
"type": "string"
},
"voters": {
"type": "array",
"items": {
"$ref": "#/components/schemas/UserRefDto"
}
}
},
"required": [
"text",
"voters"
]
},
"CommentPollDto": {
"type": "object",
"properties": {
"options": {
"type": "array",
"items": {
"$ref": "#/components/schemas/PollOptionDto"
}
},
"closed": {
"type": "boolean"
},
"winner": {
"type": "number",
"nullable": true,
"description": "Index of the winning option once closed (null on a tie)"
}
},
"required": [
"options",
"closed",
"winner"
]
},
"CommentDto": {
"type": "object",
"properties": {
@@ -17672,6 +17934,15 @@
"nullable": true,
"format": "date-time"
},
"poll": {
"nullable": true,
"type": "object",
"allOf": [
{
"$ref": "#/components/schemas/CommentPollDto"
}
]
},
"resolved": {
"type": "boolean",
"description": "A conversation (top-level comment and its replies) that was settled"
@@ -17715,6 +17986,7 @@
"decision",
"decidedBy",
"decidedAt",
"poll",
"resolved",
"resolvedBy",
"resolvedAt",
@@ -17768,6 +18040,17 @@
"type": "string",
"format": "uuid",
"description": "Comment it answers (one level: answering a reply joins its thread)"
},
"poll": {
"description": "A quick poll: 2 to 6 options",
"example": [
"Stripe",
"Redsys"
],
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
@@ -17860,6 +18143,29 @@
"on"
]
},
"VotePollDto": {
"type": "object",
"properties": {
"option": {
"type": "number",
"nullable": true,
"description": "Option index; null takes the vote back"
}
},
"required": [
"option"
]
},
"ClosePollDto": {
"type": "object",
"properties": {
"decide": {
"type": "boolean",
"default": true,
"description": "Keep the winner as a decision of the ticket"
}
}
},
"ResolveThreadDto": {
"type": "object",
"properties": {

View File

@@ -304,6 +304,7 @@ type Comment {
editedAt: String
id: ID!
issueId: ID!
poll: CommentPoll
"""In the order they are offered; only the ones somebody chose"""
reactions: [CommentReaction!]!
@@ -336,6 +337,15 @@ type CommentPage {
total: Int!
}
"""A quick poll in a comment"""
type CommentPoll {
closed: Boolean!
options: [PollOption!]!
"""Index of the winning option once closed (null on a tie)"""
winner: Int
}
"""One emoji on a comment"""
type CommentReaction {
emoji: String!
@@ -964,7 +974,14 @@ type Mutation {
"""
Comment on a ticket, or answer a comment (replyTo; one level of replies)
"""
addComment(body: String!, issueId: ID!, replyTo: ID): CommandResult!
addComment(
body: String!
issueId: ID!
"""A quick poll: 2 to 6 options"""
poll: [String!]
replyTo: ID
): CommandResult!
"""
Add a repository with its own secret (the first turns the integration on)
@@ -1010,6 +1027,11 @@ type Mutation {
"""Drop my reminder on a ticket"""
clearReminder(issueId: ID!): Boolean!
"""
Close a poll (whoever started it, or an admin); with decide, the winner stays as a decision of the ticket
"""
closePoll(commentId: ID!, decide: Boolean! = true): CommandResult!
"""
Close the sprint under way. Unfinished tickets move to carryOverToSprintId, or back to the backlog when it is null.
"""
@@ -1233,6 +1255,11 @@ type Mutation {
"""
voteIssue(issueId: ID!, on: Boolean!): CommandResult!
"""
Vote in a comment's poll (option index), or take the vote back (null). Members, viewers too
"""
votePoll(commentId: ID!, option: Int): CommandResult!
"""
Follow a ticket: be told when it moves, is reassigned or gets a comment
"""
@@ -1373,6 +1400,11 @@ type OptionCount {
value: String!
}
type PollOption {
text: String!
voters: [UserRef!]!
}
"""
One of my active projects at a glance: open work, risks, sprint, releases and epics
"""

View File

@@ -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;

View File

@@ -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 },
}),
),
);