The best way to control Claude Code, Codex and more from any computer or phone

main
ts 15 lines 631 Bytes
Raw
1 /**
2 * Chat overlays (dialogs, media previews) are opened for one thread and must not
3 * outlive its route. Overlay modules register here when they load, so the route
4 * listener can drop them without importing the overlays themselves.
5 */
6 const retainers: Array<(threadKey: string | null) => void> = [];
7
8 export function registerThreadOverlay(retain: (threadKey: string | null) => void): void {
9 retainers.push(retain);
10 }
11
12 /** Drops every overlay opened for a thread other than `threadKey`. */
13 export function retainThreadOverlaysForThread(threadKey: string | null): void {
14 for (const retain of retainers) retain(threadKey);
15 }