(kind: TabStatusKind | null)
| 51 | * a stale dot. Process-exit cleanup is handled by ink.tsx's unmount path. |
| 52 | */ |
| 53 | export function useTabStatus(kind: TabStatusKind | null): void { |
| 54 | const writeRaw = useContext(TerminalWriteContext) |
| 55 | const prevKindRef = useRef<TabStatusKind | null>(null) |
| 56 | |
| 57 | useEffect(() => { |
| 58 | // When kind transitions from non-null to null (e.g. user toggles off |
| 59 | // showStatusInTerminalTab mid-session), clear the stale dot. |
| 60 | if (kind === null) { |
| 61 | if (prevKindRef.current !== null && writeRaw && supportsTabStatus()) { |
| 62 | writeRaw(wrapForMultiplexer(CLEAR_TAB_STATUS)) |
| 63 | } |
| 64 | prevKindRef.current = null |
| 65 | return |
| 66 | } |
| 67 | |
| 68 | prevKindRef.current = kind |
| 69 | if (!writeRaw || !supportsTabStatus()) return |
| 70 | writeRaw(wrapForMultiplexer(tabStatus(TAB_STATUS_PRESETS[kind]))) |
| 71 | }, [kind, writeRaw]) |
| 72 | } |
| 73 |
no test coverage detected