mirror of
https://github.com/stablyai/orca.git
synced 2026-09-21 16:02:20 +00:00
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:
@@ -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') {
|
||||
|
||||
Reference in New Issue
Block a user