Skip to content

Add window snapshotting - #213

Merged
cmsj merged 2 commits into
mainfrom
hs.window-snapshot
Sep 9, 2026
Merged

cmsj merged 2 commits into
mainfrom
hs.window-snapshot

Conversation

@cmsj

@cmsj cmsj commented Sep 9, 2026

Copy link
Copy Markdown
Owner

No description provided.

@cmsj cmsj self-assigned this Sep 9, 2026
@greptile-apps

greptile-apps Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds asynchronous window snapshotting to the JavaScript-facing hs.window API.

  • Captures windows through ScreenCaptureKit and resolves snapshots as HSImage values.
  • Supports optional transparency preservation.
  • Exposes both instance-level snapshot() and module-level snapshotForID() APIs.
  • Validates IDs with an exact CGWindowID conversion, fixing the previously reported oversized-ID crash.
  • Updates generated API metadata and TypeScript declarations.

Confidence Score: 5/5

The PR appears safe to merge, with the previously reported oversized-ID crash fully fixed and no new actionable issues found.

Both snapshot entry points now use a failable exact conversion before invoking ScreenCaptureKit, so integers outside the valid UInt32 window-ID range reject their promises rather than trapping, while all valid window IDs remain accepted.

Important Files Changed

Filename Overview
Hammerspoon 2/Modules/hs.window/HSWindow.swift Implements ScreenCaptureKit-based window capture and safely rejects invalid instance window IDs.
Hammerspoon 2/Modules/hs.window/HSWindowModule.swift Adds the module-level snapshot API with exact integer-to-window-ID validation.
docs/api.json Records the new snapshot APIs in generated API metadata.
docs/hammerspoon.d.ts Adds TypeScript declarations for both window snapshot entry points.

Reviews (2): Last reviewed commit: "Prevent window snapshots from crashing t..." | Re-trigger Greptile

Comment thread Hammerspoon 2/Modules/hs.window/HSWindowModule.swift Outdated
@cmsj

cmsj commented Sep 9, 2026

Copy link
Copy Markdown
Owner Author

@greptile

@cmsj
cmsj merged commit 1a3b150 into main Sep 9, 2026
4 checks passed
@cmsj
cmsj deleted the hs.window-snapshot branch September 10, 2026 08:48
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