Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/core/task/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -739,14 +739,18 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
// saves, and only post parts of partial message instead of
// whole array in new listener.
this.updateClineMessage(lastMessage)
throw new Error("Current ask promise was ignored (#1)")
// Return a placeholder response for partial updates
// This prevents the error from disrupting the flow
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good fix for the partial message handling. However, consider adding a comment explaining why we return placeholder responses instead of throwing errors. Something like:

Suggested change
// This prevents the error from disrupting the flow
// Return a placeholder response for partial updates
// This prevents the "Current ask promise was ignored" error from disrupting the flow
// during multi-file concurrent diff operations
return { response: "messageResponse" as ClineAskResponse, text: undefined, images: undefined }

This would help future maintainers understand the design decision.

return { response: "messageResponse" as ClineAskResponse, text: undefined, images: undefined }
} else {
// This is a new partial message, so add it with partial
// state.
askTs = Date.now()
this.lastMessageTs = askTs
await this.addToClineMessages({ ts: askTs, type: "ask", ask: type, text, partial, isProtected })
throw new Error("Current ask promise was ignored (#2)")
// Return a placeholder response for partial updates
// This prevents the error from disrupting the flow
return { response: "messageResponse" as ClineAskResponse, text: undefined, images: undefined }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same suggestion here - add a clarifying comment for consistency:

Suggested change
return { response: "messageResponse" as ClineAskResponse, text: undefined, images: undefined }
// Return a placeholder response for partial updates
// This prevents the error from disrupting the flow
return { response: "messageResponse" as ClineAskResponse, text: undefined, images: undefined }

}
} else {
if (isUpdatingPreviousPartial) {
Expand Down
27 changes: 25 additions & 2 deletions src/core/tools/multiApplyDiffTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { TelemetryService } from "@roo-code/telemetry"
import { DEFAULT_WRITE_DELAY_MS } from "@roo-code/types"

import { ClineSayTool } from "../../shared/ExtensionMessage"
import { ClineAskResponse } from "../../shared/WebviewMessage"
import { getReadablePath } from "../../utils/path"
import { Task } from "../task/Task"
import { ToolUse, RemoveClosingTag, AskApproval, HandleError, PushToolResult } from "../../shared/tools"
Expand Down Expand Up @@ -101,7 +102,13 @@ export async function applyDiffTool(
path: getReadablePath(cline.cwd, filePath),
}
const partialMessage = JSON.stringify(sharedMessageProps)
await cline.ask("tool", partialMessage, block.partial).catch(() => {})
// Handle partial message updates gracefully
try {
await cline.ask("tool", partialMessage, block.partial)
} catch (error) {
// Log the error for debugging but don't disrupt the flow
console.debug(`Partial message update handled: ${error instanceof Error ? error.message : String(error)}`)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The error message could be more descriptive. Consider:

Suggested change
console.debug(`Partial message update handled: ${error instanceof Error ? error.message : String(error)}`)
console.debug(`Partial message update handled gracefully during multi-file diff: ${error instanceof Error ? error.message : String(error)}`)

This provides better context when debugging multi-file operations.

}
return
}

Expand Down Expand Up @@ -306,7 +313,23 @@ Original error: ${errorMessage}`
isProtected: hasProtectedFiles,
} satisfies ClineSayTool)

const { response, text, images } = await cline.ask("tool", completeMessage, hasProtectedFiles)
let response: ClineAskResponse
let text: string | undefined
let images: string[] | undefined

try {
const askResult = await cline.ask("tool", completeMessage, hasProtectedFiles)
response = askResult.response
text = askResult.text
images = askResult.images
} catch (error) {
// If ask fails, provide clear feedback to the model
const errorMessage = `Failed to get approval for batch diff operations: ${error instanceof Error ? error.message : String(error)}`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good error handling here! The clear feedback to the model when batch operations fail is exactly what we need. Consider extracting the error message construction to reduce duplication if this pattern is used elsewhere.

await cline.say("error", errorMessage)
pushToolResult(errorMessage)
cline.processQueuedMessages()
return
}

// Process batch response
if (response === "yesButtonClicked") {
Expand Down
Loading