fix: reusable agent after stop
Reset AbortController and status when stop() is called. Agent can now be reused for subsequent tasks. Changes: - Check if already stopped to prevent double-abort - Reset status to 'idle' - Create new AbortController for next task
This commit is contained in:
@@ -187,9 +187,12 @@ export class PageAgentCore extends EventTarget {
|
|||||||
|
|
||||||
/** Stop the current task. Agent remains reusable. */
|
/** Stop the current task. Agent remains reusable. */
|
||||||
stop() {
|
stop() {
|
||||||
|
if (this.#abortController.signal.aborted) return // Already stopped
|
||||||
this.pageController.cleanUpHighlights()
|
this.pageController.cleanUpHighlights()
|
||||||
this.pageController.hideMask()
|
this.pageController.hideMask()
|
||||||
this.#abortController.abort()
|
this.#abortController.abort()
|
||||||
|
this.#setStatus('idle')
|
||||||
|
this.#abortController = new AbortController()
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(task: string): Promise<ExecutionResult> {
|
async execute(task: string): Promise<ExecutionResult> {
|
||||||
|
|||||||
Reference in New Issue
Block a user