Skip to content

fix: include effective tokens count in PR comment generated footer - #32215

Merged
pelikhan merged 1 commit into
mainfrom
copilot/fix-pr-comment-footer
May 14, 2026
Merged

pelikhan merged 1 commit into
mainfrom
copilot/fix-pr-comment-footer

Conversation

Copilot AI commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

getFooterMessage relied on callers passing ctx.effectiveTokens, but callers like update_activation_comment.cjs omit it — so the · ● NM token count was never shown in those footers. Every sibling function (getFooterWorkflowRecompileMessage, getFooterAgentFailureIssueMessage, etc.) already calls getEffectiveTokensFromEnv() internally; getFooterMessage was the odd one out.

Changes

  • messages_footer.cjs — getFooterMessage now calls getEffectiveTokensFromEnv() and uses it as a fallback when ctx.effectiveTokens is absent. Callers that already supply ctx.effectiveTokens (e.g. generateFooterWithMessages) are unaffected — context value takes precedence via ??.
  • messages.test.cjs — six new cases covering: env-var fallback, ordering before history link, no-tokens when env unset, context precedence over env, and {effective_tokens_suffix} placeholder in custom templates via env.

…ffectiveTokens not in context

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan
pelikhan marked this pull request as ready for review May 14, 2026 20:52
Copilot AI review requested due to automatic review settings May 14, 2026 20:52
@pelikhan
pelikhan merged commit 207736e into main May 14, 2026
@pelikhan
pelikhan deleted the copilot/fix-pr-comment-footer branch May 14, 2026 20:52

Copilot AI 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.

Pull request overview

This PR fixes missing effective-token counts (· ● …) in generated footer messages by making getFooterMessage independently resolve the effective token count from GH_AW_EFFECTIVE_TOKENS when callers don’t provide ctx.effectiveTokens.

Changes:

  • Update getFooterMessage to fall back to getEffectiveTokensFromEnv() when ctx.effectiveTokens is absent (with context still taking precedence).
  • Ensure the computed effective_tokens_suffix is available to custom footer templates even when tokens only come from env.
  • Add test coverage for env fallback behavior, ordering relative to the history link, and precedence rules.
Show a summary per file
File Description
actions/setup/js/messages_footer.cjs Adds env-var fallback for effectiveTokens in getFooterMessage and threads the computed value into template context + default footer rendering.
actions/setup/js/messages.test.cjs Adds test cases validating env fallback, correct placement, omission when unset, precedence over env, and template placeholder behavior.

Copilot's findings

Tip

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

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

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.

3 participants