mirror of
https://github.com/stablyai/orca.git
synced 2026-10-30 16:47:34 +00:00
73 lines
2.3 KiB
TypeScript
73 lines
2.3 KiB
TypeScript
import type { Page } from '@stablyai/playwright-test'
|
|
|
|
export async function enableNativeChatSetting(page: Page): Promise<void> {
|
|
await page.evaluate(async () => {
|
|
await window.__store?.getState().updateSettings({ experimentalNativeChat: true })
|
|
})
|
|
}
|
|
|
|
export async function seedClaudeProviderSession(
|
|
page: Page,
|
|
args: { paneKey: string; worktreeId: string; sessionId: string; transcriptPath: string }
|
|
): Promise<void> {
|
|
await page.evaluate(({ paneKey, worktreeId, sessionId, transcriptPath }) => {
|
|
window.__store
|
|
?.getState()
|
|
.setAgentStatus(
|
|
paneKey,
|
|
{ state: 'working', prompt: 'e2e first-flush race probe', agentType: 'claude' },
|
|
'Claude',
|
|
undefined,
|
|
{ worktreeId },
|
|
{ providerSession: { key: 'session_id', id: sessionId, transcriptPath } }
|
|
)
|
|
}, args)
|
|
}
|
|
|
|
export async function toggleTerminalTabToChatView(
|
|
page: Page,
|
|
args: { tabId: string; worktreeId: string }
|
|
): Promise<void> {
|
|
await page.evaluate(({ tabId, worktreeId }) => {
|
|
const store = window.__store
|
|
if (!store) {
|
|
throw new Error('Store unavailable')
|
|
}
|
|
const state = store.getState()
|
|
const unifiedTab = (state.unifiedTabsByWorktree[worktreeId] ?? []).find(
|
|
(tab) => tab.contentType === 'terminal' && tab.entityId === tabId
|
|
)
|
|
if (!unifiedTab) {
|
|
throw new Error('Unified terminal tab not found for chat toggle')
|
|
}
|
|
state.toggleTabViewMode(unifiedTab.id)
|
|
}, args)
|
|
}
|
|
|
|
export function claudeTranscriptLines(args: {
|
|
sessionId: string
|
|
messageIdPrefix?: string
|
|
userText: string
|
|
assistantText: string
|
|
}): string {
|
|
const userTime = new Date()
|
|
const assistantTime = new Date(userTime.getTime() + 2_000)
|
|
const lines = [
|
|
{
|
|
sessionId: args.sessionId,
|
|
uuid: `${args.messageIdPrefix ?? args.sessionId}-user`,
|
|
timestamp: userTime.toISOString(),
|
|
type: 'user',
|
|
message: { role: 'user', content: [{ type: 'text', text: args.userText }] }
|
|
},
|
|
{
|
|
sessionId: args.sessionId,
|
|
uuid: `${args.messageIdPrefix ?? args.sessionId}-assistant`,
|
|
timestamp: assistantTime.toISOString(),
|
|
type: 'assistant',
|
|
message: { model: 'claude-opus-4', content: [{ type: 'text', text: args.assistantText }] }
|
|
}
|
|
]
|
|
return `${lines.map((line) => JSON.stringify(line)).join('\n')}\n`
|
|
}
|