Skip to content

Commit 635390e

Browse files
feat: add path2 plugin for centralized path resolution with dev isolation (#2486)
# feat: add path2 plugin for centralized path resolution with dev isolation ## Summary This PR introduces a new `path2` plugin that centralizes path resolution logic for Hyprnote. The key behavior is dev environment isolation: in debug builds, the plugin returns `app_data_dir` (which resolves to `com.hyprnote.dev`), while in release builds it returns `data_dir/hyprnote` (shared across staging/nightly/stable). The plugin provides both Rust and TypeScript APIs: - Rust: `app.path2().base()` - TypeScript: `import { commands } from "@hypr/plugin-path2"; commands.base()` Also cleans up orphaned `@hypr/plugin-db` references from `packages/tiptap` and `packages/utils`. ## Review & Testing Checklist for Human - [ ] **Verify `cfg!(debug_assertions)` is the correct mechanism for dev detection** - This is a compile-time check, meaning the path logic is baked in at build time. Confirm this matches the intended behavior (staging/nightly/stable builds should all use release mode). - [ ] **Check that `@hypr/plugin-db` removal doesn't break anything** - The PR removes this dependency from `packages/tiptap/package.json` and `packages/utils/package.json`. Verify no code in these packages actually imports from `@hypr/plugin-db`. - [ ] **Review the `create_dir_all` side effect in `base()`** - The function creates the directory if it doesn't exist. Confirm this is acceptable behavior for a path resolution function. - [ ] **Test the plugin in the running desktop app** - Run `ONBOARDING=0 pnpm -F desktop tauri dev` and verify the path resolution works correctly. Check that data is written to the expected location. ### Notes - Link to Devin run: https://app.devin.ai/sessions/6893a63da49c44f28ee5e560ebcd4b15 - Requested by: yujonglee (@yujonglee)
1 parent c7cd402 commit 635390e

File tree

23 files changed

+679
-131
lines changed

23 files changed

+679
-131
lines changed

Cargo.lock

Lines changed: 23 additions & 129 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ tauri-plugin-local-stt = { path = "plugins/local-stt" }
138138
tauri-plugin-misc = { path = "plugins/misc" }
139139
tauri-plugin-network = { path = "plugins/network" }
140140
tauri-plugin-notification = { path = "plugins/notification" }
141+
tauri-plugin-path2 = { path = "plugins/path2" }
141142
tauri-plugin-pdf = { path = "plugins/pdf" }
142143
tauri-plugin-permissions = { path = "plugins/permissions" }
143144
tauri-plugin-settings = { path = "plugins/settings" }

apps/desktop/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"@hypr/plugin-misc": "workspace:*",
4949
"@hypr/plugin-network": "workspace:*",
5050
"@hypr/plugin-notification": "workspace:*",
51+
"@hypr/plugin-path2": "workspace:*",
5152
"@hypr/plugin-pdf": "workspace:*",
5253
"@hypr/plugin-permissions": "workspace:*",
5354
"@hypr/plugin-settings": "workspace:*",

apps/desktop/src-tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ tauri-plugin-network = { workspace = true }
4949
tauri-plugin-notification = { workspace = true }
5050
tauri-plugin-opener = { workspace = true }
5151
tauri-plugin-os = { workspace = true }
52+
tauri-plugin-path2 = { workspace = true }
5253
tauri-plugin-pdf = { workspace = true }
5354
tauri-plugin-permissions = { workspace = true }
5455
tauri-plugin-prevent-default = { workspace = true }

apps/desktop/src-tauri/capabilities/default.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@
158158
"permissions:default",
159159
"settings:default",
160160
"sfx:default",
161+
"path2:default",
161162
"pdf:default",
162163
"autostart:default",
163164
{

apps/desktop/src-tauri/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ pub async fn main() {
7777
.plugin(tauri_plugin_export::init())
7878
.plugin(tauri_plugin_os::init())
7979
.plugin(tauri_plugin_fs::init())
80+
.plugin(tauri_plugin_path2::init())
8081
.plugin(tauri_plugin_pdf::init())
8182
.plugin(tauri_plugin_process::init())
8283
.plugin(tauri_plugin_misc::init())

packages/tiptap/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"@codemirror/state": "^6.5.2",
2121
"@codemirror/view": "^6.39.4",
2222
"@floating-ui/dom": "^1.7.4",
23-
"@hypr/plugin-db": "workspace:^",
2423
"@hypr/ui": "workspace:^",
2524
"@remixicon/react": "^4.7.0",
2625
"@tanstack/react-query": "^5.90.12",

packages/utils/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"dependencies": {
77
"@ai-sdk/openai-compatible": "^1.0.29",
88
"@date-fns/tz": "^1.4.1",
9-
"@hypr/plugin-db": "workspace:^",
109
"@hypr/plugin-listener": "workspace:^",
1110
"@hypr/plugin-windows": "workspace:^",
1211
"@tauri-apps/api": "^2.9.1",

plugins/path2/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

plugins/path2/Cargo.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[package]
2+
name = "tauri-plugin-path2"
3+
version = "0.1.0"
4+
authors = ["You"]
5+
edition = "2024"
6+
exclude = ["/js", "/node_modules"]
7+
links = "tauri-plugin-path2"
8+
description = ""
9+
10+
[build-dependencies]
11+
tauri-plugin = { workspace = true, features = ["build"] }
12+
13+
[dev-dependencies]
14+
specta-typescript = { workspace = true }
15+
tokio = { workspace = true, features = ["macros"] }
16+
17+
[dependencies]
18+
tauri = { workspace = true, features = ["test"] }
19+
tauri-specta = { workspace = true, features = ["derive", "typescript"] }
20+
21+
serde = { workspace = true }
22+
specta = { workspace = true }
23+
24+
thiserror = { workspace = true }

0 commit comments

Comments
 (0)