Skip to content

Add runtime file association handling and standalone association prompt for .log and .lo_ files - #6

Merged
adamgell merged 4 commits into
mainfrom
copilot/add-logic-associate-log-files
Mar 14, 2026
Merged

Add runtime file association handling and standalone association prompt for .log and .lo_ files#6
adamgell merged 4 commits into
mainfrom
copilot/add-logic-associate-log-files

Conversation

Copilot AI commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

tauri.conf.json already 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 — added initial_file_path: Mutex<Option<String>> and an explicit new(initial_file_path) constructor so the path is available before the Tauri runtime starts
  • lib.rs — reads CLI args before building the Tauri app; first non-flag positional arg is treated as the file path and stored in AppState
    fn get_initial_file_path_from_args() -> Option<String> {
        std::env::args().skip(1).find(|arg| !arg.starts_with('-'))
    }
  • file_ops.rs — new get_initial_file_path command that takes and clears the stored path (consumed once)
  • src/hooks/use-file-association.ts — new hook that calls get_initial_file_path on mount and routes the path through loadPathAsLogSource, the same flow used by drag-and-drop
  • AppShell.tsx — calls useFileAssociation() alongside the existing startup hooks
  • src-tauri/src/commands/file_association.rs — new Windows-oriented backend command module to:
    • report whether the standalone association prompt should be shown
    • associate .log and .lo_ with the current executable for the current Windows user
    • persist a Don't Ask Again preference in the app config directory
  • src/lib/commands.ts — added frontend wrappers for file-association prompt status, association, and prompt suppression
  • src/hooks/use-file-association-prompt.ts — new startup hook that checks whether the standalone association prompt should be shown
  • src/components/dialogs/FileAssociationPromptDialog.tsx — new CMTrace-style prompt dialog with Associate, Ask Later, and Don't Ask Again
  • src/stores/ui-store.ts / src/hooks/use-keyboard.ts — integrated the new prompt into existing modal state and keyboard dialog-blocking behavior
  • src-tauri/Cargo.toml — added the Windows-only winreg dependency for per-user registry-based file association

Validation

  • npm ci
  • ./node_modules/.bin/tsc --noEmit
  • rustfmt --edition 2021 --check --config skip_children=true src/commands/file_association.rs src/lib.rs src/commands/mod.rs

Full cargo check remains blocked in this Linux sandbox because Tauri's GTK/WebKit system libraries are unavailable here.

Screenshot

File association prompt


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

Copilot AI changed the title [WIP] Add logic to associate .log files with CMTrace Open Add runtime file association handling for .log and .lo_ files Mar 13, 2026
Copilot AI requested a review from adamgell March 13, 2026 12:44
@adamgell

Copy link
Copy Markdown
Owner

@copilot I want the standalone exe to ask if the user wants to associate. like the old school cmtrace.exe.

Copilot AI commented Mar 13, 2026

Copy link
Copy Markdown
Contributor Author

@copilot I want the standalone exe to ask if the user wants to associate. like the old school cmtrace.exe.

Implemented in e530c62. The standalone app now shows a CMTrace-style startup prompt with Associate, Ask Later, and Don't Ask Again, and the Windows backend can register .log/.lo_ for the current user while keeping the existing open-associated-file flow working. Screenshot: https://github.com/user-attachments/assets/539e4c36-03ca-45f0-9e1c-892e366dc54b

Copilot AI changed the title Add runtime file association handling for .log and .lo_ files Add runtime file association handling and standalone association prompt for .log and .lo_ files Mar 13, 2026
Copilot AI and others added 3 commits March 13, 2026 20:37
Co-authored-by: adamgell <27519+adamgell@users.noreply.github.com>
Co-authored-by: adamgell <27519+adamgell@users.noreply.github.com>
@adamgell
adamgell force-pushed the copilot/add-logic-associate-log-files branch from e9dc014 to 8203a49 Compare March 14, 2026 00:41
@adamgell
adamgell marked this pull request as ready for review March 14, 2026 00:53
Copilot AI review requested due to automatic review settings March 14, 2026 00:53
@adamgell
adamgell merged commit b90ba33 into main Mar 14, 2026
1 of 2 checks passed

Copilot AI 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.

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-time get_initial_file_path command, 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.

Comment on lines +35 to +42
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())
Comment thread src-tauri/Cargo.toml
tokio = { version = "1", features = ["fs", "io-util", "sync", "rt"] }

[target.'cfg(target_os = "windows")'.dependencies]
winreg = "0.52"
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.

3 participants