MCPcopy
hub / github.com/codeaashu/claude-code / withModifiers

Function withModifiers

src/utils/computerUse/executor.ts:150–165  ·  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

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

Callers 1

clickFunction · 0.85

Calls 2

releasePressedFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected