Skip to content

fix(windows): resolve file association and single-instance file opening (closes #248) - #250

Open
Enotkiller wants to merge 1 commit into
petertzy:mainfrom
Enotkiller:fix/windows-file-opening
Open

fix(windows): resolve file association and single-instance file opening (closes #248)#250
Enotkiller wants to merge 1 commit into
petertzy:mainfrom
Enotkiller:fix/windows-file-opening

Conversation

@Enotkiller

Copy link
Copy Markdown

The root cause of the Windows file association bug was a combination of missing platform-specific handling and a frontend race condition. By default, Tauri's file open event only works on macOS. On Windows, double-clicking an associated file passes the path as a standard CLI argument, but we weren't capturing it during the app's setup phase, so cold starts just dropped the file. Furthermore, if the app was already running, Windows would try to launch a whole new instance because we lacked single-instance handling. Even if the paths did make it through, Windows formats them with quotes and backslashes, which broke the frontend's file validation regex. To make matters worse, the frontend hook was trying to fetch and load these pending files immediately on mount, before the Python backend had actually finished starting up, resulting in a silent failure.

To fix all this, I added manual CLI argument parsing in the Tauri setup phase to catch files on cold starts, and integrated tauri-plugin-single-instance to intercept hot starts, route the file to the already running app, and bring the window into focus. I also wrote a path normalization helper in Rust (along with unit tests) to clean up quotes and convert backslashes to forward slashes before sending anything over IPC. On the frontend side, I updated useFileIO to wait until the backend status is explicitly marked as ready before trying to fetch and open the files. Finally, I tweaked the dev scripts to correctly forward CLI arguments so we can easily test this behavior locally. Resolves #248.

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.

Fix opening Markdown files directly in the editor on Windows Tauri builds

1 participant