Update history link generation to set type in search query#19507
Update history link generation to set type in search query#19507
Conversation
…ype context Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
Hey This PR is well-structured and looks ready for maintainer review:
The PR body checklist confirms
|
|
@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>
Fixed in 9c8477b. Added a |
|
🎬 THE END — Smoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨ |
|
✅ All tools validated successfully! Agent Container Smoke Test confirms agent container is ready. |
|
🌑 The shadows whisper... Smoke Codex failed. The oracle requires further meditation... |
|
📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing... |
There was a problem hiding this comment.
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=discussionsto URLs produced bygenerateHistoryUrl()based onitemType. - Introduce
discussion_commentas anitemTypeand treat it as a comment search (in:comments) scoped to discussions. - Update
add_comment.cjsand 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"); | ||
| }); |
There was a problem hiding this comment.
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.
| }); | |
| }); | |
| 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"); | |
| }); |
| // 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; |
There was a problem hiding this comment.
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();
Agent Container Tool Check
Result: 12/12 tools available ✅ Overall Status: PASS
|
|
Smoke test results for run §22656963495:
Overall:
|
There was a problem hiding this comment.
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" }; |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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.
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
|
@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) |
Smoke Test Results — Run §22656963474Core Tests #1–10: PR Review Tests #11–17: Overall: PARTIAL — 12 passed, 1 failed (push to branch), 3 partial/skipped
|
There was a problem hiding this comment.
💥 Automated smoke test review - all systems nominal!
💥 [THE END] — Illustrated by Smoke Claude
Updates
generateHistoryUrl()to include atype=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: Addedtype=URL parameter using an explicit itemType → searchType mapping:issue/pull_request/comment→type=issuesdiscussion/discussion_comment→type=discussions"discussion_comment"item type for comments added in a discussion contextadd_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 withtype=discussionsrather than being skipped entirely.generate_history_link.test.cjs: Updated existing tests to expect thetype=parameter and added new tests covering thediscussion_commenttype.Testing
make fmt-cjsformatting 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
Changeset
type=search parameter and treat discussion comments as a discussion-level item so the generated URLs filter the right content.Warning
The following domains were blocked by the firewall during workflow execution:
codeload.github.comgithub.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.