fix(ui): surface declarative startup failures

This commit is contained in:
Turtle
2026-07-17 16:44:25 +08:00
parent 1119c537d0
commit 12b7ac67ba
20 changed files with 484 additions and 72 deletions

View File

@@ -363,18 +363,29 @@ export class AgentLoop extends Service implements AgentFactory {
this.create(id, options, cwd === undefined ? {} : { cwd })
continue
}
ctx.effect(() => {
ctx.effect(function* (this: AgentLoop) {
let active = true
let releaseFailure = (): void => {}
const fiber = ctx.inject(['sessionPersistence'], (childCtx: Context) => {
void this.resumeWith(ctx, childCtx.sessionPersistence, {
agentId: id,
resumeSessionId,
agentOptions: options,
}).catch((error: unknown) => {
if (!active) return
const failure = new Error(error instanceof Error ? error.message : String(error), { cause: error })
ctx.logger.warn(`agent "${id}": config-driven resume of "${resumeSessionId}" failed: ${String(error)}`)
releaseFailure = ctx.agents.reportStartFailure(id, failure)
})
})
return fiber.dispose
}, `agentLoop.resume(${id})`)
yield fiber.dispose
// Yielded last, disposed first: suppress teardown rejection before the
// deferred persistence child wakes and clear any retained record.
yield () => {
active = false
releaseFailure()
}
}.bind(this), `agentLoop.resume(${id})`)
}
}