| 3708 | // progress detection honest in that case. The RPC is skipped while |
| 3709 | // streamed events are fresh, so healthy runs issue no extra requests. |
| 3710 | const pollHistoryFallback = () => { |
| 3711 | _historyPollTimer = null; |
| 3712 | const state = get(); |
| 3713 | if (!state.sending || state.currentSessionKey !== currentSessionKey) return; |
| 3714 | if (Date.now() - _lastChatEventAt >= HISTORY_POLL_EVENT_SILENCE_MS) { |
| 3715 | void state.loadHistory(true); |
| 3716 | } |
| 3717 | _historyPollTimer = setTimeout(pollHistoryFallback, HISTORY_POLL_INTERVAL_MS); |
| 3718 | }; |
| 3719 | _historyPollTimer = setTimeout(pollHistoryFallback, HISTORY_POLL_START_DELAY_MS); |
| 3720 | |
| 3721 | const checkStuck = () => { |