Files
orca/mobile/scripts/hosted-chat-transcript-fixture.mjs
T
Jinwoo-H 15d19c308b feat(mobile): move mobile sessions and settings into the hosted page
Session snapshot/feed/activate/close/createBrowser/createTerminal,
quick commands and agent options now run as Desktop mobileWeb.* adapters
behind the generic host-request forwarder instead of shell translators.
Voice, notification, terminal, browser, chat, About and diagnostics
settings render as hosted page routes with native-*/web-* operation
backends. Adds the hosted WebView e2e journeys used to validate them.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
2026-09-07 04:16:39 -04:00

43 lines
1.3 KiB
JavaScript

import { appendFile, readFile } from 'node:fs/promises'
import { randomUUID } from 'node:crypto'
export async function appendHostedChatFeedMarker(transcriptPath) {
const marker = `ORCA_CHAT_FEED_${randomUUID()}`
await appendFile(
transcriptPath,
`${JSON.stringify({
timestamp: new Date().toISOString(),
type: 'response_item',
payload: { type: 'message', role: 'assistant', content: [{ type: 'text', text: marker }] }
})}\n`
)
return marker
}
export async function assertHostedChatInputReceipt(receiptPath, message) {
const bytes = await readFile(receiptPath, 'utf8')
const lines = bytes
.split('\n')
.filter(Boolean)
.map((line) => JSON.parse(line))
const matches = lines.filter((line) => line.text === message)
if (matches.length !== 1 || matches[0].submitted !== true) {
throw new Error('Chat input was not submitted exactly once to the fixture PTY')
}
return { submittedExactlyOnce: true }
}
export function consumeHostedChatPtyInput(pending, chunk) {
const lines = (pending + String(chunk)).split(/[\r\n]/)
const next = lines.pop()
const submitted = lines
.map((line) =>
line
.slice(line.lastIndexOf('\u0015') + 1)
.replaceAll('\u001b[200~', '')
.replaceAll('\u001b[201~', '')
)
.filter(Boolean)
return { pending: next, submitted }
}