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
1 change: 1 addition & 0 deletions docs/guides/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ The first launch creates an untitled canvas. Later launches can restore the most
- Click the project name at the top left to rename it. Press `Enter` or click elsewhere to save, or press `Esc` to cancel.
- Click the arrow next to the name to switch projects. Choose **New canvas project** to create one.
- On an empty canvas, click **Configure models** to open **Settings → Model connections**.
- Click **Try image example** or **Try video example** on an empty canvas to import a hosted sample: it downloads with a progress bar, imports as a new project and opens it. A download that is a ZIP around a single `.canvas` file is unwrapped automatically, and a page returned instead of a file is reported rather than imported. The project menu's **Example canvases** row opens the full list, with sizes and a manual-import link for a sample that cannot be downloaded.
- Use the left toolbar or double-click empty canvas space to create text, image, video, audio, timeline, or subject nodes.
- Right-click empty canvas space to create a node, paste, undo, or redo.
- Click **Upload** on the left or drag files onto the canvas to add assets. Use **Asset library** to choose existing assets.
Expand Down
1 change: 1 addition & 0 deletions docs/guides/user-guide.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ vLLM-Omni 视频连接支持直接输入小数秒,例如 `6.583333`。CLI 可
- 点击左上角项目名称修改名称,按 `Enter` 或点击其他位置保存,按 `Esc` 取消。
- 点击名称右侧的箭头切换项目,选择“新建画布项目”创建项目。
- 在空白画布点击“配置模型”,可直接打开“设置 → 模型接入”。
- 在空白画布点击“体验图片示例”或“体验视频示例”可直接导入官方托管示例:下载时显示进度条,完成后导入为新工程并打开。若下载到的是包裹单个 `.canvas` 的 ZIP,会自动解开;若返回的是网页而不是文件,会明确提示而不会导入。项目菜单中的“示例画布”可打开完整列表,含大小信息,以及无法下载时的手动导入链接。
- 通过左侧工具栏或双击空白画布创建文本、图片、视频、音频、时间线或主体节点。
- 右键空白画布可新建节点、粘贴、撤销或重做。
- 点击左侧“上传”或将文件拖入画布添加素材;“资产库”可选择已有素材。
Expand Down
9 changes: 3 additions & 6 deletions scripts/i18n-baseline.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
{
"total": 168,
"total": 165,
"counts": {
"src/canvas/assets.ts": 14,
"src/canvas/workspace/useWorkspaceTransfer.ts": 1,
"src/canvas/dataBoundary.ts": 3,
"src/canvas/generationCatalog.ts": 16,
"src/canvas/generationSettings.ts": 4,
"src/canvas/library/AssetsPanel.tsx": 1,
"src/canvas/library/libraryClient.ts": 1,
"src/canvas/library/SubjectsPanel.tsx": 1,
"src/canvas/library/TrashPanel.tsx": 1,
"src/canvas/model.ts": 1,
"src/canvas/NodeComposer.tsx": 1,
"src/canvas/referenceMentions.ts": 1,
"src/canvas/toolCatalog.ts": 123
"src/canvas/toolCatalog.ts": 123,
"src/canvas/workspace/useWorkspaceTransfer.ts": 1
}
}
4 changes: 4 additions & 0 deletions scripts/run-browser-suite.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import { spawnSync } from "node:child_process";

