Files
multica/packages/views/layout/dashboard-guard.tsx
Jiayuan Zhang 01232fc2f9 feat(onboarding): add full-screen onboarding wizard for new workspaces (#852)
* feat(onboarding): add full-screen onboarding wizard for new workspaces

Replace auto-provisioned workspace with an interactive 4-step onboarding
wizard: Create Workspace → Connect Runtime → Create Agent → Get Started.

- Remove server-side ensureUserWorkspace() so new users land in onboarding
- Add onboarding wizard in packages/views/onboarding/ (4 steps)
- Wire login/OAuth callbacks to redirect to /onboarding when no workspace
- Add DashboardGuard onboardingPath fallback for workspace-less users
- Sidebar "Create workspace" navigates to /onboarding instead of modal
- Remove CreateWorkspaceModal (replaced by wizard step 1)
- Auto-generate workspace slug from name (no user-facing URL field)
- Unified CLI install flow: install.sh + multica setup (auto-detects local)
- Create onboarding issues on completion with interactive "Say hello" task

* test(auth): update workspace tests to match onboarding flow

Login no longer auto-creates workspaces — new users start with zero
workspaces and create one through the onboarding wizard. Update both
integration and handler tests to assert 0 workspaces after verify-code.
2026-04-13 17:59:51 +08:00

40 lines
1.1 KiB
TypeScript

"use client";
import type { ReactNode } from "react";
import { WorkspaceIdProvider } from "@multica/core/hooks";
import { useDashboardGuard } from "./use-dashboard-guard";
interface DashboardGuardProps {
children: ReactNode;
/** Path to redirect to when user is not authenticated */
loginPath?: string;
/** Path to redirect to when user has no workspace (onboarding) */
onboardingPath?: string;
/** Rendered when auth or workspace is loading */
loadingFallback?: ReactNode;
}
/**
* Shared guard + provider wrapper for dashboard layouts.
*
* Handles: auth check → workspace check → WorkspaceIdProvider.
* Both web and desktop layouts compose their own UI structure inside this.
*/
export function DashboardGuard({
children,
loginPath = "/",
onboardingPath,
loadingFallback = null,
}: DashboardGuardProps) {
const { user, isLoading, workspace } = useDashboardGuard(loginPath, onboardingPath);
if (isLoading || !workspace) return <>{loadingFallback}</>;
if (!user) return null;
return (
<WorkspaceIdProvider wsId={workspace.id}>
{children}
</WorkspaceIdProvider>
);
}