Skip to content

Cs 10504/pr card should add approved or request changed by which reviewer#4254

Open
lucaslyl wants to merge 5 commits intomainfrom
CS-10504/pr-card-should-add-approved-or-request-changed-by-which-reviewer
Open

Cs 10504/pr card should add approved or request changed by which reviewer#4254
lucaslyl wants to merge 5 commits intomainfrom
CS-10504/pr-card-should-add-approved-or-request-changed-by-which-reviewer

Conversation

@lucaslyl
Copy link
Contributor

linear: https://linear.app/cardstack/issue/CS-10504/pr-card-should-add-approved-or-request-changed-by-which-reviewer

  1. Show reviewer name and comment for both approved and changes_requested reviews
  2. Display "by {reviewer}" on the review state badge for PR cards.
image

@lucaslyl lucaslyl requested a review from a team March 26, 2026 12:59
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d4c5874316

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +173 to +175
if (state === 'changes_requested') {
return findLatestChangesRequestedEvent(this.latestReviewByReviewer);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Derive reviewer badge from latest review state, not comment event

latestPrReviewCommentEventInstance is used as the source for reviewer attribution, and in the changes_requested branch it calls findLatestChangesRequestedEvent(...), which filters out reviews with empty bodies. In GitHub, a reviewer can request changes without a summary body, so this flow can produce a Changes Requested state while omitting the reviewer name in the new "by {reviewer}" badge (and review header). The reviewer for badge/state should come from the latest matching review state even when the comment body is empty.

Useful? React with 👍 / 👎.

@github-actions
Copy link

github-actions bot commented Mar 26, 2026

Host Test Results

    1 files  ±0      1 suites  ±0   2h 8m 14s ⏱️ - 2m 13s
2 056 tests +5  2 041 ✅ +5  15 💤 ±0  0 ❌ ±0 
2 071 runs  +5  2 056 ✅ +5  15 💤 ±0  0 ❌ ±0 

Results for commit 8a29db0. ± Comparison against base commit 724fc8b.

♻️ This comment has been updated with latest results.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the catalog realm PR card review UI so it can attribute “Approved” / “Changes Requested” states to a specific reviewer and show the associated review details.

Changes:

  • Add support for selecting the latest approved review event (in addition to changes requested).
  • Update the PR card to surface reviewer name/comment/link for both approval and changes-requested states.
  • Update the review state badge to append “by {reviewer}” when available.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
packages/catalog-realm/pr-card/utils.ts Adds helper to find the latest approved review event; adjusts changes-requested lookup.
packages/catalog-realm/pr-card/pr-card.gts Chooses the latest relevant review event based on overall review state and passes reviewer/comment/link into the review section.
packages/catalog-realm/pr-card/components/isolated/review-section.gts Extends badge args to include reviewer name and renders “by {reviewer}”.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +121 to +124
<ReviewStateBadge
@state={{@reviewState}}
@reviewerName={{@reviewerName}}
/>
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewerName is now allowed to be null and is passed through to ReviewStateBadge. If null is possible in practice, the badge will omit the "by …" suffix and the rest of the section may also end up showing no author. Consider normalizing reviewerName to a non-empty display string before passing it into the section/badge (e.g. "Unknown reviewer").

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When @reviewerName is null, Handlebars' {{#if null}} evaluates to falsy, so the by ... block doesn't render. The badge will only show "Approved" or "Changes Requested" without the "by" suffix.

Showing "Unknown reviewer" would make users think something is broken or the data is wrong

Comment on lines 296 to +317
export function findLatestChangesRequestedEvent(
latestReviewByReviewer: Map<string, any>,
): any | null {
let activeChangesRequestedEvents = [...latestReviewByReviewer.values()].filter(
let activeChangesRequestedEvents = [
...latestReviewByReviewer.values(),
].filter(
(event: any) =>
normalizeReviewState(event?.payload?.review?.state) ===
'changes_requested' &&
(event?.payload?.review?.body ?? '').trim().length > 0,
'changes_requested',
);
return activeChangesRequestedEvents[0] ?? null;
}

export function findLatestApprovedEvent(
latestReviewByReviewer: Map<string, any>,
): any | null {
let approvedEvents = [...latestReviewByReviewer.values()].filter(
(event: any) =>
normalizeReviewState(event?.payload?.review?.state) === 'approved',
);
return approvedEvents[0] ?? null;
}
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both findLatestChangesRequestedEvent and findLatestApprovedEvent build an intermediate array via filter(...)[0]. Since only the first match is used, Array.prototype.find would avoid the extra allocation and work (especially as the number of reviewers grows).

Copilot uses AI. Check for mistakes.
get latestReviewerName() {
return (
this.latestPrReviewCommentEventInstance?.payload?.review?.user?.login ??
null
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

latestReviewerName now falls back to null when the review payload is missing user.login. That makes the reviewer label/badge render blank (and also prevents showing "by …"), which undermines the goal of showing who approved/requested changes. Consider restoring a string fallback like "Unknown reviewer" (as before) or ensuring the UI renders a placeholder when the name is missing.

Suggested change
null
'Unknown reviewer'

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for this

Comment on lines 171 to 180
get latestPrReviewCommentEventInstance() {
return findLatestChangesRequestedEvent(this.latestReviewByReviewer);
}

get latestChangesRequestedReviewerName() {
return (
this.latestPrReviewCommentEventInstance?.payload?.review?.user?.login ??
'Unknown reviewer'
);
let state = this.latestReviewState;
if (state === 'changes_requested') {
return findLatestChangesRequestedEvent(this.latestReviewByReviewer);
}
if (state === 'approved') {
return findLatestApprovedEvent(this.latestReviewByReviewer);
}
return null;
}
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

latestPrReviewCommentEventInstance can now return an approved review event as well as a changes-requested one. The name is now misleading and increases the chance of future mistakes (e.g., someone assuming it only exists when there’s a comment). Consider renaming this getter (and the dependent getters) to something like latestPrReviewEventInstance or similar.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@tintinthong tintinthong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test coverage pls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants