The VS Code of video editing, built for agents.
TypeScript
feat: update project folder handling and improve UI elements
konstantin-paulusa5717bfb6650
diff --git a/apps/web/src/assets/icons/view-grid.svg b/apps/web/src/assets/icons/view-grid.svgindex f408529f..494c29af 100644--- a/apps/web/src/assets/icons/view-grid.svg+++ b/apps/web/src/assets/icons/view-grid.svg@@ -1,3 +1,6 @@<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">-<path d="M11.1025 13.0049C11.6067 13.0562 12 13.4823 12 14V17.5L11.9951 17.6025C11.9472 18.073 11.573 18.4472 11.1025 18.4951L11 18.5H7.5C6.9823 18.5 6.5562 18.1067 6.5049 17.6025L6.5 17.5V14C6.5 13.4477 6.9477 13 7.5 13H11L11.1025 13.0049ZM17.6025 13.0049C18.1067 13.0562 18.5 13.4823 18.5 14V17.5L18.4951 17.6025C18.4472 18.073 18.073 18.4472 17.6025 18.4951L17.5 18.5H14C13.4823 18.5 13.0562 18.1067 13.0049 17.6025L13 17.5V14C13 13.4477 13.4477 13 14 13H17.5L17.6025 13.0049ZM14 17.5H17.5V14H14V17.5ZM7.5 17.5H11V14H7.5V17.5ZM11.1025 6.5049C11.6067 6.5562 12 6.9823 12 7.5V11L11.9951 11.1025C11.9472 11.573 11.573 11.9472 11.1025 11.9951L11 12H7.5C6.9823 12 6.5562 11.6067 6.5049 11.1025L6.5 11V7.5C6.5 6.9477 6.9477 6.5 7.5 6.5H11L11.1025 6.5049ZM17.6025 6.5049C18.1067 6.5562 18.5 6.9823 18.5 7.5V11L18.4951 11.1025C18.4472 11.573 18.073 11.9472 17.6025 11.9951L17.5 12H14C13.4823 12 13.0562 11.6067 13.0049 11.1025L13 11V7.5C13 6.9477 13.4477 6.5 14 6.5H17.5L17.6025 6.5049ZM7.5 11H11V7.5H7.5V11ZM14 11H17.5V7.5H14V11Z" fill="currentColor"/>+<rect x="6.5" y="6.5" width="5" height="5" rx="1" stroke="currentColor"/>+<rect x="13.5" y="6.5" width="5" height="5" rx="1" stroke="currentColor"/>+<rect x="6.5" y="13.5" width="5" height="5" rx="1" stroke="currentColor"/>+<rect x="13.5" y="13.5" width="5" height="5" rx="1" stroke="currentColor"/></svg>diff --git a/apps/web/src/components/dashboard/collections-nav.tsx b/apps/web/src/components/dashboard/collections-nav.tsxindex d2259516..65a52fa9 100644--- a/apps/web/src/components/dashboard/collections-nav.tsx+++ b/apps/web/src/components/dashboard/collections-nav.tsx@@ -66,7 +66,7 @@ export function DashboardSidebarCollections(props: DashboardSidebarCollectionsPr><SidebarNameFieldicon="navigation.folder"- value=""+ value="Untitled Folder"placeholder="Folder name"onCommit={handleAdd}onCancel={() => setAdding(false)}diff --git a/apps/web/src/components/dashboard/projects-view.tsx b/apps/web/src/components/dashboard/projects-view.tsxindex d67bffbe..c55e72cc 100644--- a/apps/web/src/components/dashboard/projects-view.tsx+++ b/apps/web/src/components/dashboard/projects-view.tsx@@ -3,9 +3,10 @@* file, You can obtain one at http://mozilla.org/MPL/2.0/. */import { toast } from "somoto";-import { For, createMemo, createSignal } from "solid-js";+import { For, Show, createMemo, createSignal } from "solid-js";import { useNavigate } from "@solidjs/router";+import { Button } from "@/components/ui/button";import {Select,SelectContent,@@ -31,7 +32,7 @@ import { DashboardSearchPanel } from "./search-bar";import { projectRoute, useReturnHere } from "@/hooks/use-project-route";import { Icon } from "../ui/icon";import { track } from "@/lib/analytics";-import { projectKey, type ProjectInfo } from "@/projects";+import { isDesktop, openProjectFolder, pickProjectFolder, projectKey, type ProjectInfo } from "@/projects";import type { ProjectScope, ProjectSortOption } from "./types";@@ -56,6 +57,7 @@ export function DashboardProjectsView(props: DashboardProjectsViewProps) {const [sort, setSort] = createSignal<ProjectSortOption>("last-viewed");const [projects, { refetch: refetchProjects }] = createProjectList();const [creating, setCreating] = createSignal(false);+ const [picking, setPicking] = createSignal(false);const [pendingDelete, setPendingDelete] = createSignal<ProjectInfo[]>([]);const [grid, setGrid] = createSignal<HTMLDivElement>();@@ -135,6 +137,21 @@ export function DashboardProjectsView(props: DashboardProjectsViewProps) {}};+ const handleOpenFolder = async () => {+ if (picking()) return;+ setPicking(true);++ try {+ const dir = await pickProjectFolder();+ if (!dir) return;+ await openProjectFolder(dir, scopeCollectionId(props.scope));+ } catch (e) {+ toast.error("Failed to open project", { description: (e as Error).message });+ } finally {+ setPicking(false);+ }+ };+return (<DashboardSearchPanelvalue={search}@@ -147,7 +164,12 @@ export function DashboardProjectsView(props: DashboardProjectsViewProps) {onBackgroundClick={selection.clear}gridRef={setGrid}controls={- <>+ <div class="flex items-center gap-2">+ <Show when={isDesktop() && props.scope.kind !== "drafts"}>+ <Button variant="secondary" disabled={picking()} onClick={handleOpenFolder}>+ Open project...+ </Button>+ </Show><Select<(typeof SORT_OPTIONS)[number]>options={SORT_OPTIONS}value={selectedSortOption()}@@ -169,7 +191,7 @@ export function DashboardProjectsView(props: DashboardProjectsViewProps) {<SelectContent /></SelectPortal></Select>- </>+ </div>}><DashboardCardButton onClick={handleCreateProject}>diff --git a/apps/web/src/pages/dashboard.tsx b/apps/web/src/pages/dashboard.tsxindex c291b890..294bf0c1 100644--- a/apps/web/src/pages/dashboard.tsx+++ b/apps/web/src/pages/dashboard.tsx@@ -3,8 +3,7 @@* file, You can obtain one at http://mozilla.org/MPL/2.0/. */import { useSearchParams } from "@solidjs/router";-import { Match, Show, Switch, createEffect, createMemo, createResource, createSignal, onCleanup, onMount } from "solid-js";-import { toast } from "somoto";+import { Match, Show, Switch, createEffect, createMemo, createResource, createSignal, onMount } from "solid-js";import { DashboardAccountView } from "@/components/dashboard/account-view";import { DashboardAiCreditsView } from "@/components/dashboard/ai-credits-view";@@ -33,12 +32,9 @@ import {isDesktop,isWindowsDesktop,listCollections,- openProjectFolder,- pickProjectFolder,projectsRevision,type CollectionRecord,} from "@/projects";-import { isInputTarget } from "@/utils";import type { DashboardView, ProjectScope } from "@/components/dashboard/types";@@ -79,32 +75,6 @@ export function DashboardPage() {const [params, setParams] = useSearchParams();const isFullscreen = useFullscreenState();- // ⌘I: the native folder picker, and the chosen folder on the recents list.- let picking = false;- const handleShortcut = async (event: KeyboardEvent) => {- if (!(event.metaKey || event.ctrlKey) || event.shiftKey || event.altKey) return;- if (event.key.toLowerCase() !== "i" || isInputTarget(event)) return;-- event.preventDefault();- if (picking || !isDesktop()) return;- picking = true;-- try {- const dir = await pickProjectFolder();- if (!dir) return;- await openProjectFolder(dir);- } catch (e) {- toast.error("Failed to add project", { description: (e as Error).message });- } finally {- picking = false;- }- };-- onMount(() => {- window.addEventListener("keydown", handleShortcut);- onCleanup(() => window.removeEventListener("keydown", handleShortcut));- });-const view = (): DashboardView => parseView(params.dashboard);const setView = (next: DashboardView) => setParams({ dashboard: next, collection: undefined }, { replace: true });diff --git a/apps/web/src/projects/host.ts b/apps/web/src/projects/host.tsindex 3854c4d9..263b636e 100644--- a/apps/web/src/projects/host.ts+++ b/apps/web/src/projects/host.ts@@ -238,14 +238,15 @@ export async function resolveProject(ref: string): Promise<ProjectInfo | null> {* Opens the folder `dir` as a project, making it one first when it is not:* the folder is created if missing and, when nothing in it can be an entry,* given an `index.tsx` holding an empty stage — and nothing else. Put on the- * list, so it stays reachable by name or id across relaunches. How+ * list, so it stays reachable by name or id across relaunches, filed in+ * `collectionId` when it is new to the list and one is given. How* `diffusion open <path>` lands anywhere on disk.*/-export async function openProjectFolder(dir: string): Promise<ProjectInfo> {+export async function openProjectFolder(dir: string, collectionId?: string): Promise<ProjectInfo> {if (!isDesktop()) throw new Error('Opening a project folder requires the desktop app.');const project = await mainBridge.call(MAIN_CHANNELS.PROJECTS_INIT, { dir });- await remember(project);+ await remember(project, collectionId);return project;}