Repository navigation
test(runtime): pin the fail-closed contract for bare Cursor titles - #12816
Conversation
detectAgentStatusFromTitle intentionally returns null for the bare Cursor Agent title (hooks own status). classifyAgentTitle still needs to treat that title as agent so guarded sends protect the pane.
📝 WalkthroughWalkthroughThe runtime now accepts agent launch preferences in startup configuration and propagates them through normal and draft startup planning as overriding session options. Cursor Agent liveness checks no longer treat a bare 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
Reverts the classification change and keeps the behavior at base. cursor-agent's native OSC title is the bare literal "Cursor Agent" and never carries a status word, so it names the agent without proving one is present. The title tracker drops it live (terminal-output-side-effects.ts), which means main records it only when the stale-working timer strips the spinner off the synthesized "⠋ Cursor Agent" — and that timer fires both when Cursor parks idle and when cursor-agent exited and the shell reclaimed the pane. The two states are observationally identical: same title, same null foreground read. Classifying it as an agent therefore removes a refusal rather than adding evidence. Guarded sends auto-submit Enter, so the false positive types into the user's shell. A null foreground is also not "unreadable" on the default local provider — local-pty-provider.ts returns null when the pty is gone, so a bare identity title must not substitute for corroboration there either. hasPty, probePtyLiveness, hasChildProcesses and inspectProcess were each checked as corroborating signals; none separates alive-with-agent from alive-with-shell when the foreground read is unavailable. Tests pin every no-evidence branch fail-closed and document the mechanism, so both tempting fixes fail loudly if reintroduced. The real gap is at the controller/daemon layer, where "cannot read" is flattened into "nothing there" — tracked separately.
Jinwoo-H
left a comment
There was a problem hiding this comment.
Thanks for re-cutting this — the underlying complaint is real and it was worth chasing down.
I reproduced it against the real cursor-agent CLI, and the result went against the fix:
- Your premise checks out: cursor-agent's native title is the bare literal
Cursor Agentand never carries a status word. - But the tracker drops that title live, so main only records it when the stale-working timer strips the spinner off the synthesized
⠋ Cursor Agent. That fires both when Cursor parks idle and when cursor-agent exited and the shell reclaimed the pane — same title, same null foreground read. - So classifying it as an agent doesn't add evidence, it removes a refusal. Driving the real send guard: base rejects with
terminal_guard_no_agent; with the patch it accepts and sends text + Enter into a bare shell. I hit this end-to-end in the app too. classifyAgentTitleis also consumed by the session-tab status projection, so the change reintroduced #1437-style stuck status for dead Cursor panes.
I tried a narrower version — trust the title only when the foreground read fails — and that's wrong as well: getForegroundProcess() returning null is the exit signal on the local provider, not "unreadable". hasPty, probePtyLiveness, hasChildProcesses and inspectProcess were each checked as corroboration; none separates alive-with-agent from alive-with-shell.
So I've reverted the behavior and kept your branch as the regression contract — your test is still here, inverted to assert the safe direction. Retitled to match. Your original commit is untouched; my work is one commit on top.
The real bug is one layer down: when a foreground read is genuinely unavailable, "cannot read" gets flattened into "nothing there", which refuses any agent whose title isn't status-decorated. Filed separately.
|
Follow-up for the underlying bug filed as #12946 — "cannot read" being flattened into "nothing there" at the controller/daemon layer. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/runtime/orca-runtime.test.ts (1)
8555-8580: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the retained
nullstatus for the accepted bare-title case.This test is the only one that exercises the accept path for a bare Cursor title (confirmed
cursor-agentforeground). It asserts onlyisTerminalRunningAgentresolvestrue. It does not callgetTerminalAgentStatusto confirmstatus: null.The PR objective states that accepted panes must be "recognized as running agents while retaining a
nullstatus". No test locks in this exact status shape for the accept path. Add an assertion forgetTerminalAgentStatus, matching the pattern used in the sibling refusal tests at Line 8508-8512 and Line 8543-8547.✅ Suggested assertion to add
foreground = 'cursor-agent' const terminal = (await runtime.listTerminals()).terminals[0] await expect(runtime.isTerminalRunningAgent(terminal.handle)).resolves.toBe(true) + await expect(runtime.getTerminalAgentStatus(terminal.handle)).resolves.toEqual({ + handle: terminal.handle, + isRunningAgent: true, + status: null + })Based on learnings from the PR objectives: "these panes should be recognized as running agents while retaining a
nullstatus".
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a0496183-72eb-4554-a3eb-50f0052c99e0
📒 Files selected for processing (2)
src/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.ts
| prompt: string | undefined, | ||
| launchPreferences?: AgentLaunchPreferences |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Inspect how buildAgentStartupPlan/buildAgentResumeStartupPlan/buildAgentDraftLaunchPlan consume sessionOptions.
set -euo pipefail
fd -a 'tui-agent-startup.ts' | while IFS= read -r file; do
echo "=== $file ==="
rg -n -C 6 'sessionOptions' "$file"
doneRepository: stablyai/orca
Length of output: 220
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Candidate files"
fd -a 'orca-runtime.ts|tui-agent-startup.ts' .
echo
echo "Orca runtime lines around toAgentSessionOptions"
file=$(fd 'orca-runtime.ts' . | head -n1)
echo "file=$file"
sed -n '20920,20995p' "$file"
echo
echo "Search sessionOptionsOverrideAgentArgs / sessionOptions across repo"
rg -n 'sessionOptionsOverrideAgentArgs|toAgentSessionOptions|buildAgentStartupPlan|buildAgentResumeStartupPlan|buildAgentDraftLaunchPlan|tui-agent-startup' .Repository: stablyai/orca
Length of output: 27017
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "shared tui-agent-startup sessionOptions usages"
sed -n '1,130p' src/shared/tui-agent-startup.ts
echo
sed -n '180,315p' src/shared/tui-agent-startup.ts
echo
echo "shell helpers/sessionOptions and command construction"
fd -a 'tui-agent-startup-shell.ts|agent-launch-command.ts' . | while IFS= read -r file; do
echo "=== $file ==="
rg -n -C 8 'sessionOptions|launchCommand|spawn\(|child_process|quote|format|concat|join' "$file"
done
echo
echo "toAgentSessionOptions callers and values"
sed -n '20895,20990p' src/main/runtime/orca-runtime.ts
sed -n '24620,24690p' src/main/runtime/orca-runtime.ts
sed -n '24705,24755p' src/main/runtime/orca-runtime.ts
sed -n '24765,24792p' src/main/runtime/orca-runtime.ts
sed -n '24938,24960p' src/main/runtime/orca-runtime.ts
echo
echo "Type definitions for AgentLaunchPreferences"
rg -n 'interface AgentLaunchPreferences|type AgentLaunchPreferences|AgentLaunchPreferences\s*=' .Repository: stablyai/orca
Length of output: 25133
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Session option launch implementation"
sed -n '1,220p' src/shared/agent-session-option-launch.ts
echo
echo "Session option related tests"
rg -n -C 6 "model|effort|mode|SessionOptionValue|quoteStartupArg|inject|commandWithOptions|sessionOptions" src/shared src/renderer mobile/src --glob '!**/*.png'
echo
echo "Agent session create operation preferences source"
sed -n '1,130p' src/renderer/src/runtime/agent-session-create-operation.ts
echo
echo "Agent launch preferences declarations"
sed -n '1,130p' src/shared/agent-session-host-authority.ts
echo
echo "Programmatic quote/startup-shape probe"
node - <<'JS'
const shell = process.platform === 'win32' ? 'powershell' : 'posix';
function quoteStartupArg(value) {
if (shell === 'powershell') return `'${value.replace(/'/g, "''")}'`;
return `'${value.replace(/'/g, `'\\''`)}`;
}
const maliciousModel = `a --eval "shutil" --`;
const optionSuffix = [
'--session-option', 'model', quoteStartupArg(maliciousModel, shell),
'--session-option', 'effort', quoteStartupArg("normal", shell),
].join(' ');
console.log({ shell, optionSuffix });
console.log("unquoted_command: \"orca\" " + optionSuffix);
console.log("tokens_for_shell: " + JSON.stringify(optionSuffix.trim().split(/\s+/)));
JSRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "$file" | sed -n '1,220p'
sed -n '1,220p' src/shared/agent-session-option-launch.ts
echo
echo "Agent launch preferences declaration"
sed -n '85,115p' src/shared/agent-session-host-authority.ts
echo
echo "Narrow quote/startup-shape probe"
node - <<'JS'
const cases = ['posix', 'powershell', 'cmd'];
for (const shell of cases) {
function quoteStartupArg(value) {
if (shell === 'powershell') return `'${value.replace(/'/g, "''")}'`;
if (shell === 'cmd') return `"${value.replace(/([\^&|<>()%!"])/g, '^$1')}"`;
return `'${value.replace(/'/g, `'\\''`)}`;
}
const maliciousModel = 'a --eval "python -c print(1)" --';
const optionSuffix = [
'--session-option', 'model', quoteStartupArg(maliciousModel, shell),
'--session-option', 'effort', quoteStartupArg(' normal ', shell),
].join(' ');
console.log(JSON.stringify({ shell, optionSuffix, command: `orca ${optionSuffix}` }));
}
JSRepository: stablyai/orca
Length of output: 188
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "agent-session-option-launch.ts"
sed -n '1,220p' src/shared/agent-session-option-launch.ts
echo
echo "Agent launch preferences declaration"
sed -n '85,115p' src/shared/agent-session-host-authority.ts
echo
echo "Narrow quote/startup-shape probe"
node - <<'JS'
const cases = ['posix', 'powershell', 'cmd'];
for (const shell of cases) {
function quoteStartupArg(value) {
if (shell === 'powershell') return `'${value.replace(/'/g, "''")}'`;
if (shell === 'cmd') return `"${value.replace(/([\^&|<>()%!"])/g, '^$1')}"`;
return `'${value.replace(/'/g, `'\\''`)}`;
}
const maliciousModel = 'a --eval "python -c print(1)" --';
const optionSuffix = [
'--session-option', 'model', quoteStartupArg(maliciousModel, shell),
'--session-option', 'effort', quoteStartupArg(' normal ', shell),
].join(' ');
console.log(JSON.stringify({ shell, optionSuffix, command: `orca ${optionSuffix}` }));
}
JSRepository: stablyai/orca
Length of output: 3983
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Session option catalog definitions"
fd -a 'agent-session-option-catalog.ts' . | while IFS= read -r file; do
echo "=== $file ==="
sed -n '1,260p' "$file"
done
echo
echo "Native chat session option types"
sed -n '1,140p' src/shared/native-chat-session-options.ts
echo
echo "Session option validation tests around options"
rg -n -C 5 'quoteStartupArg|resolveAgentSessionOptionLaunch|resolveAgentLaunchCommand|session-options|sessionOptions|validate|catalog|modelOptions|optionApply|apply.launchArgs' src/shared/tui-agent-startup-session-options.test.ts src shared src/renderer/mobile --glob '*.test.ts' --glob '*.ts' --max-count 8Repository: stablyai/orca
Length of output: 50370
Validate session option values before they reach the agent launch command.
launchPreferences.model/effort/mode are trimmed strings that are quoted when appended to the shell command, but the quotes do not prevent shell metacharacters from being interpreted by the shell. The values should be allowed only if the session option catalog accepts them before resolveAgentSessionOptionLaunch renders shell args, or the rendered arg values should be rejected after catalog resolution before command construction.
|
@Jinwoo-H thanks for the real Agree the remaining bug is #12946 (foreground-read unavailability flattened into "nothing there"), not title classification. Leaving that for the core path unless you want an external PR against a narrower surface. |
…tablyai#12816) Reverts the classification change and keeps behavior at base. cursor-agent's native OSC title is the bare literal "Cursor Agent" and never carries a status word, so it names the agent without proving one is present. The title tracker drops it live, so main records it only when the stale-working timer strips the spinner off the synthesized "⠋ Cursor Agent" — and that fires both when Cursor parks idle and when cursor-agent exited and the shell reclaimed the pane. The two states are observationally identical: same title, same null foreground read. Classifying it as an agent therefore removes a refusal rather than adding evidence. Guarded sends auto-submit Enter, so the false positive types into the user's shell. A null foreground is also not "unreadable" on the default local provider, which returns null when the pty is gone. hasPty, probePtyLiveness, hasChildProcesses and inspectProcess were each checked as corroborating signals; none separates alive-with-agent from alive-with-shell when the foreground read is unavailable. Tests pin every no-evidence branch fail-closed and document the mechanism, so both attempted fixes fail loudly if reintroduced. Real gap tracked in stablyai#12946.
Summary
Negative result: this reverts the behavior change and lands as a tests-only regression contract.
cursor-agent's native OSC title is the bare literalCursor Agentand never carries a status word, so it names the agent without proving one is present. Classifying it as an agent looked right, but it removes a refusal rather than adding evidence — and guarded sends auto-submit Enter, so the false positive types into the user's shell.Behavior is now identical to base. The production diff is 6 comment lines with zero semantic tokens changed; everything else is tests.
Why the fix could not stand
src/shared/terminal-output-side-effects.ts), so main only records it when the stale-working timer strips the spinner off the synthesized⠋ Cursor Agent. That timer fires both when Cursor parks idle and whencursor-agentexited and the shell reclaimed the pane.assertTerminalAgentSendable: base rejects withterminal_guard_no_agent; with the change it accepts and sends text + Enter into a bare shell. Confirmed end-to-end in the running app.classifyAgentTitleis also consumed by the session-tab agent-status projection, so the change reintroduced [Mobile-Beta-Feedback]: terminal icon aways loading #1437-style stuck status for dead Cursor panes.getForegroundProcess()returningnullis the exit signal on the default local provider (src/main/providers/local-pty-provider.ts), not "unreadable".hasPty,probePtyLiveness,hasChildProcessesandinspectProcesswere each evaluated as corroborating signals. None separates alive-with-agent from alive-with-shell when the foreground read is unavailable.What ships
Tests pinning every no-evidence branch fail-closed, plus a characterization test documenting how the bare title reaches main's records at all. Both tempting fixes fail loudly if reintroduced: reapplying the original change fails 8 tests; reapplying the narrower variant is caught too.
The real gap (tracked separately)
When a foreground read is genuinely unavailable — pre-v11 daemon, or the blanket
catch { return null }flattening SSH/relay transport throws — guarded sends refuse any agent whose title isn't status-decorated, not just Cursor. "Cannot read" needs to stop being flattened into "nothing there" at the controller/daemon layer, so the UI can ask the user instead of the runtime guessing.Testing
pnpm lint— passespnpm typecheck— passespnpm test—src/main/runtime/orca-runtime.test.ts: 1056 passed, 1 skipped. Wider:src/main/runtime/3723 passed,src/shared/4031 passed,terminal-pane/+lib/6761 passed.cursor-agentCLI (2026.08.04) under node-pty, and end-to-end in the Electron app via the realterminal.sendguard.Screenshots
No visual change — behavior is identical to base.