feat: comments marked as decisions, on top of the ticket and searchable
Whoever can change the ticket flags a comment as a decision (new event
CommentDecisionMarkedEvent on the comment). The ticket page lists its
decisions above the description, with a link to the comment in the
conversation (`?comment=<id>` scrolls to it and points at it), and the
search palette finds them by their text across my projects.
API: markDecision / PUT-DELETE /api/comments/{id}/decision; Issue.decisions
and GET /api/issues/{issue}/decisions; decisions(projectId?, search) and
GET /api/projects/{project}/decisions, GET /api/me/decisions. MCP:
mark_decision, search_decisions, and get_issue includes them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
Put,
|
||||
} from '@nestjs/common';
|
||||
import { ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { User } from '@task-stream/api/identity/domain';
|
||||
@@ -54,6 +55,29 @@ export class CommentsController {
|
||||
return this.comments.react(me.id, commentId, body.emoji, body.on);
|
||||
}
|
||||
|
||||
@Put(':commentId/decision')
|
||||
@ApiOperation({
|
||||
summary: 'Mark a comment as a decision of its ticket',
|
||||
description:
|
||||
'Whoever can change the ticket. Decisions are shown above the ticket and searchable (GET …/decisions).',
|
||||
})
|
||||
@ApiOkResponse({ type: CommandResultDto })
|
||||
@ApiCommandErrors()
|
||||
markDecision(@CurrentUser() me: User, @Param('commentId') commentId: string) {
|
||||
return this.comments.markDecision(me.id, commentId, true);
|
||||
}
|
||||
|
||||
@Delete(':commentId/decision')
|
||||
@ApiOperation({ summary: 'It is no longer a decision' })
|
||||
@ApiOkResponse({ type: CommandResultDto })
|
||||
@ApiCommandErrors()
|
||||
unmarkDecision(
|
||||
@CurrentUser() me: User,
|
||||
@Param('commentId') commentId: string,
|
||||
) {
|
||||
return this.comments.markDecision(me.id, commentId, false);
|
||||
}
|
||||
|
||||
@Delete(':commentId')
|
||||
@ApiOperation({ summary: 'Delete a comment (author or project admin)' })
|
||||
@ApiOkResponse({ type: CommandResultDto })
|
||||
|
||||
@@ -501,6 +501,22 @@ export class PageQueryDto {
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
export class DecisionsQueryDto {
|
||||
@ApiPropertyOptional({ description: 'Words in the decision' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(200)
|
||||
search?: string;
|
||||
|
||||
@ApiPropertyOptional({ type: Number, default: 20, minimum: 1, maximum: 100 })
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
@Max(100)
|
||||
limit = 20;
|
||||
}
|
||||
|
||||
// ---- Issues -----------------------------------------------------------------
|
||||
|
||||
export class MyIssuesQueryDto extends PageQueryDto {
|
||||
|
||||
@@ -625,12 +625,30 @@ export class CommentDto {
|
||||
description: 'In the order they are offered; only the ones somebody chose',
|
||||
})
|
||||
reactions!: CommentReactionDto[];
|
||||
@ApiProperty({
|
||||
description: 'Marked as a decision of the ticket (shown above it)',
|
||||
})
|
||||
decision!: boolean;
|
||||
@ApiProperty({
|
||||
type: UserRefDto,
|
||||
nullable: true,
|
||||
description: 'Who marked it as a decision',
|
||||
})
|
||||
decidedBy!: UserRefDto | null;
|
||||
@ApiProperty({ type: String, nullable: true, format: 'date-time' })
|
||||
decidedAt!: string | null;
|
||||
@ApiProperty({ format: 'date-time' }) createdAt!: string;
|
||||
@ApiProperty({ type: String, nullable: true, format: 'date-time' })
|
||||
editedAt!: string | null;
|
||||
@ApiProperty() version!: number;
|
||||
}
|
||||
|
||||
/** A comment marked as a decision, with its ticket. */
|
||||
export class DecisionDto {
|
||||
@ApiProperty({ type: CommentDto }) comment!: CommentDto;
|
||||
@ApiProperty({ type: IssueParentDto }) issue!: IssueParentDto;
|
||||
}
|
||||
|
||||
export class CommentPageDto {
|
||||
@ApiProperty({ type: [CommentDto] }) items!: CommentDto[];
|
||||
@ApiProperty() total!: number;
|
||||
|
||||
@@ -45,6 +45,7 @@ import {
|
||||
ChecklistItemBodyDto,
|
||||
AddCommentDto,
|
||||
CreateIssueDto,
|
||||
DecisionsQueryDto,
|
||||
IssueSearchQueryDto,
|
||||
PresenceBodyDto,
|
||||
LinkIssueDto,
|
||||
@@ -61,7 +62,9 @@ import {
|
||||
ActivityDto,
|
||||
BulkResultDto,
|
||||
CommandResultDto,
|
||||
CommentDto,
|
||||
CommentPageDto,
|
||||
DecisionDto,
|
||||
EpicDto,
|
||||
IssueDto,
|
||||
IssuePageDto,
|
||||
@@ -707,6 +710,57 @@ export class IssuesController {
|
||||
);
|
||||
}
|
||||
|
||||
@Get('issues/:issue/decisions')
|
||||
@ApiOptionalPireonAuth()
|
||||
@ISSUE
|
||||
@ApiOperation({
|
||||
summary: 'Comments of the ticket marked as decisions (oldest first)',
|
||||
})
|
||||
@ApiOkResponse({ type: [CommentDto] })
|
||||
@ApiReadErrors()
|
||||
async issueDecisions(
|
||||
@CurrentUser() me: User | undefined,
|
||||
@Param('issue') issue: string,
|
||||
) {
|
||||
return this.comments.decisions(
|
||||
viewerOf(me),
|
||||
await this.refs.issueId(viewerOf(me), issue),
|
||||
);
|
||||
}
|
||||
|
||||
@Get('projects/:project/decisions')
|
||||
@ApiOptionalPireonAuth()
|
||||
@PROJECT
|
||||
@ApiOperation({
|
||||
summary: "Search a project's decisions (most recent first)",
|
||||
})
|
||||
@ApiOkResponse({ type: [DecisionDto] })
|
||||
@ApiReadErrors()
|
||||
async projectDecisions(
|
||||
@CurrentUser() me: User | undefined,
|
||||
@Param('project') project: string,
|
||||
@Query() query: DecisionsQueryDto,
|
||||
) {
|
||||
return this.comments.searchDecisions(viewerOf(me), {
|
||||
projectId: await this.refs.projectId(viewerOf(me), project),
|
||||
search: query.search,
|
||||
limit: query.limit,
|
||||
});
|
||||
}
|
||||
|
||||
@Get('me/decisions')
|
||||
@ApiOperation({
|
||||
summary: 'Search the decisions of all my projects (most recent first)',
|
||||
})
|
||||
@ApiOkResponse({ type: [DecisionDto] })
|
||||
@ApiReadErrors()
|
||||
myDecisions(@CurrentUser() me: User, @Query() query: DecisionsQueryDto) {
|
||||
return this.comments.searchDecisions(me.id, {
|
||||
search: query.search,
|
||||
limit: query.limit,
|
||||
});
|
||||
}
|
||||
|
||||
@Post('issues/:issue/comments')
|
||||
@ISSUE
|
||||
@ApiOperation({
|
||||
|
||||
Reference in New Issue
Block a user