Skip to content

The open-source full-stack studio for Opus 5.5 motion video. Reverse engineering for any video. Code video with HTML: recreate, edit and render. BYOA + BYOK · Motion.md · Images, Video, Music & Voice.

fix(studio): reuse OD fallback for catalog previews

罗高0eb5c3e687d3
diff --git a/docs/product/architecture.md b/docs/product/architecture.md
index 44a6d2a8..6c3ad593 100644
--- a/docs/product/architecture.md
+++ b/docs/product/architecture.md
@@ -21,7 +21,7 @@ Model Gateway remains a shared media-generation backend for MCP, using local Cod
- An empty, loaded root composition shows a centered import/drop prompt over the mounted preview and hides transport controls, including the placeholder duration. The empty state requires both no timeline clips and no authored preview content; loading, failed previews and nested compositions retain their existing states. Import uses the existing timeline gateway and file-drop pipeline. The empty timeline retains its drop target and ruler, with a muted dashed track sketch instead of a duplicate import prompt or button. Empty timelines disable zoom controls. A confirmed empty composition blocks new exports at both the settings button and the shared editor render-start handler, while existing export history remains available. Properties distinguish no content from no selection; small panel empty states share muted text and icon sizing. Preview zoom percentage and Fit sit in the MVP preview header, outside the picture. Clicking the percentage opens 50%, 75%, 100%, 150% and 200% presets in a compact opaque menu. The MVP hides the corner position navigator; existing zoom gestures and Fit remain available. Browser fullscreen is unavailable in the MVP, including its playback button and keyboard entry; workspace preview expansion remains available. Playback controls respond to their own container width: secondary-button gaps narrow below 420px, and speed/loop controls hide below 420px so timecode, play/pause and volume remain on one row. Preview and track volume use upward floating vertical sliders, opened by hover or keyboard focus; clicking the speaker still toggles mute. Editor controls share one neutral hover background for both ordinary and selected states, including visible keyboard focus and highlighted menu items. Primary Export actions retain their dark action hover surface. Disabled controls share one foreground token without per-control opacity, and never gain hover feedback. Official catalog/template surfaces and timeline clip bodies retain their existing presentation. The enabled play/pause icon uses the same action-color token as the header Export background, including hover.
- The composition list places the full video first, preserves the remaining clip order, and marks the live preview target. Queued, loading, missing and failed covers share a muted gray OD placeholder without failure text; decoded covers replace it automatically. A confirmed empty root is omitted from this list using the same loaded-preview content check; when no clips remain, the panel shows a brief empty state. The MVP omits the duplicate preview breadcrumb; composition switching and existing return shortcuts remain available.
- The editor header keeps the OpenDesign logo, drawer toggle and template library on the left (the English entry is Template; Chinese remains 模板库), centers the editable project name, and places undo/redo and export on the right. Clearing the title and committing with blur or Enter saves the localized Untitled default; Escape cancels. A logo-only community link sits immediately before Export and opens the public Discord community in every interface language, with a localized accessible tooltip; external links open separately from the editor. Undo, redo and version history form one visual group with 4px internal gaps; the history group and community retain a 16px button gap. The community-to-Export button gap is 12px (18px from the 16px community icon to the Export edge), shifting only community and the three history icons right by 4px while Export and the other header content stay fixed. A decorative 1px by 16px divider in the shared border color sits between history and community without moving the buttons; it hides with the history group on narrow screens. Transient save/error status remains available. Workspace and export failures show concise causes and available next steps, with raw diagnostics behind expandable, copyable details. Workspace connection failures use a persistent single-line feedback toast at the top center with a Reconnecting status and no buttons or diagnostic details. The Reconnecting ellipsis animates without changing the toast width; reduced-motion preferences keep it static. Automatic polling waits 1.8 seconds after each completed attempt and removes the toast on recovery; it has no overall retry limit or explicit per-request timeout and does not start a stopped service. Other notice dismissal does not bypass write guards. Editor toasts stack at the top center; editor, connection and template-copy feedback share a top-layer host above native dialogs and ordinary overlays, without taking focus. Template-copy feedback retains its existing placement and three-second lifetime; identical notices replace their previous instance. Error toasts use the compact neutral feedback surface and concise recognized causes, with a dismiss button and no details icon or expandable diagnostics. Detailed error panels retain their diagnostic controls. Informational toasts disappear after three seconds without a close control; actionable error notices remain dismissible and do not auto-expire. Save-queue pauses use a brief, localized feedback toast without paths, diagnostics or a retry action; it expires after three seconds without clearing the write guard or claiming that failed edits were saved. The template library reuses the website catalog layout: brand/use-case/video-type facets, configured featured templates, search and sorting, without site navigation, promotional hero or footer. Prism metadata and local cache updates drive the list. The catalog selects the editor locale from a shared multilingual publication, falling back to English and then the Resource default; template-copy prompts support the same eleven UI languages. Previews, author/source links and editable-project opening remain available. The detail view keeps the motion.md download action (`motionDocumentUrl`) above its guide content (`styleDescription`, `reviewFocus`, `motionGuideUrl`). Recreate opens a separate prompt dialog; copied instructions never occupy the guide area.
-- The asset panel shows only the current project, with compact search/import controls, type filters, and a dedicated scrollable list. User-uploaded audio rows in My assets show full filenames with their original extensions and wrap long names within the panel; the generic Audio label is omitted, while duration and specific BGM/SFX/Voice labels remain when available. Official library sources and presentation are unchanged. Assets referenced by the current composition carry an In use badge (已使用 in Chinese); unused assets have no badge. MVP My assets deletion invokes the existing file-deletion handler directly from the menu, without a second confirmation; the full editor retains its confirmation. This does not introduce a new undo mechanism or alter official catalog assets. Usage filtering is omitted; used assets still sort first within each type. In both My assets and the official animation library, hover plays only the card thumbnail, while clicking opens a centered modal preview over a gray full-editor backdrop. The modal reuses Studio-styled playback, volume and speed controls; its play button stays centered, and speed/loop controls hide below 420px to avoid overlap. Volume and loop icons are 16px inside 28px buttons, and playback speed text is 12px; closing it restores access to the paused composition; previewing media does not add it to the project. The global cache view remains in source but has no editor entry in the MVP.
+- The asset panel shows only the current project, with compact search/import controls, type filters, and a dedicated scrollable list. User-uploaded audio rows in My assets show full filenames with their original extensions and wrap long names within the panel; the generic Audio label is omitted, while duration and specific BGM/SFX/Voice labels remain when available. Official library sources are unchanged. Official animation-library cards reuse the composition list’s muted gray OD placeholder when preview media is absent or all available preview media fail; healthy posters and videos retain their existing behavior, and catalog entries remain available. Assets referenced by the current composition carry an In use badge (已使用 in Chinese); unused assets have no badge. MVP My assets deletion invokes the existing file-deletion handler directly from the menu, without a second confirmation; the full editor retains its confirmation. This does not introduce a new undo mechanism or alter official catalog assets. Usage filtering is omitted; used assets still sort first within each type. In both My assets and the official animation library, hover plays only the card thumbnail, while clicking opens a centered modal preview over a gray full-editor backdrop. The modal reuses Studio-styled playback, volume and speed controls; its play button stays centered, and speed/loop controls hide below 420px to avoid overlap. Volume and loop icons are 16px inside 28px buttons, and playback speed text is 12px; closing it restores access to the paused composition; previewing media does not add it to the project. The global cache view remains in source but has no editor entry in the MVP.
- All supported content-insertion drops share persistent timeline feedback, including project images/video/audio, the composition list, official catalog items dropped on the timeline or preview, and local files dropped on the timeline or editor shell. Accepted drops immediately show a transient loading clip, including in an empty timeline; it remains until the saved clip appears, and failures remain dismissible at the placement. A local-file batch shows an upload placeholder immediately, then hands off without an empty frame to separate placeholders for the accepted uploaded paths; rejected files retain the upload handler's existing error feedback. Uploads retain the existing single multipart request. Catalog insertion buttons and overlays use the same state instead of progress toasts. Feedback starts at the requested time, reserves space between pending drops, and settles to the saved host identity, duration and placement once metadata and native collision resolution finish. Repeated drops remain independent. Composition insertions and catalog installs queue their writes; switching composition or project invalidates queued insertions and old selection changes. Known drag metadata bypasses duration probing, and concurrent requests for the same project asset share one in-flight probe without coalescing insertions. Unreadable durations fail visibly instead of inserting a five-second clip. Placeholders never enter project source or undo history. Drops on the Assets panel import files without inserting timeline content and retain that panel's importing state.
- Panel positions are fixed. Export settings and render history live in a compact popover below the header Export button, outside the right panel. Both side groups can temporarily collapse into 48px vertical icon rails, giving their width to preview; the rail toggle restores the previous width and tab, while a module icon opens that module. Collapse does not remove panels or remount the player. Opening the MVP starts both sides collapsed and the timeline at 30% of the available dock height (subject to minimum sizes); users can then drag the divider to enlarge or reduce it. The fixed layout reserves at least 360px for preview, 260px for each expanded side panel. Side availability retains the existing conservative breakpoints, independently of the resizable minimums: below 740px both side groups and rails hide; from 740px to 1011px only one side can expand; wider hosts allow both only when their requested widths leave the preview floor intact. Opening a side through a toggle, module shortcut or programmatic activation uses the same fit check and closes the opposite side when necessary. Shrinking the host collapses expanded sides when they no longer fit; widening restores collapsed rails without automatically reopening panels. At widths smaller than the preview floor, preview uses the available workspace. Remembered expanded side widths remain available when reopening a side. Divider hover and drag change only the thin line to green. Divider resizing and per-project expanded-size persistence remain; panel movement, closing and layout presets are absent. Preview alone can temporarily expand within the editor workspace, keeping the host chat visible and the player mounted. Its header button or Escape restores the previous layout and playback position; expansion is not persisted across reloads.
- MVP controls share a locally bundled Remix Icon 4.9.1 set with the reference design system. Menu selections consistently use check icons, and the language menu is 180px wide. Expanded side-panel tabs remain text-only; collapsed rails use the corresponding panel icons. Brand artwork and timeline geometry are separate from control icons.
diff --git a/studio/src/components/sidebar/BlocksTab.test.tsx b/studio/src/components/sidebar/BlocksTab.test.tsx
index 91e57eef..1239fa26 100644
--- a/studio/src/components/sidebar/BlocksTab.test.tsx
+++ b/studio/src/components/sidebar/BlocksTab.test.tsx
@@ -1,10 +1,11 @@
// @vitest-environment happy-dom
import { act } from "react";
-import { afterEach, expect, it, vi } from "vitest";
+import { afterEach, beforeEach, expect, it, vi } from "vitest";
import { cleanupMounted, mountHost } from "../ui/mountHost.testHelpers";
import { BlocksTab, type BlockPreviewInfo } from "./BlocksTab";
+const catalog = vi.hoisted(() => ({ preview: undefined as { video?: string; poster?: string } | undefined }));
vi.mock("../../contexts/StudioContext", () => ({ useStudioShellContext: () => ({}) }));
vi.mock("../../hooks/useBlockCatalog", () => ({
useBlockCatalog: () => ({
@@ -16,11 +17,15 @@ vi.mock("../../hooks/useBlockCatalog", () => ({
description: "A scene",
type: "hyperframes:block",
category: "scenes",
- preview: { video: "/scene.mp4", poster: "/scene.jpg" },
+ preview: catalog.preview,
}],
}),
}));
+beforeEach(() => {
+ catalog.preview = { video: "/scene.mp4", poster: "/scene.jpg" };
+});
+
afterEach(() => {
cleanupMounted();
vi.useRealTimers();
@@ -30,6 +35,7 @@ it("falls back from a failed hover video to its poster, then restores the compos
vi.useFakeTimers();
const onPreview = vi.fn<(preview: BlockPreviewInfo | null) => void>();
const host = mountHost(<BlocksTab onPreviewBlock={onPreview} />);
+ expect(host.querySelector('[data-testid="catalog-cover-placeholder"]')).toBeNull();
act(() => host.querySelector("[draggable]")!.dispatchEvent(new PointerEvent("pointerover", { bubbles: true })));
act(() => vi.advanceTimersByTime(300));
@@ -42,5 +48,28 @@ it("falls back from a failed hover video to its poster, then restores the compos
act(() => host.querySelector('img[alt="Carousel"]')!.dispatchEvent(new Event("error")));
expect(preview()).toBeNull();
- expect(host.textContent).toContain("Preview unavailable");
+ expect(host.querySelector('[data-testid="catalog-cover-placeholder"] .motion-composition-placeholder-mark')).toBeTruthy();
+ expect(host.textContent).not.toContain("Preview unavailable");
+});
+
+it.each([undefined, {}])("uses the existing OD placeholder when preview metadata is absent (%s)", (preview) => {
+ catalog.preview = preview;
+ const host = mountHost(<BlocksTab />);
+ const placeholder = host.querySelector('[data-testid="catalog-cover-placeholder"]');
+ expect(placeholder?.classList.contains("motion-composition-placeholder")).toBe(true);
+ expect(placeholder?.getAttribute("aria-hidden")).toBe("true");
+ expect(placeholder?.querySelector(".motion-composition-placeholder-mark")).toBeTruthy();
+ expect(host.querySelector("img, video")).toBeNull();
+ expect(host.querySelector('[draggable="true"]')?.textContent).toContain("Carousel");
+ expect(host.textContent).not.toContain("Preview unavailable");
+});
+
+it.each(["poster", "video"] as const)("uses the OD placeholder when the only %s fails", (kind) => {
+ catalog.preview = { [kind]: kind === "poster" ? "/scene.jpg" : "/scene.mp4" };
+ const host = mountHost(<BlocksTab />);
+ expect(host.querySelector('[data-testid="catalog-cover-placeholder"]')).toBeNull();
+ act(() => host.querySelector(kind === "poster" ? "img" : "video")!.dispatchEvent(new Event("error")));
+ expect(host.querySelector('[data-testid="catalog-cover-placeholder"] .motion-composition-placeholder-mark')).toBeTruthy();
+ expect(host.querySelector("img, video")).toBeNull();
+ expect(host.textContent).not.toContain("Preview unavailable");
});
diff --git a/studio/src/components/sidebar/BlocksTab.tsx b/studio/src/components/sidebar/BlocksTab.tsx
index 9bf505c8..9dfa8788 100644
--- a/studio/src/components/sidebar/BlocksTab.tsx
+++ b/studio/src/components/sidebar/BlocksTab.tsx
@@ -414,10 +414,8 @@ function BlockCard({
) : poster ? (
<img src={poster} alt={title} loading="lazy" onError={() => setFailedPoster(poster)} className="w-full h-full object-cover" />
) : (
- <div className="flex h-full w-full items-center justify-center bg-panel-bg">
- <span className="text-[10px] text-panel-text-3">
- {t("Preview unavailable")}
- </span>
+ <div className="motion-composition-placeholder absolute inset-0 flex items-center justify-center" data-testid="catalog-cover-placeholder" aria-hidden="true">
+ <span className="motion-composition-placeholder-mark" />
</div>
)}