Skip to content

Triggered recording: start/stop when a window, process, or text appears #336

Closed

Description

@TMHSDigital

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 is maxDurationSec or the window closing.
  • src/utils/waitLoop.ts: the pure polling loop already used by wait_for_change.
  • src/utils/resolveTarget.ts / src/utils/windows.ts: window matching that startWhen.window can reuse.
  • src/utils/ocr.ts: OCR for startWhen.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

  1. 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 (reuse wait_for_change settings).
  2. New session state armed, visible in list_sessions/get_session and the session resource; stop_recording on an armed session just disarms it.
  3. armTimeoutSec so a trigger never waits forever.
  4. 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 + replayBufferSec keeps 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

  1. added
    enhancement
    help wanted
    effort: medium
    on Nov 15, 2026
  2. TMHSDigital commented on Nov 15, 2026

    @TMHSDigital
    OwnerAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort: mediumenhancementhelp wantedpriority: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions