Repository navigation
Improve send comments to ai - #12150
Conversation
Orca now automatically replies to selected comments after launching an agent to resolve them. Review-thread comments get nested replies; review summaries and issue comments get top-level @-replies. Payloads are snapshotted at queue time and posted only after prompt delivery succeeds. Bounded concurrency (4) prevents SSH slowdown.
Combine N unresolvable comments into a single PR conversation reply to avoid timeline spam. Review threads still get one nested reply each. Refactor helper functions to pr-comment-fixing-reply-body.ts and change replyAsConversation(comment, body) → replyAsConversation(body).
Greptile SummaryThis PR significantly improves the "send comments to AI" flow by adding post-launch acknowledgement (fixing replies) to selected PR comments on GitHub. After an agent prompt is delivered, Orca now posts a "Fixing. Will be in the next commit" reply—either as a nested thread reply for inline review comments, or as a single batched conversation comment for review summaries and top-level comments—before resolving host threads.
Confidence Score: 5/5Safe to merge; the new ack lifecycle is well-tested and protected against double-posts, stale replies, and panel churn. The core orchestration (claim/release/consume lifecycle, bounded-concurrency ack loop, canPostPRReviewThreadReply classification) is backed by a 704-line test file covering stale-context mid-loop, failed thread resolves, batched conversation replies, and delivery-failure abort. The only open issue is a missing i18n key for a non-GitHub dialog description path, which falls back to readable English text and does not affect functionality. Files Needing Attention: The
|
| Filename | Overview |
|---|---|
| src/renderer/src/components/right-sidebar/pr-comments-ai-launch-ack.ts | New core module; well-tested logic for canPostPRReviewThreadReply, bounded-concurrency ack loop, and module-level singleton for surviving dialog re-renders. |
| src/renderer/src/components/right-sidebar/pr-comment-fixing-reply-body.ts | New helper for building reply bodies; correctly strips [bot] suffix, truncates long snippets, and batches multiple conversation-type comments into one post. |
| src/renderer/src/components/right-sidebar/ChecksPanel.tsx | Complex ref-based lifecycle management added; logic is sound but the abf59262fb i18n key used for the GitLab/no-target description path is missing from all locale files. |
| src/renderer/src/components/right-sidebar/runSourceControlAgentActionStart.ts | Adds onLaunchAccepted/onLaunchAborted lifecycle and wraps onSaveAgentDefault in try/catch to prevent stranded bookkeeping after recipe-save failures. |
| src/renderer/src/components/right-sidebar/pr-comments-ai-launch-ack.test.ts | Comprehensive 704-line test file covering canPostPRReviewThreadReply, batching, bounded concurrency, stale-context handling, and the pending-ack singleton. |
| src/renderer/src/components/GitHubItemDialog.tsx | Reply routing now uses canPostPRReviewThreadReply (broader than the old comment.path check) and attaches parent metadata via attachPRReviewReplyParent for correct sidebar grouping. |
| src/renderer/src/components/PullRequestPage.tsx | Parallel changes to GitHubItemDialog.tsx: same canPostPRReviewThreadReply/buildPRCommentConversationReplyBody/attachPRReviewReplyParent adoption. |
| src/renderer/src/components/right-sidebar/useSourceControlAgentActionDialog.ts | Passes new lifecycle callbacks through; refactors four near-identical useCallback patterns into a resetPlanAfter HOF using useMemo. |
| src/renderer/src/i18n/locales/en.json | Four existing keys updated, one new key (7e4b2a19c0) added; abf59262fb key used in ChecksPanel for the non-GitHub path is absent from all locale files. |
Sequence Diagram
sequenceDiagram
participant U as User
participant CP as ChecksPanel
participant D as SourceControlAgentActionDialog
participant R as runSourceControlAgentActionStart
participant GH as GitHub API
U->>CP: clicks "Resolve Comments With AI"
CP->>CP: setPendingPRCommentAiAck(payload)
CP->>D: open dialog (commentResolution payload)
U->>D: "confirms prompt & clicks Start"
D->>R: runSourceControlAgentActionStart()
R->>R: launchAgentInNewTab()
R-->>CP: onLaunchAccepted()
CP->>CP: "claimPendingCommentResolutionForLaunch()<br/>(moves payload to claimedRef, sets AckBusy=true)"
R->>R: await promptDeliveryResult
alt prompt delivered
R-->>CP: onLaunched()
CP->>CP: consumeClaimedCommentResolutionAfterDelivery()
par per thread group (bounded 4x concurrency)
CP->>GH: addPRReviewCommentReply(Fixing. Will be in the next commit)
CP->>GH: resolvePRReviewThread(threadId)
end
par batched conversation groups
CP->>GH: addPRConversationComment(batched body)
end
CP-->>U: toast (resolved N, replied M, skipped K, failed F)
else prompt delivery failed
R-->>CP: onLaunchAborted()
CP->>CP: "releaseClaimedCommentResolutionAfterFailedLaunch()<br/>(returns payload to pending, AckBusy=false)"
end
Reviews (2): Last reviewed commit: "Handle bot account mentions in PR conver..." | Re-trigger Greptile
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe PR adds deferred AI acknowledgements for selected pull request comments. It posts nested review-thread replies when supported and batches standalone conversation replies. It resolves eligible threads after successful replies, limits concurrent requests, tracks pending launch state, and handles stale or failed launches. Pull request surfaces preserve thread metadata and render nested replies. Launch lifecycle callbacks distinguish session creation from prompt-delivery success. Review prompts, status messages, and translations report reply, resolution, skipped, and failure counts. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/components/GitHubItemDialog.tsx (1)
3276-3284: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winThe conversation-reply fallback builds an unresolvable bot mention in both PR surfaces. Both surfaces build the fallback body as
@${comment.author} ${replyBody}. A GitHub App login carries a[bot]suffix, so@coderabbitai[bot]renders literally and never notifies the bot. This PR narrows the review-thread branch withcanPostPRReviewThreadReply, which routes bot-authored review summaries into this fallback, so the broken mention is now reachable.buildPRCommentConversationReplyBodyinsrc/renderer/src/components/right-sidebar/pr-comment-fixing-reply-body.tsalready strips the suffix.
src/renderer/src/components/GitHubItemDialog.tsx#L3276-L3284: replace thebodytemplate literal withbuildPRCommentConversationReplyBody(comment.author, replyBody)and import the helper.src/renderer/src/components/PullRequestPage.tsx#L3420-L3428: apply the same replacement and import.
🧹 Nitpick comments (4)
src/renderer/src/components/GitHubItemDialog.tsx (2)
3262-3297: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueHoist the routing condition into a local constant.
The same expression
item.type === 'pr' && canPostPRReviewThreadReply(comment)decides the request at Line 3263 and the optimistic update at Line 3294. A future edit can change one occurrence only, and the posted reply would then be decorated with the wrong metadata.♻️ Proposed refactor
+ const isReviewThreadReply = item.type === 'pr' && canPostPRReviewThreadReply(comment) // Why: nest under review threads (path/threadId/discussion_r); never post a // separate top-level conversation comment for those. - const result = - item.type === 'pr' && canPostPRReviewThreadReply(comment) + const result = isReviewThreadReply ? await addPRReviewCommentReplyForRepo({- onCommentAdded( - item.type === 'pr' && canPostPRReviewThreadReply(comment) - ? attachPRReviewReplyParent(result.comment, comment) - : result.comment - ) + onCommentAdded( + isReviewThreadReply ? attachPRReviewReplyParent(result.comment, comment) : result.comment + )
156-159: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winTwo PR conversation surfaces now depend on the launch-ack module for generic helpers.
canPostPRReviewThreadReplyandattachPRReviewReplyParentdescribe PR review-thread reply targets. They do not describe agent launch acknowledgement. Both surfaces import the launch-ack module only to reach them, which points the dependency in the wrong direction. Move both helpers into a dedicated module, for examplesrc/renderer/src/components/right-sidebar/pr-comment-reply-target.ts, and re-export them frompr-comments-ai-launch-ack.tsfor existing callers.
src/renderer/src/components/GitHubItemDialog.tsx#L156-L159: import both helpers from the new module.src/renderer/src/components/PullRequestPage.tsx#L149-L152: import both helpers from the new module.src/renderer/src/components/right-sidebar/checks-panel-content.tsx (1)
2021-2044: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueThe nested-reply composer receives the left rail twice.
The wrapper adds
ml-3 border-l-2 border-border/50 pl-3for every comment in a thread group.renderReplyComposerruns in two positions:
- Under
group.rootat Line 2090, outsidepresentation.repliesContainer.- Under each nested reply at Line 2104, inside
presentation.repliesContainer, which already appliesml-3 border-l-2 border-border/50(seepr-comment-presentation.tsLine 228).In the second position the composer shows a doubled indent and two stacked rails. Key the indentation off the composer position instead of
group.kind.♻️ Proposed refactor
- const renderReplyComposer = (comment: PRComment): React.ReactNode => + const renderReplyComposer = (comment: PRComment, nested = false): React.ReactNode => replyingCommentId === comment.id && onReply ? ( <div className={cn( 'px-3 pb-2', // Why: nest the composer under the parent the same way GitHub nests thread replies. - group.kind === 'thread' && 'ml-3 border-l-2 border-border/50 pl-3' + // The replies container already draws the rail, so only the root composer adds one. + group.kind === 'thread' && !nested && 'ml-3 border-l-2 border-border/50 pl-3' )} >- {renderReplyComposer(reply)} + {renderReplyComposer(reply, true)}src/renderer/src/components/right-sidebar/runSourceControlAgentActionStart.test.ts (1)
108-131: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for launch acceptance on the
onStartbranch.The new tests exercise acceptance only through the
launchAgentInNewTabbranch. The source also callsnotifyLaunchAccepted()in theonStartbranch at lines 91-93 ofrunSourceControlAgentActionStart.ts. That branch has different semantics: it never awaits a delivery result, soonLaunchAbortedmust never fire after a successfulonStart.Add a case that supplies
onStartreturningtrueand assertsonLaunchAcceptedfired once andonLaunchAbortednever fired. Add a second case whereonStartreturnsfalseand assert neither callback fired.🧪 Proposed test additions
+ it('accepts an onStart launch and never aborts it', async () => { + const onLaunchAccepted = vi.fn() + const onLaunchAborted = vi.fn() + const onStart = vi.fn().mockResolvedValue(true) + + await expect( + runSourceControlAgentActionStart( + buildArgs({ onStart, onLaunchAccepted, onLaunchAborted }) + ) + ).resolves.toBe(true) + + expect(onLaunchAccepted).toHaveBeenCalledTimes(1) + expect(onLaunchAborted).not.toHaveBeenCalled() + expect(mocks.onLaunched).toHaveBeenCalledTimes(1) + }) + + it('reports neither callback when onStart declines the launch', async () => { + const onLaunchAccepted = vi.fn() + const onLaunchAborted = vi.fn() + const onStart = vi.fn().mockResolvedValue(false) + + await expect( + runSourceControlAgentActionStart( + buildArgs({ onStart, onLaunchAccepted, onLaunchAborted }) + ) + ).resolves.toBe(false) + + expect(onLaunchAccepted).not.toHaveBeenCalled() + expect(onLaunchAborted).not.toHaveBeenCalled() + })
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 0e7f7e9f-df93-4220-b088-60a7bb9d0c35
📒 Files selected for processing (20)
src/renderer/src/components/GitHubItemDialog.tsxsrc/renderer/src/components/PullRequestPage.tsxsrc/renderer/src/components/pr-comments-resolution-prompt.tssrc/renderer/src/components/right-sidebar/ChecksPanel.tsxsrc/renderer/src/components/right-sidebar/SourceControlAgentActionDialog.tsxsrc/renderer/src/components/right-sidebar/checks-panel-content.tsxsrc/renderer/src/components/right-sidebar/pr-comment-fixing-reply-body.tssrc/renderer/src/components/right-sidebar/pr-comment-presentation.test.tssrc/renderer/src/components/right-sidebar/pr-comment-presentation.tssrc/renderer/src/components/right-sidebar/pr-comments-ai-launch-ack.test.tssrc/renderer/src/components/right-sidebar/pr-comments-ai-launch-ack.tssrc/renderer/src/components/right-sidebar/runSourceControlAgentActionStart.test.tssrc/renderer/src/components/right-sidebar/runSourceControlAgentActionStart.tssrc/renderer/src/components/right-sidebar/useSourceControlAgentActionDialog.tssrc/renderer/src/components/right-sidebar/useSourceControlAgentActionStart.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.json
Use buildPRCommentConversationReplyBody to properly handle GitHub App bot accounts, which don't resolve as @-mentions. Enforce delivery semantics with type-safe PendingPRCommentAiAck payloads and improve error handling around agent launch to prevent stranded state.
Move comment-resolution payload ref clears and latest-callback mirrors into effects so render stays pure for the static analysis gate.
* Post fixing replies after launching PR comment resolution agents Orca now automatically replies to selected comments after launching an agent to resolve them. Review-thread comments get nested replies; review summaries and issue comments get top-level @-replies. Payloads are snapshotted at queue time and posted only after prompt delivery succeeds. Bounded concurrency (4) prevents SSH slowdown. * Batch conversation replies instead of posting per-comment Combine N unresolvable comments into a single PR conversation reply to avoid timeline spam. Review threads still get one nested reply each. Refactor helper functions to pr-comment-fixing-reply-body.ts and change replyAsConversation(comment, body) → replyAsConversation(body). * Handle bot account mentions in PR conversation replies Use buildPRCommentConversationReplyBody to properly handle GitHub App bot accounts, which don't resolve as @-mentions. Enforce delivery semantics with type-safe PendingPRCommentAiAck payloads and improve error handling around agent launch to prevent stranded state. * Fix React Doctor ref-mutated-during-render errors in ChecksPanel Move comment-resolution payload ref clears and latest-callback mirrors into effects so render stays pure for the static analysis gate.
Summary
Describe the user-visible change.
Screenshots
No visual change.Testing
pnpm lintpnpm typecheckpnpm testpnpm buildAI Review Report
Summarize the code review you ran with your AI coding agent. Include the main risks it checked, what it flagged, and what you changed or verified as a result.
Confirm that the review explicitly checked cross-platform compatibility for macOS, Linux, and Windows, including shortcuts, labels, paths, shell behavior, and any Electron-specific platform differences touched by this PR.
Security Audit
Provide a basic security audit summary from your AI coding agent. Call out any input handling, command execution, path handling, auth, secrets, dependency, or IPC risks that were reviewed, plus any follow-up needed.
Notes
Call out any platform-specific behavior, risks, or follow-up work.