| 1 | import { app } from "./bridge"; |
| 2 | |
| 3 | const replayInFlight = new Set<string>(); |
| 4 | |
| 5 | export function replayPendingPromptsForActiveTab( |
| 6 | activeTabId: string | undefined, |
| 7 | replay: (tabId: string) => Promise<void> = (tabId) => { |
| 8 | // Older test/dev bindings fall back to the reconnect-compatible global call. |
| 9 | const scopedReplay = app.ReplayPendingPromptsForTab; |
| 10 | return typeof scopedReplay === "function" ? scopedReplay(tabId) : app.ReplayPendingPrompts(); |
| 11 | }, |
| 12 | ): void { |
| 13 | if (!activeTabId) return; |
| 14 | if (replayInFlight.has(activeTabId)) return; |
| 15 | replayInFlight.add(activeTabId); |
| 16 | void replay(activeTabId).catch(() => {}).finally(() => replayInFlight.delete(activeTabId)); |
| 17 | } |
| 18 |