mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-19 01:51:21 +08:00
fix(agent-manager): reload the snapshot only for expired review failures
Content rejections such as an empty body or a bad line range leave the snapshot valid, so gate the reload on the host's reload hints instead of every failed comment. Extend the regression test to cover the non-expiry cases.
This commit is contained in:
@@ -80,10 +80,12 @@ describe("PR diff comment state", () => {
|
||||
state.dispose()
|
||||
})
|
||||
|
||||
it("keeps the cached snapshot when a comment succeeds or belongs elsewhere", () => {
|
||||
it("keeps the cached snapshot when a comment succeeds, fails on content, or belongs elsewhere", () => {
|
||||
const { posted, receive, state, comment } = setup()
|
||||
|
||||
receive(comment({ success: true, error: undefined }) as ExtensionMessage)
|
||||
receive(comment({ error: "A review comment body is required." }) as ExtensionMessage)
|
||||
receive(comment({ error: "Selected lines are not in a complete review hunk." }) as ExtensionMessage)
|
||||
receive(comment({ worktreeId: "other" }) as ExtensionMessage)
|
||||
receive(comment({ projectId: "other" }) as ExtensionMessage)
|
||||
|
||||
|
||||
@@ -84,10 +84,15 @@ export function createPRDiffCommentState(opts: Options) {
|
||||
}
|
||||
|
||||
// The host caps its snapshot store, so a comment can fail against a snapshot
|
||||
// it has already dropped. Drop the cached snapshot and reload, so the next
|
||||
// attempt is bound to a snapshot the host still holds.
|
||||
// it has already dropped. Those failures, and the context/ref changes that
|
||||
// invalidate a snapshot, end with the host's reload hints; content errors
|
||||
// (empty body, bad line range, unconfirmed write) must not force a reload.
|
||||
// Keep in sync with the throw messages in review-actions.ts and
|
||||
// pr-status-bridge.ts.
|
||||
const expired = /(?:Reload the review|Refresh and try again|Reopen the PR review)/
|
||||
const release = opts.onMessage((message) => {
|
||||
if (message.type !== "agentManager.createReviewCommentResult" || message.success) return
|
||||
if (!expired.test(message.error ?? "")) return
|
||||
const ctx = typeof message.worktreeId === "string" ? message.worktreeId : undefined
|
||||
const route = target(ctx)
|
||||
if (!route || route.projectId !== message.projectId) return
|
||||
|
||||
Reference in New Issue
Block a user