Repository navigation
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between c69b9e997680e9f4d630dcca7ebdb46c7208f553 and 9132871. 📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (6)
📝 WalkthroughWalkthroughIntroduces shared helpers for resolving OpenCode data and storage directories. Updates database discovery to resolve configured and scanned database paths from the shared data directory, including relative 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 23dcaf33-5346-4c70-a471-729799e37363
📥 Commits
Reviewing files that changed from the base of the PR and between 1bd36ce and 3864748a13c9e8fe592f7315f7db81a11c92339b.
📒 Files selected for processing (6)
src/main/ai-vault/session-scanner-opencode-sources.test.tssrc/main/ai-vault/session-scanner-opencode-sources.tssrc/main/opencode-usage/scanner.test.tssrc/main/opencode-usage/scanner.tssrc/main/opencode/opencode-data-directory.test.tssrc/main/opencode/opencode-data-directory.ts
|
reviewed and approved, please merge to master and release the fix. thanks |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 0aa0cdde-8ff3-46d3-857c-83161ddb9f2f
📥 Commits
Reviewing files that changed from the base of the PR and between 3864748a13c9e8fe592f7315f7db81a11c92339b and 065998fa5ad1f2b8baf40e28eee3258d7bd522e8.
📒 Files selected for processing (2)
src/main/opencode-usage/scanner.test.tssrc/main/opencode-usage/scanner.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/opencode-usage/scanner.test.ts
|
Taking a look! |
|
Review summary for b3322640c (CI: 22/22 jobs green):
Status: READY TO MERGE. |
Greptile SummaryThis PR centralizes OpenCode data-directory resolution into a new
Confidence Score: 5/5The change narrows a path-resolution inconsistency and fixes a real edge case where a directory passed as OPENCODE_DB would have reached SQLite; no regressions expected. All three callsites now use a single, well-tested helper. The existsSync → stat().isFile() replacement closes a real edge case without introducing new branches. The test suite covers all three platforms, both env-override paths, and an end-to-end Windows scenario. The intentional behavior change on Windows (dropping LOCALAPPDATA in favour of ~/.local/share) is documented and verified by integration tests. Files Needing Attention: No files require special attention; the new opencode-data-directory.ts and its callers are straightforward and well covered by tests.
|
| Filename | Overview |
|---|---|
| src/main/opencode/opencode-data-directory.ts | New module centralizing OpenCode data-directory resolution; uses XDG_DATA_HOME or ~/.local/share/opencode on all platforms; no logic issues found |
| src/main/opencode-usage/scanner.ts | Refactored to use shared resolveOpenCodeDataDirectory(); replaced synchronous existsSync with async stat().isFile() to correctly reject directories passed as OPENCODE_DB; differentiated :memory: from unconfigured states |
| src/main/ai-vault/session-scanner-opencode-sources.ts | Replaced module-level OPENCODE_STORAGE_DIR constant (evaluated at load time) with a call-time resolveOpenCodeStorageDirectory(); drops the incorrect OPENCODE_CONFIG_DIR fallback |
| src/main/opencode/opencode-data-directory.test.ts | Unit tests for the new directory-resolution module; covers XDG override, all three platforms, and storage sub-directory derivation |
| src/main/opencode-usage/scanner-windows-data-directory.test.ts | Integration test that fakes win32 platform and validates end-to-end DB discovery at ~/.local/share/opencode instead of AppData directories |
| src/main/opencode-usage/scanner.test.ts | Added two regression tests: :memory: override returns empty list, and a directory-as-OPENCODE_DB returns empty list |
| src/main/ai-vault/session-scanner-opencode-sources.test.ts | New test verifying that opencodeDiscoveries passes the correct XDG-derived storage directory to the discovery function |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[listOpenCodeDatabases / opencodeDiscoveries] --> B[resolveOpenCodeDataDirectory]
B --> C{XDG_DATA_HOME set?}
C -- yes --> D[join XDG_DATA_HOME opencode]
C -- no --> E[join homedir .local share opencode]
D --> F[dataDirectory]
E --> F
F --> G[getOpenCodeDatabaseOverride]
G --> H{OPENCODE_DB set?}
H -- not set --> I[readdir dataDirectory for opencode files]
H -- memory --> J[return empty]
H -- relative path --> K[join dataDirectory OPENCODE_DB]
H -- absolute path --> L[OPENCODE_DB as-is]
K --> M{stat isFile?}
L --> M
M -- yes --> N[return path]
M -- no or error --> J
Reviews (1): Last reviewed commit: "test(opencode): reproduce Windows sessio..." | Re-trigger Greptile
* fix(opencode): use cross-platform data directory * fix(opencode): honor in-memory database override * fix(opencode): harden database discovery coverage * test(opencode): reproduce Windows session discovery --------- Co-authored-by: OrcaWin <[email protected]> Co-authored-by: OrcaWin <[email protected]>
Summary
XDG_DATA_HOMEwhen set, otherwise~/.local/share/opencodeon every platform.OPENCODE_DBpaths rooted in the OpenCode data directory.Closes #10332
Screenshots
No visual change.
Testing
pnpm lintpnpm typecheckpnpm test(local full-suite run: 35,486 passed, 61 skipped, and 16 failures outside this change in PowerShell PTY, sparse-checkout, runtime-retirement, zsh lookup, and relay/SSH timing tests)pnpm buildTargeted regression tests: 18 passed across the OpenCode data-directory, Session History source, and usage scanner suites.
AI Review Report
Reviewed data-directory resolution, both scanner call sites, environment precedence, relative
OPENCODE_DBhandling, and regression coverage. Cross-platform review confirmed the fallback uses runtime path utilities and the home directory on macOS, Linux, and Windows; explicit WSL/SSH home discovery remains unchanged. No shortcut, label, shell, or Electron-specific behavior changed.Security Audit
Reviewed environment and path handling. Values are only used to locate local OpenCode data, with no command execution, IPC, auth, secret, dependency, or network changes. Existing filesystem error handling remains non-throwing; no follow-up is required.
Notes
%USERPROFILE%\.local\share\opencode, matching OpenCode.XDG_DATA_HOMEandOPENCODE_DBoverrides remain supported.ELI5
OpenCode data paths were wrong on some platforms. Orca now uses XDG_DATA_HOME or ~/.local/share/opencode everywhere so usage stats and session history find the real OpenCode database.