Skip to content

macOS: open presentations from Finder (double-click, Open With, Dock) - #1028

Open
eskimoburger wants to merge 1 commit into
storytold:mainfrom
eskimoburger:macos-open-documents
Open

eskimoburger wants to merge 1 commit into
storytold:mainfrom
eskimoburger:macos-open-documents

Conversation

@eskimoburger

@eskimoburger eskimoburger commented Oct 19, 2026 •

Copy link
Copy Markdown

Problem

On macOS (0.8.0 DMG), double-clicking a .pptx in Finder, using Open With, dropping a file on the Dock icon, or running open -a DeckCraft talk.pptx launches DeckCraft on File › Home with nothing open. DeckCraft also isn't offered in Finder's Open With list for presentations.

Two causes:

  1. packaging/macos/Info.plist.in declares the UTIs (UTExportedTypeDeclarations / UTImportedTypeDeclarations) but no CFBundleDocumentTypes, so LaunchServices doesn't know DeckCraft can open them.
  2. Finder doesn't pass paths on the command line. It sends a kAEOpenDocuments ('odoc') Apple event, which winit 0.30 doesn't handle. Only open --args file.pptx worked.

WordCraft and GridCraft already handle both; DeckCraft was missing them.

Fix

  • Info.plist.in: add CFBundleDocumentTypes: .deckcraft (Owner) and the Open XML presentation, template and slideshow types (Alternate, as WordCraft does for .docx).
  • apps/deckcraft/src/apple_events.rs (new): register an NSAppleEventManager handler through fmv-macos-events = "=0.1.0", the same crate and pattern as apps/wordcraft/src/apple_events.rs. It's installed before the event loop, so it also catches the event that launched the app, and the frame loop drains it. No unsafe in this workspace.
  • Opened paths go through SlideApp::open_from_system, the same path the command-line files take, so a .ppsx given last still starts its slide show. Failures are logged and shown in the status bar. A quit Apple event closes the window, so the unsaved-changes prompt still runs.
  • The new dependency is macOS-only.

Testing (macOS 27, Apple silicon)

  • I built cargo build --release -p deckcraft, put the binary and rendered Info.plist into the 0.8.0 app bundle (ad-hoc signed) and registered it with lsregister.
  • Launch: open -a DeckCraft deck.pptx with the app not running. The deck opens; before the fix it stayed on Home.
  • While running: open -a DeckCraft other.pptx opens the second deck. Both appear in the Recent list.
  • cargo fmt --all -- --check and cargo clippy -p deckcraft --all-targets -- -D warnings are clean.
  • In cargo test -p deckcraft, 32 tests pass and control_server::tests::a_line_that_is_not_a_request_closes_the_connection fails. It fails the same way on unmodified main on this machine, so this change didn't cause it.
  • I didn't run the full cargo xtask ci because it expects the sibling craftrules / craft-fonts checkouts.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • On macOS, DeckCraft can open .deckcraft presentations and supported PowerPoint files from Finder.
    • macOS quit events now close DeckCraft.

A Finder double-click, Open With or `open -a DeckCraft talk.pptx` brought
the app up on File > Home with nothing open, and DeckCraft wasn't offered
for presentations at all:

- Info.plist had no CFBundleDocumentTypes, so LaunchServices didn't know
  DeckCraft opens .deckcraft, .pptx, .potx or .ppsx.
- Finder doesn't pass paths on the command line; it sends a
  kAEOpenDocuments Apple event, which winit 0.30 doesn't handle.

Declare the document types (Owner for .deckcraft, Alternate for the Open
XML presentation types) and handle the Apple event with fmv-macos-events,
the crate WordCraft already uses for the same thing (no unsafe here).
Opened paths go through open_from_system, so a .ppsx still starts its
slide show and failures land in the log and the status bar.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 76c9e06d-fc19-475f-b7bc-802d47194a3e
📥 Commits

Reviewing files that changed from the base of the PR and between 010941e and e90d367.

⛔ Files ignored due to path filters: 1
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing: 4
  • apps/deckcraft/Cargo.toml
  • apps/deckcraft/src/apple_events.rs
  • apps/deckcraft/src/main.rs
  • packaging/macos/Info.plist.in

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

DeckCraft now registers macOS document types and handles Finder open-document and quit events. The app connects an Apple Events inbox to its event loop and processes queued events.

Changes: macOS Apple Events

Layer / File(s) Summary
Register and connect macOS events
apps/deckcraft/Cargo.toml, packaging/macos/Info.plist.in, apps/deckcraft/src/apple_events.rs, apps/deckcraft/src/main.rs
The macOS target adds the pinned fmv-macos-events dependency. The bundle declares DeckCraft’s native presentation type and PowerPoint document types. The app installs the Apple Events handler and connects its inbox to the app.
Poll and process events
apps/deckcraft/src/apple_events.rs, apps/deckcraft/src/main.rs
The app polls queued events. It passes UTF-8 paths from open events to SlideApp::open_from_system, displays and logs returned errors, and sends a viewport-close command for quit events.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Finder
  participant AppleEvents
  participant Inbox
  participant App
  participant SlideApp
  Finder->>AppleEvents: Deliver open or quit event
  AppleEvents->>Inbox: Queue event
  App->>Inbox: Poll events
  App->>SlideApp: Open UTF-8 paths
  SlideApp-->>App: Return open errors
  App->>App: Display errors or close viewport
