mirror of
https://github.com/remorses/gpuix.git
synced 2026-10-28 18:59:22 +08:00
Make every native example honor GPUIX_BACKGROUND and make every current real-window automation example pass that flag. Human launches still focus normally, while agent-driven launches avoid taking the user keyboard on macOS and Windows. Explain why live input, clicks, and screenshots do not require activation. Correct stale guidance that claimed fill and press were unavailable, and document that Linux currently ignores the focus option. Validated with the examples and example-app test suites, type checking, lintcn, a live screenshot, and a macOS foreground-process check. Session: ses_fb208083cffewN8NfeygDAdslz
33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
/**
|
|
* Drive the app like Playwright and write a PNG.
|
|
*
|
|
* `launch()` starts `app.tsx` as a child process and speaks the automation
|
|
* protocol over its stdin pipe. `clock.pause()` freezes native motion, so the
|
|
* sidebar frame is the same on every run.
|
|
*
|
|
* bun run screenshot writes screenshots/todo.png
|
|
* bun run screenshot out.png writes that path instead
|
|
*/
|
|
|
|
import { mkdirSync } from 'node:fs'
|
|
import path from 'node:path'
|
|
|
|
import { launch } from '@gpuix/react/automation'
|
|
|
|
// The renderer writes the file itself and does not create the folder.
|
|
const out = process.argv[2] ?? 'screenshots/todo.png'
|
|
mkdirSync(path.dirname(out), { recursive: true })
|
|
|
|
const app = await launch({
|
|
command: 'bun',
|
|
args: ['app.tsx'],
|
|
// Live automation needs the real window, but never needs to interrupt the user.
|
|
env: { GPUIX_BACKGROUND: '1' },
|
|
})
|
|
await app.getByTestId('composer').waitFor({ timeoutMs: 60_000 })
|
|
await app.clock.pause()
|
|
await app.screenshot({ path: out })
|
|
await app.close()
|
|
|
|
console.log(`[screenshot] wrote ${out}`)
|