feat(stream): RECONNECTING driven by the status poll — no invented countdown (TASK 32·2)
Creator challenge (2026-11-05): "I really don't think that's going to be a constant — it's going to
depend on so many variables, some that are dark to us." Correct, so the measured-grace constant and
the countdown are dropped from the spec. YouTube's cutoff is server-side and depends on ingest health,
prior stream quality, region and load; a pinned number would be a guess wearing a timer, and it would
be wrong exactly when the creator is staring at it.
What ships instead:
- **Amber RECONNECTING** in the top bar with measured facts only: elapsed seconds and the attempt
number ("0:12 · attempt 2 of 4"). The seconds come from a stopwatch started at the drop.
- **The status poll speeds up while recovering** (30 s → 4 s) and drives the sign; it restores 30 s
when recovery ends.
- **`chatEndedEvent`** — already in the chat feed we poll and previously skipped — now raises a signal
that prompts an immediate status check. It never decides anything: `liveBroadcasts.list`
`lifeCycleStatus` stays authoritative, with `liveStreams.list` health as the push-received signal.
- At `complete`: red OFF AIR (the existing stop path) rather than a pretend-live sign.
Tests: `ChatEndedSignalTests` (the marker is not a chat row, the service raises the signal, and a
complete broadcast ends recovery with the honest message). FAST gate: 543 passed, 0 warnings.
This commit is contained in:
@@ -25,6 +25,14 @@ public class YouTubeChatService : IDisposable
|
||||
|
||||
public event Action<ChatMessage>? MessageReceived;
|
||||
|
||||
internal void NotifyChatEnded() => ChatEnded?.Invoke();
|
||||
|
||||
/// <summary>Raised when YouTube puts a <c>chatEndedEvent</c> in the feed — the chat is over, which
|
||||
/// means the broadcast is. TASK 32·2 uses it as a cheap prompt to check the broadcast status
|
||||
/// immediately instead of waiting for the next health poll. It never decides anything by itself:
|
||||
/// <c>liveBroadcasts.list</c> stays authoritative.</summary>
|
||||
public event Action? ChatEnded;
|
||||
|
||||
private static readonly JsonSerializerOptions JsonOpts = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
@@ -80,6 +88,7 @@ public class YouTubeChatService : IDisposable
|
||||
|
||||
var json = await response.Content.ReadAsStringAsync();
|
||||
var page = ParsePage(json);
|
||||
if (json.Contains("chatEndedEvent", StringComparison.Ordinal)) NotifyChatEnded();
|
||||
|
||||
if (page.NextPageToken != null)
|
||||
_nextPageToken = page.NextPageToken;
|
||||
|
||||
Reference in New Issue
Block a user