Skip to content

fix(tag-mode): enable inline PR comments alongside sticky comments#1046

Open
sunnypatell wants to merge 2 commits intoanthropics:mainfrom
sunnypatell:fix/enable-inline-comments-tag-mode
Open

fix(tag-mode): enable inline PR comments alongside sticky comments#1046
sunnypatell wants to merge 2 commits intoanthropics:mainfrom
sunnypatell:fix/enable-inline-comments-tag-mode

Conversation

@sunnypatell
Copy link

fixes #955

tag mode never included mcp__github_inline_comment__create_inline_comment in 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 @claude mentions, and the problem surfaced clearly when users enabled use_sticky_comment: true since both features should work together.

root cause

tagModeTools in src/modes/tag/index.ts included 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, prepareMcpConfig in install-mcp-server.ts skipped starting the github_inline_comment server entirely (the hasInlineCommentTools check on line 80 was always false for tag mode).

fix

+  if (context.isPR) {
+    tagModeTools.push("mcp__github_inline_comment__create_inline_comment");
+  }

conditionally adds the inline comment tool to tag mode's allowed tools for PR contexts. this causes prepareMcpConfig to:

  1. start the inline comment MCP server
  2. include the tool in the --allowedTools flag passed to the Claude CLI

the 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

  • added test verifying inline comment server is excluded for non-PR contexts (issues)
  • added test verifying both github_comment and github_inline_comment servers coexist when useStickyComment: true on a PR context

all 654 tests pass.

Copilot AI review requested due to automatic review settings March 11, 2026 21:52
- 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
@sunnypatell sunnypatell force-pushed the fix/enable-inline-comments-tag-mode branch from 863638f to 162843d Compare March 11, 2026 21:52
Copy link

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

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_comment tool in tag mode when context.isPR is 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.

Comment on lines +134 to +138
// 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");
}
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +333 to +357
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");
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@sunnypatell
Copy link
Author

re: copilot's inline comments:

on the duplicate tool concern (src/modes/tag/index.ts:138): this is already handled. tagModeTools is passed through Array.from(new Set(tagModeTools)) at line 168 before being used in both prepareMcpConfig and the CLI --allowedTools string, so duplicates from userAllowedMCPTools are deduped.

on the test name (test/install-mcp-server.test.ts:357): fair point, renamed the test to better reflect what it actually asserts (comment + inline servers coexist for PR contexts).

- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sticky comments with inline in PR review

2 participants