Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 10, 2025

Adds hide-older-comments boolean field to the add-comment safe output and allowed-reasons array field to both add-comment and hide-comment safe outputs. When hide-older-comments is enabled, minimizes all previous add-comment outputs from the same workflow (identified by workflow ID from GITHUB_WORKFLOW environment variable) before creating a new comment. Reaction comments are excluded from hiding to preserve workflow status history. The allowed-reasons configuration restricts which reasons can be used for hiding comments. Only lowercase reason values are supported.

Changes

Schema

  • Added hide-older-comments field to add-comment configuration in main_workflow_schema.json
  • Added allowed-reasons array field to add-comment configuration with enum validation for lowercase only: spam, abuse, off_topic, outdated, resolved
  • Added allowed-reasons array field to hide-comment configuration with enum validation for lowercase only: spam, abuse, off_topic, outdated, resolved

Go Implementation

  • Added HideOlderComments field to AddCommentsConfig struct
  • Added AllowedReasons field to AddCommentsConfig struct
  • Added AllowedReasons field to HideCommentConfig struct
  • Parsing logic in parseCommentsConfig() and parseHideCommentConfig() for new fields
  • Environment variables GH_AW_HIDE_OLDER_COMMENTS, GH_AW_ALLOWED_REASONS, and GH_AW_HIDE_COMMENT_ALLOWED_REASONS passed to JavaScript
  • Modified compiler_jobs.go to pass GH_AW_TRACKER_ID environment variable to activation job for reaction comments

JavaScript Implementation

  • Uses GITHUB_WORKFLOW environment variable (automatically set by GitHub Actions) to identify comments from the same workflow
  • hideOlderComments() orchestrates the hiding logic with reason validation in add_comment.cjs
  • findCommentsWithTrackerId() for issue/PR comments (REST API with pagination) - searches for workflow-id markers and filters out reaction comments
  • findDiscussionCommentsWithTrackerId() for discussion comments (GraphQL with pagination) - searches for workflow-id markers and filters out reaction comments
  • minimizeComment() uses GraphQL mutation with configurable classifier (default: "outdated")
  • Validates reason against allowed-reasons list before hiding in both add_comment.cjs and hide_comment.cjs
  • Normalizes all lowercase reasons to uppercase internally for GitHub API compatibility
  • Integrated before comment creation in add_comment.cjs
  • Comments marked with <!-- workflow-id: ... --> for workflow identification
  • Add-comment safe outputs marked with <!-- comment-type: add-comment -->
  • Updated add_reaction_and_edit_comment.cjs to add workflow-id, tracker-id, and <!-- comment-type: reaction --> markers to reaction comments
  • Reaction comments are filtered out and never hidden to preserve workflow status history

Tests

  • Go unit tests for add-comment parsing (9 test cases total)
  • JavaScript tests for add-comment hiding logic and allowed-reasons validation (6 test cases total) - updated to use GITHUB_WORKFLOW
  • JavaScript tests for hide-comment allowed-reasons validation (4 test cases total)
  • JavaScript tests for reaction comments (15 test cases) - verified markers are included
  • Test workflow in .github/workflows/test-hide-older-comments.md

Documentation

  • Updated docs/src/content/docs/reference/safe-outputs.md with usage examples and requirements
  • Documented all valid reasons (lowercase only: spam, abuse, off_topic, outdated, resolved)
  • Explained automatic workflow ID usage from GITHUB_WORKFLOW environment variable
  • Removed tracker-id requirement from documentation

Smoke Test Integration

  • Added hide-older-comments: true to all smoke test workflows:
    • smoke-copilot
    • smoke-claude
    • smoke-codex
    • smoke-copilot-no-firewall
    • smoke-copilot-playwright
    • smoke-copilot-safe-inputs
    • smoke-detector
  • Removed tracker-id from smoke test workflows (no longer needed)
  • Smoke tests will now automatically hide older add-comment outputs when posting new ones, while preserving reaction comments

AI Moderator Integration

  • Added allowed-reasons: [spam] to ai-moderator workflow to restrict comment hiding to spam reason only
  • Ensures content moderation only hides comments explicitly flagged as spam

Comment Type Markers

  • Add-comment safe outputs include <!-- comment-type: add-comment --> marker
  • Reaction comments (initial workflow status) include <!-- comment-type: reaction --> marker
  • Reaction comments are filtered out from hide-older-comments logic to preserve workflow status history
  • Only add-comment outputs are hidden when hide-older-comments is enabled

Usage

add-comment with hide-older-comments

---
safe-outputs:
  add-comment:
    hide-older-comments: true
    allowed-reasons: [outdated, resolved]  # optional: restrict reasons (lowercase only)
---

Current build status: {{ status }}
Last updated: {{ timestamp }}

hide-comment with allowed-reasons

---
safe-outputs:
  hide-comment:
    max: 5
    allowed-reasons: [spam]  # optional: restrict reasons (lowercase only)
---

