Skip to content

feat(agents): add first-class Muse Code harness - #22216

Merged
nwparker merged 13 commits into
stablyai:mainfrom
nwparker:muse-harness-2
Sep 23, 2026
Merged

nwparker merged 13 commits into
stablyai:mainfrom
nwparker:muse-harness-2

Conversation

@nwparker

@nwparker nwparker commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Orca now treats Muse Code like its other supervised coding agents. You can launch Muse from the agent picker. Its questions, approval prompts, notifications, working/waiting/done state, history, resume, hooks and Source Control flows all appear in the same Orca places as other agents.

What Changed

  • Added Muse as a built-in agent across desktop, mobile, config, telemetry, permissions, localization, docs and the bundled icon.
  • Launches Muse 1.3 with the workspace trusted, and sends the prompt only after the terminal UI is ready. That way a prompt that happens to be a subcommand name, such as exec or resume, is still typed as a prompt.
  • Recognizes Muse's versioned muse-bin-* process, and keeps one-shot muse exec runs out of interactive status.
  • Muse status comes from structured signals only; Orca never reads the terminal screen for it:
    • Hooks: Muse's Claude-style hook events drive working and done.
    • Approvals: Muse's Notification event with type permission_prompt drives waiting for approval. PermissionRequest also fires for calls Muse approves on its own, so Orca only uses it to fill in the approval card (tool name and command).
    • Questions: Muse 1.3 sends no hook while its request_user_input question tool waits. Orca instead reads the question from Muse's session log (user_input_prompt_requested / user_input_prompt_settled in ~/.local/share/muse/sessions/YYYY/MM/DD/<session>/session.jsonl). The existing once-a-second Codex transcript poll now also serves Muse and runs on the machine where Muse runs, including over SSH and WSL. The pane shows waiting with the question card, then working once you answer.
    • Background helpers: Muse runs internal reminder helpers under their own session ids, and their hooks fire even after Muse finishes. Orca ignores them (it learns their ids from SubagentStart; helper events also carry turn_id === session_id). Before this, they produced "tool failed" rows and flipped finished panes back to working.
  • Hook installs don't break Muse settings files that contain comments, replace the file in one step, keep your own keys, set Muse 1.3's managed_hooks_env_vars, and never overwrite a hooks path someone else configured. The allowed variables include USERPROFILE, because Muse removes most environment variables before running a hook, and a Windows cmd startup (AutoRun) script that uses %USERPROFILE% otherwise makes every hook exit 1.
  • Hook and session support for local, WSL, SSH and native Windows hosts. On native Windows Orca uses muse.cmd and generates a hook script that calls curl.exe.
  • Session history scanning (local and remote) and muse resume <session-id>, offered only when the host supports it.
  • Source Control AI uses muse exec with read-only flags and passes the prompt after --.

Why

Adding Muse to the agent list alone would leave questions, approvals, history, resume and remote Windows incomplete, so this follows the same contracts as the other first-class agents. We captured Muse 1.3.0's real hook payloads and found:

  • No hook fires for questions.
  • Hidden helper sessions post hooks with their own session ids.
  • PermissionRequest fires even for calls Muse approves automatically.

Alternatives considered for detecting questions:

  • muse serve publishes proper status updates, but only for sessions it hosts itself, and it can't attach to a terminal session.
  • The model-call hooks (PreLLMCall / PostLLMCall) don't include tool names, and each one is about 34 KB.
  • Reading the terminal screen breaks whenever Muse's layout changes.

The session log is written for every session, has stable fields, and is readable on the machine where Muse runs.

Linked Issue

Related to the community implementation work in #19188, #18791, and #21494.

Visual Proof

Before / launch picker:

Muse search and launch picker

After / Muse running as a first-class agent:

Muse picker entry and running TUI

Muse ready screen

Muse request_user_input question

Orca waiting state

Orca waiting metadata

Muse completion state

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Manual, macOS dev build (Muse 1.3.0, 1.3.0-R3401.1):

  • A question showed waiting with the question card in the sidebar, went back to working after the answer, then done. It was still done 40 seconds after Muse finished, while its helpers were still firing hooks.
  • A command approval showed waiting as "bash: mkdir -p …", then working after approval.

Manual, Windows (awin):

  • Muse runs hook commands through cmd.exe /c, keeping SystemRoot, ComSpec and Path, and the generated hook script and curl.exe run.
  • Adding USERPROFILE to the allowed variables changed hook runs from failed exit=1 to completed exit=0 on a host whose cmd AutoRun script uses it.
  • Not confirmed: that hook events reach an Orca instance on awin, because the Orca running there doesn't include this branch.

