Files
LanMountainDesktop/LanMountainDesktop.Shared.Contracts/Launcher/LoadingState.cs
lincube 33591a0a63 Add startup visual modes and attempt registry
Implement startup visual behavior, de-duplicate startup attempts, and improve failure UX.

Key changes:
- Add spec and docs for startup visuals and timing contract (.trae/specs and docs/LAUNCHER_STARTUP_VISUALS.md).
- Introduce StartupVisualPreferences contract and resolver; create SplashWindow via resolved mode.
- Add StartupAttemptRecord model and a file-backed StartupAttemptRegistry to persist and coordinate in-progress startup attempts (attach/adopt, soft/hard timeouts, IPC/connect state, lifecycle updates).
- Update LauncherFlowCoordinator to: adopt/attach to existing attempts, track IPC connection and soft/hard timeouts (30s/120s), show delayed UI state, attempt foreground recovery via public IPC, compose detailed launch result metadata, and mark registry states (soft timeout, detached waiting, succeeded, failed).
- Add TryActivateExistingInstanceAsync to attempt activating an existing desktop via IPC.
- Change failure flow: ShowFailureWindowAsync now returns user choice; ErrorWindow updated to present Activate/Wait/Open Logs/Exit semantics and new layouts/styles; improved button wiring and debug/dev mode handling.
- Add UI and resource tweaks (ErrorWindow and SplashWindow changes), project asset link for nightly logo, and unit tests for StartupVisualPreferences.

These changes prevent duplicate desktop processes during slow startups, provide clearer UX for delayed startups, and persist startup attempt state across Launcher invocations for safer recovery/attach behavior.
2026-04-23 09:03:35 +08:00

86 lines
1.8 KiB
C#

namespace LanMountainDesktop.Shared.Contracts.Launcher;
public enum LoadingItemType
{
System,
Settings,
Plugin,
Component,
Resource,
Data,
Network,
Other
}
public enum LoadingState
{
Pending,
InProgress,
Completed,
Delayed,
Failed,
Cancelled,
Timeout
}
public record LoadingItem
{
public required string Id { get; init; }
public LoadingItemType Type { get; init; }
public required string Name { get; init; }
public string? Description { get; init; }
public LoadingState State { get; init; }
public int ProgressPercent { get; init; }
public string? Message { get; init; }
public string? ErrorMessage { get; init; }
public DateTimeOffset? StartTime { get; init; }
public DateTimeOffset? EndTime { get; init; }
public int? EstimatedRemainingSeconds { get; init; }
public List<LoadingItem>? Children { get; init; }
public Dictionary<string, string>? Metadata { get; init; }
public DateTimeOffset Timestamp { get; init; } = DateTimeOffset.UtcNow;
}
public record LoadingStateMessage
{
public StartupStage Stage { get; init; }
public int OverallProgressPercent { get; init; }
public List<LoadingItem> ActiveItems { get; init; } = new();
public int CompletedCount { get; init; }
public int TotalCount { get; init; }
public string? Message { get; init; }
public bool HasErrors { get; init; }
public List<string>? ErrorMessages { get; init; }
public DateTimeOffset Timestamp { get; init; } = DateTimeOffset.UtcNow;
}
public record DetailedProgressMessage : StartupProgressMessage
{
public LoadingItem? CurrentItem { get; init; }
public List<LoadingItem>? AllItems { get; init; }
public bool IsMajorUpdate { get; init; }
}