Add runtime file association handling and standalone association prompt for .log and .lo_ files - #6
Conversation
|
@copilot I want the standalone exe to ask if the user wants to associate. like the old school cmtrace.exe. |
Implemented in |
Co-authored-by: adamgell <27519+adamgell@users.noreply.github.com>
Co-authored-by: adamgell <27519+adamgell@users.noreply.github.com>
e9dc014 to
8203a49
Compare
There was a problem hiding this comment.
Pull request overview
Adds runtime handling for .log / .lo_ OS file associations (opening an associated file passes a path via CLI args) and introduces a Windows-only “CMTrace-style” prompt to optionally associate those extensions with the standalone executable.
Changes:
- Capture the initial CLI file path in Rust
AppState, expose it via a one-timeget_initial_file_pathcommand, and open it on the frontend during startup. - Add a Windows-only backend command module to detect/perform per-user file association and persist a “Don’t ask again” preference.
- Integrate a new startup prompt dialog into existing UI modal state and keyboard dialog-blocking.
Reviewed changes
Copilot reviewed 14 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/stores/ui-store.ts | Adds UI state + actions for the new association prompt modal. |
| src/lib/commands.ts | Adds frontend invoke wrappers for initial-file-path + association/prompt APIs. |
| src/hooks/use-keyboard.ts | Treats the association prompt as a modal for shortcut blocking. |
| src/hooks/use-file-association.ts | Startup hook to consume initial CLI path and open it via existing log-source flow. |
| src/hooks/use-file-association-prompt.ts | Startup hook to decide whether to show the association prompt. |
| src/components/layout/AppShell.tsx | Wires in the new hooks and dialog into app startup/layout. |
| src/components/dialogs/FileAssociationPromptDialog.tsx | Implements the CMTrace-style association prompt UI and actions. |
| src-tauri/src/state/app_state.rs | Adds initial_file_path storage and explicit constructor to AppState. |
| src-tauri/src/lib.rs | Parses CLI args before Tauri starts; registers new commands; manages AppState::new. |
| src-tauri/src/commands/mod.rs | Exposes new file_association command module. |
| src-tauri/src/commands/file_ops.rs | Adds get_initial_file_path tauri command to consume the stored CLI path. |
| src-tauri/src/commands/file_association.rs | Windows-only registry association logic + prompt suppression persistence. |
| src-tauri/Cargo.toml | Adds Windows-only winreg dependency. |
| src-tauri/Cargo.lock | Locks new Windows dependency graph for winreg and transitive crates. |
| scripts/Launch-CMTraceOpen.ps1 | Adds -OpenPath support and forwards the path into dev/build launch flows. |
| package-lock.json | Updates lockfile metadata (platform libc fields removed). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (event.key === "Escape" && !isSubmitting) { | ||
| onClose(); | ||
| } | ||
| }; | ||
|
|
||
| window.addEventListener("keydown", handleKey); | ||
| return () => window.removeEventListener("keydown", handleKey); | ||
| }, [isOpen, isSubmitting, onClose]); |
| } | ||
|
|
||
| let content = fs::read_to_string(&path).map_err(|e| e.to_string())?; | ||
| serde_json::from_str(&content).map_err(|e| e.to_string()) |
| tokio = { version = "1", features = ["fs", "io-util", "sync", "rt"] } | ||
|
|
||
| [target.'cfg(target_os = "windows")'.dependencies] | ||
| winreg = "0.52" |
tauri.conf.jsonalready registers.log/.lo_file associations for the installer, but the app had no runtime handler for the file path the OS passes as a CLI argument when a user opens a file via association (double-click, "Open with", etc.). This update also adds a classic CMTrace-style prompt for the standalone Windows executable so users can choose whether to associate log files with CMTrace Open.Changes
AppState— addedinitial_file_path: Mutex<Option<String>>and an explicitnew(initial_file_path)constructor so the path is available before the Tauri runtime startslib.rs— reads CLI args before building the Tauri app; first non-flag positional arg is treated as the file path and stored inAppStatefile_ops.rs— newget_initial_file_pathcommand that takes and clears the stored path (consumed once)src/hooks/use-file-association.ts— new hook that callsget_initial_file_pathon mount and routes the path throughloadPathAsLogSource, the same flow used by drag-and-dropAppShell.tsx— callsuseFileAssociation()alongside the existing startup hookssrc-tauri/src/commands/file_association.rs— new Windows-oriented backend command module to:.logand.lo_with the current executable for the current Windows userDon't Ask Againpreference in the app config directorysrc/lib/commands.ts— added frontend wrappers for file-association prompt status, association, and prompt suppressionsrc/hooks/use-file-association-prompt.ts— new startup hook that checks whether the standalone association prompt should be shownsrc/components/dialogs/FileAssociationPromptDialog.tsx— new CMTrace-style prompt dialog withAssociate,Ask Later, andDon't Ask Againsrc/stores/ui-store.ts/src/hooks/use-keyboard.ts— integrated the new prompt into existing modal state and keyboard dialog-blocking behaviorsrc-tauri/Cargo.toml— added the Windows-onlywinregdependency for per-user registry-based file associationValidation
npm ci./node_modules/.bin/tsc --noEmitrustfmt --edition 2021 --check --config skip_children=true src/commands/file_association.rs src/lib.rs src/commands/mod.rsFull
cargo checkremains blocked in this Linux sandbox because Tauri's GTK/WebKit system libraries are unavailable here.Screenshot
📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.