fix(cua-driver-rs)(macos): isolate and clean up window capture temp files - #2281
Open
z-x-yang wants to merge 1 commit into
Open
fix(cua-driver-rs)(macos): isolate and clean up window capture temp files#2281z-x-yang wants to merge 1 commit into
z-x-yang wants to merge 1 commit into
Conversation
z-x-yang
requested review from
ddupont808,
f-trycua and
r33drichards
as code owners
July 17, 2026 07:02
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
Why
Window capture currently reuses
/tmp/cua-driver-rs-capture-{window_id}.png.Concurrent captures of the same window can therefore overwrite, read, or remove each other's files. Cleanup also happens only after a successful file read, so a failed
screencaptureinvocation or read can leave a partial file behind.A per-capture path removes the same-window collision, while RAII cleanup keeps failure paths from leaking temporary files.
Relation to #2104
This PR is intentionally separate from #2104.
#2104 adds display-asleep diagnostics and surfaces screenshot failures. This PR does not add or duplicate
screenshot_error, text diagnostics, display-state detection, or action-result changes. It only hardens the temporary-file lifecycle used by window capture.After #2104 is rebased onto current
main, the changes remain complementary: its diagnostics run inside capture failure branches, while this PR ensures the associated temporary file is unique and removed when those branches return.Test Plan
rustfmt --edition 2021 --check crates/platform-macos/src/capture.rscargo check -p platform-macoscargo test -p platform-macos— 134 passed, 0 failedgit diff --checkThe new tests deterministically verify unique paths and cleanup-on-drop without requiring Screen Recording permission or live TCC changes.
Caveats
cargo fmt -p platform-macos -- --checkcurrently reports pre-existing formatting drift in unrelated files, beginning withsrc/apps/mod.rs. The modifiedcapture.rspasses a targeted rustfmt check, and unrelated formatting was intentionally left out of this PR.mainand therefore requires rebasing independently of this PR.