mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
Handle cancelling browser session
This commit is contained in:
@@ -614,7 +614,7 @@ export class Cline {
|
||||
newUserContent.push({
|
||||
type: "text",
|
||||
text:
|
||||
`[TASK RESUMPTION] This task was interrupted ${agoText}. It may or may not be complete, so please reassess the task context. Be aware that the project state may have changed since then. The current working directory is now '${cwd.toPosix()}'. If the task has not been completed, retry the last step before interruption and proceed with completing the task.\n\nNote: If you previously attempted a tool use that the user did not provide a result for, you should assume the tool use was not successful and assess whether you should retry.${
|
||||
`[TASK RESUMPTION] This task was interrupted ${agoText}. It may or may not be complete, so please reassess the task context. Be aware that the project state may have changed since then. The current working directory is now '${cwd.toPosix()}'. If the task has not been completed, retry the last step before interruption and proceed with completing the task.\n\nNote: If you previously attempted a tool use that the user did not provide a result for, you should assume the tool use was not successful and assess whether you should retry. If the last tool was a browser_action, the browser has been closed and you must launch a new browser if needed.${
|
||||
wasRecent
|
||||
? "\n\nIMPORTANT: If the last tool use was a write_to_file that was interrupted, the file was reverted back to its original state before the interrupted edit, and you do NOT need to re-read the file as you already have its up-to-date contents."
|
||||
: ""
|
||||
|
||||
@@ -37,8 +37,19 @@ const BrowserSessionRow = memo((props: BrowserSessionRowProps) => {
|
||||
const [maxActionHeight, setMaxActionHeight] = useState(0)
|
||||
const [consoleLogsExpanded, setConsoleLogsExpanded] = useState(false)
|
||||
|
||||
// const isLastApiReqInterrupted = useMemo(() => {
|
||||
// // Check if last api_req_started is cancelled
|
||||
// const lastApiReqStarted = [...messages].reverse().find((m) => m.say === "api_req_started")
|
||||
// if (lastApiReqStarted?.text != null) {
|
||||
// const info = JSON.parse(lastApiReqStarted.text)
|
||||
// return info.cancelReason != null
|
||||
// }
|
||||
// const lastApiReqFailed = isLast && lastModifiedMessage?.ask === "api_req_failed"
|
||||
// return lastApiReqFailed
|
||||
// }, [messages, lastModifiedMessage, isLast])
|
||||
|
||||
const isBrowsing = useMemo(() => {
|
||||
return isLast && messages.some((m) => m.say === "browser_action_result") // after user approves, browser_action_result with "" is sent to indicate that the session has started
|
||||
return isLast && messages.some((m) => m.say === "browser_action_result") //&& !isLastApiReqInterrupted // after user approves, browser_action_result with "" is sent to indicate that the session has started
|
||||
}, [isLast, messages])
|
||||
|
||||
// Organize messages into pages with current state and next action
|
||||
|
||||
@@ -473,6 +473,22 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
|
||||
isInBrowserSession = true
|
||||
currentGroup.push(message)
|
||||
} else if (isInBrowserSession) {
|
||||
// end session if api_req_started is cancelled
|
||||
|
||||
if (message.say === "api_req_started") {
|
||||
// get last api_req_started in currentGroup to check if it's cancelled. If it is then this api req is not part of the current browser session
|
||||
const lastApiReqStarted = [...currentGroup].reverse().find((m) => m.say === "api_req_started")
|
||||
if (lastApiReqStarted?.text != null) {
|
||||
const info = JSON.parse(lastApiReqStarted.text)
|
||||
const isCancelled = info.cancelReason != null
|
||||
if (isCancelled) {
|
||||
endBrowserSession()
|
||||
result.push(message)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isBrowserSessionMessage(message)) {
|
||||
currentGroup.push(message)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user