import {
	OnboardingModal,
	OttoRouterTopupModal,
} from '@ottocode/web-sdk/components';
import type { Theme } from '@ottocode/web-sdk/hooks';
import type { ReactNode } from 'react';
import type { Project } from '../../lib/tauri-bridge';
import { DesktopSessionsLayout } from './DesktopSessionsLayout';
import { DesktopWorkspaceProvider } from './DesktopWorkspaceProvider';

interface DesktopWorkspaceAppProps {
	apiUrl: string;
	project: Project;
	theme: Theme;
	onToggleTheme: () => void;
	sessionId?: string;
	view?: 'agents' | 'otto';
	dashboardOpen: boolean;
	onCloseDashboard: () => void;
	titleBar?: ReactNode;
}

export function DesktopWorkspaceApp({
	apiUrl,
	project,
	theme,
	onToggleTheme,
	sessionId,
	view,
	dashboardOpen,
	onCloseDashboard,
	titleBar,
}: DesktopWorkspaceAppProps) {
	return (
		<DesktopWorkspaceProvider apiUrl={apiUrl}>
			<div className="h-full min-h-0" data-project-path={project.path}>
				<DesktopSessionsLayout
					project={project}
					theme={theme}
					onToggleTheme={onToggleTheme}
					sessionId={sessionId}
					view={view}
					dashboardOpen={dashboardOpen}
					onCloseDashboard={onCloseDashboard}
					titleBar={titleBar}
				/>
				<OnboardingModal hideHeader />
				<OttoRouterTopupModal />
			</div>
		</DesktopWorkspaceProvider>
	);
}
