Skip to content

fix(pty): do not create unused Pi/OMP home dirs on bare shells - #10198

Merged
brennanb2025 merged 4 commits into
stablyai:mainfrom
innocarpe:fix/no-eager-pi-omp-home-dirs
Jul 30, 2026
Merged

brennanb2025 merged 4 commits into
stablyai:mainfrom
innocarpe:fix/no-eager-pi-omp-home-dirs

Conversation

@innocarpe

@innocarpe innocarpe commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Bare shells no longer create ~/.pi / ~/.omp just so a later typed agent might get hooks.
  • Default agent homes are materialized only on explicit Pi/OMP launch, or when the directory already exists.
  • OMP status for bare shells still uses the existing userData fallback (omp-managed-status-extension) so shell-launched omp keeps the wrapper extension without polluting $HOME.
  • Same policy on the SSH relay overlay path.

Fixes #10196.

Why

After install, Orca detects/prepares many agents. For Pi/OMP, every plain terminal ran managed-extension install into the default ~/.<agent>/agent tree. Users who never use Pi or OMP still saw those folders reappear after deletion (Windows report, but the path is host-local for all platforms).

Test plan

  • titlebar-extension-service regression: bare-shell prep does not create missing homes; OMP status lands in userData
  • plugin-overlay regression: bare-shell materializeDefaultHome: false leaves remote homes untouched
  • pty.test spawn env / WSLENV assertions updated for no-default-home bare shells
  • pnpm exec vitest run --config config/vitest.config.ts focused suites (389 tests)

Screenshots

No visual change.

ELI5

Every bare shell used to create ~/.pi and ~/.omp just in case, cluttering HOME. Those dirs are only created when you actually launch Pi/OMP or they already exist.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds materializeDefaultHome controls to Pi and OMP extension environment and overlay materialization. Bare shells no longer create missing default agent homes when materialization is disabled. OMP still exports a userData-scoped status extension in that case, without ORCA_OMP_SOURCE_AGENT_DIR. PTY and relay callers pass options based on launch commands and agent kind, and related spawn, daemon, WSL, and unit-test expectations are updated.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description covers summary, why, testing, and screenshots, but omits the required AI Review Report, Security Audit, and Notes sections. Add the missing AI Review Report, Security Audit, and Notes sections, and briefly confirm cross-platform checks in the review report.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address #10196 by preventing bare shells from recreating unused Pi/OMP home dirs while preserving the OMP userData fallback.
Out of Scope Changes check ✅ Passed The code and test changes all support the same bare-shell home-dir prevention goal and do not introduce unrelated scope.
Title check ✅ Passed The title accurately summarizes the main change: preventing unused Pi/OMP home directories on bare shells.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f0d06c97-2476-42ca-8925-a4f5b64dd82f

📥 Commits

Reviewing files that changed from the base of the PR and between 8f40ddf and 6fd3c630086ae518b98703fb3d506c4fbd6ac145.

📒 Files selected for processing (7)
  • src/main/ipc/pty.test.ts
  • src/main/ipc/pty.ts
  • src/main/pi/titlebar-extension-service.test.ts
  • src/main/pi/titlebar-extension-service.ts
  • src/relay/plugin-overlay.test.ts
  • src/relay/plugin-overlay.ts
  • src/relay/relay.ts

Comment thread src/relay/plugin-overlay.ts Resolved
Bare terminals used to materialize ~/.pi/agent and ~/.omp/agent (and install
managed extensions) for possible later shell-launched agents. Users who never
use those agents still saw the directories recreated after deletion.

Only create the default agent home when launching that agent explicitly, or
when the home already exists. Bare-shell OMP status still uses the userData
fallback so typed `omp` keeps the shell wrapper extension.

Closes stablyai#10196
CodeRabbit: relay materializePi returned null on bare shells with a missing
OMP home, so SSH PTYs never set ORCA_OMP_STATUS_EXTENSION. Local already
wrote a userData-managed status extension in that case.

Write the status file under ~/.orca-relay/omp-managed-status-extension and
return MaterializePiResult so relay.ts can export ORCA_OMP_STATUS_EXTENSION
without ORCA_OMP_SOURCE_AGENT_DIR or creating ~/.omp. Also fix the local
withOrcaManagedExtensionMarker typo on the bare-shell path.
@innocarpe
innocarpe force-pushed the fix/no-eager-pi-omp-home-dirs branch from 6fd3c63 to 4c8421a Compare July 24, 2026 08:55
@innocarpe

Copy link
Copy Markdown
Contributor Author

Sync update (4c8421a64)

Address CodeRabbit: SSH relay bare shells now write OMP status extension under ~/.orca-relay/omp-managed-status-extension and export ORCA_OMP_STATUS_EXTENSION without creating ~/.omp or setting ORCA_OMP_SOURCE_AGENT_DIR (parity with local userData fallback).

@innocarpe

