fix: don't retry or show AbortError; remove reason from dispose; don't clean history in dispose

This commit is contained in:
Simon
2026-01-22 20:19:51 +08:00
parent 299a5b2075
commit dad837e173
2 changed files with 8 additions and 7 deletions

View File

@@ -108,6 +108,7 @@ export class PageAgentCore extends EventTarget {
})
this.#llm.addEventListener('error', (e) => {
const error = (e as CustomEvent).detail.error as Error | InvokeError
if ((error as any)?.rawError?.name === 'AbortError') return
const message = String(error)
this.emitActivity({ type: 'error', message })
// Also push to history for panel rendering
@@ -577,16 +578,16 @@ export class PageAgentCore extends EventTarget {
`)
}
dispose(reason?: string) {
dispose() {
console.log('Disposing PageAgent...')
this.disposed = true
this.pageController.dispose()
this.history = []
this.#abortController.abort(reason ?? 'PageAgent disposed')
// this.history = []
this.#abortController.abort()
// Emit dispose event for UI cleanup
this.dispatchEvent(new Event('dispose'))
this.config.onDispose?.(this, reason)
this.config.onDispose?.(this)
}
}

View File

@@ -88,12 +88,12 @@ async function withRetry<T>(
try {
return await fn()
} catch (error: unknown) {
// do not retry if aborted by user
if ((error as any)?.rawError?.name === 'AbortError') throw error
console.error(error)
settings.onError(error as Error)
// do not retry if aborted by user
if ((error as { name?: string })?.name === 'AbortError') throw error
// do not retry if error is not retryable (InvokeError)
if (error instanceof InvokeError && !error.retryable) throw error