refactor: decouple open_file from recording logic + auto-detect ffmpeg#392
Merged
refactor: decouple open_file from recording logic + auto-detect ffmpeg#392
Conversation
Per owner's design directive: "The recording tool should return the
files and the default file to use. The caller should process the result
and report abnormality if any. Then open_file tool should be called with
filename."
Changes:
1. open_file: stripped recording-specific logic.
- Requires `path` arg (get it from recording tool result).
- `find_latest_recording: true` flag as explicit fallback — only
called when model lost the path, not as silent default.
- Removed: subtitled_pending flag, version detection, polling
logic, findRecording() as default behavior.
- Kept: known file aliases (diagnostics), QuickTime activation,
playback-path write, duration/size metadata.
2. screen_record stop: returns explicit file list.
- New `files` object: `{raw, narrated, subtitled, recommended}`.
- `instruction` string tells the model exactly which path to pass
to open_file and how to offer alternatives to the user.
- Subtitle burn still happens synchronously on stop.
3. No changes to record_screen_with_narration — its auto-stop timer
fires in a setTimeout and can't return files to the model through
a tool result. The model already has the raw path from the start
call; open_file with that path works. Full file-list return for
record_screen_with_narration is a follow-up.
Net: +39/-38 (near-zero). This is a separation of concerns, not new
features. findRecording() and findFfmpegWithSubtitles() are preserved
as helpers; they just stop being called by default in open_file.
Supersedes the approach in #353 (non-blocking return + subtitled_pending)
and makes #355 (subtitled_pending gate) + #357 (ffmpeg-full path)
unnecessary as open_file changes — though #357's findFfmpegWithSubtitles
is still needed in the recording tool's burn path.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Apr 16, 2026
sonichi
commented
Apr 16, 2026
Owner
Author
sonichi
left a comment
There was a problem hiding this comment.
MacBook review: LGTM. Clean redesign:
- open_file now requires path from model, find_recording is explicit fallback only
- screen_record stop returns {files: {raw, narrated, subtitled, recommended}} with paths
- findFfmpegWithSubtitles() cached probe with env override
- burnLiveTranscriptSubtitles uses detected binary, graceful skip if no libass
- Removed all subtitled_pending/polling logic (root cause of false positives)
- +71/-41, tsc clean. Ready to merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Per owner's design directive: recording tools return explicit file paths,
open_filebecomes a path-based file opener, andfindFfmpegWithSubtitles()auto-detects the right ffmpeg binary for subtitle burns.Supersedes #355 (subtitled_pending gate) and #357 (ffmpeg-full path switch) — folds both concerns into a cleaner architecture.
Changes (+71/-41)
1.
open_filestripped of recording-specific logicpatharg — get it from the recording tool's return valuefind_recording: trueflag as explicit fallback only (when model lost the path)2.
screen_record stopreturns explicit file listfilesobject:{raw, narrated, subtitled, recommended}instructionstring tells the model exactly which path to pass toopen_file3.
findFfmpegWithSubtitles()auto-detection (from #357)$FFMPEG_SUBTITLE_BINenv → systemffmpeg→ homebrew narrow → homebrew full (keg-only)burnLiveTranscriptSubtitles()uses it instead of hardcoded/opt/homebrew/bin/ffmpegWhy this design
Owner: "The recording tool should return the files and the default file to use. The caller should process the result and report abnormality. Then open_file should be called with filename."
This eliminates the class of bugs we chased yesterday:
Test plan
npx tsc --noEmit --skipLibCheckcleanfindFfmpegWithSubtitles()runtime-tested: correctly picks ffmpeg-full on Mac MiniPRs to close after merge
Still open (independent)
🤖 Generated with Claude Code