Skip to content

fix(github): skip progress-comment edits whose visible content is unchanged#757

Open
aparajon wants to merge 1 commit into
mainfrom
armand/progress-comment-dedupe
Open

fix(github): skip progress-comment edits whose visible content is unchanged#757
aparajon wants to merge 1 commit into
mainfrom
armand/progress-comment-dedupe

Conversation

@aparajon

@aparajon aparajon commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Why this matters

A stagnant apply re-edits its PR progress comment every 30 seconds forever, even though every render is byte-identical except for two re-stamped timestamps (the "Last updated" footer and the attribution line). Each of those PATCHes spends the installation's shared GitHub write budget — under the secondary content-creation limit, a handful of stalled long-running applies is real pressure — while changing nothing a reader can see.

What it does

  • Adds templates.CommentContentKey, which collapses rendered timestamps out of a comment body. Two renders of an unchanged status produce equal keys; any real change (rows, state, checksum) produces a different key. Durations such as the revert-window countdown survive in the key, so comments where the passage of time is the information keep editing live.
  • The observer remembers the content key it last wrote per GitHub comment ID and skips edits whose key is unchanged. A cache miss (e.g. the handler-posted initial comment) always edits — uncertainty degrades to an extra edit, never a missed one.
  • A comment younger than 10 minutes always edits, even when unchanged. Young comments are the ones people actively watch — apply just started, setup phase, first rows copying — and an early stall must not read as SchemaBot going silent. The grace cost is bounded (a stagnant young comment refreshes at most every 30s for 10 minutes), and rotation-created comments get a fresh window since a new comment means someone just acted.
  • Past the grace window, the "Last updated" footer doubles as a liveness signal, so skips lapse after a 10-minute heartbeat: a stalled apply's comment still refreshes a few times an hour to show SchemaBot is watching, instead of freezing indefinitely.
tick → render → content key
        comment <10m old ──── edit (grace: always fresh while watched)
        key unchanged  ─┬─ written <10m ago → skip (no PATCH)
                        └─ written ≥10m ago → edit (liveness refresh)
        key changed    ──── edit immediately

🤖 Generated with Claude Code

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.

Pull request overview

This PR reduces unnecessary GitHub API write traffic by avoiding progress-comment edits when the rendered status is unchanged aside from auto-stamped timestamps, while still ensuring periodic “liveness” updates.

Changes:

  • Added templates.CommentContentKey to normalize rendered comment bodies by collapsing render-time timestamps into a stable comparison key.
  • Updated CommentObserver to cache the last written content key per GitHub comment ID and skip PATCH edits when the key is unchanged, with a 10-minute heartbeat to refresh the “Last updated” footer.
  • Added unit and integration coverage validating both skip behavior and heartbeat refresh behavior.

Reviewed changes

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

File Description
pkg/webhook/templates/common.go Adds timestamp-collapsing CommentContentKey used to compare rendered comment “visible content”.
pkg/webhook/templates/common_test.go Unit tests for CommentContentKey stability across re-renders and sensitivity to real progress changes/countdowns.
pkg/webhook/comment_observer.go Adds last-written caching and heartbeat-based skip logic to avoid redundant GitHub comment edits.
pkg/webhook/apply_comment_integration_test.go Integration tests verifying identical renders are skipped and heartbeat refreshes still occur.

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

…hanged

A stagnant apply re-edits its progress comment every 30 seconds forever,
even though each render differs only in re-stamped timestamps (the "Last
updated" footer and the attribution line). Those PATCHes spend the
installation's shared GitHub write budget without showing readers
anything new.

templates.CommentContentKey collapses rendered timestamps out of a
comment body so two renders of an unchanged status compare equal, while
real changes (rows, state, checksum) and live durations (revert-window
countdown) still differ. The observer remembers the key it last wrote
per GitHub comment ID and skips edits whose key is unchanged; a cache
miss always edits.

Two guards keep unchanged comments from reading as SchemaBot going
silent: a comment younger than its 10-minute grace window always edits
(young comments are actively watched, and an early stall is exactly
when a frozen footer is most alarming — rotation-created comments get a
fresh window), and past the grace window skips lapse after a 10-minute
heartbeat so a stalled apply's comment still refreshes a few times an
hour.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@aparajon
aparajon force-pushed the armand/progress-comment-dedupe branch from 76f5734 to 290a5dd Compare July 19, 2026 00:04
@aparajon
aparajon marked this pull request as ready for review July 19, 2026 02:00
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.

2 participants