mirror of
https://github.com/stablyai/orca.git
synced 2026-10-17 00:03:08 +00:00
Avoid auto-opening native chat for draft prompt followups
Followup paths paste the prompt as an unsubmitted draft. When prompt delivery is configured as 'auto-submit', this previously opened the native chat view with no actual submitted turn to render. By gating the initial view mode using 'draft' delivery on followup paths, we ensure the tab starts in terminal mode instead.
This commit is contained in:
@@ -2,7 +2,7 @@ import type { Tab, TuiAgent } from '../../../../shared/types'
|
||||
import type { AgentType } from '../../../../shared/agent-status-types'
|
||||
import { isNativeChatSupportedAgent } from '@/lib/native-chat-supported-agent'
|
||||
|
||||
export { isNativeChatSupportedAgent } from '@/lib/native-chat-supported-agent'
|
||||
export { isNativeChatSupportedAgent }
|
||||
|
||||
/** Inputs that decide whether a tab may toggle into the native chat view.
|
||||
* Kept as a plain shape (not the live store) so the decision stays pure and
|
||||
|
||||
@@ -176,6 +176,9 @@ export function launchPromptAsMessage(
|
||||
}
|
||||
}
|
||||
|
||||
// Why: prune only once an assistant turn has landed after the matching user
|
||||
// text — keeping the optimistic bubble through the user-only phase avoids a
|
||||
// first-turn flash before the transcript's own copy of the turn catches up.
|
||||
export function shouldPruneLaunchPrompt(
|
||||
entry: NativeChatLaunchPrompt,
|
||||
messages: NativeChatMessage[]
|
||||
|
||||
@@ -268,10 +268,19 @@ export function launchAgentInNewTab(args: LaunchAgentInNewTabArgs): LaunchAgentI
|
||||
// lands after mount the agent binary never starts; the user sees a bare shell.
|
||||
// Since both calls happen synchronously in the same React batch, the queue
|
||||
// is in place by the time the pane commits.
|
||||
// Why: the followup path pastes the prompt as an unsubmitted draft (submit
|
||||
// stays false), so gate the initial chat view like a `draft` launch —
|
||||
// otherwise a default `auto-submit` followup would open native chat with no
|
||||
// submitted turn to render.
|
||||
const viewModePromptDelivery =
|
||||
hasPrompt && isFollowupPath && promptDelivery === 'auto-submit' ? 'draft' : promptDelivery
|
||||
const tab = store.createTab(worktreeId, groupId, undefined, {
|
||||
launchAgent: agent,
|
||||
quickCommandLabel,
|
||||
...initialAgentTabViewModeProps(store.settings, { agent, promptDelivery })
|
||||
...initialAgentTabViewModeProps(store.settings, {
|
||||
agent,
|
||||
promptDelivery: viewModePromptDelivery
|
||||
})
|
||||
})
|
||||
store.queueTabStartupCommand(tab.id, {
|
||||
command: startupPlan.launchCommand,
|
||||
|
||||
@@ -495,6 +495,61 @@ describe('ensureWorktreeHasInitialTerminal', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('opens the startup default tab in native chat when configured', () => {
|
||||
let createdIndex = 0
|
||||
const createTab = vi.fn(() => ({ id: `tab-${++createdIndex}` }))
|
||||
const store = createMockStore({
|
||||
createTab,
|
||||
settings: {
|
||||
experimentalNativeChat: true,
|
||||
openAgentTabsInChatByDefault: true
|
||||
}
|
||||
})
|
||||
|
||||
ensureWorktreeHasInitialTerminal(
|
||||
store,
|
||||
'wt-1',
|
||||
{ command: 'claude', launchAgent: 'claude' },
|
||||
undefined,
|
||||
undefined,
|
||||
{ runCommands: true, tabs: [{ title: 'Claude', command: 'claude' }] }
|
||||
)
|
||||
|
||||
expect(createTab).toHaveBeenNthCalledWith(1, 'wt-1', undefined, undefined, {
|
||||
pendingActivationSpawn: true,
|
||||
recordInteraction: false,
|
||||
launchAgent: 'claude',
|
||||
viewMode: 'chat'
|
||||
})
|
||||
})
|
||||
|
||||
it('keeps a draft startup default tab in terminal mode even when native chat is configured', () => {
|
||||
let createdIndex = 0
|
||||
const createTab = vi.fn(() => ({ id: `tab-${++createdIndex}` }))
|
||||
const store = createMockStore({
|
||||
createTab,
|
||||
settings: {
|
||||
experimentalNativeChat: true,
|
||||
openAgentTabsInChatByDefault: true
|
||||
}
|
||||
})
|
||||
|
||||
ensureWorktreeHasInitialTerminal(
|
||||
store,
|
||||
'wt-1',
|
||||
{ command: 'claude', launchAgent: 'claude', draftPrompt: 'Review before sending' },
|
||||
undefined,
|
||||
undefined,
|
||||
{ runCommands: true, tabs: [{ title: 'Claude', command: 'claude' }] }
|
||||
)
|
||||
|
||||
expect(createTab).toHaveBeenNthCalledWith(1, 'wt-1', undefined, undefined, {
|
||||
pendingActivationSpawn: true,
|
||||
recordInteraction: false,
|
||||
launchAgent: 'claude'
|
||||
})
|
||||
})
|
||||
|
||||
it('gates startup behind setup completion when both are provided in new-tab mode', () => {
|
||||
setSetupScriptLaunchMode('new-tab')
|
||||
let createdIndex = 0
|
||||
|
||||
Reference in New Issue
Block a user