Automated:

  • Added tests that use the captured Muse 1.3.0 payloads, covering:
    • helper-session filtering,
    • the approval flow,
    • finding and incrementally reading the session log,
    • the main-side poll flipping working → waiting → working.
  • pnpm tc and the changed-code quality gate pass. The agent-hook, relay, Muse and ai-vault suites pass: 4,519 tests.

AI Disclosure

OpenAI Codex and Anthropic Claude assisted with implementation, validation, and this pull request description.

Review

The requested community PRs were reviewed directly:

  • #19188 by homesh-dev provided most of the overall structure: hooks, history/resume and Source Control patterns.
  • #18791 by jeffhuen and John Cusack provided the starting point for the agent entry, permissions, mobile, icon and docs.
  • #21494 by adriendeoliveira provided the readiness checks, versioned process recognition and headless behavior.

None of them handled Muse questions. #21494 read the terminal screen, which this PR avoids. Muse behavior was checked against muse --help, the Muse Code documentation, the Muse Code SDK, and captured hook payloads and session logs.

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

  • The session-log check runs on the machine where Muse runs: in Orca's main process for local and native Windows, and in the relay for SSH and WSL. It stops once the pane is done.
  • WSL without the in-distro hook relay gets no question detection, because Orca on Windows can't reach the Linux log.
  • The relay-side poll has no Muse-specific test yet.

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 (CI covers the full suite and build; typecheck, the changed-code gate and the focused suites pass locally)

@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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

📝 Walkthrough

Walkthrough

The pull request adds Muse as an interactive and headless agent. It adds launch, process recognition, permission, resume, commit-message, hook, telemetry, and transcript-polling support. It adds local and remote Muse session scanning with transcript parsing. It adds terminal readiness and idle detection. It updates renderer, mobile, skills, localization, documentation, configuration, and tests.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to c83d9

Muse can show a stale question during a later turn, and several integration inconsistencies remain. Resolve these issues before merging.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.81% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 93 functions across 71 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding first-class Muse Code harness support.
Description check ✅ Passed The description is comprehensive and covers the required sections, user impact, implementation, rationale, testing, visual proof, AI disclosure, platform considerations, and checklist. The Linked Issu…
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.
  • Fix all pre-merge checks with AI

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

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

Important

One red CI test: adding muse to AI_VAULT_AGENTS without a Muse fixture in writeEveryAgentVault fails the every-agent transcript-capture guard, so pnpm test cannot pass. The rest of the harness wiring looks sound — the JSONC editor preserves user content, the readiness lane does not leak into other agents, and the session parser checks out.

Reviewed changes

  • Canonical agent registration — muse threaded through the shared agent registries (tui-agent, kind, labels, telemetry, permissions, selection, skill discovery/install) plus catalog, icon, mobile, i18n, docs, and README.
  • Managed hooks — new src/main/muse/ service with a JSONC-preserving settings.json editor, a generated managed hooks file, POSIX and native-Windows .cmd scripts, and local + SSH SFTP install paths; Claude-compatible events normalized in providers/muse-events.ts.
  • Session history — local and remote Muse transcript parsing (envelope unwrap, microsecond timestamps, intent/run dedupe), date-sharded path resolution, and token/model/branch/cwd extraction; pre-existing remote parsers were extracted to a new remote-session-scanner-source-parsers.ts.
  • Resume — muse resume <id> for AI Vault, a gated agent-session.muse-resume.v1 capability, and the host-authority map entry.
  • Runtime readiness — a dedicated Muse ready-screen lane, since Muse emits no idle OSC title, held to quiescence as tier 1b.
  • Process recognition — versioned muse-bin-* foreground matching and muse exec one-shot filtering.

ℹ️ Nitpicks

  • docs/site/content/docs/agents/supported.mdx:51 lists "macOS/Linux", but this PR adds native Windows hook and session support; reconcile the row with what actually ships.
  • No test covers the Muse pane-resume plan, which builds muse --trust-workspace resume <id> (a flag before the resume subcommand). An AI Vault resume uses muse resume <id>, so a buildAgentResumeStartupPlan('muse', …) test would pin the ordering against the CLI.
  • The hasQuietMuseReadyPrompt doc comment (src/main/runtime/tui-idle-evidence.ts) says a non-Muse scrollback quoting Muse "must not settle its wait", but the agent === null branch does admit that evidence. Either narrow the branch or correct the comment.

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

