Files
fusion/packages/dashboard/app/utils/githubCommentAuthor.ts
gsxdsm fc958bc54b FN-7178: improve review comment rendering
Render task Review tab comments with cleaner content, author context, and filter controls.

- Reuse the sanitized mailbox markdown renderer and strip GitHub HTML comments in plain-text mode.
- Add human/bot author derivation, avatars, badges, and All/Human/Bot filtering for review items.
- Cover rendering, filtering, selection pruning, and author classification with dashboard tests.
- Document the Review tab behavior and add the release changeset.

Files changed:
 .../fn-7178-task-review-comment-rendering.md       |   7 +
 docs/dashboard-guide.md                            |   1 +
 .../dashboard/app/components/TaskReviewTab.css     | 117 ++++++++++++++++
 .../dashboard/app/components/TaskReviewTab.tsx     | 144 ++++++++++++-------
 .../components/__tests__/TaskReviewTab.test.tsx    | 153 +++++++++++++++++++++
 .../utils/__tests__/githubCommentAuthor.test.ts    |  46 +++++++
 .../dashboard/app/utils/githubCommentAuthor.ts     |  33 +++++
 packages/dashboard/vitest.config.ts                |   1 +
 8 files changed, 455 insertions(+), 47 deletions(-)

Fusion-Task-Id: FN-7178

Fusion-Task-Lineage: 98269a09-3c57-492d-b433-d6ccb81d5b17

Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-06-27 23:53:51 -07:00

34 lines
1.8 KiB
TypeScript

export interface ReviewCommentAuthorResolution {
author: string;
authorIsBot: boolean;
authorAvatarUrl?: string;
}
export interface ResolveReviewCommentAuthorOptions {
reviewSource?: "pull-request" | "reviewer-agent";
}
const KNOWN_AGENT_LOGINS = new Set(["agent", "reviewer-agent", "fusion-agent", "fusion-reviewer", "executor-agent", "triage-agent", "merger-agent"]);
/*
FNXC:TaskReview 2026-06-27-00:00:
Task-detail Review comments only receive a GitHub login from the review backend, so the UI derives the same author shape as the GitHub import preview: `[bot]` suffixes are agents, missing logins render as `unknown`, and human logins get GitHub's deterministic PNG avatar URL.
Bot avatars are intentionally suppressed because synthetic `[bot]` logins often do not resolve to a real avatar; the Review tab renders a generic Bot icon instead of a broken image.
FNXC:TaskReview 2026-06-27-00:00:
Direct reviewer-agent feedback can arrive as `author.login: "reviewer-agent"` or without a login at all. Treat those known reviewer identities as agents so badges, fallback avatars, and Human/Bot filtering do not mislabel AI reviewer feedback as a human GitHub author.
*/
export function resolveReviewCommentAuthor(login?: string | null, options: ResolveReviewCommentAuthorOptions = {}): ReviewCommentAuthorResolution {
const trimmedLogin = login?.trim() ?? "";
const author = trimmedLogin || "unknown";
const normalizedAuthor = author.toLowerCase();
const authorIsBot = /\[bot\]$/i.test(author)
|| KNOWN_AGENT_LOGINS.has(normalizedAuthor)
|| (options.reviewSource === "reviewer-agent" && author === "unknown");
const authorAvatarUrl = !authorIsBot && author !== "unknown"
? `https://github.com/${encodeURIComponent(author)}.png?size=40`
: undefined;
return { author, authorIsBot, authorAvatarUrl };
}