mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-16 14:27:26 +00:00
* feat(studio): make storyboard view default available (remove FF) Removes STUDIO_STORYBOARD_ENABLED. The storyboard view-mode toggle was gated behind a default-off feature flag (VITE_STUDIO_ENABLE_STORYBOARD) since #1529. With the storyboard experience now ready for broad exposure, drop the gating and make the toggle available unconditionally. Changes: - packages/studio/src/components/editor/manualEditingAvailability.ts: delete the STUDIO_STORYBOARD_ENABLED constant. - packages/studio/src/App.tsx: drop the import + FF arg to useViewModeState(). Hook is now called argument-free. - packages/studio/src/components/StudioHeader.tsx: drop the import + the conditional-render guard on <ViewModeToggle />. The toggle always renders in StudioHeader's center slot. - packages/studio/src/contexts/ViewModeContext.tsx: remove the enabled: boolean parameter from useViewModeState() and simplify. - packages/studio/fixtures/storyboard-sample/README.md: drop the VITE_STUDIO_ENABLE_STORYBOARD=1 prefix from the preview command. The VITE_STUDIO_ENABLE_STORYBOARD / VITE_STUDIO_STORYBOARD_ENABLED env vars become no-ops after this change. Co-Authored-By: Jerrai <noreply@anthropic.com> * docs(skills): drop stale VITE_STUDIO_ENABLE_STORYBOARD reference The Storyboard view is now available by default (the FF removed in this PR); storyboard-format.md no longer points at the dead env var, and skills-manifest is regenerated for the hyperframes-core hash. Closes the Via/Magi review nit. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Jerrai <noreply@anthropic.com>
90 lines
2.8 KiB
TypeScript
90 lines
2.8 KiB
TypeScript
import {
|
|
createContext,
|
|
useCallback,
|
|
useContext,
|
|
useEffect,
|
|
useMemo,
|
|
useState,
|
|
type ReactNode,
|
|
} from "react";
|
|
|
|
/**
|
|
* Top-level Studio view mode.
|
|
*
|
|
* `timeline` is the existing NLE/preview stage. `storyboard` replaces that stage
|
|
* with the storyboard contact sheet. The mode is mirrored to the `?view=` query
|
|
* param so it survives reloads and — importantly — so an agent can deep-link the
|
|
* user straight into the storyboard by navigating the tab to `?view=storyboard`.
|
|
*/
|
|
export type StudioViewMode = "timeline" | "storyboard";
|
|
|
|
const VIEW_QUERY_PARAM = "view";
|
|
|
|
function readViewModeFromUrl(): StudioViewMode {
|
|
if (typeof window === "undefined") return "timeline";
|
|
return new URLSearchParams(window.location.search).get(VIEW_QUERY_PARAM) === "storyboard"
|
|
? "storyboard"
|
|
: "timeline";
|
|
}
|
|
|
|
function writeViewModeToUrl(mode: StudioViewMode): void {
|
|
if (typeof window === "undefined") return;
|
|
const url = new URL(window.location.href);
|
|
if (mode === "storyboard") {
|
|
url.searchParams.set(VIEW_QUERY_PARAM, "storyboard");
|
|
} else {
|
|
url.searchParams.delete(VIEW_QUERY_PARAM);
|
|
}
|
|
window.history.replaceState(window.history.state, "", url);
|
|
}
|
|
|
|
export interface ViewModeValue {
|
|
viewMode: StudioViewMode;
|
|
setViewMode: (mode: StudioViewMode) => void;
|
|
}
|
|
|
|
/**
|
|
* Owns the view-mode state — initial read from `?view=`, toggling, popstate sync.
|
|
* Storyboard mode is always available; no flag gating.
|
|
*/
|
|
export function useViewModeState(): ViewModeValue {
|
|
const [viewMode, setMode] = useState<StudioViewMode>(() => readViewModeFromUrl());
|
|
|
|
// Reflect genuine browser back/forward between history entries with a different
|
|
// `?view=`. Note: our own writes use `replaceState` (below), which does NOT fire
|
|
// `popstate`, so this listener never sees them — `setViewMode` updates state directly.
|
|
// An agent deep-links by doing a full navigation to `?view=storyboard` (picked up by
|
|
// the mount-time read); a scripted `pushState`/`replaceState` to `?view=` would not be
|
|
// reflected here, by design.
|
|
useEffect(() => {
|
|
const onPopState = () => setMode(readViewModeFromUrl());
|
|
window.addEventListener("popstate", onPopState);
|
|
return () => window.removeEventListener("popstate", onPopState);
|
|
}, []);
|
|
|
|
const setViewMode = useCallback((mode: StudioViewMode) => {
|
|
setMode(mode);
|
|
writeViewModeToUrl(mode);
|
|
}, []);
|
|
|
|
return useMemo(() => ({ viewMode, setViewMode }), [viewMode, setViewMode]);
|
|
}
|
|
|
|
const ViewModeContext = createContext<ViewModeValue | null>(null);
|
|
|
|
export function useViewMode(): ViewModeValue {
|
|
const ctx = useContext(ViewModeContext);
|
|
if (!ctx) throw new Error("useViewMode must be used within ViewModeProvider");
|
|
return ctx;
|
|
}
|
|
|
|
export function ViewModeProvider({
|
|
value,
|
|
children,
|
|
}: {
|
|
value: ViewModeValue;
|
|
children: ReactNode;
|
|
}) {
|
|
return <ViewModeContext value={value}>{children}</ViewModeContext>;
|
|
}
|