Comment thread src/shared/ai-vault-types.ts Resolved
diagnosticName: string
): Record<string, unknown> | null {
const errors: ParseError[] = []
const parsed = parseJsonc(text, errors)

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.

parseJsonc reports an InvalidSymbol error for a leading UTF-8 BOM even when it parses the object, so a BOM-prefixed Muse settings.json is treated as malformed and install()/getStatus()/remove() all fail closed — Orca can never install hooks and only reports Could not read Muse settings.json. The sibling JSONC reader strips the BOM first (src/main/agent-hooks/hooks-json-read.ts:17); doing the same here would keep the two readers consistent.

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

Important

Test-only follow-up since the prior review. The four new commits harden the hook, source-control, and skill-picker tests and all five touched test files pass. One item from the prior review is still open: session-transcript-every-agent-capture.test.ts remains red at 7b3f0c2 because the shared every-agent vault still has no Muse fixture (verified by re-running it).

Reviewed changes

  • Remote hook registration coverage — remote-hook-service-installers.test.ts adds museHookService to the service map that guards the remote installer list.
  • Hook command contract coverage — managed-hook-command-contract.test.ts adds local and remote Muse command builders.
  • Count hardening — managed-hook-local-filesystem.test.ts now derives expected installer counts from REMOTE_MANAGED_HOOK_INSTALLER_AGENTS.length instead of a hardcoded 14, and filters managed scripts by .sh/.cmd extension.
  • Contract string and picker coverage — the Source Control unsupported-agent message now asserts Muse, and SkillInstallDialog.test.tsx scopes its provider-button lookup to the detected provider so canonical-root agents cannot break it.

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

nwparker and others added 7 commits September 22, 2026 04:22
Add Muse as a supervised Orca agent across desktop, mobile, session history, source control, local hooks, SSH, WSL, and native Windows. Preserve user settings, support Muse 1.3 hook environment allowlists, and recognize versioned foreground processes. Include question, waiting, completion, resume, and readiness coverage.

Co-authored-by: homesh-dev <[email protected]>

Co-authored-by: jeffhuen <[email protected]>

Co-authored-by: John Cusack <[email protected]>

Co-authored-by: Adrien De oliveira <[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: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 8ca1bcd3-b53a-4920-9c10-bca0792f4232

📥 Commits

Reviewing files that changed from the base of the PR and between 59c0d55 and e30d78f.

⛔ Files ignored due to path filters (1)
  • src/shared/agent-icons/muse.png is excluded by !**/*.png
📒 Files selected for processing (102)
  • README.md
  • config/scripts/mobile-web-app-session-terminal-closure.test.mjs
  • config/tsconfig.cli.json
  • docs/readme/README.es.md
  • docs/readme/README.fr.md
  • docs/readme/README.ja.md
  • docs/readme/README.ko.md
  • docs/readme/README.pt.md
  • docs/readme/README.zh-CN.md
  • docs/site/content/docs/agents/session-history.mdx
  • docs/site/content/docs/agents/supported.mdx
  • mobile/src/components/mobile-agent-icon-assets.ts
  • mobile/src/tasks/mobile-tui-agents.ts
  • src/main/agent-hooks/managed-agent-hook-registry.ts
  • src/main/agent-hooks/managed-hook-command-contract.test.ts
  • src/main/agent-hooks/managed-hook-local-filesystem.test.ts
  • src/main/agent-hooks/remote-hook-service-installers.test.ts
  • src/main/agent-hooks/remote-managed-hook-installers.ts
  • src/main/agent-hooks/server-retired-pane-new-turn.test.ts
  • src/main/ai-vault/remote-session-scanner-muse.test.ts
  • src/main/ai-vault/remote-session-scanner-source-parsers.ts
  • src/main/ai-vault/remote-session-scanner-sources.ts
  • src/main/ai-vault/session-scanner-agent-parser.ts
  • src/main/ai-vault/session-scanner-agent-sources.ts
  • src/main/ai-vault/session-scanner-codex-workers.test.ts
  • src/main/ai-vault/session-scanner-every-agent-fixture.ts
  • src/main/ai-vault/session-scanner-muse-parser.ts
  • src/main/ai-vault/session-scanner-muse-paths.ts
  • src/main/ai-vault/session-scanner-muse.test.ts
  • src/main/ai-vault/session-scanner-opencode-sqlite-coexistence.test.ts
  • src/main/ai-vault/session-scanner-parse-cache.ts
  • src/main/ai-vault/session-scanner-test-fixtures.ts
  • src/main/ai-vault/session-scanner-types.ts
  • src/main/ai-vault/session-scanner.test.ts
  • src/main/muse/hook-config-json.test.ts
  • src/main/muse/hook-config-json.ts
  • src/main/muse/hook-service.test.ts
  • src/main/muse/hook-service.ts
  • src/main/muse/hook-settings.ts
  • src/main/runtime/__fixtures__/muse-empty-folder-ready.meta.json
  • src/main/runtime/__fixtures__/muse-empty-folder-ready.txt
  • src/main/runtime/muse-readiness-transcript.test.ts
  • src/main/runtime/orca-runtime-resolve-exit-waiters.ts
  • src/main/runtime/runtime-terminal-idle-polls.ts
  • src/main/runtime/runtime-terminal-wait.ts
  • src/main/runtime/terminal-wait-detection.test.ts
  • src/main/runtime/terminal-wait-detection.ts
  • src/main/runtime/terminal-wait-name-only-idle.test.ts
  • src/main/runtime/tui-idle-evidence.test.ts
  • src/main/runtime/tui-idle-evidence.ts
  • src/main/skills/skill-discovery-concurrency.test.ts
  • src/main/skills/skill-discovery-sources.ts
  • src/renderer/src/components/skills/SkillInstallDialog.test.tsx
  • src/renderer/src/components/terminal-pane/terminal-startup-command-classifier.test.ts
  • src/renderer/src/components/terminal-pane/terminal-startup-command-classifier.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/lib/agent-catalog.tsx
  • src/renderer/src/lib/agent-favicon-assets.ts
  • src/renderer/src/lib/agent-status.ts
  • src/renderer/src/lib/tui-agent-startup.test.ts
  • src/renderer/src/runtime/agent-resume-host-authority-capability.test.ts
  • src/renderer/src/runtime/agent-resume-host-authority-capability.ts
  • src/renderer/src/runtime/remote-agent-session-launch.test.ts
  • src/shared/agent-headless-command.ts
  • src/shared/agent-hook-listener-claude-compatible-vendors.test.ts
  • src/shared/agent-hook-listener/provider-dispatch.ts
  • src/shared/agent-hook-listener/provider-event-routing.ts
  • src/shared/agent-hook-listener/providers/muse-events.ts
  • src/shared/agent-hook-listener/source-routing.ts
  • src/shared/agent-hook-relay.ts
  • src/shared/agent-hook-types.ts
  • src/shared/agent-kind.ts
  • src/shared/agent-process-recognition.test.ts
  • src/shared/agent-process-recognition.ts
  • src/shared/agent-session-resume.ts
  • src/shared/agent-type-label.ts
  • src/shared/ai-vault-resume-command.test.ts
  • src/shared/ai-vault-resume-command.ts
  • src/shared/ai-vault-types.ts
  • src/shared/commit-message-agent-spec.test.ts
  • src/shared/commit-message-agent-specs-secondary.ts
  • src/shared/commit-message-plan.test.ts
  • src/shared/constants.test.ts
  • src/shared/muse-headless-command.ts
  • src/shared/protocol-version.ts
  • src/shared/skill-install-providers.ts
  • src/shared/skills-cli-agent-keys.ts
  • src/shared/source-control-ai-action-recipes.test.ts
  • src/shared/telemetry-property-schemas.ts
  • src/shared/tui-agent-config.test.ts
  • src/shared/tui-agent-config.ts
  • src/shared/tui-agent-display-names.ts
  • src/shared/tui-agent-permissions.test.ts
  • src/shared/tui-agent-permissions.ts
  • src/shared/tui-agent-selection.ts
  • src/shared/tui-agent-startup.test.ts
  • src/shared/tui-agent.ts

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

| Codebuff | Auto-setup | [Codebuff](https://www.codebuff.com/docs/help/quick-start) |
| Freebuff | Auto-setup | [Freebuff](https://freebuff.com/cli) |
| Command Code | Auto-setup, status | [Command Code](https://commandcode.ai/docs/quickstart) |
| Muse | macOS/Linux; trusts the workspace at launch | [Meta](https://dev.meta.ai/docs/muse-code) |

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

rg -n -C4 "muse|win32|Windows|powershell|muse\\.cmd" src/shared/tui-agent-config.ts src/shared/tui-agent-startup.test.ts src/main/muse/hook-service.ts docs/site/content/docs/agents/supported.mdx

Repository: stablyai/orca

Length of output: 34491


Document native Windows support for Muse.

The Muse startup tests cover native Windows with both PowerShell and cmd, and the implementation provides a Windows hook script. Add Windows to this platform list.

Comment thread README.md
<a href="https://github.com/mistralai/mistral-vibe"><kbd><img src="https://www.google.com/s2/favicons?domain=mistral.ai&sz=64" alt="Mistral Vibe logo" width="16" valign="middle" /> Mistral Vibe</kbd></a> &nbsp;
<a href="https://github.com/QwenLM/qwen-code"><kbd><img src="https://www.google.com/s2/favicons?domain=qwenlm.github.io&sz=64" alt="Qwen Code logo" width="16" valign="middle" /> Qwen Code</kbd></a> &nbsp;
<a href="https://support.atlassian.com/rovo/docs/install-and-run-rovo-dev-cli-on-your-device/"><kbd><img src="https://www.google.com/s2/favicons?domain=atlassian.com&sz=64" alt="Rovo Dev logo" width="16" valign="middle" /> Rovo Dev</kbd></a> &nbsp;
<a href="https://dev.meta.ai/docs/muse-code"><kbd><img src="https://www.google.com/s2/favicons?domain=dev.meta.ai&sz=64" alt="Muse logo" width="16" valign="middle" /> Muse</kbd></a> &nbsp;

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Remove the duplicate Muse entry.

The Supported Agents list already adds Muse on Line 181. Remove the second entry on Line 207 so the README lists each agent once.

Muse 1.3 fires no hook for request_user_input, so a pending question left
the pane "working". Its internal reminder subagents also post hooks with
their own session ids (even after Stop), which surfaced "tool failed" rows
and flipped finished panes back to working.

- Read pending questions from Muse's session log
  (user_input_prompt_requested/settled) via the existing transcript poll,
  now generalized from Codex subagents to Muse on main and relay.
- Drop child-session hooks (SubagentStart ids, or turn_id === session_id).
- Treat Notification permission_prompt as the approval wait; PermissionRequest
  also fires for auto-approved calls, so it only caches the approval card.
- Ignore Notification copy as the prompt; poll replays are not new prompts
  or turn boundaries.
- Allowlist USERPROFILE so Windows cmd AutoRun doesn't fail every hook.

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

Run ID: be2d021f-a932-44b8-835b-2399f58d2c29

📥 Commits

Reviewing files that changed from the base of the PR and between e30d78f and 5bef4cb.

📒 Files selected for processing (23)
  • src/main/agent-hooks/server-hook-http-ingest.test.ts
  • src/main/agent-hooks/server-muse-session-log-poll.test.ts
  • src/main/agent-hooks/server/server-authority-aliases.ts
  • src/main/agent-hooks/server/server-authority-fences.ts
  • src/main/agent-hooks/server/server-cleanup.ts
  • src/main/agent-hooks/server/server-lifecycle.ts
  • src/main/agent-hooks/server/server-state.ts
  • src/main/agent-hooks/server/server-status-retries.ts
  • src/main/agent-hooks/server/server-tab-cleanup.ts
  • src/main/ai-vault/session-scanner-muse-paths.ts
  • src/main/muse/hook-config-json.ts
  • src/main/muse/hook-settings.ts
  • src/relay/agent-hook-result-retry-scheduler.ts
  • src/relay/agent-hook-server.test.ts
  • src/relay/agent-hook-server.ts
  • src/shared/agent-hook-listener-claude-compatible-vendors.test.ts
  • src/shared/agent-hook-listener-relay-dependency.test.ts
  • src/shared/agent-hook-listener/listener-state.ts
  • src/shared/agent-hook-listener/providers/muse-events.test.ts
  • src/shared/agent-hook-listener/providers/muse-events.ts
  • src/shared/agent-hook-listener/transcript-poll-policy.ts
  • src/shared/muse-session-log.test.ts
  • src/shared/muse-session-log.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/muse/hook-settings.ts
  • src/shared/agent-hook-listener-claude-compatible-vendors.test.ts

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

codexSubagentTranscriptByPaneKey: new Map(),
codexLeadStateByPaneKey: new Map(),
grokActiveTurnByPaneKey: new Map(),
musePaneStateByPaneKey: new Map(),

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Clear Muse state in clearAllListenerCaches.

The new map survives clearAllListenerCaches. A stop and restart can retain old session-log cursors, child-session filters, and pending approval data.

Add state.musePaneStateByPaneKey.clear() with the other provider caches.

Proposed fix
   state.codexLeadStateByPaneKey.clear()
   state.grokActiveTurnByPaneKey.clear()
+  state.musePaneStateByPaneKey.clear()
   state.opencodeSessionPaneBySessionId.clear()

@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 small state-cleanup gap inline.

Reviewed changes

This run re-reviewed 5bef4cb (fix(muse): detect questions and approvals from structured Muse signals), the only commit since the last reviewed version, and a sizeable functional addition rather than a test-only follow-up.

  • New Muse session-log reader — src/shared/muse-session-log.ts locates a live session's session.jsonl from its UUIDv7 timestamp shard (probing ±1 day, local and UTC), incrementally reads user_input_prompt_requested/user_input_prompt_settled, and returns the newest open question.
  • Generalized transcript poll — transcript-poll-policy.ts reworks the Codex-subagent poll into shouldPollHookTranscript/transcriptPollUpdate; Muse polls its session log to surface the request_user_input wait and clears it on settle, stripping the replay's hasExplicitPrompt/hookEventName.
  • Muse event rework — child-session hooks are dropped (SubagentStart ids, or turn_id === session_id); PermissionRequest only caches the approval card, Notification permission_prompt is the visible wait, and Notification copy no longer overwrites the prompt.
  • Scheduler rename — schedule/clearCodexSubagentPoll became schedule/clearTranscriptPoll across the main server and relay; no stale references remain.
  • Windows and child hooks — SubagentStart added to the managed events and USERPROFILE to the managed-hook env allowlist.
  • Coverage — new muse-events.test.ts, muse-session-log.test.ts, and a main-server server-muse-session-log-poll.test.ts that fails if question detection regresses; hook/relay ordering tests updated. All targeted tests pass locally.

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

codexSubagentTranscriptByPaneKey: new Map(),
codexLeadStateByPaneKey: new Map(),
grokActiveTurnByPaneKey: new Map(),
musePaneStateByPaneKey: new Map(),

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.

musePaneStateByPaneKey is now the only per-pane map that clearAllListenerCaches (listener-state.ts:331) does not clear, so Muse child-session ids and pendingApproval outlive a full server/relay cache reset (stop() / relay close). The pane-scoped path already handles it in clearPaneCacheState; the global sweep just needs the same line.

Technical details
# Muse pane state not cleared by the global cache sweep

## Affected sites
- `src/shared/agent-hook-listener/listener-state.ts:331` — `clearAllListenerCaches` clears `codexSubagentTranscriptByPaneKey`, `codexLeadStateByPaneKey`, `grokActiveTurnByPaneKey`, `opencodeSessionPaneBySessionId`, `lastLaunchTokenByPaneKey`, … but not `musePaneStateByPaneKey` (added at line 56/132).
- `src/shared/agent-hook-listener/listener-state.ts:221` — `clearPaneCacheState` does delete it, so only the global sweep is inconsistent.

## Required outcome
- `clearAllListenerCaches` clears `musePaneStateByPaneKey`, matching its sibling per-pane maps.

## Suggested approach
- Add `state.musePaneStateByPaneKey.clear()` next to the other map clears.

Most Muse session-log lines are large model/tool records. Filter raw lines
by the user_input_prompt_ marker before JSON.parse via an optional
readJsonlCursor line filter.
# Conflicts:
#	config/scripts/mobile-web-app-session-terminal-closure.test.mjs
… turn

Review follow-ups: question events inside retained_frame batches were
skipped, and a question left open by a crash or interrupt stayed pending
for the pane's life. Share the history scanner's retained_frame unwrapper,
and only report a pending question whose run_id matches the hook turn_id.

@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 in the latest commits — two earlier review threads remain open.

Reviewed changes

This run re-reviewed the two commits since the prior pullfrog review at d8c9609: d86d2aa (fix(muse): unwrap batched log records and scope questions to the live turn) and 95f2599 (refactor(muse): drop type assertion in retained_frame unwrap).

  • Batched log unwrap — extracted unwrapMuseLogRecords into src/shared/muse-session-log.ts. Both the surface-log poll and the AI Vault parser (session-scanner-muse-parser.ts) now expand a retained_frame's children[].record_json identically; the byte-offset cursor and the "user_input_prompt_ line filter still run against whole physical lines, so a batched frame is parsed as one line and unwrapped afterward.
  • Turn-scoped questions — readMusePendingUserInput now takes the hook payload's turn_id and returns only the newest pending prompt whose log run_id matches it (falling back when either id is absent). A question left open by a crashed or interrupted earlier run (run_id persisted from the log's outer payload.run_id) no longer pins a later turn as waiting.
  • Coverage — muse-session-log.test.ts adds cases for a prompt batched inside a retained_frame and for an earlier run's open prompt; muse-events.test.ts aligns its log run_id with the hook turn_id, so the poll path is actually exercised. Verified locally: muse-session-log (8) and muse-events (5), the ai-vault Muse parsers, and server-muse-session-log-poll all pass.

Two earlier findings are still open and untouched by these commits, so I have not re-raised them inline:

  • parseMuseSettingsText does not strip a UTF-8 BOM (src/main/muse/hook-config-json.ts:32), so a BOM-prefixed settings.json fails closed.
  • clearAllListenerCaches omits musePaneStateByPaneKey (src/shared/agent-hook-listener/listener-state.ts:331), leaving Muse child-session ids and pendingApproval across a full cache reset.

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

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

Run ID: 54b8aa13-f508-41af-a5eb-ea81d81e737f

📥 Commits

Reviewing files that changed from the base of the PR and between f54510c and c83d935.

⛔ Files ignored due to path filters (1)
  • src/shared/agent-icons/muse.png is excluded by !**/*.png
📒 Files selected for processing (8)
  • config/scripts/mobile-web-app-session-terminal-closure.test.mjs
  • src/main/ai-vault/session-scanner-codex-workers.test.ts
  • src/main/ai-vault/session-scanner-muse-parser.ts
  • src/shared/agent-hook-listener/providers/muse-events.test.ts
  • src/shared/agent-hook-listener/providers/muse-events.ts
  • src/shared/agent-hook-listener/transcript-poll-policy.ts
  • src/shared/muse-session-log.test.ts
  • src/shared/muse-session-log.ts

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

}
// Why: a question left open by a crash or interrupt stays in the log; only the live turn's can block.
const pending = Array.from(log.pending.values())
return pending.findLast((prompt) => !turnId || !prompt.runId || prompt.runId === turnId)

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- outline ---'
ast-grep outline src/shared/muse-session-log.ts
printf '%s\n' '--- target and nearby definitions ---'
sed -n '1,230p' src/shared/muse-session-log.ts
printf '%s\n' '--- related run_id and pending-input references ---'
rg -n -C 3 'run_id|runId|user_input_prompt_requested|readMusePendingUserInput|pending' src --glob '!**/node_modules/**'

Repository: stablyai/orca

Length of output: 45543


🤖 get_repo_knowledge executed:

get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions

Length of output: 47678


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- file size ---'
wc -l src/shared/muse-session-log.ts
printf '%s\n' '--- session log source ---'
cat -n src/shared/muse-session-log.ts
printf '%s\n' '--- exact function callers ---'
rg -n -l 'readMusePendingUserInput|MusePendingUserInput|createMuseSessionLogState' src --glob '!**/node_modules/**' | head -100
printf '%s\n' '--- bounded caller excerpts ---'
for file in $(rg -l 'readMusePendingUserInput|MusePendingUserInput|createMuseSessionLogState' src --glob '!**/node_modules/**' | head -20); do
  printf '\n--- %s ---\n' "$file"
  rg -n -C 8 'readMusePendingUserInput|MusePendingUserInput|createMuseSessionLogState' "$file"
done

Repository: stablyai/orca

Length of output: 14072


Require an exact run ID for scoped turns.

When turnId is defined, the predicate still accepts prompts without runId. An unanswered record without payload.run_id can therefore match a later turn, return a stale question, and set that turn to waiting.

Suggested fix
-  return pending.findLast((prompt) => !turnId || !prompt.runId || prompt.runId === turnId)
+  return pending.findLast((prompt) => turnId === undefined || prompt.runId === turnId)
📝 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
return pending.findLast((prompt) => !turnId || !prompt.runId || prompt.runId === turnId)
return pending.findLast((prompt) => turnId === undefined || prompt.runId === turnId)

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