Skip to content

fix(terminal): complete OMP stale cwd recovery - #17154

Merged
nwparker merged 1 commit into
stablyai:mainfrom
nwparker:nwparker/fix-omp-stale-cwd-gaps
Aug 29, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
nwparker:nwparker/fix-omp-stale-cwd-gaps

Conversation

@nwparker

@nwparker nwparker commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

An Orca terminal can keep standing in an old folder object after the project path is deleted and recreated. The prompt still shows the familiar path, but OMP cannot determine its current directory and exits before doing any work.

Orca now checks the shell's real directory before every wrapped OMP command. If the path was replaced, OMP runs from the live replacement in a temporary subshell; the user's parent shell stays untouched. If only a logical symlink disappeared but the physical directory is still usable, Orca leaves it alone.

What Changed

  • Run stale-cwd validation and recovery for every wrapped POSIX OMP invocation, including commands such as omp --version that intentionally skip the status extension.
  • Reject cached pwd -P output unless the path still exists and names the shell's current directory.
  • Preserve a usable physical cwd when PWD is unset or names a removed logical symlink.
  • Expand real Bash/Zsh PTY coverage and regenerate the byte-identical local, daemon/SSH, and relay wrapper fixtures.

Why

The original recovery in #17128 left two real failure modes: extension-skipping commands bypassed recovery, and shell builtins could report a cached deleted path as though the cwd were usable. A narrow cwd predicate plus a recovery subshell closes those gaps without changing OMP argv, extension selection, exit status, or parent-shell state.

Linked Issue

Fixes #16457

Follow-up to #17128.

Visual Proof

N/A — this changes terminal cwd/process behavior, not product layout or visual design. The real rendered terminal flow is covered under Testing.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • Dedicated Orca Electron instance attached to this branch:

    • real omp/18.0.10 --version exited 0 from a replaced cwd while the parent shell remained on the stale inode
    • real OMP exited 0 after the logical symlink was removed while the physical cwd remained usable
    • stale cwd + unset PWD + no workspace/root fallback showed the actionable Orca error and returned 1 without starting OMP
    • visible terminal output and the main-owned PTY buffer snapshot agreed
  • 10 focused test files: 151/151 tests passed.

  • Bash 3.2 and Zsh 5.9 real-PTY wrapper tests: 20/20 passed.

  • All six generated local/daemon/relay Bash/Zsh fixtures passed native syntax checks; the shared wrapper passed ShellCheck.

  • pnpm tc:node

  • pnpm run check:code-quality:changed

  • pnpm run check:max-lines-ratchet

  • pnpm run check:reliability-gates

  • Full macOS, Windows, shell-contract, typecheck, static-analysis, and eight-shard test coverage is enforced by PR CI.

AI Disclosure

Review

  • Reliability invariant: terminal-session.startup-cwd-missing-dir-recovery — recovery may rebind only the child OMP invocation; parent cwd/PWD, argv, extension behavior, and exit status remain authoritative.
  • Oracle: real Bash/Zsh PTYs cover usable physical cwd authority, replaced inodes with set/unset PWD, skipped and extension-enabled argv, nonzero status propagation, parent-shell isolation, and visible failure without invocation when no recovery path exists.
  • Performance: every wrapped OMP launch adds only a bounded group of shell filesystem predicates; a short subshell is created only after an unusable cwd is detected. No polling, retry, listener, timer, provider scan, render work, or extra OMP subprocess was added.
  • Compatibility: no persisted state, protocol/wire payload, mobile-facing surface, dependency, or native PowerShell behavior changed. The POSIX wrapper executes on its owning local/daemon/SSH/relay host, and generated fixtures pin all six Bash/Zsh variants to the same source.
  • Readiness verdict: no P0/P1/P2 candidate finding remains after fixes and verification. Findings-severity counsel is skipped as required when the candidate list is empty.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Residual execution gaps are explicit in the experimental reliability gate: no live Linux/WSL or SSH/relay stale-inode journey was run. Those topologies consume the same execution-host POSIX wrapper pinned by generated-file snapshots. Native Windows/PowerShell does not use this cwd predicate.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@greptile-apps

greptile-apps Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Greptile Summary

