Reshape desktop bootstrap into independent services

HostRuntime self-boots via boot() and emits state through existing
subscribeAll plumbing. DaemonStartService runs in parallel: on success
it upserts the connection, which HostRuntime's syncHosts already wires
into a controller; on failure it emits an error.

The bootstrap no longer awaits daemon-start before letting saved-host
controllers connect. index.tsx resolves the redirect from
useEarliestOnlineHostServerId + useDaemonStartLastError subscriptions,
not from a procedural promise. The splash error is derived state:
splashError = !anyOnlineHostServerId ? daemonStartError : null. Retry
calls only DaemonStartService.start().

Deletes initializeHostRuntime, setupDesktopManagedConnection,
addConnectionFromListenAndWaitForOnline, bootstrapDesktop on the store,
waitForAnyConnectionOnline (now unused in production), and the
phase enum. Net -623 lines.
This commit is contained in:
Mohamed Boudra
2026-04-27 16:36:07 +07:00
parent 88f382cad3
commit 40ce317ac2
10 changed files with 704 additions and 990 deletions
@@ -24,8 +24,7 @@ import { useWebScrollbarStyle } from "@/hooks/use-web-scrollbar-style";
interface StartupSplashScreenProps {
bootstrapState?: {
phase: "starting-daemon" | "connecting" | "online" | "error";
error: string | null;
splashError: string | null;
retry: () => void;
};
}
@@ -312,7 +311,7 @@ export function StartupSplashScreen({ bootstrapState }: StartupSplashScreenProps
const [logsError, setLogsError] = useState<string | null>(null);
const [isLoadingLogs, setIsLoadingLogs] = useState(false);
const isError = bootstrapState?.phase === "error";
const isError = bootstrapState !== undefined && bootstrapState.splashError !== null;
useEffect(() => {
if (!isError) {
@@ -418,7 +417,7 @@ export function StartupSplashScreen({ bootstrapState }: StartupSplashScreenProps
GitHub and include the logs below.
</Text>
<Text style={styles.errorMessage}>{bootstrapState.error}</Text>
<Text style={styles.errorMessage}>{bootstrapState.splashError}</Text>
{daemonLogs?.logPath ? <Text style={styles.logsMeta}>{daemonLogs.logPath}</Text> : null}