Skip to content

fix(files): fail files.open for a missing path instead of opening a ghost tab#8850

Closed
xianjianlf2 wants to merge 1 commit into
stablyai:mainfrom
xianjianlf2:fix/file-open-missing-path-8844
Closed

fix(files): fail files.open for a missing path instead of opening a ghost tab#8850
xianjianlf2 wants to merge 1 commit into
stablyai:mainfrom
xianjianlf2:fix/file-open-missing-path-8844

Conversation

@xianjianlf2

Copy link
Copy Markdown
Contributor

Summary

Fixes #8844.

orca file open <path> reported ok: true / opened: true with exit code 0 even when the resolved file does not exist. A ghost editor tab was created, and the failure only surfaced later inside the editor as an fs:readFile … ENOENT card. Agents driving the CLI treated the result as success.

Fix

openMobileFile (the files.open handler) now stats the resolved path before opening:

  • Local worktrees: stat on the joined path.
  • SSH worktrees: the target's SSH filesystem provider (provider.stat), mirroring how files.resolveTerminalPath already probes existence remotely.
  • Missing paths and directories fail with a stable file_not_found error code (added to the RPC passthrough allowlist), a nonzero exit, and no tab.
  • Genuine not-found is distinguished from transport/permission failures — a dropped remote session still surfaces as an error instead of reading as "file missing".

file open-changed is unaffected: it already skips deleted entries before calling files.open.

Testing

  • New tests: local ENOENT → file_not_found + no open; directory target → file_not_found; SSH remote not-found → file_not_found; existing open tests updated to stat a real file.
  • vitest run src/main/runtime/orca-runtime-files.test.ts src/main/runtime/rpc/methods/files.test.ts src/cli/handlers/file.test.ts — 121 tests pass.
  • npm run typecheck — no new findings.

🤖 Generated with Claude Code

…host tab

`orca file open` returned ok:true / opened:true / exit 0 for a path
that resolves to a non-existent file, creating a tab that only failed at
render time with an ENOENT card. Callers that trust the exit code or
JSON (agents driving the CLI) were misled into thinking the open
succeeded (stablyai#8844).

Stat the resolved path — via the SSH filesystem provider for remote
worktrees, plain stat for local ones — before opening. Missing paths
and directories now fail with a stable `file_not_found` code (added to
the RPC passthrough allowlist) and no tab is created. Transport or
permission failures still propagate as errors rather than reading as
"file missing", and `file open-changed` is unaffected because it
already skips deleted entries before calling files.open.

Fixes stablyai#8844

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 3293b69c-a41f-4f10-ac0e-39e2da5e2c83

📥 Commits

Reviewing files that changed from the base of the PR and between 9e2c63e and 4e16268.

📒 Files selected for processing (3)
  • src/main/runtime/orca-runtime-files.test.ts
  • src/main/runtime/orca-runtime-files.ts
  • src/main/runtime/rpc/errors.ts

📝 Walkthrough

Walkthrough

openMobileFile now verifies that the resolved local or SSH target exists and is a file before calling host.openFile. Missing files and directories produce file_not_found, while other errors are rethrown. The runtime error passthrough allowlist includes file_not_found. Tests cover successful text and image opens, local missing files, directories, and remote SSH missing files.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers summary and testing, but omits required Screenshots, AI Review Report, Security Audit, and Notes sections. Add the missing template sections, or state "No visual change" for screenshots and include the AI review, security audit, and notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the core fix: files.open now fails on missing paths instead of creating a ghost tab.
Linked Issues check ✅ Passed The change validates resolved paths before opening, returns file_not_found, and prevents ghost tabs, matching #8844's requirements.
Out of Scope Changes check ✅ Passed The touched code and new tests are directly related to file-open existence checks and error mapping, with no obvious unrelated edits.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker

Copy link
Copy Markdown
Contributor

Thanks for the early fix and for adding a stable file_not_found path plus directory rejection.

Merged #9006 instead: same fail-before-tab outcome for local and SSH missing paths, reuses resolveAuthorizedPath + existing remote not-found helpers (local stat(filePath) without authorization is a regression risk), and has green required verify.

Closing as a duplicate for #8844. Appreciate the solid first cut.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: orca file open reports ok:true / exit 0 for a path that resolves to a non-existent file (creates a ghost tab)

3 participants