Skip to content

Commit d6eebb0

Browse files
committed
fix(desktop): observe the focused window after an untargeted key
1 parent e569e49 commit d6eebb0

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

‎apps/desktop/src/main/computer-use/service.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,17 @@ export class ComputerUseService {
229229
this.check(work)
230230
const owner = 'snapshotId' in input ? this.snapshots.get(input.snapshotId) : undefined
231231
const elementId = 'elementId' in input ? input.elementId : undefined
232-
/** Calls without a window act on the snapshot's selected window, or the element's own. */
232+
/**
233+
* Element and coordinate calls observe the window they acted on. An untargeted key keeps the
234+
* focused-window default, so a key that closes the window still returns fresh state.
235+
*/
233236
const windowId =
234237
('windowId' in input ? input.windowId : undefined) ??
235-
(elementId ? owner?.elementWindows.get(elementId) : undefined) ??
236-
owner?.windowId
238+
(elementId
239+
? (owner?.elementWindows.get(elementId) ?? owner?.windowId)
240+
: 'x' in input
241+
? owner?.windowId
242+
: undefined)
237243
if ('snapshotId' in input) this.snapshots.delete(input.snapshotId)
238244
/** Mutations accept includeScreenshot as shorthand for observeAfter.includeScreenshot. */
239245
const isMutation = input.action !== 'get_app_state'

0 commit comments

Comments
 (0)