Skip to content

fix(terminal): give plain fish tabs Orca's codex function without changing fish's startup - #24284

Merged
Jinwoo-H merged 11 commits into
mainfrom
jinwoo/codex-fish-vendor-conf
Oct 1, 2026
Merged

Jinwoo-H merged 11 commits into
mainfrom
jinwoo/codex-fish-vendor-conf

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​345 $\color{#cf222e}{\Huge{\mathbf{−}}}$​11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​334
Prod 14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​190 $\color{#cf222e}{\Huge{\mathbf{−}}}$​40 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​150

ELI5

Orca has a small codex helper that starts Codex in a way that keeps each tab's agent status separate. fish tabs only got that helper when Orca was already launching something in them. If you opened a normal fish tab and typed codex yourself, you got plain Codex, and it shared one background server across tabs. Now every fish tab gets the helper, and fish still starts exactly the way it did before.

What Changed

Before: in a plain fish tab (no startup command), type codex showed the binary. A hand-typed codex ran without --no-daemon, so Codex 0.156+ started its shared background server and per-tab agent status broke.

After: in a plain fish tab, codex is Orca's function from src/shared/codex-shell-function.ts, and a hand-typed codex gets --no-daemon (it already did in zsh and bash). Nothing else in the shell changes:

  • fish's command line is still fish -l.
  • XDG_DATA_DIRS is back to its original value, or unset again if it was unset.
  • No Orca variable is left behind for child processes.
  • A user's own codex function or alias still wins, and ORCA_CODEX_ISOLATE=0 still opts out.

Mechanism. fish loads startup snippets from <dir>/fish/vendor_conf.d for every directory in XDG_DATA_DIRS. This is the standard way a terminal adds shell integration to fish without changing its arguments, and it plays the same role as the zsh wrapper's ZDOTDIR hand-back.

  1. Orca's generated shell-wrapper tree now also contains fish-xdg-data/fish/vendor_conf.d/orca-shell-integration.fish. It is built by the same content-addressed fileset machinery, for both the in-process provider and the terminal daemon.
  2. For a plain fish spawn, Orca puts that directory at the front of XDG_DATA_DIRS and records the exact prefix it added in ORCA_FISH_XDG_DATA_DIRS_PREFIX.
  3. The snippet's first step is to undo this. It removes exactly that prefix from XDG_DATA_DIRS (or unsets the variable if nothing is left), and erases the marker. Orca's directory stays in the lookup paths fish already derived from it for that session; it holds only this snippet, so nothing else loads from it.
  4. It then registers a one-time fish_prompt handler that runs the shared fish codex definition, unchanged. That definition runs after config.fish, the same timing wrapped tabs have today. So a codex the user defines in config.fish, or adds to PATH there, is seen first.
  5. If the in-process provider falls back to another shell, it now puts back the value each launch-env key had before Orca wrote it (unsetting keys that had none). Before, it deleted every launch-env key. This hands back the user's own XDG_DATA_DIRS after a fish fallback, and also an inherited ZDOTDIR after a zsh→bash fallback.

When XDG_DATA_DIRS was unset, Orca adds the XDG spec default (/usr/local/share:/usr/share) after its own directory. fish 4.7 and newer scans exactly those directories when the variable is unset, so the resulting paths are identical; this was checked against Homebrew fish 4.9.3 at /opt/homebrew. fish older than 4.7 used a different default when unset (its own data directory, or nothing). On those versions a plain Orca tab also searches /usr/local/share/fish/vendor_*.d. Nothing fish loaded before is dropped, and the variable itself is still restored to unset.

Daemon: the terminal daemon spawns these shells, so PROTOCOL_VERSION goes 38 → 39 (same pattern as #23907). New tabs move to a daemon that sets the env; v38 owners stay attachable.

Why

  • Not "always wrap fish with --init-command": that changes how every fish tab starts, and we rejected it earlier. The env approach leaves argv alone and cleans up after itself before the user's config.fish runs.
  • One mechanism per tab: wrapped fish tabs (startup command or ready marker) keep their existing -C path byte-for-byte, and plain tabs use the vendor snippet. No shell ever runs both. If both ever did run, the shared definition only wraps when type -t codex is file, so the second run would do nothing. Moving wrapped tabs onto the snippet as well would have changed when their codex gets defined, and would have made them depend on the wrapper tree being written. I kept them unchanged.
  • The function body is not copied: the snippet includes getFishCodexShellLaunchPreflight() verbatim, and a test checks that.

Related: Linear STA-9051.

Linked Issue

Related: STA-9051 (Linear). Follow-up to #23900 / #23933 / #23907.

Visual Proof

N/A. There is nothing visible in the UI; the change is in shell startup. Terminal transcripts are under Testing.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated

Live in a real Orca-spawned tab, macOS: isolated headless runtime (orca-dev serve, ORCA_BACKGROUND_LAUNCH=1 ORCA_DISABLE_MACOS_LOGIN_SHELL=1, throwaway user data, HOME and CODEX_HOME). A fake codex was first on PATH, and command -v codex confirmed it was the fake. Homebrew fish 4.9.3, served by the v39 daemon:

  • Plain tab: argv is /opt/homebrew/bin/fish -l. type codex shows the function. XDG_DATA_DIRS is unset, the marker is gone, env has no Orca entries, and config.fish ran.
  • $__fish_vendor_confdirs matches a fish started without Orca, plus Orca's own directory, which holds only the snippet.
  • complete -C 'brew ' and complete -C 'docker ' return the same counts (117 and 58) with and without Orca, so Homebrew vendor completions still load.
  • Typed codex exec hello ran as --no-daemon exec hello. codex --remote ws://x ran without the flag, as the skip list intends.
  • With XDG_DATA_DIRS=/opt/e2e-a:/opt/e2e-b inherited, the tab shows exactly that value, and children see exactly that value.
  • codex defined in config.fish: the user function wins.
  • Wrapped tab (terminal create --command "codex exec …"): it still launches with -C. The startup command and a later typed codex both got --no-daemon, and no XDG env was injected.
  • In-process provider launch config, driven into a real PTY: same results for unset and inherited XDG_DATA_DIRS.

Live, Linux (Docker): Debian bookworm with fish 3.6.0 and Debian trixie with fish 4.0.2. The real daemon and local launch-config code was run inside each container, and fish ran interactively under script (8 runs: both versions × both paths × unset/set):

  • argv is fish -l, codex is the function, typed codex gets --no-daemon, the marker is gone, children see no Orca dir, and config.fish ran.
  • With an inherited XDG_DATA_DIRS, all derived paths are identical to a run without Orca. With it unset, they differ only by the extra /usr/local/share/fish/vendor_*.d described above.
  • A config.fish codex function wins, and ORCA_CODEX_ISOLATE=0 opts out, on both versions.

No regression for other shells: I dumped getShellLaunchConfig for zsh, bash, pwsh, powershell.exe and fish across feature sets and with and without a startup command, on both transports, for main and for this branch. The only differences are the plain-fish rows. zsh .zshenv and bash rcfile bytes are identical once the content-hash directory name is normalized.

Automated:

  • fish-xdg-data-dirs-handoff.test.ts: env prepend and marker for unset, existing, and already-containing values; an empty value handled like unset; the skip for -N/--no-config args; the snippet path; and the snippet embedding the shared function verbatim. Its real-fish tests run in the shell contracts CI job, which requires fish.
  • fish-xdg-data-dirs-no-config-launch.test.ts: both the daemon and local spawn paths leave XDG_DATA_DIRS alone for -N and still hand off for -l.
  • Live fish runs in the same file: derived paths match a no-Orca fish exactly; typed codex is wrapped; opt-out; user function wins; non-interactive fish gets no hook.
  • Fallback-restore tests in local-pty-utils.test.ts (fish XDG_DATA_DIRS, zsh→bash ZDOTDIR); updated launch-config tests; protocol-version tests.
  • pnpm tc, oxlint and check:code-quality:changed are clean. repro-13767-shell-ready-marker-lost-to-exec.test.ts also fails locally on unmodified origin/main, so that failure predates this change.

Review

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

  • SSH relay fish: not changed. The relay has no fish codex function at all today, and it generates its wrappers separately. Follow-up.
  • WSL fish: not changed. The local provider skips WSL panes here, and the daemon's Windows branch launches wsl.exe. Follow-up.
  • Windows has no fish.
  • Skipped launches: when the user-configured fish args include -N/--no-config (fish then never reads the snippet), Orca injects nothing, so that tab keeps its env exactly but gets no codex function. An empty XDG_DATA_DIRS is handled like unset (the XDG spec and fish 4.7+ read both as the default; older fish only gains the two default vendor dirs), so that tab still gets the function and ends up with the variable unset.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • 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)

…nging fish's startup

A `codex` typed into a plain fish tab ran without --no-daemon because only
wrapped fish tabs (startup command / ready marker) got Orca's codex function.

Plain fish spawns now prepend an Orca data dir to XDG_DATA_DIRS and record the
exact prefix in ORCA_FISH_XDG_DATA_DIRS_PREFIX. Fish sources the dir's
fish/vendor_conf.d snippet, which first restores XDG_DATA_DIRS (unset again if it
was unset), erases the marker, drops its dir from fish's derived vendor/function/
completion paths, then defines the shared fish codex function at the first prompt
so the user's config.fish still wins. fish argv is unchanged; wrapped tabs keep
their existing -C path. A local fallback to another shell restores the user's
XDG_DATA_DIRS instead of deleting it.

Bumps the terminal daemon protocol to v39 so new tabs move to a daemon that
injects the env; v38 owners stay attachable.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[High risk] Daemon protocol version bump and shell startup environment changes.

The PR does not yet appear safe to merge because the previously reported empty-XDG fish startup issue remains.

Findings

  1. P1 Empty XDG loads vendor directories ▶
  2. P2 Fish file gates other shells ▶
  3. P2 Fish cleanup removes user paths ▶

Summary

This PR gives plain fish tabs Orca’s Codex function through a temporary XDG data-directory handoff, while retaining fish’s existing launch arguments. It also updates both PTY spawn paths, fallback environment restoration, tests, and daemon protocol compatibility.

Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Plain fish spawn] --> B[Prepend Orca XDG data directory]
  B --> C[fish loads vendor snippet]
  C --> D[Restore launch environment]
  D --> E[Register Codex function at first prompt]
Loading

Reviews (10) · Last reviewed commit: "docs(fish): drop the comment for the rem..."

Comment thread src/main/fish-xdg-data-dirs-handoff.ts Resolved
export function getLocalShellReadyWrapperPaths(root: string): readonly string[] {
const zshDir = `${root}/zsh`
return [`${zshDir}/.zshenv`, `${zshDir}/${ZSH_WRAPPER_DIR_MARKER_FILE}`, `${root}/bash/rcfile`]
return [

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Fish file gates other shells

If the fish snippet cannot be written while the zsh and bash wrapper files are available, the shared whole-tree check still marks every wrapper unusable. Those shells then lose their startup integration because of a fish-only file failure; checking availability per shell would keep the failure contained.

Knowledge Base Used: Terminal runtime and interaction

@pullfrog pullfrog 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.

ℹ️ No critical issues — one coverage observation below.

Reviewed changes

  • Plain fish gets an env-only launch config — local-pty-shell-ready.ts and daemon/shell-ready.ts now return args: null plus an XDG_DATA_DIRS prefix for markerless fish, leaving fish -l byte-for-byte; wrapped fish (ready / startup command) is untouched.
  • New fish-xdg-data-dirs-handoff.ts — prepends <wrapperRoot>/fish-xdg-data to XDG_DATA_DIRS, records the exact prefix in ORCA_FISH_XDG_DATA_DIRS_PREFIX, and supplies both a Node restoreFishXdgDataDirs twin and the fish/vendor_conf.d snippet that undoes the prefix (env, __fish_vendor_*dirs, fish_function_path, fish_complete_path) then defines codex on the first fish_prompt.
  • Both wrapper filesets emit the snippet — local and daemon trees, written through the existing content-addressed machinery; wrapper-path existence checks include it so stale trees rebuild.
  • Fallback restore — spawnShellWithFallback hands the user's own XDG_DATA_DIRS back before scrubbing stale launch keys and no longer deletes it, since restore owns that key.
  • Protocol bump 38 → 39 — daemon-protocol-version.ts and the local-build compatibility contract, with the attachable list and version tests updated. Wrapped fish deliberately keeps its -C path so no tab runs both mechanisms.

ℹ️ The snippet's real-fish behavior is not exercised by CI

The only tests that drive the snippet through an actual fish are gated on resolveFishBinary() and skip when fish is absent, and the shell contracts CI job — the one lane that installs fish and sets ORCA_REQUIRE_FISH=1 — runs a fixed file list that does not include fish-xdg-data-dirs-handoff.test.ts. In the normal shards the whole describe.skipIf(!fish.available) block skips, so the load-bearing behavior (fish actually sources vendor_conf.d, the restore yields state identical to a no-Orca fish, and a typed codex becomes the function at the first prompt) is verified only on developer machines. The unit tests that do run cover the Node env helpers and the snippet's contents, but nothing asserts that fish parses the emitted script as intended.

Technical details
# Real-fish coverage only runs off CI

## Affected sites
- `src/main/fish-xdg-data-dirs-handoff.test.ts` — `describe.skipIf(!fish.available)('fish vendor snippet in a real fish', ...)` covers the env round-trip, path cleanup, typed-codex wrapping, opt-out and config.fish precedence, but is skipped whenever fish is not installed.
- `.github/workflows/pr.yml` — the `shell contracts` job's "Test real shell contracts" step enumerates an explicit file list; `fish-xdg-data-dirs-handoff.test.ts` is not on it. Other live-fish suites (e.g. `src/main/pty/codex-shell-no-daemon.test.ts`) are.

## Required outcome
The snippet's end-to-end behavior should be guarded by CI, not only by manual runs, so a later change to the generated fish script (or a fish version difference on the runner) cannot pass green while the mechanism is broken.

## Suggested approach
Add `src/main/fish-xdg-data-dirs-handoff.test.ts` to the `shell contracts` step's `vitest run` list. Optionally mirror the other live-fish suites by asserting `fishRequirementViolation(lookup)` is null in an always-running test in the file.

## Open questions for the human
Is the omission intentional (e.g. runtime budget), or is the file simply not yet wired into that lane?

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 4bbb1487-aff8-4e69-8483-72963e011d48

📥 Commits

Reviewing files that changed from the base of the PR and between 238a38f and eba2c9a.

📒 Files selected for processing (14)
  • src/main/daemon/daemon-protocol-version.test.ts
  • src/main/daemon/daemon-protocol-version.ts
  • src/main/daemon/shell-ready.ts
  • src/main/fish-xdg-data-dirs-handoff.test.ts
  • src/main/fish-xdg-data-dirs-handoff.ts
  • src/main/fish-xdg-data-dirs-no-config-launch.test.ts
  • src/main/providers/local-pty-finalize-environment.ts
  • src/main/providers/local-pty-launch-plan.ts
  • src/main/providers/local-pty-pi-owner-env.test.ts
  • src/main/providers/local-pty-shell-ready.ts
  • src/main/providers/local-pty-spawn.ts
  • src/main/providers/local-pty-utils.test.ts
  • src/main/providers/local-pty-utils.ts
  • src/main/pty/codex-launch-shell-wrapping.test.ts
💤 Files with no reviewable changes (2)
  • src/main/daemon/daemon-protocol-version.ts
  • src/main/daemon/daemon-protocol-version.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

Fish shell launches can receive an Orca vendor configuration directory through XDG_DATA_DIRS. The vendor snippet restores the original data-directory value and defers interactive Codex setup until the first prompt. Unix fallback handling restores the original environment. The daemon protocol and local-build compatibility contract now use version 39, with version 38 listed as a previous supported version.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to eba2c

The Fish handoff preserves launch arguments, restores inherited environment values, and retains protocol v38 compatibility according to the supplied changes. No actionable merge-blocking issue is established; merge after normal checks pass.

Security Architecture Review

Security architecture risk: 🔵 Low · up to eba2c

The change stays within user-owned terminal startup and preserves important cleanup, user-override, and opt-out controls. No security regression is demonstrated, but startup-file integrity, downstream hook preparation, and older-daemon behavior are only partially established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated exposure expansion is execution of generated startup code in eligible plain Fish tabs, followed by the existing Codex helper when the user invokes it. Those executions carry the shell user's authority; they are not a new tenant or credential-isolation boundary.

Trust Boundaries and Controls

  • observed — The handoff is skipped for configuration-disabled Fish arguments and wrapper paths containing a colon. Executable startup-file trust still depends on the wrapper root: existing non-empty files are reused without ownership or content verification. Production daemon spawning explicitly supplies its user-data path; the existing temporary-directory fallback remains a separate trust assumption, now relevant to plain Fish too.

Resilience and Maintainability Implications

  • observed — Local environment mutation is scoped to a launch invocation. Fallback selection does not read the new XDG handoff variables, and the located production fallback observer changes history variables only. Cancellation after spawning kills and destroys the process; reservation and pending-spawn bookkeeping are released in finally blocks.

Hardening Proposals

  • proposed — Consider enforcing owner-controlled wrapper directories and rejecting untrusted shared-temporary or symlinked trees before reusing executable startup files. This would strengthen an existing trust assumption rather than remediate a demonstrated production exploit.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 21 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the main change: adding Orca’s codex function to plain fish tabs without changing fish startup.
Description check ✅ Passed The description covers the change, rationale, implementation, testing, visual-proof requirement, and scope notes. It identifies a related Linear issue, but does not provide a direct issue link as the …
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

…_DIRS

fish never reads vendor_conf.d under -N/--no-config (also abbreviated or
clustered), so the snippet could not undo the prefix; and the restore cannot
tell an empty XDG_DATA_DIRS from an unset one. Both now launch untouched.
Run the real-fish handoff tests in the shell contracts job, where fish is
required, so they no longer skip in CI.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Comment thread src/main/fish-xdg-data-dirs-handoff.ts Resolved

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • -N/--no-config and empty XDG_DATA_DIRS now skip the handoff — getFishXdgDataDirsLaunchEnv returns {} when fish args disable config loading (-N, -lN, --no-c+, matched by the new fishArgsSkipConfig) or when inherited XDG_DATA_DIRS is '', so no prefix is injected that the snippet could never undo.
  • shellArgs plumbed to the handoff decision — the daemon plan passes userShellArgs and simplifies the arg expression to userShellArgs ?? shellLaunch.args ?? ['-l']; the local plan captures { inheritedXdgDataDirs, shellArgs } before the closure re-runs. Both are behavior-preserving for wrapped fish.
  • Prior coverage gap closed — fish-xdg-data-dirs-handoff.test.ts is now in the shell contracts CI list and gains an always-running fishRequirementViolation assertion, so a missing fish fails rather than silently skipping the load-bearing real-fish tests.
  • New launch-env test — fish-xdg-data-dirs-no-config-launch.test.ts drives both the daemon and local spawn paths and asserts XDG_DATA_DIRS is left untouched for -N/--no-config/-lN while a plain -l still hands off.

Verified the two changed test files pass locally (35 passed | 7 skipped; the skipped block is the real-fish suite, absent on this host).

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Ubuntu runners ship snapd's fish vendor snippet, which sets XDG_DATA_DIRS on
every fish start, so "unset" was never the right oracle there.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Made the unset-restore fish test environment-robust — the restores an unset XDG_DATA_DIRS case in fish-xdg-data-dirs-handoff.test.ts now compares the xdg=/XDG_DATA_DIRS=/child-clean probe lines against a baseline fish run without Orca, instead of hardcoding xdg=unset. A distro vendor snippet (e.g. Ubuntu's snapd) that sets XDG_DATA_DIRS itself no longer trips the assertion. The marker-left and not.toContain(root) checks are retained, so the env round-trip and fish-path cleanup remain covered.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

…ets the codex hook

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
return {}
}
// Why empty counts as unset: fish and the XDG spec read both as the default, so restoring '' as unset is invisible.
const prefix = inheritedXdgDataDirs ? dataDir : `${dataDir}:${XDG_DATA_DIRS_DEFAULT}`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Empty XDG loads vendor directories

If a plain tab uses fish older than 4.7 and inherits an explicitly empty XDG_DATA_DIRS, this branch adds /usr/local/share:/usr/share. Those fish versions would not search those vendor directories with an empty value. If either directory contains vendor scripts, the tab can run startup code the user's environment excluded; vendor function and completion paths also remain for the session. The snippet removes Orca's directory, but does not undo the added default directories.

Knowledge Base Used: Terminal runtime and interaction

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • An empty XDG_DATA_DIRS is now handled like unset — getFishXdgDataDirsLaunchEnv dropped the inheritedXdgDataDirs === '' skip, so a plain fish tab launched with an explicitly empty variable gets the dataDir:/usr/local/share:/usr/share prefix and, after the snippet's restore, ends with the variable unset rather than empty. The rationale holds: fish and the XDG spec read '' and unset as the same default, so the tab's own path derivation is unchanged and only the set-empty-versus-unset distinction for children differs.
  • Unit test updated to pin the new contract — the empty case now asserts the exact launch env ({ XDG_DATA_DIRS: '<dataDir>:/usr/local/share:/usr/share', ORCA_FISH_XDG_DATA_DIRS_PREFIX: <same> }) and restoreFishXdgDataDirs deleting both keys, replacing the prior toEqual({}) skip assertion.

Verified locally: src/main/fish-xdg-data-dirs-handoff.test.ts, src/main/fish-xdg-data-dirs-no-config-launch.test.ts, and src/main/providers/local-pty-utils.test.ts — 50 passed, 7 skipped (the real-fish block, absent on this host). The prior review's coverage gap is closed (the file is on the shell contracts CI list). No inline comments.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Jinwoo-H and others added 2 commits October 1, 2026 04:35
The primary shell's launch config now records the pre-launch value of each
key it writes. A fallback shell restores those values (unsetting keys that
had none) instead of deleting the keys, which hands back an inherited
XDG_DATA_DIRS after a fish fallback and an inherited ZDOTDIR after a
zsh->bash fallback, with no per-shell special case.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ippet

- Remove restoreFishXdgDataDirs; the generic fallback restore covers it.
- Snippet: read ":$XDG_DATA_DIRS:" directly and filter Orca's vendor dirs
  with one string match per variable.
- Require inheritedXdgDataDirs in both getShellLaunchConfig option shapes.
- Drop the test-only FISH_XDG_DATA_DIRS_HANDOFF_DAEMON_PROTOCOL_VERSION.
- Fix stale fish comments and trim redundant -N launch cases.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Comment thread src/main/fish-xdg-data-dirs-handoff.ts Outdated

set -l orca_fish_dir (string split -m 1 : -- $prefix)[1]/fish
for var in __fish_vendor_confdirs __fish_vendor_functionsdirs __fish_vendor_completionsdirs fish_function_path fish_complete_path
set $var (string match -v -- "$orca_fish_dir/*" $$var)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Fish cleanup removes user paths If the wrapper root contains a literal * or ?, fish treats it as part of this match pattern rather than as part of the directory name. The cleanup can then remove unrelated user search paths, making functions or completions disappear from this tab.

Knowledge Base Used: Terminal runtime and interaction

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Restored the user's own launch env on shell fallback — local-pty-finalize-environment.ts now captures primaryPreLaunchEnv (the value each launch-env key had before Orca wrote it) and spawnShellWithFallback restores those values per attempt instead of deleting the keys, so a fish→zsh fallback hands back the user's XDG_DATA_DIRS and a zsh→bash fallback hands back an inherited ZDOTDIR. The per-attempt recompute unwinds the previous fallback's own env before applying the next.
  • Dropped the Node restore twin and its protocol constant — restoreFishXdgDataDirs and the unused FISH_XDG_DATA_DIRS_HANDOFF_DAEMON_PROTOCOL_VERSION are gone; PROTOCOL_VERSION stays 39 and the attachable list is unchanged. The captured-preLaunchEnv path fully supersedes the twin.
  • Simplified the fish vendor snippet — the XDG restore no longer pre-joins $XDG_DATA_DIRS, and the five fish path variables are cleaned with one string match -v -- "$orca_fish_dir/*" each, replacing the nested contains/set -e loops.
  • Tightened the launch-config signatures — both transports take an optional options object, local-pty-shell-ready.ts takes fishLaunch?, and the tests that only exercise wrapped shells now pass inheritedXdgDataDirs: undefined.

Verified locally: pnpm tc clean; local-pty-utils.test.ts, fish-xdg-data-dirs-no-config-launch.test.ts, fish-xdg-data-dirs-handoff.test.ts, and codex-launch-shell-wrapping.test.ts all pass (45 passed, 7 skipped — the real-fish block, fish absent on this host).

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Merged origin/main (71766487) into the branch — the only new commit is a merge-up (d36d30a4); incrementalDiffPath is null and the merge carries no authored logic delta. Two of the PR's own files picked up main's newer content: .github/workflows/pr.yml (main's CI routing rework) and src/main/providers/local-pty-launch-plan.ts (main's unconditional ensureNodePtySpawnHelperExecutable(), dropping the canUseBunPty guard).
  • The branch's authored edits survive the merge — git diff d36d30a4 71766487 is exactly primaryPreLaunchEnv in local-pty-launch-plan.ts plus the fish-xdg-data-dirs-handoff.test.ts line in the shell contracts list; nothing else diverges from main. No conflict-resolution code.
  • Merged tree verified — fish-xdg-data-dirs-handoff.test.ts, fish-xdg-data-dirs-no-config-launch.test.ts, local-pty-utils.test.ts, codex-launch-shell-wrapping.test.ts, and local-pty-pi-owner-env.test.ts: 48 passed, 7 skipped (the real-fish block, absent on this host). All prior Pullfrog review threads are resolved; the prior review stands.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

Only XDG_DATA_DIRS is restored, by exact prefix; Orca's dir holds nothing but this snippet, so leaving it on fish's derived paths loads nothing else and drops the glob match.

@pullfrog pullfrog 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.

ℹ️ No critical issues — one stale comment to clean up, plus a PR-body inconsistency.

Reviewed changes

Reviewed the delta since the prior pullfrog review (a2c0027, “stop scrubbing fish's lookup paths after the handoff”) against 2baf2c1, which is 2 files (test + source).

  • Dropped the fish derived-path scrub — __orca_fish_xdg_handoff now restores only XDG_DATA_DIRS by exact prefix and no longer strips Orca's dir from __fish_vendor_*dirs, fish_function_path, or fish_complete_path. The wrapper dir holds only the snippet, so nothing else loads from it; re-sourcing the snippet is idempotent (the marker is gone, so the function returns early). No functional regression found.
  • Simplified the real-fish tests to match — removed the fishScansXdgDefaultWhenUnset version probe and the separate unset-restore case, folding undefined into the baseline it.each; STATE_PROBE no longer prints the derived path variables.

ℹ️ Nitpicks

  • The PR body's Testing bullet "$__fish_vendor_confdirs is identical to a fish started without Orca" now contradicts the mechanism section, which states Orca's directory stays on fish's derived paths. Update or drop the bullet.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

Comment thread src/main/fish-xdg-data-dirs-handoff.ts Resolved
@Jinwoo-H
Jinwoo-H merged commit ae41eb4 into main Oct 1, 2026
47 checks passed
Jinwoo-H added a commit that referenced this pull request Oct 2, 2026
… a new terminal (STA-9051) (#24501)

Backport of open PR #24501 at fd86a9a: CODEX_FISH_SHELL_FUNCTION_DAEMON_PROTOCOL_VERSION is 38 on this release line, where #24284's fish wrapper ships at v38 (main bumped to 39 for it); its fish test cases shift to v37/v38 to match. PROTOCOL_VERSION stays 38.
OmarHung pushed a commit to OmarHung/orca that referenced this pull request Oct 3, 2026
…nging fish's startup (stablyai#24284)

* fix(terminal): give plain fish tabs Orca's codex function without changing fish's startup

A `codex` typed into a plain fish tab ran without --no-daemon because only
wrapped fish tabs (startup command / ready marker) got Orca's codex function.

Plain fish spawns now prepend an Orca data dir to XDG_DATA_DIRS and record the
exact prefix in ORCA_FISH_XDG_DATA_DIRS_PREFIX. Fish sources the dir's
fish/vendor_conf.d snippet, which first restores XDG_DATA_DIRS (unset again if it
was unset), erases the marker, drops its dir from fish's derived vendor/function/
completion paths, then defines the shared fish codex function at the first prompt
so the user's config.fish still wins. fish argv is unchanged; wrapped tabs keep
their existing -C path. A local fallback to another shell restores the user's
XDG_DATA_DIRS instead of deleting it.

Bumps the terminal daemon protocol to v39 so new tabs move to a daemon that
injects the env; v38 owners stay attachable.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* fix(fish): skip the XDG handoff for -N/--no-config and empty XDG_DATA_DIRS

fish never reads vendor_conf.d under -N/--no-config (also abbreviated or
clustered), so the snippet could not undo the prefix; and the restore cannot
tell an empty XDG_DATA_DIRS from an unset one. Both now launch untouched.
Run the real-fish handoff tests in the shell contracts job, where fish is
required, so they no longer skip in CI.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* test(fish): compare the unset-restore case against a fish without Orca

Ubuntu runners ship snapd's fish vendor snippet, which sets XDG_DATA_DIRS on
every fish start, so "unset" was never the right oracle there.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* fix(fish): treat an empty XDG_DATA_DIRS like unset so the tab still gets the codex hook

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* fix(pty): put back the user's own launch env on a shell fallback

The primary shell's launch config now records the pre-launch value of each
key it writes. A fallback shell restores those values (unsetting keys that
had none) instead of deleting the keys, which hands back an inherited
XDG_DATA_DIRS after a fish fallback and an inherited ZDOTDIR after a
zsh->bash fallback, with no per-shell special case.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* refactor(fish): drop the Node restore twin and simplify the vendor snippet

- Remove restoreFishXdgDataDirs; the generic fallback restore covers it.
- Snippet: read ":$XDG_DATA_DIRS:" directly and filter Orca's vendor dirs
  with one string match per variable.
- Require inheritedXdgDataDirs in both getShellLaunchConfig option shapes.
- Drop the test-only FISH_XDG_DATA_DIRS_HANDOFF_DAEMON_PROTOCOL_VERSION.
- Fix stale fish comments and trim redundant -N launch cases.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* refactor(fish): stop scrubbing fish's lookup paths after the handoff

Only XDG_DATA_DIRS is restored, by exact prefix; Orca's dir holds nothing but this snippet, so leaving it on fish's derived paths loads nothing else and drops the glob match.

* docs(fish): drop the comment for the removed vendor-dir cleanup

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Backport: keeps PROTOCOL_VERSION at 38. This release replaces v37 (1.4.218) services anyway, and main's v39 also carries later daemon work this branch lacks.

(cherry picked from commit ae41eb4)
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.

1 participant