@@ -17556,6 +17556,7 @@ async function applyDecisionsCommand(args: Args): Promise<void> {
1755617556 }
1755717557 const updatedSinceReview = Boolean(storedUpdatedAt && item.updatedAt !== storedUpdatedAt);
1755817558 const reviewCommentOnlyUpdate = item.updatedAt === commentUpdatedAt(existingReviewComment);
17559+ const storedUpdatedAtMs = timestampMs(storedUpdatedAt);
1755917560 const labelSyncFreshEnough = (): boolean => {
1756017561 if (!storedUpdatedAt) return false;
1756117562 if (!updatedSinceReview || reviewCommentOnlyUpdate) return true;
@@ -17565,14 +17566,31 @@ async function applyDecisionsCommand(args: Args): Promise<void> {
1756517566 if (Math.abs(itemUpdatedAtMs - existingReviewCommentUpdatedAtMs) > 5 * 60 * 1000) {
1756617567 return false;
1756717568 }
17568- const storedUpdatedAtMs = timestampMs(storedUpdatedAt);
1756917569 if (storedUpdatedAtMs === null) return false;
1757017570 return !contextHasNonAutomationActivityAfter(currentItemContext(), storedUpdatedAtMs);
1757117571 };
1757217572 const stalePrReviewHead =
1757317573 state === "open" && item.kind === "pull_request"
1757417574 ? stalePullRequestReviewHead(markdown, currentItemContext())
1757517575 : null;
17576+ const reportPullHeadSha =
17577+ state === "open" && item.kind === "pull_request" ? pullHeadShaFromReport(markdown) : null;
17578+ const currentPullHeadSha =
17579+ state === "open" && item.kind === "pull_request"
17580+ ? pullHeadShaFromContext(currentItemContext())
17581+ : null;
17582+ const isCompleteSameHeadPullRequestReport =
17583+ Boolean(storedUpdatedAt) &&
17584+ state === "open" &&
17585+ item.kind === "pull_request" &&
17586+ frontMatterValue(markdown, "review_status") === "complete" &&
17587+ !stalePrReviewHead &&
17588+ storedUpdatedAtMs !== null &&
17589+ !contextHasNonAutomationActivityAfter(currentItemContext(), storedUpdatedAtMs) &&
17590+ reportPullHeadSha !== null &&
17591+ reportPullHeadSha === currentPullHeadSha;
17592+ const shouldSyncCurrentPullRequestReviewLabels =
17593+ labelSyncFreshEnough() || (!isCloseProposal && isCompleteSameHeadPullRequestReport);
1757617594 let currentPrStatusKind: PrStatusLabelKind | null = null;
1757717595 if (state === "open" && item.kind === "pull_request") {
1757817596 if (stalePrReviewHead) {
@@ -17588,7 +17606,7 @@ async function applyDecisionsCommand(args: Args): Promise<void> {
1758817606 "current_pull_head_sha",
1758917607 stalePrReviewHead.liveHeadSha,
1759017608 );
17591- } else if (labelSyncFreshEnough() ) {
17609+ } else if (shouldSyncCurrentPullRequestReviewLabels ) {
1759217610 const realBehaviorProof = reportRealBehaviorProof(markdown);
1759317611 const proofSufficientSyncResult = syncRealBehaviorProofSufficientLabel({
1759417612 number,
@@ -17906,7 +17924,9 @@ async function applyDecisionsCommand(args: Args): Promise<void> {
1790617924 const isCurrentCompleteReport =
1790717925 frontMatterValue(markdown, "review_status") === "complete" &&
1790817926 !stalePrReviewHead &&
17909- labelSyncFreshEnough();
17927+ (item.kind === "pull_request"
17928+ ? shouldSyncCurrentPullRequestReviewLabels
17929+ : labelSyncFreshEnough());
1791017930 if (state === "open" && isCurrentCompleteReport) {
1791117931 try {
1791217932 const syncResult = syncPriorityLabel({
0 commit comments