The best way to control Claude Code, Codex and more from any computer or phone
| 1 | /** Android handoffs report background; deferred work must wait to avoid tearing down active flows. */ |
| 2 | let activeHandoffs = 0; |
| 3 | |
| 4 | /** Returns an idempotent end function; call it when the handoff resolves. */ |
| 5 | export function beginForegroundHandoff(): () => void { |
| 6 | activeHandoffs += 1; |
| 7 | let ended = false; |
| 8 | return () => { |
| 9 | if (ended) return; |
| 10 | ended = true; |
| 11 | activeHandoffs -= 1; |
| 12 | }; |
| 13 | } |
| 14 | |
| 15 | export function isForegroundHandoffActive(): boolean { |
| 16 | return activeHandoffs > 0; |
| 17 | } |