Repository navigation
feat(jcode): first-class agent — live status, questions, notifications, send-to-agent, orchestration - #22539
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Important Review skippedWe couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting You can disable this status message by setting the Use the checkbox below for a quick retry:
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe pull request adds Jcode support across agent registration, managed hooks, hook-event processing, AI Vault session discovery and resume, pane runtime setup, terminal query handling, and commit-message generation. It adds shared backward file scanning and Jcode-specific prompt and title utilities. Additional changes update Pi session metadata, agent assets, translations, documentation, tests, and formatting. Priority: ➖ Normal Merge Risk: 🟠 High · up to Resolve the unrestricted commit-message agent and terminal-spawn failure risk before merging. Several Jcode features also remain unreliable across configurations and platforms. 🚥 Pre-merge checks | ✅ 4 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (4 passed)
Full details: Out of Scope Changes checkExplanation The PR includes several unrelated formatting-only edits in documentation, Pi/runtime tests, orchestration tests, a bug reproduction, and smoke tooling. These changes are not necessary to implement first-class Jcode support. Full details: Out of Scope Changes checkExplanation The pull request includes changes with no demonstrated connection to [ Resolution Remove the unrelated documentation, formatting-only, Pi metadata, orchestration-test, OpenCode, and generic transcript-scan changes. Retain changes only when they implement [ ✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Comment |
There was a problem hiding this comment.
Actionable comments posted: 16
🧹 Nitpick comments (1)
src/renderer/src/runtime/agent-resume-host-authority-capability.ts (1)
38-39: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winDocument why
jcoderemains ungated.
jcodewas added afteragent-session.host-authority.v1. An older host rejectsjcodeinExplicitEnsure, so it cannot resume ajcodeprovider session through this path. The generic probe is safe, but the current comment incorrectly says that the v1 enum already coversjcode.Suggested comment update
- // Why: jcode resumed by id (--resume <id>) through the same host-authority session enum the generic probe covers. + // Why: jcode was added after agent-session.host-authority.v1, so an older host cannot accept + // jcode in ExplicitEnsure or resume a jcode provider session. The generic probe is safe here.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 24f41017-3159-4676-8363-cda089fe82e7
📥 Commits
Reviewing files that changed from the base of the PR and between 519bde8 and 7c0eee69d77535f783d31c1937e279d6d0c4181a.
⛔ Files ignored due to path filters (1)
src/shared/agent-icons/jcode.pngis excluded by!**/*.png
📒 Files selected for processing (122)
config/scripts/locale-translation-policy.mjsconfig/tsconfig.cli.jsondocs/reference/agent-status-store.mddocs/reference/antigravity-readiness-evidence.mddocs/reference/ssh-execution-boundary.mdmobile/src/components/mobile-agent-icon-assets.tssrc/main/agent-hooks/managed-agent-hook-registry.tssrc/main/agent-hooks/managed-hook-command-contract.test.tssrc/main/agent-hooks/managed-hook-local-filesystem.test.tssrc/main/agent-hooks/remote-hook-installer-registry-guard.test.tssrc/main/agent-hooks/remote-hook-service-installers.test.tssrc/main/agent-hooks/remote-managed-hook-installers.tssrc/main/agent-hooks/server-opencode-binder.test.tssrc/main/agent-hooks/server-retired-pane-new-turn.test.tssrc/main/ai-vault/remote-session-scanner-sources.tssrc/main/ai-vault/session-scanner-agent-parser.tssrc/main/ai-vault/session-scanner-agent-sources.tssrc/main/ai-vault/session-scanner-codex-workers.test.tssrc/main/ai-vault/session-scanner-every-agent-fixture.tssrc/main/ai-vault/session-scanner-jcode-parser.test.tssrc/main/ai-vault/session-scanner-jcode-parser.tssrc/main/ai-vault/session-scanner-opencode-sqlite-coexistence.test.tssrc/main/ai-vault/session-scanner-parse-cache.tssrc/main/ai-vault/session-scanner-test-fixtures.tssrc/main/ai-vault/session-scanner-types.tssrc/main/ai-vault/session-scanner.test.tssrc/main/daemon/pty-subprocess/spawn-environment.tssrc/main/ipc/pty-spawn-env-terminal-basics.test.tssrc/main/ipc/pty/ipc/spawn-env.tssrc/main/ipc/terminal-startup-color-query-replies.test.tssrc/main/ipc/terminal-startup-color-query-replies.tssrc/main/jcode/daemon-prewarm.test.tssrc/main/jcode/daemon-prewarm.tssrc/main/jcode/hook-config.test.tssrc/main/jcode/hook-config.tssrc/main/jcode/hook-gate-script.test.tssrc/main/jcode/hook-service.test.tssrc/main/jcode/hook-service.tssrc/main/jcode/hook-settings.tssrc/main/pi/agent-status-extension-source.tssrc/main/pi/titlebar-extension-service.test.tssrc/main/pi/titlebar-extension-service.tssrc/main/providers/local-pty-launch-helpers.tssrc/main/providers/local-pty-spawn.tssrc/main/runtime/headless-terminal-query-reply-policy.test.tssrc/main/runtime/headless-terminal-query-reply-policy.tssrc/main/runtime/orca-runtime-controller-knows-pty-is-live.tssrc/main/runtime/orca-runtime-create-terminal.tssrc/main/runtime/orca-runtime-resolve-browser-network-execution-host-for-worktree.tssrc/main/runtime/orca-runtime-split-pty-backed-terminal.tssrc/main/runtime/orca-runtime-terminal-handle-incarnation.test.tssrc/main/runtime/orca-runtime-tests/terminal-creation-and-readiness.spec.tssrc/main/runtime/orca-runtime-write-terminal-agent-prompt.tssrc/main/runtime/rpc/methods/orchestration-worker-release-incarnation-fallback.test.tssrc/main/runtime/rpc/methods/orchestration-worker-release-reap-fixed.func.test.tssrc/main/text-generation/commit-message-model-discovery-policy.tssrc/main/text-generation/commit-message-text-generation-cancellation.test.tssrc/main/text-generation/source-control-local-process.tssrc/renderer/src/components/sidebar/worktree-title-derived-agent-rows.tssrc/renderer/src/components/terminal-pane/pty-connection-hidden-atlas-recovery.test.tssrc/renderer/src/components/terminal-pane/pty-connection-pi-synchronized-input.test.tssrc/renderer/src/components/terminal-pane/pty-connection/hidden-output-seq-and-skip.tssrc/renderer/src/components/terminal-pane/pty-connection/hidden-startup-renderer-query-write.tssrc/renderer/src/components/terminal-pane/pty-connection/pane-agent-identity.tssrc/renderer/src/components/terminal-pane/pty-connection/pane-launch-agent-candidate.test.tssrc/renderer/src/components/terminal-pane/pty-connection/pane-launch-agent-candidate.tssrc/renderer/src/components/terminal-pane/pty-connection/pty-input-recovery.tssrc/renderer/src/components/terminal-pane/terminal-capability-replies.test.tssrc/renderer/src/components/terminal-pane/terminal-capability-replies.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/lib/agent-catalog.tsxsrc/renderer/src/lib/agent-favicon-assets.tssrc/renderer/src/lib/agent-status.tssrc/renderer/src/runtime/agent-resume-host-authority-capability.tssrc/renderer/src/runtime/web-session-tabs-sync/mirrored-status-tab-retractions.test.tssrc/renderer/src/runtime/web-session-tabs-sync/mirrored-status-tab-retractions.tssrc/shared/agent-hook-listener-extraction-characterization.test.tssrc/shared/agent-hook-listener-jcode.test.tssrc/shared/agent-hook-listener.tssrc/shared/agent-hook-listener/provider-dispatch.tssrc/shared/agent-hook-listener/provider-event-routing.tssrc/shared/agent-hook-listener/providers/jcode-events.tssrc/shared/agent-hook-listener/providers/jcode-tool-fields.tssrc/shared/agent-hook-listener/source-routing.tssrc/shared/agent-hook-relay.tssrc/shared/agent-hook-types.tssrc/shared/agent-kind.tssrc/shared/agent-name-token-match.tssrc/shared/agent-row-conversation-name.test.tssrc/shared/agent-row-conversation-name.tssrc/shared/agent-session-resume.test.tssrc/shared/agent-session-resume.tssrc/shared/agent-title-identity.tssrc/shared/agent-type-label.tssrc/shared/ai-vault-resume-command.tssrc/shared/ai-vault-types.tssrc/shared/commit-message-agent-output.tssrc/shared/commit-message-agent-spec.test.tssrc/shared/commit-message-agent-spec.tssrc/shared/commit-message-agent-specs-secondary.tssrc/shared/commit-message-plan.test.tssrc/shared/commit-message-prompt.test.tssrc/shared/jcode-runtime-dir.test.tssrc/shared/jcode-runtime-dir.tssrc/shared/jcode-session-files.test.tssrc/shared/jcode-session-files.tssrc/shared/jcode-terminal-title.test.tssrc/shared/jcode-terminal-title.tssrc/shared/pane-agent-identity-inventory.test.tssrc/shared/skills-cli-agent-keys.tssrc/shared/source-control-ai-action-recipes.test.tssrc/shared/telemetry-property-schemas.tssrc/shared/terminal-title-agent-type.tssrc/shared/tui-agent-config.tssrc/shared/tui-agent-display-names.tssrc/shared/tui-agent-selection.tssrc/shared/tui-agent.tstests/tools/omp-source-control-runtime-smoke.mjs
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.
| 'jcode', | ||
| remoteHome, | ||
| hostPlatform, | ||
| ['.jcode', 'sessions'], |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Discover sessions under a remote custom JCODE_HOME.
If Jcode on the remote host uses JCODE_HOME, this source still scans only <remoteHome>/.jcode/sessions. Those sessions do not appear in AI Vault. Resolve the remote Jcode home or provide an explicit remote-root override. Jcode documents JCODE_HOME as an override for its state directory. (github.com)
| // Why: parse only the durable `messages` array. The live `.journal.jsonl` | ||
| // sibling is intentionally ignored: its writes do not bump this file's mtime, | ||
| // so a merged read would go stale against the parse cache until the session | ||
| // doc is rewritten (checkpoint/close). | ||
| for (const message of arrayValue(record.messages)) { | ||
| consumeJcodeMessage(accumulator, message) | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Include the session journal in AI Vault reads.
When Jcode appends a turn to session_*.journal.jsonl, this parser reads only the older JSON snapshot. The snapshot's unchanged mtime also lets the parse cache reuse that older result. AI Vault can show an incomplete conversation until Jcode checkpoints the snapshot. Jcode's loader replays the journal after reading the snapshot, and ordinary saves can append without checkpointing. Read or replay the journal and track its freshness for both local and remote scans. (raw.githubusercontent.com)
| const titleCandidate = normalizeTitleText(extractContentText(content) ?? '') | ||
| if (titleCandidate) { | ||
| accumulator.title ??= titleCandidate |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Preserve the session's stored title.
When a user names a Jcode session, this code still takes its title from the first user message. Jcode stores custom_title and title in the session document. Prefer the custom title, then the stored title, before deriving one from a prompt. (github.com)
| accumulator.messageCount++ | ||
| addPreviewContent(accumulator, role, content, messageRecord.timestamp) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Accumulate persisted token usage.
Jcode stores input and output token counts on messages, but this parser never updates accumulator.totalTokens. AI Vault therefore reports zero tokens for a Jcode session with persisted usage. Add the stored counts using the accumulator's token-total convention. (raw.githubusercontent.com)
| export function agentSkipsStartupOscColorQueryReplies(launchAgent: unknown): boolean { | ||
| return launchAgent === 'jcode' | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
The startup color-reply skip checks only launchAgent, so a command-only Jcode launch still gets answered.
shouldReplyToStartupTerminalColorQueries recognizes an agent from launchAgent, from telemetry.agent_kind, or from command/launchConfig.agentCommand. The skip checks only launchAgent === 'jcode'. A spawn with command: 'jcode' or telemetry.agent_kind: 'jcode' and no launchAgent still sends the startup OSC 10/11 replies. That is the composer-text leak this change is meant to fix. Apply the same signals in the skip check.
Proposed fix
-export function agentSkipsStartupOscColorQueryReplies(launchAgent: unknown): boolean {
- return launchAgent === 'jcode'
-}
+export function agentSkipsStartupOscColorQueryReplies(args: {
+ launchAgent?: unknown
+ telemetry?: { agent_kind?: unknown } | undefined
+ command?: string
+ launchConfig?: SleepingAgentLaunchConfig
+}): boolean {
+ if (args.launchAgent === 'jcode' || args.telemetry?.agent_kind === 'jcode') {
+ return true
+ }
+ const command = args.launchConfig?.agentCommand?.trim() || args.command?.trim() || ''
+ return recognizeAgentProcessFromCommandLine(command) === 'jcode'
+}Update the call on line 66 to agentSkipsStartupOscColorQueryReplies(args). Also confirm what recognizeAgentProcessFromCommandLine returns for jcode.
| if (target === 'local' && process.platform === 'win32') { | ||
| return [ | ||
| '@echo off', | ||
| 'setlocal', | ||
| // Why: endpoint file holds the live port/token; a PTY that outlives an Orca restart carries stale env, so `call` it to refresh (else PTY env). | ||
| 'if defined ORCA_AGENT_HOOK_ENDPOINT if exist "%ORCA_AGENT_HOOK_ENDPOINT%" call "%ORCA_AGENT_HOOK_ENDPOINT%" 2>nul', | ||
| ...buildWindowsHookEnvironmentGuardLines(), | ||
| // Why: pre_tool is jcode's gate — it writes the tool input to our stdin and | ||
| // waits for us. Drain it first so a tool input larger than the pipe buffer | ||
| // can never stall the agent mid-write. | ||
| `if "%JCODE_HOOK_EVENT%"=="pre_tool" ${WINDOWS_HOOK_STDIN_DRAIN_COMMAND}`, | ||
| buildWindowsAgentHookPostCommand('jcode'), | ||
| 'exit /b 0', | ||
| ...buildWindowsHookStdinDrainEpilogue(), | ||
| '' | ||
| ].join('\r\n') |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Forward the Jcode payload and event name in the Windows hook script.
The POSIX script pipes $JCODE_HOOK_PAYLOAD into curl. It also posts hook_event_name, session_id, and cwd as form fields.
The Windows script calls buildWindowsAgentHookPostCommand('jcode') with no extra lines. That command sends payload@-, which reads stdin, and stdin never holds the Jcode payload:
- On
pre_tool, line 46 has already drained stdin. - On observer events, Jcode sends the payload through the environment variable, not stdin.
As a result, the server gets no hook_event_name, no session_id, and no tool fields. normalizeJcodeEvent returns null for every event, so Windows panes never show Jcode status. The pre_tool POST also runs synchronously, so every tool call can wait up to curl's 1.5 s --max-time.
At minimum, post the event, session, and working directory as form fields. The server reads hook_event_name from the top-level record. Tool fields also need the payload. One option is curl's --variable %JCODE_HOOK_PAYLOAD with --expand-data-urlencode "payload={{JCODE_HOOK_PAYLOAD}}", which requires curl 8.3 or later. Another option is the existing PowerShell launcher. Detach pre_tool with start "" /b.
Partial fix (event identity)
- buildWindowsAgentHookPostCommand('jcode'),
+ buildWindowsAgentHookPostCommand('jcode', [
+ ' --data-urlencode "hook_event_name=%JCODE_HOOK_EVENT%" ^',
+ ' --data-urlencode "session_id=%JCODE_HOOK_SESSION_ID%" ^',
+ ' --data-urlencode "cwd=%JCODE_HOOK_CWD%" ^'
+ ]),📝 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.
| if (target === 'local' && process.platform === 'win32') { | |
| return [ | |
| '@echo off', | |
| 'setlocal', | |
| // Why: endpoint file holds the live port/token; a PTY that outlives an Orca restart carries stale env, so `call` it to refresh (else PTY env). | |
| 'if defined ORCA_AGENT_HOOK_ENDPOINT if exist "%ORCA_AGENT_HOOK_ENDPOINT%" call "%ORCA_AGENT_HOOK_ENDPOINT%" 2>nul', | |
| ...buildWindowsHookEnvironmentGuardLines(), | |
| // Why: pre_tool is jcode's gate — it writes the tool input to our stdin and | |
| // waits for us. Drain it first so a tool input larger than the pipe buffer | |
| // can never stall the agent mid-write. | |
| `if "%JCODE_HOOK_EVENT%"=="pre_tool" ${WINDOWS_HOOK_STDIN_DRAIN_COMMAND}`, | |
| buildWindowsAgentHookPostCommand('jcode'), | |
| 'exit /b 0', | |
| ...buildWindowsHookStdinDrainEpilogue(), | |
| '' | |
| ].join('\r\n') | |
| if (target === 'local' && process.platform === 'win32') { | |
| return [ | |
| '@echo off', | |
| 'setlocal', | |
| // Why: endpoint file holds the live port/token; a PTY that outlives an Orca restart carries stale env, so `call` it to refresh (else PTY env). | |
| 'if defined ORCA_AGENT_HOOK_ENDPOINT if exist "%ORCA_AGENT_HOOK_ENDPOINT%" call "%ORCA_AGENT_HOOK_ENDPOINT%" 2>nul', | |
| ...buildWindowsHookEnvironmentGuardLines(), | |
| // Why: pre_tool is jcode's gate — it writes the tool input to our stdin and | |
| // waits for us. Drain it first so a tool input larger than the pipe buffer | |
| // can never stall the agent mid-write. | |
| `if "%JCODE_HOOK_EVENT%"=="pre_tool" ${WINDOWS_HOOK_STDIN_DRAIN_COMMAND}`, | |
| buildWindowsAgentHookPostCommand('jcode', [ | |
| ' --data-urlencode "hook_event_name=%JCODE_HOOK_EVENT%" ^', | |
| ' --data-urlencode "session_id=%JCODE_HOOK_SESSION_ID%" ^', | |
| ' --data-urlencode "cwd=%JCODE_HOOK_CWD%" ^' | |
| ]), | |
| 'exit /b 0', | |
| ...buildWindowsHookStdinDrainEpilogue(), | |
| '' | |
| ].join('\r\n') |
| // Why: jcode executes hook commands directly (not through a shell), so the | ||
| // managed value must be the bare script path — no `if [ -f … ]` wrapper. Paths | ||
| // with spaces are handled by jcode's shell-style command parsing. | ||
| export function getJcodeManagedCommand(scriptPath: string): string { | ||
| return scriptPath | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Find how the managed command is consumed and compared.
rg -nP -C3 'getJcodeManagedCommand|getJcodeRemoteManagedCommand|managedCommand\s*=' src/main/jcodeRepository: stablyai/orca
Length of output: 1391
🌐 Web query:
jcode hooks config.toml command parsing shell-words split arguments
💡 Result:
<source_evidence>
Citations:
- 1: https://github.com/1jehuang/jcode/blob/435fb4a8/crates/jcode-base/src/hooks.rs
- 2: https://github.com/1jehuang/jcode/blob/435fb4a8/crates/jcode-base/src/config/default_file.rs
- 3: https://jcode.sh/docs
- 4: https://github.com/1jehuang/jcode/blob/435fb4a8/crates/jcode-terminal-launch/src/lib.rs
- 5: 1jehuang/jcode@5d482ca
- 6: GitHub pull request 417 in 1jehuang/jcode (link omitted to avoid creating a cross-reference)
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- hook-settings.ts ---'
cat -n src/main/jcode/hook-settings.ts
printf '%s\n' '--- hook-service.ts focused range ---'
sed -n '1,190p' src/main/jcode/hook-service.ts | cat -n
printf '%s\n' '--- jcode references and version/config bindings ---'
rg -n -P -C2 'jcode|JCODE|hook(s)?|config\.toml' package.json package-lock.json yarn.lock pnpm-lock.yaml bun.lockb src/main/jcode README.md docs 2>/dev/null | head -240Repository: stablyai/orca
Length of output: 26250
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- exact managed-command usages ---'
rg -n -F -C3 'getJcodeManagedCommand' src tests 2>/dev/null || true
rg -n -F -C3 'getJcodeRemoteManagedCommand' src tests 2>/dev/null || true
printf '%s\n' '--- hook-config outline and relevant definitions ---'
ast-grep outline src/main/jcode/hook-config.ts
rg -n -P -C8 'applyJcodeManagedHooks|removeJcodeManagedHooks|scriptPath|managedCommand' src/main/jcode/hook-config.ts src/main/jcode/hook-service.ts
printf '%s\n' '--- remote install continuation ---'
sed -n '186,280p' src/main/jcode/hook-service.ts | cat -nRepository: stablyai/orca
Length of output: 20648
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- hook-config implementation ---'
sed -n '1,180p' src/main/jcode/hook-config.ts | cat -n
printf '%s\n' '--- jcode hook tests and related status tests ---'
rg -n -P -C5 'applyJcodeManagedHooks|tomlQuoteString|JcodeHookService|getStatus|managed command|hook-config' src/main --glob '*test*' | head -260Repository: stablyai/orca
Length of output: 29834
Quote and persist managed jcode commands.
Jcode splits unquoted whitespace and consumes backslashes before it executes a hook. The local and remote installers pass raw paths to applyJcodeManagedHooks, so paths with spaces or backslashes can invoke the wrong executable.
getJcodeManagedCommand is used only by a test. Changing that helper alone does not change production configuration. applyJcodeManagedHooks also preserves existing managed entries, so new quoting must rewrite existing entries as well. Compare status with the same quoted command stored in TOML.
🐛 Suggested fix
export function getJcodeManagedCommand(scriptPath: string): string {
- return scriptPath
+ return /[\s\\"']/.test(scriptPath) ? `"${scriptPath.replace(/(["\\])/g, '\\$1')}"` : scriptPath
}
export function getJcodeRemoteManagedCommand(scriptPath: string): string {
- return scriptPath
+ return /[\s\\"']/.test(scriptPath) ? `"${scriptPath.replace(/(["\\])/g, '\\$1')}"` : scriptPath
}Pass these helpers to both applyJcodeManagedHooks calls, compare getJcodeManagedCommand(scriptPath) in getStatus, and rewrite existing managed entries to the quoted value.
| const jcodeRuntimeDir = args.env?.[JCODE_RUNTIME_DIR_ENV_KEY] | ||
| if (jcodeRuntimeDir) { | ||
| await mkdir(jcodeRuntimeDir, { recursive: true }) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Jcode runtime-directory creation is fatal for every local terminal.
JCODE_RUNTIME_DIR is stamped on every local pane, not only on Jcode panes. All three creation sites let a mkdir error propagate into the spawn. A plain shell then fails to open when creation fails. EACCES on a /tmp/orca-jcode owned by another user is one trigger. A full disk or a read-only TMPDIR is another. Treat a creation failure as "no runtime dir": catch the error and leave JCODE_RUNTIME_DIR out of the environment.
src/main/providers/local-pty-spawn.ts#L46-L48: wrapawait mkdirintry/catch. On failure, deleteargs.env[JCODE_RUNTIME_DIR_ENV_KEY]and skipprewarmJcodeDaemon.src/main/ipc/pty/ipc/spawn-env.ts#L155-L157: wrapmkdirSyncintry/catch. On failure, skipObject.assign(ctx.baseEnv, jcodeEnv).src/main/runtime/orca-runtime-resolve-browser-network-execution-host-for-worktree.ts#L170-L171: callensureJcodeRuntimeDir(paneKey).catch(() => undefined)so thatbuildTerminalWorkspaceEnvcannot reject.
📍 Affects 3 files
src/main/providers/local-pty-spawn.ts#L46-L48(this comment)src/main/ipc/pty/ipc/spawn-env.ts#L155-L157src/main/runtime/orca-runtime-resolve-browser-network-execution-host-for-worktree.ts#L170-L171
| // Why: `jcode run` takes the message as a positional argv argument and has no | ||
| // stdin prompt mode, so Source Control AI prompts ride argv (fine for branch | ||
| // naming and small diffs, argv-capped on Windows). | ||
| promptDelivery: 'argv', |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
Limit Jcode's single prompt argument on Linux.
Jcode receives the full prompt as one argv argument, but staged patches can reach the 200,000-character prompt budget. On a Linux host with 4-KiB pages, one argument cannot exceed 32 pages. A patch that pushes the prompt past roughly 128 KiB therefore fails to spawn Jcode, while the new size check covers only Windows. Apply a byte-aware Jcode prompt budget before spawn, or return a specific size error before attempting generation. (raw.githubusercontent.com)
| export function buildJcodeRuntimeDir(paneKey: string): string { | ||
| const hash = createHash('sha256').update(paneKey).digest('hex').slice(0, 16) | ||
| return join(tmpdir(), 'orca-jcode', hash) | ||
| } |
There was a problem hiding this comment.
🔒 Security & Privacy | 🛡️ Detected with Advanced Tier | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🌐 Web query:
jcode JCODE_RUNTIME_DIR socket directory permission ownership check
💡 Result:
Inspection citation: inspection_ff3ceb174bcba039472964cf0dbed3c2
<source_evidence>
Citations:
- 1: https://github.com/1jehuang/jcode/blob/435fb4a8/crates/jcode-storage/src/lib.rs
- 2: https://github.com/1jehuang/jcode/blob/a63dbc45/crates/jcode-storage/src/lib.rs
- 3: https://github.com/1jehuang/jcode/blob/a63dbc45/crates/jcode-app-core/src/server/socket.rs
- 4: https://github.com/1jehuang/jcode/blob/435fb4a8/sdk/typescript/src/launch.ts
- 5: https://github.com/1jehuang/jcode/blob/a63dbc45/sdk/typescript/src/launch.ts
- 6: https://github.com/1jehuang/jcode/blob/435fb4a8/crates/jcode-sdk/src/launch.rs
- 7: https://github.com/1jehuang/jcode/blob/a63dbc45/sdk/typescript/README.md
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- helper ---'
cat -n src/shared/jcode-runtime-dir.ts
printf '%s\n' '--- helper tests ---'
cat -n src/shared/jcode-runtime-dir.test.ts
printf '%s\n' '--- direct bindings ---'
rg -n -C 5 'JCODE_RUNTIME_DIR|prewarmJcodeDaemon|ensureJcodeRuntimeDir|buildJcodeRuntimeDirEnv' src
printf '%s\n' '--- jcode package/config references ---'
rg -n -C 4 'jcode-runtime|JCODE_RUNTIME_DIR|jcode.sock|jcode daemon|prewarm' package.json pnpm-lock.yaml yarn.lock package-lock.json src 2>/dev/null || trueRepository: stablyai/orca
Length of output: 41447
🏁 Script executed:
set -eu
cat -n src/shared/jcode-runtime-dir.ts
printf '\n--- callers ---\n'
rg -n -C 6 'JCODE_RUNTIME_DIR|prewarmJcodeDaemon|ensureJcodeRuntimeDir|buildJcodeRuntimeDirEnv' srcRepository: stablyai/orca
Length of output: 35729
Security Misconfiguration
Reachability: Internal
Exploitability: Difficult
CWE: CWE-379
Keep Jcode sockets in a validated per-user directory.
On Linux, this path can resolve to /tmp/orca-jcode/<hash>. The local PTY path and daemon-host path create it recursively without a mode or ownership check, then pass it to Jcode as JCODE_RUNTIME_DIR. Another local user can control the parent, replace the pane directory, and serve a fake jcode.sock. This can expose prompts and code, forge responses, or cause EACCES failures.
Use XDG_RUNTIME_DIR only after validating that it is an owned, mode 0700 directory. Otherwise use a per-user fallback. Keep the fallback as the direct parent to preserve the Unix socket path limit. Apply the same secure creation and lstat checks to ensureJcodeRuntimeDir, the local PTY provider, and the daemon-host spawn path. Jcode accepts the configured runtime directory directly, so Orca must enforce these checks.
Proposed path change
export function buildJcodeRuntimeDir(paneKey: string): string {
const hash = createHash('sha256').update(paneKey).digest('hex').slice(0, 16)
- return join(tmpdir(), 'orca-jcode', hash)
+ const base = process.env.XDG_RUNTIME_DIR
+ ? join(process.env.XDG_RUNTIME_DIR, 'orca-jcode')
+ : join(tmpdir(), `orca-jcode-${process.getuid?.() ?? 'u'}`)
+ return join(base, hash)
}📝 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.
| export function buildJcodeRuntimeDir(paneKey: string): string { | |
| const hash = createHash('sha256').update(paneKey).digest('hex').slice(0, 16) | |
| return join(tmpdir(), 'orca-jcode', hash) | |
| } | |
| export function buildJcodeRuntimeDir(paneKey: string): string { | |
| const hash = createHash('sha256').update(paneKey).digest('hex').slice(0, 16) | |
| const base = process.env.XDG_RUNTIME_DIR | |
| ? join(process.env.XDG_RUNTIME_DIR, 'orca-jcode') | |
| : join(tmpdir(), `orca-jcode-${process.getuid?.() ?? 'u'}`) | |
| return join(base, hash) | |
| } |
| function isInjectedContextMessage(message: Record<string, unknown>): boolean { | ||
| return message.display_role === 'system' || message.role === 'system' |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
cat -n src/main/ai-vault/session-scanner-jcode-parser.ts
sed -n '1,95p' src/main/ai-vault/session-scanner-jcode-parser.test.ts
rg -n 'system-reminder|Scheduled task|isInjected|envelope' src/main/ai-vault/*.ts | head -40Repository: stablyai/orca
Length of output: 12357
🏁 Script executed:
sed -n '1,240p' src/main/ai-vault/session-scanner-values.ts
sed -n '1,240p' src/main/ai-vault/session-scanner-accumulator.ts
rg -n -C 4 'extractContentText|normalizeTitleText|addPreviewContent|background_task|Scheduled task|display_role' src/main/ai-vaultRepository: stablyai/orca
Length of output: 41910
🏁 Script executed:
cat -n src/main/ai-vault/session-scanner-values.ts
cat -n src/main/ai-vault/session-scanner-accumulator.ts
cat -n src/main/ai-vault/session-scanner-values.test.ts
cat -n src/main/ai-vault/session-scanner-text-normalization.tsRepository: stablyai/orca
Length of output: 43247
Filter Jcode internal messages before aggregation.
The current filter excludes only role or display_role equal to system. Jcode messages with display_role: "background_task" and user messages beginning with [Scheduled task] can still affect the title, count, and preview.
An unmarked <system-reminder> is already removed from title and preview text by the shared normalizers, but it still increments messageCount and can be published by addPreviewContent. Apply Jcode’s complete visible-message rule before timeline, count, title, preview, and transcript handling.
| const jcodeRuntimeDir = args.env?.[JCODE_RUNTIME_DIR_ENV_KEY] | ||
| if (jcodeRuntimeDir) { | ||
| await mkdir(jcodeRuntimeDir, { recursive: true }) | ||
| // Why here and not earlier: the dir must exist before the daemon binds its | ||
| // socket in it, and this is the last point before the shell starts — the | ||
| // head start the client's 5s ready budget needs on a cold runtime dir. | ||
| prewarmJcodeDaemon({ | ||
| launchAgent: args.launchAgent, | ||
| runtimeDir: jcodeRuntimeDir, | ||
| cwd: args.cwd, | ||
| env: args.env | ||
| }) | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,90p' src/main/providers/local-pty-spawn.ts
cat -n src/main/jcode/daemon-prewarm.ts
rg -n 'ORCA_AGENT_HOOK_PORT|ORCA_AGENT_HOOK_ENDPOINT' src/main/providers src/main/ipc/pty | head -20Repository: stablyai/orca
Length of output: 8187
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\n' '--- changed diff ---'
git diff --stat 519bde81df438478ff1c6ac010f1339f32a306ee 7c0eee69d77535f783d31c1937e279d6d0c4181a -- src/main/providers/local-pty-spawn.ts src/main/jcode
git diff --unified=35 519bde81df438478ff1c6ac010f1339f32a306ee 7c0eee69d77535f783d31c1937e279d6d0c4181a -- src/main/providers/local-pty-spawn.ts src/main/jcode
printf '%s\n' '--- environment builder definitions ---'
rg -n -C 8 'function buildLocalPtySpawnEnvironment|buildLocalPtySpawnEnvironment|finalizeLocalPtySpawnEnvironment|ORCA_AGENT_HOOK_PORT|ORCA_AGENT_HOOK_ENDPOINT|ORCA_AGENT_HOOK_TOKEN|ORCA_PANE_KEY|JCODE_RUNTIME_DIR' src/main src/shared
printf '%s\n' '--- jcode and hook integration ---'
rg -n -S -C 6 'jcode|hook|ORCA_AGENT_HOOK|ORCA_PANE_KEY' src/main src/shared --glob '!**/*.map' --glob '!**/node_modules/**' | head -500
printf '%s\n' '--- relevant files ---'
git ls-files | rg '(^|/)(jcode|.*hook.*|.*pty.*env.*|tui-agent|child-process)'Repository: stablyai/orca
Length of output: 45545
🏁 Script executed:
set -u
git diff --stat 519bde81df438478ff1c6ac010f1339f32a306ee 7c0eee69d77535f783d31c1937e279d6d0c4181a -- src/main/providers/local-pty-spawn.ts src/main/jcode
git diff --unified=25 519bde81df438478ff1c6ac010f1339f32a306ee 7c0eee69d77535f783d31c1937e279d6d0c4181a -- src/main/providers/local-pty-spawn.ts src/main/jcode
printf '%s\n' '--- env refs ---'
rg -n -C 6 'buildLocalPtySpawnEnvironment|finalizeLocalPtySpawnEnvironment|ORCA_AGENT_HOOK_PORT|ORCA_AGENT_HOOK_ENDPOINT|ORCA_AGENT_HOOK_TOKEN|ORCA_PANE_KEY|JCODE_RUNTIME_DIR' src/main src/shared
printf '%s\n' '--- jcode/hook refs ---'
rg -n -S -C 5 'jcode|hook|ORCA_AGENT_HOOK|ORCA_PANE_KEY' src/main src/shared --glob '!**/*.map' --glob '!**/node_modules/**' | head -500
printf '%s\n' '--- files ---'
git ls-files | rg '(^|/)(jcode|.*hook.*|.*pty.*env.*|tui-agent|child-process)'Repository: stablyai/orca
Length of output: 45545
🤖 get_repo_knowledge executed:
get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings
Length of output: 14167
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\n' '--- source files ---'
git ls-files | rg '(^|/)(jcode|.*hook.*|.*pty.*env.*|tui-agent|child-process)'
printf '%s\n' '--- exact symbols ---'
rg -n -C 12 'buildLocalPtySpawnEnvironment|finalizeLocalPtySpawnEnvironment|ORCA_AGENT_HOOK_PORT|ORCA_AGENT_HOOK_ENDPOINT|ORCA_AGENT_HOOK_TOKEN|ORCA_PANE_KEY|JCODE_RUNTIME_DIR|prewarmJcodeDaemon' src/main src/sharedRepository: stablyai/orca
Length of output: 45538
🏁 Script executed:
#!/bin/bash
set -u
for f in \
src/shared/jcode-runtime-dir.ts \
src/main/jcode/hook-gate-script.ts \
src/main/jcode/hook-service.ts \
src/main/jcode/hook-config.ts \
src/main/jcode/hook-settings.ts \
src/main/jcode/daemon-prewarm.ts \
src/main/providers/local-pty-spawn-environment.ts \
src/main/providers/local-pty-finalize-environment.ts \
src/main/ipc/pty/host-env/assembly.ts \
src/main/ipc/pty/host-env/spawn-env-keys.ts \
src/shared/agent-hook-listener-jcode.test.ts
do
if [ -f "$f" ]; then
printf '\n--- %s ---\n' "$f"
cat -n "$f"
fi
done
printf '\n--- focused call sites ---\n'
rg -n -C 10 'buildJcodeRuntimeDirEnv|ORCA_AGENT_HOOK|ORCA_PANE_KEY|buildLocalPtySpawnEnvironment|finalEnv|prewarmJcodeDaemon' \
src/main/providers src/main/ipc/pty src/main/jcode src/shared/jcode-runtime-dir.ts src/shared/agent-hook-listener-jcode.test.tsRepository: stablyai/orca
Length of output: 42935
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\n' '--- local environment builder ---'
cat -n src/main/providers/local-pty-spawn-environment.ts
printf '%s\n' '--- local finalizer ---'
cat -n src/main/providers/local-pty-finalize-environment.ts
printf '%s\n' '--- IPC spawn environment entry and call flow ---'
sed -n '1,210p' src/main/ipc/pty/ipc/spawn-env.ts
rg -n -C 12 'assemblePtyIpcSpawn|baseEnv|spawnLocalPty|provider\.spawn|LocalPtyProvider' src/main/ipc/pty src/main/providers --glob '*.ts'
printf '%s\n' '--- host assembly entry ---'
sed -n '1,190p' src/main/ipc/pty/host-env/assembly.ts
printf '%s\n' '--- changed hunk only ---'
git diff --unified=12 519bde81df438478ff1c6ac010f1339f32a306ee 7c0eee69d77535f783d31c1937e279d6d0c4181a -- src/main/providers/local-pty-spawn.tsRepository: stablyai/orca
Length of output: 45537
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\n' '--- local-pty-spawn-environment.ts ---'
wc -l src/main/providers/local-pty-spawn-environment.ts
cat -n src/main/providers/local-pty-spawn-environment.ts
printf '%s\n' '--- direct builder references ---'
rg -n -C 8 'buildLocalPtySpawnEnvironment|buildPtyHostEnv|buildPtySpawnEnvironment' \
src/main/providers/local-pty-spawn-environment.ts \
src/main/providers/local-pty-spawn.ts \
src/main/providers/local-pty-provider-spawn-env.test.ts \
src/main/ipc/pty/ipc/spawn-env.ts
printf '%s\n' '--- provider invocation context ---'
rg -n -C 12 'spawnLocalPty\(|provider\.spawn\(|env:' src/main/ipc/pty src/main/providers/local-pty-provider.ts src/main/providers/local-pty-provider-types.ts 2>/dev/null | head -240Repository: stablyai/orca
Length of output: 28171
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\n' '--- buildSpawnEnv assignments ---'
rg -n -C 16 'buildSpawnEnv\s*[:=]|buildSpawnEnv\(' src/main --glob '*.ts' | head -400
printf '%s\n' '--- provider option types and construction ---'
cat -n src/main/providers/local-pty-provider-types.ts
rg -n -C 16 'LocalPtyProviderOptions|new LocalPtyProvider|buildPtyHostEnv' src/main --glob '*.ts' | head -500Repository: stablyai/orca
Length of output: 40398
🏁 Script executed:
#!/bin/bash
set -u
cat -n src/main/ipc/pty/provider/local-configure.ts | sed -n '35,145p'Repository: stablyai/orca
Length of output: 5032
🏁 Script executed:
#!/bin/bash
set -u
rg -n -C 12 'buildPtyEnv|ORCA_AGENT_HOOK_PORT|ORCA_AGENT_HOOK_TOKEN|ORCA_AGENT_HOOK_ENDPOINT' src/main/agent-hooks/server.tsRepository: stablyai/orca
Length of output: 151
🏁 Script executed:
#!/bin/bash
set -u
file=$(rg -l 'class AgentHookServer|buildPtyEnv' src/main/agent-hooks src/main | head -1)
printf 'file=%s\n' "$file"
if [ -n "$file" ]; then
rg -n -C 14 'buildPtyEnv|ORCA_AGENT_HOOK_PORT|ORCA_AGENT_HOOK_TOKEN|ORCA_AGENT_HOOK_ENDPOINT' "$file"
fiRepository: stablyai/orca
Length of output: 4711
🏁 Script executed:
#!/bin/bash
set -u
rg -l --glob '!**/*.test.ts' --glob '!**/*.spec.ts' 'class AgentHookServer|export const agentHookServer|buildPtyEnv' src/main/agent-hooks src/main | head -30Repository: stablyai/orca
Length of output: 1664
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\n' '--- server env symbols ---'
rg -n -C 18 'buildPtyEnv|ORCA_AGENT_HOOK_PORT|ORCA_AGENT_HOOK_TOKEN|ORCA_AGENT_HOOK_ENDPOINT' \
src/main/agent-hooks/server.ts src/main/agent-hooks/server/server-runtime-env.tsRepository: stablyai/orca
Length of output: 4002
Prewarm Jcode with finalEnv, not args.env.
spawnLocalPty starts the daemon before buildLocalPtySpawnEnvironment calls buildPtyHostEnv. When hooks are enabled, that builder adds the current ORCA_AGENT_HOOK_PORT and ORCA_AGENT_HOOK_TOKEN. Jcode hooks run inside the daemon, and the managed script exits when those values are missing. A normal Jcode launch can therefore drop lifecycle events while the shell receives valid hook coordinates.
Suggested fix
if (jcodeRuntimeDir) {
await mkdir(jcodeRuntimeDir, { recursive: true })
- // Why here and not earlier: the dir must exist before the daemon binds its
- // socket in it, and this is the last point before the shell starts — the
- // head start the client's 5s ready budget needs on a cold runtime dir.
- prewarmJcodeDaemon({
- launchAgent: args.launchAgent,
- runtimeDir: jcodeRuntimeDir,
- cwd: args.cwd,
- env: args.env
- })
}
@@
const historyResult = finalizeLocalPtySpawnEnvironment({
spawn: args,
getOptions,
plan,
env: finalEnv
})
+ // The daemon must inherit the finalized hook environment before the shell starts.
+ if (jcodeRuntimeDir) {
+ prewarmJcodeDaemon({
+ launchAgent: args.launchAgent,
+ runtimeDir: jcodeRuntimeDir,
+ cwd: args.cwd,
+ env: finalEnv
+ })
+ }| function exceedsWindowsCommandLineBudget(command: string, args: string[]): boolean { | ||
| let units = command.length + args.length | ||
| for (const arg of args) { | ||
| units += arg.length + 2 |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '80,200p' src/main/text-generation/source-control-local-process.ts
rg -n "on\('error'|\.on\(\"error\"|shell: |\.cmd" src/main/text-generation | head -30Repository: stablyai/orca
Length of output: 5183
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- source-control-local-process imports, guard, and spawn setup ---'
sed -n '1,125p' src/main/text-generation/source-control-local-process.ts
printf '%s\n' '--- source-control-local-process handlers ---'
sed -n '145,245p' src/main/text-generation/source-control-local-process.ts
printf '%s\n' '--- spawnAgent bindings ---'
rg -n -C 5 "spawnAgent" src/main/text-generation src/main | head -160
printf '%s\n' '--- jcode plan/default command ---'
rg -n -C 8 "jcode|binary:|customAgentCommand" src/main/text-generation | head -220Repository: stablyai/orca
Length of output: 41763
🏁 Script executed:
sed -n '1,125p' src/main/text-generation/source-control-local-process.ts; sed -n '145,245p' src/main/text-generation/source-control-local-process.ts; rg -n -C 5 "spawnAgent" src/main/text-generation src/main | head -160; rg -n -C 8 "jcode|binary:|customAgentCommand" src/main/text-generation | head -220Repository: stablyai/orca
Length of output: 41308
🏁 Script executed:
rg -n -C 12 "spawnAgent" src/main
rg -n -C 12 "jcode" src/mainRepository: stablyai/orca
Length of output: 43264
🏁 Script executed:
set -e
printf '%s\n' '--- exact spawn helper locations ---'
rg -l "spawnSourceControlAgent|function spawnSourceControlAgent|const spawnSourceControlAgent" src
printf '%s\n' '--- exact jcode plan locations ---'
rg -l "planCommitMessageGeneration|getAgentModelProbeSpec|jcode" src/main/text-generation src/main/shared 2>/dev/null | head -40
printf '%s\n' '--- exact definitions ---'
rg -n -C 18 "spawnSourceControlAgent|planCommitMessageGeneration|getAgentModelProbeSpec" src/main/text-generation src/main | head -260Repository: stablyai/orca
Length of output: 26896
🏁 Script executed:
set -e
printf '%s\n' '--- source-control-agent-launch.ts ---'
sed -n '1,180p' src/main/text-generation/source-control-agent-launch.ts
printf '%s\n' '--- Windows command helpers ---'
rg -n -C 12 "function resolveCliCommand|const resolveCliCommand|function getSpawnArgsForWindows|const getSpawnArgsForWindows|resolveCliCommand|getSpawnArgsForWindows" src/main
printf '%s\n' '--- plan implementation ---'
rg -l "export function planCommitMessageGeneration|function planCommitMessageGeneration" src shared
rg -n -C 18 "planCommitMessageGeneration" src sharedRepository: stablyai/orca
Length of output: 41837
🏁 Script executed:
set -e
printf '%s\n' '--- commit-message-plan.ts ---'
sed -n '1,240p' src/shared/commit-message-plan.ts
printf '%s\n' '--- windows-batch-spawn.ts ---'
sed -n '1,240p' src/shared/windows-batch-spawn.tsRepository: stablyai/orca
Length of output: 12928
🏁 Script executed:
set -e
sed -n '240,430p' src/shared/commit-message-plan.ts
rg -n -C 18 "jcode|getCommitMessageAgentSpec|promptDelivery|prompt" src/shared/commit-message-agent-spec.ts src/shared/commit-message-plan.tsRepository: stablyai/orca
Length of output: 31955
🏁 Script executed:
set -e
rg -n -C 8 "jcode|buildSecondaryCommitMessageAgentSpecs|promptDelivery: 'argv'|binary:" src/shared/commit-message-agent-spec.ts src/shared/commit-message-prompt.ts src/sharedRepository: stablyai/orca
Length of output: 42080
🏁 Script executed:
set -e
rg -n -C 24 "export function resolveCliCommand|function resolveCliCommand|resolveCliCommand" src/main/codex-cli/command.ts src/shared/node-cli-command-resolution.tsRepository: stablyai/orca
Length of output: 10178
🏁 Script executed:
sed -n '90,160p' src/shared/node-cli-command-resolution.tsRepository: stablyai/orca
Length of output: 2943
Budget the effective Windows launcher command.
Jcode puts the prompt in argv as jcode run --json <prompt>. When Windows resolves jcode to a .cmd shim, spawnSourceControlAgent launches it through cmd.exe /d /c. The current 30,000-unit guard runs before resolution and does not enforce cmd.exe’s lower command-length limit. A large prompt can pass the guard and still fail during launch.
The failure is returned as success: false through the child error or close handler. It does not cause a hang or crash. Quotation marks are not a useful trigger for the batch-shim case because getSpawnArgsForWindows rejects them before spawning. Calculate the effective command after resolution and apply the limit for the selected launcher.
| // clap rejects them after `run`. | ||
| '--no-update', | ||
| '--quiet', | ||
| '--no-selfdev', |
There was a problem hiding this comment.
🔒 Security & Privacy | 🛡️ Detected with Advanced Tier | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
set -eu
printf '%s\n' '--- target symbols and cited lines ---'
ast-grep outline src/shared/commit-message-agent-specs-secondary.ts
sed -n '230,315p' src/shared/commit-message-agent-specs-secondary.ts
printf '%s\n' '--- Jcode references ---'
rg -n -C 3 --glob '!node_modules' --glob '!dist' --glob '!build' 'jcode|Jcode|no-selfdev|commit-message-agent' src package.json pnpm-lock.yaml yarn.lock package-lock.json 2>/dev/null | head -240
printf '%s\n' '--- changed hunk summary ---'
git diff --stat 519bde81df438478ff1c6ac010f1339f32a306ee 7c0eee69d77535f783d31c1937e279d6d0c4181a -- src/shared/commit-message-agent-specs-secondary.ts src/shared/commit-message-agent-spec.ts
git diff --unified=25 519bde81df438478ff1c6ac010f1339f32a306ee 7c0eee69d77535f783d31c1937e279d6d0c4181a -- src/shared/commit-message-agent-specs-secondary.ts | sed -n '1,260p'Repository: stablyai/orca
Length of output: 24955
🌐 Web query:
Jcode CLI run --no-selfdev MCP tools shell write permissions
💡 Result:
Inspection citation: inspection_8d9f3557cd8ff1e1b03bd384d21d09d2
<source_evidence>
Citations:
- 1: https://github.com/1jehuang/jcode/blob/f8004dbd/src/cli/args.rs
- 2: https://github.com/1jehuang/jcode/blob/master/docs/WRAPPERS.md
- 3: http://github.com/1jehuang/jcode
- 4: GitHub issue 390 in 1jehuang/jcode (link omitted to avoid creating a cross-reference)
- 5: https://github.com/1jehuang/jcode/blob/a63dbc45/src/cli/dispatch.rs
- 6: https://github.com/1jehuang/jcode/blob/a63dbc45/crates/jcode-base/src/config.rs
- 7: https://github.com/1jehuang/jcode/blob/a63dbc45/crates/jcode-base/src/config/default_file.rs
- 8: https://github.com/1jehuang/jcode/blob/a63dbc45/crates/jcode-app-core/src/tool/write.rs
- 9: https://github.com/1jehuang/jcode/blob/a63dbc45/crates/jcode-app-core/src/tool/bash_tests.rs
🌐 Web query:
site:github.com/1jehuang/jcode default tool profile shell write MCP tool-profile none
💡 Result:
Inspection citation: inspection_9c230d15a4d6c5877a1df338332e5d22
<source_evidence>
Citations:
- 1: https://github.com/1jehuang/jcode/blob/f8004dbd/src/cli/args.rs
- 2: https://github.com/1jehuang/jcode/blob/435fb4a8/src/cli/dispatch.rs
- 3: https://github.com/1jehuang/jcode/blob/435fb4a8/crates/jcode-tool-types/src/lib.rs
- 4: https://github.com/1jehuang/jcode/blob/435fb4a8/crates/jcode-app-core/src/tool/tests.rs
- 5: https://github.com/1jehuang/jcode/blob/435fb4a8/crates/jcode-app-core/src/tool/bash.rs
- 6: https://github.com/1jehuang/jcode/blob/master/README.md
- 7: GitHub pull request 417 in 1jehuang/jcode (link omitted to avoid creating a cross-reference)
- 8: https://github.com/1jehuang/jcode/blob/a63dbc45/crates/jcode-base/src/mcp/tool.rs
LLM Security
Reachability: External
Exploitability: Moderate
CWE: CWE-1427
Restrict tools for commit-message generation.
jcode run receives the staged patch as its prompt, but this invocation only sets --no-selfdev. It does not pass --tool-profile none or disable MCP. Jcode exposes shell, read, write, and MCP tools; its shell tool runs commands in the agent working directory. A malicious patch can therefore prompt Jcode to use the user's workspace or configured external tools. Run this action with an explicit no-tool profile and MCP disabled.
There was a problem hiding this comment.
Important
A few real defects to address before merge. The strongest are in the hand-rolled [hooks] TOML editing — removeJcodeManagedHooks can delete a user-owned line and is a silent no-op on Windows — and the daemon pre-warm only runs on the LocalPtyProvider spawn path, so the orchestration fix may not fire on the default local backend.
Reviewed changes
- jcode hook layer — new
src/main/jcode/(hook-settings, byte-preservinghook-configTOML edit,hook-serviceinstall/remove/status/remote,daemon-prewarm), registered in the managed-hook and remote-installer registries plus the script refresher. - Per-pane runtime dir + pre-warm — new
shared/jcode-runtime-dir.ts;JCODE_RUNTIME_DIRstamped inspawn-env.tsand the (nowasync)buildTerminalWorkspaceEnv;spawnLocalPtycreates the dir and pre-warms the daemon. - Live status / questions / notifications — new jcode listener provider, tool fields and transcript reader, wired through
provider-dispatch, event routing, source routing and the hook relay. - Title / row naming —
jcode-terminal-title.tsrejects jcode's repainting identity title so agent rows fall back to the prompt. - OSC color-reply skip — startup ingress, headless policy and the renderer capability handlers; the pane launch-agent ladder is extracted to a pure, tested module (fixes the original pane-connect crash).
- AI Vault / Source Control AI / resume — jcode session parser + sources, argv-prompt commit-message spec with
jcode model listdiscovery,[Tokens]/JSON output cleanup, Windows argv budget guard, and resume/agent-type/icon/catalog/i18n registrations.
⚠️ Evidence document referenced by the new code is not in the PR
Three added files cite docs/reference/jcode-hook-events.md as the source of jcode's captured payloads and terminal titles (agent-hook-listener-jcode.test.ts:11, jcode-terminal-title.ts:5, jcode-terminal-title.test.ts:5), and the PR body says it was added — but no such file is in the diff or the tree. Without it the payload contracts the listener is written against are unverifiable, which is exactly what the repo's transcript-capture convention exists to prevent.
Technical details
# Missing evidence doc
## Affected sites
- src/shared/agent-hook-listener-jcode.test.ts:11 — "see docs/reference/jcode-hook-events.md"
- src/shared/jcode-terminal-title.ts:5 — same reference
- src/shared/jcode-terminal-title.test.ts:5 — same reference
- docs/reference/ — no jcode file exists
## Required outcome
- Commit the captured jcode payloads/titles under docs/reference/jcode-hook-events.md, or drop the references and the PR-body claim.
ℹ️ Windows .cmd gate POST is synchronous, unlike the POSIX script
The POSIX managed script background-s the pre_tool POST and exits immediately precisely because jcode blocks the tool call until the gate exits; the Windows .cmd branch runs buildWindowsAgentHookPostCommand('jcode') inline after draining stdin. In the normal case the curl round trip is small, but a slow or unreachable hook server makes every Windows tool call sit on the 1.5 s --max-time the detached POSIX path exists to avoid.
Technical details
# Windows pre_tool gate is not detached
## Affected sites
- src/main/jcode/hook-service.ts — getManagedScript() win32 branch builds the .cmd with an inline POST
- src/main/agent-hooks/hook-stdin-contract.ts:205 — the drain epilogue
## Required outcome
- Confirm whether jcode on Windows waits on the hook to EOF like POSIX; if it does, detach the pre_tool POST there too (or document the Windows cost as accepted).
ℹ️ WSL jcode panes still share one daemon
shouldInjectJcodeRuntimeDir gates on process.platform === 'win32', so a WSL pane — spawned by a Windows Orca but running in a Linux guest where unix sockets exist — gets no per-pane runtime dir and falls back to the shared guest daemon. That is the same cross-pane status misattribution this PR fixes for native panes, just displaced to WSL; the comment frames it as Windows.
Technical details
# WSL excluded from the runtime dir by a Windows platform check
## Affected sites
- src/shared/jcode-runtime-dir.ts:23-26 — shouldInjectJcodeRuntimeDir(platform)
- src/main/ipc/pty/ipc/spawn-env.ts:149 — skip also requires !args.connectionId, which WSL panes set
## Open questions for the human
- Is a WSL jcode pane a supported target? If so it needs its own decision, not the win32 branch.
ℹ️ Nitpicks
ensureJcodeRuntimeDircallsmkdirunguarded and is awaited on the terminal-create path for every local pane (orca-runtime-resolve-browser-environment…:170-171), so a tmpdir error fails PTY creation for non-jcode shells; the pre-warm itself is deliberately fail-open.JCODE_RUNTIME_DIRisn't deleted on remote paths, only skipped (spawn-env.ts:149), unlike the pane-key/launch-token scrub just above it.modelis emitted only onturn_start/turn_end, so apre_tool/post_toolrow drops the model for shared-store readers (worktree ps, mobile) even though the renderer masks it.isJcodeManagedCommand(hook-settings.ts:66) is exported but unused.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| if (trimmed.length === 0) { | ||
| return null | ||
| } | ||
| return trimmed.split('.').map((segment) => segment.trim().replace(/^"|"$/g, '')) |
There was a problem hiding this comment.
parseTomlTablePath strips only double quotes and has no dotted-key support, so valid-but-non-canonical spellings — ['hooks'], a top-level hooks.turn_end = …, or a dotted turn_end.foo inside the table — are not recognized as the hooks table. applyJcodeManagedHooks then appends a second [hooks] table (or a colliding key) and jcode stops parsing the whole config, while parseJcodeHooksTable returns {} rather than null, so the install() guard cannot catch it. The repo already has parseTomlTableHeaderPath in src/main/codex/config-toml-key-path.ts that handles quoted keys; the scalar check also rejects a valid commented value (pre_tool_timeout_ms = 5000 # ms), which makes install() report error and never install.
Technical details
# Hand-rolled `[hooks]` parser misses valid TOML spellings
## Affected sites
- src/main/jcode/hook-config.ts:68-74 — `parseTomlTablePath` ignores `'…'` and dotted paths
- src/main/jcode/hook-config.ts:64-66 — `isTomlScalarValue` matches the whole remainder, so a trailing comment is a false parse error
- src/main/jcode/hook-config.ts:146-149 — append branch writes the duplicate table
- src/main/codex/config-toml-key-path.ts:12 — existing `parseTomlTableHeaderPath` handles these
## Required outcome
- A file with `['hooks']`, `hooks.<event> = …`, or a dotted sub-key must not gain a duplicate `[hooks]` / colliding key on install.
- A scalar hook setting with an inline comment must not make install report `error`.
## Suggested approach (optional)
- Reuse the codex key-path parser; strip an inline comment before the scalar test.| @@ -607,11 +607,14 @@ | |||
| "0708ed89f1": "Claude", | |||
| "fc80296033": "Devin", | |||
| "da41abbdd4": "Ante", | |||
| "mimo_code_label": "MiMo Code", | |||
| "jcode_label": "Jcode", | |||
There was a problem hiding this comment.
This adds jcode_label (and mimo_code_label) a second time — both already exist further down the same object, and the identical duplicate pair is in es.json, ja.json, ko.json and zh.json. JSON.parse keeps the last value so it renders, but the redundant entries should be de-duplicated in all five locale files.
81d6431 to
d520fab
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 57ed837e-d4f6-4060-a5c9-fab426250866
📥 Commits
Reviewing files that changed from the base of the PR and between 7c0eee69d77535f783d31c1937e279d6d0c4181a and d520fab.
⛔ Files ignored due to path filters (1)
src/shared/agent-icons/jcode.pngis excluded by!**/*.png
📒 Files selected for processing (17)
src/main/jcode/daemon-prewarm.test.tssrc/main/jcode/daemon-prewarm.tssrc/main/jcode/hook-gate-script.test.tssrc/main/jcode/hook-service.test.tssrc/main/jcode/hook-service.tssrc/renderer/src/components/terminal-pane/pty-connection/pane-launch-agent-candidate.tssrc/shared/agent-hook-listener-jcode.test.tssrc/shared/agent-hook-listener.tssrc/shared/agent-hook-listener/command-code-transcript.tssrc/shared/agent-hook-listener/providers/jcode-events.tssrc/shared/agent-hook-listener/providers/jcode-tool-fields.tssrc/shared/agent-hook-listener/reverse-file-region-scan.test.tssrc/shared/agent-hook-listener/reverse-file-region-scan.tssrc/shared/agent-hook-listener/transcript-reader.tssrc/shared/jcode-session-files.tssrc/shared/jcode-terminal-title.test.tssrc/shared/jcode-terminal-title.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.
| it('warms each runtime dir at most once', () => { | ||
| prewarmJcodeDaemon({ launchAgent: 'jcode', runtimeDir: '/tmp/orca-jcode/abc' }) | ||
| prewarmJcodeDaemon({ launchAgent: 'jcode', runtimeDir: '/tmp/orca-jcode/abc' }) | ||
| prewarmJcodeDaemon({ launchAgent: 'jcode', runtimeDir: '/tmp/orca-jcode/def' }) | ||
| expect(spawnProcessMock).toHaveBeenCalledTimes(2) | ||
| }) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Pin platform in the dedupe and retry tests.
Two tests omit platform: Lines 49-54 and Lines 78-86. prewarmJcodeDaemon then uses process.platform. On a Windows test host, prewarmTarget returns null and spawnProcessMock is never called. Both assertions that the mock was called twice then fail. The test at Lines 20-37 already passes platform: 'darwin'. Use the same value in these two tests.
💚 Proposed fix
- prewarmJcodeDaemon({ launchAgent: 'jcode', runtimeDir: '/tmp/orca-jcode/abc' })
- prewarmJcodeDaemon({ launchAgent: 'jcode', runtimeDir: '/tmp/orca-jcode/abc' })
- prewarmJcodeDaemon({ launchAgent: 'jcode', runtimeDir: '/tmp/orca-jcode/def' })
+ const platform = 'darwin' as const
+ prewarmJcodeDaemon({ launchAgent: 'jcode', runtimeDir: '/tmp/orca-jcode/abc', platform })
+ prewarmJcodeDaemon({ launchAgent: 'jcode', runtimeDir: '/tmp/orca-jcode/abc', platform })
+ prewarmJcodeDaemon({ launchAgent: 'jcode', runtimeDir: '/tmp/orca-jcode/def', platform })Apply the same platform: 'darwin' change to both prewarmJcodeDaemon calls in the retry test.
Also applies to: 78-86
| scanFileRegionsBackward( | ||
| journalPath, | ||
| { chunkBytes: JCODE_JOURNAL_CHUNK_BYTES, maxScanBytes: JCODE_SESSION_SCAN_BYTES }, | ||
| (region) => | ||
| readLastUserMessageFromJournalLines(region.toString('utf8').split('\n'), sessionId) ?? | ||
| undefined | ||
| ) ?? null |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,204p' src/shared/jcode-session-files.ts
rg -n 'promptInteractionKey|interactionKey' src/shared src/main --glob '!*.test.ts' | head -60Repository: stablyai/orca
Length of output: 11671
🏁 Script executed:
set -e
printf '%s\n' '--- reverse scanner ---'
cat -n src/shared/agent-hook-listener/reverse-file-region-scan.ts
printf '%s\n' '--- provider dispatch ---'
cat -n src/shared/agent-hook-listener/provider-dispatch.ts | sed -n '1,230p'
printf '%s\n' '--- listener ---'
cat -n src/shared/agent-hook-listener.ts | sed -n '150,215p'
printf '%s\n' '--- server status application ---'
cat -n src/main/agent-hooks/server/server-status-application.ts | sed -n '1,235p'
printf '%s\n' '--- prompt key consumers and tests ---'
rg -n -C 5 'promptInteractionKey|previousPromptInteractionKey|incomingPromptInteractionKey|hasTranscriptPromptEvidence' src/main src/shared --glob '*.{ts,tsx}' | head -260Repository: stablyai/orca
Length of output: 42514
🏁 Script executed:
set -e
printf '%s\n' '--- server timing and telemetry ---'
cat -n src/main/agent-hooks/server/server-status-application.ts | sed -n '90,225p'
printf '%s\n' '--- prompt evidence and event routing ---'
rg -n -C 8 'function hasExplicitUserPrompt|export function hasExplicitUserPrompt|isNewTurnEvent|normalizeJcodeEvent' src/shared/agent-hook-listener
printf '%s\n' '--- jcode provider events ---'
cat -n src/shared/agent-hook-listener/providers/jcode-events.tsRepository: stablyai/orca
Length of output: 42183
🏁 Script executed:
set -e
rg -n -C 12 'hasExplicitUserPrompt' src/shared/agent-hook-listener.ts src/shared/agent-hook-listener --glob '*.ts'Repository: stablyai/orca
Length of output: 6730
🏁 Script executed:
cat -n src/shared/agent-hook-listener/provider-event-routing.ts | sed -n '81,135p'Repository: stablyai/orca
Length of output: 2555
🏁 Script executed:
set -e
printf '%s\n' '--- all promptInteractionKey consumers ---'
rg -n -C 4 'promptInteractionKey|interactionKey' --glob '*.{ts,tsx,js,jsx}' .
printf '%s\n' '--- jcode turn-end/session-end references ---'
rg -n -C 5 "turn_end|session_end" src docs --glob '*.{ts,tsx,md}' | head -240Repository: stablyai/orca
Length of output: 42463
Use the journal line’s absolute byte offset in the interaction key.
scanFileRegionsBackward provides regionPosition, but readLastUserMessageFromJournal drops it and salts the key with the region-local index. When a journal exceeds 64 KiB, appending records can change that index for the same message.
The prompt hash suppresses repeats during normal working and working-to-done events. However, a repeated turn_end can reach the server as two done events with different keys, which bypasses the same-hash dedupe and can emit duplicate agent_prompt_sent telemetry.
Suggested fix
- (region) =>
- readLastUserMessageFromJournalLines(region.toString('utf8').split('\n'), sessionId) ??
- undefined
+ (region, regionPosition) =>
+ readLastUserMessageFromJournalLines(region, regionPosition, sessionId) ?? undefinedUpdate readLastUserMessageFromJournalLines to split the Buffer on 0x0a, track each line’s byte offset as regionPosition + lineStart, and use ${lineOffset}:${messageIndex}:${text} as the salt.
📝 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.
| scanFileRegionsBackward( | |
| journalPath, | |
| { chunkBytes: JCODE_JOURNAL_CHUNK_BYTES, maxScanBytes: JCODE_SESSION_SCAN_BYTES }, | |
| (region) => | |
| readLastUserMessageFromJournalLines(region.toString('utf8').split('\n'), sessionId) ?? | |
| undefined | |
| ) ?? null | |
| scanFileRegionsBackward( | |
| journalPath, | |
| { chunkBytes: JCODE_JOURNAL_CHUNK_BYTES, maxScanBytes: JCODE_SESSION_SCAN_BYTES }, | |
| (region, regionPosition) => | |
| readLastUserMessageFromJournalLines(region, regionPosition, sessionId) ?? undefined | |
| ) ?? null |
| export function readLastJcodeUserPromptFromHookPayload( | ||
| hookPayload: Record<string, unknown> | ||
| ): JcodeUserPromptEvidence | null { | ||
| const sessionId = hookPayload.session_id ?? hookPayload.sessionId | ||
| if (!isSafeJcodeSessionId(sessionId)) { | ||
| return null | ||
| } | ||
| return ( | ||
| readLastUserMessageFromJournal(sessionJournalPath(sessionId), sessionId) ?? | ||
| readLastUserMessageFromJson(sessionFilePath(sessionId), sessionId) | ||
| ) | ||
| } |
There was a problem hiding this comment.
🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
rg -nP -C8 '\bfunction hasExplicitUserPrompt\b' src/shared
rg -nP -C3 'hasTranscriptPromptEvidence' src/sharedRepository: stablyai/orca
Length of output: 7564
🏁 Script executed:
#!/bin/bash
printf '%s\n' '--- provider-dispatch.ts ---'
sed -n '1,215p' src/shared/agent-hook-listener/provider-dispatch.ts
printf '%s\n' '--- provider-event-routing.ts ---'
sed -n '1,145p' src/shared/agent-hook-listener/provider-event-routing.ts
printf '%s\n' '--- agent-hook-listener.ts prompt/cache references ---'
rg -n -C6 'resolvePrompt|lastPromptByPaneKey|isNewTurnEvent|normalizeProviderEvent|normalizeJcodeEvent' src/shared/agent-hook-listener.ts src/shared/agent-hook-listener
printf '%s\n' '--- jcode-session-files.ts ---'
sed -n '1,240p' src/shared/jcode-session-files.tsRepository: stablyai/orca
Length of output: 42064
🏁 Script executed:
sed -n '1,215p' src/shared/agent-hook-listener/provider-dispatch.ts; sed -n '1,145p' src/shared/agent-hook-listener/provider-event-routing.ts; rg -n -C6 'resolvePrompt|lastPromptByPaneKey|isNewTurnEvent|normalizeProviderEvent|normalizeJcodeEvent' src/shared/agent-hook-listener.ts src/shared/agent-hook-listener; sed -n '1,240p' src/shared/jcode-session-files.tsRepository: stablyai/orca
Length of output: 42681
<inspected_source>The Jcode branch in src/shared/agent-hook-listener/provider-dispatch.ts:158-168 calls readLastJcodeUserPromptFromHookPayload for every event. The reader performs synchronous bounded file scans and JSON parsing in src/shared/jcode-session-files.ts:128-204. This includes pre_tool and post_tool events.</inspected_source>
<inspected_source>resolvePrompt caches only prompt text in state.lastPromptByPaneKey (src/shared/agent-hook-listener/prompt-fields.ts:97-114). The dispatch result initializes hasTranscriptPromptEvidence to false for each event (src/shared/agent-hook-listener/provider-dispatch.ts:49-52).</inspected_source>
<inspected_source>hasExplicitUserPrompt requires transcript evidence for Jcode turn_start, pre_tool, post_tool, and turn_end (src/shared/agent-hook-listener/provider-event-routing.ts:101-113).</inspected_source>
Cache Jcode transcript evidence before non-turn events.
normalizeProviderEvent performs a synchronous journal scan and possible JSON parse for every Jcode event. During tool use, this repeats for pre_tool and post_tool and can delay the listener.
Read the transcript on isNewTurnEvent('jcode', eventName), or when the pane has no Jcode evidence cache. Cache the complete result, including the prompt text, interaction key, and transcript-evidence flag, for later events. Caching only state.lastPromptByPaneKey is not sufficient because hasExplicitUserPrompt also requires hasTranscriptPromptEvidence on non-turn events.
There was a problem hiding this comment.
Important
The Windows jcode hook never sends the payload, so no jcode event reaches Orca there. The POSIX branch was just migrated to post $JCODE_HOOK_PAYLOAD verbatim; the .cmd branch still posts curl's stdin and has no %JCODE_HOOK_PAYLOAD% reference. This is the only new must-address item — the reverse-scan fold and the POSIX transport migration both check out.
Reviewed changes
- Folded the three near-copy reverse chunked line scans (
transcript-reader,command-code-transcript, and the jcode journal reader) into one shared, testedscanFileRegionsBackward; region boundaries,regionPositionbyte offsets, and the command-codeinteractionKeyare preserved. - Switched jcode's managed POSIX hook from its hand-rolled
curltobuildPosixAgentHookPostCommand, posting$JCODE_HOOK_PAYLOADverbatim and draining thepre_toolstdin before the environment guard. - Read jcode's lifecycle point from the payload's own
eventkey (the shared transport no longer restates it as a form field), with a test pinning the shape. - Replaced
normalizeJcodeEvent's inline ternaries with aJCODE_EVENT_STATEStable and hoisted the failed-turn error text ahead of the snapshot. - Consolidated
daemon-prewarmonto a single entry point and renamed the jcode title stripper tostripJcodeTitleStatuswith one combined regex.
ℹ️ Nitpicks
src/shared/agent-hook-listener/transcript-reader.ts:6—EMPTY_TRANSCRIPT_REGIONis now referenced nowhere after the fold (only its declaration remains); drop the export.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
d520fab to
d3e9b85
Compare
There was a problem hiding this comment.
ℹ️ No critical issues — the type-narrowing pass is behavior-neutral and the new Windows suite pins the generated
.cmd's shape. One coverage gap noted inline: that suite cannot fail while the known Windows payload gap is present.
Reviewed changes
- Replaced the
Reflect.get-based dynamic reads with narrowing predicates —hasIntentFieldinjcode-tool-fields.tsandisJcodeJsonResultincommit-message-agent-output.ts— so the anti-slop audit passes without changing behavior. - Added a platform-mocked
the Windows managed hooksuite inhook-gate-script.test.ts, pinning the generated.cmd's ordering (environment guard before thepre_toolstdin drain), CRLF line endings,@echo off,exit /b 0, and themore.comdrain. - Documented the Windows guard-before-drain rationale in
hook-service.ts(comments only; the emitted script is unchanged). - Re-aligned a markdown table in
docs/bug-reproductions/opencode2-form-created-kinds/README.md.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
4c64022 to
f161781
Compare
🧪 Jcode first-class support is ready to test — please try itAn installable build of this PR is up. If you opened, commented on, or reacted to a Jcode request, you're exactly who I need: @czzczz @dcieslak19973 @dm13379 @dommer1 @duane-eldridge @edheltzel @eric-akkio @guiguan @IvanProg00 @JianJia2018 @Jp-CB-IN0010 @lnilluv @NickSchouten @OrcaWin @shashwattrili @sirinath @termez19 @vpelikh
This is a throwaway dev build from a branch. It installs alongside nothing — back up anything you care about, and switch back to your normal Orca when you're done. Setup
What to check (any subset is useful — even one line of feedback helps)
🪟 Windows testers especially wantedI could not test Windows on real hardware. One bug there was only found in review: Orca was sending Jcode's hook payload the wrong way, so Windows panes showed no status at all. That's fixed but unverified — if you're on Windows, item #1 above is the single most valuable thing anyone can report. Also unverified: SSH/remote Jcode panes. How to reportReply here with your OS + whether each thing worked. Screenshots welcome. A "tried it, #1 and #2 work on Windows" is genuinely useful — I'd rather have three short confirmations than none. Known gaps, already documented in the PR, no need to report: remote Once a few people confirm this works — especially on Windows — we can approve and merge. 🙏 |

ELI5
Jcode is a fast coding agent that runs in a terminal. Orca could already start it, but once it was running Orca had no idea what it was doing — no live status, no "it's asking you something", no way to send it work, and it couldn't be used as an orchestration worker.
This makes Jcode behave like Claude, Codex and the rest: you can see what it's doing while it does it, you get told when it finishes or needs you, you can send it a prompt from anywhere in the app, hand it a task as a supervised worker, use it to write commit messages, and find and resume its past sessions.
What Changed
This takes over #10521 (@czzczz), rebases it onto current
main, and finishes the integration.Status — from "after the fact" to live. The original wiring only subscribed to jcode's
post_toolandturn_end, so a pane sat blank from the moment you hit Enter until the first tool finished, and a three-minutebashshowed nothing at all. Orca now also subscribes to:turn_start— jcode fires this the instant a prompt is submitted, before the model generates. That is the window that used to be blank.pre_tool— the only event that carries the tool's arguments, so the row can say "read README.md" while it runs rather than after.Every mapping is written against jcode's own captured payloads, recorded and documented in a new
docs/reference/jcode-hook-events.md.pre_toolis a gate, so it is handled as one. jcode blocks the tool call until the hook exits and reads its stderr to EOF. The managed script therefore drains the tool input off stdin (a largewriteexceeds the pipe buffer and would stall the agent mid-write) and runs the POST detached with both pipes closed. A contract test pins this: with a server that accepts and never replies, a synchronous POST takes 1522 ms per tool call and the detached one takes ~10 ms.Questions. jcode has no per-tool approval prompt — its safety model denies or asks the model to justify, both inside the tool. The one tool a human answers is ambient mode's
request_permission. Apre_toolfor it now maps towaitingand publishes the full tool input as the question card;post_tooldeliberately does not, because by then the human has already answered. The original substring matcher (ask/confirm/permission…) is replaced with jcode's real tool names.Agent rows showed jcode's screensaver instead of your work. jcode repaints its OSC title about once a second as
🌐 jcode Puppy · +3 -0 · last ~23s. Orca accepted that as the row's conversation name, so a jcode row readjcode Pupp…where the Claude row beside it read the prompt and the reply. Orca now recognises that title shape as identity, not content, and falls back to the prompt like every other agent.Orchestration didn't work at all. A dispatched jcode worker died at
agent_readinesswithTimed out waiting for responsive server socket. Cause: Orca gives every pane its ownJCODE_RUNTIME_DIR, so every jcode pane is a cold daemon start, and jcode's client waits a hardcoded 5 s for that socket. Orca now starts the pane's daemon as the PTY spawns, giving it the shell's own startup time as head start. Same dispatch now reachesworker: succeeded.A crash the original introduced. Its new OSC-color-reply skip called the pane launch-agent ladder on every pane connect, where an unguarded
?.identity.agentTypethrew — 24 failures across 8connectPanePtysuites. The ladder is now a pure, tested module, and the skip is evaluated per query rather than captured at install time (a pane connects before its launch agent is registered, so the captured verdict answered jcode's burst anyway — the exact leak the skip exists to prevent).One reverse-scan, not three. The jcode journal reader the original added was a near-copy of
command-code-transcript.ts's reverse chunked line scan, which is itself a near-copy oftranscript-reader.ts's. All three now share one testedscanFileRegionsBackward— a net deletion, and the subtle carry-chunk arithmetic lives in one place. jcode's managed hook script likewise drops its hand-rolledcurlfor the sharedbuildPosixAgentHookPostCommand, which gains it the raw-JSON transport and the--noproxy 127.0.0.1guard the bespoke copy was missing (a user withhttp_proxyset was routing hook POSTs through their proxy). Two behaviour notes for the reviewer:transcript-readernow clamps its last chunk to the 4 MB budget instead of overshooting by up to one chunk, and jcode's event name is read from its owneventkey, since the shared transport posts the payload verbatim rather than restating fields on a form.Smaller fixes on top of #10521
removeJcodeManagedHooksrebuilt the config from the lines it kept but stopped at the table after[hooks]— uninstalling deleted every table declared after it. Regression-tested.jcode model listinstead of a hardcoded list that named models jcode does not have (claude-sonnet-4,gpt-5.4).turn_endkeeps the finished turn's tool, because the completion notification only fires when the done row carries a reply or a tool.Why
The gap this closes is the one @lnilluv described on #10521: launching was done, the hook layer was not. The follow-up work landed there, but against the events that are cheapest to consume rather than the ones that describe what jcode is doing. Reading
pre_toolis what makes the status live, and it is only safe because the gate contract is handled explicitly — hence the latency test rather than a comment promising it is fine.The alternative for per-pane attribution was to drop the per-pane daemon and let all panes share one, which is cheaper (~57 MB per extra daemon) but attributes every pane's events to whichever pane started the daemon. jcode does forward a client's terminal identity to hooks, but its allowlist covers tmux/zellij/herdr, not
ORCA_PANE_KEY; if that lands upstream the isolation and the pre-warm can both go.Linked Issue
Fixes #10830
Visual Proof
All captured in a real Orca dev build driving a real jcode 0.87.1, one worktree, one session.
Launch — jcode in the agent picker
https://github.com/user-attachments/assets/3b973806-1c03-4070-a17a-847b116d72b8
Status, live through one turn. Prompt: "Use bash to run: sleep 18 && echo SLOW. Then read README.md and say TRACE_DONE."
turn_start→ working, before any tool has run (this frame was blank before):https://github.com/user-attachments/assets/e2a3a68d-f9e5-4b55-a31f-4843be2c10ea
pre_tool→ the tool and its argument, while the tool runs:https://github.com/user-attachments/assets/ad9e7cf3-cb26-46be-b3c7-d1f5e6abc916
Working through a long
bash, with the model on the row:https://github.com/user-attachments/assets/e8b7512a-d105-4799-a373-788e4d101477
turn_end→ done, with the reply:https://github.com/user-attachments/assets/397ef5be-c0b6-454e-b31d-3d1b496eba36
Questions —
request_permissionmaps towaiting, orange "?" on both the workspace and the agent row, tool line naming the question:https://github.com/user-attachments/assets/9cf0d8e0-09b8-4be5-baa2-09b37ce2d9f0
Notifications — completion while backgrounded raises the unread bell on the workspace:
https://github.com/user-attachments/assets/2555747d-df61-465a-b7a2-0dba8f5b1e84
Send to agent — the jcode pane is an eligible target:
https://github.com/user-attachments/assets/e29b4c09-bc98-412a-aa07-0fa4715768a4
…and the prompt lands in the running TUI, which answers it:
https://github.com/user-attachments/assets/09de677e-92c0-4405-9d6a-748e7baf4976
Orchestration — a supervised jcode worker, nested under its coordinator, labelled with the orchestration task title and its reply (
worker: succeeded):https://github.com/user-attachments/assets/c7951eb9-a643-42e4-8c4c-2e99270306f5
Source Control AI — Jcode in the agent list:
https://github.com/user-attachments/assets/82104cbc-25fe-402e-b305-ba89f7039f14
…generating a commit message (the
[Tokens]usage line stripped):https://github.com/user-attachments/assets/0243188b-26a0-4df9-bf54-a7cd18ed3025
AI Vault — jcode sessions indexed with titles, previews, message counts and models:
https://github.com/user-attachments/assets/6a4d3dc6-5467-4622-99ec-ea66dcd7db83
orca worktree ps— the reader orchestration coordinators poll — showing the full round trip:[ { "branch": "jcode-worker-2", "agentType": "jcode", "state": "done", "prompt": "… === TASK === Read README.md in this worktree and reply with exactly: ORCHESTRATION_WORKER_OK", "lastAssistantMessage": "… here is the required response:\n\n**ORCHESTRATION_WORKER_OK**", "taskTitle": "jcode orchestration proof", "toolName": "bash" }, { "branch": "jcode-first-class", "agentType": "jcode", "state": "done", "prompt": "You have 1 orchestration message. Run `orca orchestration check --run run_89a54ed596b6`.", "lastAssistantMessage": "… The orchestration system has recorded that the README.md was read successfully." } ]Resume — the vault's own command, replayed against the session it names:
Testing
macOS, real jcode 0.87.1, real turns — everything above was driven through the app, not stubbed. The one exception is the
request_permissionquestion: jcode's ambient permission flow is not reachable from a normal TUI turn, so that event was delivered by running jcode's own installed hook script with the payload jcode produces for it. Everything downstream of the script is the real path.Automated — ~150 jcode-focused tests, including the gate-latency contract (mutation-checked: making the POST synchronous fails it at 1522 ms), the config-truncation regression, the pane-connect crash, the title/conversation-name rule, and listener mappings written against captured payloads.
pnpm tc,pnpm run check:code-quality:changed, andpnpm lintpass.Full
pnpm test: 5 files fail, and the same 5 fail onorigin/mainunchanged — verified byrunning that exact set in a worktree at the branch point. My branch fails fewer individual
tests than the base (19 vs 21; the difference is
claude-structured-real-cliflaking on a10s timeout). None are jcode-related:
browser-manager-viewport-ownershipmain(12/12, 6ms)claude-structured-real-cliopencode/hook-plugin-module-contracthooks?.event is not a function— needs the OpenCode plugin module installedcross-version-wire/release-checkoutgit rev-parse ~2^{commit}— this checkout is shallowrelay-region-correctionCannot find package 'pg'— relay workspace deps not installedAn earlier run of mine reported ~20 failing files; that run was contaminated by the Orca dev
app and jcode daemons competing for CPU during live validation, and every extra failure was
load-sensitive (terminal-history GC, SSH commands, a dialog test). On an idle machine they pass.
Not tested here: Windows and SSH. Both are code-reviewed — the runtime dir and the daemon pre-warm are non-Windows only, SSH terminals never receive the host-local socket path, and the Windows
.cmdhook drains stdin through the shared contract helper — but neither was exercised on real hardware.Known gap, called out rather than hidden: the desktop completion banner did not fire in this dev instance. Neither did Claude's, under an identical control run in the same instance, so it is environmental here rather than jcode-specific — but it means the banner itself is unproven. The in-app unread path is proven above, and a unit test pins the row detail the banner consumes.
Authorship
The base commit is @czzczz's, preserved with their authorship; every commit on top carries them as co-author.
AI Disclosure
Implemented with Claude (Opus 5). The jcode source was cloned and read to ground the hook mapping; every behavioural claim was checked against a running jcode rather than the model's recollection.
Review
spawnProcesswithstdio: 'ignore'and no shell.path.join.getStatuskeeps reportingpartialand preserving user-owned hooks and jcode's ownpre_tool_timeout_ms.config.tomlfails to parse for an unrelated reason, jcode silently stops firing all hooks while Orca still reports the install as healthy —getStatusonly parses the[hooks]table. Hit this during testing. Not fixed here; it needs a real parse probe.Agent skill upstream boundary
Checklist
pnpm lint,pnpm typecheckpass;pnpm testdifferences from base explained above