An open-source, self-hosted system for apps built with web technologies.
Wait for restored Programs at startup
zohayrslilehd8bc496253cb
diff --git a/source/client/view/desktop/window-manager/process-window.tsx b/source/client/view/desktop/window-manager/process-window.tsxindex ba94232..763838f 100644--- a/source/client/view/desktop/window-manager/process-window.tsx+++ b/source/client/view/desktop/window-manager/process-window.tsx@@ -19,7 +19,7 @@ const loadingExitDuration = 200* props so memoization can see which process actually changed even though* the peer deliberately keeps each Process instance alive and mutates it.*/-export default memo(function ({ identity, record, client, title, icon, position, size, localSurface, geometryAnimation, onLocalAnimationComplete, onLocalRepresentation, paintSurfaceSize, depth, active, minimized, closing, stopping, entering, bare, door, programAccess, onFrame, onFrameLoad, onRaise, onMinimize, onFill, onClose, onClosed, onUnavailable, onMove, onResize, onSnap }: ProcessWindowProps) {+export default memo(function ({ identity, record, client, title, icon, position, size, localSurface, geometryAnimation, onLocalAnimationComplete, onLocalRepresentation, paintSurfaceSize, depth, active, minimized, closing, stopping, entering, bare, door, programAccess, onFrame, onFrameLoad, onReady, onRaise, onMinimize, onFill, onClose, onClosed, onUnavailable, onMove, onResize, onSnap }: ProcessWindowProps) {const activate = useCallback(() => onRaise(record), [onRaise, record])@@ -72,7 +72,13 @@ export default memo(function ({ identity, record, client, title, icon, position,secondFrame = requestAnimationFrame(() => {- settled = globalThis.setTimeout(() => setLoading({ source: frameSource, phase: "leaving" }), settleDelay)+ settled = globalThis.setTimeout(() => {++ setLoading({ source: frameSource, phase: "leaving" })++ onReady(record.identity)++ }, settleDelay)})})@@ -85,7 +91,7 @@ export default memo(function ({ identity, record, client, title, icon, position,if (settled) globalThis.clearTimeout(settled)}- }, [frameSource, loading])+ }, [frameSource, loading, onReady, record.identity])const loadingVisible = closing || programAccess === "checking" || programAccess === "available" && (loading.source !== frameSource || loading.phase !== "hidden")@@ -240,6 +246,8 @@ interface ProcessWindowProps {onFrameLoad: (identity: string, element: HTMLIFrameElement) => void+ onReady: (identity: string) => void+onRaise: (record: Process) => voidonMinimize: (record: Process, minimized: boolean) => voiddiff --git a/source/client/view/desktop/workspace.tsx b/source/client/view/desktop/workspace.tsxindex 247f887..4a7b703 100644--- a/source/client/view/desktop/workspace.tsx+++ b/source/client/view/desktop/workspace.tsx@@ -1,5 +1,5 @@import { type Layer } from "@server/core/link-manager/auth-manager/program-manager/config"-import { type SyntheticEvent, useCallback, useRef, useState } from "react"+import { type SyntheticEvent, useCallback, useEffect, useRef, useState } from "react"import { ApplicationContext, AuthManagerContext } from "../contexts"import useClientHost from "./client-host/client-host"import DesktopDisplay from "./desktop-display"@@ -18,6 +18,7 @@ import useProperty from "@libs/the-link/plugins/react-helper/property-hook"import { ReadyWallpaper, WallpaperBackground } from "../components/wallpaper"import ProgramFrame from "./program-frame"import Loading from "../components/loading"+import { useRequirement } from "@libs/readiness/main"export default function Workspace() {@@ -29,6 +30,14 @@ export default function Workspace() {const windows = useWindows()+ const completePrograms = useRequirement("programs")++ const initialPrograms = useRef<ReadonlySet<string> | null>(null)++ initialPrograms.current ??= new Set(windows.records.map(record => record.identity))++ const [readyPrograms, setReadyPrograms] = useState<ReadonlySet<string>>(() => new Set())+const wallpaperIdentity = windows.wallpaper?.identity ?? nullconst [readyWallpaper, setReadyWallpaper] = useState<string | null>(null)@@ -43,6 +52,16 @@ export default function Workspace() {const [programAccess, setProgramAccess] = useState<ProgramAccess>("checking")+ const currentPrograms = new Set(windows.records.map(record => record.identity))++ const initialProgramsReady = programAccess === "blocked" || [...initialPrograms.current].every(identity => readyPrograms.has(identity) || !currentPrograms.has(identity))++ useEffect(function () {++ if (initialProgramsReady) completePrograms()++ }, [completePrograms, initialProgramsReady])+// Each frame, by process identity. This resolves a message's sender and// lets the desktop announce the surface that actually contains it.const sources = useRef(new Map<string, HTMLIFrameElement | null>())@@ -67,6 +86,19 @@ export default function Workspace() {setFileWallpaperReady(true)}, [])+ const programReady = useCallback(function (identity: string) {++ if (!initialPrograms.current?.has(identity)) return++ setReadyPrograms(current => {++ if (current.has(identity)) return current++ return new Set([...current, identity])+ })++ }, [])+const focus = useDesktopFocus(desktop, windows)// Resolved once per desktop render. Asking inside every window and@@ -132,6 +164,8 @@ export default function Workspace() {onFrameLoad={frameLoaded}+ onReady={programReady}+onRaise={windows.raise}onMinimize={focus.minimize}