Skip to content

Conversation

@TianyangRen
Copy link
Contributor

@TianyangRen TianyangRen commented Dec 18, 2025

Description

Reduces spam from office-hours reminders by ensuring each user receives only one notification on their most recent open pull request, even if they have multiple PRs open.

Problem

Currently, the office-hours bot posts reminders on all open PRs. When users have multiple PRs open, this creates unnecessary spam and redundant notifications.

Solution

Modified .github/workflows/bot-office-hours.yml to intelligently filter PRs by author and only notify on the most recent one per user.

Implementation Details

The workflow now:

  1. Retrieves all open PRs with metadata

    • Uses gh pr list --json number,author,createdAt to fetch PR data including author and timestamps
  2. Groups and sorts by author

    • Leverages jq to group PRs by author.login
    • Sorts each author's PRs by createdAt in descending order (newest first)
  3. Selects only the most recent PR per user

    • Uses group_by(.author.login) | .[] | sort_by(.createdAt) | reverse | .[0]
    • Ensures each user receives exactly one notification on their latest PR

Changes

  • Modified: .github/workflows/bot-office-hours.yml
  • Updated: CHANGELOG.md

Testing

The changes can be tested by:

  • Triggering the workflow with workflow_dispatch
  • Verifying that users with multiple PRs only receive one notification on their most recent PR

Related Issue

Closes #1121

Checklist

  • Follows Conventional Commits specification
  • Includes changelog entry
  • Commits are signed (GPG + DCO)
  • Workflow logic preserves existing behavior for single-PR users

Summary by CodeRabbit

  • Bug Fixes
    • Office-hours reminders now post only on each author's most recent open PR, reducing notification spam.
    • System treats an empty PR payload as no open PRs to avoid unnecessary processing.
    • Status messages updated to indicate processing of the most recent PR per user rather than every PR.

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI review requested due to automatic review settings December 18, 2025 16:51
@coderabbitai
Copy link

coderabbitai bot commented Dec 18, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

The office-hours GitHub Actions workflow now selects and processes only the most recent open PR per author by using a richer PR_DATA payload and a jq pipeline that groups PRs by author, sorts by creation time, and extracts the latest PR per user before posting reminders.

Changes

Cohort / File(s) Summary
Workflow filtering logic
\.github/workflows/bot-office-hours.yml
Replaced flat PR list with enriched PR_DATA (number, author, createdAt); added guard treating empty/[] PR_DATA as no open PRs; changed loop to group PRs by author, sort by createdAt, select each author’s most recent PR, updated processing message; comment/post logic preserved but now runs on filtered set.
Release notes
CHANGELOG.md
Added Unreleased entry documenting reduced office-hours reminder spam by posting only on each user's most recent open PR (#1121).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Pay attention to the jq pipeline correctness for grouping, sorting, and selecting latest PR per author.
  • Verify PR_DATA structure and the new empty/[] guard behaviour.
  • Confirm the loop now iterates only over the filtered PR numbers and that existing comment/post steps receive expected inputs.

Poem

🐰
Twitched my nose at the noisy spree,
One bright carrot for each dev I see—
The newest branch gets the kindly knock,
Quiet fields now, no double knock! 🥕

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: reducing office-hours reminder spam by posting only on the most recent PR per user, which matches the core objective.
Linked Issues check ✅ Passed The changes fully implement issue #1121 requirements: searching open PRs, ranking by creation time, and posting only to the most recent PR per user.
Out of Scope Changes check ✅ Passed All changes directly address issue #1121 with no unrelated modifications: workflow modifications and changelog entry are both in-scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f4b6abe and 00c4349.

📒 Files selected for processing (2)
  • .github/workflows/bot-office-hours.yml (2 hunks)
  • CHANGELOG.md (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (3)
CHANGELOG.md (1)

56-56: LGTM! Clear changelog entry.

The changelog entry accurately describes the change and follows the project's changelog conventions.

.github/workflows/bot-office-hours.yml (2)

40-40: LGTM! Correct data enrichment.

Fetching author and createdAt fields in addition to number provides the necessary data for grouping and sorting PRs by author.


42-43: LGTM! Empty array check properly implemented.

The check now correctly handles both empty strings and empty JSON arrays ("[]"), addressing the past review comment about GitHub's API returning [] when no PRs exist.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

This PR reduces notification spam from the office-hours reminder bot by ensuring each user receives only one reminder on their most recent open pull request, rather than posting to all of their open PRs.

Key Changes:

  • Modified the workflow to fetch PR metadata (number, author, createdAt) and use jq to group by author and select the most recent PR per user
  • Updated CHANGELOG.md to document this enhancement

Reviewed changes

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

File Description
.github/workflows/bot-office-hours.yml Implements intelligent PR filtering using jq to group PRs by author and select only the most recent one per user for notification
CHANGELOG.md Documents the spam reduction improvement in the Changed section

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 08ba48a and f4b6abe.

📒 Files selected for processing (2)
  • .github/workflows/bot-office-hours.yml (2 hunks)
  • CHANGELOG.md (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Agent
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: StepSecurity Harden-Runner
🔇 Additional comments (3)
CHANGELOG.md (1)

56-56: LGTM!

The changelog entry accurately describes the change and correctly references the linked issue #1121.

.github/workflows/bot-office-hours.yml (2)

62-63: LGTM!

The jq pipeline correctly groups PRs by author, sorts each group by creation time descending, and extracts the most recent PR number per user. ISO 8601 date strings sort lexicographically as expected.


65-72: LGTM!

The comment deduplication logic is preserved correctly. The grep -F with || true properly handles both the presence and absence of prior notifications.

@TianyangRen TianyangRen force-pushed the fix/office-hours-spam-clean branch from f4b6abe to 00c4349 Compare December 18, 2025 16:56
@codecov
Copy link

codecov bot commented Dec 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1150   +/-   ##
=======================================
  Coverage   91.11%   91.11%           
=======================================
  Files         139      139           
  Lines        8451     8451           
=======================================
  Hits         7700     7700           
  Misses        751      751           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@exploreriii exploreriii merged commit cacd167 into hiero-ledger:main Dec 19, 2025
20 checks passed
@exploreriii
Copy link
Contributor

Thank you @TianyangRen for this excellent improvement!

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.

Edit office hour bot to post once per user

2 participants