You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(pr-watch): report a head's CI result once when two runs in a suite share a name - #52701
Orca kept posting "CI green" to a chat every poll for the same commit. That happened when a PR had two check runs with the same name in one suite. Now it posts once.
What Changed
Before: a head with two same-named runs in one check suite got a new "CI green" (or failure) line on every PR-watch poll.
After: each real result gets one line. A real rerun still posts a line.
Mechanism: evaluatePRCheckOccurrence (src/main/github/pr-watch/pr-check-occurrence.ts) now builds observed contexts through observedContexts. It sorts the runs by run id and adds #2, #3, ... to the key of each repeated name, so each run gets its own saved row.
Why
The context key is suite + name, so two same-named runs shared one saved row. On every read, one of the two had a different run id from the saved row, which looks like a rerun, so a new occurrence was reported. That collision is the root cause, and giving each run its own deterministic key fixes it at the source. GitHub can return the runs in any order, which is why they are sorted by run id first.
N/A. This is main-process PR-watch logic with no UI change. The visible effect (no repeated chat lines) is covered by the unit test and the probes below.
Testing
The new test pr-check-occurrence.test.ts reads the same head twice, with the same-named runs in a different order the second time. It fails on main (expected 'success' to be null) and passes with this change.
Probe scenarios, run against main and then this branch:
Five identical polls with the runs in rotated order: 5 events on main, 1 on this branch.
A real rerun of one of the pair: 2 events (one per real result).
Pending to complete across run ids 9 and 10 (a digit boundary): 2 events.
Three same-named runs across two suites with a failure: 6 events on main, 1 on this branch.
Heads where every run name is unique: no change from main.
Ran the targeted vitest on src/main/github/pr-watch/, oxlint, oxfmt, the anti-slop, code-quality and ast-grep gates, and the changed-code quality gate. All pass. Checked on macOS. The logic has no platform-specific code.
Performance
PR-watch polling runs in the main process, once per watched head per poll. The cost is one sort and one map over that head's check rows. Per evaluatePRCheckOccurrence call:
Check rows on the head
main
this PR
30 (typical)
~10 us
~14 us
100
~33 us
~49-59 us
1000 (adversarial)
~330 us
~650 us
5000 (adversarial)
~1.6 ms
~3.7-4.3 ms
Every case stays far under 16 ms. It adds no I/O, subprocess or polling. The work scales only with that head's own rows, not with other watched PRs.
Risk
Level: Low
The first read after upgrading can post one extra CI line for a head with same-named runs, because the #2 key is new to the saved rows. Edge case: a job literally named Publish#2 next to two Publish runs could collide. That is unlikely and no worse than main. The key is a value in an existing text column, so there is no schema change. A plain revert backs it out.
Review
Main-process logic only, with no path, shell or platform code, so it behaves the same on macOS, Linux, Windows and SSH hosts. No IPC or mobile protocol change.
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
Targeted tests, lint, format and static gates pass locally; CI covers the full suite
The reason will be displayed to describe this comment to others. Learn more.
Generated keys match real names
Two runs named build and one named build#2 in the same suite produce two rows with the same context. The database keeps only one, so an unchanged poll still reports a new CI result. Use a collision-free key for repeated names and add this case to the regression test.
No actionable comments were generated in the recent review.
Walkthrough
The occurrence evaluator now sorts observed checks by run ID and assigns distinct context keys to repeated check names in one suite. It uses those keys when comparing observations and saving state. A new test verifies that evaluating the same runs in a different order returns a null verdict.
Merge Risk: Low · up to f39ca
The change fixes repeated "CI green" messages for same-named check runs. Two edge cases remain: a check named like a generated suffix, and runs with null IDs. In those cases an extra notification could still appear. This is low impact and unlikely to be hit.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the fix (pr-watch) and the specific behavior: a head's CI result is reported once when two runs in a suite share a name. This matches the raw summary, which describes disambiguating sa…
Description check
The description follows the repository template. It includes ELI5, What Changed, Why, Linked Issue (Fixes #52700), Visual Proof (N/A with reason), Testing with checklist items, Performance with a one-…
Linked Issues check
Issue #52700 requires one "CI green" line per commit when two same-named check runs share one check suite. The whole-PR diff (merge base to head f39ca35) adds observedContexts() in src/main/github/pr-…
Out of Scope Changes check
The whole-PR diff against merge base 9b27fdb touches only src/main/github/pr-watch/pr-check-occurrence.ts (observedContexts helper and its use in evaluatePRCheckOccurrence) and the new test file src/m…
Full details: Title check
Explanation
The title names the fix (pr-watch) and the specific behavior: a head's CI result is reported once when two runs in a suite share a name. This matches the raw summary, which describes disambiguating same-named check runs so each occurrence is tracked separately and unchanged reads return null. The title is specific and scoped to the main change.
Full details: Description check
Explanation
The description follows the repository template. It includes ELI5, What Changed, Why, Linked Issue (Fixes #52700), Visual Proof (N/A with reason), Testing with checklist items, Performance with a one-line justification, Risk with a level and revert plan, AI Disclosure, Review, the upstream boundary checkbox, Notes, and the checklist. The 'Fixes #' placeholder in the template is filled with a real issue number. The Risk section names the riskiest part (one extra CI line for PRs with same-named runs) and how to back it out.
Full details: Linked Issues check
Explanation
Issue #52700 requires one "CI green" line per commit when two same-named check runs share one check suite. The whole-PR diff (merge base to head f39ca35) adds observedContexts() in src/main/github/pr-watch/pr-check-occurrence.ts. It sorts observed rows by runId and appends #2, #3 to repeated context keys (check:<suiteId>:<name>). evaluatePRCheckOccurrence() now calls observedContexts(rollup) instead of the earlier per-row flatMap. Each run keeps its own key, so an unchanged read compares equal and reports no new final verdict. A real rerun gets a new run id, so it still reports. The new test in pr-check-occurrence.test.ts reads two skipped same-named runs in one suite, then reads them again in a different order with the prior contexts, and expects verdict null on the second read. I did not run the test, so the claim that it fails without the fix rests on code reading. The incremental diff from the previous reviewed head (3cbc31e) could not be read, so this verdict uses the whole-PR diff. Minor uncertainty: keys are assigned by a string sort of runId, so a rerun that changes sort order could move the suffix between runs. The test does not cover that case. The PR description states one extra line appears after update, which the issue allows.
Full details: Out of Scope Changes check
Explanation
The whole-PR diff against merge base 9b27fdb touches only src/main/github/pr-watch/pr-check-occurrence.ts (observedContexts helper and its use in evaluatePRCheckOccurrence) and the new test file src/main/github/pr-watch/pr-check-occurrence.test.ts. Both serve issue #52700: the helper implements the fix and the test covers its regression. No unrelated source, UI, IPC, schema, or dependency change appears in the reviewed diff. The PR description's non-code sections do not add code changes.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Break ties between null-ID runs by state in observedContexts.
Runs with a null databaseId get runId: null, so their sort key is ''. Two same-name runs in one suite with null IDs compare as equal. toSorted is stable, so the rollup's input order decides which run receives the base key and which receives #2. If the rows arrive in the other order on a later read, the keys swap between states. The final comparison then sees a state change for both keys and can emit another verdict line, even though no check changed. The CheckRun schema permits a nulldatabaseId, and prCheckRollupRows passes such rows through without filtering.
Break the tie by state so the key assignment does not depend on input order:
Numeric run IDs still sort first, so the existing behavior for distinct IDs does not change. Add a test with two same-name null-ID runs in both input orders.
Committable suggestion
IMPORTANT
Review the replacement and indentation, then test before committing.
…e share a name
Check runs were keyed by suite and name, so two same-named runs in one
suite shared one saved row. Every poll one of them carried a different run
id than the saved row and read as a rerun, posting a new "CI green" line
for the same head. Sort observed runs by run id and suffix repeated names
(stablyai#2, stablyai#3) so each run keeps its own row and an unchanged read compares equal.
Fixesstablyai#52700
Co-authored-by: Neil <[email protected]>
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
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.
ELI5
Orca kept posting "CI green" to a chat every poll for the same commit. That happened when a PR had two check runs with the same name in one suite. Now it posts once.
What Changed
evaluatePRCheckOccurrence(src/main/github/pr-watch/pr-check-occurrence.ts) now builds observed contexts throughobservedContexts. It sorts the runs by run id and adds#2,#3, ... to the key of each repeated name, so each run gets its own saved row.Why
The context key is suite + name, so two same-named runs shared one saved row. On every read, one of the two had a different run id from the saved row, which looks like a rerun, so a new occurrence was reported. That collision is the root cause, and giving each run its own deterministic key fixes it at the source. GitHub can return the runs in any order, which is why they are sorted by run id first.
Linked Issue
Fixes #52700
Visual Proof
N/A. This is main-process PR-watch logic with no UI change. The visible effect (no repeated chat lines) is covered by the unit test and the probes below.
Testing
pr-check-occurrence.test.tsreads the same head twice, with the same-named runs in a different order the second time. It fails on main (expected 'success' to be null) and passes with this change.src/main/github/pr-watch/, oxlint, oxfmt, the anti-slop, code-quality and ast-grep gates, and the changed-code quality gate. All pass. Checked on macOS. The logic has no platform-specific code.Performance
PR-watch polling runs in the main process, once per watched head per poll. The cost is one sort and one map over that head's check rows. Per
evaluatePRCheckOccurrencecall:Every case stays far under 16 ms. It adds no I/O, subprocess or polling. The work scales only with that head's own rows, not with other watched PRs.
Risk
Level: Low
The first read after upgrading can post one extra CI line for a head with same-named runs, because the
#2key is new to the saved rows. Edge case: a job literally namedPublish#2next to twoPublishruns could collide. That is unlikely and no worse than main. The key is a value in an existing text column, so there is no schema change. A plain revert backs it out.Review
Main-process logic only, with no path, shell or platform code, so it behaves the same on macOS, Linux, Windows and SSH hosts. No IPC or mobile protocol change.
Agent skill upstream boundary
Checklist
N/Awith reasonOriginal fix by @NicholasTing.