MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / withModifiers

Function withModifiers

source code/utils/computerUse/executor.ts:152–167  ·  view source on GitHub ↗

* Bracket `fn()` with modifier press/release. `pressed` tracks which presses * actually landed, so a mid-press throw only releases what was pressed — no * stuck modifiers. The finally covers both press-phase and fn() throws. * * Caller must already be inside drainRunLoop() — key() dispatches to

(
  input: Input,
  mods: string[],
  fn: () => Promise<T>,
)

Source from the content-addressed store, hash-verified

150 * main queue and needs the pump to resolve.
151 */
152async function withModifiers<T>(
153 input: Input,
154 mods: string[],
155 fn: () => Promise<T>,
156): Promise<T> {
157 const pressed: string[] = []
158 try {
159 for (const m of mods) {
160 await input.key(m, 'press')
161 pressed.push(m)
162 }
163 return await fn()
164 } finally {
165 await releasePressed(input, pressed)
166 }
167}
168
169/**
170 * Port of Cowork's `typeViaClipboard`. Sequence:

Callers 1

clickFunction · 0.85

Calls 1

releasePressedFunction · 0.85

Tested by

no test coverage detected