| 1 | import type { AppBindings } from "../../lib/bridge"; |
| 2 | import { publishMockTranscriptEvent } from "../../lib/sessionReaderBridge"; |
| 3 | import type { WireEvent } from "../../lib/types"; |
| 4 | |
| 5 | /** Feed fixture history through Follow; metadata never initiates another cut. */ |
| 6 | export function installRemoteTranscriptFixture(commands: Record<string, unknown>): void { |
| 7 | const snapshots = new Map<string, Awaited<ReturnType<AppBindings["RemoteTabSnapshot"]>>>(); |
| 8 | commands.HistoryForTab = async (tabId: string) => { |
| 9 | const snapshot = await (commands.RemoteTabSnapshot as AppBindings["RemoteTabSnapshot"])(tabId); |
| 10 | snapshots.set(tabId, snapshot); |
| 11 | for (const event of snapshot.pendingEvents ?? []) publishMockTranscriptEvent({ ...(event as WireEvent), tabId }); |
| 12 | return snapshot.history ?? []; |
| 13 | }; |
| 14 | commands.RemoteTabMetadata = async (tabId: string) => snapshots.get(tabId) ?? {}; |
| 15 | } |
| 16 |