Loading

Suggested reviewers: echelon

Merge Risk: ⚪ Minimal · up to e90d3

Finder document opening preserves the existing presentation-opening behavior, and no actionable merge-blocking risk remains after normal checks.

Security architecture risk: 🔵 Low · up to e90d3

Finder-delivered presentations now reach the existing file-opening workflow, and quit requests retain the unsaved-changes check. No privilege increase or direct overwrite bypass was identified. Some platform-event delivery and input-handling guarantees remain unverified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The evidenced direct scope is the local DeckCraft process: accepted document paths reach file reading, presentation parsing, session-document creation and the application-global font database. The new handler itself requests opens and window closure, not elevation or saving. Required privileges for an arbitrary event sender remain unverified.

Trust Boundaries and Controls

  • observed — The new adapter crosses from OS-delivered document events into application file opening. It adds no sender or path authorization check beyond UTF-8 conversion, but it also does not bypass the existing opening consumer. The base command-line route already passed supplied paths to that same consumer. Dependency-level sender and decoding controls are not established by the available source.

Resilience and Maintainability Implications

  • observed — Apple Quit requests issue a normal viewport Close command. Existing presentation logic cancels closure when documents are dirty and invokes the quit dialog; cancellation leaves quit confirmation unset. Open events processed before that check do not replace existing dirty documents. Native concurrent-delivery and pending-close timing were not runtime-validated.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. (2 skipped: 2… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarizes the main change: enabling macOS presentations to open from Finder through double-click, Open With, and the Dock.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@FredApps FredApps left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read the diff against WordCraft's apple_events.rs and Info.plist.in (the pattern this copies), the engine's open path, and the new dependency. I can't run macOS or cargo here, so this is by my reading, and the Finder behaviour itself rests on the author's own run (macOS 27, open -a with the app closed and running).

Verified:

  • The dependency. fmv-macos-events 0.1.0 is pinned exactly (=0.1.0) and macOS-only. I downloaded the .crate from crates.io: its SHA-256 is 90642cf6…23fe55, the checksum in the lock hunk, and WordCraft's lock has the same entry (same objc2 0.6.5, objc2-app-kit 0.3.2, objc2-foundation 0.3.2, which are already in this lock under those versions, so the lock adds only the one package). It is MIT OR Apache-2.0 and its unsafe stays inside the crate, so #![forbid(unsafe_code)] still holds for the app.
  • The module. apple_events.rs is WordCraft's line for line except the handler: it goes through SlideApp::open_from_system, the function the command-line files use, so the .ppsx-starts-the-show rule is shared. The session is multi-document and file.open adds a document, so a Finder open while another deck has unsaved changes doesn't replace it; Quit becomes a window close, which keeps the existing unsaved-changes prompt (lib.rs:1576).
  • Wiring. The handler is installed before run_native, so it sees the launch event; the inbox is drained in logic and wakes the context for later events. The tuple field and the test constructor are cfg-gated consistently, so other platforms compile the same as before.
  • The plist. The exported UTI ai.storyteller.deckcraft.presentation matches the new LSItemContentTypes; the icon name DeckCraft matches what package.sh copies into the bundle (DeckCraft.icns); .deckcraft is Owner and the Open XML types are Alternate, as WordCraft does for .docx. The engine opens pptx, potx and ppsx, so all three listed types can be handled.
  • DeckCraft has no translation catalogs (every other set_status is a plain English format!), so the new "Couldn't open …" status needs no catalog rows.

Two things I can't confirm from here (neither blocks):

  1. Info.plist.in imports only org.openxmlformats.presentationml.presentation, but the second document type also names .template and .slideshow. If macOS doesn't declare those two itself (it may depend on Office being installed), LaunchServices ignores them and DeckCraft isn't offered for .potx/.ppsx. WordCraft does the same for .dotx, so this matches the suite, but a quick check of Open With on a .ppsx on a Mac without Office would tell.
  2. The description says control_server::tests::a_line_that_is_not_a_request_closes_the_connection fails on unmodified main on the author's machine. That may be machine-specific, but it needs a clean run on another host before this lands.

This stays a comment: no CI has run on this head, and I have no macOS result for it.

Validation request (head e90d3676590ec26ff7cc20a79821816d2c33da47):

  • os: macos (apple silicon), and linux and windows for the build
  • commands: cargo fmt --all -- --check; cargo clippy --workspace --all-targets --locked -- -D warnings; cargo test -p deckcraft --locked; package the app and run open -a DeckCraft deck.pptx with the app closed and running, a double-click and Open With on .pptx, .ppsx, .potx and .deckcraft, a drop on the Dock icon, and Quit from the Dock with unsaved changes
  • expected: all pass, 0 ignored (including a_line_that_is_not_a_request_closes_the_connection); each file opens, a .ppsx starts its show, quit asks about unsaved changes
  • holds: no macOS receipt for this head; the control_server test result on a second host

@aiongg aiongg added the bugfix Fixes something that is broken: wrong result, crash, data loss label Nov 4, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes something that is broken: wrong result, crash, data loss

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants