refactor(memory): route Obsidian deep link through workspace-link layer (#2492)
Summary
- New Tauri command
resolve_workspace_absolute_pathexposes the workspace-link resolver introduced in #2476 so renderers can derive canonical absolute paths through the same guard asopen_workspace_path/reveal_workspace_path/preview_workspace_text. - New TS wrapper
resolveWorkspaceAbsolutePathinutils/tauriCommands/workspacePaths.ts. ObsidianVaultSectionnow resolves the vault's absolute path through that wrapper before building theobsidian://open?path=<abs>URL, replacing the last Memory-tab surface that was constructing the deep link straight from a graph-export RPC field.- User-visible behavior is unchanged — click still opens Obsidian to the vault, same toast copy — but the absolute path is now derived from the Rust-side resolver, not from a prop fed by RPC.
Problem
Issue #2492 (Phase 3 cleanup of #1402) requires every Memory surface that constructs an on-disk path to compose with the shared workspace-link layer rather than hand-rolling its own resolution.
MemoryGraph was migrated in PR #2638. The remaining offender was ObsidianVaultSection, which built obsidian://open?path=${encodeURIComponent(contentRootAbs)} directly from the content_root_abs field returned by memory_tree_obsidian_vault_status — no canonicalize, no workspace-containment recheck, no shared error surface. Acceptance criterion from the issue:
Obsidian behavior is preserved intentionally — Obsidian launch remains available where it is a user-facing feature, but it is composed with the shared workspace-link layer rather than replacing it.
Solution
Three layers, kept thin:
- Rust (
app/src-tauri/src/workspace_paths.rs): newresolve_workspace_absolute_path#[tauri::command]that wraps the existing internalresolve_workspace_pathhelper (same canonicalize + workspace-containment + non-leaky error surface as the other three commands). Registered inlib.rsand added to theallow-workspace-filespermission manifest. Two new unit tests cover the happy-path (memory_tree/contentresolves inside the workspace root) and the empty-input rejection; the existing resolver test suite already covers absolute-path /../ URI-scheme / symlink escapes. - TypeScript (
app/src/utils/tauriCommands/workspacePaths.ts):resolveWorkspaceAbsolutePath(path)wrapper mirroring the style of the other workspace wrappers (assertTauri guard + plaininvoke<string>). - Component (
app/src/components/intelligence/ObsidianVaultSection.tsx):fireDeepLinknowawaitsresolveWorkspaceAbsolutePath('memory_tree/content')and builds the URL from the returned absolute path. ThecontentRootAbsprop is preserved for display (button tooltip, guidance-panel code block, toast message text) so no cascading prop changes are needed — only the deep-link URL is rerouted.
Tests
Updated ObsidianVaultSection.test.tsx:
- Mock the new wrapper in the existing
workspacePathsmock block. - New test: deep link URL is composed from the resolver output (not from
contentRootAbs). - New test: resolver rejection surfaces an error toast and keeps the guidance panel expanded.
- All 7 existing tests still pass (9 total).
Updated MemoryWorkspace.test.tsx:
- Mock
resolveWorkspaceAbsolutePathto return the same path the assertion expects so the existing'View vault in Obsidian' triggers the deep linktest stays stable. All 20 tests pass.
Submission Checklist
- [x] Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy
- [x] Diff coverage ≥ 80% — every new line is exercised by the two new Vitest cases plus the existing happy-path test (now stricter via the resolver-call assertion) and the two new Rust unit tests. Resolver internals already covered by the prior
resolve_workspace_path_*test suite. - [x] N/A: Coverage matrix update — this is a behaviour-preserving refactor of an existing matrix entry, not an added/removed/renamed feature row.
- [x] N/A: No new feature IDs from the matrix affected.
- [x] No new external network dependencies introduced (mock backend used per Testing Strategy)
- [x] N/A: Manual smoke checklist — no release-cut surface touched; deep-link UX is unchanged from the user's point of view.
- [x] Linked issue closed via
Closes #2492in the## Relatedsection.
Impact
- Runtime/platform: desktop only (
#[tauri::command]lives in the Tauri shell; iOS client does not hit this code path). No change to JSON-RPC surface. - Security: net positive — the Obsidian deep link now goes through the same workspace-containment guard as the other workspace commands, so a malicious
content_root_absvalue from the RPC (or a future scenario where the field is user-influenced) can no longer slip out of the workspace. - Migration / compatibility: none; the URL shape is identical.
Related
- Closes #2492
- Builds on #2476 (workspace-link layer) and #2638 (MemoryGraph migration)
- Follow-up PR(s)/TODOs: none — this is the final Memory-tab surface called out in #2492.
AI Authored PR Metadata (required for Codex/Linear PRs)
Linear Issue
- Key: N/A (GitHub issue only)
- URL: https://github.com/tinyhumansai/openhuman/issues/2492
Commit & Branch
- Branch:
fix/2492-memory-workspace-link-migration - Commit SHA:
3682a02d(tip),910d8097,8ff810ba
Validation Run
- [x]
pnpm --filter openhuman-app format:check— equivalent:pnpm exec prettier --checkon changed files, clean. - [x]
pnpm typecheck— ranpnpm exec tsc --noEmitinsideapp/, clean. - [x] Focused tests:
pnpm debug unit ObsidianVaultSection→ 9 passed;pnpm debug unit MemoryWorkspace→ 20 passed. - [x] Rust fmt/check (if changed):
cargo fmt --manifest-path app/src-tauri/Cargo.toml --checkclean;GGML_NATIVE=OFF cargo check --manifest-path app/src-tauri/Cargo.toml --libclean (GGML_NATIVE=OFFis the documented macOS Tahoe + whisper-rs workaround). - [x] Tauri fmt/check (if changed): same as above.
Validation Blocked
command:n/a — all validation passed.error:n/aimpact:n/a
Behavior Changes
- Intended behavior change: deep-link absolute path is now derived from the workspace-link resolver instead of trusted RPC output.
- User-visible effect: none. Same click, same Obsidian URL shape, same toast copy. The vault path printed in the guidance panel / toast still comes from
contentRootAbs(RPC) because it is a display concern.
Parity Contract
- Legacy behavior preserved: the
obsidian://open?path=<abs>URL shape is byte-for-byte unchanged when the resolver returns the same path the RPC reports (normal case).MemoryWorkspace.test.tsx's existing assertion proves it. - Guard/fallback/dispatch parity checks: resolver failure now surfaces an error toast and keeps the guidance panel expanded — covered by a new test. Existing
detection failure degrades gracefully to the guidance paneltest still passes.
Duplicate / Superseded PR Handling
- Duplicate PR(s): none
- Canonical PR: this
- Resolution: n/a
Summary by CodeRabbit
-
New Features
- Added a workspace-path resolver that returns canonical absolute paths for constructing vault deep links.
-
Bug Fixes
- Deep-link generation now uses resolved canonical workspace paths; on resolution failure it surfaces an error and does not attempt a fallback.
-
Tests
- Added/updated tests for path resolution success, failure, canonicalization, and deep-link behavior.
-
Chores
- Updated runtime permissions to allow workspace-path resolution.
[!NOTE]
Reviews paused
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
reviews.auto_review.auto_pause_after_reviewed_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
- [ ] ▶️ Resume reviews
- [ ] 🔍 Trigger review
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9cbf5908-6e62-471e-89f8-0cfd17d46033
📥 Commits
Reviewing files that changed from the base of the PR and between a56c7f784a6ae2c18c8a22254d7d5d559b15e8d4 and b3288b3e3a5e8872778932336493047314c8cb3a.
📒 Files selected for processing (2)
app/src-tauri/src/workspace_paths.rsapp/src/components/intelligence/ObsidianVaultSection.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- app/src-tauri/src/workspace_paths.rs
📝 Walkthrough
Walkthrough
This PR adds a new Tauri command resolve_workspace_absolute_path to canonicalize workspace-relative paths and uses it in ObsidianVaultSection to construct Obsidian deep links with normalized paths instead of relying on the contentRootAbs prop directly.
Changes
Workspace Absolute Path Resolver
| Layer / File(s) | Summary |
|---|---|
Rust command implementation and permissions app/src-tauri/permissions/allow-workspace-files.toml, app/src-tauri/src/workspace_paths.rs, app/src-tauri/src/lib.rs |
Permission config allows resolve_workspace_absolute_path command. New Rust command loads workspace root, resolves input path via existing helpers, logs the mapping, and returns canonical absolute path. Tauri handler registration exposes it to IPC. Unit tests assert canonical path return and empty-input rejection. |
TypeScript Tauri command wrapper app/src/utils/tauriCommands/workspacePaths.ts, app/src/utils/tauriCommands/workspacePaths.test.ts |
New exported resolveWorkspaceAbsolutePath function asserts Tauri runtime and invokes the Rust-side command, returning the resolved absolute path string. Tests cover success, invoke rejection propagation, and non-Tauri early rejection. |
Obsidian deep-link resolution and tests app/src/components/intelligence/ObsidianVaultSection.tsx, app/src/components/intelligence/__tests__/MemoryWorkspace.test.tsx, app/src/components/intelligence/__tests__/ObsidianVaultSection.test.tsx |
ObsidianVaultSection now resolves MEMORY_CONTENT_WORKSPACE_PATH via the new command before constructing obsidian://open?path=... URLs. Tests mock the resolver and verify resolver invocation, correct deep-link URL composition, and error handling (error toast, no openUrl call, guidance panel visible on failure). |
Sequence Diagram
sequenceDiagram
participant User
participant ObsidianVaultSection
participant resolveWorkspaceAbsolutePath
participant resolve_workspace_absolute_path
participant ObsidianApp as openUrl
User->>ObsidianVaultSection: click deep-link
ObsidianVaultSection->>resolveWorkspaceAbsolutePath: resolve(MEMORY_CONTENT_WORKSPACE_PATH)
resolveWorkspaceAbsolutePath->>resolve_workspace_absolute_path: invoke
resolve_workspace_absolute_path-->>resolveWorkspaceAbsolutePath: canonical absolute path
ObsidianVaultSection->>ObsidianApp: openUrl("obsidian://open?path="+resolvedPath)
ObsidianApp-->>User: open vault
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related issues
- tinyhumansai/openhuman#1402: Matches the workspace-link Tauri command surface and frontend integration for canonicalizing workspace paths.
Possibly related PRs
- tinyhumansai/openhuman#2476: Extends the same
workspace_pathsIPC surface;#2476added open/reveal/preview commands that this PR builds upon.
Suggested labels
memory
Suggested reviewers
- graycyrus
- senamakel
Poem
🐰 I hop from path to path, precise and neat,
Canonical crumbs beneath my feet.
Deep links now find vaults with ease,
Tests nod in chorus, errors appease—
A rabbit's cheer for tidy trees.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The pull request title accurately describes the main change: routing Obsidian deep-link URL composition through a shared workspace-link resolver instead of direct RPC usage, with reference to the related issue (#2492). |
| Docstring Coverage | ✅ Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
[!WARNING] There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.
🔧 ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add
eslintto devDependencies.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
Addressed CodeRabbit feedback in cffa53a5 + a8a11f6f:
- Coverage Gate: added Vitest cases for
resolveWorkspaceAbsolutePathinapp/src/utils/tauriCommands/workspacePaths.test.tscovering the happy-path invoke call, aninvokerejection bubbling back to the caller, and theisTauri()guard short-circuiting beforeinvokeis touched. That brings the new wrapper lines (workspacePaths.ts:56-58) under test. - PII log nit: routed the
resolve_workspace_absolute_pathdebug log through the existingworkspace_path_label(workspace, target)helper instead oftarget.display(), matching the redaction pattern the other workspace-path commands already use so the canonical absolute workspace root no longer leaks into logs.
Local verification: cargo fmt --check, cargo check --lib (Tauri shell), prettier --check, pnpm debug unit workspacePaths (12 passed), pnpm typecheck — all green.
@YOMXXX unresolved review feedback — please address before we review.
Unresolved review feedback from coderabbitai[bot] — please address before we review.