| 1405 | // One toast per burst, on the same clock as the lines relayed to Claude: a |
| 1406 | // burst ends after WATCH_BURST_MS of quiet, or WATCH_BURST_MAX_MS after it began. |
| 1407 | async function queueToast($, lines, epoch) { |
| 1408 | toastLines.push(...lines) |
| 1409 | const now = await $.clock.now() |
| 1410 | if (epoch !== seenEpoch) return |
| 1411 | if (!toastStart) toastStart = now |
| 1412 | if (toastTimer) toastTimer.cancel() |
| 1413 | const wait = Math.max(0, Math.min(WATCH_BURST_MS, toastStart + WATCH_BURST_MAX_MS - now)) |
| 1414 | toastTimer = $.clock.after(wait, () => { |
| 1415 | toastTimer = null |
| 1416 | toastStart = 0 |
| 1417 | const burst = toastLines |
| 1418 | toastLines = [] |
| 1419 | if (!burst.length) return |
| 1420 | const last = clipLine(burst[burst.length - 1], 120) |
| 1421 | $.ui.toast(burst.length > 1 ? last + ' (+' + (burst.length - 1) + ' more)' : last) |
| 1422 | }) |
| 1423 | } |
| 1424 | |
| 1425 | function drawSeenBand($, e) { |
| 1426 | const { Box, Text } = $.ui.resolve(e) |