-
Notifications
You must be signed in to change notification settings - Fork 424
feat: render PR comments in the checks panel #1959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jschwxrz
merged 8 commits into
generalaction:main
from
arnestrickmann:arne/eng-1071-render-pr-comments-in-the-right-sidebar
May 11, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0ef372e
ENG-1071 render PR comments in checks panel
arnestrickmann 33b7e48
Merge remote-tracking branch 'generalaction/main' into arne/eng-1071-…
arnestrickmann addd09d
ENG-1071 scope PR comment HTML rendering
arnestrickmann a24f55a
ENG-1071 match bot comment avatar radius
arnestrickmann bcf4365
ENG-1071 limit comment external link target
arnestrickmann 9f88907
ENG-1071 limit check external link target
arnestrickmann 68ed83b
refactor: extract hook into file
jschwxrz d1a2450
feat: prevent comment clamping
jschwxrz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
src/renderer/features/tasks/diff-view/changes-panel/components/pr-entry/comments-list.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| import { ExternalLink, MessageSquare } from 'lucide-react'; | ||
| import { useMemo } from 'react'; | ||
| import type { PullRequestComment } from '@shared/pull-requests'; | ||
| import { rpc } from '@renderer/lib/ipc'; | ||
| import { MarkdownRenderer } from '@renderer/lib/ui/markdown-renderer'; | ||
| import { RelativeTime } from '@renderer/lib/ui/relative-time'; | ||
| import { cn } from '@renderer/utils/utils'; | ||
|
|
||
| function commentAuthorLabel(comment: PullRequestComment): string { | ||
| return comment.author?.displayName ?? comment.author?.userName ?? 'Unknown author'; | ||
| } | ||
|
|
||
| function commentLocationLabel(comment: PullRequestComment): string | null { | ||
| if (!comment.path) return null; | ||
| return comment.line ? `${comment.path}:${comment.line}` : comment.path; | ||
| } | ||
|
|
||
| function isBotAuthor(comment: PullRequestComment): boolean { | ||
| return comment.author?.userName.endsWith('[bot]') ?? false; | ||
| } | ||
|
|
||
| function CommentItem({ comment }: { comment: PullRequestComment }) { | ||
| const location = commentLocationLabel(comment); | ||
| const author = commentAuthorLabel(comment); | ||
| const avatarRadiusClass = isBotAuthor(comment) ? 'rounded' : 'rounded-full'; | ||
|
|
||
| return ( | ||
| <div className="group relative flex w-full min-w-0 gap-2 rounded-md px-3 py-2 text-left hover:bg-background-1"> | ||
| {comment.author?.avatarUrl ? ( | ||
| <img | ||
| src={comment.author.avatarUrl} | ||
| alt={author} | ||
| className={cn('mt-0.5 size-5 shrink-0', avatarRadiusClass)} | ||
| /> | ||
| ) : ( | ||
| <div | ||
| className={cn( | ||
| 'mt-0.5 flex size-5 shrink-0 items-center justify-center bg-background-2 text-foreground-muted', | ||
| avatarRadiusClass | ||
| )} | ||
| > | ||
| <MessageSquare className="size-3" /> | ||
| </div> | ||
| )} | ||
| <div className="min-w-0 flex-1"> | ||
| <div className="flex min-w-0 items-center gap-1.5 text-xs text-foreground-muted"> | ||
| <span className="truncate font-medium text-foreground">{author}</span> | ||
| <span className="shrink-0 text-foreground-passive">/</span> | ||
| <RelativeTime compact value={comment.updatedAt} className="shrink-0" /> | ||
| {comment.isResolved && ( | ||
| <> | ||
| <span className="shrink-0 text-foreground-passive">/</span> | ||
| <span className="shrink-0 text-foreground-passive">Resolved</span> | ||
| </> | ||
| )} | ||
| </div> | ||
| {location && ( | ||
| <div className="mt-0.5 truncate font-mono text-[11px] text-foreground-passive"> | ||
| {location} | ||
| </div> | ||
| )} | ||
| <div | ||
| className={cn( | ||
| 'mt-1 break-words text-xs leading-relaxed text-foreground-muted [&_*:last-child]:mb-0 [&_p]:mb-1.5', | ||
| comment.isOutdated && 'text-foreground-passive' | ||
| )} | ||
| > | ||
| <MarkdownRenderer | ||
| content={comment.body} | ||
| variant="compact" | ||
| allowHtml={isBotAuthor(comment)} | ||
| /> | ||
| </div> | ||
| </div> | ||
| <button | ||
| className="absolute right-3 top-2 hidden items-center justify-center rounded bg-background-1 px-1 py-0.5 text-foreground-muted hover:text-foreground group-hover:flex" | ||
| onClick={() => void rpc.app.openExternal(comment.url)} | ||
| > | ||
| <ExternalLink className="size-3.5" /> | ||
| </button> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export function CommentsList({ | ||
| comments, | ||
| isLoading, | ||
| error, | ||
| }: { | ||
| comments: PullRequestComment[]; | ||
| isLoading?: boolean; | ||
| error?: Error | null; | ||
| }) { | ||
| const sorted = useMemo( | ||
| () => | ||
| [...comments].sort( | ||
| (a, b) => new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime() | ||
| ), | ||
|
jschwxrz marked this conversation as resolved.
|
||
| [comments] | ||
| ); | ||
|
|
||
| if (isLoading) { | ||
| return <div className="px-3 py-2 text-xs text-foreground-passive">Loading comments...</div>; | ||
| } | ||
|
|
||
| if (error) { | ||
| return <div className="px-3 py-2 text-xs text-foreground-passive">Unable to load comments</div>; | ||
| } | ||
|
|
||
| if (sorted.length === 0) { | ||
| return <div className="px-3 py-2 text-xs text-foreground-passive">No comments available</div>; | ||
| } | ||
|
|
||
| return ( | ||
| <div className="flex flex-col gap-[1px]"> | ||
| {sorted.map((comment) => ( | ||
| <CommentItem key={comment.id} comment={comment} /> | ||
| ))} | ||
| </div> | ||
| ); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.