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:
@@ -1,8 +1,12 @@
|
||||
import { Args, ID, Mutation, Resolver } from '@nestjs/graphql';
|
||||
import { Args, ID, Int, Mutation, Query, Resolver } from '@nestjs/graphql';
|
||||
import { User } from '@task-stream/api/identity/domain';
|
||||
import { CurrentUser } from '@task-stream/api/identity/presenters';
|
||||
import {
|
||||
CurrentUser,
|
||||
OptionalAuth,
|
||||
} from '@task-stream/api/identity/presenters';
|
||||
import { CommentsService } from '@task-stream/api/tracker/application';
|
||||
import { CommandResultGql, CommentGql } from './types';
|
||||
import { viewerOf } from '../common/viewer';
|
||||
import { CommandResultGql, CommentGql, DecisionGql } from './types';
|
||||
|
||||
@Resolver(() => CommentGql)
|
||||
export class CommentResolver {
|
||||
@@ -43,6 +47,37 @@ export class CommentResolver {
|
||||
return this.comments.react(me.id, commentId, emoji, on);
|
||||
}
|
||||
|
||||
@Mutation(() => CommandResultGql, {
|
||||
description:
|
||||
'Mark a comment as a decision of its ticket, or unmark it (on: false). Whoever can change the ticket',
|
||||
})
|
||||
markDecision(
|
||||
@CurrentUser() me: User,
|
||||
@Args('commentId', { type: () => ID }) commentId: string,
|
||||
@Args('on', { defaultValue: true }) on: boolean,
|
||||
) {
|
||||
return this.comments.markDecision(me.id, commentId, on);
|
||||
}
|
||||
|
||||
@OptionalAuth()
|
||||
@Query(() => [DecisionGql], {
|
||||
description:
|
||||
'Decisions by their text, most recent first: of a project, or of all my projects without one',
|
||||
})
|
||||
decisions(
|
||||
@CurrentUser() me: User | undefined,
|
||||
@Args('projectId', { type: () => ID, nullable: true })
|
||||
projectId: string | null,
|
||||
@Args('search', { nullable: true }) search: string | null,
|
||||
@Args('limit', { type: () => Int, defaultValue: 20 }) limit: number,
|
||||
) {
|
||||
return this.comments.searchDecisions(viewerOf(me), {
|
||||
projectId: projectId ?? undefined,
|
||||
search: search ?? undefined,
|
||||
limit,
|
||||
});
|
||||
}
|
||||
|
||||
@Mutation(() => CommandResultGql, { description: 'Author or project admin' })
|
||||
deleteComment(
|
||||
@CurrentUser() me: User,
|
||||
|
||||
@@ -44,6 +44,7 @@ import {
|
||||
ActivityGql,
|
||||
BulkResultGql,
|
||||
CommandResultGql,
|
||||
CommentGql,
|
||||
CommentPageGql,
|
||||
EpicGql,
|
||||
CustomFieldValueGql,
|
||||
@@ -247,6 +248,16 @@ export class IssueResolver {
|
||||
return !!me && issue.voterIds.includes(me.id);
|
||||
}
|
||||
|
||||
@ResolveField(() => [CommentGql], {
|
||||
description: 'Its comments marked as decisions, oldest first',
|
||||
})
|
||||
decisions(
|
||||
@CurrentUser() me: User | undefined,
|
||||
@Parent() issue: IssueReadModel,
|
||||
) {
|
||||
return this.commentsService.decisions(viewerOf(me), issue.id);
|
||||
}
|
||||
|
||||
@ResolveField(() => Boolean, {
|
||||
description: 'Whether I pinned it (false without a token)',
|
||||
})
|
||||
|
||||
@@ -548,6 +548,16 @@ export class CommentGql {
|
||||
description: 'In the order they are offered; only the ones somebody chose',
|
||||
})
|
||||
reactions!: CommentReactionGql[];
|
||||
@Field({
|
||||
description: 'Marked as a decision of the ticket (shown above it)',
|
||||
})
|
||||
decision!: boolean;
|
||||
@Field(() => UserRefGql, {
|
||||
nullable: true,
|
||||
description: 'Who marked it as a decision',
|
||||
})
|
||||
decidedBy!: UserRefGql | null;
|
||||
@Field(() => String, { nullable: true }) decidedAt!: string | null;
|
||||
@Field() createdAt!: string;
|
||||
@Field(() => String, { nullable: true }) editedAt!: string | null;
|
||||
@Field(() => Int) version!: number;
|
||||
@@ -559,6 +569,14 @@ export class CommentPageGql {
|
||||
@Field(() => Int) total!: number;
|
||||
}
|
||||
|
||||
@ObjectType('Decision', {
|
||||
description: 'A comment marked as a decision, with its ticket',
|
||||
})
|
||||
export class DecisionGql {
|
||||
@Field(() => CommentGql) comment!: CommentGql;
|
||||
@Field(() => IssueParentGql) issue!: IssueParentGql;
|
||||
}
|
||||
|
||||
@ObjectType('Release')
|
||||
export class ReleaseGql {
|
||||
@Field(() => ID) id!: string;
|
||||
|
||||
@@ -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