Workflow ID is automatically obtained from the GITHUB_WORKFLOW environment variable (set by GitHub Actions). Only add-comment outputs with matching workflow ID are hidden - reaction comments are preserved to maintain workflow status history. If allowed-reasons is specified, only the listed reasons can be used (if the default reason is not in the list, hiding will be skipped with a warning). Failures to hide individual comments are logged but don't block the workflow. Default behavior allows all reasons when not specified.

Only lowercase values (spam, abuse, off_topic, outdated, resolved) are accepted for allowed-reasons. Uppercase values will be rejected by schema validation. JavaScript internally normalizes these to uppercase before sending to GitHub's API.

Original prompt

Add a "hide-older-comments" Boolean field to the "add-comment" safe output.

When this feature is enabled, all previous comments from the same agentic workflow should be minimized/hidden.


💡 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.


Changeset

  • Type: patch
  • Description: Adds hide-older-comments boolean and allowed-reasons array fields to add-comment and hide-comment safe outputs; includes parsing, JavaScript hiding logic, tests, and documentation updates.

Ahoy! This treasure was crafted by 🏴‍☠️ Changeset Generator


Changeset

  • Type: patch
  • Description: Adds hide-older-comments boolean and allowed-reasons array fields to add-comment and hide-comment safe outputs; includes parsing, JavaScript hiding logic, tests, and documentation updates.

Ahoy! This treasure was crafted by 🏴‍☠️ Changeset Generator


Changeset

  • Type: patch
  • Description: Adds hide-older-comments boolean and allowed-reasons array fields to add-comment and hide-comment safe outputs; includes parsing, JavaScript hiding logic, tests, and documentation updates.

Ahoy! This treasure was crafted by 🏴‍☠️ Changeset Generator


Changeset

  • Type: patch
  • Description: Adds hide-older-comments boolean and allowed-reasons array fields to add-comment and hide-comment safe outputs; includes parsing, JavaScript hiding logic, tests, and documentation updates.

Ahoy! This treasure was crafted by 🏴‍☠️ Changeset Generator


Changeset

  • Type: patch
  • Description: Adds hide-older-comments boolean and allowed-reasons array fields to add-comment and hide-comment safe outputs; includes parsing, JavaScript hiding logic, tests, and documentation updates.

Ahoy! This treasure was crafted by 🏴‍☠️ Changeset Generator

@pelikhan
Copy link
Contributor

@copilot the user should be able to specify a set of "allowed-reasons" to limit how/why the agent is minimizing the comment. Default is all.

Copilot AI changed the title [WIP] Add hide-older-comments field to add-comment safe output Add hide-older-comments field to add-comment safe output Dec 10, 2025
Copilot AI requested a review from pelikhan December 10, 2025 23:56
@pelikhan
Copy link
Contributor

@copilot add flag to smoke agentic workflows

Copy link
Contributor Author

Copilot AI commented Dec 11, 2025

@copilot the user should be able to specify a set of "allowed-reasons" to limit how/why the agent is minimizing the comment. Default is all.

Added allowed-reasons field to restrict which reasons can be used when hiding older comments. Valid reasons are: SPAM, ABUSE, OFF_TOPIC, OUTDATED, RESOLVED. Default behavior allows all reasons when not specified.

Configuration example:

safe-outputs:
  add-comment:
    hide-older-comments: true
    allowed-reasons: [OUTDATED, RESOLVED]

Commit: 74ac24b

Copilot AI changed the title Add hide-older-comments field to add-comment safe output Add hide-older-comments field with allowed-reasons to add-comment safe output Dec 11, 2025
Copy link
Contributor Author

Copilot AI commented Dec 11, 2025

@copilot add flag to smoke agentic workflows

Added hide-older-comments: true and tracker-id to all smoke test workflows:

  • smoke-copilot
  • smoke-claude
  • smoke-codex
  • smoke-copilot-no-firewall
  • smoke-copilot-playwright
  • smoke-copilot-safe-inputs
  • smoke-detector

Smoke tests will now automatically hide older status comments when posting new ones.

Commit: d75030d

@pelikhan
Copy link
Contributor

@copilot restrict ai-moderztor to spam reason

@pelikhan
Copy link
Contributor

@copilot tracker-id AND workflow id

Copy link
Contributor Author

Copilot AI commented Dec 11, 2025

@copilot restrict ai-moderztor to spam reason

Added allowed-reasons: [SPAM] to ai-moderator workflow to restrict comment hiding to SPAM reason only.

Also implemented allowed-reasons support for the hide-comment safe output:

  • Schema: Added allowed-reasons array field to hide-comment configuration
  • Go: Parse and pass allowed-reasons via GH_AW_HIDE_COMMENT_ALLOWED_REASONS environment variable
  • JavaScript: Validate reason against allowed list before hiding comments
  • Tests: Added 3 test cases for allowed-reasons validation

Commit: 47bfc88

@pelikhan
Copy link
Contributor

@copilot add support for lower case reasons, not uppercase

Copilot AI changed the title Add hide-older-comments field with allowed-reasons to add-comment safe output Add hide-older-comments and allowed-reasons fields to add-comment and hide-comment safe outputs Dec 11, 2025
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@pelikhan
Copy link
Contributor

@copilot the reaction/conclusion comments should not be hidden. Ignore them for now. Store the comment type in the metadata and ignore reaction comments.

