Skip to content

vcli-capture: Capture trait + macOS ScreenCaptureKit + MockCapture + Windows stub - #7

Merged
blaksmatic merged 13 commits into
masterfrom
implement/plan-2-vcli-capture
Apr 17, 2026
Merged

blaksmatic merged 13 commits into
masterfrom
implement/plan-2-vcli-capture

Conversation

@blaksmatic

Copy link
Copy Markdown
Owner

Summary

  • Implements the vcli-capture crate (plan §v0 scope) across 10 commits covering all 12 plan tasks
  • Capture trait + WindowDescriptor + DisplayId scaffold with full # Errors/# Panics docs
  • CaptureError taxonomy with stable code() strings (permission_denied, unknown_window, capture_failed, unsupported)
  • MockCapture with cycling frame sequences, per-window frame maps, and single-shot armed error injection — Send + Sync, tested via dyn Capture
  • TCC permission probe via CGPreflightScreenCaptureAccess / CGRequestScreenCaptureAccess FFI + CoreGraphics framework link
  • BGRA physical→logical converter: pass-through at 1x, 2:1 box-filter downsample at 2x; 6 pure unit tests
  • MacCapture (ScreenCaptureKit v1.5.4) — enumerate_windows, grab_screen, grab_window; 2 TCC-gated #[ignore] smoke tests
  • WindowsCapture stub returning CaptureError::Unsupported for all methods
  • capture_once example binary for manual TCC/SCK verification
  • Workspace clippy (-D warnings) + cargo fmt clean

Deviations from plan

Plan assumption Actual / fix
screencapturekit = "0.3" Used v1.5.4 (only published version); adapted all APIs
CGDisplayScaleFactor for Retina scale Removed (not in macOS 26 SDK); SCK returns logical px directly, scale=1.0
cgimage.bgra_bytes() Used rgba_data() (RGBA); Frame.format set to Rgba8
util::has_permission() Replaced with direct CoreGraphics FFI
@rpath/libswift_Concurrency.dylib missing on macOS 26 Added build.rs rpath pointing to Xcode swift-5.5/macosx; ObjC duplication warnings appear but tests pass

Test plan

  • cargo test -p vcli-capture — 26 unit tests pass, 2 integration tests ignored
  • cargo clippy --workspace --all-targets -- -D warnings — clean
  • cargo fmt --all -- --check — clean
  • cargo test --workspace --locked — clean
  • Manual: cargo run --example capture_once on a macOS machine with TCC permission granted

🤖 Generated with Claude Code

blaksmatic and others added 13 commits April 17, 2026 07:43
Plan deviation: screencapturekit = "1.5.4" used (plan said "0.3" which does
not exist on crates.io; latest compatible major version chosen instead).
Stub files for permission.rs, mock.rs, macos/, windows/ included to allow
compilation; filled out in subsequent tasks.
Plan deviation: screencapturekit v1.5.4 has no util::has_permission.
Used extern "C" links to CGPreflightScreenCaptureAccess /
CGRequestScreenCaptureAccess from CoreGraphics framework directly (via
build.rs rustc-link-lib). Changed #![forbid(unsafe_code)] to
#![deny(unsafe_code)] + #[allow(unsafe_code)] on permission module to
permit the two extern "C" call sites.
Plan deviation: screencapturekit v1.5.4 API differs from plan's v0.3 assumptions.
Key adaptations:
- SCContentFilter::create() builder pattern (not direct ctor)
- CGRect has flat fields .x/.y/.width/.height (not .origin.x/.size.width)
- application_name() returns String directly
- window_id() returns u32, converted to u64 via From<u32>
- CGDisplayScaleFactor via extern "C" (no display.scale_factor() method)
- build.rs adds rpath to Xcode swift-5.5/macosx for libswift_Concurrency.dylib
  (macOS 26 moved this dylib out of the dyld cache path screencapturekit expects)
- assign_window_indices() extracted as pub(crate) for unit testing
Also: refine MacCapture to remove CGDisplayScaleFactor (not in macOS 26 SDK).
SCDisplay.width()/height() already report logical pixels, so scale=1.0 is correct.
Fix mock.rs unused-import warnings by moving Rect/WindowIndex/DisplayId to
the test submodule where they are used. Fix rpath for libswift_Concurrency.dylib
(macOS 26 moved it; added Xcode swift-5.5/macosx to rpath in build.rs).
All clippy::pedantic warnings resolved, cargo fmt applied, dyn
Capture roundtrip test added to MockCapture test suite.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…li-capture

# Conflicts:
#	Cargo.lock
#	Cargo.toml
The module-level `use std::env;` was unused on non-macOS targets
because `env::args()` is only called from the macOS `run()` function.
Under `-D warnings` on Ubuntu this failed the build.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…li-capture

# Conflicts:
#	Cargo.lock
#	Cargo.toml
@blaksmatic
blaksmatic merged commit 8cf676d into master Apr 17, 2026
4 checks passed
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.

1 participant