| 1 | import { useEffect } from "react"; |
| 2 | import { useCommittedCommand } from "../lib/useCommittedCommand"; |
| 3 | |
| 4 | // The subscription lives with the application runtime, not the lazy panel. |
| 5 | // Only a newly-created tab in the foreground turn may reveal the panel. |
| 6 | export function useBrowserFirstOpen(taskId: string | undefined, turnId: string | undefined, reveal: () => void, sessionId?: string) { |
| 7 | const current = useCommittedCommand(() => ({ taskId, turnId, sessionId, reveal })); |
| 8 | useEffect(() => { |
| 9 | let closed = false, off: (() => void) | undefined; |
| 10 | void import("./browserFirstOpenLifecycle").then(module => { if (!closed) off = module.observeFirstBrowserOpen(current); }); |
| 11 | return () => { closed = true; off?.(); }; |
| 12 | }, [current]); |
| 13 | } |
| 14 |