Drop buffered inline comment when it is posted live (#1405)#1412
Open
archievi wants to merge 1 commit into
Open
Drop buffered inline comment when it is posted live (#1405)#1412archievi wants to merge 1 commit into
archievi wants to merge 1 commit into
Conversation
When classify_inline_comments is enabled, create_inline_comment buffers calls without confirmed=true. The model frequently re-issues the call with confirmed=true after reading the buffered reply, which posts the comment live but leaves the original buffered entry behind. The post-session replay step then posts it again, so every inline comment lands twice. Reconcile the buffer on a live post: after a confirmed comment is created, remove any buffered entry matching the same path, line, startLine and body so it cannot be replayed. Extracts the reconciliation into src/mcp/inline-comment-buffer.ts (the MCP server module starts a server on import) and adds unit tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1405: inline comments are posted twice when
classify_inline_commentsis enabled (the default).When buffering is on,
create_inline_commentbuffers calls withoutconfirmed=trueand replies "Set confirmed=true to post immediately." The model frequently reacts by re-issuing the call withconfirmed=true, which posts the comment live, but the original buffered entry stays in/tmp/inline-comments-buffer.jsonl. Thepost-buffered-inline-commentsstep then replays it, so every inline comment lands twice (~15-25s apart). For Vertex/Bedrock users (noANTHROPIC_API_KEY) the whole buffer is replayed unconditionally, but the duplicate happens regardless of classification because the buffered entries are genuine comments.Fix
This implements option 1 from the issue: reconcile the buffer on a live post. After a
confirmed=truecomment is created, any buffered entry matching the samepath+line+startLine+bodyis removed, so the replay step can no longer post a duplicate.The reconciliation is extracted into
src/mcp/inline-comment-buffer.ts. The MCP server module starts a stdio server (andprocess.exits on missing env) at import time, so the logic is pulled into an import-safe module to keep it unit-testable.Tests
test/inline-comment-buffer.test.ts(5 cases): removes the matching entry, removes repeated copies, leaves the buffer untouched when nothing matches, no-ops when the buffer file is absent, and preserves lines that cannot be parsed.Verification (run locally)
bun test— full suite 734 pass / 0 fail (5 new tests included).bun run typecheck(tsc --noEmit) — clean.prettier --check— clean on all changed files.Notes
This is the minimal root-cause fix for the re-call path. The issue also suggests dedup in the post-step (idempotency across retries /
gh apiposts) as defense-in-depth; happy to add that here or in a follow-up if preferred.