From a7855d9c82fd0d6602efd76762487c1a858bf36f Mon Sep 17 00:00:00 2001 From: ggbdpq Date: Thu, 8 Oct 2026 09:23:02 +0800 Subject: [PATCH 1/2] fix(runtime): deliver Devin launch prompts via argv instead of stdin-after-start MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The stdin-after-start follow-up polls for the foreground process name, and the devin wrapper execs into `devin acp` almost instantly — so the prompt was written ~30ms after launch, while Devin was still printing its banner and its REPL input loop did not exist yet. The write was dropped (or stranded as an unsubmitted draft) while the launch reported success. Switch Devin to argv delivery with the documented `--` separator: the prompt rides the launch command itself, which the reporter verified end-to-end (3/3 runs, ~3s to submission) against the measured acceptance windows — a stability heuristic cannot hit the ~1s early window without sliding into the discard zone. No-prompt launches are unaffected (both modes take the same early exit), and the reviewer-facing draft semantics stay on the draft path where they belong. Fixes #26302 Generated-by: GLM-5.3-Flash (ZCode) --- ...worktree-setup-and-startup-part-04.spec.ts | 81 +++++++++++++++++++ .../src/lib/tui-agent-startup.test.ts | 7 +- src/shared/tui-agent-config.ts | 8 +- src/shared/tui-agent-startup.spec.ts | 7 +- 4 files changed, 92 insertions(+), 11 deletions(-) diff --git a/src/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-04.spec.ts b/src/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-04.spec.ts index c0d59bb0ad02..595b94897165 100644 --- a/src/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-04.spec.ts +++ b/src/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-04.spec.ts @@ -98,6 +98,87 @@ describe('OrcaRuntimeService', () => { }) }) + it('carries a Devin startup prompt on argv instead of writing it into the PTY', async () => { + // Why: the foreground process is `devin` at ~0.03 s (the wrapper execs), so a + // stdin-after-start follow-up wrote while the REPL was still printing its banner and the + // text was dropped (#26302). The prompt must ride the launch command instead. + vi.useFakeTimers() + try { + const metaById: Record = {} + const runtimeStore = { + ...store, + getSettings: () => ({ + ...store.getSettings(), + agentCmdOverrides: {} + }), + getAllWorktreeMeta: () => metaById, + getWorktreeMeta: (worktreeId: string) => metaById[worktreeId], + setWorktreeMeta: (worktreeId: string, meta: Partial) => { + metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta } + return metaById[worktreeId] + } + } + const runtime = new OrcaRuntimeService(runtimeStore as never) + const spawn = vi.fn().mockResolvedValue({ id: 'pty-cli-devin-startup' }) + const write = vi.fn().mockReturnValue(true) + runtime.setPtyController({ + spawn, + write, + kill: () => true, + getForegroundProcess: async () => 'devin' + }) + runtime.setNotifier({ + worktreesChanged: vi.fn(), + reposChanged: vi.fn(), + activateWorktree: vi.fn(), + createTerminal: vi.fn(), + revealTerminalSession: vi.fn().mockResolvedValue({ tabId: 'tab-cli-devin-startup' }), + splitTerminal: vi.fn(), + renameTerminal: vi.fn(), + focusTerminal: vi.fn(), + closeTerminal: vi.fn(), + sleepWorktree: vi.fn(), + terminalFitOverrideChanged: vi.fn(), + terminalDriverChanged: vi.fn() + }) + runtime.attachWindow(1) + + computeWorktreePathMock.mockReturnValue('/tmp/workspaces/runtime-cli-devin-startup') + ensurePathWithinWorkspaceMock.mockReturnValue('/tmp/workspaces/runtime-cli-devin-startup') + vi.mocked(listWorktrees).mockResolvedValue([ + { + path: '/tmp/workspaces/runtime-cli-devin-startup', + head: 'def', + branch: 'runtime-cli-devin-startup', + isBare: false, + isMainWorktree: false + } + ]) + + const result = await runtime.createManagedWorktree({ + repoSelector: TEST_REPO_ID, + name: 'runtime-cli-devin-startup', + startupAgent: 'devin', + startupPrompt: 'fix it' + }) + + expect(spawn).toHaveBeenCalledWith( + expect.objectContaining({ + cwd: '/tmp/workspaces/runtime-cli-devin-startup', + command: + "devin '--permission-mode' 'bypass' '--respect-workspace-trust' 'false' -- 'fix it'", + worktreeId: result.worktree.id + }) + ) + // Outlast the whole 30 x 150 ms readiness poll: nothing may type the prompt into the PTY. + await vi.advanceTimersByTimeAsync(6000) + + expect(write).not.toHaveBeenCalled() + } finally { + vi.useRealTimers() + } + }) + it('does not send stdin-after-start prompts into a shell when the agent never starts', async () => { vi.useFakeTimers() try { diff --git a/src/renderer/src/lib/tui-agent-startup.test.ts b/src/renderer/src/lib/tui-agent-startup.test.ts index 01dec6c9e850..a91b5b05e1db 100644 --- a/src/renderer/src/lib/tui-agent-startup.test.ts +++ b/src/renderer/src/lib/tui-agent-startup.test.ts @@ -279,7 +279,7 @@ describe('buildAgentStartupPlan', () => { }) }) - it('launches Devin first and injects the prompt after startup', () => { + it('launches Devin with the prompt on argv behind a -- separator', () => { expect( buildAgentStartupPlan({ agent: 'devin', @@ -290,9 +290,10 @@ describe('buildAgentStartupPlan', () => { }) ).toEqual({ agent: 'devin', - launchCommand: "devin '--permission-mode' 'bypass' '--respect-workspace-trust' 'false'", + launchCommand: + "devin '--permission-mode' 'bypass' '--respect-workspace-trust' 'false' -- 'Trace the failing test'", expectedProcess: 'devin', - followupPrompt: 'Trace the failing test', + followupPrompt: null, launchConfig: { agentCommand: "devin '--permission-mode' 'bypass' '--respect-workspace-trust' 'false'", agentArgs: '--permission-mode bypass --respect-workspace-trust false', diff --git a/src/shared/tui-agent-config.ts b/src/shared/tui-agent-config.ts index a809d350f76e..2498d3adc3b6 100644 --- a/src/shared/tui-agent-config.ts +++ b/src/shared/tui-agent-config.ts @@ -344,11 +344,9 @@ const TUI_AGENT_CONFIG_SOURCE: Record = { draftPasteReadySignal: 'zcode-composer-prompt', composerReadyCaptures: ['zcode-composer-ready'] }, - devin: { - detectCmd: 'devin', - // Why: `devin -- ` auto-submits immediately (docs.devin.ai/cli), so start the REPL with no argv prompt. - promptInjectionMode: 'stdin-after-start' - }, + // Why: stdin-after-start's follow-up wrote before Devin's input loop existed (#26302); `devin -- ` submits reliably. + // prettier-ignore + devin: { detectCmd: 'devin', promptInjectionMode: 'argv', argvPromptSeparator: '--' }, // prettier-ignore jcode: { detectCmd: 'jcode', launchCmd: 'jcode', expectedProcess: 'jcode', promptInjectionMode: 'stdin-after-start' } } diff --git a/src/shared/tui-agent-startup.spec.ts b/src/shared/tui-agent-startup.spec.ts index b1b7de942d54..fba38d588e4c 100644 --- a/src/shared/tui-agent-startup.spec.ts +++ b/src/shared/tui-agent-startup.spec.ts @@ -764,7 +764,7 @@ describe('tui agent startup plans', () => { }) }) - it('launches Devin with stdin-after-start prompt delivery', () => { + it('launches Devin with the prompt on argv behind a -- separator', () => { const plan = buildAgentStartupPlan({ agent: 'devin', prompt: 'fix the tests', @@ -774,9 +774,10 @@ describe('tui agent startup plans', () => { }) expect(plan).toEqual({ agent: 'devin', - launchCommand: "devin '--permission-mode' 'bypass' '--respect-workspace-trust' 'false'", + launchCommand: + "devin '--permission-mode' 'bypass' '--respect-workspace-trust' 'false' -- 'fix the tests'", expectedProcess: 'devin', - followupPrompt: 'fix the tests', + followupPrompt: null, launchConfig: { agentCommand: "devin '--permission-mode' 'bypass' '--respect-workspace-trust' 'false'", agentArgs: '--permission-mode bypass --respect-workspace-trust false', From fcbe38b444058d06b0e62cc34b58c7e53e358db6 Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 24 Oct 2026 18:49:21 -0700 Subject: [PATCH 2/2] test(runtime): drop Devin runtime spec that duplicates the startup-plan pin followupPrompt: null already guarantees no PTY write; the shared startup-plan test pins Devin's argv shape. Co-authored-by: ggbdpq <67929842+ggbdpq@users.noreply.github.com> --- ...worktree-setup-and-startup-part-04.spec.ts | 81 ------------------- 1 file changed, 81 deletions(-) diff --git a/src/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-04.spec.ts b/src/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-04.spec.ts index 595b94897165..c0d59bb0ad02 100644 --- a/src/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-04.spec.ts +++ b/src/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-04.spec.ts @@ -98,87 +98,6 @@ describe('OrcaRuntimeService', () => { }) }) - it('carries a Devin startup prompt on argv instead of writing it into the PTY', async () => { - // Why: the foreground process is `devin` at ~0.03 s (the wrapper execs), so a - // stdin-after-start follow-up wrote while the REPL was still printing its banner and the - // text was dropped (#26302). The prompt must ride the launch command instead. - vi.useFakeTimers() - try { - const metaById: Record = {} - const runtimeStore = { - ...store, - getSettings: () => ({ - ...store.getSettings(), - agentCmdOverrides: {} - }), - getAllWorktreeMeta: () => metaById, - getWorktreeMeta: (worktreeId: string) => metaById[worktreeId], - setWorktreeMeta: (worktreeId: string, meta: Partial) => { - metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta } - return metaById[worktreeId] - } - } - const runtime = new OrcaRuntimeService(runtimeStore as never) - const spawn = vi.fn().mockResolvedValue({ id: 'pty-cli-devin-startup' }) - const write = vi.fn().mockReturnValue(true) - runtime.setPtyController({ - spawn, - write, - kill: () => true, - getForegroundProcess: async () => 'devin' - }) - runtime.setNotifier({ - worktreesChanged: vi.fn(), - reposChanged: vi.fn(), - activateWorktree: vi.fn(), - createTerminal: vi.fn(), - revealTerminalSession: vi.fn().mockResolvedValue({ tabId: 'tab-cli-devin-startup' }), - splitTerminal: vi.fn(), - renameTerminal: vi.fn(), - focusTerminal: vi.fn(), - closeTerminal: vi.fn(), - sleepWorktree: vi.fn(), - terminalFitOverrideChanged: vi.fn(), - terminalDriverChanged: vi.fn() - }) - runtime.attachWindow(1) - - computeWorktreePathMock.mockReturnValue('/tmp/workspaces/runtime-cli-devin-startup') - ensurePathWithinWorkspaceMock.mockReturnValue('/tmp/workspaces/runtime-cli-devin-startup') - vi.mocked(listWorktrees).mockResolvedValue([ - { - path: '/tmp/workspaces/runtime-cli-devin-startup', - head: 'def', - branch: 'runtime-cli-devin-startup', - isBare: false, - isMainWorktree: false - } - ]) - - const result = await runtime.createManagedWorktree({ - repoSelector: TEST_REPO_ID, - name: 'runtime-cli-devin-startup', - startupAgent: 'devin', - startupPrompt: 'fix it' - }) - - expect(spawn).toHaveBeenCalledWith( - expect.objectContaining({ - cwd: '/tmp/workspaces/runtime-cli-devin-startup', - command: - "devin '--permission-mode' 'bypass' '--respect-workspace-trust' 'false' -- 'fix it'", - worktreeId: result.worktree.id - }) - ) - // Outlast the whole 30 x 150 ms readiness poll: nothing may type the prompt into the PTY. - await vi.advanceTimersByTimeAsync(6000) - - expect(write).not.toHaveBeenCalled() - } finally { - vi.useRealTimers() - } - }) - it('does not send stdin-after-start prompts into a shell when the agent never starts', async () => { vi.useFakeTimers() try {