mirror of
https://github.com/stablyai/orca.git
synced 2026-11-13 09:27:29 +00:00
* Chat UI leaves Experimental: each agent's Chat | CLI choice decides launches Remove the experimentalNativeChat switch and every gate on it. The Chat settings page, Default Agent Chat | CLI choice, + menu Chat/CLI rows, source-control surface choice, Antigravity chat section and orchestration chat-error switch are always present. What a new launch opens comes only from the per-agent choice (no saved choice opens a chat) plus the existing support checks. - One lookup, nativeChatPreferenceFor, keyed by agent id so host-registered agents read the same way; unreadable settings still open a terminal. - A relayed desktop stamp (nativeChatDefault) maps onto the launched agent; an explicit surface still wins. Old phones' createSupport keeps admitting by the host's per-agent choice. - settings.get stops publishing the retired switch keys; nothing in the repo reads them from a host. - Startup chat sync and hydration run when some agent can open as a chat or the machine already holds chats. - The retired key is stripped on load. The one-time upgrade tip from the chat upgrade is retired with its audience record; a new record, captured once from the raw profile, marks which existing profiles had Chat UI off. - The window-side AI-button tab path, which only ran with the switch off, is deleted. * Keep profiles that had Chat UI off on the terminal Existing users who never turned Chat UI on would otherwise see new agent launches open as chats, since an agent without a saved choice now opens as a chat. The one-time load step that records the new audience also sets every known agent to CLI for those profiles, in the same save and only when the record was absent, overwriting saved chat choices the old switch masked. Profiles that had Chat UI on and new profiles are untouched. Browser profiles keep their own settings, so the web client does the same once: a stored switch that is not on seeds CLI choices, and dropping the key marks the step done. Agents first seen after this step open as chats. * Agents without a saved Chat | CLI choice open as their CLI An agent with no saved choice now opens in the terminal for everyone, including fresh installs and agents first seen later. The one-time load step carries what launches opened while Chat UI was experimental: with the switch on, every known agent without a saved choice is saved as chat; with it off, chat choices the switch masked are saved as CLI. Existing profiles join the launch tip audience whether the switch was on or off. Browser profiles get the same carry from their saved key. The startup chat restore and host agent list now run only when some agent is saved as chat or the runtime holds chats. * Preserve owned terminal launches and local chat choices * Clarify chat and terminal support * Explain worker CLI integration timeout budget * Use checked annotations for chat graduation test fixtures * Store agent surface default separately from per-agent overrides * Preserve explicit Chat intent across default changes * Preserve current browser settings during host replies * Correct browser settings factory and regression types * Name exported launch fixture mock types and clarify agent defaults * Preserve settings fallbacks and complete launch test lifecycles * Check allocated tab identity before launch fixture interpolation * Register combined integration project for compiler parity probes * Use checked settings in the launch test fixture * Preserve retired Chat preference data privately * Align chat E2E fixtures and capture pane lifecycle evidence * Use typed raw settings in retention contracts * Consolidate transcript diagnostic imports * test: align chat fixtures with live pane and native menu contracts * test: capture relay tab selection loss diagnostics * test: wait for owned shells before synthetic chat fixtures * test: preserve all-host visibility in SSH observer * test: bind synthetic transcript fixtures before provider seeding * test: assert selected chat owner after narrow image preview * ci: allow fifth compiler project to complete comparison * Type the web-terminal fixture's chat map without an assertion * Right-click the selection itself in the chat copy spec
213 lines
6.5 KiB
TypeScript
213 lines
6.5 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({ nativeChatProviders: { claude: true, codex: 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`
|
|
}
|
|
|
|
/** Observe only structural lifecycle evidence; never keep PTY bytes, prompts or transcript contents. */
|
|
export async function observeTranscriptPaneLifetime(
|
|
page: Page,
|
|
args: { tabId: string; worktreeId: string; paneKey: string }
|
|
) {
|
|
const handle = await page.evaluateHandle(({ tabId, worktreeId, paneKey }) => {
|
|
const store = window.__store
|
|
if (!store) {
|
|
throw new Error('Store unavailable for transcript lifetime observation')
|
|
}
|
|
const events: {
|
|
at: number
|
|
source: string
|
|
snapshot: string
|
|
detail: unknown
|
|
stack?: string
|
|
}[] = []
|
|
let overflow = 0
|
|
let previous = ''
|
|
const managers = new WeakMap<object, number>()
|
|
const ownedPtys = new Set<string>()
|
|
let managerId = 0
|
|
const snapshot = () => {
|
|
const state = store.getState()
|
|
const manager = window.__paneManagers?.get(tabId)
|
|
if (manager && !managers.has(manager)) {
|
|
managers.set(manager, ++managerId)
|
|
}
|
|
const layout = state.terminalLayoutsByTabId[tabId]
|
|
for (const id of Object.values(layout?.ptyIdsByLeafId ?? {})) {
|
|
ownedPtys.add(id)
|
|
}
|
|
const status = state.agentStatusByPaneKey[paneKey]
|
|
const tab = (state.unifiedTabsByWorktree[worktreeId] ?? []).find(
|
|
(tab) => tab.entityId === tabId
|
|
)
|
|
return JSON.stringify({
|
|
worktreeId,
|
|
tabId,
|
|
paneKey,
|
|
activeWorktreeId: state.activeWorktreeId,
|
|
unifiedTabId: tab?.id,
|
|
viewMode: tab?.viewMode,
|
|
manager: manager ? managers.get(manager) : null,
|
|
activeLeafId: manager?.getActivePane()?.leafId,
|
|
panes: manager?.getPanes().map((pane) => ({
|
|
id: pane.id,
|
|
leafId: pane.leafId,
|
|
ptyId: pane.container.dataset.ptyId
|
|
})),
|
|
ptyIdsByLeafId: layout?.ptyIdsByLeafId,
|
|
chatLeafId: layout?.chatLeafId,
|
|
status: status
|
|
? {
|
|
state: status.state,
|
|
agentType: status.agentType,
|
|
providerSessionId: status.providerSession?.id,
|
|
connectionId: status.connectionId
|
|
}
|
|
: null
|
|
})
|
|
}
|
|
const record = (source: string, detail: unknown = null) => {
|
|
const current = snapshot()
|
|
if (source === 'store' || source === 'pane-dom') {
|
|
if (current === previous) {
|
|
return
|
|
}
|
|
}
|
|
previous = current
|
|
if (events.length === 160) {
|
|
overflow++
|
|
return
|
|
}
|
|
events.push({
|
|
at: performance.now(),
|
|
source,
|
|
snapshot: current,
|
|
detail,
|
|
stack: new Error('Transcript pane lifecycle observation').stack
|
|
})
|
|
}
|
|
record('initial')
|
|
const unsubscribe = store.subscribe(() => record('store'))
|
|
const offFacts = window.api.pty.onSideEffect((batch) => {
|
|
if (batch.tabId !== tabId && !ownedPtys.has(batch.ptyId)) {
|
|
return
|
|
}
|
|
record('main-side-effect', {
|
|
ptyId: batch.ptyId,
|
|
paneKey: batch.paneKey,
|
|
tabId: batch.tabId,
|
|
worktreeId: batch.worktreeId,
|
|
seq: batch.seq,
|
|
replay: batch.replay,
|
|
facts: batch.facts.map((fact) =>
|
|
fact.kind === 'command-finished'
|
|
? { kind: fact.kind, exitCode: fact.exitCode }
|
|
: { kind: fact.kind }
|
|
)
|
|
})
|
|
})
|
|
const offExit = window.api.pty.onExit((event) => {
|
|
record('pty-exit', { ...event, owned: ownedPtys.has(event.id) })
|
|
})
|
|
const offSpawn = window.api.pty.onSpawned((event) => {
|
|
record('pty-spawned', { ...event, owned: ownedPtys.has(event.id) })
|
|
})
|
|
const observer = new MutationObserver(() => record('pane-dom'))
|
|
observer.observe(document.body, {
|
|
childList: true,
|
|
subtree: true,
|
|
attributes: true,
|
|
attributeFilter: ['data-pty-id']
|
|
})
|
|
return {
|
|
finish: () => {
|
|
record('final')
|
|
unsubscribe()
|
|
offFacts()
|
|
offExit()
|
|
offSpawn()
|
|
observer.disconnect()
|
|
return { events, overflow }
|
|
}
|
|
}
|
|
}, args)
|
|
return async () => {
|
|
try {
|
|
return await handle.evaluate((observer) => observer.finish())
|
|
} catch (error) {
|
|
return { captureError: String(error) }
|
|
} finally {
|
|
await handle.dispose().catch(() => {})
|
|
}
|
|
}
|
|
}
|