Skip to content

Commit 8e29e17

Browse files
Copilotalexr00
andcommitted
Hide outdated comments in PR overview with minimal timeline item
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 148c109 commit 8e29e17

2 files changed

Lines changed: 41 additions & 11 deletions

File tree

webviews/components/timeline.tsx

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ const ReviewEventView = (event: ReviewEvent) => {
229229

230230
function CommentThread({ thread, event }: { thread: IComment[]; event: ReviewEvent }) {
231231
const comment = thread[0];
232-
const [revealed, setRevealed] = useState(!comment.isResolved);
232+
const isOutdated = comment.position === null;
233+
const [revealed, setRevealed] = useState(!comment.isResolved && !isOutdated);
233234
const [resolved, setResolved] = useState(!!comment.isResolved);
234235
const { openDiff, toggleResolveComment } = useContext(PullRequestContext);
235236
const resolvePermission =
@@ -246,20 +247,26 @@ function CommentThread({ thread, event }: { thread: IComment[]; event: ReviewEve
246247
}
247248
};
248249

250+
// For outdated comments, show a minimal timeline item
251+
if (isOutdated) {
252+
return (
253+
<div key={event.id} className="diff-container">
254+
<div className="outdated-comment">
255+
<span className="outdated-comment-label">This comment was marked as outdated.</span>
256+
{nbsp}
257+
<a href={comment.htmlUrl} target="_blank" rel="noopener noreferrer">View in GitHub</a>
258+
</div>
259+
</div>
260+
);
261+
}
262+
249263
return (
250264
<div key={event.id} className="diff-container">
251265
<div className="resolved-container">
252266
<div>
253-
{comment.position === null ? (
254-
<span>
255-
<span>{comment.path}</span>
256-
<span className="outdatedLabel">Outdated</span>
257-
</span>
258-
) : (
259-
<a className="diffPath" onClick={() => openDiff(comment)}>
260-
{comment.path}
261-
</a>
262-
)}
267+
<a className="diffPath" onClick={() => openDiff(comment)}>
268+
{comment.path}
269+
</a>
263270
{!resolved && !revealed ? <span className="unresolvedLabel">Unresolved</span> : null}
264271
</div>
265272
<button className="secondary" onClick={() => setRevealed(!revealed)}>

webviews/editorWebview/index.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,29 @@ body .resolved-container .unresolvedLabel {
418418
margin-left: 5px;
419419
}
420420

421+
body .outdated-comment {
422+
padding: 12px 16px;
423+
background: var(--vscode-editor-background);
424+
border: 1px solid var(--vscode-panel-border);
425+
border-radius: 4px;
426+
margin: 8px 0;
427+
color: var(--vscode-descriptionForeground);
428+
font-size: 13px;
429+
}
430+
431+
body .outdated-comment .outdated-comment-label {
432+
font-style: italic;
433+
}
434+
435+
body .outdated-comment a {
436+
color: var(--vscode-textLink-foreground);
437+
text-decoration: none;
438+
}
439+
440+
body .outdated-comment a:hover {
441+
text-decoration: underline;
442+
}
443+
421444
body .diff .diffPath {
422445
margin-right: 4px;
423446
}

0 commit comments

Comments
 (0)