Repository navigation
Conversation
|
| if (!existsSync(dbPath)) { | ||
| return [] | ||
| } |
There was a problem hiding this comment.
Unreadable store appears missing
If the database exists but its parent directory cannot be searched, existsSync can return false. This returns an empty list before the read can report the access failure. The binder then skips that round without a warning, making unbound OpenCode sessions harder to diagnose.
Knowledge Base Used: Agent integrations and hooks
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (1)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 0001f188c376d1a725ce9309f502dc2c55324121 and 5e1aaef. 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe OpenCode session binder now checks whether the database exists before attempting to read it. Tests verify that repeated reads of a missing database produce no warnings, that the binder reads the database if it appears later, and that an existing unreadable database still produces a warning. Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🔵 Low · up to Permission-related database failures may be treated as absence, suppressing warnings. Session listing remains safe, but diagnostics may be lost. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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.
✅ No new issues found.
Reviewed changes
- Missing store is now silent —
listOpenCodeDbSessionsreturns[]before the read-only open whenexistsSync(dbPath)is false, so a host that has never run OpenCode no longer emits a warning stack trace every binder round. - Real read failures still warn — the existing
catchis untouched, so an existing-but-unreadable database keeps itsconsole.warn. - Tests pin both directions — one test asserts two consecutive missing-DB reads stay quiet and detection resumes once the file appears; a second asserts an invalid SQLite file still warns exactly once.
I ran npx vitest run src/main/agent-hooks/server-opencode-binder.test.ts (14 passed) and confirmed the new quiet-path test fails with the guard removed (2 warns), so it is a genuine regression test rather than a passing-by-construction one. The approach matches the issue's stated contract (quiet while absent, detect on appearance, warn on genuine failure) and reuses the existing fail-open contract.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 3ac2bc2b-5995-46ee-8393-82a4aacf0509
📥 Commits
Reviewing files that changed from the base of the PR and between 5c59a2d and 0001f188c376d1a725ce9309f502dc2c55324121.
📒 Files selected for processing (2)
src/main/agent-hooks/server-opencode-binder.test.tssrc/main/opencode/opencode-session-binder.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| if (!existsSync(dbPath)) { | ||
| return [] |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
git diff 5c59a2dfec9c5f935a4a38e5fbb03324150f707c 0001f188c376d1a725ce9309f502dc2c55324121 -- src/main/opencode/opencode-session-binder.ts src/main/agent-hooks/server-opencode-binder.test.ts
sed -n '190,290p' src/main/opencode/opencode-session-binder.ts
rg -n '"engines"|"node"|"electron"|listOpenCodeDbSessions' package.json src/main/opencode/opencode-session-binder.tsRepository: stablyai/orca
Length of output: 6445
🌐 Web query:
Official Node.js v24 documentation for fs.existsSync and fs.statSync throwIfNoEntry false behavior, including how filesystem errors are handled
💡 Result:
The official **Node.js v24.20.0** docs say:
- **`fs.existsSync(path)`** returns `true` if the path exists and `false` otherwise. It has no `throwIfNoEntry` option. The docs do not specify in this entry how individual filesystem errors are mapped to the boolean result. ([nodejs.org](https://nodejs.org/download/release/v24.20.0/docs/api/fs.html))
- **`fs.statSync(path[, options])`** defaults `throwIfNoEntry` to `true`. Set it to `false` to return `undefined` when the entry does not exist; otherwise, `statSync` returns an `fs.Stats` object. ([nodejs.org](https://nodejs.org/download/release/v24.20.0/docs/api/fs.html))
- **Other filesystem errors:** The option is specifically about a missing entry; the docs do not say it suppresses other filesystem errors. Treat `throwIfNoEntry: false` as handling the missing-entry case, not as a general “ignore errors” switch. For synchronous calls, catch errors that may still be thrown. The docs’ error-code note is stated for asynchronous `stat()`, not explicitly for `statSync()`. ([nodejs.org](https://nodejs.org/download/release/v24.20.0/docs/api/fs.html))
```js
const stats = fs.statSync(path, { throwIfNoEntry: false });
// stats is undefined if the entry is missing
```
The cited v24 docs establish that option’s behavior, but do not enumerate precisely which OS/filesystem errors count as “no entry.”
Citations:
- 1: https://nodejs.org/download/release/v24.20.0/docs/api/fs.html
- 2: https://nodejs.org/download/release/v24.20.0/docs/api/fs.html
- 3: https://nodejs.org/download/release/v24.20.0/docs/api/fs.html
🌐 Web query:
site:github.com/nodejs/node v24.0.0 src/node_file.cc existsSync err == 0 fs.existsSync implementation
💡 Result:
In **Node.js v24.0.0**, `fs.existsSync()` is a JavaScript wrapper in `lib/fs.js`: it validates the path, returns `false` if validation fails, then calls `binding.existsSync(path)`. ([github.com](https://github.com/nodejs/node/blob/v24.0.0/lib/fs.js))
The tagged `src/node_file.cc` source is present, but the GitHub-rendered page doesn’t expose a matching `existsSync` symbol or the `err == 0` check. So the wrapper behavior is established by the source; the specific C++ implementation detail isn’t confirmed by the available page. ([github.com](https://github.com/nodejs/node/blob/v24.0.0/src/node_file.cc))
Citations:
- 1: https://github.com/nodejs/node/blob/v24.0.0/lib/fs.js
- 2: https://github.com/nodejs/node/blob/v24.0.0/src/node_file.cc
🏁 Script executed:
set -o pipefail
curl -fsSL https://raw.githubusercontent.com/nodejs/node/v24.0.0/src/node_file.cc |
rg -n -C 10 'ExistsSync|existsSync|err == 0|uv_fs_stat' || true
curl -fsSL https://raw.githubusercontent.com/nodejs/node/v24.0.0/lib/fs.js |
rg -n -C 8 'function existsSync|existsSync' | head -80Repository: stablyai/orca
Length of output: 11816
Preserve warnings for filesystem inspection failures.
Node 24 maps any failed uv_fs_access call, including EACCES, to false in existsSync. Because this check is outside the try, an unreadable database bypasses the warning handler. The session result is already []; the material impact is lost diagnostics, not an additional session-discovery failure.
Use statSync inside the existing try. Return [] only when it returns undefined, and let other errors reach the warning handler.
Suggested fix
-import { existsSync } from 'node:fs'
+import { statSync } from 'node:fs'
...
- if (!existsSync(dbPath)) {
- return []
- }
try {
+ if (statSync(dbPath, { throwIfNoEntry: false }) === undefined) {
+ return []
+ }
return readOpenCodeDatabase({0001f18 to
5e1aaef
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Rebased onto current
main— the fix itself is unchanged:listOpenCodeDbSessionsreturns[]before the read-only open whenexistsSync(dbPath)is false, so a host that has never run OpenCode stays quiet. - Real read failures still warn — the
catchis untouched, so an existing-but-unreadable store still logs exactly once. - Tests realigned to the current store layout —
mainnow reads thesessiontable only, so the quiet-path test seedssessioninstead ofsession_v2. Both new tests (quiet-when-absent, warn-when-unreadable) remain and I reran the suite locally (16 passed).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Superseded by merged #24577. The original missing-store fix is credited to @drakeo338 in that PR and its commits. Real hidden-app before/after validation confirms absent stores are quiet; permission and corrupt-store failures still warn. Thank you for the original fix. |

ELI5
If OpenCode has never run, its database file does not exist yet, and Orca logged a warning about that on every session lookup. Now it stays quiet until the file appears.
What Changed
listOpenCodeDbSessionsopened the database even when the file was missing, so the open threw and the catch warned on every binder round. It now returns an empty list when the file does not exist; real read failures still warn.Why
A missing store is an expected state, not an error.
Linked Issue
Fixes #23926.
Visual Proof
N/A, no UI change; only a log warning is removed.
Testing
The new test fails without the fix and passes with it. Unticked boxes were not run by me.
AI Disclosure
Written with Claude (Anthropic) via Claude Code.
Review
Two reviews found no blockers.
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
No security, cross-platform, SSH or performance impact.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)