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.
TypeScript agent-skillsagentic-aiai-agentsai-videobyokclaude-codecodexdeepseek-harnessdsh-plugingenerative-ailocal-firstmcpmotionmotion-graphicsmultimodalopenmotionreverse-engineeringvideo-editingvideo-generationworkbuddy
import { useI18n } from "../i18n/I18n";
import { useStudioShellContextOptional } from "../contexts/StudioContext";
import { RotateCcw, RotateCw } from "../icons/SystemIcons";
import { trackStudioEvent } from "../utils/studioTelemetry";
import { historyEntryLabel } from '../i18n/historyMessages';
import { getHistoryShortcutLabel } from '../utils/studioHelpers';
import { flatBtn, flatDisabled, flatIdle } from "./timelineToolbarStyles";
import { Tooltip } from "./ui";
import { useMvpEditor } from "../motion/StudioHost";
import { RemixIcon } from "../icons/RemixIcons";
interface HistoryButtonProps {
action: "undo" | "redo";
can: boolean;
label: string | undefined;
onClick: (() => Promise<void> | void) | undefined;
}
function HistoryButton({ action, can, label, onClick }: HistoryButtonProps) {
const { t } = useI18n();
const mvp = useMvpEditor();
const Icon = action === "undo" ? RotateCcw : RotateCw;
const enabled = Boolean(onClick) && can;
const verb = t(action === 'undo' ? 'Undo' : 'Redo');
const shortcut = getHistoryShortcutLabel(action);
return (
<Tooltip label={!mvp && label ? t('{action} {label} ({shortcut})', { action: verb, label: historyEntryLabel(label, t), shortcut }) : t('{action} ({shortcut})', { action: verb, shortcut })}>
<button
type="button"
aria-label={action === "undo" ? t("Undo") : t("Redo")}
disabled={!enabled}
className={enabled ? (mvp ? `${flatBtn} text-text-0 hover:bg-hover active:bg-press active:scale-[0.98]` : flatIdle) : flatDisabled}
onClick={() => {
trackStudioEvent("toolbar_action", { action });
void onClick?.();
}}
>
{mvp ? <RemixIcon name={action === "undo" ? "arrow-go-back-line" : "arrow-go-forward-line"} size={16} /> : <Icon size={16} />}
</button>
</Tooltip>
);
}
export interface TimelineHistoryButtonsProps {
canUndo?: boolean;
canRedo?: boolean;
undoLabel?: string;
redoLabel?: string;
onUndo?: () => Promise<void> | void;
onRedo?: () => Promise<void> | void;
}
/** Undo and Redo: a host's props win, else the shell's edit history. */
export function TimelineHistoryButtons(props: TimelineHistoryButtonsProps) {
const shell = useStudioShellContextOptional();
const onUndo = props.onUndo ?? shell?.handleUndo;
const onRedo = props.onRedo ?? shell?.handleRedo;
return (
<>
<HistoryButton
action="undo"
can={props.canUndo ?? shell?.editHistory.canUndo ?? false}
label={props.undoLabel ?? shell?.editHistory.undoLabel}
onClick={onUndo}
/>
<HistoryButton
action="redo"
can={props.canRedo ?? shell?.editHistory.canRedo ?? false}
label={props.redoLabel ?? shell?.editHistory.redoLabel}
onClick={onRedo}
/>
</>
);
}