const workflows = [
{ name: "timeline node output", script: "tests/browser/timeline_node_output.mjs" },
{
name: "example canvas picker",
script: "tests/browser/example_canvas_picker.mjs",
},
{ name: "locale", script: "tests/browser/locale.mjs" },
{ name: "creation closure", script: "scripts/verify_creation_browser.mjs" },
{ name: "assistant activity", script: "tests/browser/assistant_activity.mjs" },
Expand Down
17 changes: 17 additions & 0 deletions src/canvas/ProjectSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export function ProjectSelector({
disabled,
onSelect,
onCreate,
onExamples,
onRename,
onRenameProject,
onDeleteProject,
Expand All @@ -31,6 +32,8 @@ export function ProjectSelector({
disabled: boolean;
onSelect: (project: WorkspaceProject) => Promise<boolean>;
onCreate: () => void;
/** Opens the example canvas picker; omitted where it is not offered. */
onExamples?: () => void;
onRename: (name: string) => Promise<void>;
onRenameProject: (project: WorkspaceProject, name: string) => Promise<void>;
onDeleteProject: (project: WorkspaceProject) => Promise<void>;
Expand Down Expand Up @@ -462,6 +465,20 @@ export function ProjectSelector({
<CanvasIcon name="trash" size={18} />
</button>
)}
{onExamples && (
<button
className="cw-project-examples"
role="menuitem"
disabled={busy || loading || disabled}
onClick={() => {
setOpen(false);
onExamples();
}}
>
<span>{t("canvas.project.examples")}</span>
<CanvasIcon name="clapperboard" size={18} />
</button>
)}
<button
className="cw-project-create"
role="menuitem"
Expand Down
26 changes: 26 additions & 0 deletions src/canvas/workspace.css
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@
flex-shrink: 0;
}
.cw-project-create,
.cw-project-examples,
.cw-project-cleanup {
display: flex;
align-items: center;
Expand All @@ -623,6 +624,7 @@
text-align: left;
}
.cw-project-create:hover,
.cw-project-examples:hover,
.cw-project-cleanup:hover {
color: #fff;
}
Expand Down Expand Up @@ -1222,6 +1224,30 @@
padding: 10px 16px;
font-size: 12px;
}

.cw-empty-example-status {
gap: 8px;
margin: 16px auto 0;
max-width: 320px;
font-size: 12px;
color: #9599a8;
}

.cw-empty-example-status .cw-example-progress {
flex: 1;
min-width: 120px;
}

/* Specificity beats the shared .cw-empty small tagline rule. */
.cw-empty small.cw-empty-example-error {
display: block;
margin: 12px auto 0;
max-width: 420px;
color: #e08a8a;
font-size: 12px;
line-height: 1.6;
}

.cw-empty button:hover {
background: #2a2a2d;
}
Expand Down
126 changes: 112 additions & 14 deletions src/canvas/workspace/WorkspaceView.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Background, BackgroundVariant, MiniMap, SelectionMode, ViewportPortal } from "@xyflow/react";

import "@xyflow/react/dist/style.css";
import { Suspense, useEffect, type CSSProperties } from "react";
import { Suspense, useEffect, useRef, useState, type CSSProperties } from "react";
import { createNode } from "../model.ts";
import { NodeVersionHistory } from "../NodeVersionHistory";

Expand All @@ -17,8 +17,18 @@ import { TimelinePackageImport, exportTimelinePackage as exportNativeTimelinePac
import { readLocalResource } from "../timelineExport.ts";
import { timelinePublication } from "../../backend/timelinePublication";
import { acknowledgeToolPlacement, cancelToolTask } from "../../backend/tools.ts";
import { createWorkspaceProject, listWorkspaceProjects, openExampleWorkspaceProject, openWorkspaceProject, saveWorkspaceDocument, workspaceProjection } from "../../backend/workspace";
import { exampleDocument, exampleProjectTitle, studyImage } from "../assets";
import { createWorkspaceProject, listWorkspaceProjects, openWorkspaceProject, saveWorkspaceDocument, workspaceProjection } from "../../backend/workspace";
import { studyImage } from "../assets";
import { ExampleCanvasDialog } from "./example/ExampleCanvasDialog.tsx";
import {
IMAGE_EXAMPLE_ID,
VIDEO_EXAMPLE_ID,
availableExamples,
loadExampleCatalog,
type ExampleEntry,
} from "./example/exampleCatalog.ts";
import { exampleFailureText, examplePercent } from "./example/exampleFailure.ts";
import { useExampleImport } from "./example/useExampleImport.ts";

import { AssistantPanel } from "../AssistantPanel";
import { CanvasActionsContext } from "../CanvasActionsContext";
Expand Down Expand Up @@ -167,6 +177,7 @@ export function WorkspaceView({ rt }: { rt: WorkspaceRuntime }) {
historyReplaying,
importActionResultFiles,
importActionResults,
importCanvasArchive,
importCanvasSource,
importDocument,
importFiles,
Expand Down Expand Up @@ -301,6 +312,51 @@ export function WorkspaceView({ rt }: { rt: WorkspaceRuntime }) {
} = rt;


/**
* Example canvases: one cached catalog feeds both the empty-state buttons and
* the picker in the project menu.
*/
const [exampleEntries, setExampleEntries] = useState<ExampleEntry[] | null>(null);
const [exampleLoading, setExampleLoading] = useState(false);
const exampleCatalog = useRef<Promise<ExampleEntry[]> | null>(null);
const loadExamples = () =>
(exampleCatalog.current ??= loadExampleCatalog().then((result) =>
availableExamples(result.catalog),
));
const openExamplePicker = async () => {
if (exampleLoading) return;
setExampleLoading(true);
try {
setExampleEntries(await loadExamples());
} finally {
setExampleLoading(false);
}
};
const exampleImport = useExampleImport({ importCanvas: importCanvasArchive });
const [exampleMissing, setExampleMissing] = useState(false);
const runExampleButton = async (id: string) => {
setExampleMissing(false);
exampleImport.reset(IMAGE_EXAMPLE_ID);
exampleImport.reset(VIDEO_EXAMPLE_ID);
const entry = (await loadExamples()).find((item) => item.id === id);
if (!entry) {
setExampleMissing(true);
return;
}
// A finished import switches the document, so the bar disappears with it.
if (await exampleImport.start(entry)) exampleImport.reset(entry.id);
};
const exampleButtonStatus =
exampleImport.statuses[IMAGE_EXAMPLE_ID] ??
exampleImport.statuses[VIDEO_EXAMPLE_ID];
const exampleBusy =
exampleButtonStatus?.phase === "downloading" ||
exampleButtonStatus?.phase === "importing";
const exampleProgress = exampleButtonStatus
? examplePercent(exampleButtonStatus)
: null;


const outputState = timelineOutput.state;
const outputSource = outputState ? doc.nodes.find((node) => node.id === outputState.itemId) : undefined;
const existingOutput = outputState ? projected.nodes.find((node: { id: string }) => node.id === outputState.output.id) : undefined;
Expand Down Expand Up @@ -845,6 +901,7 @@ export function WorkspaceView({ rt }: { rt: WorkspaceRuntime }) {
return document;
}).then(success => { if (success) setEditProjectNameId(id); });
}}
onExamples={() => void openExamplePicker()}
onRename={renameCurrentProject}
onRenameProject={renameProject}
onDeleteProject={deleteProject}
Expand Down Expand Up @@ -1009,20 +1066,54 @@ export function WorkspaceView({ rt }: { rt: WorkspaceRuntime }) {
{t("canvas.workspace.empty.configureModels")}
</button>
<button
onClick={() => {
void switchDocument(
() =>
openExampleWorkspaceProject(
exampleProjectTitle(locale),
() => exampleDocument(locale),
),
true,
);
}}
disabled={exampleBusy}
onClick={() => void runExampleButton(IMAGE_EXAMPLE_ID)}
>
<CanvasIcon name="image" size={15} />
{t("canvas.workspace.empty.tryImage")}
</button>
<button
disabled={exampleBusy}
onClick={() => void runExampleButton(VIDEO_EXAMPLE_ID)}
>
{t("canvas.workspace.empty.example")} <span>↗</span>
<CanvasIcon name="video" size={15} />
{t("canvas.workspace.empty.tryVideo")}
</button>
</div>
{exampleBusy && exampleButtonStatus && (
<div
className="cw-empty-example-status"
role="status"
aria-live="polite"
>
<progress
className="cw-example-progress"
aria-label={t("canvas.example.progress.label")}
{...(exampleProgress === null
? {}
: {
value: exampleButtonStatus.received ?? 0,
max: exampleButtonStatus.total ?? 1,
})}
/>
<span>
{exampleButtonStatus.phase === "importing"
? t("canvas.example.state.importing")
: exampleProgress === null
? t("canvas.example.state.downloading")
: t("canvas.example.state.downloadingPercent", {
percent: exampleProgress,
})}
</span>
</div>
)}
{(exampleMissing || exampleButtonStatus?.phase === "failed") && (
<small className="cw-empty-example-error" role="alert">
{exampleMissing
? t("canvas.example.error.unknown")
: exampleFailureText(t, exampleButtonStatus!)}
</small>
)}
<small>{t("canvas.workspace.empty.tagline")}</small>
</div>
)}
Expand Down Expand Up @@ -2728,6 +2819,13 @@ export function WorkspaceView({ rt }: { rt: WorkspaceRuntime }) {
onClose={() => { dismissModelSetup(); setSettingsOpen(false); }}
/>
)}
{exampleEntries && (
<ExampleCanvasDialog
entries={exampleEntries}
onClose={() => setExampleEntries(null)}
onImport={(archive) => importCanvasArchive(archive)}
/>
)}
{help && (
<div className="cw-modal-backdrop" onClick={() => setHelp(false)}>
<section
Expand Down
Loading
Loading