Repository navigation
Conversation
GridCraft read files to open only from argv. Finder "Open With", double-click and `open -a GridCraft file.xlsx` deliver files through the application:openURLs: Apple Event on the NSApplicationDelegate instead, so macOS reported that GridCraft cannot open files in that format. winit 0.30 registers its own application delegate and panics if it is replaced. So the new crates/macos-open adds application:openURLs: to the class of winit's delegate at NSApplicationWillFinishLaunchingNotification, before AppKit delivers the launch documents. The app queues the paths, wakes egui, and drains the queue in raw_input_hook through the same open path as argv and drag-and-drop. No-op on other platforms. crates/macos-open does not inherit the workspace unsafe_code = "forbid", because Objective-C interop needs unsafe. It is the only crate that opts out. It keeps the no-panic clippy deny list. No new external crates: objc2, block2, objc2-foundation and objc2-app-kit were already in Cargo.lock. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
4 tasks done
Member
|
Thank you for this! macOS open-documents support has since landed via #164 ( If you haven't already, come join us on the ArtCraft Discord: https://discord.gg/artcraft |
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.
Same fix as the WordCraft PR: storytold/wordcraft#33
Problem
On macOS, Finder "Open With" and double-click on a
.xlsxshow "GridCraft cannot open files in the … format".open -a GridCraft file.xlsxalso opens nothing. File > Open and drag-and-drop work.Cause
GridCraft reads files to open only from argv. Finder and
opensend files through theapplication:openURLs:Apple Event on the NSApplicationDelegate. Nothing handled that method.Approach
crates/macos-open(gridcraft-macos-open). It addsapplication:openURLs:to the class of winit's own delegate withclass_addMethod. It does this atNSApplicationWillFinishLaunchingNotification: the delegate exists, and AppKit has not yet delivered the launch documents.EventLoop::newand panics if it is replaced:tried to get a delegate that was not the one Winit has registered. Its doc comment that says otherwise is stale.apps/gridcraftinstalls the handler beforeeframe::run_native. The handler queues the paths and requests a repaint.raw_input_hookdrains the queue throughopen_path, the same path as argv and drag-and-drop.objc2,block2,objc2-foundationandobjc2-app-kitwere already inCargo.lock. The lockfile diff adds only the new workspace package and one dependency edge.xtask/src/layers.rsclassifiesmacos-openas L6.Testing
cargo fmt --all --check,cargo clippy --workspace --all-targets -- -D warnings,cargo xtask layers,cargo build --release -p gridcraft: pass.cargo xtask ci: fmt, clippy, test, assets and layers pass. The wasm step did not run locally (nowasm32target installed). The new crate has only macOS-target dependencies and is not a wasm crate.open -aon an.xlsxlaunched the app with that workbook open. Confirmed through the JSON control channel.open -aon a second file opened it in the running app. Confirmed through the control channel.Notes
crates/macos-opendoes not inherit the workspaceunsafe_code = "forbid", because Objective-C interop needsunsafe. It is the only crate that opts out. It keeps the no-panic clippydenylist. AGENTS.md / CLAUDE.md may want to record this exception.installis a no-op and the app does not depend on the crate.🤖 Generated with Claude Code