From 07ffee80da01fba08d9a0d4a5416def924c84f3b Mon Sep 17 00:00:00 2001 From: Darknode-Official Date: Tue, 24 Nov 2026 11:54:28 -0800 Subject: [PATCH] fix(boot): keep the boot screen up until the Deck has drawn Signed-in loads faded the boot screen out as soon as sign-in resolved, then loaded the Deck code and three Firestore reads one after another, so the empty page showed for 1-2 s. The Deck paths (web and desktop) now dismiss the boot screen once openDeck has drawn (or failed), and openDeck loads its code and the profile, plan-share and notification reads together. --- public/js/auth.js | 11 ++++++++--- public/js/deck/launch.js | 16 +++++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/public/js/auth.js b/public/js/auth.js index da8c0f78..bd42c38c 100644 --- a/public/js/auth.js +++ b/public/js/auth.js @@ -1712,7 +1712,8 @@ function renderDesktopHome(user) { if (typeof t === "function") t("Darknode " + r.latest + " is available. Open This Computer to download it."); }, () => {}); }) - .catch((e) => note("The workspace did not load", esc((e && e.message) || "Unknown error"), true)); + .catch((e) => note("The workspace did not load", esc((e && e.message) || "Unknown error"), true)) + .finally(dismissBoot); } // Web home: the Deck is the only signed-in UI and owns every darknode.ai/ link. // The console is not offered to anyone, admins included: an old /console/ link opens @@ -1751,7 +1752,8 @@ function renderDeckHome(user) { view.innerHTML = `

Your workspace did not load

A network or browser error stopped it. Check your connection and try again.

`; view.querySelector("#dkRetry").onclick = () => location.reload(); // a failed import stays failed for this page, so reload view.querySelector("#dkOut").onclick = doLogout; - }); + }) + .finally(dismissBoot); } function renderApp(user) { _appUid = user && user.uid || null; @@ -1760,7 +1762,9 @@ function renderApp(user) { // the Deck) can adopt the parent tab's session when its own Firebase persistence resolves // to null — otherwise every Deck tool paints the public landing page instead of the tool. try { window.__dnCurrentUser = user || null; } catch (_) {} - dismissBoot(); + // The Deck paths take the boot screen down only once the Deck has drawn, so the empty + // page never shows while its code and the account's profile load. + if (window.__boot) window.__boot.set(85); document.body.classList.remove("landing"); document.body.classList.add("app"); // Desktop app (top frame only; tool iframes never see the bridge): the Deck is the home screen. @@ -1772,6 +1776,7 @@ function renderApp(user) { if (q.get("embed") === "1" && window.parent === window) { q.delete("embed"); q.delete("ink"); const qs = q.toString(); location.replace(location.pathname + (qs ? "?" + qs : "") + location.hash); return; } } catch (_) {} if (deckIsHome()) { renderDeckHome(user); return; } + dismissBoot(); // Embed mode: when loaded as /?embed=1 (e.g. inside Darknode Command's // in-deck workspace iframe), strip the console chrome so only the live tool // shows, full-bleed and transparent. Reused by any host that frames a tool. diff --git a/public/js/deck/launch.js b/public/js/deck/launch.js index 86b966f8..7d19aa2c 100644 --- a/public/js/deck/launch.js +++ b/public/js/deck/launch.js @@ -13,14 +13,15 @@ let _deckOff = null; // teardown of the mounted Deck, so relaunching never stack // admin custom claim; Security Rules enforce it server-side) unlocks the owner-only // pieces, and onSignOut makes the Deck the primary UI (no console exit). export async function openDeck(user, extra = {}) { - const [{ renderDeck }, nav] = await Promise.all([ + const modsP = Promise.all([ import("/js/deck-ui.js?v=20261030d"), import("/js/console-nav.js?v=20261029d"), ]); // Workspace identity (A1): load the owner's workspace profile so the Deck header, // Plans and reports show it instead of a hardcoded label. Non-fatal if it fails. + // The code and the three reads below are independent, so they load together (the boot screen waits on them). let wsProfile = {}, deckTier = "", onboarding = {}; - if (user) { + const profileP = !user ? null : (async () => { try { const snap = await getDoc(doc(db, "users", user.uid)); const d = snap.exists() ? snap.data() : {}; @@ -28,26 +29,27 @@ export async function openDeck(user, extra = {}) { deckTier = d.tier || ""; onboarding = d.onboarding || {}; } catch (_) {} - } + })(); // Plan sharing: when the remembered active workspace is a team whose owner shares their // plan, the Deck is built for that plan. Non-fatal (falls back to the user's own plan). let sharedTier = ""; - if (user) { + const shareP = !user ? null : (async () => { try { const ws = await import("/js/workspaces.js?v=20261018i"); const wid = ws.activeWorkspace(); if (wid && wid !== user.uid) { const sh = await ws.getWorkspacePlanShare(wid); if (sh.on) sharedTier = sh.tier; } } catch (_) {} - } + })(); // Durable account notifications (A6): the owner's own recent account-level // messages (e.g. a granted upgrade). Low-volume subcollection; non-fatal. let accountNotifs = []; - if (user) { + const notifsP = !user ? null : (async () => { try { const nsnap = await getDocs(query(collection(db, "users", user.uid, "notifications"), orderBy("ts", "desc"), limit(20))); accountNotifs = nsnap.docs.map((dd) => { const n = dd.data() || {}; return { id: dd.id, text: n.text || "", ts: typeof n.ts === "number" ? n.ts : 0, kind: n.kind || "", read: !!n.read }; }); } catch (_) {} - } + })(); + const [[{ renderDeck }, nav]] = await Promise.all([modsP, profileP, shareP, notifsP]); // Inside the desktop app: report app + VM usage to the owner's admin panel (at most // every 6 hours; Settings > Share app usage turns it off). A no-op in a browser. if (user) import("/js/usage-ping.js?v=1").then((m) => m.pingAppUsage()).catch(() => {});