feat(topbar): three activities, always visible — build, stream, record

Creator ruling 2026-11-13: "the app does three things. builds. records. live-streams." So the bar holds
three buttons that never disappear; the active one is lit and runs its own flow in place, and the other
two dim but stay clickable, so there is no state where the creator cannot see where they are or how to
step back.

  Build    [Build Scenes]  -> editing on, nothing to start
  YouTube  [Live][Private] -> [Start] -> [Stop]     (Private = the private-visibility test stream)
  Record   [Start Recording] -> [● REC hh:mm:ss][Stop Recording]

Arming and starting are separate presses on purpose (creator): Start is the last chance to tell someone
"check you are ready". Collapsing them would save one click and lose that prompt.

This replaces the two-world model (BarWorld) and its output stage outright, including the chips added
earlier today. The old pills remain the underlying state (OnAirPillOn/RecordPillOn) so the start, stop and
step-down paths are untouched; the activity only decides what the bar shows.

Closing the app no longer waits 6 s for a session that cannot stop: it waits ~2 s, then clears the state
and closes anyway. A window that refuses to close is worse than a stale flag — and that refusal is what
hung the suite in ZoomBoxInteractionTests, which sets IsRecording and closes a real window.

Test: TopBarActivityTests pins all three flows, the arm-then-start split, and that stepping back to Build
forgets the YouTube choice instead of carrying it. TopBarWorldTests is retired with the model it tested.
This commit is contained in:
2026-11-13 11:30:57 -08:00
parent f4caea09ad
commit ba60f9ab3d
9 changed files with 311 additions and 251 deletions
@@ -656,7 +656,7 @@ public partial class MainViewModel : ViewModelBase
}
OnPropertyChanged(nameof(RecDotOpacity));
OnPropertyChanged(nameof(LiveElapsedText));
OnPropertyChanged(nameof(RecordChipText));
OnPropertyChanged(nameof(RecordActionLabel));
}
private void OnLiveTimerTick(object? sender, EventArgs e)
@@ -666,7 +666,7 @@ public partial class MainViewModel : ViewModelBase
_recordLength = _liveElapsed;
_recDotPulse = _recDotPulse > 0.5 ? 0.2 : 1.0;
OnPropertyChanged(nameof(RecDotOpacity));
OnPropertyChanged(nameof(RecordChipText));
OnPropertyChanged(nameof(RecordActionLabel));
// TASK 55·3: the last useful warning before the encoder fails for a reason it won't explain.
if (IsRecording && !_lowDiskWarned && _recordFolder is { } folder
+4 -4
View File
@@ -87,7 +87,7 @@ public partial class MainViewModel : ViewModelBase
OnPropertyChanged(nameof(ShowChatInactiveMessage));
OnPropertyChanged(nameof(ShowPreviewPlaceholder));
RaiseTopBarModes();
RaiseOutputStage(); // IsLive drives ShowOutputStage
RaiseActivityStage(); // IsLive drives ShowOutputStage
UpdateLiveVisuals();
}
}
@@ -118,7 +118,7 @@ public partial class MainViewModel : ViewModelBase
{
if (!SetProperty(ref _recordPillOn, value)) return;
if (value && _onAirPillOn) OnAirPillOn = false; // record-OR-live — arming REC drops ON-AIR
RaiseOutputStage();
RaiseActivityStage();
OnPropertyChanged(nameof(ShowPrimaryStartButton));
OnPropertyChanged(nameof(PrimaryStartKind));
OnPropertyChanged(nameof(PrimaryStartButtonLabel));
@@ -138,7 +138,7 @@ public partial class MainViewModel : ViewModelBase
// intent, not reality; the Start face turns this into a sign-in.
if (!SetProperty(ref _onAirPillOn, value)) return;
if (value && _recordPillOn) RecordPillOn = false; // record-OR-live — arming ON-AIR drops REC
RaiseOutputStage();
RaiseActivityStage();
OnPropertyChanged(nameof(ShowPrimaryStartButton));
OnPropertyChanged(nameof(PrimaryStartKind));
OnPropertyChanged(nameof(PrimaryStartButtonLabel));
@@ -171,7 +171,7 @@ public partial class MainViewModel : ViewModelBase
OnPropertyChanged(nameof(EndButtonText));
OnPropertyChanged(nameof(ShowTestButton));
RaiseTopBarModes();
RaiseOutputStage(); // Start Recording <-> Stop Recording, and the REC clock
RaiseActivityStage(); // Start Recording <-> Stop Recording, and the REC clock
UpdateSessionTimer();
}
}
+86 -94
View File
@@ -3,123 +3,115 @@ using ytLive.Helpers;
namespace ytLive.ViewModels;
/// <summary>Which half of the top bar's dual segment is in force.</summary>
public enum BarWorld
/// <summary>What the app is doing (creator, 2026-11-13): build, record, or stream. Three activities,
/// three buttons, always visible.</summary>
/// <summary>Which YouTube stream is armed. Choosing does not start it — Start does.</summary>
public enum StreamMode
{
/// <summary>Build Scenes — the edit surface. The default at launch (creator ruling 2026-11-12).</summary>
Build,
/// <summary>Record / Go Live — the output surface: which output, and the one action that starts it.</summary>
Output,
None,
Live,
Private,
}
public enum TopActivity
{
Build,
YouTube,
Record,
}
/// <summary>
/// The top bar's one decision (creator ruling 2026-11-12): <c>[ Build Scenes ][ Record / Go Live ]</c>.
/// Build Scenes <b>is</b> edit mode — there is no separate EDIT toggle any more, so "may I edit?" and
/// "which world am I in?" cannot disagree.
///
/// <para>Clicking the highlighted segment is not a no-op: it re-enters that world, which matters while a
/// session runs because Build Scenes is the only way back to the layers (see
/// <see cref="LockEditWhileLive"/>).</para>
/// </summary>
public partial class MainViewModel
{
private BarWorld _barWorld = BarWorld.Build;
private TopActivity _activity = TopActivity.Build;
public BarWorld BarWorld => _barWorld;
public TopActivity Activity => _activity;
public bool IsBuildWorld => _barWorld == BarWorld.Build;
public bool IsOutputWorld => _barWorld == BarWorld.Output;
public bool IsBuildActivity => _activity == TopActivity.Build;
public bool IsYouTubeActivity => _activity == TopActivity.YouTube;
public bool IsRecordActivity => _activity == TopActivity.Record;
/// <summary>The output stage belongs to the Record / Go Live world, and only while nothing is
/// running — a live session cannot change its output, so its switch is not offered.</summary>
// A recording KEEPS the stage visible: the pill carries REC, the elapsed time and the stop. A live
// stream does not — its reality line takes over (see RunningVisible).
public bool ShowOutputStage => IsOutputWorld && !IsLive;
// ─── Each activity's own flow ───
// Build: nothing to start. YouTube: Live or Private, then Stop. Record: Start, then Stop.
// ─── The output stage's three states (creator, builds 728/729) ───
// 1. nothing chosen: [YouTube] [Local MP4]
// 2. YouTube chosen: [YouTube(red)] [Live Stream] [Private Stream] (Private = the test run)
// 3. Local MP4 chosen: [Local MP4(red)] [Start Recording] -> [End Recording] while recording
public bool ShowOutputChoice => ShowOutputStage && !RecordPillOn && !OnAirPillOn;
public bool ShowYouTubeSelected => ShowOutputStage && OnAirPillOn;
public bool ShowLocalMp4Selected => ShowOutputStage && RecordPillOn;
/// <summary>The YouTube chip shows while nothing is chosen and while YouTube IS the choice; once
/// Local MP4 is chosen the MP4 chip replaces it in the left slot (creator, build 729).</summary>
public bool YouTubeChipVisible => ShowOutputChoice || ShowYouTubeSelected;
public bool LocalMp4ChipVisible => ShowOutputChoice || ShowLocalMp4Selected;
// YouTube is two steps ON PURPOSE (creator, 2026-11-13): choosing Live or Private only ARMS it,
// because Start is the last moment to tell someone "check you are ready". Collapsing the two would
// trade that prompt for one fewer click.
private StreamMode _streamMode = StreamMode.None;
/// <summary>The left chip reads "Local MP4" while idle and "REC: hh:mm:ss" while recording, so the
/// tabular figure cannot jitter the pill's width.</summary>
public string RecordChipText => IsRecording ? $"REC: {LiveElapsedText}" : "Local MP4";
public bool IsLiveModeChosen => _streamMode == StreamMode.Live;
public bool IsPrivateModeChosen => _streamMode == StreamMode.Private;
public bool ShowStartRecordingAction => ShowLocalMp4Selected && !IsRecording;
public bool ShowEndRecordingAction => ShowLocalMp4Selected && IsRecording;
public bool ShowYouTubeModeChoices => IsYouTubeActivity && !IsLive && _streamMode == StreamMode.None;
public bool ShowYouTubeStart => IsYouTubeActivity && !IsLive && _streamMode != StreamMode.None;
public bool ShowYouTubeStop => IsYouTubeActivity && IsLive;
public bool ShowRecordStart => IsRecordActivity && !IsRecording;
public bool ShowRecordStop => IsRecordActivity && IsRecording;
public ICommand SelectYouTubeCommand { get; private set; } = null!;
public ICommand SelectLocalMp4Command { get; private set; } = null!;
public ICommand StartRecordingCommand { get; private set; } = null!;
public ICommand TestStreamCommand { get; private set; } = null!;
public ICommand GoLiveCommand { get; private set; } = null!;
/// <summary>The Record activity's own words: its name while idle, its action while chosen.</summary>
public string RecordActionLabel => IsRecording ? "Stop Recording" : "Start Recording";
public string RecordElapsedLabel => $"REC: {LiveElapsedText}";
public ICommand EnterBuildWorldCommand { get; private set; } = null!;
public ICommand EnterOutputWorldCommand { get; private set; } = null!;
public ICommand SelectBuildActivityCommand { get; private set; } = null!;
public ICommand SelectYouTubeActivityCommand { get; private set; } = null!;
public ICommand SelectRecordActivityCommand { get; private set; } = null!;
public ICommand ChooseLiveModeCommand { get; private set; } = null!;
public ICommand ChoosePrivateModeCommand { get; private set; } = null!;
public ICommand StartChosenStreamCommand { get; private set; } = null!;
private void InitializeWorldCommands()
private void InitializeActivityCommands()
{
SelectYouTubeCommand = new RelayCommand(_ => OnAirPillOn = true, _ => ShowOutputChoice);
SelectLocalMp4Command = new RelayCommand(_ => RecordPillOn = true, _ => ShowOutputChoice);
StartRecordingCommand = new RelayCommand(_ => BeginRecordOnly(), _ => ShowStartRecordingAction);
// A signed-out press starts the sign-in flow instead of sitting dead (no-dead-ends rule).
TestStreamCommand = new RelayCommand(_ =>
SelectBuildActivityCommand = new RelayCommand(_ => SelectActivity(TopActivity.Build));
SelectYouTubeActivityCommand = new RelayCommand(_ => SelectActivity(TopActivity.YouTube));
SelectRecordActivityCommand = new RelayCommand(_ => SelectActivity(TopActivity.Record));
ChooseLiveModeCommand = new RelayCommand(_ => SetStreamMode(StreamMode.Live), _ => ShowYouTubeModeChoices);
ChoosePrivateModeCommand = new RelayCommand(_ => SetStreamMode(StreamMode.Private), _ => ShowYouTubeModeChoices);
// Start is its own press: the last chance to say "you're about to be live".
// Signed out still routes to sign-in rather than sitting dead (no-dead-ends rule).
StartChosenStreamCommand = new RelayCommand(_ =>
{
if (!IsConnected) { _ = SignInAsync(); return; }
BeginTestStream();
}, _ => ShowYouTubeSelected);
GoLiveCommand = new RelayCommand(_ =>
{
if (!IsConnected) { _ = SignInAsync(); return; }
StartSession();
}, _ => ShowYouTubeSelected);
EnterBuildWorldCommand = new RelayCommand(_ => EnterWorld(BarWorld.Build));
EnterOutputWorldCommand = new RelayCommand(_ => EnterWorld(BarWorld.Output));
if (_streamMode == StreamMode.Private) BeginTestStream();
else StartSession();
}, _ => ShowYouTubeStart);
}
/// <summary>Everything the output stage shows or hides, in one place so no caller can forget
/// one of them.</summary>
internal void RaiseOutputStage()
/// <summary>Switches activity. Build is the only one that edits; the other two take the layers away
/// but leave the button lit, so the creator can see where they are and step back.</summary>
internal void SelectActivity(TopActivity activity)
{
OnPropertyChanged(nameof(ShowOutputStage));
OnPropertyChanged(nameof(ShowOutputChoice));
OnPropertyChanged(nameof(ShowYouTubeSelected));
OnPropertyChanged(nameof(YouTubeChipVisible));
OnPropertyChanged(nameof(LocalMp4ChipVisible));
OnPropertyChanged(nameof(ShowLocalMp4Selected));
OnPropertyChanged(nameof(ShowStartRecordingAction));
OnPropertyChanged(nameof(ShowEndRecordingAction));
OnPropertyChanged(nameof(RecordChipText));
_activity = activity;
OnPropertyChanged(nameof(Activity));
OnPropertyChanged(nameof(IsBuildActivity));
OnPropertyChanged(nameof(IsYouTubeActivity));
OnPropertyChanged(nameof(IsRecordActivity));
EditingActive = activity == TopActivity.Build;
// The underlying outputs follow the activity, so the existing start commands and the
// record/live paths agree with what the bar is showing.
RecordPillOn = activity == TopActivity.Record;
OnAirPillOn = activity == TopActivity.YouTube;
_streamMode = StreamMode.None; // the YouTube flow always restarts at the choice
RaiseActivityStage();
}
/// <summary>Switches worlds. Re-entering the current one still re-asserts its edit state, which is
/// what lets a creator take EDIT back mid-show by clicking Build Scenes.</summary>
internal void EnterWorld(BarWorld world)
private void SetStreamMode(StreamMode mode)
{
_barWorld = world;
_streamMode = mode;
OnPropertyChanged(nameof(IsLiveModeChosen));
OnPropertyChanged(nameof(IsPrivateModeChosen));
RaiseActivityStage();
}
// Entering a world starts with NOTHING chosen inside it (creator, build 729): the output
// switches are a fresh decision each time, not a remembered one.
if (world == BarWorld.Output)
{
RecordPillOn = false;
OnAirPillOn = false;
}
OnPropertyChanged(nameof(BarWorld));
OnPropertyChanged(nameof(IsBuildWorld));
OnPropertyChanged(nameof(IsOutputWorld));
EditingActive = world == BarWorld.Build;
OnPropertyChanged(nameof(ShowOutputStage));
RaiseOutputStage();
internal void RaiseActivityStage()
{
OnPropertyChanged(nameof(ShowYouTubeModeChoices));
OnPropertyChanged(nameof(ShowYouTubeStart));
OnPropertyChanged(nameof(ShowYouTubeStop));
OnPropertyChanged(nameof(ShowRecordStart));
OnPropertyChanged(nameof(ShowRecordStop));
}
}
+12 -3
View File
@@ -342,7 +342,7 @@ public partial class MainViewModel : ViewModelBase
OpenHotkeyConfigCommand = new RelayCommand(_ => OpenHotkeyConfig());
ChangeAccountCommand = new RelayCommand(_ => _ = ChangeAccountAsync());
LogoutCommand = new RelayCommand(_ => _ = SignOutYouTubeAsync());
InitializeWorldCommands();
InitializeActivityCommands();
_layoutStore = new LayoutStore(LayoutPathOverride ?? DefaultLayoutPath);
_activeLayoutPath = _layoutStore.ActivePath;
@@ -635,10 +635,19 @@ public partial class MainViewModel : ViewModelBase
_shuttingDown = true;
StopStream();
for (var i = 0; i < 120 && (IsLive || IsRecording); i++) // up to ~6 s
for (var i = 0; i < 40 && (IsLive || IsRecording); i++) // ~2 s: long enough for a flush
await Task.Delay(50).ConfigureAwait(true);
return !IsLive && !IsRecording;
if (IsLive || IsRecording)
{
// The stop could not finish (no pump, a dead encoder, a test harness). A window that cannot
// close is a worse failure than a session flag left set, so clear the UI state and go.
AppLog.Write("Shutdown: session did not stop in time; closing anyway", AppLogMessageType.Warning);
IsRecording = false;
StreamStatus = StreamStatus.Offline;
}
return true;
}
public void Shutdown()