Skip to content

feat: scale edit timeouts, write outputs atomically, report progress (#81) - #136

Merged
TMHSDigital merged 1 commit into
mainfrom
fix/long-edit-jobs-81
Oct 24, 2026
Merged

TMHSDigital merged 1 commit into
mainfrom
fix/long-edit-jobs-81

Conversation

@TMHSDigital

Copy link
Copy Markdown
Owner

Closes #81.

What

A new src/utils/jobs.ts with runEditJob(args, { output, durationSec, extra }), used by all 17 edit/produce tools in place of runFfmpeg(args, <fixed timeout>):

  • Duration-scaled timeout: max(10 min, 4 × duration); 30 min when the length can't be probed; SCREENCAST_JOB_TIMEOUT_MS overrides. Each tool passes the length of what it writes (trim/clip segment length, speed ÷ factor, concat/assemble sum, title card duration, etc.).
  • Atomic output: ffmpeg writes <name>.partial.<ext> (extension kept so the muxer doesn't change), renamed onto output on success, deleted on failure / timeout / cancel. A retry no longer trips "Output already exists".
  • Progress: -progress pipe:1 -nostats, parsed incrementally (out_time_us, robust to chunk splits), forwarded as notifications/progress (0-100, whole-percent throttled) when the request has a progressToken.
  • Cancellation: the tool's extra.signal kills ffmpeg.

Bug found along the way

The new cancellation test failed on Windows with EPERM: runCapture rejected as soon as it sent the kill, so cleanup tried to delete the .partial while the dying ffmpeg still held it open. It now settles after the child's close (with a 5 s grace timer if close never comes). This also affects the old timeout path, so it fixes a latent issue there too.

Tests

  • Unit (jobs.test.ts): timeout scaling / env override, partial naming, output retargeting, progress parser across chunk boundaries, reporter throttling and the no-token case.
  • Integration (real ffmpeg): successful job renames and reports progress ending at 100; a failing job leaves nothing at output; a cancelled job kills ffmpeg and leaves no partial.
  • End-to-end through the built server with the SDK client's onprogress: compress on a 20 s 720p clip got 8 progress events ending at 100, output present, no .partial.
  • Live capture harness: 9/9.

Version 0.13.0, README, ROADMAP, CHANGELOG updated.

🤖 Generated with Claude Code

…81)

All edit and produce tools now go through runEditJob: the timeout scales
with the media's duration (SCREENCAST_JOB_TIMEOUT_MS overrides), ffmpeg
writes a .partial sibling that is renamed on success and deleted on any
failure, and -progress pipe:1 is forwarded as MCP progress notifications
when the request has a progressToken. Cancelling a request kills ffmpeg.

runCapture now waits for a killed child to exit before rejecting, so
Windows cleanup no longer races the dying process (EPERM).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@TMHSDigital
TMHSDigital merged commit 5c20ac5 into main Oct 24, 2026
8 checks passed
@TMHSDigital
TMHSDigital deleted the fix/long-edit-jobs-81 branch October 24, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Long edits: fixed timeouts, partial output files left behind, and no progress reporting

1 participant