The VS Code of video editing, built for agents.
TypeScript
Refactor dashboard and project routing for improved navigation
konstantin-paulusba1dd1b8cdfd
diff --git a/apps/web/src/app.tsx b/apps/web/src/app.tsxindex efcd8533..f1d22604 100644--- a/apps/web/src/app.tsx+++ b/apps/web/src/app.tsx@@ -14,10 +14,11 @@ import { UpgradeDialog } from '@/components/upgrade-dialog';import { PurchaseSuccess } from '@/components/purchase-success';import { ScreenTooSmall } from '@/components/screen-too-small';import { UnsupportedBrowser } from '@/components/unsupported-browser';-import { HomePage } from './pages/home';-import { LoginPage } from './pages/login';-import { AuthCallbackPage } from './pages/auth-callback';-import { NotFoundPage } from './pages/not-found';+import { ProjectPage } from '@/pages/project';+import { LoginPage } from '@/pages/login';+import { AuthCallbackPage } from '@/pages/auth-callback';+import { NotFoundPage } from '@/pages/not-found';+import { DashboardPage } from '@/pages/dashboard';function AuthGate(props: { children: JSX.Element }) {const auth = useAuth();@@ -66,7 +67,8 @@ function App() {)}><Route path="/auth/callback" component={AuthCallbackPage} />- <Route path="/" component={() => <AuthGate><HomePage /></AuthGate>} />+ <Route path="/" component={() => <AuthGate><DashboardPage /></AuthGate>} />+ <Route path="/projects/*name" component={() => <AuthGate><ProjectPage /></AuthGate>} /><Route path="*404" component={NotFoundPage} /></RouterComponent>);diff --git a/apps/web/src/components/canvas/desktop-app-banner.tsx b/apps/web/src/components/canvas/desktop-app-banner.tsxindex 2923e4f3..c1637fc1 100644--- a/apps/web/src/components/canvas/desktop-app-banner.tsx+++ b/apps/web/src/components/canvas/desktop-app-banner.tsx@@ -5,7 +5,7 @@import { Show } from "solid-js";import { Button } from "@/components/ui/button";import { Icon } from "@/components/ui/icon";-import { useEditorApi } from "@/context/editor-api";+import { useEditorApi } from "@/context/dapi";import { createStoredSignal } from "@/lib/store";import { downloadDesktopApp } from "@/lib/desktop-app";import { track } from "@/lib/analytics";diff --git a/apps/web/src/components/dashboard/dashboard.tsx b/apps/web/src/components/dashboard/dashboard.tsxdeleted file mode 100644index 8813b172..00000000--- a/apps/web/src/components/dashboard/dashboard.tsx+++ /dev/null@@ -1,104 +0,0 @@-/* This Source Code Form is subject to the terms of the Mozilla Public- * License, v. 2.0. If a copy of the MPL was not distributed with this- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */--import { useSearchParams } from "@solidjs/router";-import { Match, Switch } from "solid-js";--import { Dialog, DialogContent, DialogPortal } from "@/components/ui/dialog";--import { DashboardAccountView } from "./account-view";-import { DashboardAiCreditsView } from "./ai-credits-view";-import { DashboardBillingView } from "./billing-view";-import { DashboardGetDesktopApp } from "./get-desktop-app";-import { DashboardHelpView } from "./help-view";-import { DashboardProjectsView } from "./projects-view";-import { DashboardSettingsView } from "./settings-view";-import { DashboardSidebarHeader, DashboardSidebarNav, DashboardSidebarUser, DashboardSidebarItem } from "./sidebar";-import { Separator } from "@/components/ui/separator";--import type { DashboardView } from "./types";--const DASHBOARD_VIEWS: readonly DashboardView[] = [- "projects",- "templates",- "ai-credits",- "billing",- "account",- "settings",- "preferences",- "help",-];--function parseView(value: string | string[] | undefined): DashboardView {- const raw = Array.isArray(value) ? value[0] : value;- return DASHBOARD_VIEWS.find((v) => v === raw) ?? "projects";-}--export function Dashboard() {- const [params, setParams] = useSearchParams();-- const view = (): DashboardView => parseView(params.dashboard);- const setView = (next: DashboardView) => {- setParams({ dashboard: next }, { replace: true });- };-- const close = () => {- setParams({ dashboard: undefined }, { replace: true });- };-- const handleOpenChange = (open: boolean) => {- if (!open) close();- };-- return (- <Dialog open preventScroll={false} onOpenChange={handleOpenChange}>- <DialogPortal>- <DialogContent- showCloseButton={false}- class="h-150 min-w-251 overflow-hidden rounded-xl p-0 gap-0"- >- <div class="flex h-full min-h-0 flex-row">- <aside class="flex min-h-0 w-56 shrink-0 flex-col bg-card">- <DashboardSidebarHeader />- <DashboardSidebarNav>- <DashboardSidebarItem active={view() === "projects"} onClick={() => setView("projects")} icon="diffusion-project-file" label="Projects" />- <DashboardSidebarItem active={view() === "ai-credits"} onClick={() => setView("ai-credits")} icon="ai-generate" label="AI credits" class="mt-auto" />- <DashboardSidebarItem active={view() === "billing"} onClick={() => setView("billing")} icon="billing" label="Billing" />- <DashboardSidebarItem active={view() === "settings"} onClick={() => setView("settings")} icon="settings" label="Settings" />- <DashboardSidebarItem active={view() === "help"} onClick={() => setView("help")} icon="help" label="Help" />- </DashboardSidebarNav>- <DashboardSidebarUser active={view() === "account"} onClick={() => setView("account")} />- </aside>-- <Separator orientation="vertical" class="bg-border-strong" />-- <section class="flex min-h-0 flex-1 flex-col bg-canvas">- <Switch>- <Match when={view() === "projects"}>- <DashboardProjectsView />- </Match>- <Match when={view() === "ai-credits"}>- <DashboardAiCreditsView />- </Match>- <Match when={view() === "billing"}>- <DashboardBillingView />- </Match>- <Match when={view() === "account"}>- <DashboardAccountView />- </Match>- <Match when={view() === "settings"}>- <DashboardSettingsView />- </Match>- <Match when={view() === "help"}>- <DashboardHelpView />- </Match>- </Switch>- <DashboardGetDesktopApp />- </section>- </div>- </DialogContent>- </DialogPortal>- </Dialog>- );-}diff --git a/apps/web/src/components/dashboard/get-desktop-app.tsx b/apps/web/src/components/dashboard/get-desktop-app.tsxindex 0671eece..b060832a 100644--- a/apps/web/src/components/dashboard/get-desktop-app.tsx+++ b/apps/web/src/components/dashboard/get-desktop-app.tsx@@ -11,7 +11,6 @@ import {ContextMenuPortal,ContextMenuTrigger,} from "@/components/ui/context-menu";-import { useEditorApi } from "@/context/editor-api";import { downloadDesktopApp } from "@/lib/desktop-app";import { createStoredSignal } from "@/lib/store";import { track } from "@/lib/analytics";@@ -25,7 +24,7 @@ import { store } from "@/init";* context menu on the bar itself.*/export function DashboardGetDesktopApp() {- const { isDesktop } = useEditorApi();+ const isDesktop = !!window.desktop;const [hidden, setHidden] = createStoredSignal(store.define("dashboard.desktop-app-promo-hidden", false),);diff --git a/apps/web/src/components/dashboard/index.ts b/apps/web/src/components/dashboard/index.tsdeleted file mode 100644index c0d66686..00000000--- a/apps/web/src/components/dashboard/index.ts+++ /dev/null@@ -1,5 +0,0 @@-/* This Source Code Form is subject to the terms of the Mozilla Public- * License, v. 2.0. If a copy of the MPL was not distributed with this- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */--export * from "./dashboard";diff --git a/apps/web/src/components/dashboard/projects-view.tsx b/apps/web/src/components/dashboard/projects-view.tsxindex 649f660c..69835518 100644--- a/apps/web/src/components/dashboard/projects-view.tsx+++ b/apps/web/src/components/dashboard/projects-view.tsx@@ -2,7 +2,7 @@* License, v. 2.0. If a copy of the MPL was not distributed with this* file, You can obtain one at http://mozilla.org/MPL/2.0/. */-import { generateProjectName, DEFAULT_PROJECT_ID } from "@/components/engine/db";+import { generateProjectName } from "@/components/engine/db";import {ContextMenu,ContextMenuContent,@@ -14,8 +14,8 @@ import {import { Button } from "@/components/ui/button";import { TextField, TextFieldInput } from "@/components/ui/text-field";import { toast } from "somoto";-import { For, Show, batch, createMemo, createResource, createSignal, onCleanup, onMount } from "solid-js";-import { useSearchParams } from "@solidjs/router";+import { For, Show, batch, createMemo, createResource, createSignal, onCleanup } from "solid-js";+import { useNavigate } from "@solidjs/router";import {Select,@@ -32,9 +32,7 @@ import {DashboardViewSection,} from "./shared";import { DashboardSearchPanel } from "./search-bar";-import { useProjectId } from "@/hooks/use-project-id";-import { captureCanvasThumbnail } from "../engine/thumbnail";-import { MAIN_CANVAS_ID } from "../canvas";+import { projectRoute } from "@/hooks/use-project-id";import { Icon } from "../ui/icon";import { track } from "@/lib/analytics";import {@@ -51,10 +49,8 @@ import type { ProjectSortOption } from "./types";// Projects live on disk under a user-picked root (see @/projects). Thumbnails,// rename, duplicate and delete have no on-disk backing yet: the UI stays, the// operations are no-ops until the desktop host grows them.-const thumbnails = new Map<string, Blob>();--async function setProjectThumbnail(name: string, blob: Blob): Promise<void> {- thumbnails.set(name, blob);+async function getProjectThumbnail(_name: string): Promise<Blob | undefined> {+ return undefined;}async function setProjectName(_name: string, _newName: string): Promise<void> {@@ -71,8 +67,7 @@ async function deleteProject(_name: string): Promise<void> {}export function DashboardProjectsView() {- const projectId = useProjectId();- const [, setParams] = useSearchParams();+ const navigate = useNavigate();const [search, setSearch] = createSignal("");const [sort, setSort] = createSignal<ProjectSortOption>("last-viewed");const [projects, { refetch: refetchProjects }] = createResource(projectsRoot, () => listProjects());@@ -85,18 +80,6 @@ export function DashboardProjectsView() {const normalizedSearch = createMemo(() => search().trim().toLowerCase());- onMount(async () => {- if (projectId() == DEFAULT_PROJECT_ID) return;-- const canvas = document.getElementById(MAIN_CANVAS_ID) as HTMLCanvasElement | null;- if (!canvas) return;- const blob = await captureCanvasThumbnail(canvas);- if (blob) {- await setProjectThumbnail(projectId(), blob);- refetchProjects();- };- })-const filteredProjects = createMemo(() => {const query = normalizedSearch();const entries = projects() ?? [];@@ -127,7 +110,7 @@ export function DashboardProjectsView() {if (renamingProject() === project.name) return;track('project_opened');- setParams({ project: project.name, dashboard: undefined }, { replace: true });+ navigate(projectRoute(project.name));};const startRenaming = (project: ProjectInfo) => {@@ -296,7 +279,7 @@ export function DashboardProjectsView() {onClick={() => openProject(project)}><DashboardCardPreview>- <ProjectThumbnail thumbnail={thumbnails.get(project.name)} />+ <ProjectThumbnail name={project.name} /></DashboardCardPreview><div class="flex flex-col gap-1 px-2"><div class="relative h-4 w-full">@@ -361,10 +344,12 @@ export function DashboardProjectsView() {);}-function ProjectThumbnail(props: { thumbnail?: Blob }) {+function ProjectThumbnail(props: { name: string }) {+ const [thumbnail] = createResource(() => props.name, getProjectThumbnail);const url = createMemo(() => {- if (!props.thumbnail) return null;- return URL.createObjectURL(props.thumbnail);+ const blob = thumbnail();+ if (!blob) return null;+ return URL.createObjectURL(blob);});onCleanup(() => {diff --git a/apps/web/src/components/dashboard/settings-view.tsx b/apps/web/src/components/dashboard/settings-view.tsxindex cbcf3132..62723565 100644--- a/apps/web/src/components/dashboard/settings-view.tsx+++ b/apps/web/src/components/dashboard/settings-view.tsx@@ -2,14 +2,12 @@* License, v. 2.0. If a copy of the MPL was not distributed with this* file, You can obtain one at http://mozilla.org/MPL/2.0/. */-import { Match, Switch, createResource } from "solid-js";+import { Match, Switch } from "solid-js";import { toast } from "somoto";-import { retrieveLastAccessedDirectory } from "@/components/engine/db";-import { changeAssetDirectory } from "@/components/engine";import { Button } from "@/components/ui/button";import { Icon } from "@/components/ui/icon";-import { useEngine } from "@/context/engine";+import { pickProjectsRoot, projectsRoot } from "@/projects";import { usePermissionState, type PermissionState } from "@/hooks/use-permission";import {@@ -20,12 +18,12 @@ import {} from "./shared";function DashboardProjectsFolderSection() {- const engine = useEngine();- const [directory, { refetch }] = createResource(() => retrieveLastAccessedDirectory());-const handleChange = async () => {- await changeAssetDirectory(engine.world);- refetch();+ try {+ await pickProjectsRoot();+ } catch (e) {+ toast.error("Failed to choose projects folder", { description: (e as Error).message });+ }};return (@@ -33,7 +31,7 @@ function DashboardProjectsFolderSection() {<DashboardInfoActionRowtitle="Save projects to"leading={<Icon name="navigation.folder" class="text-foreground" />}- description={directory()?.name ?? "Origin private file system (OPFS)"}+ description={projectsRoot() ?? "No folder selected"}action={<Button variant="secondary" onClick={handleChange}>Change...diff --git a/apps/web/src/components/dashboard/sidebar.tsx b/apps/web/src/components/dashboard/sidebar.tsxindex beb6b950..1d327a51 100644--- a/apps/web/src/components/dashboard/sidebar.tsx+++ b/apps/web/src/components/dashboard/sidebar.tsx@@ -47,7 +47,9 @@ export function DashboardSidebarHeader() {const auth = useAuth();return (- <div class="flex flex-col items-start gap-3 p-4">+ // Extra top padding on the macOS desktop build clears the traffic lights+ // (hiddenInset title bar), except in fullscreen where they are gone.+ <div class="flex flex-col items-start gap-3 p-4 [[data-platform=darwin]:not([data-fullscreen=true])_&]:pt-12"><Icon name="diffusion-logo-large" class="size-6 text-muted-foreground" /><div class="flex h-10 w-full flex-col items-start gap-1 text-muted-foreground"><p class="w-full text-base leading-5 font-450 text-muted-foreground">diff --git a/apps/web/src/components/engine/db/global-db.ts b/apps/web/src/components/engine/db/global-db.tsindex 3acf0aa5..bc217c93 100644--- a/apps/web/src/components/engine/db/global-db.ts+++ b/apps/web/src/components/engine/db/global-db.ts@@ -6,8 +6,6 @@ import { openDB } from 'idb';import type * as idb from 'idb';import { nanoid } from 'nanoid';-export const DEFAULT_PROJECT_ID = 'V1StGXR8_Z5jdHi6B-myT';-const adjectives = ["Golden", "Silent", "Fast", "Bright", "Dark", "Wild", "Calm"];const nouns = ["River", "Mountain", "Dream", "Storm", "Sunset", "Forest", "Ocean"];@@ -136,7 +134,7 @@ export async function retrieveDirectoryHandle() {const PROJECT_ID_PATTERN = /^[A-Za-z0-9_-]{21}$/;export async function markProjectOpened(projectId: string): Promise<void> {- if (!PROJECT_ID_PATTERN.test(projectId) || projectId === DEFAULT_PROJECT_ID) return;+ if (!PROJECT_ID_PATTERN.test(projectId)) return;const now = new Date().toISOString();const existing = projects.get(projectId);@@ -165,7 +163,7 @@ export async function createProject(name?: string): Promise<ProjectEntry> {export async function getProjectName(projectId: string): Promise<string> {const project = projects.get(projectId);// Projects on disk are named by their folder (see @/projects).- if (!project) return projectId === DEFAULT_PROJECT_ID ? generateProjectName() : projectId;+ if (!project) return projectId;return project.name;}@@ -195,7 +193,7 @@ export async function listRecentProjects(limit = 10): Promise<ProjectEntry[]> {}export async function setProjectThumbnail(projectId: string, thumbnail: Blob): Promise<void> {- if (!PROJECT_ID_PATTERN.test(projectId) || projectId === DEFAULT_PROJECT_ID) return;+ if (!PROJECT_ID_PATTERN.test(projectId)) return;const existing = projects.get(projectId);if (!existing) return;diff --git a/apps/web/src/components/sidebar-left/project-menu/ai-credits-menu.tsx b/apps/web/src/components/sidebar-left/project-menu/ai-credits-menu.tsxindex 6315903b..46d45c73 100644--- a/apps/web/src/components/sidebar-left/project-menu/ai-credits-menu.tsx+++ b/apps/web/src/components/sidebar-left/project-menu/ai-credits-menu.tsx@@ -2,7 +2,7 @@* License, v. 2.0. If a copy of the MPL was not distributed with this* file, You can obtain one at http://mozilla.org/MPL/2.0/. */-import { useSearchParams } from "@solidjs/router";+import { useNavigate } from "@solidjs/router";import {DropdownMenuItem,DropdownMenuSeparator,@@ -22,7 +22,7 @@ function progressWidth(used: number, total: number): string {export function AiCreditsMenu() {const auth = useAuth();- const [, setParams] = useSearchParams();+ const navigate = useNavigate();const isPro = () => auth.isPro();const total = () => auth.creditLimit();@@ -41,7 +41,7 @@ export function AiCreditsMenu() {const openAiCredits = () => {(document.activeElement as HTMLElement)?.blur?.();- setParams({ dashboard: "billing" }, { replace: true });+ navigate("/?dashboard=billing");};return (diff --git a/apps/web/src/components/sidebar-left/project-menu/file-menu.tsx b/apps/web/src/components/sidebar-left/project-menu/file-menu.tsxindex 71cf1668..622055d6 100644--- a/apps/web/src/components/sidebar-left/project-menu/file-menu.tsx+++ b/apps/web/src/components/sidebar-left/project-menu/file-menu.tsx@@ -12,22 +12,22 @@ import {DropdownMenuSubTrigger,DropdownMenuGroup,} from "@/components/ui/dropdown-menu";-import { useSearchParams } from "@solidjs/router";+import { useNavigate } from "@solidjs/router";import { getAllEntities } from "bitecs";import { For, Show, createMemo } from "solid-js";import { toast } from "somoto";-import { deleteProject, duplicateProject, DEFAULT_PROJECT_ID, generateProjectName } from "@/components/engine/db";+import { deleteProject, duplicateProject, generateProjectName } from "@/components/engine/db";import { createProject, pickProjectsRoot, projectsRoot } from "@/projects";import { Not } from "bitecs";import { ChildOf, isScene, useQuery, loadAsset, changeAssetDirectory, removeAsset, getAssetFile } from "@/components/engine";-import { useProjectId } from "@/hooks/use-project-id";+import { projectRoute, useProjectId } from "@/hooks/use-project-id";import { useEngine } from "@/context/engine";import { useExport } from "@/context/export";import { getDefaultExportTemplate } from "@/components/sidebar-right/inspector/export-templates";import { showFileDialog, mimeTypeToExtension } from "@/utils";export function FileMenu() {- const [, setParams] = useSearchParams();+ const navigate = useNavigate();const projectId = useProjectId();const { world } = useEngine();@@ -35,10 +35,7 @@ export function FileMenu() {try {if (!projectsRoot() && !(await pickProjectsRoot())) return;const project = await createProject(folderName(generateProjectName()));- setParams({- project: project.name,- dashboard: undefined- }, { replace: true });+ navigate(projectRoute(project.name));} catch (e) {toast.error("Failed to create project", {description: (e as Error).message,@@ -48,15 +45,12 @@ export function FileMenu() {const handleDuplicateProject = async () => {const currentId = projectId();- if (currentId === DEFAULT_PROJECT_ID) return;+ if (!currentId) return;try {const entry = await duplicateProject(currentId);if (!entry) return;- setParams({- project: entry.id,- dashboard: undefined- }, { replace: true });+ navigate(projectRoute(entry.id));} catch {toast.error("Failed to duplicate project");}@@ -64,14 +58,11 @@ export function FileMenu() {const handleDeleteProject = async () => {const currentId = projectId();- if (currentId === DEFAULT_PROJECT_ID) return;+ if (!currentId) return;try {await deleteProject(currentId);- setParams({- project: undefined,- dashboard: "projects",- }, { replace: true });+ navigate("/?dashboard=projects");} catch {toast.error("Failed to delete project");}@@ -106,7 +97,7 @@ export function FileMenu() {New project</DropdownMenuItem><DropdownMenuItem- disabled={projectId() === DEFAULT_PROJECT_ID}+ disabled={!projectId()}onSelect={handleDuplicateProject}>Duplicate project@@ -155,7 +146,7 @@ export function FileMenu() {<DropdownMenuGroup><DropdownMenuItem- disabled={projectId() === DEFAULT_PROJECT_ID}+ disabled={!projectId()}onSelect={handleDeleteProject}>Delete projectdiff --git a/apps/web/src/components/sidebar-left/project-menu/index.tsx b/apps/web/src/components/sidebar-left/project-menu/index.tsxindex d3c32af8..7b98649d 100644--- a/apps/web/src/components/sidebar-left/project-menu/index.tsx+++ b/apps/web/src/components/sidebar-left/project-menu/index.tsx@@ -15,9 +15,9 @@ import {DropdownMenuTrigger,DropdownMenuGroup,} from "@/components/ui/dropdown-menu";-import { useSearchParams } from "@solidjs/router";+import { useNavigate } from "@solidjs/router";import { Show } from "solid-js";-import { useEditorApi } from "@/context/editor-api";+import { useEditorApi } from "@/context/dapi";import { downloadDesktopApp } from "@/lib/desktop-app";import { FileMenu } from "./file-menu";import { EditMenu } from "./edit-menu";@@ -27,17 +27,17 @@ import { AiCreditsMenu } from "./ai-credits-menu";import { HelpMenu } from "./help-menu";export function ProjectMenu() {- const [, setParams] = useSearchParams();+ const navigate = useNavigate();const { isDesktop } = useEditorApi();const handleOpenDashboard = () => {(document.activeElement as HTMLElement)?.blur?.();- setParams({ dashboard: "projects" }, { replace: true });+ navigate("/?dashboard=projects");};const handleOpenAccount = () => {(document.activeElement as HTMLElement)?.blur?.();- setParams({ dashboard: "account" }, { replace: true });+ navigate("/?dashboard=account");};return (diff --git a/apps/web/src/components/sidebar-left/sidebar-left.tsx b/apps/web/src/components/sidebar-left/sidebar-left.tsxindex 1b0d061e..c7c056d6 100644--- a/apps/web/src/components/sidebar-left/sidebar-left.tsx+++ b/apps/web/src/components/sidebar-left/sidebar-left.tsx@@ -52,7 +52,7 @@ type ProjectHeaderProps = {export function ProjectHeader(props: ProjectHeaderProps) {const projectId = useProjectId();const [projectNameDraft, setProjectNameDraft] = createSignal<string | null>(null);- const [projectName, { refetch: refetchProjectName }] = createResource(() => getProjectName(projectId()));+ const [projectName, { refetch: refetchProjectName }] = createResource(() => getProjectName(projectId() ?? "project"));const handleProjectNameInput = (event: InputEvent & { currentTarget: HTMLInputElement }) => {setProjectNameDraft(event.currentTarget.value);@@ -74,7 +74,7 @@ export function ProjectHeader(props: ProjectHeaderProps) {const currentName = projectName() ?? "";if (trimmedName.length > 0 && trimmedName !== currentName) {- await setProjectName(projectId(), trimmedName);+ if (projectId()) await setProjectName(projectId()!, trimmedName);}refetchProjectName();diff --git a/apps/web/src/context/export.tsx b/apps/web/src/context/export.tsxindex 30ee712c..f2a2ca3c 100644--- a/apps/web/src/context/export.tsx+++ b/apps/web/src/context/export.tsx@@ -42,7 +42,7 @@ export function ExportProvider(props: { children: JSX.Element }) {const format = config.format ?? "mp4";const mimeType = MIME_TYPES[format];- const name = (await getProjectName(projectId()))+ const name = (await getProjectName(projectId() ?? "project")).replace(/\s+/g, "-").toLowerCase();@@ -131,7 +131,7 @@ export function ExportProvider(props: { children: JSX.Element }) {return;}- const projectName = (await getProjectName(projectId()))+ const projectName = (await getProjectName(projectId() ?? "project")).replace(/\s+/g, "-").toLowerCase();await downloadObject(blob, `${projectName}-frame.png`);diff --git a/apps/web/src/hooks/use-project-id.ts b/apps/web/src/hooks/use-project-id.tsindex eed3634a..4f0fefdd 100644--- a/apps/web/src/hooks/use-project-id.ts+++ b/apps/web/src/hooks/use-project-id.ts@@ -3,20 +3,25 @@* file, You can obtain one at http://mozilla.org/MPL/2.0/. */import { z } from 'zod';-import { useSearchParams } from "@solidjs/router";+import { useParams } from "@solidjs/router";import { createMemo } from 'solid-js';-import { DEFAULT_PROJECT_ID } from '@/components/engine/db';// A project id is the name of a project folder under the projects root// (see @/projects), so anything goes except path segments.const PROJECT_ID = z.string().min(1).regex(/^(?!\.{1,2}$)[^/\\]+$/);+/** Route for the editor with project `name` loaded (see `/projects/*name` in app.tsx). */+export const projectRoute = (name: string): string => `/projects/${encodeURIComponent(name)}`;++/**+ * The project folder name from the `/projects/*name` route, or null when the+ * route carries no valid name. Only meaningful under that route.+ */export function useProjectId() {- const [params] = useSearchParams();+ const params = useParams<{ name?: string }>();const projectId = createMemo(() => {- const { success, data } = PROJECT_ID.safeParse(params.project);- if (!success) return DEFAULT_PROJECT_ID; // when no project is set use a default project id- return data;+ const { success, data } = PROJECT_ID.safeParse(params.name);+ return success ? data : null;});return projectId;}diff --git a/apps/web/src/pages/dashboard.tsx b/apps/web/src/pages/dashboard.tsxnew file mode 100644index 00000000..e3282271--- /dev/null+++ b/apps/web/src/pages/dashboard.tsx@@ -0,0 +1,86 @@+/* This Source Code Form is subject to the terms of the Mozilla Public+ * License, v. 2.0. If a copy of the MPL was not distributed with this+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */++import { useSearchParams } from "@solidjs/router";+import { Match, Show, Switch } from "solid-js";++import { DashboardAccountView } from "@/components/dashboard/account-view";+import { DashboardAiCreditsView } from "@/components/dashboard/ai-credits-view";+import { DashboardBillingView } from "@/components/dashboard/billing-view";+import { DashboardGetDesktopApp } from "@/components/dashboard/get-desktop-app";+import { DashboardHelpView } from "@/components/dashboard/help-view";+import { DashboardProjectsView } from "@/components/dashboard/projects-view";+import { DashboardSettingsView } from "@/components/dashboard/settings-view";+import { DashboardSidebarHeader, DashboardSidebarNav, DashboardSidebarUser, DashboardSidebarItem } from "@/components/dashboard/sidebar";+import { Separator } from "@/components/ui/separator";++import type { DashboardView } from "@/components/dashboard/types";++const DASHBOARD_VIEWS: readonly DashboardView[] = [+ "projects",+ "templates",+ "ai-credits",+ "billing",+ "account",+ "settings",+ "preferences",+ "help",+];++function parseView(value: string | string[] | undefined): DashboardView {+ const raw = Array.isArray(value) ? value[0] : value;+ return DASHBOARD_VIEWS.find((v) => v === raw) ?? "projects";+}++export function DashboardPage() {+ const [params, setParams] = useSearchParams();++ const view = (): DashboardView => parseView(params.dashboard);+ const setView = (next: DashboardView) => setParams({ dashboard: next }, { replace: true });++ return (+ <div class="flex h-screen w-full min-h-0 flex-row overflow-hidden bg-background">+ <Show when={!!window.desktop}>+ <div class="fixed top-0 left-0 right-0 h-10 z-20" style="-webkit-app-region: drag;" />+ </Show>+ <aside class="flex min-h-0 w-56 shrink-0 flex-col bg-card">+ <DashboardSidebarHeader />+ <DashboardSidebarNav>+ <DashboardSidebarItem active={view() === "projects"} onClick={() => setView("projects")} icon="diffusion-project-file" label="Projects" />+ <DashboardSidebarItem active={view() === "ai-credits"} onClick={() => setView("ai-credits")} icon="ai-generate" label="AI credits" class="mt-auto" />+ <DashboardSidebarItem active={view() === "billing"} onClick={() => setView("billing")} icon="billing" label="Billing" />+ <DashboardSidebarItem active={view() === "settings"} onClick={() => setView("settings")} icon="settings" label="Settings" />+ <DashboardSidebarItem active={view() === "help"} onClick={() => setView("help")} icon="help" label="Help" />+ </DashboardSidebarNav>+ <DashboardSidebarUser active={view() === "account"} onClick={() => setView("account")} />+ </aside>++ <Separator orientation="vertical" class="bg-border-strong" />++ <section class="flex min-h-0 flex-1 flex-col bg-canvas">+ <Switch>+ <Match when={view() === "projects"}>+ <DashboardProjectsView />+ </Match>+ <Match when={view() === "ai-credits"}>+ <DashboardAiCreditsView />+ </Match>+ <Match when={view() === "billing"}>+ <DashboardBillingView />+ </Match>+ <Match when={view() === "account"}>+ <DashboardAccountView />+ </Match>+ <Match when={view() === "settings"}>+ <DashboardSettingsView />+ </Match>+ <Match when={view() === "help"}>+ <DashboardHelpView />+ </Match>+ </Switch>+ <DashboardGetDesktopApp />+ </section>+ </div>+ );+}diff --git a/apps/web/src/pages/home.tsx b/apps/web/src/pages/project.tsxsimilarity index 76%rename from apps/web/src/pages/home.tsxrename to apps/web/src/pages/project.tsxindex 44711b8f..6b867291 100644--- a/apps/web/src/pages/home.tsx+++ b/apps/web/src/pages/project.tsx@@ -3,35 +3,31 @@* file, You can obtain one at http://mozilla.org/MPL/2.0/. */import { Show } from 'solid-js';+import { Navigate } from '@solidjs/router';import { EditorPage } from './editor';import { LayoutProvider } from "@/context/layout";-import { Dashboard } from '@/components/dashboard';import { PromptInputProvider } from "@/context/prompt-input";import { EngineProvider } from '@/context/engine';import { EditorApiProvider } from '@/context/dapi';import { ExportProvider } from '@/context/export';import { useProjectId } from '@/hooks/use-project-id';-import { useSearchParams } from '@solidjs/router';import { ECSProvider } from '@/context/ecs';import { TimelineProvider } from '@/context/timeline';import { EngineProvider as KootaEngineProvider } from '@/engine';import { ProjectLoader } from '@/projects';-import { DEFAULT_PROJECT_ID } from '@/components/engine/db';-export function HomePage() {+/** `/projects/:name` — the editor, with the project folder `name` loaded. */+export function ProjectPage() {const projectId = useProjectId();- const [params] = useSearchParams();return (/*** using show with keyed to ensure the engine provider is remounted when the project id changes*/- <Show when={projectId()} keyed>+ <Show when={projectId()} keyed fallback={<Navigate href="/" />}>{(id) => (<KootaEngineProvider projectId={id}>- <Show when={id !== DEFAULT_PROJECT_ID}>- <ProjectLoader name={id} />- </Show>+ <ProjectLoader name={id} /><EngineProvider projectId={id}><EditorApiProvider><TimelineProvider>@@ -42,9 +38,6 @@ export function HomePage() {<EditorPage /></LayoutProvider></PromptInputProvider>- <Show when={!params.project || !!params.dashboard}>- <Dashboard />- </Show></ExportProvider></ECSProvider></TimelineProvider>diff --git a/packages/runtime/MIGRATION.md b/packages/runtime/MIGRATION.mdindex 9ebb606f..1f9d7c56 100644--- a/packages/runtime/MIGRATION.md+++ b/packages/runtime/MIGRATION.md@@ -108,7 +108,7 @@ apps/web now depends on `@diffusionstudio/runtime` and `@diffusionstudio/koota-s- **Engine shell** (`apps/web/src/engine/`, not in this package — it's browser/DOM-coupled, which this package deliberately isn't): `Engine` (`create-engine.ts`) is a class wrapping `createRuntimeWorld` + `runSystems`; it owns canvas mount/resize/DPR, an AudioContext (created or injected, closed on `dispose()` only if it created it), and its own `requestAnimationFrame` loop (`start`/`stop`, plus a public `step(timestamp)` escape hatch for a future host to drive the tick itself and interleave app-side input/HUD systems around it). `context.tsx` (`EngineProvider`/`useEngineContext`) composes koota-solid's `WorldProvider` around `engine.world`, so trait state is read via `useTrait`/`useQuery` directly against the world, not funneled through a context bag. `canvas.tsx` (`EngineCanvas`) is the reusable mount/resize/start component. `hooks/` has a few illustrative per-trait wrappers so far: `useCamera`, `useActiveScene`, `useRunning`.- **Wired into the live app**: `KootaEngineProvider` (the new `EngineProvider`, aliased) is mounted in `pages/home.tsx` at the same level and lifetime as the old bitecs `EngineProvider` (both keyed on `projectId`), so anything under `EditorPage` can reach the koota world as more gets migrated. In `components/canvas/canvas.tsx`, the koota `EngineCanvas` now occupies the visible `z-1` canvas slot. The old bitecs `<canvas id="engine-canvas">` stays mounted at the same DOM id (so its `EngineProvider`'s `init()` still finds it and keeps initializing, and everything still on `useEngine()`/`useECS()` — Toolbar, drag/drop, sidebars, timeline — keeps working) but is `opacity-0 pointer-events-none`: no longer visible or interactive. Drag/drop handlers moved from the canvas element to its wrapping div so `pointer-events-none` didn't silently kill them.-- **Projects on disk (desktop only)**: `apps/web/src/projects/` loads real content into the koota world. A project is a folder under a user-picked root (persisted in `dspro.ui.projects.root`) holding an `index.tsx` whose default export renders `<stage>`; the electron main process (`apps/desktop/src/projects.ts`) scans the root, scaffolds new folders (`index.tsx`, `package.json`, `tsconfig.json`, generated `jsx.d.ts`), bundles with esbuild + babel-preset-solid (universal, moduleName `@diffusionstudio/jsx`) and watches for changes. The new `@diffusionstudio/reconciler` package (`packages/reconciler`, modeled on ds-next's `src/reconciler/`) evaluates the CJS bundle against the app's solid-js and `@diffusionstudio/jsx`, and its `RuntimeDocument` implements `ProjectDocument` over the world (`mount(code, world)` wraps both): `<stage>` = Scene entity (x/y/width/height), `<rect>` = RECT entity (x/y/width/height/fill as a solid Paint child). Host nodes wrap entities in objects because Solid's universal renderer treats numbers as text. `ProjectLoader` (mounted in `pages/home.tsx`) compiles → renders → refits the camera once → re-renders on disk changes; the project id in `?project=` is the folder name. Only those two tags/five props so far; no write-back from canvas edits to source yet.+- **Projects on disk (desktop only)**: `apps/web/src/projects/` loads real content into the koota world. A project is a folder under a user-picked root (persisted in `dspro.ui.projects.root`) holding an `index.tsx` whose default export renders `<stage>`; the electron main process (`apps/desktop/src/projects.ts`) scans the root, scaffolds new folders (`index.tsx`, `package.json`, `tsconfig.json`, generated `jsx.d.ts`), bundles with esbuild + babel-preset-solid (universal, moduleName `@diffusionstudio/jsx`) and watches for changes. The new `@diffusionstudio/reconciler` package (`packages/reconciler`, modeled on ds-next's `src/reconciler/`) evaluates the CJS bundle against the app's solid-js and `@diffusionstudio/jsx`, and its `RuntimeDocument` implements `ProjectDocument` over the world (`mount(code, world)` wraps both): `<stage>` = Scene entity (x/y/width/height), `<rect>` = RECT entity (x/y/width/height/fill as a solid Paint child). Host nodes wrap entities in objects because Solid's universal renderer treats numbers as text. `ProjectLoader` (mounted in `pages/project.tsx`) compiles → renders → refits the camera once → re-renders on disk changes. Routes: `/` is the full-screen dashboard (`pages/home.tsx`, no longer a dialog), `/projects/*name` is the editor with the project folder `name` loaded (`useProjectId()` reads it from the route); the old default project id is gone, so there is no editor without a project. Only those two tags/five props so far; no write-back from canvas edits to source yet.## Remaining work (suggested order)