Copy link
Contributor Author

Copilot AI commented Dec 11, 2025

@copilot the reaction/conclusion comments should not be hidden. Ignore them for now. Store the comment type in the metadata and ignore reaction comments.

Added comment-type markers to distinguish reaction from add-comment comments. Reaction comments are now excluded from hide-older-comments logic.

Changes:

  • Reaction comments: Added <!-- comment-type: reaction --> marker in add_reaction_and_edit_comment.cjs
  • Add-comment outputs: Added <!-- comment-type: add-comment --> marker in add_comment.cjs
  • Filtering logic: Modified findCommentsWithTrackerId() and findDiscussionCommentsWithTrackerId() to skip comments with comment-type: reaction marker
  • Preserves status: Reaction/conclusion comments remain visible while only add-comment outputs can be hidden

When hide-older-comments is enabled, the system now:

  1. Finds all comments with matching workflow-id
  2. Filters out any comments with comment-type: reaction
  3. Hides only the add-comment outputs

This ensures workflow status indicators (reaction comments) remain visible as a permanent record of workflow activity.

Commit: 7499285

@github-actions
Copy link
Contributor

💥 WHOOSH! Smoke Claude springs into action on this pull request! [Panel 1 begins...]

@github-actions
Copy link
Contributor

🔮 The ancient spirits stir... Smoke Codex awakens to divine this pull request...

@github-actions
Copy link
Contributor

📰🚀🔍👀📡🕵️ https://github.com/githubnext/gh-aw/actions/runs/20121176014

@github-actions
Copy link
Contributor

github-actions bot commented Dec 11, 2025

🎉 Yo ho ho! Changeset Generator found the treasure and completed successfully! ⚓💰

c2441b6

@github-actions
Copy link
Contributor

📰 BREAKING: Smoke Copilot Playwright is now investigating this pull request. Sources say the story is developing...

@github-actions
Copy link
Contributor

📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing...

@github-actions
Copy link
Contributor

Smoke Test Results

Test Results:

  • ❌ GitHub MCP - HTTP/HTTPS client error
  • ✅ File Writing - File created successfully
  • ✅ Bash Tool - File read successfully
  • ❌ Serena MCP - Command not found
  • ❌ Safe Input gh - HTTP/HTTPS client error

Overall Status: FAIL

File test successful, but GitHub MCP and Serena MCP tools unavailable in environment.

📰🔥📋 https://github.com/githubnext/gh-aw/actions/runs/20121176014 fer issue #6073 🗺️

@github-actions
Copy link
Contributor

Recent merged PRs: 6083 “Add runtime-import macro for dynamic markdown inclusion”; 6086 “Fix shellcheck violations in safe-inputs server startup script”
GitHub MCP: ✅
File write/read /tmp/gh-aw/agent: ✅
Playwright title check: ✅
Cache-memory write/read: ✅
safeinputs-gh (gh issues list --limit 3): ❌ tool unavailable
Overall: FAIL

🔮 The oracle has spoken through Smoke Codex fer issue #6073 🗺️

@github-actions
Copy link
Contributor

Smoke Test Results - Claude Engine

Last 2 Merged PRs:

Test Results:

  • ✅ GitHub MCP: Retrieved PRs successfully
  • ✅ File Writing: Created /tmp/gh-aw/agent/smoke-test-claude-20121176008.txt
  • ✅ Bash Tool: Verified file contents
  • ✅ Playwright MCP: Navigated to GitHub, title contains "GitHub"
  • ✅ Cache Memory: Created and verified /tmp/gh-aw/cache-memory/smoke-test-20121176008.txt
  • ❌ Safe Input gh Tool: Tool not available

Status: PASS (5/6 tests passed)

💥 [THE END] — Illustrated by Smoke Claude fer issue #6073 🗺️

@github-actions
Copy link
Contributor

Copilot Smoke Test Results

Last 2 Merged PRs:

Test Results:

  • ✅ GitHub MCP (PRs retrieved)
  • ✅ File writing (/tmp/gh-aw/agent/)
  • ✅ Bash execution (verified files)
  • ✅ Default toolsets (confirmed get_me NOT available - 403 as expected)
  • ✅ Cache memory (/tmp/gh-aw/cache-memory/)

Status: PASS

📰 BREAKING: Report filed by Smoke Copilot fer issue #6073 🗺️

@github-actions
Copy link
Contributor

Smoke Test Results

Playwright MCP: Page loaded successfully, title contains "GitHub"
Cache Memory: Test file created and verified
Safe Input gh: Failed - HTTP/HTTPS connection error

Overall Status: FAIL (1/3 tests passed)

Note: GitHub CLI tool encountered connection issues with the API endpoint.

📰 BREAKING: Report filed by Smoke Copilot Playwright fer issue #6073 🗺️

@pelikhan pelikhan marked this pull request as ready for review December 11, 2025 03:45
@pelikhan pelikhan merged commit f989704 into main Dec 11, 2025
8 checks passed
@pelikhan pelikhan deleted the copilot/add-hide-older-comments-field-again branch December 11, 2025 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants