Skip to content

Update history link generation to set type in search query#19507

Merged
pelikhan merged 4 commits intomainfrom
copilot/update-history-link-generation
Mar 4, 2026
Merged

Update history link generation to set type in search query#19507
pelikhan merged 4 commits intomainfrom
copilot/update-history-link-generation

Conversation

Copy link
Contributor

Copilot AI commented Mar 4, 2026

Updates generateHistoryUrl() to include a type= search parameter in generated GitHub search URLs, scoped to the correct content type based on the execution context of the footer.

Changes Made

  • generate_history_link.cjs: Added type= URL parameter using an explicit itemType → searchType mapping:

    • issue / pull_request / commenttype=issues
    • discussion / discussion_commenttype=discussions
    • Added new "discussion_comment" item type for comments added in a discussion context
  • add_comment.cjs: Updated history URL generation to determine the item type from the execution context — itemType: isDiscussion ? "discussion_comment" : "comment" — so discussion comments now generate a history link with type=discussions rather than being skipped entirely.

  • generate_history_link.test.cjs: Updated existing tests to expect the type= parameter and added new tests covering the discussion_comment type.

Testing

  • ✅ All 34 tests pass
  • make fmt-cjs formatting validated

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.



✨ PR Review Safe Output Test - Run 22656963474

💥 [THE END] — Illustrated by Smoke Claude ·


Changeset

  • Type: patch
  • Description: History links now set the type= search parameter and treat discussion comments as a discussion-level item so the generated URLs filter the right content.

Generated by Changeset Generator for issue #19507 ·

Warning

⚠️ Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • codeload.github.com
  • github.com

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

network:
  allowed:
    - defaults
    - "codeload.github.com"
    - "github.com"

See Network Configuration for more information.

…ype context

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

github-actions bot commented Mar 4, 2026

Hey @Copilot 👋 — great work on the history link improvement! Adding the type= search parameter to generateHistoryUrl() is a clean, targeted fix that ensures GitHub's search UI opens in the right context (issues vs. discussions) for each item type.

This PR is well-structured and looks ready for maintainer review:

  • ✅ Focused change — only touches generate_history_link.cjs and its test counterpart
  • ✅ Tests updated — all 10 affected assertions in generate_history_link.test.cjs are aligned with the new behavior
  • ✅ Follows the agentic development process — Copilot agent PR assigned to a core team member
  • ✅ No new dependencies introduced
  • ✅ Small, minimal diff (24 lines changed)

The PR body checklist confirms make fmt-cjs and make lint-cjs were run and all 32 tests pass. Once the WIP/draft status is lifted and CI is green, this looks ready to merge. 🚀

Generated by Contribution Check ·

@pelikhan
Copy link
Contributor

pelikhan commented Mar 4, 2026

@copilot for comments, you need to determine the context from the execution site: issues/discussion/pr

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

Copilot AI commented Mar 4, 2026

@copilot for comments, you need to determine the context from the execution site: issues/discussion/pr

Fixed in 9c8477b. Added a "discussion_comment" item type that maps to type=discussions with in:comments, and updated add_comment.cjs to use itemType: isDiscussion ? "discussion_comment" : "comment" — so comments on discussions now generate a history link with type=discussions rather than being skipped entirely.

Copilot AI changed the title [WIP] Update history link generation to set type in search query Update history link generation to set type in search query Mar 4, 2026
@pelikhan pelikhan marked this pull request as ready for review March 4, 2026 05:49
Copilot AI review requested due to automatic review settings March 4, 2026 05:49
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

✅ All tools validated successfully! Agent Container Smoke Test confirms agent container is ready.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

🌑 The shadows whisper... Smoke Codex failed. The oracle requires further meditation...

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

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

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

Updates history link generation so GitHub search URLs include an explicit type= parameter, ensuring results are correctly scoped for issues vs discussions (including discussion comments).

Changes:

  • Add type=issues / type=discussions to URLs produced by generateHistoryUrl() based on itemType.
  • Introduce discussion_comment as an itemType and treat it as a comment search (in:comments) scoped to discussions.
  • Update add_comment.cjs and tests to use/validate the new type scoping behavior.

Reviewed changes

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

File Description
actions/setup/js/generate_history_link.cjs Adds discussion_comment support and sets type= param based on itemType.
actions/setup/js/add_comment.cjs Generates history URLs for discussion comments using discussion_comment item type.
actions/setup/js/generate_history_link.test.cjs Updates expectations for type= and adds coverage for discussion_comment.

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

expect(url).not.toContain("is%3A");
expect(url).toContain("type=discussions");
expect(url).toContain("in%3Acomments");
});
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

There’s no test coverage for the itemType: "comment" path, even though it now always adds type=issues and uses in:comments. Add a test case that exercises itemType: "comment" and asserts both the type param and in:comments qualifier so regressions are caught.

Suggested change
});
});
it("should set type=issues and use in:comments for comment type", () => {
const url = generateHistoryUrl({
owner: "testowner",
repo: "testrepo",
itemType: "comment",
workflowId: "my-workflow",
serverUrl: "https://github.com",
});
expect(url).not.toContain("is%3A");
expect(url).toContain("type=issues");
expect(url).toContain("in%3Acomments");
});

Copilot uses AI. Check for mistakes.
Comment on lines +530 to +539
// Generate history URL using in:comments, with type= based on execution context
const historyUrl =
generateHistoryUrl({
owner: repoParts.owner,
repo: repoParts.repo,
itemType: isDiscussion ? "discussion_comment" : "comment",
workflowCallId: callerWorkflowId,
workflowId,
serverUrl: context.serverUrl,
}) || undefined;
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

historyUrl is computed unconditionally here, but it’s only used when includeFooter is true (otherwise it’s dead work). Consider moving the generateHistoryUrl(...) call inside the if (includeFooter) block; also, || undefined is redundant since generateHistoryUrl already returns null when unavailable and generateFooterWithMessages normalizes falsy values.

See below for a potential fix:

    if (includeFooter) {
      // Generate history URL using in:comments, with type= based on execution context
      const historyUrl = generateHistoryUrl({
        owner: repoParts.owner,
        repo: repoParts.repo,
        itemType: isDiscussion ? "discussion_comment" : "comment",
        workflowCallId: callerWorkflowId,
        workflowId,
        serverUrl: context.serverUrl,
      });

      // When footer is enabled, add full footer with attribution and XML markers
      processedBody += generateFooterWithMessages(
        workflowName,
        runUrl,
        workflowSource,
        workflowSourceURL,
        triggeringIssueNumber,
        triggeringPRNumber,
        triggeringDiscussionNumber,
        historyUrl
      ).trimEnd();

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Agent Container Tool Check

Tool Status Version
bash 5.2.21
sh available
git 2.53.0
jq 1.7
yq 4.52.4
curl 8.5.0
gh 2.87.3
node 20.20.0
python3 3.12.3
go 1.24.13
java 21.0.10 (Temurin)
dotnet 10.0.102

Result: 12/12 tools available ✅

Overall Status: PASS

🔧 Tool validation by Agent Container Smoke Test ·

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Smoke test results for run §22656963495:

Test Status
GitHub MCP

Overall: ⚠️ PARTIAL PASS — Serena MCP tools unavailable

@pelikhan @Copilot

📰 BREAKING: Report filed by Smoke Copilot ·

@github-actions github-actions bot removed the smoke label Mar 4, 2026
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Clean and focused change. The PR correctly adds discussion_comment as a new item type and ensures history links for discussion comments use type=discussions in the search query. Minor suggestion: extract searchTypeMap as a module-level constant.

📰 BREAKING: Report filed by Smoke Copilot

url.searchParams.set("q", queryParts.join(" "));

// Set the type parameter based on itemType for correct GitHub search filtering
const searchTypeMap = { issue: "issues", pull_request: "issues", discussion: "discussions", comment: "issues", discussion_comment: "discussions" };
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider extracting searchTypeMap as a module-level constant to avoid recreation on each call and improve readability:

const SEARCH_TYPE_MAP = { issue: "issues", pull_request: "issues", discussion: "discussions", comment: "issues", discussion_comment: "discussions" };

generateHistoryUrl({
owner: repoParts.owner,
repo: repoParts.repo,
itemType: isDiscussion ? "discussion_comment" : "comment",
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice fix! This correctly maps discussion comments to discussion_comment type, enabling the history URL to use type=discussions in the search query so history links now work for discussion comments too.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@pelikhan
Copy link
Contributor

pelikhan commented Mar 4, 2026

@copilot the generated footer injected in the safe output "add-comment" is missing the gh-aw-workflow-call-id identifier that allows search to find the comment. Update the generate comment generation for comment to receive those markers as well.

see #19507 (comment)

@pelikhan pelikhan merged commit 038c4c9 into main Mar 4, 2026
132 of 134 checks passed
@pelikhan pelikhan deleted the copilot/update-history-link-generation branch March 4, 2026 05:56
Copilot stopped work on behalf of pelikhan due to an error March 4, 2026 05:56
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Smoke Test Results — Run §22656963474

Core Tests #1–10:
1 GitHub MCP ⚠️ | 2 safeinputs-gh ✅ | 3 Serena ⚠️ (activate ✅ / find_symbol ❌) | 4 make build ✅ | 5 Playwright ✅ | 6 Tavily ✅ | 7 file write ✅ | 8 bash verify ✅ | 9 discussion ✅ | 10 aw-status ✅

PR Review Tests #11–17:
11 update PR ✅ | 12 review comments ✅ | 13 submit review ✅ | 14 resolve thread ✅ | 15 add reviewer ✅ | 16 push to branch ❌ | 17 close PR ⚠️

Overall: PARTIAL — 12 passed, 1 failed (push to branch), 3 partial/skipped

💥 [THE END] — Illustrated by Smoke Claude ·

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

💥 Automated smoke test review - all systems nominal!

💥 [THE END] — Illustrated by Smoke Claude

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