()
| 258 | } |
| 259 | |
| 260 | function markExpectingSwitch() { |
| 261 | state.expectingSwitch = true; |
| 262 | if (state.expectingSwitchTimer) clearTimeout(state.expectingSwitchTimer); |
| 263 | state.expectingSwitchTimer = setTimeout(() => { |
| 264 | state.expectingSwitch = false; |
| 265 | state.expectingSwitchTimer = null; |
| 266 | log('Expecting-switch flag expired (no new transcript found)'); |
| 267 | }, 15000); |
| 268 | log('Expecting session switch (/clear detected)'); |
| 269 | if (maybeAttachPendingSwitchTarget('markExpectingSwitch')) return; |
| 270 | |
| 271 | if (state.switchWatcher) { clearInterval(state.switchWatcher); state.switchWatcher = null; } |
| 272 | if (state.switchWatcherDelayTimer) { clearTimeout(state.switchWatcherDelayTimer); state.switchWatcherDelayTimer = null; } |
| 273 | state.switchWatcherDelayTimer = setTimeout(() => { |
| 274 | state.switchWatcherDelayTimer = null; |
| 275 | if (state.expectingSwitch && !state.switchWatcher) { |
| 276 | log('Hook did not bind within 5s, starting switchWatcher fallback'); |
| 277 | startSwitchWatcher(); |
| 278 | } |
| 279 | }, 5000); |
| 280 | } |
| 281 | |
| 282 | function startSwitchWatcher() { |
| 283 | if (state.switchWatcher) { clearInterval(state.switchWatcher); state.switchWatcher = null; } |
no test coverage detected