feat(bundle): use tauri-native resources + dynamic bundle path detection#213
Conversation
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.
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?'
|
Update the description to note 1dbc66b |
|
Done — updated the description to note commit 1dbc66b and explain the new approach (build-time injection vs static resources in ). |
|
@TimeToBuildBob Do we still need this? |
|
Good timing on the ping, Erik. Short answer: the The tauri-native bundling direction (replacing So: can land the |
|
Promoted to ready for review. This PR now only contains the Why this should land: the hardcoded What this does NOT gate on: the larger question of replacing |
Greptile SummaryThis PR replaces the hardcoded
Confidence Score: 5/5Safe to merge — the dynamic path detection correctly handles standard .app bundles, macOS app translocation, and non-bundle invocations without introducing any regressions. The change is narrow and well-guarded: No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[get_discovery_paths macOS] --> B[Push ~/aw-modules]
B --> C{current_exe ok?}
C -- No --> Z[Return paths]
C -- Yes --> D[exe: Contents/MacOS/aw-tauri]
D --> E[parent: Contents/MacOS]
E --> F[parent.parent: Contents]
F --> G[resources_dir: Contents/Resources]
G --> H{resources_dir exists?}
H -- No --> Z
H -- Yes --> I[Push resources_dir/modules]
I --> J[Push resources_dir]
J --> Z
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[get_discovery_paths macOS] --> B[Push ~/aw-modules]
B --> C{current_exe ok?}
C -- No --> Z[Return paths]
C -- Yes --> D[exe: Contents/MacOS/aw-tauri]
D --> E[parent: Contents/MacOS]
E --> F[parent.parent: Contents]
F --> G[resources_dir: Contents/Resources]
G --> H{resources_dir exists?}
H -- No --> Z
H -- Yes --> I[Push resources_dir/modules]
I --> J[Push resources_dir]
J --> Z
Reviews (2): Last reviewed commit: "fix: remove unnecessary .clone() on reso..." | Re-trigger Greptile |
TimeToBuildBob
left a comment
There was a problem hiding this comment.
Greptile P1: Contents/MacOS path drop — verified false positive
I verified against the actual build_app_tauri.sh at https://github.com/ActivityWatch/activitywatch/blob/master/scripts/package/build_app_tauri.sh:
mkdir -p "dist/${APP_NAME}.app/Contents/"{MacOS,Resources}
# aw-tauri goes to MacOS/
cp "dist/activitywatch/aw-tauri" "dist/${APP_NAME}.app/Contents/MacOS/aw-tauri"
# All modules go to Resources/<component_name>/
for component in dist/activitywatch/*/; do
if [ -d "$component" ]; then
component_name=$(basename "$component")
cp -r "$component"/* "dist/${APP_NAME}.app/Contents/Resources/$component_name/"
fi
doneKey findings:
Contents/MacOS/only contains theaw-tauriexecutable itself- All modules (aw-server-rust, aw-watcher-*, aw-notify) go to
Contents/Resources/<name>/ - The old hardcoded
Contents/MacOSpath was effectively dead code for module discovery — no module has ever been placed there
So dropping Contents/MacOS from the dynamic discovery paths is correct and safe. The Resources/ path my code adds covers the actual legacy layout, and Resources/modules/ covers the future Tauri-native layout.
No code change needed. This finding is resolved — confirmed false positive.
|
@greptileai review |
|
All checks have been completed:
Ready for merge. (I lack permissions on this repo.) |
Summary
Replace the hardcoded
/Applications/ActivityWatch.app/Contents/...discovery paths with runtime detection viacurrent_exe(), so module discovery works regardless of install location.Changes
dirs.rs— dynamic resource path detectionReplace the hardcoded
/Applications/ActivityWatch.app/Contents/...discovery paths with runtime detection viacurrent_exe():Why this matters: The old code only worked when installed at
/Applications/ActivityWatch.app. Users who move the app to~/Applications/or run from a downloaded DMG had no module discovery.tauri.conf.json— (reverted)The companion
bundle.resourcesconfig entries were removed in 1dbc66b to keep aw-tauri CI self-contained. The activitywatch build system injects resources at build time via--config.What was verified
build_app_tauri.shputs all modules inContents/Resources/<name>/;Contents/MacOS/only contains the aw-tauri binary.clone()): Fixed in faa6c6eGreptile Findings Status
.clone()