返回 DeepSeek-Reasonix
remoteTranscriptFixture.ts
根目录 / desktop / frontend / src / __tests__ / helpers / remoteTranscriptFixture.ts
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
16 lines TYPESCRIPT