Files
orca/tests/e2e/helpers/native-chat-view.ts

37 lines
1.3 KiB
TypeScript

import type { Page } from '@stablyai/playwright-test'
import type { AgentType } from '../../../src/shared/agent-status/contracts/agent-status-types'
import { waitForActivePaneHookDescriptor } from './terminal'
export async function showActivePaneAsNativeChat(
page: Page,
agentType: AgentType,
title: string
): Promise<void> {
const descriptor = await waitForActivePaneHookDescriptor(page)
await page.evaluate(
async ({ paneKey, worktreeId, agentType, title }) => {
const settings = await window.api.settings.set({
nativeChatProviders: { claude: true, codex: true }
})
const store = window.__store
if (!store) {
throw new Error('Store unavailable')
}
store.setState({ settings })
const state = store.getState()
state.setAgentStatus(paneKey, { state: 'done', agentType, prompt: '' }, title, undefined, {
worktreeId
})
const [tabId] = paneKey.split(':')
const tab = (state.unifiedTabsByWorktree[worktreeId] ?? []).find(
(candidate) => candidate.contentType === 'terminal' && candidate.entityId === tabId
)
if (!tab) {
throw new Error('Terminal tab unavailable')
}
state.toggleTabViewMode(tab.id)
},
{ ...descriptor, agentType, title }
)
}