Skip to content

refactor: extract bot inactivity comment builders to bot-inactivity-comments.js#1654

Open
utkarsh232005 wants to merge 1 commit into
hiero-ledger:mainfrom
utkarsh232005:fix/1598-abstract-bot-inactivity-comments
Open

refactor: extract bot inactivity comment builders to bot-inactivity-comments.js#1654
utkarsh232005 wants to merge 1 commit into
hiero-ledger:mainfrom
utkarsh232005:fix/1598-abstract-bot-inactivity-comments

Conversation

@utkarsh232005

Copy link
Copy Markdown
Contributor

Summary

Resolves #1598

The four comment builder functions (, , , ) and the two HTML marker constants (, ) have been moved from bot-inactivity.js into a new sibling file bot-inactivity-comments.js.

This follows the established *.js*-comments.js pattern used by the commands/ bots (assign, finalize, unassign), making the inactivity bot consistent with the rest of the bot system.

Changes

  • Create .github/scripts/bot-inactivity-comments.js with SPDX header, the two HTML markers, and all four builder functions exported via module.exports.
  • Update buildWarningComment and buildClosureComment signatures to accept duration values (warnAfterMs, closeAfterMs) as parameters instead of reading module-level constants, keeping WARN_AFTER_MS, CLOSE_AFTER_MS, and BLOCKED_CHECKIN_AFTER_MS as a single source of truth in bot-inactivity.js.
  • Refactor bot-inactivity.js to replace inline definitions with a require('./bot-inactivity-comments') import.
  • Update call sites in handleStaleItem to pass the duration constants into the builders.

Verification

  • ✅ All 34 existing tests in tests/test-inactivity-bot.js pass without modification.
  • ✅ ESLint is clean.
  • ✅ No behavioral change — warn, close, linked-PR-closed, and blocked-checkin comments render identically.

Checklist

  • .github/scripts/bot-inactivity-comments.js exists at the top level, colocated with bot-inactivity.js
  • The four builders and the two HTML markers live in the new file
  • bot-inactivity.js imports them and no longer defines them inline
  • Duration constants (WARN_AFTER_MS, CLOSE_AFTER_MS, BLOCKED_CHECKIN_AFTER_MS) remain in bot-inactivity.js
  • Existing tests pass without behavioral changes
  • ESLint is clean
  • No unrelated changes to bot logic or other files

…omments.js

Resolves hiero-ledger#1598

The four comment builder functions (buildWarningComment, buildClosureComment,
buildLinkedPRClosedComment, buildBlockedCheckinComment) and the two HTML
marker constants (WARN_MARKER, BLOCKED_CHECKIN_MARKER) have been moved from
bot-inactivity.js into a new sibling file bot-inactivity-comments.js.

This follows the established *.js <-> *-comments.js pattern used by the
commands/ bots (assign, finalize, unassign), making the inactivity bot
consistent with the rest of the bot system.

Changes:
- Create .github/scripts/bot-inactivity-comments.js with SPDX header,
  the two HTML markers, and all four builder functions exported via
  module.exports.
- Update buildWarningComment and buildClosureComment signatures to accept
  duration values (warnAfterMs, closeAfterMs) as parameters instead of
  reading module-level constants, keeping WARN_AFTER_MS, CLOSE_AFTER_MS,
  and BLOCKED_CHECKIN_AFTER_MS as a single source of truth in
  bot-inactivity.js.
- Replace inline definitions in bot-inactivity.js with a
  require('./bot-inactivity-comments') import.
- Update call sites in handleStaleItem to pass the duration constants into
  the builders.

All 34 existing tests in tests/test-inactivity-bot.js continue to pass
without modification. ESLint is clean. No behavioral change.

Signed-off-by: utkarsh patrikar <utkarshpatrikar@gmail.com>
Copilot AI review requested due to automatic review settings May 16, 2026 15:41
@utkarsh232005 utkarsh232005 requested review from a team as code owners May 16, 2026 15:41
@utkarsh232005 utkarsh232005 requested a review from rwalworth May 16, 2026 15:41
@github-actions

Copy link
Copy Markdown

Hey @utkarsh232005 👋 thanks for the PR!
I'm your friendly PR Helper Bot 🤖 and I'll be riding shotgun on this one, keeping track of your PR's status to help you get it approved and merged.

This comment updates automatically as you push changes -- think of it as your PR's live scoreboard!
Here's the latest:


PR Checks

DCO Sign-off -- All commits have valid sign-offs. Nice work!


GPG Signature -- All commits have verified GPG signatures. Locked and loaded!


Merge Conflicts -- No merge conflicts detected. Smooth sailing!


Issue Link -- Linked to #1598 (assigned to you).


🎉 All checks passed! Your PR is ready for review. Great job!

@github-actions github-actions Bot added the status: needs review The pull request is ready for maintainer review label May 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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

Labels

status: needs review The pull request is ready for maintainer review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Beginner]: Bot inactivity comments can be abstracted

2 participants