Skip to content

The VS Code of video editing, built for agents.

TypeScript

Refactor project creation and dashboard interaction logic

konstantin-paulus8691f3739954
diff --git a/apps/web/src/components/dashboard/shared.tsx b/apps/web/src/components/dashboard/shared.tsx
index 88d5f0b4..b355ca56 100644
--- a/apps/web/src/components/dashboard/shared.tsx
+++ b/apps/web/src/components/dashboard/shared.tsx
@@ -559,7 +559,7 @@ export function createBackgroundClickHandler(onCLick: () => void): JSX.EventHand
* it on the list. Null — with the reason already shown — when there is no
* desktop to create it on, and when the user is asked where to put it and
* declines to say. The one flow behind every "new project": the card on each
- * view, and the dashboard's keyboard shortcut.
+ * view.
*/
export async function createNewProject(): Promise<ProjectInfo | null> {
if (!isDesktop()) {
diff --git a/apps/web/src/engine/editor.ts b/apps/web/src/engine/editor.ts
index b6960968..17316791 100644
--- a/apps/web/src/engine/editor.ts
+++ b/apps/web/src/engine/editor.ts
@@ -17,6 +17,7 @@ import { createRoot } from 'solid-js';
import { authoredElement, authoredTree, getRuntimeDocument, insert, isSceneNode, renderAuthored, withDocument } from '@diffusionstudio/reconciler';
import { findInspectEntry } from './inspect';
+import { AssetSelection } from './traits';
import type { SceneNode } from '@diffusionstudio/runtime';
import type { AssetRef, InspectValue, PropValue, SerializedAssetRef } from '@diffusionstudio/jsx';
@@ -399,6 +400,10 @@ export class DocumentEditor {
public select(entities: Entity | Entity[], options: { extend?: boolean } = {}): void {
const next = new Set(Array.isArray(entities) ? entities : [entities]);
+ if (this.world.has(AssetSelection) && this.world.get(AssetSelection)?.id !== null) {
+ this.world.set(AssetSelection, { id: null });
+ }
+
if (!options.extend) {
for (const entity of [...this.world.query(Selected)]) {
if (!next.has(entity)) this.setSelected(entity, false);
diff --git a/apps/web/src/engine/input/interactions.ts b/apps/web/src/engine/input/interactions.ts
index 4cb4ccb0..252d234f 100644
--- a/apps/web/src/engine/input/interactions.ts
+++ b/apps/web/src/engine/input/interactions.ts
@@ -32,7 +32,7 @@ import { Not, Or } from 'koota';
import { getDocumentEditor } from '../editor';
import { syncKeyframe } from '../keyframes';
-import { AssetSelection, Hud, Keys, Pointer, SnapLines } from '../traits';
+import { Hud, Keys, Pointer, SnapLines } from '../traits';
import { getToolCursor, updateCursor, type CursorType } from './cursor';
import { mountNameInput } from '../hud/name-input';
import {
@@ -237,7 +237,6 @@ export function handleCanvasInteraction(world: World, event: DispatchedPointerEv
if (Math.hypot(dx, dy) < CLICK_DISTANCE * resolution(world)) {
editor.clearSelection();
- world.set(AssetSelection, { id: null });
syncInteractiveState(world);
clearHovering(world);
}
diff --git a/apps/web/src/pages/dashboard.tsx b/apps/web/src/pages/dashboard.tsx
index 3bc6f20b..5a84c957 100644
--- a/apps/web/src/pages/dashboard.tsx
+++ b/apps/web/src/pages/dashboard.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 { useNavigate, useSearchParams } from "@solidjs/router";
+import { useSearchParams } from "@solidjs/router";
import { Match, Show, Switch, createEffect, createSignal, onCleanup, onMount } from "solid-js";
import { toast } from "somoto";
@@ -15,7 +15,6 @@ import { DashboardHomeView } from "@/components/dashboard/home-view";
import { DashboardMcpView } from "@/components/dashboard/mcp-view";
import { DashboardProjectsView } from "@/components/dashboard/projects-view";
import { DashboardSettingsView } from "@/components/dashboard/settings-view";
-import { createNewProject } from "@/components/dashboard/shared";
import {
DashboardSidebarConnectCard,
DashboardSidebarHeader,
@@ -27,10 +26,8 @@ import {
} from "@/components/dashboard/sidebar";
import { Separator } from "@/components/ui/separator";
import { useFullscreenState } from "@/hooks/use-fullscreen-state";
-import { projectRoute } from "@/hooks/use-project-route";
-import { track } from "@/lib/analytics";
import { connectedAgents, fetchMcpStatus } from "@/lib/mcp";
-import { isDesktop, projectKey } from "@/projects";
+import { isDesktop, openProjectFolder, pickProjectFolder } from "@/projects";
import { isInputTarget } from "@/utils";
import type { DashboardView } from "@/components/dashboard/types";
@@ -68,28 +65,27 @@ function isSettingsView(view: DashboardView): boolean {
}
export function DashboardPage() {
- const navigate = useNavigate();
const [params, setParams] = useSearchParams();
const isFullscreen = useFullscreenState();
- let creating = false;
+ // ⌘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 (creating) return;
- creating = true;
+ if (picking || !isDesktop()) return;
+ picking = true;
try {
- const project = await createNewProject();
- if (!project) return;
- track("project_opened");
- navigate(projectRoute(projectKey(project)));
+ const dir = await pickProjectFolder();
+ if (!dir) return;
+ await openProjectFolder(dir);
} catch (e) {
- toast.error("Failed to create project", { description: (e as Error).message });
+ toast.error("Failed to add project", { description: (e as Error).message });
} finally {
- creating = false;
+ picking = false;
}
};