Files
orca/mobile/src/session/mobile-structured-transcript-subscription.ts
T
Brennan Benson 8c1ade9e44 Keep pending chat decisions available outside loaded history (#29121)
* fix(native-chat): retire acknowledged send echoes after catch-up

* test: follow phone lint rules in reconnect regression

* test: format reconnect message expectation

* Keep current chat requests independent of loaded history

* Read current chat requests in bounded cursor pieces

* Fix current request subscription static checks

* Match generated request schema import ordering

* fix(native-chat): correct current request type boundaries

* Exercise current request reads in wire compatibility inventory

* Align current request fixtures with provider commit and RPC surface

* test(native-chat): include current request browser capability

* Keep the mobile chat session hook within its line budget

* Format mobile current request readers

* fix(native-chat): reopen once for a current-request version whose read keeps failing

A deterministic read failure reopened the subscription, whose first frame re-read the same version and reset the backoff, so the pane resubscribed every 750 ms forever.

* test(native-chat): type the current-request snapshot fixture

* test(native-chat): wait for the hydrated open before driving the subscription
2026-10-16 16:01:58 -07:00

38 lines
1.2 KiB
TypeScript

import type { RpcClient } from '../transport/rpc-client'
import type { AgentSessionSubscribeEvent } from '../../../src/shared/agent-session-wire'
/**
* Opens the transcript stream once the hold settles, either way: a refused hold is an older host
* saying it could not start the agent — which the next send does — never a reason to hide the
* transcript. Returns what ends the stream, opened or not yet. Outside the effect so its cleanup
* rule can see the stream is owned.
*/
export function openTranscriptAfterHold(
client: RpcClient,
sessionId: string,
held: Promise<unknown>,
onFrame: (raw: unknown) => void
): () => void {
let ended = false
let close = (): void => {}
void held
.catch(() => undefined)
.then(() => {
if (!ended) {
close = client.subscribe('agentSession.subscribe', { sessionId }, onFrame)
}
})
return () => {
ended = true
close()
}
}
export function isSubscribeEvent(value: unknown): value is AgentSessionSubscribeEvent {
if (typeof value !== 'object' || value === null) {
return false
}
const type = 'type' in value ? value.type : undefined
return type === 'snapshot' || type === 'batch' || type === 'reset' || type === 'end'
}