fix(claude): prefill continuation context for manual submission (#21912)

* fix(claude): prefill continuation context for manual submission

* fix(agents): force draft paste when inline prefill falls back
This commit is contained in:
Neil
2026-09-20 22:45:05 -07:00
committed by GitHub
parent 5d13a70ea3
commit 2872c3fccc
6 changed files with 43 additions and 6 deletions
@@ -3,6 +3,9 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
const mockIsWebRuntimeSessionActive = vi.fn(() => false)
const mockCreateWebRuntimeAgentSessionTerminal = vi.fn()
const mockCreateWebRuntimeAgentSessionTerminalWithLaunchDraft = vi.fn()
const mockCreateTab = vi.fn()
const mockQueueTabStartupCommand = vi.fn()
const mockPasteDraftWhenAgentReady = vi.fn()
@@ -102,13 +105,21 @@ vi.mock('@/lib/telemetry', () => ({
vi.mock('@/runtime/web-runtime-session', () => ({
createWebRuntimeSessionTerminal: vi.fn(),
isWebRuntimeSessionActive: vi.fn(() => false),
isWebRuntimeSessionActive: mockIsWebRuntimeSessionActive,
createWebRuntimeAgentSessionTerminal: mockCreateWebRuntimeAgentSessionTerminal,
createWebRuntimeAgentSessionTerminalWithLaunchDraft:
mockCreateWebRuntimeAgentSessionTerminalWithLaunchDraft,
isWebTerminalSurfaceTabId: vi.fn(() => false)
}))
describe('launchAgentInNewTab Windows shell quoting', () => {
beforeEach(() => {
vi.clearAllMocks()
mockIsWebRuntimeSessionActive.mockReturnValue(false)
mockCreateWebRuntimeAgentSessionTerminal.mockResolvedValue({
outcome: { status: 'created' },
promptDelivered: true
})
store.activeRepoId = 'repo-1'
store.activeWorktreeId = 'wt-1'
store.settings = {
@@ -147,6 +158,29 @@ describe('launchAgentInNewTab Windows shell quoting', () => {
mockPasteDraftWhenAgentReady.mockResolvedValue(true)
})
it('forces oversized Windows drafts through the paired-host paste fallback without submitting', async () => {
mockIsWebRuntimeSessionActive.mockReturnValue(true)
const { launchAgentInNewTab } = await import('./launch-agent-in-new-tab')
const prompt = 'x'.repeat(25_000)
launchAgentInNewTab({
agent: 'claude',
worktreeId: 'wt-1',
prompt,
promptDelivery: 'draft',
launchPlatform: 'win32'
})
expect(mockCreateWebRuntimeAgentSessionTerminal).toHaveBeenCalledWith(
expect.objectContaining({
promptAfterReady: prompt,
submitPrompt: false,
forcePromptPaste: true
})
)
expect(mockCreateWebRuntimeAgentSessionTerminalWithLaunchDraft).not.toHaveBeenCalled()
})
it('uses the explicit startup shell platform when building draft launch commands', async () => {
const { launchAgentInNewTab } = await import('./launch-agent-in-new-tab')
@@ -647,7 +647,7 @@ describe('launchAgentInNewTab', () => {
content: prompt,
agent: 'claude',
submit: false,
forcePaste: false
forcePaste: true
})
)
})
@@ -305,7 +305,7 @@ function launchAgentInNewTabInternal(args: LaunchAgentInNewTabArgs): LaunchAgent
content: pasteDraftAfterLaunch,
agent,
submit: submitPastedPrompt,
forcePaste: promptDelivery === 'submit-after-ready',
forcePaste: true,
onTimeout: timeoutNotice.onTimeout
}).then((delivered) => {
if (delivered) {
@@ -72,7 +72,7 @@ describe('launchAgentSessionContinuation', () => {
worktreeId: 'wt-1',
groupId: 'group-1',
initialCwd: '/repo/worktree/packages/app',
promptDelivery: 'submit-after-ready'
promptDelivery: 'draft'
})
)
})
@@ -129,6 +129,9 @@ describe('launchAgentSessionContinuation', () => {
launchSource: 'sidebar'
})
expect(launchAgentInNewTab).toHaveBeenCalledWith(
expect.objectContaining({ agent: 'codex', promptDelivery: 'submit-after-ready' })
)
await vi.waitFor(() =>
expect(toast.error).toHaveBeenCalledWith(
'The new Codex session started, but its context could not be sent.'
@@ -90,7 +90,7 @@ export async function launchAgentSessionContinuation({
worktreeId,
...(groupId ? { groupId } : {}),
prompt,
promptDelivery: 'submit-after-ready',
promptDelivery: agent === 'claude' ? 'draft' : 'submit-after-ready',
launchSource,
...(initialCwd ? { initialCwd } : {}),
onPromptDelivered: () =>
@@ -128,7 +128,7 @@ export function launchAgentInWebHostTab(args: {
agent,
promptAfterReady: pastePromptAfterReady,
submitPrompt: submitPastedPrompt,
forcePromptPaste: promptDelivery === 'submit-after-ready'
forcePromptPaste: true
}).then(handleCreation)
}
if (hasPrompt && promptDelivery === 'draft') {