Skip to content

fix(mimo): keep MiMo's login and sessions by injecting the status plugin via MIMOCODE_CONFIG_DIR - #33668

Merged
nwparker merged 10 commits into
mainfrom
nwparker/agint-mimo-home-overlay
Oct 26, 2026
Merged

nwparker merged 10 commits into
mainfrom
nwparker/agint-mimo-home-overlay

Conversation

@nwparker

@nwparker nwparker commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​148 $\color{#cf222e}{\Huge{\mathbf{−}}}$​62 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​86
Prod 11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​163 $\color{#cf222e}{\Huge{\mathbf{−}}}$​83 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​80

ELI5

To add its status plugin, Orca pointed MiMo Code at a whole replacement home folder. That folder also replaced where MiMo keeps your login (auth.json), sessions and history. So MiMo started inside Orca without your credentials, and requests failed with 401. Now Orca adds one extra config folder that holds only its plugin. Your login, sessions, config and plugins stay where MiMo normally keeps them.

What Changed

  • MimoCodeHookService.buildPtyEnv now returns MIMOCODE_CONFIG_DIR=<userData>/mimocode-hooks/config instead of MIMOCODE_HOME=<userData>/mimocode-hooks/shared. That directory holds only plugins/orca-mimocode-status.js. No data/, cache/ or state/ is created, and user config is not mirrored, because MiMo still loads its normal config dir.
  • If the user already sets MIMOCODE_CONFIG_DIR, Orca mirrors that dir into a per-source overlay and adds its plugin there. A symlinked plugins/ folder is mirrored entry by entry, so Orca's file never lands in the user's folder. This folds in the fix from fix: preserve user plugins behind linked MiMo configuration #23203.
  • Spawn env (host-env/assembly.ts) records and restores ORCA_MIMOCODE_CONFIG_DIR / ORCA_MIMOCODE_SOURCE_CONFIG_DIR the same way OpenCode's overlay does. It also strips an older build's MIMOCODE_HOME overlay (ORCA_MIMOCODE_HOME markers) from nested panes. A user's own MIMOCODE_HOME is left alone.
  • Carry-over from main. A login made only inside Orca under main lived in <userData>/mimocode-hooks/shared/data/auth.json. On a MiMo launch, if MiMo's normal data dir ($MIMOCODE_HOME/data, else $XDG_DATA_HOME/mimocode, else ~/.local/share/mimocode) has no auth.json, Orca moves the old one across once:
    • The copy uses COPYFILE_EXCL, so it never overwrites, and gets mode 0600.
    • The old file is then renamed to auth.json.migrated. This also happens without copying when MiMo already has its own auth.json. Either way, the Orca-only login is never restored later, even if the user deletes the normal one.
    • The old folder is otherwise left in place.
    • A relative MIMOCODE_HOME is skipped, because MiMo rejects relative paths.
  • Sessions/history are not carried over. MiMo keeps them in one SQLite DB, mimocode.db (plus -wal/-shm). Any mimo command, even mimo debug paths, creates that DB, so "the normal store is empty" can't be detected reliably. Merging two DBs isn't safe either. Orca-only sessions from main stay readable under <userData>/mimocode-hooks/shared/data, and can be reached with MIMOCODE_HOME=<userData>/mimocode-hooks/shared mimo.
  • A user's own MIMOCODE_CONFIG_DIR overlay is re-mirrored using the OpenCode overlay manifest instead of being wiped on every launch. This keeps the node_modules/package.json that MiMo installs into config dirs. An explicit per-pane MIMOCODE_CONFIG_DIR beats inherited markers (preserveExplicitPrimary, as for OpenCode). The MiMo marker keys are also dropped with the OpenCode ones in getInheritedAgentHookEnvKeysToDelete.
  • The shell wrappers (bash, zsh, PowerShell; local and daemon) now restore MIMOCODE_CONFIG_DIR after user rc files instead of MIMOCODE_HOME.

Why

MiMo Code (@mimo-ai/cli 0.1.15, darwin-arm64 binary, probed in a temp HOME):

Env mimo debug paths data mimo auth list (placeholder auth.json in the canonical data dir) Orca plugin loaded (mimo debug config) User mimocode.json model
MIMOCODE_HOME=<Orca overlay> (main) <overlay>/data 0 credentials (reads <overlay>/data/auth.json) yes n/a
MIMOCODE_CONFIG_DIR=<Orca plugin dir> (this PR) ~/.local/share/mimocode 1 credential yes (plugin_origins.source = <Orca dir>) kept (openai/agint-user-model)

Like OpenCode's OPENCODE_CONFIG_DIR, MIMOCODE_CONFIG_DIR adds a config layer: global config and user plugins load alongside it. This matches the reporter's root-cause analysis in #9132.

#9133 does the same env switch but adds about 1.4k lines of ownership records and per-PTY hashing. This PR reuses the existing overlay-mirror helpers instead. It changes 78 production lines.

Linked Issue

Fixes #9132

Visual Proof

N/A. This is environment and config plumbing with no UI change.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated

  • Carry-over, run with env -i and a temp HOME: put a placeholder auth.json only in the old shared overlay, then ran this branch's carryOverLegacyAuth + buildPtyEnv.

    • The file appeared at ~/.local/share/mimocode/auth.json with mode -rw-------, and mimo auth list showed 1 credential.
    • After mimo ran, the overlay held node_modules, package.json, package-lock.json and .gitignore. All four survived the next launch's re-mirror.
  • Real CLI, macOS:

    • Built the env with this branch's MimoCodeHookService against a temp userData.
    • Ran mimo 0.1.15 with env -i and a temp HOME, which gave the table above.
    • No model request was made.
  • pnpm test src/main/ipc src/main/providers src/main/daemon/pty-subprocess src/main/mimo src/main/opencode passes.

  • pnpm tc and check:code-quality:changed are clean.

  • Not run: a full prompt turn showing /hook/mimo-code status. The plugin source is unchanged; only where it loads from moved.

  • Already failing on main: src/main/daemon/shell-ready.test.ts has 4 fish/zsh timeouts that fail identically on main on this machine.

Review

Risk is low to medium.

  • Panes launched before upgrading keep their old env until restarted.
  • Shell rc restore keys are renamed. A daemon running an older version restores MIMOCODE_HOME only if ORCA_MIMOCODE_HOME is set, and new builds no longer set it, so the worst case is no restore after user rc files. That is the same as a non-wrapped shell.
  • SSH and WSL still get no MiMo overlay, as on main.
  • Trade-off vs main: Orca no longer gives MiMo a separate data/state dir. MiMo sessions launched from Orca now share history with the user's normal MiMo sessions, which is the intended behaviour.

Co-authored-by: BluesYoung-web [email protected]

…MIMOCODE_HOME

MIMOCODE_HOME moves MiMo's data, cache and state too, so an Orca-launched
mimo lost the canonical auth.json and failed with 401. MIMOCODE_CONFIG_DIR
is an extra config layer: user config, plugins and auth stay where they are.
A user's own MIMOCODE_CONFIG_DIR is mirrored, never linked through, and an
older build's MIMOCODE_HOME overlay is dropped from nested panes.

Fixes #9132

Co-authored-by: BluesYoung-web <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

MiMo hook setup now applies a config-directory overlay instead of redirecting MIMOCODE_HOME. The host environment resolves the source config directory, restores or removes inherited overlay variables, and carries legacy auth to MiMo’s data directory when needed. Bash, zsh, and PowerShell startup code now restores MIMOCODE_CONFIG_DIR from ORCA_MIMOCODE_CONFIG_DIR. Tests cover overlay construction, host environment handling, auth copying, and shell restoration.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Moderate · up to 8927b

MiMo launches can read auth and sessions from the wrong directory when an older pane left overlay markers behind. WSL MiMo launches will not load the Orca plugin overlay. Fix these and the earlier open typecheck and overlay-sharing concerns before merging.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Linked Issues check Warning Issue [#9132] native config-only injection is implemented. MimoCodeHookService.buildPtyEnv sets MIMOCODE_CONFIG_DIR, preserves the source config through a manifest overlay, and falls back to the s… Implement MiMo config-overlay materialization inside the WSL and SSH execution hosts. Add PTY-safe overlay ownership or synchronization so one PTY cannot replace another PTY's active overlay. Add automated tests that verify canonical auth v…
Docstring Coverage Warning Docstring coverage is 23.08% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 20 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: preserving MiMo login and sessions by injecting the status plugin through MIMOCODE_CONFIG_DIR.
Description check Passed The description is complete and focused. It explains the user impact, implementation, rationale, linked issue, testing, platform scope, limitations, and known failures.
Out of Scope Changes check Passed The changed production code supports Issue [#9132]. Config-only MiMo injection, config mirroring, symlink-safe plugin handling, legacy-auth compatibility, inherited-environment cleanup, and shell-wrap…
Full details: Out of Scope Changes check

Explanation

The changed production code supports Issue [#9132]. Config-only MiMo injection, config mirroring, symlink-safe plugin handling, legacy-auth compatibility, inherited-environment cleanup, and shell-wrapper restoration all support the issue's ownership and migration requirements. The related tests validate these changes. No unrelated production change is demonstrated.

Full details: Linked Issues check

Explanation

Issue [#9132] native config-only injection is implemented. MimoCodeHookService.buildPtyEnv sets MIMOCODE_CONFIG_DIR, preserves the source config through a manifest overlay, and falls back to the source directory on setup failure. buildPtyHostEnv restores user MIMOCODE_HOME and config values. The remaining coding requirements are unmet. The MiMo service uses the local app userData path, and the WSL path adds only OpenCode guest materialization. The PR states that WSL and SSH receive no MiMo overlay, so target-host materialization is absent. buildPtyEnv ignores _ptyId and uses a shared or source-derived overlay, so the code does not establish that separate PTYs cannot replace one another's active overlays. The tests cover legacy-auth migration and environment variables, but do not cover canonical auth visibility and first-login/writeback.

Resolution

Implement MiMo config-overlay materialization inside the WSL and SSH execution hosts. Add PTY-safe overlay ownership or synchronization so one PTY cannot replace another PTY's active overlay. Add automated tests that verify canonical auth visibility and first-login/writeback, in addition to the existing legacy-auth tests.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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 and others added 2 commits October 25, 2026 16:18
… files

Older builds kept MiMo data under <userData>/mimocode-hooks/shared, so a
login made only inside Orca would vanish after the switch. Copy that
auth.json into MiMo's normal data dir once (owner-only, never overwriting).
Re-mirror a user's MIMOCODE_CONFIG_DIR by manifest so plugin deps MiMo
installs in the overlay survive launches, preserve an explicit pane value,
and drop inherited MiMo overlay markers like OpenCode's.

Co-authored-by: BluesYoung-web <[email protected]>

@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
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ba694618-a559-47d2-8254-ea0423d090b5
Commits

Reviewing files that changed from the base of the PR and between 1b0e56e and ce63081.

Files selected for processing: 26
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-bash-rcfile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zshenv.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-bash-rcfile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zshenv.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/relay-bash-rcfile.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/relay-zsh-zshenv.txt
  • src/main/daemon/daemon-bash-shell-ready-rcfile.ts
  • src/main/daemon/pty-subprocess-managed-agent-env.test.ts
  • src/main/daemon/pty-subprocess-test-harness.ts
  • src/main/daemon/shell-ready.test.ts
  • src/main/ipc/pty-ipc-mock-registry.ts
  • src/main/ipc/pty-ipc-suite-environment.ts
  • src/main/ipc/pty/host-env/assembly.ts
  • src/main/ipc/pty/host-env/pi-agent.ts
  • src/main/ipc/pty/pty-spawn-env-agent-overlays.test.ts
  • src/main/mimo/hook-service.test.ts
  • src/main/mimo/hook-service.ts
  • src/main/powershell-osc133-bootstrap.test.ts
  • src/main/powershell-osc133-bootstrap.ts
  • src/main/providers/local-pty-provider-spawn-env.test.ts
  • src/main/providers/local-pty-shell-ready-bash-rcfile.ts
  • src/main/providers/local-pty-shell-ready-wrapper-generation.test.ts
  • src/main/providers/windows-shell-args.test.ts
  • src/main/shell-startup-features.ts
  • src/main/shell-wrapper-generated-file-snapshot.test.ts
  • src/main/zsh-startup-wrapper-builder.ts

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


export const mimoHookServiceModuleMock = () => ({
mimoCodeHookService: {
carryOverLegacyAuth: vi.fn(),

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.

Major · Functional Correctness · Quick win

Add an explicit type to the carryOverLegacyAuth spy. The typecheck step fails in CI.

The pipeline reports TS2883 at line 125. The inferred return type of mimoHookServiceModuleMock now includes a bare vi.fn(). TypeScript cannot name that type without Vitest's internal Procedure type. The typecheck:ci step exits with code 1, so this change blocks the build.

buildPtyEnv does not have this problem because it references mimoCodeBuildPtyEnvMock, which is annotated as Mock at line 26. Give the new spy the same annotation.

🐛 Proposed fix
--- "a/src/main/ipc/pty-ipc-mock-registry.ts"
+++ "b/src/main/ipc/pty-ipc-mock-registry.ts"
@@ -124,7 +124,7 @@
 
 export const mimoHookServiceModuleMock = () => ({
   mimoCodeHookService: {
-    carryOverLegacyAuth: vi.fn(),
+    carryOverLegacyAuth: vi.fn() as Mock,
     buildPtyEnv: mimoCodeBuildPtyEnvMock
   }
 })

An alternative is to annotate the factory's return type explicitly, for example (): { mimoCodeHookService: Record<string, Mock> } =>.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
carryOverLegacyAuth: vi.fn(),
carryOverLegacyAuth: vi.fn() as Mock,

Source: Pipeline failures

@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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Minor · Make the plugin overlay write atomic when several MiMo PTYs share one… · hook-service.ts:89-94

src/main/mimo/hook-service.ts:89-94
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Make the plugin overlay write atomic when several MiMo PTYs share one source config.

Each PTY launch that uses the same source config rewrites plugins/orca-mimocode-status.js in place. writeFileSync truncates the file before it writes the new content. A launch that starts while another launch reads that file can read an empty or partial plugin. Write the new content to a temporary file, then rename it over the target.

🐛 Suggested fix
-      writeFileSync(
-        join(pluginsDir, ORCA_MIMOCODE_PLUGIN_FILE),
-        getOpenCodeFamilyPluginSource('/hook/mimo-code', { emitSessionStart: false })
-      )
+      const pluginPath = join(pluginsDir, ORCA_MIMOCODE_PLUGIN_FILE)
+      const tmpPath = `${pluginPath}.${process.pid}.${Date.now()}.tmp`
+      writeFileSync(
+        tmpPath,
+        getOpenCodeFamilyPluginSource('/hook/mimo-code', { emitSessionStart: false })
+      )
+      renameSync(tmpPath, pluginPath)

The rename keeps the per-source overlay design. On Windows, a rename can fail while another process holds the target open. The existing catch then returns the fallback, so the launch continues without the new overlay.


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5c25ec8a-bc6d-412a-9ba2-4fdf467731d8
Commits

Reviewing files that changed from the base of the PR and between ce63081 and eb14fee.

Files selected for processing: 2
  • src/main/mimo/hook-service.test.ts
  • src/main/mimo/hook-service.ts

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

Comment thread src/main/mimo/hook-service.ts Resolved

@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: 3


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: eebff553-0d22-4a0f-bb17-874e9e748801
Commits

Reviewing files that changed from the base of the PR and between cf5ad02 and 8927bfc.

Files selected for processing: 2
  • src/main/ipc/pty/host-env/assembly.ts
  • src/main/ipc/pty/host-env/pi-agent.ts

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

Comment on lines +104 to +108
restoreOrStripOverlayEnv(baseEnv, {
primary: 'MIMOCODE_HOME',
overlay: 'ORCA_MIMOCODE_HOME',
source: 'ORCA_MIMOCODE_SOURCE_HOME'
})

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.

Major · Data Integrity & Integration · Quick win

🔎 Supported by static analysis

Script executed:

rg -n 'restoreOrStripOverlayEnv' src/main
sed -n '90,135p' src/main/ipc/pty/host-env/assembly.ts

Repository: stablyai/orca

Length of output: 2995


Script executed:

sed -n '1,220p' src/shared/agent-overlay-env.ts
rg -n -F --glob '*.ts' -e 'preserveExplicitPrimary' -e 'restoreOrStripOverlayEnv(' src/main src/shared

Repository: stablyai/orca

Length of output: 2230


Preserve explicit MiMo directories when clearing legacy markers.

restoreOrStripOverlayEnv restores sourceValue whenever a source marker exists unless preservePrimary is true. The MIMOCODE_HOME call does not enable that option, so an explicit home can be replaced. The config-directory call enables it, but the helper only preserves the explicit value when an overlay marker also exists. A source-only marker can still replace an explicit config directory.

Suggested fix
   const preservePrimary =
     keys.preserveExplicitPrimary &&
-    Boolean(overlayValue) &&
     baseEnv[keys.primary] !== undefined &&
     baseEnv[keys.primary] !== overlayValue
   restoreOrStripOverlayEnv(baseEnv, {
     primary: 'MIMOCODE_HOME',
     overlay: 'ORCA_MIMOCODE_HOME',
-    source: 'ORCA_MIMOCODE_SOURCE_HOME'
+    source: 'ORCA_MIMOCODE_SOURCE_HOME',
+    preserveExplicitPrimary: true
   })

Comment on lines +116 to +120
if (opts.agentStatusHooksEnabled && isMimoLaunchCommand(launchCommandHint)) {
mimoCodeHookService.carryOverLegacyAuth({ ...process.env, ...baseEnv })
const overlay = mimoCodeHookService.buildPtyEnv(id, mimoSourceConfigDir).MIMOCODE_CONFIG_DIR
if (overlay && overlay !== mimoSourceConfigDir) {
baseEnv.MIMOCODE_CONFIG_DIR = overlay

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.

Major · Functional Correctness · Heavy lift

🔎 Supported by static analysis

Script executed:

#!/bin/bash
# Inspect WSL launch classification and MiMo environment transfer without running repository code.
rg -n -C 4 'buildPtyHostEnv\(|isMimoLaunchCommand\(|MIMOCODE_CONFIG_DIR|isWsl:' \
  src/main/ipc/pty src/main/providers src/main/mimo

Repository: stablyai/orca

Length of output: 41747


Script executed:

set -eu
printf '%s\n' '--- buildPtyHostEnv signature and MiMo branch ---'
nl -ba src/main/ipc/pty/host-env/assembly.ts | sed -n '40,135p'
printf '%s\n' '--- WSL provider call chain ---'
nl -ba src/main/providers/local-pty-spawn-environment.ts | sed -n '1,80p'
rg -n -C 5 -F -- 'buildPtyHostEnv(' src/main/ipc/pty src/main/providers
printf '%s\n' '--- WSL environment transfer and path translation references ---'
rg -n -C 6 -e 'WSLENV' -e 'MIMOCODE_CONFIG_DIR' -e 'wslDistro' -e 'isWsl' src/main/ipc/pty src/main/providers src/shared | head -n 1000
printf '%s\n' '--- changed file diff against supplied merge base ---'
git diff --no-ext-diff --unified=25 1ff73e808d9e38a16f5e372b015ad312fe801c11 8927bfcfbc8d6eca6490760e416d86c659c5a184 -- src/main/ipc/pty/host-env/assembly.ts src/main/providers/local-pty-spawn-environment.ts src/main/ipc/pty

Repository: stablyai/orca

Length of output: 42247


Script executed:

set -eu
printf '%s\n' '--- exact MIMOCODE_CONFIG_DIR and WSLENV ownership ---'
rg -n -F --glob '*.{ts,tsx}' -e 'MIMOCODE_CONFIG_DIR' -e 'WSLENV' src/main src/shared
printf '%s\n' '--- host environment construction ---'
nl -ba src/main/ipc/pty/spawn-host-env.ts | sed -n '180,255p'
printf '%s\n' '--- local provider spawn implementation references ---'
rg -n -C 8 -e 'spawn\\(' -e 'wsl.exe' -e 'launchWslDistro' -e 'plan.isWslShell' src/main/providers src/main/ipc/pty | head -n 700
printf '%s\n' '--- WSL environment helper definitions ---'
rg -n -C 12 -e 'function .*Wsl' -e 'WSLENV' -e 'toWsl' -e 'wsl.*Env' src/main src/shared | head -n 1000

Repository: stablyai/orca

Length of output: 41556


Script executed:

set -eu
printf '%s\n' '--- WSL carrier helper ---'
nl -ba src/main/pty/wsl-orca-env.ts | sed -n '1,155p'
printf '%s\n' '--- WSL carrier call sites ---'
rg -n -C 10 -e 'apply.*Wsl' -e 'wsl-orca-env' -e 'ORCA_OPENCODE_CONFIG_DIR/u' -e 'ORCA_OMP_STATUS_EXTENSION' src/main src/shared
printf '%s\n' '--- Windows local PTY spawn environment ---'
nl -ba src/main/providers/local-pty-windows-spawn-environment.ts | sed -n '1,150p'
printf '%s\n' '--- host environment tail after MiMo branch ---'
nl -ba src/main/ipc/pty/host-env/assembly.ts | sed -n '128,230p'
printf '%s\n' '--- OMP WSL environment helper ---'
nl -ba src/main/ipc/pty/host-env/omp-launch-environment.ts | sed -n '1,100p'

Repository: stablyai/orca

Length of output: 42410


Script executed:

set -eu
rg -n -C 12 -F -- 'addOrcaWslInteropEnv' src/main/daemon/pty-subprocess src/main/providers src/main

Repository: stablyai/orca

Length of output: 42315


Do not inject the host MiMo overlay into WSL.

A WSL mimo launch can enter this branch. The WSL carrier does not forward MIMOCODE_CONFIG_DIR or ORCA_MIMOCODE_CONFIG_DIR, so the guest receives neither the plugin overlay nor the mirrored host config. Build a guest-resident overlay and pass it with /u, or skip the host overlay for WSL and leave the guest config unchanged.

Source: Coding guidelines

Comment on lines +140 to +141
'ORCA_MIMOCODE_CONFIG_DIR',
'ORCA_MIMOCODE_SOURCE_CONFIG_DIR'

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.

Minor · Functional Correctness · Quick win

🔎 Supported by static analysis

Script executed:

rg -n 'restoreOrStripOverlayEnv|getInheritedAgentHookEnvKeysToDelete|resolveMimocodeSourceConfigDir' src/main
sed -n '60,180p' src/main/ipc/pty/host-env/assembly.ts

Repository: stablyai/orca

Length of output: 7718


Script executed:

set -o pipefail
printf '%s\n' '--- agent-overlay-env references ---'
rg -n -F --glob '*.ts' -e 'export function restoreOrStripOverlayEnv' -e 'restoreOrStripOverlayEnv' -e 'MIMOCODE_CONFIG_DIR' src/shared src/main/ipc/pty src/main/daemon | sed -n '1,240p'
printf '%s\n' '--- helper implementation ---'
rg -n -F --glob '*.ts' -- 'export function restoreOrStripOverlayEnv' src/shared
helper=$(rg -l -F --glob '*.ts' -- 'export function restoreOrStripOverlayEnv' src/shared | head -n 1)
if [ -n "$helper" ]; then
  sed -n '1,180p' "$helper"
fi
printf '%s\n' '--- pi-agent block ---'
sed -n '110,190p' src/main/ipc/pty/host-env/pi-agent.ts
printf '%s\n' '--- assembly relevant blocks ---'
sed -n '80,135p' src/main/ipc/pty/host-env/assembly.ts
sed -n '190,235p' src/main/ipc/pty/host-env/assembly.ts
printf '%s\n' '--- ambient merge and call sites ---'
rg -n -F --glob '*.ts' -e '...process.env' -e 'Object.assign(baseEnv' -e 'baseEnv = {' -e 'spawnEnv' src/main/ipc/pty/host-env src/main/ipc/pty | sed -n '1,260p'
printf '%s\n' '--- relevant tests ---'
rg -n -F --glob '*test*.ts' -e 'resolveMimocodeSourceConfigDir' -e 'ORCA_MIMOCODE_CONFIG_DIR' -e 'MIMOCODE_CONFIG_DIR' src/main src/shared | sed -n '1,260p'

Repository: stablyai/orca

Length of output: 19949


Script executed:

set -o pipefail
printf '%s\n' '--- spawn environment assembly ---'
sed -n '1,155p' src/main/ipc/pty/ipc/spawn-env.ts
printf '%s\n' '--- spawn options assembly ---'
sed -n '1,95p' src/main/ipc/pty/spawn-options-assembly.ts
printf '%s\n' '--- local provider ambient merge ---'
rg -n -F --glob '*.ts' -e 'getInheritedAgentHookEnvKeysToDelete' -e 'process.env' -e 'envToDelete' src/main/providers src/main/ipc/pty | sed -n '1,260p'
printf '%s\n' '--- overlay tests ---'
sed -n '230,350p' src/main/ipc/pty/pty-spawn-env-agent-overlays.test.ts
printf '%s\n' '--- all direct cleanup assignments ---'
rg -n -F --glob '*.ts' -e 'delete baseEnv.MIMOCODE_CONFIG_DIR' -e 'delete env.MIMOCODE_CONFIG_DIR' -e 'MIMOCODE_CONFIG_DIR: undefined' -e 'MIMOCODE_CONFIG_DIR' src/main/ipc/pty src/main/providers src/shared | sed -n '1,260p'

Repository: stablyai/orca

Length of output: 41602


Script executed:

set -o pipefail
printf '%s\n' '--- local provider environment builder ---'
sed -n '1,125p' src/main/providers/local-pty-spawn-environment.ts
printf '%s\n' '--- host assembly invocation and environment inputs ---'
rg -n -F --glob '*.ts' -e 'assemblePtyHostEnv' -e 'assemblePtyHostEnvironment' -e 'assemblePtyIpcSpawnEnv' -e 'baseEnv' src/main/ipc/pty | sed -n '1,240p'
printf '%s\n' '--- MiMo overlay test setup and helper ---'
sed -n '1,120p' src/main/ipc/pty/pty-spawn-env-agent-overlays.test.ts
sed -n '120,235p' src/main/ipc/pty/pty-spawn-env-agent-overlays.test.ts
printf '%s\n' '--- direct MIMOCODE cleanup outside inspected helper ---'
rg -n -F --glob '*.ts' -e 'delete process.env.MIMOCODE_CONFIG_DIR' -e 'delete baseEnv.MIMOCODE_CONFIG_DIR' -e 'delete env.MIMOCODE_CONFIG_DIR' -e 'delete inheritedEnv.MIMOCODE_CONFIG_DIR' -e 'MIMOCODE_CONFIG_DIR' src/main/providers/local-pty-spawn-environment.ts src/main/ipc/pty/host-env src/main/ipc/pty/runtime src/main/ipc/pty/ipc

Repository: stablyai/orca

Length of output: 30951


Script executed:

set -o pipefail
printf '%s\n' '--- daemon PTY environment merge ---'
sed -n '1,125p' src/main/daemon/pty-subprocess/spawn-environment.ts
printf '%s\n' '--- daemon managed-agent environment tests ---'
sed -n '120,190p' src/main/daemon/pty-subprocess-managed-agent-env.test.ts
printf '%s\n' '--- daemon host spawn deletion flow ---'
sed -n '1,90p' src/main/ipc/pty/runtime/spawn-options.ts
sed -n '145,210p' src/main/ipc/pty/spawn-host-env.ts

Repository: stablyai/orca

Length of output: 13218


Script executed:

sed -n '120,270p' src/main/daemon/pty-subprocess/spawn-environment.ts

Repository: stablyai/orca

Length of output: 4742


Strip the inherited public config path with an orphaned overlay marker.

For daemon or remote launches with a sparse baseEnv, remove MIMOCODE_CONFIG_DIR when it is inherited and matches ORCA_MIMOCODE_CONFIG_DIR. Preserve an explicit pane value.

The daemon merges process.env before applying envToDelete. Add the public key to the inherited cleanup list. Its existing env[key] === undefined filter preserves explicit pane values.

🐛 Suggested fix
--- "a/src/main/ipc/pty/host-env/pi-agent.ts"
+++ "b/src/main/ipc/pty/host-env/pi-agent.ts"
@@ -136,9 +136,10 @@
     'ORCA_CLAUDE_CONFIG_DIR',
     'ORCA_OPENCODE_AGENT',
     'ORCA_OPENCODE_CONFIG_DIR',
     'ORCA_OPENCODE_SOURCE_CONFIG_DIR',
     'ORCA_MIMOCODE_CONFIG_DIR',
-    'ORCA_MIMOCODE_SOURCE_CONFIG_DIR'
+    'ORCA_MIMOCODE_SOURCE_CONFIG_DIR',
+    'MIMOCODE_CONFIG_DIR'
   ].filter((key) => env[key] === undefined)
 }
 
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
'ORCA_MIMOCODE_CONFIG_DIR',
'ORCA_MIMOCODE_SOURCE_CONFIG_DIR'
'ORCA_MIMOCODE_CONFIG_DIR',
'ORCA_MIMOCODE_SOURCE_CONFIG_DIR',
'MIMOCODE_CONFIG_DIR'

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]: MiMo agent home overlay hides canonical auth and runtime data

1 participant