'use client';
import { ArrowLeft, Redo2, Undo2 } from 'lucide-react';
import { useRouter } from 'next/navigation';
import type { ReactNode } from 'react';
import { Button } from '@/components/ui/button';
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
import { useI18n } from '@/lib/hooks/use-i18n';
import { cn } from '@/lib/utils';
import type { EditorCommand, SurfaceHistory } from '@/lib/edit/scene-editor-surface';
interface CommandBarProps {
readonly title: string;
readonly history?: SurfaceHistory;
readonly commands?: readonly EditorCommand[];
/**
* Right-edge slot owned by Stage. In Pro mode it carries the
* HeaderControls (settings pill + Pro Switch + Download) since Stage
* Header is unmounted to keep top chrome to a single bar.
*/
readonly trailing?: ReactNode;
}
/**
* Top bar of the Pro mode chrome. Undo/redo + title on the left, insert
* primitives in the center, surface commands on the right. History /
* insertItems / commands are all optional so the bar renders cleanly when
* no surface is registered for the current scene type.
*
* Exiting Pro mode is handled by the global Pro Switch in the playback
* Header (which stays mounted above this bar) — Pro mode is a toggle,
* not a one-way state, so we deliberately do *not* place a "Done" pill
* here that would compete with the Switch's affordance.
*/
export function CommandBar({ title, history, commands, trailing }: CommandBarProps) {
const { t } = useI18n();
const router = useRouter();
return (
{/* Back-to-home — mirrors playback Header's leftmost button so the
user has the same global-out affordance across modes. */}
router.push('/')}>
{history && (
<>
>
)}
{title}