Repository navigation
feat(computer): add RecordStart and RecordStop screen recording tools - #1304
Conversation
Opt-in tools (computer_use.recording.enabled) that record the primary screen, a window, or a frame-space region to H.264/yuv420p MP4 with ffmpeg (PATH first, then the prebuilt ~/.infer/bin download). - One recording at a time; RecordStop finalizes it by sending "q", and ffmpeg -t caps it at max_duration (default 120s) on its own. - ServiceContainer.Shutdown finalizes an active recording on exit, SIGINT and SIGTERM; infer tools execute refuses both tools. - Window bounds are resolved natively: the macOS AX helper, EWMH over X11, and user32/DWM on Windows. The X11 screen size is read from X directly because robotgo's purego build targets Wayland. - macOS crops relative to the captured input so Retina scaling needs no detection; Screen Recording permission is preflighted. - Approval follows computer_use.approval; the chat status bar shows a REC badge while recording. Closes #1293
# Conflicts: # go.mod # internal/container/container.go # internal/presentation/tui/app/chat.go
Co-authored-by: Eden Reich <[email protected]>
|
@infer Can you review this PR? use /ponytail:ponytail /ponytail:ponytail-review /domain-driven-design /clean-architecture /clean-code |
|
Model: Todos
Pull Request✅ Infer Result: SuccessReview complete. Here are my findings: Review of PR #1304 (RecordStart / RecordStop)Read the full diff (36 files, +1586/-45), the new recorder/capture/record_tools code with its tests, and the supporting code they reuse (audio BinaryStore, approval policy, computer domain). Verified locally: ponytail-review (over-engineering hunt)This diff is unusually disciplined for its size. The reuse rungs were genuinely climbed rather than performed: ffmpeg resolution reuses
Nothing else to cut -
domain-driven-design: 8/10Satisfied rows: expert-readable names ( clean-architecture: 9/10Six of seven diagnostic rows satisfied: lifecycle rules test without a screen or real ffmpeg; dependencies point inward within the repo's context model (presentation untouched except the event handler and status bar); capture implementations swap behind three small per-OS functions; the recorder knows nothing about TUI/headless (it emits a bool event); Main wires everything ( clean-code: 9/10Names reveal intent; comments explain why (exit 255, Correctness notes (outside ponytail-review's scope, flagged for the record)
Bottom lineLean, well-layered, and honestly tested; the admitted gaps (Windows runtime, binaries#31 ffmpeg rebuild) are correctly documented with follow-ups. Nothing blocking from this review - the two two-line nits and the optional registry-helper move are the whole list. Model: Tokens: 2,053,408 in · 20,954 out · 2,074,362 total (20 requests) Tool calls: 29 total · 100% success rate TracesStatsTriggered by edenreich · Infer Action · OSS |
- Move the session-only tool check into IsSessionOnlyTool next to IsComputerUseTool - Keep the DWM error when reading window bounds on Windows - Name an uncollected, already stopped recording in the next RecordStart status - Make the stop timeout a recorder field and test the kill of a hung ffmpeg - Flatten FormatForLLM guards and drop comments inside function bodies
- Name the accessibility bbox format [left, top, right, bottom] in its result - Give RecordStart the tmux pane to region formula - Only call RecordStop when the user asks to stop the recording
RecordStart starts capturing the screen, so in chat it now always asks for approval (auto-accept mode still bypasses). RecordStop stays approval-free, and outside chat both keep following computer_use.approval.
…t outside chat
RecordStart now requires approval in every mode except auto-accept, so
headless hosts get it as an approval_request with --require-approval
(and it is blocked without an approver) instead of only the chat TUI
prompting. RecordStop is unchanged.
Headless installs a UI notifier bridge that forwards recording status
into the rendered stream; the AG-UI renderer emits it as a CUSTOM
screen_recording event with {active}, so a desktop host can show a
recording indicator.
…s runs alive A screen recording now holds a machine-wide lock (~/.infer/run/screen-recording.lock, flock or LockFileEx) while its ffmpeg runs, so a RecordStart from any other infer process fails with the owner's pid instead of starting a competing capture. A running recording is also a silent, session-holding background job (kind recording): a headless run waits for it instead of exiting and finalizing it early, so a user_message follow-up can reach RecordStop in the same process, and /tasks lists it. A recording that ends on its own queues a note asking the agent to collect it with RecordStop.
|
🎉 This PR is included in version 0.208.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Resolves #1293
Summary
Adds two opt-in tools,
RecordStartandRecordStop, that record the primary screen, a single window, or a frame-space region to an H.264 /yuv420pMP4 with ffmpeg. Gated bycomputer_use.recording.enabled(INFER_COMPUTER_USE_RECORDING_ENABLED), off by default.Changes
computer_use.recording(enabled,max_duration120,output_dir->~/.infer/tmp/recordings,framerate15), validated when enabled; env vars come free through the sidecar mapping.internal/computer/recorder.go) - one recording at a time. ffmpeg runs withexec.Commandso it outlives the tool call, is stopped withqon stdin (works on every OS, writes themoovatom), and is capped with-t max_durationso it also finalizes on its own. A 1.5s startup check surfaces ffmpeg errors (missing encoder, capture device, permission) as the tool error. Exit status 255 (ffmpeg finalizing after a terminal signal) counts as success; a kill after the 10s stop timeout is reported.ServiceContainer.Shutdownfinalizes an active recording first, covering normal exit, SIGINT and SIGTERM for chat and headless.infer tools executerefuses both tools, since a one-shot run never shuts down.internal/computer/infrastructure/capture) - robotgo's purego build has no window-bounds API on any OS, so bounds are resolved natively: macOS through a newwindowaction in the existing AX helper, Linux through EWMH over X11 (jezek/xgbutil), Windows through user32 + DWM frame bounds. On Linux the screen size is read from X directly, because robotgo's purego build targets Wayland (see [BUG] Computer tool reports a 0x0 display on Linux X11 in purego release builds #1303).avfoundation+ acropexpressed relative to the input size, so the Retina backing scale never has to be detected; Screen Recording permission is preflighted withCGPreflightScreenCaptureAccess. Linux:x11grab -video_size/+X,Y, refused under Wayland or withoutDISPLAY. Windows:gdigrabwith offsets/size in physical pixels (DESKTOPHORZRES/HORZRES). Sizes are rounded down to even for libx264.ffmpegon PATH, otherwise the prebuilt~/.infer/bin/ffmpegdownload (reusingaudio.BinaryStore). That build gains libx264 and the screen grabbers in feat: build ffmpeg with screen capture and libx264 binaries#31.computer_use.approval(observations underdestructive).ScreenRecordingStatusEventdrives a● RECbadge in the status bar that is never dropped for space and clears when ffmpeg exits (stop, cap, or shutdown).docs/tools-reference.md,docs/configuration-reference.md,docs/directory-structure.md, README tool table.Verification
-race): per-OS ffmpeg args for each mode, even rounding and clamping, frame-to-screen scaling and the region error text, request parsing, target parsing, the Wayland/DISPLAYrefusal, and the recorder lifecycle against the test binary acting as ffmpeg (single-active guard, stop with nothing running, max-duration cap, Close finalizing and refusing new starts, startup failure surfacing stderr).inferbinary driven by the mock gateway: screen, region, and window (app:Finder,frontmost) recordings probed withffprobe(h264, yuv420p, even Retina dimensions); both guards;max_duration=3stops on its own; normal exit, SIGTERM and Ctrl+C in the TUI all leave a playable file and no ffmpeg process;● RECshows while recording and clears at the cap.app:xterm,frontmost) and region recordings probe as h264/yuv420p with even dimensions, guards work, the recording finalizes on exit, and a Wayland session gets the clear refusal.task precommit:runpasses;golangci-lintis also clean withGOOS=linuxandGOOS=windows.Cross-repo impact
avfoundation/gdigrab/x11grab; the macOS/Windows builds become GPL (Linux already was). Until that release ships, recording needs ffmpeg on PATH; an outdated~/.infer/bin/ffmpegfails with an error that names the fix.~/.infer/bin/ffmpegcache, so it gets the larger binary; no behaviour change.Follow-ups
Computertool sees a 0x0 display on X11 in purego builds.