Skip to content

Open files and folders with the app via OS file associations#15

Merged
anbturki merged 1 commit into
mainfrom
feat/open-with-file-associations
Jul 11, 2026
Merged

Open files and folders with the app via OS file associations#15
anbturki merged 1 commit into
mainfrom
feat/open-with-file-associations

Conversation

@anbturki

Copy link
Copy Markdown
Owner

What

Adds OS-level "Open With DocsReader" for markdown files and folders:

  • Double-click a .md/.markdown/.mdx in Finder, or right-click > Open With > DocsReader
  • Set DocsReader as the default handler for markdown
  • Opening a folder adds it as a workspace root
  • Opening a file resolves it to its enclosing workspace (or its parent folder as an ad-hoc root) and opens it in the active pane

Works whether the app is already running (warm) or is launched by the open (cold).

How

  • bundle.fileAssociations in tauri.conf.json registers .md/.markdown/.mdx, generating the macOS CFBundleDocumentTypes / UTI declarations.
  • macOS: opens arrive as RunEvent::Opened { urls }. A buffer in Rust state (OpenedPaths) holds paths captured before the webview mounts, drained by the take_opened_paths command on cold start; warm opens are delivered via the open-path event.
  • Windows/Linux: tauri-plugin-single-instance folds a second launch into the running window and forwards the file path from argv.
  • Frontend: useOpenWith listens for open-path (and drains the cold-start buffer), then routes each target - folder to addRoot, file to its resolved root + openInActivePane. Handling is serialized so batched opens don't race on the shared root list.

Validation

Local, mirroring CI: tsc --noEmit, 116 frontend tests, vite build, cargo fmt --check, cargo clippy --workspace --all-targets -D warnings, cargo test --workspace - all green.

The OS-level LaunchServices registration and Apple Event delivery can only be exercised from a bundled/notarized build, so that path gets its real end-to-end test from the release artifact.

Register .md/.markdown/.mdx associations so DocsReader appears in
Finder's Open With menu and can be set as the default handler. Opened
targets route into the app: a folder becomes a workspace root, and a
file resolves to its enclosing workspace (or its parent folder as an
ad-hoc root) and opens in the active pane.

macOS delivers opens through RunEvent::Opened for both cold and warm
starts; Windows and Linux deliver them as argv via the single-instance
plugin, which also folds a second launch into the running window. A
buffer on the Rust side holds paths captured before the frontend mounts
so cold-start opens are not lost.
@anbturki anbturki merged commit 4474e4e into main Jul 11, 2026
3 checks passed
@anbturki anbturki deleted the feat/open-with-file-associations branch July 11, 2026 14:44
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