diff --git a/src/main/github/client.ts b/src/main/github/client.ts index e533b9204..0a4126379 100644 --- a/src/main/github/client.ts +++ b/src/main/github/client.ts @@ -2416,6 +2416,7 @@ export async function getPRComments( path: c.path, threadId: thread.id, isResolved: thread.isResolved, + isOutdated: thread.line == null, // Why: GitHub nulls out line/startLine when the commented code is // outdated (e.g. after a force-push). Fall back to originalLine which // always preserves the line numbers from when the comment was created. diff --git a/src/renderer/src/assets/main.css b/src/renderer/src/assets/main.css index 59d927600..f8a63f664 100644 --- a/src/renderer/src/assets/main.css +++ b/src/renderer/src/assets/main.css @@ -1343,6 +1343,63 @@ letter-spacing: 0.03em; } +.orca-diff-comment-author-row { + display: flex; + min-width: 0; + align-items: center; + gap: 6px; + margin: 0 0 6px; + color: var(--muted-foreground); + font-size: 11px; + line-height: 1.2; +} + +.orca-diff-comment-avatar { + width: 18px; + height: 18px; + flex: 0 0 auto; + border-radius: 50%; + border: 1px solid color-mix(in srgb, var(--foreground) 15%, transparent); + background: var(--muted); +} + +.orca-diff-comment-avatar-fallback { + display: inline-flex; + align-items: center; + justify-content: center; + color: var(--muted-foreground); + font-size: 10px; + font-weight: 600; +} + +.orca-diff-comment-author { + min-width: 0; + overflow: hidden; + color: var(--foreground); + font-weight: 600; + text-overflow: ellipsis; + white-space: nowrap; +} + +.orca-diff-comment-created-at { + flex: 0 0 auto; +} + +.orca-diff-comment-link { + margin-left: auto; + flex: 0 0 auto; + border: 0; + background: transparent; + color: var(--muted-foreground); + font: inherit; + cursor: pointer; +} + +.orca-diff-comment-link:hover { + color: var(--foreground); + text-decoration: underline; +} + /* Why: keep edit + delete close together but visually distinct from the meta label. Both share the same subtle button styling; only delete recolours on hover (destructive intent). */ @@ -1408,6 +1465,10 @@ word-break: break-word; } +.orca-diff-comment-review-body { + padding-left: 24px; +} + /* Why: mirror the saved-note card treatment so the "entering" and "saved" states read as the same object at two stages of the same flow. Same foreground-tinted fill over --editor-surface, same border + left accent diff --git a/src/renderer/src/components/GitHubItemDialog.tsx b/src/renderer/src/components/GitHubItemDialog.tsx index 0d702028d..ce366dc51 100644 --- a/src/renderer/src/components/GitHubItemDialog.tsx +++ b/src/renderer/src/components/GitHubItemDialog.tsx @@ -66,6 +66,7 @@ import CommentMarkdown from '@/components/sidebar/CommentMarkdown' import { detectLanguage } from '@/lib/language-detect' import { cn } from '@/lib/utils' import { DiffSectionItem } from '@/components/editor/DiffSectionItem' +import type { DecoratedDiffComment } from '@/components/diff-comments/useDiffCommentDecorator' import { CombinedDiffFileTree, createCombinedDiffSectionIndexMap, @@ -1542,6 +1543,7 @@ function getPRFileDiffResult(contents: GitHubPRFileContents): GitDiffResult { type PRFilesCombinedDiffViewerProps = { files: GitHubPRFile[] + comments: PRComment[] repoPath: string repoId: string prNumber: number @@ -1555,6 +1557,7 @@ type PRFilesCombinedDiffViewerProps = { function PRFilesCombinedDiffViewer({ files, + comments, repoPath, repoId, prNumber, @@ -1596,6 +1599,37 @@ function PRFilesCombinedDiffViewer({ return nextEntries }, [diffEntrySignature, files]) const fileByPath = useMemo(() => new Map(files.map((file) => [file.path, file])), [files]) + const inlineReviewComments = useMemo( + () => + comments.flatMap((comment): DecoratedDiffComment[] => { + // Why: stale threads keep originalLine for the sidebar, but rendering + // that number inline can attach the comment to unrelated current code. + if (comment.isOutdated || !comment.path || typeof comment.line !== 'number') { + return [] + } + const createdAtMs = new Date(comment.createdAt).getTime() + return [ + { + id: `github-pr-comment:${comment.id}`, + worktreeId: `github-pr:${repoId}:${prNumber}`, + filePath: comment.path, + source: 'diff', + startLine: comment.startLine, + lineNumber: comment.line, + body: comment.body, + createdAt: Number.isFinite(createdAtMs) ? createdAtMs : Date.now(), + side: 'modified', + author: comment.author, + authorAvatarUrl: comment.authorAvatarUrl, + createdAtLabel: formatRelativeTime(comment.createdAt), + url: comment.url, + canDelete: false, + canEdit: false + } + ] + }), + [comments, prNumber, repoId] + ) const entrySignature = useMemo( () => JSON.stringify({ @@ -1985,6 +2019,7 @@ function PRFilesCombinedDiffViewer({ settings={settings} sectionHeight={sectionHeights[virtualItem.index]} worktreeId={`github-pr:${repoId}:${prNumber}`} + inlineComments={inlineReviewComments} loadSection={loadSection} retrySection={retrySection} toggleSection={toggleSection} @@ -5501,6 +5536,7 @@ export default function GitHubItemDialog({ ) : ( void + author?: string + authorAvatarUrl?: string + createdAtLabel?: string + url?: string + onDelete?: () => void // Why: Monaco view zones have a fixed `heightInPx` set at insertion time // and aren't auto-measured. While the user is in edit mode the textarea // grows, so the parent decorator passes a callback we fire on resize and @@ -35,6 +40,10 @@ export function DiffCommentCard({ label, body, sentAt, + author, + authorAvatarUrl, + createdAtLabel, + url, onDelete, onContentResize, onSubmitEdit, @@ -107,6 +116,7 @@ export function DiffCommentCard({ const trimmedDraft = draft.trim() const canSubmit = !submitting && trimmedDraft.length > 0 && trimmedDraft !== body + const lineLabel = label ?? getDiffCommentLineLabel({ lineNumber, startLine }).toLowerCase() const handleSubmit = async (): Promise => { if (!canSubmit || !onSubmitEdit) { @@ -133,7 +143,7 @@ export function DiffCommentCard({
- Note · {label ?? getDiffCommentLineLabel({ lineNumber, startLine }).toLowerCase()} + {author ? 'Review comment' : 'Note'} · {lineLabel} {sentAt ? ' · sent' : ''}
@@ -154,7 +164,7 @@ export function DiffCommentCard({ )} - {!editing && ( + {onDelete && !editing && (
+ {author ? ( +
+ {authorAvatarUrl ? ( + + ) : ( + + {author.slice(0, 1).toUpperCase()} + + )} + {author} + {createdAtLabel ? ( + {createdAtLabel} + ) : null} + {url ? ( + + ) : null} +
+ ) : null} {editing ? ( <>