Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions public/js/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/<page> link.
// The console is not offered to anyone, admins included: an old /console/<page> link opens
Expand Down Expand Up @@ -1751,7 +1752,8 @@ function renderDeckHome(user) {
view.innerHTML = `<div role="status" style="max-width:560px;margin:18vh auto 0;padding:28px 32px;border:1px solid var(--line,rgba(23,33,56,.14));border-radius:8px"><h1 style="font-size:22px;margin:0 0 8px">Your workspace did not load</h1><p style="margin:0 0 20px;overflow-wrap:anywhere">A network or browser error stopped it. Check your connection and try again.</p><div style="display:flex;gap:10px;flex-wrap:wrap"><button class="btn" id="dkRetry">Try again</button><button class="btn ghost" id="dkOut">Sign out</button></div></div>`;
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;
Expand All @@ -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.
Expand All @@ -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 /<sec>?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.
Expand Down
16 changes: 9 additions & 7 deletions public/js/deck/launch.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,43 @@ 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() : {};
wsProfile = { name: d.workspaceName || "", logo: d.workspaceLogo || "", accent: d.workspaceAccent || "" };
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(() => {});
Expand Down
Loading