refactor(app): make session start terminal

Move live-session startup and its existing diagnostics into the typed Phase-9 owner. GameWindow.OnLoad now ends immediately after that phase, so no callback binding, publication, or allocation can occur after the session becomes active.

Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
Erik 2026-07-22 19:06:00 +02:00
parent 3628aeb520
commit 54244d31f1
11 changed files with 139 additions and 39 deletions

View file

@ -0,0 +1,47 @@
using AcDream.App.Net;
namespace AcDream.App.Composition;
internal sealed record SessionStartDependencies(
RuntimeOptions Options,
Action<string> Log);
/// <summary>
/// Terminal startup phase. Every callback, command target, and frame root is
/// already published when this owner asks the canonical session host to start.
/// </summary>
internal sealed class SessionStartCompositionPhase
: ISessionStartCompositionPhase<FrameRootResult>
{
private readonly SessionStartDependencies _dependencies;
public SessionStartCompositionPhase(SessionStartDependencies dependencies) =>
_dependencies = dependencies
?? throw new ArgumentNullException(nameof(dependencies));
public void Start(FrameRootResult frame)
{
ArgumentNullException.ThrowIfNull(frame);
LiveSessionStartResult result =
frame.SessionHost.Start(_dependencies.Options);
Report(result, _dependencies.Log);
}
internal static void Report(
LiveSessionStartResult result,
Action<string> log)
{
ArgumentNullException.ThrowIfNull(result);
ArgumentNullException.ThrowIfNull(log);
switch (result.Status)
{
case LiveSessionStartStatus.MissingCredentials:
log(
"live: ACDREAM_LIVE set but TEST_USER/TEST_PASS missing; skipping");
break;
case LiveSessionStartStatus.Failed:
log($"live: session failed: {result.Error}");
break;
}
}
}