Skip to content

fix(zsh): keep deferred line-init defined for plugins that wrap it by name - #26157

Closed
petersindex wants to merge 1 commit into
stablyai:mainfrom
petersindex:petersindex/fix-zsh-deferred-line-init
Closed

petersindex wants to merge 1 commit into
stablyai:mainfrom
petersindex:petersindex/fix-zsh-deferred-line-init

Conversation

@petersindex

@petersindex petersindex commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #26029

ELI5

When Orca starts a zsh terminal, it installs a small temporary startup helper and deletes it once startup finishes. Some zsh plugins (like zimfw/input) copy a call to that helper into their own code. Orca's "is anything still using this?" check couldn't see that, so it deleted the helper anyway, and every prompt printed command not found: __orca_deferred_line_init. Now Orca keeps the helper. After startup it returns immediately, so keeping it is harmless.

What changed

  • Removed the widget scan + unfunction __orca_deferred_line_init from the deferred-init cleanup block in src/main/zsh-deferred-startup-line-init.ts
  • Updated the local, daemon and relay zsh wrapper snapshots (each diff is only the 8 removed lines)
  • Added a live-shell regression test using a zimfw/input-style wrapper that calls the line-init by name
  • Dropped the old O_IR assertion, which checked that the helper had been deleted (the behaviour this PR removes on purpose)

Why this over the alternative

I considered keeping the cleanup and also scanning ${functions[@]} bodies for the name. That still misses calls held in eval strings or variables, would have to exclude Orca's own functions (which contain the name), and adds work to the first prompt on frameworks with hundreds of functions. The scan has already been patched once (for the add-zle-hook-widget alias), and zimfw is a second miss. Leaving one inert function defined closes the whole class of bug.

Testing

  • Reproduced in the released app (Orca 1.4.222, macOS, zsh 5.9) with zimfw/input at bdec2b3: the error prints at every prompt.
  • Verified the fix in Orca Dev built from this branch, with the same plugin loaded: clean prompts. In that shell _start_application_mode still contains the __orca_deferred_line_init call and zle-line-init is bound to it, so the plugin really was active.
  • New regression test fails on main with the exact error from the issue and passes with the fix. The zsh live-shell suites and wrapper snapshot test pass (70/70).
  • pnpm typecheck and pnpm lint pass.
  • Full pnpm test locally: 279 unrelated files fail because node:sqlite is unavailable in my local runtime (Node 25; the repo pins 24) and Electron APIs are missing under the Bun runner. I reran exactly those files on unmodified main and the identical 279 fail, with none unique to this branch.

Screenshots

Before (Orca Dev on main):
before

After (Orca Dev on this branch):
after

AI review

  • Cross-platform: zsh-only wrapper code; no effect on bash, fish or PowerShell; applies the same way to local, daemon and SSH relay wrappers
  • Performance: removes a loop over all widgets at startup; one no-op function stays defined
  • Security: no new inputs or execution paths; the function's guard returns immediately after init
  • UI: none beyond removing the error line
  • Agents and integrations: zsh panes only. It applies the same way to every agent running in a zsh pane, because the wrapper runs before any agent starts and has no agent-specific code.

X: @petersindex

… name

zimfw/input chains zle-line-init by splicing the bound function's name
into its own body. In an Orca pane that name is __orca_deferred_line_init,
and the deferred init deleted it once no widget pointed at it, so every
prompt printed "command not found: __orca_deferred_line_init".

Leave the function defined. Its guard returns immediately once
__orca_deferred_init is gone, so keeping it changes nothing else.

Fixes stablyai#26029
@petersindex
petersindex force-pushed the petersindex/fix-zsh-deferred-line-init branch from fd64fe8 to 76fd16a Compare October 7, 2026 09:03
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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: 1fc455ad-6fd9-4942-86e6-21bf79e63b0a
📥 Commits

Reviewing files that changed from the base of the PR and between e6bcc5a and 76fd16a.

📒 Files selected for processing (5)
  • src/main/__fixtures__/shell-wrapper-snapshots/daemon-zsh-zshenv.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/local-zsh-zshenv.txt
  • src/main/__fixtures__/shell-wrapper-snapshots/relay-zsh-zshenv.txt
  • src/main/zsh-deferred-startup-line-init.live-shell.test.ts
  • src/main/zsh-deferred-startup-line-init.ts
💤 Files with no reviewable changes (3)
  • src/main/fixtures/shell-wrapper-snapshots/daemon-zsh-zshenv.txt
  • src/main/fixtures/shell-wrapper-snapshots/local-zsh-zshenv.txt
  • src/main/fixtures/shell-wrapper-snapshots/relay-zsh-zshenv.txt

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


📝 Walkthrough

Walkthrough

The Zsh deferred cleanup no longer scans widget bindings or removes __orca_deferred_line_init. The shell-wrapper snapshots and live-shell tests reflect this change. A new PTY test checks that a plugin wrapper runs across two prompts without a “command not found” message.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 76fd1

The change addresses the repeated zsh prompt error without an identified merge-blocking risk. Normal validation remains appropriate before merging.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue [#26029] requires stopping repeated command not found: __orca_deferred_line_init errors when a plugin calls the helper by name. The cleanup block no longer removes __orca_deferred_line_init,…
Out of Scope Changes check ✅ Passed All changes support issue [#26029]. The source change preserves the helper, the wrapper snapshots verify generated output, and the live-shell test covers the reported plugin behavior. Removing the old…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Title check ✅ Passed The title clearly and concisely describes the primary change: keeping the deferred zsh line-init helper defined for plugins that reference it by name.
Description check ✅ Passed The description is mostly complete. It includes the issue link, ELI5 explanation, changes, rationale, testing details, regression coverage, and before/after screenshots. Some template sections such as…
  • Autopilot · 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 added a commit that referenced this pull request Oct 9, 2026
Records the retained adapted contribution from #26157 in replacement PR #26842.

Co-authored-by: petersindex <[email protected]>
@petersindex

Copy link
Copy Markdown
Contributor Author

closing this one. #26842 fixed the same zsh line-init issue, so mine's not needed.

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]: zsh prints "command not found: __orca_deferred_line_init" at every prompt with zimfw/input

1 participant