Handy/src-tauri/src
Shehab Tarek 10beb60d63
feat: add portable mode to NSIS installer (#807)
* ci: add temporary test workflow for portable ZIP validation

* ci: fix mock setup in test workflow

* ci: remove temporary test workflow

* feat: add portable mode option to NSIS installer

Custom NSIS template based on tauri-v2.9.1 upstream with 6 targeted
modifications for portable mode support:

- New PortableMode variable and /PORTABLE CLI flag for silent installs
- Install type selection page with Normal/Portable radio buttons
- Conditional default directory (Desktop for portable, LocalAppData for normal)
- Skip registry writes, file associations, deep links, and uninstaller for portable
- Skip Start Menu and desktop shortcuts for portable installs
- Create portable marker file and Data/ directory on portable install

The existing portable.rs runtime detection is unchanged — it looks for the
same marker file this installer creates.

Usage:
  GUI: select "Portable Installation" on the install type page
  Silent: Handy_setup.exe /S /PORTABLE /D=C:\path\to\Handy

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: implement true portable mode via source code path override

Detect a `portable` marker file next to the executable at startup.
When present, redirect all data paths (settings, models, recordings,
database, logs) to a local `Data/` directory instead of %APPDATA%.

This approach works because it intercepts path resolution at the Rust
level, bypassing Tauri/Windows Shell API limitations that made the
previous environment-variable and junction approaches unreliable.

Changes:
- Add src-tauri/src/portable.rs with OnceLock-based detection
- Replace all app.path().app_data_dir() calls with portable helper
- Configure tauri-plugin-log to use Folder target when portable
- Configure tauri-plugin-store with absolute path when portable
- Simplify build.yml portable ZIP (exe + resources + marker file)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: add missing Manager trait import in portable.rs

The .path() method on AppHandle requires `tauri::Manager` in scope.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: redirect WebView2 cache to portable Data dir

Move main window creation from tauri.conf.json to setup closure so
we can set data_directory when in portable mode. This prevents
WebView2 from creating %LOCALAPPDATA%\com.pais.handy.

Also set data_directory on the recording overlay window.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: auto-detect portable mode during updates

When the Tauri updater runs the installer with /UPDATE, the install type
page is skipped and /PORTABLE is not passed. Detect the existing portable
marker file in .onInit so updates preserve portable mode automatically.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* style: fix prettier formatting in portable.rs and lib.rs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: CJ Pais <cj@cjpais.com>
2026-03-06 12:07:11 +08:00
..
audio_toolkit drain audio (#838) 2026-02-19 10:32:30 +08:00
commands feat: add portable mode to NSIS installer (#807) 2026-03-06 12:07:11 +08:00
helpers WIP: Add tauri-specta for generating TS bindings (#322) 2025-11-27 17:07:22 +07:00
managers feat: add portable mode to NSIS installer (#807) 2026-03-06 12:07:11 +08:00
shortcut use blocking for handy keys (#881) 2026-02-23 11:18:47 +08:00
actions.rs feat: implement structured outputs for post-processing providers (#706) 2026-02-17 12:14:00 +08:00
apple_intelligence.rs feat: implement structured outputs for post-processing providers (#706) 2026-02-17 12:14:00 +08:00
audio_feedback.rs feat: add portable mode to NSIS installer (#807) 2026-03-06 12:07:11 +08:00
cli.rs feat: add CLI parameters for linux (#792) 2026-02-17 12:48:43 +08:00
clipboard.rs Add "external script" paste method (#638) 2026-02-19 17:07:16 +08:00
input.rs refactor enigo input (#441) 2025-12-12 16:33:49 +07:00
lib.rs feat: add portable mode to NSIS installer (#807) 2026-03-06 12:07:11 +08:00
llm_client.rs feat: implement structured outputs for post-processing providers (#706) 2026-02-17 12:14:00 +08:00
main.rs feat: add CLI parameters for linux (#792) 2026-02-17 12:48:43 +08:00
overlay.rs feat: add portable mode to NSIS installer (#807) 2026-03-06 12:07:11 +08:00
portable.rs feat: add portable mode to NSIS installer (#807) 2026-03-06 12:07:11 +08:00
settings.rs feat: add portable mode to NSIS installer (#807) 2026-03-06 12:07:11 +08:00
signal_handle.rs feat: add CLI parameters for linux (#792) 2026-02-17 12:48:43 +08:00
transcription_coordinator.rs fix: transcription lock-up race condition & add small debounce (#824) 2026-02-16 22:18:50 +08:00
tray.rs Add show tray icon setting (#667) 2026-02-10 10:39:35 +08:00
tray_i18n.rs fix(i18n): tray menu shows Simplified Chinese when Traditional Chinese is selected (#901) 2026-03-01 10:39:14 +07:00
utils.rs fix: transcription lock-up race condition & add small debounce (#824) 2026-02-16 22:18:50 +08:00