fix(cua): annotate the post-approval lifetime recheck

This commit is contained in:
creatixchu committed 2026-09-29 19:05:40 +08:00
1 parent 1d40e9bf31
commit e3ab7232ef
1 file changed
+2 -2
@@ -81,8 +81,6 @@ export class ApplicationAccess {
const saved = identity.persistable && this.options.grants().some(grant => grant.id === identity.id)
let scope: Selection['scope'] = 'persistent'
if (!saved && this.rejected.get(agent)?.has(identity.id)) throw this.denied(identity)
// The awaited user decision can outlive the helper, so re-read its live getter.
// oxlint-disable-next-line typescript/no-unnecessary-condition
if (client.disposed) throw new NativeError('NATIVE_CLOSED', 'Helper is closed; acquire fresh application handles')
if (!saved) {
const questions = this.ctx.get('userQuestions')
@@ -120,6 +118,8 @@ export class ApplicationAccess {
}
}
signal.throwIfAborted()
// The awaited user decision can outlive the helper, so re-read its live getter.
// oxlint-disable-next-line typescript/no-unnecessary-condition
if (client.disposed) throw new NativeError('NATIVE_CLOSED', 'Helper is closed; acquire fresh application handles')
const state = this.clients.get(client) ?? { agent, handles: new Map<CuaAppHandle, Selection>() }
const { persistable: _persistable, ...grant } = identity