fix(tag-mode): enable inline PR comments alongside sticky comments#1046
fix(tag-mode): enable inline PR comments alongside sticky comments#1046sunnypatell wants to merge 2 commits intoanthropics:mainfrom
Conversation
- added `mcp__github_inline_comment__create_inline_comment` to tag mode's allowed tools when the context is a PR - the inline comment MCP server was previously only available in agent mode or when explicitly passed via `claude_args`, making it impossible to post review feedback on specific diff lines in tag mode - this allows sticky comments (for the main tracking comment) and inline comments (for code-level review feedback) to coexist - added tests verifying inline comments are excluded for non-PR contexts and that both comment servers work together with sticky comments enabled closes anthropics#955
863638f to
162843d
Compare
There was a problem hiding this comment.
Pull request overview
This PR enables GitHub inline PR comment support in tag mode for PR contexts, and adds tests to validate when the inline-comment MCP server is (and isn’t) included in the generated MCP config.
Changes:
- Automatically add the
mcp__github_inline_comment__create_inline_commenttool in tag mode whencontext.isPRis true. - Add tests ensuring the inline-comment server is excluded for non-PR contexts, and coexists with the standard comment server for PRs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/modes/tag/index.ts |
Adds inline-comment tool to the tag-mode allowed tool list for PR contexts. |
test/install-mcp-server.test.ts |
Adds coverage around inline-comment server inclusion/exclusion in prepareMcpConfig. |
💡 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.
| // Enable inline PR comments for PR contexts so Claude can post | ||
| // review feedback directly on diff lines alongside the tracking comment | ||
| if (context.isPR) { | ||
| tagModeTools.push("mcp__github_inline_comment__create_inline_comment"); | ||
| } |
There was a problem hiding this comment.
tagModeTools already contains user-supplied MCP tools via userAllowedMCPTools. Unconditionally pushing mcp__github_inline_comment__create_inline_comment for PRs can introduce duplicates when the user also provided that tool, and --allowedTools later uses tagModeTools.join(",") without de-duping. Consider building a de-duplicated list once (e.g., via Set) and use it consistently for both prepareMcpConfig and the CLI --allowedTools string.
test/install-mcp-server.test.ts
Outdated
| test("should include inline comment server alongside sticky comment support for PRs", async () => { | ||
| const mockPRContextWithSticky: ParsedGitHubContext = { | ||
| ...mockPRContext, | ||
| inputs: { | ||
| ...mockPRContext.inputs, | ||
| useStickyComment: true, | ||
| }, | ||
| }; | ||
|
|
||
| const result = await prepareMcpConfig({ | ||
| githubToken: "test-token", | ||
| owner: "test-owner", | ||
| repo: "test-repo", | ||
| branch: "test-branch", | ||
| baseBranch: "main", | ||
| allowedTools: ["mcp__github_inline_comment__create_inline_comment"], | ||
| mode: "tag", | ||
| context: mockPRContextWithSticky, | ||
| }); | ||
|
|
||
| const parsed = JSON.parse(result); | ||
| // Both comment server (for sticky tracking comment) and inline comment server should coexist | ||
| expect(parsed.mcpServers.github_comment).toBeDefined(); | ||
| expect(parsed.mcpServers.github_inline_comment).toBeDefined(); | ||
| expect(parsed.mcpServers.github_inline_comment.env.PR_NUMBER).toBe("456"); |
There was a problem hiding this comment.
This test is labeled as validating sticky comment support, but prepareMcpConfig does not branch on context.inputs.useStickyComment, and the test does not pass a claudeCommentId (the piece of data that actually differentiates sticky tracking comment behavior). Either rename the test/comment to reflect what it asserts (comment + inline servers coexist on PRs), or pass claudeCommentId and assert github_comment.env.CLAUDE_COMMENT_ID to make the sticky-comment aspect real.
|
re: copilot's inline comments: on the duplicate tool concern ( on the test name ( |
- changed "should include inline comment server alongside sticky comment support for PRs" to "should include both comment and inline comment servers for PR contexts" since the test validates server coexistence, not sticky comment behavior specifically
fixes #955
tag mode never included
mcp__github_inline_comment__create_inline_commentin its allowed tools, so the inline comment MCP server was never started for PR contexts. this made it impossible to post review feedback on specific diff lines when using@claudementions, and the problem surfaced clearly when users enableduse_sticky_comment: truesince both features should work together.root cause
tagModeToolsinsrc/modes/tag/index.tsincluded the comment server (mcp__github_comment__update_claude_comment) and CI tools, but not the inline comment tool. without that tool in the allowed list,prepareMcpConfigininstall-mcp-server.tsskipped starting thegithub_inline_commentserver entirely (thehasInlineCommentToolscheck on line 80 was always false for tag mode).fix
conditionally adds the inline comment tool to tag mode's allowed tools for PR contexts. this causes
prepareMcpConfigto:--allowedToolsflag passed to the Claude CLIthe sticky comment feature (controlled by
create-initial.ts) is completely orthogonal to inline comments. sticky controls how the main tracking comment is created/updated, while inline comments are separate PR review comments on diff lines. both now coexist.tests
github_commentandgithub_inline_commentservers coexist whenuseStickyComment: trueon a PR contextall 654 tests pass.