Copy link
Copy Markdown
Contributor Author

Scope note (from #10196)

Keeping this PR scoped to bare-shell Pi/OMP home materialization (and the SSH relay overlay parity).

Amethyst also reported a related-but-broader repro: with agents disabled, Orca still creates other homes (.commandcode, .factory, .gemini, .grok, .hermes) on open. That looks like a separate startup/discovery path and is not in this PR. Ownership of the issue was reassigned to @brennanb2025 — happy to extend or open a follow-up if asked; otherwise this stays Pi/OMP-only.

Issue thread: #10196 (comment)

@brennanb2025

Copy link
Copy Markdown
Contributor

Implemented the follow-up fix in 6e9df2537c.

The fix keeps Pi/OMP home materialization scoped to explicit Pi/OMP launches:

  • Bare local shells leave missing ~/.pi and ~/.omp homes absent.
  • Explicit Pi and OMP launches still materialize the appropriate home, including custom commands identified by authoritative launchAgent metadata.
  • Existing homes retain their previous integration behavior.
  • Bare-shell OMP status uses the userData fallback without setting ORCA_OMP_SOURCE_AGENT_DIR.
  • SSH relay receives the same launch metadata and fallback behavior under ~/.orca-relay.
  • WSL launch metadata and environment propagation remain aligned with local/daemon behavior.

Review and validation:

  • Two fresh same-model review lanes returned clean after independently checking the CodeRabbit fix, scope boundaries, local/daemon/WSL/SSH parity, and the requested matrix.
  • Performance review returned clean; this adds only a bounded first-token classification at PTY spawn and removes filesystem writes from missing-home bare-shell paths.
  • Latest-origin/main synthetic merge was conflict-free.
  • Synthetic-merge validation passed Node + CLI typecheck, touched lint/format, 176 focused tests, and the 10-case PTY matrix.
  • Branch validation passed full typecheck and lint (pre-existing warnings only).
  • Isolated Electron E2E passed the local missing-home, explicit-launch, fallback, and existing-home phases.
  • Deterministic relay tests cover fallback placement under ~/.orca-relay, no ~/.omp creation, and no ORCA_OMP_SOURCE_AGENT_DIR; deterministic WSL tests cover propagation.

Live Docker SSH was attempted, but the pinned base image did not finish resolving after roughly four minutes, so no live SSH container result is claimed. Relay unit/integration coverage passed.

Fixes #10196 is appropriate now that #11442 has merged; #11442 owns and covers the complementary managed-hook pollution for other agents.

Electron evidence:

Existing-home bare-shell preservation:

pr-10198-bare-shell-existing-home.png

Explicit Pi/OMP launches and subsequent existing-home preservation:

pr-10198-explicit-and-existing-homes.png

@greptile-apps

greptile-apps Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR fixes a UX regression where every bare terminal spawn would mkdir ~/.pi/agent and ~/.omp/agent, causing deleted Pi/OMP homes to silently reappear. The fix threads a materializeDefaultHome flag through the extension-install layer so that missing default homes are only created on an explicit Pi/OMP launch; bare shells get an OMP status-extension written to a userData/relay path instead.

  • Adds detectExplicitPiAgentKindFromCommand (returns null for bare shells) alongside the existing detectPiAgentKindFromCommand (defaults to 'pi'); both pty.ts and relay.ts now use the explicit variant with a null-safe fallback.
  • buildPtyEnv (titlebar-extension-service) and materializePi (plugin-overlay) both accept { materializeDefaultHome?: boolean } defaulting to true, so all existing callers remain backward-compatible.
  • materializePi return type changes from string | null to MaterializePiResult | null, separating sourceAgentDir from statusExtensionPath; all call sites in relay.ts are updated accordingly.

Confidence Score: 5/5

Safe to merge. The change only restricts when agent home dirs are created; all existing dirs and explicit launches are unaffected.

Every changed code path has a matching test (unit and integration), the OMP userData fallback is covered by both the local and relay test suites, the return-type refactor on materializePi is fully propagated across all call sites, and the removed getRelayPiStatusExtensionPath export has no remaining consumers. No production logic is silently changed for users who already have ~/.pi or ~/.omp on disk.

Files Needing Attention: No files require special attention.

Important Files Changed

Filename Overview
src/shared/pi-agent-kind.ts Adds detectExplicitPiAgentKindFromCommand (returns null for bare/non-pi shells); simplifies OMP detection to first-binary comparison. detectPiAgentKindFromCommand now has no production callers — it delegates to the explicit variant and is kept only for tests.
src/main/pi/titlebar-extension-service.ts Adds materializeDefaultHome option to buildPtyEnv; short-circuits before any mkdirSync when the dir is absent and the flag is false, writing only the OMP userData fallback status extension for bare-shell OMP prep.
src/relay/plugin-overlay.ts Changes materializePi return from string
src/main/ipc/pty.ts Switches to detectExplicitPiAgentKindFromCommand + isPiCompatibleAgentType for explicit kind resolution; passes materializeDefaultHome: explicitPiAgentKind === 'pi'/'omp' so bare shells never create missing homes.
src/relay/relay.ts Mirrors the pty.ts logic for the SSH relay env-augmenter path; reads MaterializePiResult fields individually so the OMP bare-shell status-only case (statusExtensionPath set, sourceAgentDir absent) is handled correctly.
src/relay/pty-handler.ts Threads launchAgent through buildSpawnEnv context and PtyEnvAugmenter callback; simplifies isUnattended to launchAgent !== undefined after isTuiAgent validation is hoisted to the spawn handler.

Reviews (2): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile

@brennanb2025

Copy link
Copy Markdown
Contributor

SSH Docker validation — LAND

Tested exact PR head 6e9df25 in an isolated Electron user-data directory against a disposable Docker SSH host.

Target: Debian GNU/Linux 12 Bookworm, arm64, Node 22.23.1, Git 2.39.5. Remote agent hooks were enabled. No emulator or simulator was started.

Real SSH behavior

  • Bare remote shell with both agent homes initially absent:
    • HOME/.pi stayed absent
    • HOME/.omp stayed absent
    • ORCA_OMP_SOURCE_AGENT_DIR stayed unset
    • ORCA_OMP_STATUS_EXTENSION pointed to an existing relay-owned fallback under HOME/.orca-relay
  • Negative classification: a non-agent startup command whose argument mentioned omp did not create either agent home.
  • Explicit Pi launch metadata:
    • created HOME/.pi/agent
    • installed the Pi status extension
    • exported the Pi source directory
    • did not create HOME/.omp
  • Explicit OMP launch metadata:
    • created HOME/.omp/agent
    • installed the OMP status extension
    • exported both the OMP source directory and status extension path
  • Transport non-vacuity: an Orca-rendered remote PTY created branch orca-pr10198-ssh-proof-6e9df253, a linked worktree, and pr10198-ssh-proof.txt. A separate host SSH connection observed the same branch, worktree, and file contents.
  • Initial relay deployment on node:22-slim correctly failed with actionable missing-build-tools guidance. After installing build-essential and python3, relay native dependencies built and connection succeeded.

Landing-state regression gate

The PR head is 392 commits behind current main and its old baseline alone carries seven stale PowerShell cwd expectation failures. Current main already has that test-helper correction. A conflict-free synthetic merge with current main passed the complete targeted set:

  • 5 test files passed
  • 576 tests passed
  • Covered Pi/OMP classification, titlebar installation, relay overlays, relay PTY handling, and main PTY IPC

Relay log had zero plugin-overlay or PTY failures; daemon log had no relevant failures. The app did emit existing SSH filesystem notification warnings while browsing files, outside this PRs touched paths and without affecting PTY or Git transport.

Screenshots

Bare shell plus real transport:

pr10198-ssh-docker-gate.png

Explicit Pi:

pr10198-ssh-explicit-pi.png

Explicit OMP:

pr10198-ssh-explicit-omp.png

Cleanup

Killed all three test PTYs, removed the remote test worktree/branch/file and test-created agent homes, verified the remote main repo clean, removed the Orca repo/SSH target, stopped the isolated Electron instance, removed the Docker container, removed the synthetic-merge worktree, and moved local test artifacts to Trash. No task-prefixed container, temp directory, or worktree remains.

Verdict: land.

@brennanb2025
brennanb2025 merged commit 9e0a9eb into stablyai:main Jul 30, 2026
43 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…yai#10198)

* fix(pty): do not create unused Pi/OMP home dirs on bare shells

Bare terminals used to materialize ~/.pi/agent and ~/.omp/agent (and install
managed extensions) for possible later shell-launched agents. Users who never
use those agents still saw the directories recreated after deletion.

Only create the default agent home when launching that agent explicitly, or
when the home already exists. Bare-shell OMP status still uses the userData
fallback so typed `omp` keeps the shell wrapper extension.

Closes stablyai#10196

* fix(relay): OMP bare-shell status fallback without ~/.omp

CodeRabbit: relay materializePi returned null on bare shells with a missing
OMP home, so SSH PTYs never set ORCA_OMP_STATUS_EXTENSION. Local already
wrote a userData-managed status extension in that case.

Write the status file under ~/.orca-relay/omp-managed-status-extension and
return MaterializePiResult so relay.ts can export ORCA_OMP_STATUS_EXTENSION
without ORCA_OMP_SOURCE_AGENT_DIR or creating ~/.omp. Also fix the local
withOrcaManagedExtensionMarker typo on the bare-shell path.

* fix(pty): only materialize Pi home for Pi launches

---------

Co-authored-by: Brennan Benson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Agent home dirs (e.g. .pi, .omp) recreated in user root for agents never used

4 participants