MCPcopy Create free account
hub / github.com/Facets-cloud/flow / buildAppleScript

Function buildAppleScript

internal/warp/warp.go:202–219  ·  view source on GitHub ↗

buildAppleScript activates Warp, waits for the new tab from `open warp://...` to take key focus, then keystrokes `bash ` + Return into the front Warp session. Why `keystroke (ASCII character 13)` instead of `keystroke return` or `key code 36`: Warp v0.2026.04 filters synthetic Return-ke

(scriptPath string)

Source from the content-addressed store, hash-verified

200// - 1.8s cold — cold-start Warp launch.
201// - 0.5s mid — between typed text and CR; needed for ~90-char temp paths.
202func buildAppleScript(scriptPath string) string {
203 safePath := escapeAppleScriptString(scriptPath)
204 return fmt.Sprintf(`set wasRunning to application id "dev.warp.Warp-Stable" is running
205tell application "Warp" to activate
206if wasRunning then
207 delay 0.6
208else
209 delay 1.8
210end if
211tell application "System Events"
212 tell process "Warp"
213 keystroke "bash %s"
214 delay 0.5
215 keystroke (ASCII character 13)
216 end tell
217end tell
218`, safePath)
219}
220
221// tempScriptPath returns os.TempDir()/flow-warp-<uuid>.sh. UUID is 16
222// crypto/rand bytes hex-encoded — sufficient uniqueness for concurrent

Callers 1

SpawnTabFunction · 0.85

Calls 1

escapeAppleScriptStringFunction · 0.70

Tested by

no test coverage detected