Skip to content

fix(ci): Only post the token cost comment when the MCP surface changes - #2533

Merged
BYK merged 2 commits into
mainfrom
fix/token-cost-comment-only-on-change
Nov 26, 2026
Merged

BYK merged 2 commits into
mainfrom
fix/token-cost-comment-only-on-change

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

token-cost.yml runs on any change to the root pnpm-lock.yaml, package.json, or pnpm-workspace.yaml. Since #2413 removed the "token count changed" guard, the workflow also comments on every run, so CLI-only PRs that touch the lockfile (such as #2507) get an MCP token cost report.

This PR moves the comment step into scripts/token-cost-comment.mjs, which decides what to do:

It also paginates listComments. The old step read only the first 30 comments, so on busy PRs it could post a duplicate report.

The path filters are unchanged. A real dependency bump can still change the MCP output, so lockfile changes should keep triggering the measurement and the Token Cost check run. They just stay quiet when the measurement matches main.

via @BYK.

--

View Session [Sentry]

The Token Cost workflow runs on any pnpm-lock.yaml change, and since
#2413 it comments on every run, so CLI-only PRs that touch
the lockfile get an MCP token cost report.

Move the comment step into scripts/token-cost-comment.mjs. It now comments
only when token-stats.json or ui-stats.json differ from main's last
artifact, which also catches view-only changes. An existing comment is
still updated on each run so it never shows stale numbers.

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
@vercel

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cli Ready Ready Preview Nov 26, 2026 5:55pm UTC
sentry-local Ready Ready Preview Nov 26, 2026 5:55pm UTC

Request Review

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2b9d19c. Configure here.

Comment thread scripts/token-cost-comment.mjs Resolved
The download step matches the artifact name by regex, so it unpacks
main's stats into main-stats/token-stats-<sha>/. The comment script read
main-stats/ directly, never found a baseline, and so never created a
comment.
Comment thread scripts/token-cost-comment.mjs Resolved
@BYK
BYK merged commit e255c20 into main Nov 26, 2026
44 checks passed
@BYK
BYK deleted the fix/token-cost-comment-only-on-change branch November 26, 2026 18:31
BYK pushed a commit that referenced this pull request Nov 26, 2026
…ript (#2535)

Follow-up to review feedback on #2533.
`scripts/token-cost-comment.mjs` now reads the stats files and lists
main's artifact folder directly, and treats `ENOENT` as missing instead
of checking `existsSync` first. This skips the separate existence check
and its check-then-read race, and any other read error still throws.
Nothing else changes.

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:local%3Aweb%3A2c41e4487a01112f529e2132 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/local%3Aweb%3A2c41e4487a01112f529e2132)
[[Sentry]](https://sentry.sentry.io/explore/conversations/local%3Aweb%3A2c41e4487a01112f529e2132/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>

This branch was successfully deployed

2 active deployments
Preview – sentry-local — e33c9b96 Deployed Nov 26, 2026 by vercel[bot]
Preview – cli — e33c9b96 Deployed Nov 26, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant