Skip to content

Add conditional footer control for PR review comments#15643

Merged
pelikhan merged 3 commits intomainfrom
copilot/add-footer-option-for-pr-reviews
Feb 14, 2026
Merged

Add conditional footer control for PR review comments#15643
pelikhan merged 3 commits intomainfrom
copilot/add-footer-option-for-pr-reviews

Conversation

Copy link
Contributor

Copilot AI commented Feb 14, 2026

Implementation Complete: PR Review Footer Configuration

Summary

Successfully implemented dedicated footer setting for PR Review comments that supports conditional footer display.

Features Implemented

  • footer field on create-pull-request-review-comment configuration
  • Three modes: "always" (default), "none", "if-body"
  • Boolean mapping: true"always", false"none" (in Go)
  • Priority-based config resolution
  • Backward compatibility maintained

Implementation Details

Go Changes:

  • Added Footer *string field to CreatePullRequestReviewCommentsConfig
  • Parsing logic with validation and boolean-to-string conversion
  • Handler config builder integration
  • Boolean conversion happens in Go before reaching JavaScript

JavaScript Changes:

  • Updated pr_review_buffer.cjs with conditional footer logic
  • JavaScript only accepts string values ("always", "none", "if-body")
  • Handler managers apply footer config with priority
  • Backward compatible setIncludeFooter() alias for string values

Tests:

  • ✅ Go: 10 test cases covering all modes and edge cases
  • ✅ JavaScript: 31 test cases (removed boolean tests from JS)
  • ✅ All tests passing

Recent Changes (per review feedback)

  • Removed boolean handling from JavaScript
  • Boolean-to-string conversion now only in Go compiler
  • JavaScript validates only string values
  • Updated tests to reflect string-only JavaScript API

Usage Example

safe-outputs:
  create-pull-request-review-comment:
    footer: if-body  # Only show footer when review has body text
    # Can also use: true (maps to "always") or false (maps to "none")
  submit-pull-request-review:

Result: Clean approval reviews without footer noise when body is empty.

Files Changed

  • pkg/workflow/create_pr_review_comment.go
  • pkg/workflow/create_pr_review_comment_footer_test.go
  • pkg/workflow/compiler_safe_outputs_config.go
  • actions/setup/js/pr_review_buffer.cjs
  • actions/setup/js/pr_review_buffer.test.cjs
  • actions/setup/js/safe_output_handler_manager.cjs
  • actions/setup/js/safe_output_unified_handler_manager.cjs

Validation

  • ✅ All unit tests passing
  • ✅ Code formatted and linted
  • ✅ Backward compatibility confirmed
  • ✅ Ready for review
Original prompt

This section details on the original issue you should resolve

<issue_title>Consider dedicated setting for PR Review Footer w/o Body</issue_title>
<issue_description>For PR Reviews, it's often convenient to not include a body so that it just shows approval. This reduces noise by just marking approval.

It would be nice to have an option whereby the footer is not printed if there is no body to the PR review without having to totally disable the footer altogether.

Image

vs

Image</issue_description>

Comments on the Issue (you are @copilot in this section)

@pelikhan Add optional field for "footer: false" on safe-outputs.create-pull-request-review-comment that turns off the generation of generated comment in the pull request review comment body. Default is true. @pelikhan I see @pelikhan Can you cook a PR that adds support for

footer: "if-body"

and implement this logic when this value is found?</comment_new>
<comment_new>@pelikhan
other values are none, always

True/false map to always/none</comment_new>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

- Add Footer field to CreatePullRequestReviewCommentsConfig
- Support "always", "none", "if-body" values
- Support boolean true/false mapping
- Update pr_review_buffer to support conditional footer logic
- Update handler managers to apply footer config
- Add comprehensive tests for Go and JavaScript

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
includeFooter = value;
core.info(`PR review footer ${value ? "enabled" : "disabled"}`);
function setFooterMode(value) {
if (typeof value === "boolean") {
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot the JavaScript should only handle the three strings. Perform the conversion in the Go compiler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in commit 84c58a6. JavaScript now only handles string values ("always", "none", "if-body"). Boolean conversion is performed in the Go compiler before values reach JavaScript.

Copilot AI changed the title [WIP] Add optional footer setting for PR review without body Add conditional footer control for PR review comments Feb 14, 2026
Copilot AI requested a review from pelikhan February 14, 2026 07:09
JavaScript now only handles string values ("always", "none", "if-body").
Boolean conversion (true->always, false->none) is performed in Go compiler
before values reach JavaScript, per review feedback.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review February 14, 2026 07:25
Copilot AI review requested due to automatic review settings February 14, 2026 07:25
@pelikhan pelikhan merged commit bdd5dd4 into main Feb 14, 2026
90 checks passed
@pelikhan pelikhan deleted the copilot/add-footer-option-for-pr-reviews branch February 14, 2026 07:28
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

Adds a dedicated footer configuration for PR review comment workflows, enabling conditional footer inclusion (including a new "if-body" mode) while aiming to preserve backward compatibility.

Changes:

  • Add footer (string mode) to create-pull-request-review-comment safe-outputs config with validation + bool→string mapping in Go.
  • Update the PR review buffer to support footer modes: "always", "none", "if-body", and update handler managers to apply config with explicit priority.
  • Add/adjust Go + JS unit tests for the new footer behavior and config propagation.

Reviewed changes

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

Show a summary per file
File Description
pkg/workflow/create_pr_review_comment.go Parses and validates footer for PR review comments (string modes + bool mapping).
pkg/workflow/compiler_safe_outputs_config.go Emits footer into handler manager config for create_pull_request_review_comment.
pkg/workflow/create_pr_review_comment_footer_test.go Adds Go tests for parsing + handler-config emission of the new footer setting.
actions/setup/js/pr_review_buffer.cjs Implements footer mode behavior (always/none/if-body) in review submission logic.
actions/setup/js/pr_review_buffer.test.cjs Expands tests to cover new footer modes and reset behavior.
actions/setup/js/safe_output_handler_manager.cjs Applies footer config to the shared PR review buffer with priority logic.
actions/setup/js/safe_output_unified_handler_manager.cjs Same as above for unified manager path.

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

Comment on lines +123 to 145
* Set the footer mode for review body.
* Supported modes:
* - "always" (default): Always include footer
* - "none": Never include footer
* - "if-body": Only include footer if review body is non-empty
* Note: Boolean values are converted to strings in the Go compiler before reaching JavaScript.
* @param {string} value - Footer mode string
*/
function setIncludeFooter(value) {
includeFooter = value;
core.info(`PR review footer ${value ? "enabled" : "disabled"}`);
function setFooterMode(value) {
if (typeof value === "string") {
// Validate string mode
if (value === "always" || value === "none" || value === "if-body") {
footerMode = value;
core.info(`PR review footer mode set to "${footerMode}"`);
} else {
core.warning(`Invalid footer mode: "${value}". Using default "always". Valid values: "always", "none", "if-body"`);
footerMode = "always";
}
} else {
core.warning(`Invalid footer mode type: ${typeof value}. Using default "always".`);
footerMode = "always";
}
}
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

setIncludeFooter is labeled as a backward-compatibility alias, but it now points to setFooterMode and no longer supports the previous boolean contract. Any remaining callers passing false will hit the "invalid type" path and silently reset to the default "always" (re-enabling the footer). Consider keeping setIncludeFooter(value: boolean) semantics by mapping booleans to modes (false→"none", true→"always"), while keeping setFooterMode(value: string) as the new string-only API.

Copilot uses AI. Check for mistakes.
}

if (footerConfig !== undefined) {
prReviewBuffer.setFooterMode(footerConfig);
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

submit_pull_request_review.footer is still emitted as a boolean by the Go compiler (via AddBoolPtr/getEffectiveFooter), but here it’s forwarded into prReviewBuffer.setFooterMode(), which only accepts strings. As a result, footer: false (or global safe-outputs.footer: false) will be treated as an invalid type and the buffer will fall back to the default "always", re-enabling the footer unexpectedly. Normalize boolean values to the corresponding string modes (false→"none", true→"always") before calling setFooterMode, or change the Go handler config to emit a string mode for submit_pull_request_review.footer as well.

Suggested change
prReviewBuffer.setFooterMode(footerConfig);
let normalizedFooterConfig = footerConfig;
if (typeof footerConfig === "boolean") {
normalizedFooterConfig = footerConfig ? "always" : "none";
}
prReviewBuffer.setFooterMode(normalizedFooterConfig);

Copilot uses AI. Check for mistakes.
core.info(`Using footer config from submit_pull_request_review: ${footerConfig}`);
}

if (footerConfig !== undefined) {
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

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

Same issue as in safe_output_handler_manager.cjs: configs.regular.submit_pull_request_review.footer comes from Go as a boolean, but it’s passed into setFooterMode() which only accepts strings. This causes footer: false (and global footer disable) to be ignored and the footer mode to revert to the default "always". Convert boolean to string mode (false→"none", true→"always") before calling setFooterMode, or update the Go config emission for submit_pull_request_review to provide a string footer mode.

Suggested change
if (footerConfig !== undefined) {
if (footerConfig !== undefined) {
// Normalize boolean footer configs (from Go) to string modes expected by setFooterMode
if (typeof footerConfig === "boolean") {
footerConfig = footerConfig ? "always" : "none";
core.info(`Normalized boolean footer config to mode: ${footerConfig}`);
}

Copilot uses AI. Check for mistakes.
github-actions bot added a commit that referenced this pull request Feb 14, 2026
Document the new footer field for create-pull-request-review-comment
that was added in PR #15643. This feature enables conditional footer
display on PR review comments with three modes: always, none, and if-body.

Changes:
- Add footer field documentation to safe-outputs.md PR review comments section
- Add dedicated PR review comment footer control section to footers.md
- Include examples and use cases for the if-body mode

The if-body mode is particularly useful for clean approval reviews
without body text, reducing footer noise while maintaining attribution
for reviews with explanatory text.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
cursor bot pushed a commit to strawgate/gh-aw that referenced this pull request Feb 14, 2026
…mpatibility

The Copilot PR reviewer on github#15643 identified that submit_pull_request_review.footer
is still emitted as a boolean by the Go compiler (via AddBoolPtr/getEffectiveFooter),
but setFooterMode() in JavaScript only accepts strings after the PR review footer
refactoring. This caused footer: false to be silently ignored, defaulting back to
'always' (the opposite of the user's intent).

Fix: Add boolean normalization in setFooterMode() so that:
- false maps to 'none' (disable footer)
- true maps to 'always' (enable footer)

This also fixes the setIncludeFooter() backward-compatibility alias, which
previously would reject boolean values passed through the old API contract.

Added 3 new test cases covering:
- setFooterMode(false) -> 'none'
- setFooterMode(true) -> 'always'
- setIncludeFooter(false) backward compatibility

Co-authored-by: Bill Easton <williamseaston@gmail.com>
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.

Consider dedicated setting for PR Review Footer w/o Body

3 participants