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:
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using ytLive.Services;
|
||||
|
||||
namespace ytLive.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// TASK 32·2 — the reconnecting sign is driven by what YouTube says, not by a timer (spec revised
|
||||
/// 2026-11-05: the creator pointed out that the cutoff is not a constant, it depends on variables
|
||||
/// "some that are dark to us"). So: the chat-ended marker is a prompt to check, the broadcast status
|
||||
/// decides, and a completion ends recovery honestly.
|
||||
/// </summary>
|
||||
public class ChatEndedSignalTests
|
||||
{
|
||||
[Fact]
|
||||
public void ChatEndedEvent_IsNotAChatRow_ButItIsASignal()
|
||||
{
|
||||
const string json = """
|
||||
{
|
||||
"items": [
|
||||
{"id":"e1","snippet":{"type":"chatEndedEvent","publishedAt":"2026-11-05T10:00:00.000Z"}}
|
||||
]
|
||||
}
|
||||
""";
|
||||
|
||||
// It never becomes a message…
|
||||
Assert.Empty(YouTubeChatService.ParsePage(json).Messages);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThePollingService_RaisesChatEnded_ForThatMarker()
|
||||
{
|
||||
var service = new YouTubeChatService(new YouTubeAuthService("id", "secret"));
|
||||
var raised = 0;
|
||||
service.ChatEnded += () => raised++;
|
||||
|
||||
service.NotifyChatEnded();
|
||||
|
||||
Assert.Equal(1, raised);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task BroadcastComplete_EndsRecovery_InsteadOfPretendingToBeLive()
|
||||
{
|
||||
var reported = new List<string>();
|
||||
var recovery = new StreamRecovery(new StreamRetryPolicy(new[] { TimeSpan.Zero }), new StreamRecoverySteps
|
||||
{
|
||||
RestartAudio = _ => Task.CompletedTask,
|
||||
StartPush = _ => Task.FromResult(true),
|
||||
CheckBroadcast = _ => Task.FromResult(BroadcastLiveness.Complete),
|
||||
Report = reported.Add,
|
||||
Log = _ => { },
|
||||
});
|
||||
|
||||
var result = await recovery.RunAsync(CancellationToken.None);
|
||||
|
||||
Assert.Equal(RecoveryOutcome.BroadcastComplete, result.Outcome);
|
||||
Assert.Contains(reported, text => text.Contains("complete") && text.Contains("cannot be resumed"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user