The PR completes POSIX OMP stale-working-directory recovery while preserving the parent shell’s state.

  • Applies cwd validation and recovery to every wrapped OMP invocation, including extension-skipping commands.
  • Validates cached physical cwd output before treating it as usable.
  • Adds real Bash and Zsh PTY coverage for replaced directories, removed logical symlinks, unset PWD, fallback failure, argv preservation, and exit-status propagation.
  • Regenerates matching local, daemon/SSH, and relay wrapper fixtures and updates the reliability gate.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/main/pty/omp-shell-wrapper.ts Extends stale-cwd validation to all wrapped POSIX OMP commands and verifies physical cwd paths before direct invocation.
src/main/pty/omp-shell-wrapper.node-pty.test.ts Adds real Bash and Zsh PTY scenarios covering stale inodes, removed symlinks, unset PWD, fallback selection, parent-shell isolation, argv, and status propagation.
config/reliability-gates.jsonc Updates the terminal cwd recovery invariant, oracle, evidence, and known coverage gaps to reflect the expanded behavior.
src/main/fixtures/shell-wrapper-snapshots/local-bash-rcfile.txt Regenerates the local Bash wrapper fixture with the shared cwd validation and recovery logic.
src/main/fixtures/shell-wrapper-snapshots/local-zsh-zshenv.txt Regenerates the local Zsh wrapper fixture with the shared cwd validation and recovery logic.
src/main/fixtures/shell-wrapper-snapshots/daemon-bash-rcfile.txt Regenerates the daemon and SSH Bash fixture with the shared wrapper behavior.
src/main/fixtures/shell-wrapper-snapshots/daemon-zsh-zshenv.txt Regenerates the daemon and SSH Zsh fixture with the shared wrapper behavior.
src/main/fixtures/shell-wrapper-snapshots/relay-bash-rcfile.txt Regenerates the relay Bash fixture with the shared wrapper behavior.
src/main/fixtures/shell-wrapper-snapshots/relay-zsh-zshenv.txt Regenerates the relay Zsh fixture with the shared wrapper behavior.

Reviews (4): Last reviewed commit: "fix(terminal): complete OMP stale cwd re..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Aug 29, 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 Plus

Run ID: 88c3d937-dd1c-45ea-a3c7-db22d2419c3c

📥 Commits

Reviewing files that changed from the base of the PR and between fd027a5deafe6f1297b08b5b527b39a2014c5f3d and 4294ae474c260b39d5512ad6822efaeba5a41483.

📒 Files selected for processing (1)
  • config/reliability-gates.jsonc
🚧 Files skipped from review as they are similar to previous changes (1)
  • config/reliability-gates.jsonc

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

Shell-wrapper cwd validation now checks logical and physical paths for directory existence and inode identity. Recovery now runs for all OMP invocations, including extension-skipping commands. PTY coverage adds symlink, stale-directory, unset-PWD, missing-fallback, and argv scenarios. Reliability-gate entries document the expanded assertions and performance evidence.

Merge Risk: ⚪ Minimal · up to 4294a

This change completes stale working-directory recovery for wrapped terminal commands, with reported coverage for the affected Bash and Zsh cases and passing checks. No actionable merge-blocking risk remains beyond normal review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description is complete and follows the repository template. It explains the change, motivation, linked issue, testing, compatibility, performance, and checklist status.
Linked Issues check ✅ Passed The description links the change to issue #16457 and identifies it as a follow-up to #17128.
Out of Scope Changes check ✅ Passed The changes remain focused on POSIX OMP stale-cwd recovery, related shell fixtures, reliability gates, and PTY tests. No unrelated product, protocol, dependency, or native PowerShell changes are inclu…
Title check ✅ Passed The title clearly and concisely describes the primary change: completing terminal OMP stale-cwd recovery.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 unsupported.)

Full details: Out of Scope Changes check

Explanation

The changes remain focused on POSIX OMP stale-cwd recovery, related shell fixtures, reliability gates, and PTY tests. No unrelated product, protocol, dependency, or native PowerShell changes are included.

  • Fix all pre-merge checks with AI

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
nwparker force-pushed the nwparker/fix-omp-stale-cwd-gaps branch 2 times, most recently from 4294ae4 to d387f3e Compare August 29, 2026 21:17
@nwparker
nwparker force-pushed the nwparker/fix-omp-stale-cwd-gaps branch from d387f3e to 834b8cf Compare August 29, 2026 21:27
@nwparker
nwparker merged commit 7655d20 into stablyai:main Aug 29, 2026
26 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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] OMP Unknown error

1 participant