Skip to content

[jsweep] Clean add_comment.cjs#20900

Merged
pelikhan merged 2 commits intomainfrom
jsweep/clean-add-comment-37a534d84723dd63
Mar 14, 2026
Merged

[jsweep] Clean add_comment.cjs#20900
pelikhan merged 2 commits intomainfrom
jsweep/clean-add-comment-37a534d84723dd63

Conversation

@github-actions
Copy link
Contributor

Summary

Cleaned actions/setup/js/add_comment.cjs — a github-script context handler for adding comments to issues, PRs, and discussions.

Changes

add_comment.cjs (-82 lines net)

1. Remove const item = message alias
The handler was declaring const item = message immediately on entry and using item throughout. Removed the alias and used message directly — eliminates a confusing layer of indirection.

2. Remove redundant discussion ID pre-checks (saves 1–2 API calls per run)
In two places (main discussion path and 404-fallback retry path), the code was querying GitHub to verify a discussion existed before calling commentOnDiscussion. But commentOnDiscussion already does the same internal query and throws the same ERR_NOT_FOUND error if not found. Removing the pre-checks reduces API call count with no behavioral change:

  • Main path: removed ~20 lines + 1 GraphQL call
  • Fallback path: removed ~20 lines + 1 GraphQL call

3. Extract recordComment helper
The success-result construction (building the _tracking object, pushing to createdComments, returning the result) was duplicated in both the main path and the discussion fallback path. Extracted into a local recordComment(comment, isDiscussionFlag) helper.

4. Remove unused result variable in hideOlderComments
const result = await minimizeComment(...)result was assigned but never read. Removed the assignment.

add_comment.test.cjs (1 line changed)

Updated one test assertion that checked for the now-removed log message "Found discussion #X, adding comment...". Changed to check for "Created comment on discussion" which is still logged after a successful discussion comment.

Test Coverage

56 tests — all passing. The file already had comprehensive coverage; no new tests needed.

Validation ✅

  • Formatting: npm run format:cjs ✓ (unchanged)
  • Linting: npm run lint:cjs ✓ (all files pass Prettier)
  • Type checking: npm run typecheck ✓ (no errors)
  • Tests: npm run test:js add_comment.test.cjs ✓ (56/56 passed)

Generated by jsweep - JavaScript Unbloater ·

Warning

⚠️ Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • proxy.golang.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "proxy.golang.org"

See Network Configuration for more information.

  • expires on Mar 16, 2026, 3:17 AM UTC

- Remove unnecessary `const item = message` alias, use `message` directly
- Remove redundant discussion ID pre-check before commentOnDiscussion (saves 1-2 API calls per discussion comment; commentOnDiscussion already checks internally)
- Extract `recordComment` helper to eliminate duplicated comment-result construction
- Remove unused `result` variable in hideOlderComments loop
- Update test: check for 'Created comment on discussion' log instead of removed 'Found discussion' log

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan
Copy link
Contributor

@copilot recompile, run tests

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor

Copilot AI commented Mar 14, 2026

@copilot recompile, run tests

Done — recompiled 173/173 workflows and all 56 JS tests pass (14c7b1b).

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw (http block)
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw 9dXBlC3HS6Iv (http block)
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw 4vguBAC/v_mOG2iF-1 (http block)
  • https://api.github.com/repos/astral-sh/setup-uv/git/ref/tags/eac588ad8def6316056a12d4907a9d4d84ff7a3b
    • Triggering command: /usr/bin/gh gh api /repos/astral-sh/setup-uv/git/ref/tags/eac588ad8def6316056a12d4907a9d4d84ff7a3b --jq .object.sha (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/a70c5eada06553e3510ac27f2c3bda9d3705bccb
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/a70c5eada06553e3510ac27f2c3bda9d3705bccb --jq .object.sha (http block)
  • https://api.github.com/repos/githubnext/agentics/git/ref/tags/
    • Triggering command: /usr/bin/gh gh api /repos/githubnext/agentics/git/ref/tags/# --jq .object.sha (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI requested a review from pelikhan March 14, 2026 03:29
@pelikhan pelikhan marked this pull request as ready for review March 14, 2026 03:31
Copilot AI review requested due to automatic review settings March 14, 2026 03:31
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

Cleans up add_comment.cjs by removing a redundant variable alias, eliminating duplicate discussion-existence pre-checks (saving API calls), extracting a recordComment helper, and removing an unused variable assignment. Lock files are also regenerated, picking up an unrelated close_pull_request tool.

Changes:

  • Removed const item = message alias and redundant GraphQL discussion pre-checks, reducing code by ~82 lines
  • Extracted recordComment helper to deduplicate success-result construction
  • Updated one test assertion to match a changed log message

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
actions/setup/js/add_comment.cjs Core cleanup: remove alias, pre-checks, unused var; add recordComment helper
actions/setup/js/add_comment.test.cjs Update assertion to check for remaining log message
.github/workflows/smoke-claude.lock.yml Lockfile regen; adds close_pull_request config
.github/workflows/poem-bot.lock.yml Lockfile regen; adds close_pull_request config
.github/workflows/draft-pr-cleanup.lock.yml Lockfile regen; adds close_pull_request config

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

You can also share your feedback on Copilot code review. Take the survey.

mkdir -p /tmp/gh-aw/mcp-logs/safeoutputs
cat > /opt/gh-aw/safeoutputs/config.json << 'GH_AW_SAFE_OUTPUTS_CONFIG_EOF'
{"add_comment":{"max":2},"add_labels":{"allowed":["smoke-claude"],"max":3},"add_reviewer":{"max":2},"create_issue":{"expires":2,"group":true,"max":1},"create_pull_request_review_comment":{"max":5},"missing_data":{},"missing_tool":{},"noop":{"max":1},"push_to_pull_request_branch":{"max":1,"target":"*"},"resolve_pull_request_review_thread":{"max":5},"submit_pull_request_review":{"max":1},"update_pull_request":{"max":1}}
{"add_comment":{"max":2},"add_labels":{"allowed":["smoke-claude"],"max":3},"add_reviewer":{"max":2},"close_pull_request":{"max":1,"staged":true},"create_issue":{"expires":2,"group":true,"max":1},"create_pull_request_review_comment":{"max":5},"missing_data":{},"missing_tool":{},"noop":{"max":1},"push_to_pull_request_branch":{"max":1,"target":"*"},"resolve_pull_request_review_thread":{"max":5},"submit_pull_request_review":{"max":1},"update_pull_request":{"max":1}}
@pelikhan pelikhan merged commit b003384 into main Mar 14, 2026
54 checks passed
@pelikhan pelikhan deleted the jsweep/clean-add-comment-37a534d84723dd63 branch March 14, 2026 03:35
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.

3 participants