From 924689fa947d4a13d11a4f06abce2f465f8505fa Mon Sep 17 00:00:00 2001 From: Bob Date: Thu, 9 Apr 2026 21:42:05 +0000 Subject: [PATCH 1/3] feat(bundle): use tauri-native resources + dynamic bundle path detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Draft exploration of Tauri-native module bundling instead of build_app_tauri.sh. **tauri.conf.json**: Add `bundle.resources` to include pre-built Python watcher modules in `Contents/Resources/modules/` during `tauri build`. Paths assume the repo is used as a submodule inside activitywatch (`../../dist/activitywatch/`). **dirs.rs** (macOS): Replace hardcoded `/Applications/ActivityWatch.app/...` paths with dynamic detection via `current_exe()`. The new logic: 1. Gets the executable path (Contents/MacOS/aw-tauri) 2. Walks up to Contents/Resources 3. Adds Resources/modules/ (for tauri-native layout) and Resources/ (legacy compat) This fixes discovery for any install location — not just /Applications. ### Trade-offs vs build_app_tauri.sh - Gains: standard Tauri tooling, dynamic resource path, auto-generated Info.plist - Unchanged: Python.framework signing complexity (PyInstaller issue, not bundler issue) - Still needed: activitywatch Makefile/CI changes to run `cargo tauri build` instead of `build_app_tauri.sh` — see ActivityWatch/activitywatch for the CI side This is a draft for evaluation — the CI integration is not yet done. --- src-tauri/src/dirs.rs | 24 ++++++++++++++++++------ src-tauri/tauri.conf.json | 9 ++++++++- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src-tauri/src/dirs.rs b/src-tauri/src/dirs.rs index f5de9b5..09bf6ec 100644 --- a/src-tauri/src/dirs.rs +++ b/src-tauri/src/dirs.rs @@ -177,12 +177,24 @@ pub fn get_discovery_paths() -> Vec { if let Ok(home_dir) = std::env::var("HOME") { discovery_paths.push(PathBuf::from(home_dir).join("aw-modules")); } - discovery_paths.push(PathBuf::from( - "/Applications/ActivityWatch.app/Contents/MacOS", - )); - discovery_paths.push(PathBuf::from( - "/Applications/ActivityWatch.app/Contents/Resources", - )); + // Detect if running inside a .app bundle dynamically via the executable path. + // This replaces the previous hardcoded /Applications/ActivityWatch.app paths, + // which broke for non-standard install locations (e.g. ~/Downloads, CI artifacts). + // + // Structure: Contents/MacOS/aw-tauri -> go up two levels -> Contents/Resources + if let Ok(exe_path) = std::env::current_exe() { + if let Some(contents_dir) = exe_path.parent().and_then(|p| p.parent()) { + let resources_dir = contents_dir.join("Resources"); + if resources_dir.exists() { + // Running inside a macOS .app bundle. + // Modules bundled via tauri.conf.json `bundle.resources` land in Resources/modules/. + discovery_paths.push(resources_dir.join("modules")); + // Also include Resources/ directly for compatibility with modules placed + // at the root (e.g. legacy build_app_tauri.sh layout). + discovery_paths.push(resources_dir.clone()); + } + } + } } #[cfg(target_os = "android")] diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index fa866a4..72e9ae4 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -18,6 +18,13 @@ "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico" - ] + ], + "resources": { + "../../dist/activitywatch/aw-server-rust": "modules/aw-server-rust", + "../../dist/activitywatch/aw-watcher-afk": "modules/aw-watcher-afk", + "../../dist/activitywatch/aw-watcher-window": "modules/aw-watcher-window", + "../../dist/activitywatch/aw-watcher-input": "modules/aw-watcher-input", + "../../dist/activitywatch/aw-notify": "modules/aw-notify" + } } } From 1dbc66b9e198265f19f6f5c5ddf01c218ccfd6be Mon Sep 17 00:00:00 2001 From: Bob Date: Thu, 9 Apr 2026 22:03:10 +0000 Subject: [PATCH 2/3] fix(bundle): remove static resources from tauri.conf.json The hardcoded ../../dist/activitywatch/* paths broke standalone aw-tauri CI since they only exist when aw-tauri is used as a submodule inside activitywatch. Instead, the activitywatch build system should inject resources at build time: cargo tauri build --config '{"bundle":{"resources":{...}}}' This keeps aw-tauri self-contained and CI-friendly. The dirs.rs dynamic discovery change is independently valuable and unaffected. Addresses ErikBjare's review: 'Maybe these should be conditionally added?' --- src-tauri/tauri.conf.json | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 72e9ae4..fa866a4 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -18,13 +18,6 @@ "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico" - ], - "resources": { - "../../dist/activitywatch/aw-server-rust": "modules/aw-server-rust", - "../../dist/activitywatch/aw-watcher-afk": "modules/aw-watcher-afk", - "../../dist/activitywatch/aw-watcher-window": "modules/aw-watcher-window", - "../../dist/activitywatch/aw-watcher-input": "modules/aw-watcher-input", - "../../dist/activitywatch/aw-notify": "modules/aw-notify" - } + ] } } From faa6c6e76d8863886a63d1b69a4457473e8bd3cc Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 30 Jun 2026 13:30:25 +0000 Subject: [PATCH 3/3] fix: remove unnecessary .clone() on resources_dir (Greptile P2) --- src-tauri/src/dirs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-tauri/src/dirs.rs b/src-tauri/src/dirs.rs index 09bf6ec..60a9a5c 100644 --- a/src-tauri/src/dirs.rs +++ b/src-tauri/src/dirs.rs @@ -191,7 +191,7 @@ pub fn get_discovery_paths() -> Vec { discovery_paths.push(resources_dir.join("modules")); // Also include Resources/ directly for compatibility with modules placed // at the root (e.g. legacy build_app_tauri.sh layout). - discovery_paths.push(resources_dir.clone()); + discovery_paths.push(resources_dir); } } }