fix(cua): check step cancellation after the helper query
This commit is contained in:
1 parent
d4c0e28f60
commit
102493bfcc
2 files changed
+2
-2
No files matched your search
@@ -44,7 +44,7 @@ export function watchWindowActivity(ctx: Context): NonNullable<CuaBackend['windo
|
||||
ctx.on('agent/pre-step', async ({ agent, signal }, next) => {
|
||||
const decision = await next()
|
||||
const watch = watches.get(agent.session)
|
||||
if (decision.kind === 'reject' || signal.aborted || !watch || watch.client.disposed) return decision
|
||||
if (decision.kind === 'reject' || !watch || watch.client.disposed) return decision
|
||||
const lines: string[] = []
|
||||
for (const [handle, windows] of watch.apps) {
|
||||
const observations = Object.fromEntries(windows)
|
||||
|
||||
@@ -239,7 +239,7 @@ it('delivers window activity at the next accepted step and clears it at turn end
|
||||
native.request.mockResolvedValueOnce([{ windowId: '7', source: 'agent', ageSeconds: 5 }])
|
||||
expect(JSON.stringify(await step())).toContain('5 seconds ago')
|
||||
const controller = new AbortController()
|
||||
native.request.mockImplementationOnce(() => { controller.abort(); return Promise.reject(controller.signal.reason) })
|
||||
native.request.mockImplementationOnce(() => { controller.abort(); return Promise.reject(new Error('cancelled')) })
|
||||
expect(await step(controller.signal)).toMatchObject({ messages: [] })
|
||||
native.request.mockResolvedValueOnce([{ windowId: '8', source: 'agent', ageSeconds: 5 }])
|
||||
expect(await step()).toMatchObject({ messages: [] })
|
||||
|
||||
Reference in new issue
Block a user