Repository navigation
Description
Summary
Arm a recording instead of starting it: start_recording { startWhen, stopWhen } waits for a condition (a window appears, a process starts, text shows up on screen, the screen changes) and only then starts capturing. stopWhen ends it the same way. This turns the server into a tripwire for intermittent bugs and keeps recordings short.
Where
src/tools/startRecording.ts: starts immediately; the only automatic stop ismaxDurationSecor the window closing.src/utils/waitLoop.ts: the pure polling loop already used bywait_for_change.src/utils/resolveTarget.ts/src/utils/windows.ts: window matching thatstartWhen.windowcan reuse.src/utils/ocr.ts: OCR forstartWhen.text.
Details
Today an agent that wants to capture "the moment the error dialog appears" has to either record everything (large files, more to review) or poll with wait_for_change and race to start a recording after the fact. The replay buffer (save_replay) covers "keep what just happened"; triggers cover "start when it happens", and the two combine well (startWhen + replayBufferSec keeps a few seconds of lead-in).
start_recording {
"target": "window:exe=myapp.exe",
"startWhen": { "window": "Error*" },
"stopWhen": { "text": "Ready", "orAfterSec": 60 },
"replayBufferSec": 10
}Suggested fix
- Conditions:
window(title glob or exe appears),process(exe starts),text(OCR match, ties into wait_for_change mode "text": wait until OCR text appears or disappears #318),change(reusewait_for_changesettings). - New session state
armed, visible inlist_sessions/get_sessionand the session resource;stop_recordingon an armed session just disarms it. armTimeoutSecso a trigger never waits forever.- Return the trigger time and what matched in the session result.
Acceptance criteria
- Armed sessions appear in session listings and can be cancelled
- Each condition type tested with the pure wait loop
-
startWhen+replayBufferSeckeeps the lead-in seconds - Arm timeout ends the session with a clear status
Getting started
- Relevant files:
src/tools/startRecording.ts,src/utils/waitLoop.ts,src/utils/sessions.ts - Tests:
npm test
Related: #318
Filed by repo-audit/feature-ideas at 19569f7. Severity: medium. Effort: M. audit-key: enhancement|src/tools/startRecording.ts|startWhen
Activity
TMHSDigital commentedon Nov 15, 2026
Done in c3c4805: start_recording startWhen {window, text, timeoutSec} arms a recording and returns an arm id. It starts with the same arguments once the window exists and/or the text is on screen. list_sessions shows arms, get_session reports the outcome, stop_recording disarms, and shutdown disarms everything. stopWhen {text} stops a recording when its text appears. Verified with unit tests and a live run (arm fired, recorded, stopped by arm id; a second arm was listed and disarmed). Process-start conditions and a replay lead-in combination were not added; a window:exe= condition covers apps with a window.