Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

refactor: remove onboarding flow, fix daemon zero-workspace bootstrap (#1175)

Naiyuan Qing6a2432b16b32
diff --git a/apps/desktop/src/main/index.ts b/apps/desktop/src/main/index.ts
index 1fd30736f4..e3f61a2f09 100644
--- a/apps/desktop/src/main/index.ts
+++ b/apps/desktop/src/main/index.ts
@@ -151,7 +151,7 @@ if (!gotTheLock) {
});
// IPC: toggle immersive mode — hides the macOS traffic lights so full-screen
- // modals (create-workspace, onboarding) can place UI in the top-left corner
+ // modals (e.g. create-workspace) can place UI in the top-left corner
// without fighting the native window controls' hit-test.
ipcMain.handle("window:setImmersive", (_event, immersive: boolean) => {
if (process.platform !== "darwin") return;
diff --git a/apps/desktop/src/renderer/src/App.tsx b/apps/desktop/src/renderer/src/App.tsx
index 3b0997959e..32dbddb74d 100644
--- a/apps/desktop/src/renderer/src/App.tsx
+++ b/apps/desktop/src/renderer/src/App.tsx
@@ -1,8 +1,8 @@
-import { useEffect, useState } from "react";
-import { useQueryClient } from "@tanstack/react-query";
+import { useEffect, useRef, useState } from "react";
+import { useQuery, useQueryClient } from "@tanstack/react-query";
import { CoreProvider } from "@multica/core/platform";
import { useAuthStore } from "@multica/core/auth";
-import { workspaceKeys } from "@multica/core/workspace/queries";
+import { workspaceKeys, workspaceListOptions } from "@multica/core/workspace/queries";
import { api } from "@multica/core/api";
import { ThemeProvider } from "@multica/ui/components/common/theme-provider";
import { MulticaIcon } from "@multica/ui/components/common/multica-icon";
@@ -20,8 +20,8 @@ function AppContent() {
// as soon as getMe resolves, which would cause DesktopShell to mount
// before the workspace list is hydrated and briefly see `!workspace`.
// This local flag keeps the loading screen up until the whole chain
- // finishes, so the shell's "needs onboarding?" check gets a definitive
- // workspace state on first render.
+ // finishes, so IndexRedirect gets a definitive workspace state on
+ // first render.
const [bootstrapping, setBootstrapping] = useState(false);
// Tell the main process which backend URL we talk to, so daemon-manager
@@ -69,6 +69,38 @@ function AppContent() {
})();
}, [user]);
+ // When a user who started the session with zero workspaces creates their
+ // first one, restart the daemon so it picks up the new workspace
+ // immediately (otherwise workspaceSyncLoop's next 30s tick would be the
+ // earliest pickup point). Specifically scoped to "started empty" because
+ // account switches (user A logout → user B login) should not trigger a
+ // daemon restart here — daemon-manager already restarts on user change
+ // via syncToken.
+ const { data: workspaces, isFetched: workspaceListFetched } = useQuery({
+ ...workspaceListOptions(),
+ enabled: !!user,
+ });
+ const wsCount = workspaces?.length ?? 0;
+ // null = undecided (pre-login or list hasn't settled yet)
+ // true = session started with zero workspaces; next transition to >=1 triggers restart
+ // false = session started with >=1 workspace, OR we've already restarted; skip
+ const sessionStartedEmptyRef = useRef<boolean | null>(null);
+ useEffect(() => {
+ if (!user) {
+ sessionStartedEmptyRef.current = null;
+ return;
+ }
+ if (!workspaceListFetched) return;
+ if (sessionStartedEmptyRef.current === null) {
+ sessionStartedEmptyRef.current = wsCount === 0;
+ return;
+ }
+ if (sessionStartedEmptyRef.current && wsCount >= 1) {
+ void window.daemonAPI.restart();
+ sessionStartedEmptyRef.current = false;
+ }
+ }, [user, workspaceListFetched, wsCount]);
+
if (isLoading || bootstrapping) {
return (
<div className="flex h-screen items-center justify-center">
diff --git a/apps/desktop/src/renderer/src/components/desktop-layout.tsx b/apps/desktop/src/renderer/src/components/desktop-layout.tsx
index 8d3c820341..b8c0c61201 100644
--- a/apps/desktop/src/renderer/src/components/desktop-layout.tsx
+++ b/apps/desktop/src/renderer/src/components/desktop-layout.tsx
@@ -13,11 +13,9 @@ import { ModalRegistry } from "@multica/views/modals/registry";
import { AppSidebar } from "@multica/views/layout";
import { SearchCommand, SearchTrigger } from "@multica/views/search";
import { ChatFab, ChatWindow } from "@multica/views/chat";
-import { StepWorkspace } from "@multica/views/onboarding";
import { WorkspaceSlugProvider } from "@multica/core/paths";
import { getCurrentSlug, subscribeToCurrentSlug } from "@multica/core/platform";
import { DesktopNavigationProvider } from "@/platform/navigation";
-import { OnboardingGate } from "./onboarding-gate";
import { TabBar } from "./tab-bar";
import { TabContent } from "./tab-content";
@@ -109,39 +107,32 @@ export function DesktopShell() {
return (
<DesktopNavigationProvider>
- <OnboardingGate
- onboarding={(onComplete) => (
- <div className="flex min-h-screen items-center justify-center overflow-auto bg-background px-6 py-12">
- <StepWorkspace onNext={onComplete} />
- </div>
- )}
- >
- {/* WorkspaceSlugProvider accepts null — components that need slug
- use useWorkspaceSlug() (nullable) or useRequiredWorkspaceSlug()
- (throws). TabContent MUST always render so the tab router can
- mount WorkspaceRouteLayout, which calls setCurrentWorkspace()
- to populate the slug. The sidebar gates on slug being present
- to avoid the useRequiredWorkspaceSlug throw. */}
- <WorkspaceSlugProvider slug={slug}>
- <div className="flex h-screen">
- <SidebarProvider className="flex-1">
- {slug && <AppSidebar topSlot={<SidebarTopBar />} searchSlot={<SearchTrigger />} />}
- {/* Right side: header + content container */}
- <div className="flex flex-1 min-w-0 flex-col">
- <MainTopBar />
- {/* Content area with inset styling — relative so ChatWindow/ChatFab are constrained here */}
- <div className="relative flex flex-1 min-h-0 flex-col overflow-hidden mr-2 mb-2 ml-0.5 rounded-xl shadow-sm bg-background">
- <TabContent />
- {slug && <ChatWindow />}
- {slug && <ChatFab />}
- </div>
+ {/* WorkspaceSlugProvider accepts null — components that need slug
+ use useWorkspaceSlug() (nullable) or useRequiredWorkspaceSlug()
+ (throws). TabContent MUST always render so the tab router can
+ mount WorkspaceRouteLayout, which calls setCurrentWorkspace()
+ to populate the slug. The sidebar gates on slug being present
+ to avoid the useRequiredWorkspaceSlug throw. Zero-workspace
+ users are routed to /new-workspace by IndexRedirect. */}
+ <WorkspaceSlugProvider slug={slug}>
+ <div className="flex h-screen">
+ <SidebarProvider className="flex-1">
+ {slug && <AppSidebar topSlot={<SidebarTopBar />} searchSlot={<SearchTrigger />} />}
+ {/* Right side: header + content container */}
+ <div className="flex flex-1 min-w-0 flex-col">
+ <MainTopBar />
+ {/* Content area with inset styling — relative so ChatWindow/ChatFab are constrained here */}
+ <div className="relative flex flex-1 min-h-0 flex-col overflow-hidden mr-2 mb-2 ml-0.5 rounded-xl shadow-sm bg-background">
+ <TabContent />
+ {slug && <ChatWindow />}
+ {slug && <ChatFab />}
</div>
- </SidebarProvider>
- </div>
- {slug && <ModalRegistry />}
- {slug && <SearchCommand />}
- </WorkspaceSlugProvider>
- </OnboardingGate>
+ </div>
+ </SidebarProvider>
+ </div>
+ {slug && <ModalRegistry />}
+ {slug && <SearchCommand />}
+ </WorkspaceSlugProvider>
</DesktopNavigationProvider>
);
}
diff --git a/apps/desktop/src/renderer/src/components/onboarding-gate.test.tsx b/apps/desktop/src/renderer/src/components/onboarding-gate.test.tsx
deleted file mode 100644
index 670f33bc74..0000000000
--- a/apps/desktop/src/renderer/src/components/onboarding-gate.test.tsx
+++ /dev/null
@@ -1,99 +0,0 @@
-import { describe, it, expect, vi, beforeEach } from "vitest";
-import { render, screen, act } from "@testing-library/react";
-import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
-import { workspaceKeys } from "@multica/core/workspace/queries";
-import { OnboardingGate } from "./onboarding-gate";
-
-// Prevent actual API calls — the tests seed data via setQueryData.
-vi.mock("@multica/core/api", () => ({
- api: {
- listWorkspaces: vi.fn().mockResolvedValue([]),
- },
-}));
-
-function createTestQueryClient(
- workspaces: Array<{ id: string; slug: string }> = [],
-) {
- const qc = new QueryClient({
- defaultOptions: { queries: { retry: false } },
- });
- // Seed the workspace list so the gate can read it synchronously.
- qc.setQueryData(workspaceKeys.list(), workspaces);
- return qc;
-}
-
-function renderGate(
- qc: QueryClient,
- onboarding?: (onComplete: () => void) => React.ReactNode,
-) {
- return render(
- <QueryClientProvider client={qc}>
- <OnboardingGate
- onboarding={
- onboarding ??
- ((onComplete) => (
- <button type="button" data-testid="finish" onClick={onComplete}>
- wizard
- </button>
- ))
- }
- >
- <div data-testid="main">main shell</div>
- </OnboardingGate>
- </QueryClientProvider>,
- );
-}
-
-describe("OnboardingGate", () => {
- beforeEach(() => {
- vi.clearAllMocks();
- });
-
- it("renders children when workspaces exist in cache", () => {
- const qc = createTestQueryClient([{ id: "ws-1", slug: "my-team" }]);
- renderGate(qc);
-
- expect(screen.getByTestId("main")).toBeInTheDocument();
- expect(screen.queryByText("wizard")).not.toBeInTheDocument();
- });
-
- it("renders onboarding when workspace list is empty", () => {
- const qc = createTestQueryClient([]);
- renderGate(qc);
-
- expect(screen.getByText("wizard")).toBeInTheDocument();
- expect(screen.queryByTestId("main")).not.toBeInTheDocument();
- });
-
- it("keeps the wizard mounted even after workspaces appear in cache mid-flow", () => {
- const qc = createTestQueryClient([]);
- renderGate(qc);
-
- expect(screen.getByText("wizard")).toBeInTheDocument();
-
- // Simulate the onboarding wizard creating a workspace mid-flow.
- act(() => {
- qc.setQueryData(workspaceKeys.list(), [
- { id: "ws-new", slug: "new-team" },
- ]);
- });
-
- // Wizard should still be visible — only onComplete dismisses it.
- expect(screen.getByText("wizard")).toBeInTheDocument();
- expect(screen.queryByTestId("main")).not.toBeInTheDocument();
- });
-
- it("transitions to children after the wizard calls onComplete", () => {
- const qc = createTestQueryClient([]);
- renderGate(qc);
-
- expect(screen.getByTestId("finish")).toBeInTheDocument();
-
- act(() => {
- screen.getByTestId("finish").click();
- });
-
- expect(screen.getByTestId("main")).toBeInTheDocument();
- expect(screen.queryByTestId("finish")).not.toBeInTheDocument();
- });
-});
diff --git a/apps/desktop/src/renderer/src/components/onboarding-gate.tsx b/apps/desktop/src/renderer/src/components/onboarding-gate.tsx
deleted file mode 100644
index f1c2a07159..0000000000
--- a/apps/desktop/src/renderer/src/components/onboarding-gate.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import { useState, type ReactNode } from "react";
-import { useQuery } from "@tanstack/react-query";
-import { workspaceListOptions } from "@multica/core/workspace/queries";
-
-/**
- * Renders `onboarding` as a full-screen takeover when the user has no
- * workspaces, otherwise renders `children`.
- *
- * Reads the workspace list directly from React Query — this works regardless
- * of whether a WorkspaceSlugProvider is mounted, unlike useCurrentWorkspace()
- * which depends on slug context from the router tree.
- *
- * The onboarding decision is frozen at first mount via the lazy useState
- * initializer: this way the onboarding wizard controls its own exit by
- * calling the `onComplete` callback, instead of being unmounted the moment
- * the workspace list updates mid-flow (e.g. after the user creates their
- * first workspace in step 1 but still has steps 2-3 to complete).
- *
- * The frozen decision only triggers when the initial query has settled AND
- * the list is empty. While the list is loading, children are rendered
- * (the shell shows its own loading state).
- */
-export function OnboardingGate({
- onboarding,
- children,
-}: {
- onboarding: (onComplete: () => void) => ReactNode;
- children: ReactNode;
-}) {
- const { data: workspaces, isFetched } = useQuery(workspaceListOptions());
- const hasWorkspaces = !isFetched || (workspaces?.length ?? 0) > 0;
-
- const [initialNeedsOnboarding] = useState(() => !hasWorkspaces);
- const [onboardingDone, setOnboardingDone] = useState(false);
-
- if (initialNeedsOnboarding && !onboardingDone) {
- return <>{onboarding(() => setOnboardingDone(true))}</>;
- }
- return <>{children}</>;
-}
diff --git a/apps/desktop/src/renderer/src/components/workspace-route-layout.tsx b/apps/desktop/src/renderer/src/components/workspace-route-layout.tsx
index 3dd585272f..2b3a9c2d17 100644
--- a/apps/desktop/src/renderer/src/components/workspace-route-layout.tsx
+++ b/apps/desktop/src/renderer/src/components/workspace-route-layout.tsx
@@ -5,6 +5,8 @@ import { WorkspaceSlugProvider, paths } from "@multica/core/paths";
import { workspaceBySlugOptions } from "@multica/core/workspace";
import { setCurrentWorkspace } from "@multica/core/platform";
import { useAuthStore } from "@multica/core/auth";
+import { NoAccessPage } from "@multica/views/workspace/no-access-page";
+import { useWorkspaceSeen } from "@multica/views/workspace/use-workspace-seen";
/**
* Desktop equivalent of apps/web/app/[workspaceSlug]/layout.tsx.
@@ -16,9 +18,8 @@ import { useAuthStore } from "@multica/core/auth";
* kept distinct: slug (URL / browser) and UUID (API / cache keys).
*
* If the slug doesn't resolve to any workspace the user has access to,
- * we redirect to `/` so IndexRedirect can pick the first valid workspace
- * (more forgiving than bouncing to onboarding, which is only right for
- * zero-workspace users).
+ * we render NoAccessPage instead of silently redirecting — users get
+ * explicit feedback for stale bookmarks or revoked access.
*/
export function WorkspaceRouteLayout() {
const { workspaceSlug } = useParams<{ workspaceSlug: string }>();
@@ -26,6 +27,14 @@ export function WorkspaceRouteLayout() {
const user = useAuthStore((s) => s.user);
const isAuthLoading = useAuthStore((s) => s.isLoading);
+ // Workspace routes require auth. If user is unauthenticated (token
+ // expired, logged out from another tab, etc.), bounce to /login.
+ // Without this, the layout renders null and the user sees a blank page
+ // stuck on /{slug}/...
+ useEffect(() => {
+ if (!isAuthLoading && !user) navigate(paths.login(), { replace: true });
+ }, [isAuthLoading, user, navigate]);
+
const { data: workspace, isFetched: listFetched } = useQuery({
...workspaceBySlugOptions(workspaceSlug ?? ""),
enabled: !!user && !!workspaceSlug,
@@ -40,24 +49,10 @@ export function WorkspaceRouteLayout() {
setCurrentWorkspace(workspaceSlug, workspace.id);
}
- // Double-write legacy localStorage key for rollback compatibility — a
- // pre-refactor build reads it to pick the initial workspace. Placed in
- // an effect so repeated renders don't hammer localStorage.
- useEffect(() => {
- if (!workspace) return;
- try {
- localStorage.setItem("multica_workspace_id", workspace.id);
- } catch {
- // non-critical
- }
- }, [workspace]);
-
- // Slug can't be resolved → bounce to `/` (IndexRedirect picks first
- // valid workspace; falls to onboarding only if the list is truly empty).
- useEffect(() => {
- if (!user) return;
- if (listFetched && !workspace) navigate(paths.root(), { replace: true });
- }, [user, listFetched, workspace, navigate]);
+ // Remember whether this slug has resolved before (see hook docs). Gates
+ // the NoAccessPage render below so active workspace removal doesn't
+ // flash "Workspace not available" before the navigate lands.
+ const hasBeenSeen = useWorkspaceSeen(workspaceSlug, !!workspace);
if (isAuthLoading) return null;
if (!workspaceSlug) return null;
@@ -66,7 +61,15 @@ export function WorkspaceRouteLayout() {
// unknown — gating here is the single point where that invariant is
// enforced, so every descendant can call useWorkspaceId() safely.
if (!listFetched) return null;
- if (!workspace) return null;
+ if (!workspace) {
+ // Active workspace just removed (delete/leave/realtime eviction) —
+ // navigate is in flight; hold null briefly instead of flashing
+ // NoAccessPage.
+ if (hasBeenSeen) return null;
+ // Genuinely inaccessible slug (stale bookmark, revoked access, or a
+ // link from a former teammate's workspace) → explicit feedback.
+ return <NoAccessPage />;
+ }
return (
<WorkspaceSlugProvider slug={workspaceSlug}>
diff --git a/apps/desktop/src/renderer/src/routes.tsx b/apps/desktop/src/renderer/src/routes.tsx
index ab16785f14..61ae74f5c4 100644
--- a/apps/desktop/src/renderer/src/routes.tsx
+++ b/apps/desktop/src/renderer/src/routes.tsx
@@ -20,7 +20,7 @@ import { DaemonRuntimeCard } from "./components/daemon-runtime-card";
import { AgentsPage } from "@multica/views/agents";
import { InboxPage } from "@multica/views/inbox";
import { SettingsPage } from "@multica/views/settings";
-import { OnboardingWizard } from "@multica/views/onboarding";
+import { NewWorkspacePage } from "@multica/views/workspace/new-workspace-page";
import { InvitePage } from "@multica/views/invite";
import { useNavigation } from "@multica/views/navigation";
import { paths } from "@multica/core/paths";
@@ -59,11 +59,11 @@ function PageShell() {
);
}
-function OnboardingRoute() {
+function NewWorkspaceRoute() {
const nav = useNavigation();
return (
- <OnboardingWizard
- onComplete={(ws) => nav.push(paths.workspace(ws.slug).issues())}
+ <NewWorkspacePage
+ onSuccess={(ws) => nav.push(paths.workspace(ws.slug).issues())}
/>
);
}
@@ -76,22 +76,23 @@ function OnboardingRoute() {
* duplicate fetches across tabs — each tab's memory router hits this
* component independently but the query is deduped.
*
- * Sends first-time users without any workspace to onboarding, everyone
- * else to their first workspace's issues page. Persisted tab paths that
- * already carry a workspace slug bypass this component entirely.
+ * Sends first-time users without any workspace to /new-workspace,
+ * everyone else to their first workspace's issues page. Persisted tab
+ * paths that already carry a workspace slug bypass this component
+ * entirely.
*/
function IndexRedirect() {
const { data: wsList, isFetched } = useQuery(workspaceListOptions());
- // Wait for the query to settle so we don't redirect to onboarding on
- // the initial render before the seeded/fetched data arrives.
+ // Wait for the query to settle so we don't redirect to /new-workspace
+ // on the initial render before the seeded/fetched data arrives.
if (!isFetched) return null;
const firstWorkspace = wsList?.[0];
if (firstWorkspace) {
return <Navigate to={paths.workspace(firstWorkspace.slug).issues()} replace />;
}
- return <Navigate to={paths.onboarding()} replace />;
+ return <Navigate to={paths.newWorkspace()} replace />;
}
function InviteRoute() {
@@ -107,7 +108,7 @@ function InviteRoute() {
* Structure mirrors the web app's [workspaceSlug]/... layout: all dashboard
* pages live under /:workspaceSlug, with WorkspaceRouteLayout resolving the
* slug to a workspace and syncing side-effects (api client, persist namespace,
- * Zustand mirror). Global (pre-workspace) routes — onboarding and invite —
+ * Zustand mirror). Global (pre-workspace) routes — new-workspace and invite —
* sit at the top level alongside the workspace wrapper.
*/
export const appRoutes: RouteObject[] = [
@@ -117,12 +118,12 @@ export const appRoutes: RouteObject[] = [
// Top-level index: no slug yet. `IndexRedirect` reads the workspace
// list from React Query cache (seeded by AuthInitializer on reopen
// or App.tsx on deep-link login) and bounces to the first
- // workspace's issues page — or onboarding if the user has none.
+ // workspace's issues page — or /new-workspace if the user has none.
{ index: true, element: <IndexRedirect /> },
{
- path: "onboarding",
- element: <OnboardingRoute />,
- handle: { title: "Get Started" },
+ path: "new-workspace",
+ element: <NewWorkspaceRoute />,
+ handle: { title: "Create Workspace" },
},
{
path: "invite/:id",
diff --git a/apps/desktop/src/renderer/src/stores/tab-store.ts b/apps/desktop/src/renderer/src/stores/tab-store.ts
index 6842b44d7b..e057f85f73 100644
--- a/apps/desktop/src/renderer/src/stores/tab-store.ts
+++ b/apps/desktop/src/renderer/src/stores/tab-store.ts
@@ -63,7 +63,7 @@ const ROUTE_ICONS: Record<string, string> = {
*
* Path shape after the workspace URL refactor:
* - workspace-scoped: `/{workspaceSlug}/{route}/...` → use segment index 1
- * - global (onboarding/invite/auth/login): `/{route}/...` → use segment index 0
+ * - global (new-workspace/invite/auth/login): `/{route}/...` → use segment index 0
*
* `isGlobalPath` is the single source of truth for which prefixes are global.
*/
diff --git a/apps/web/app/(auth)/login/page.tsx b/apps/web/app/(auth)/login/page.tsx
index bfcd9cdd8b..2c6b2704e0 100644
--- a/apps/web/app/(auth)/login/page.tsx
+++ b/apps/web/app/(auth)/login/page.tsx
@@ -28,8 +28,9 @@ function LoginPageContent() {
// the user's workspace list.
const nextUrl = searchParams.get("next");
- // Already authenticated — honor ?next= or fall back to first workspace /
- // onboarding. Skip this entire path when the user arrived to authorize the CLI.
+ // Already authenticated — honor ?next= or fall back to first workspace
+ // (or /new-workspace if the user has none). Skip this entire path when
+ // the user arrived to authorize the CLI.
useEffect(() => {
if (isLoading || !user || cliCallbackRaw) return;
if (nextUrl) {
@@ -39,7 +40,7 @@ function LoginPageContent() {
const list = qc.getQueryData<Workspace[]>(workspaceKeys.list()) ?? [];
const [first] = list;
router.replace(
- first ? paths.workspace(first.slug).issues() : paths.onboarding(),
+ first ? paths.workspace(first.slug).issues() : paths.newWorkspace(),
);
}, [isLoading, user, router, nextUrl, cliCallbackRaw, qc]);
@@ -53,7 +54,7 @@ function LoginPageContent() {
const list = qc.getQueryData<Workspace[]>(workspaceKeys.list()) ?? [];
const [first] = list;
router.push(
- first ? paths.workspace(first.slug).issues() : paths.onboarding(),
+ first ? paths.workspace(first.slug).issues() : paths.newWorkspace(),
);
};
diff --git a/apps/web/app/(auth)/onboarding/page.tsx b/apps/web/app/(auth)/new-workspace/page.tsx
similarity index 67%
rename from apps/web/app/(auth)/onboarding/page.tsx
rename to apps/web/app/(auth)/new-workspace/page.tsx
index 51b711039f..9107512b3b 100644
--- a/apps/web/app/(auth)/onboarding/page.tsx
+++ b/apps/web/app/(auth)/new-workspace/page.tsx
@@ -1,17 +1,16 @@
"use client";
-import { useEffect } from "react";
import { useRouter } from "next/navigation";
+import { useEffect } from "react";
import { useAuthStore } from "@multica/core/auth";
import { paths } from "@multica/core/paths";
-import { OnboardingWizard } from "@multica/views/onboarding";
+import { NewWorkspacePage } from "@multica/views/workspace/new-workspace-page";
-export default function OnboardingPage() {
+export default function Page() {
const router = useRouter();
const user = useAuthStore((s) => s.user);
const isLoading = useAuthStore((s) => s.isLoading);
- // Redirect to login if not authenticated
useEffect(() => {
if (!isLoading && !user) router.replace(paths.login());
}, [isLoading, user, router]);
@@ -19,8 +18,8 @@ export default function OnboardingPage() {
if (isLoading || !user) return null;
return (
- <OnboardingWizard
- onComplete={(ws) => router.push(paths.workspace(ws.slug).issues())}
+ <NewWorkspacePage
+ onSuccess={(ws) => router.push(paths.workspace(ws.slug).issues())}
/>
);
}
diff --git a/apps/web/app/[workspaceSlug]/layout.tsx b/apps/web/app/[workspaceSlug]/layout.tsx
index 4eb2959b1d..fc2da626e5 100644
--- a/apps/web/app/[workspaceSlug]/layout.tsx
+++ b/apps/web/app/[workspaceSlug]/layout.tsx
@@ -7,6 +7,8 @@ import { WorkspaceSlugProvider, paths } from "@multica/core/paths";
import { workspaceBySlugOptions } from "@multica/core/workspace";
import { setCurrentWorkspace } from "@multica/core/platform";
import { useAuthStore } from "@multica/core/auth";
+import { NoAccessPage } from "@multica/views/workspace/no-access-page";
+import { useWorkspaceSeen } from "@multica/views/workspace/use-workspace-seen";
export default function WorkspaceLayout({
children,
@@ -20,6 +22,14 @@ export default function WorkspaceLayout({
const isAuthLoading = useAuthStore((s) => s.isLoading);
const router = useRouter();
+ // Workspace routes require auth. If user is unauthenticated (initial visit
+ // without a session, token expired, another tab logged out, etc.), bounce
+ // to /login. Without this, the layout renders null and the user sees a
+ // blank page stuck on /{slug}/...
+ useEffect(() => {
+ if (!isAuthLoading && !user) router.replace(paths.login());
+ }, [isAuthLoading, user, router]);
+
// Resolve workspace by slug from the React Query list cache.
// Enabled only when user is authenticated — otherwise the list query isn't seeded.
const { data: workspace, isFetched: listFetched } = useQuery({
@@ -35,39 +45,36 @@ export default function WorkspaceLayout({
setCurrentWorkspace(workspaceSlug, workspace.id);
}
- // Cookie write (last_workspace_slug) — proxy reads it on next page load.
- // ALSO write legacy localStorage["multica_workspace_id"] for forward/back
- // compatibility: if this version ever gets reverted to the pre-refactor
- // build, the legacy code reads that localStorage key to know which
- // workspace to attach to API requests. Without double-writing, a rollback
- // would leave returning users with empty data (API calls would have no
- // X-Workspace-ID header). Forward compatible — new code ignores this key.
+ // Cookie write (last_workspace_slug) — proxy reads it on next page load
+ // to redirect unauthenticated-URL hits to the user's last workspace.
useEffect(() => {
if (!workspace || typeof document === "undefined") return;
const oneYear = 60 * 60 * 24 * 365;
const secure = location.protocol === "https:" ? "; Secure" : "";
document.cookie = `last_workspace_slug=${encodeURIComponent(workspaceSlug)}; path=/; max-age=${oneYear}; SameSite=Lax${secure}`;
- try {
- localStorage.setItem("multica_workspace_id", workspace.id);
- } catch {
- // localStorage may be unavailable in restricted contexts; non-critical.
- }
}, [workspace, workspaceSlug]);
- // Slug doesn't match any workspace the user has access to → bounce to `/`
- // and let the root IndexRedirect pick the first valid workspace (falls to
- // onboarding only when the list is truly empty).
- useEffect(() => {
- if (!user) return;
- if (listFetched && !workspace) router.replace(paths.root());
- }, [user, listFetched, workspace, router]);
+ // Remember whether this slug has resolved before. Used below to avoid
+ // flashing NoAccessPage during active workspace removal (delete, leave,
+ // or realtime eviction) — in those cases the caller is navigating away
+ // and we just need to hold null briefly.
+ const hasBeenSeen = useWorkspaceSeen(workspaceSlug, !!workspace);
if (isAuthLoading) return null;
// Don't render children until workspace is resolved. useWorkspaceId()
// throws when the list hasn't populated or the slug is unknown — gating
// here makes that invariant hold for every descendant.
if (!listFetched) return null;
- if (!workspace) return null;
+ if (!workspace) {
+ // If we've resolved this slug before in this session, it was just
+ // removed from our list (deleted/left/evicted). A navigate is almost
+ // certainly in flight — render null to avoid a NoAccessPage flash.
+ if (hasBeenSeen) return null;
+ // Otherwise: the URL points at a workspace the user never had access
+ // to. Show explicit feedback instead of silently redirecting. Doesn't
+ // distinguish 404 vs 403 to avoid letting attackers enumerate slugs.
+ return <NoAccessPage />;
+ }
return (
<WorkspaceSlugProvider slug={workspaceSlug}>
diff --git a/apps/web/app/auth/callback/page.tsx b/apps/web/app/auth/callback/page.tsx
index d458c63b66..cbc7f2e095 100644
--- a/apps/web/app/auth/callback/page.tsx
+++ b/apps/web/app/auth/callback/page.tsx
@@ -66,11 +66,11 @@ function CallbackContent() {
// URL is now the source of truth for the current workspace — the
// [workspaceSlug]/layout syncs stores + cookie once we navigate.
// Honor ?next= first (e.g. came from /invite/{id}), otherwise land
- // in the first workspace's issues, or /onboarding if the user has none.
+ // in the first workspace's issues, or /new-workspace for zero-workspace users.
const [first] = wsList;
const defaultDest = first
? paths.workspace(first.slug).issues()
- : paths.onboarding();
+ : paths.newWorkspace();
router.push(nextUrl || defaultDest);
})
.catch((err) => {
diff --git a/apps/web/features/landing/components/redirect-if-authenticated.tsx b/apps/web/features/landing/components/redirect-if-authenticated.tsx
index 57e011ba78..c803dc092b 100644
--- a/apps/web/features/landing/components/redirect-if-authenticated.tsx
+++ b/apps/web/features/landing/components/redirect-if-authenticated.tsx
@@ -16,7 +16,7 @@ import { paths } from "@multica/core/paths";
* login* — before the user has ever visited a workspace — the cookie is
* absent, so the proxy falls through to the landing page. This component
* covers that gap: once auth is resolved and the workspace list has loaded,
- * push the user into their workspace (or onboarding if they have none).
+ * push the user into their workspace (or /new-workspace if they have none).
*
* Renders nothing. Uses `router.replace` so the landing page never enters
* browser history for authenticated users.
@@ -35,7 +35,7 @@ export function RedirectIfAuthenticated() {
if (isLoading || !user || !list) return;
const [first] = list;
if (!first) {
- router.replace(paths.onboarding());
+ router.replace(paths.newWorkspace());
return;
}
router.replace(paths.workspace(first.slug).issues());
diff --git a/docs/plans/2026-04-16-remove-onboarding-and-fix-daemon-bootstrap.md b/docs/plans/2026-04-16-remove-onboarding-and-fix-daemon-bootstrap.md
new file mode 100644
index 0000000000..2cf7f273c3
--- /dev/null
+++ b/docs/plans/2026-04-16-remove-onboarding-and-fix-daemon-bootstrap.md
@@ -0,0 +1,1315 @@
+# Remove Onboarding & Fix Daemon Zero-Workspace Bootstrap
+
+> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
+
+**Goal:** Delete the entire onboarding flow, replace it with a minimal `/new-workspace` page, render an explicit "no access" page when the URL slug doesn't match a workspace the user can access, and fix the latent daemon bug that crashes when the user has zero workspaces.
+
+**Architecture:**
+- Extract `CreateWorkspaceForm` (form + mutation + slug validation) so both the existing `CreateWorkspaceModal` and the new global `/new-workspace` route reuse it.
+- Replace silent `navigate("/")` redirects on slug-not-found with an explicit `NoAccessPage` so users get clear feedback instead of magic URL changes.
+- Remove the `len(allRuntimeIDs) == 0 → fail` hard-stop in the Go daemon; let `workspaceSyncLoop` (already 30 s ticker) discover workspaces post-startup. This finishes what PR #1001 started.
+- Three navigation states cleanly separated: (a) no workspace → `/new-workspace`, (b) wrong slug → `NoAccessPage`, (c) match → render.
+
+**Tech Stack:** Next.js 15 (web), Electron + react-router-dom (desktop), Go (daemon/CLI), Vitest, Playwright, TanStack Query, Zustand.
+
+---
+
+## Prerequisites (MUST verify before starting)
+
+1. **The current uncommitted workspace-slug refactor cleanup is merged to main.**
+ Run `git status` in the project root — must be clean (outside the new worktree).
+ Run `git log --oneline -5` — top commit should be the cleanup commit post-#1164.
+2. **CI is green on main.** Check `gh run list --branch main --limit 3`.
+3. **Working in a fresh worktree** (do not pollute the main checkout). Use `superpowers:using-git-worktrees`.
+4. **Read this entire plan once before starting Task 1.** Each phase is sequential — Phase 6 cannot run before Phase 5 finishes.
+5. **Verify line numbers before editing.** Plan line numbers were captured at HEAD 94c9d280; ±1-3 line drift is expected and safe. Always locate code by grep/pattern, not by raw line number.
+
+If any prerequisite fails, **STOP** and report — do not start.
+
+---
+
+## Decisions Already Made (no need to re-ask)
+
+| Decision | Choice | Reason |
+|---|---|---|
+| Demo issues (4 sample issues created in `step-complete.tsx`) | **Delete with onboarding** | Not part of new flow; new workspaces are empty by design |
+| Runtime/Agent guidance step | **Delete entirely** | Desktop manages daemon itself; web users discover via empty state in `/runtimes` |
+| `cmd_login.go` polling | **Keep polling, change URL** to `/new-workspace` | Minimal CLI change; UX equivalent |
+| `NoAccessPage` copy | "This workspace doesn't exist or you don't have access." + two buttons: `Go to my workspaces` (→ `/`), `Sign in as a different user` (→ `/login`) | Doesn't leak existence; gives users a way out |
+| Desktop daemon restart on first workspace creation | **Yes, do it** | 30s wait feels broken; one extra `useEffect` is cheap |
+| Workspace 404 vs 403 distinction | **Don't distinguish on the client** | Avoid letting attackers enumerate workspace slugs |
+| Keep `"onboarding"` in RESERVED_SLUGS (both frontend + backend) | **Keep — do NOT remove** | Frontend + backend must stay in sync; one extra string is zero cost; leaves door open if `/onboarding` route is ever revived. Only `paths.onboarding()` function and `/onboarding` from GLOBAL_PREFIXES are removed. |
+
+If the user contradicts any of these mid-execution, pause and re-confirm.
+
+### Known UX tradeoff (acknowledged, no action)
+
+Deleting demo issues removes the **only** automatic agent execution that happened in onboarding (issue #1 — "Say hello to the team!" — was `todo` + assigned to the created agent, and was the only way new users saw an end-to-end agent run without manual steps). Per user decision, we accept this: new workspaces are fully empty; users discover agent capabilities by assigning their own issues.
+
+### Backlog logic is unaffected
+
+Investigation confirmed `backlog` is the issue status "agent paused" state — orthogonal to onboarding. The 4 demo issues used `backlog` as a text-guide vehicle (issues #2-4), but no downstream UI depends on their existence. Issues/Projects/My-Issues/Inbox pages all have working empty-state UI already. Safe to delete without UX replacement.
+
+---
+
+## Phase 0: Setup
+
+### Task 0.1: Create worktree and verify clean base
+
+**Step 1: Create worktree**
+
+Run from main checkout:
+```bash
+git worktree add ../multica-onboarding-removal -b chore/remove-onboarding origin/main
+cd ../multica-onboarding-removal
+```
+
+**Step 2: Verify clean state**
+
+```bash
+git status # → "nothing to commit, working tree clean"
+git log -1 --oneline # → must include the workspace-slug cleanup commit
+```
+
+**Step 3: Install + smoke build**
+
+```bash
+pnpm install
+pnpm typecheck # baseline must pass
+make test # baseline Go tests must pass
+```
+
+If any baseline fails, **STOP** — the issue is pre-existing, fix on main first.
+
+**Step 4: No commit (worktree setup only).**
+
+---
+
+## Phase 1: Daemon Fix (smallest, ship-able alone)
+
+This phase is independent — could merge to main alone if needed. Doing it first gives the safest foundation for everything else.
+
+### Task 1.1: Write failing test for zero-workspace startup
+
+**Files:**
+- Modify: `server/internal/daemon/daemon_test.go`
+
+**Step 1: Write the failing test**
+
+Add to `daemon_test.go`:
+```go
+func TestDaemon_StartsWithZeroWorkspaces(t *testing.T) {
+ // Server returns an empty workspace list
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if r.URL.Path == "/api/workspaces" {
+ w.Header().Set("Content-Type", "application/json")
+ _, _ = w.Write([]byte("[]"))
+ return
+ }
+ w.WriteHeader(http.StatusNotFound)
+ }))
+ defer srv.Close()
+
+ d := newTestDaemon(t, srv.URL) // helper that exists in daemon_test.go; reuse pattern from other tests
+ ctx, cancel := context.WithCancel(context.Background())
+
+ // Run daemon in a goroutine; it MUST NOT return an error within 200ms.
+ errCh := make(chan error, 1)
+ go func() { errCh <- d.Run(ctx) }()
+
+ select {
+ case err := <-errCh:
+ t.Fatalf("daemon exited unexpectedly with zero workspaces: %v", err)
+ case <-time.After(200 * time.Millisecond):
+ // Expected: daemon stays running
+ }
+
+ cancel()
+ <-errCh // drain
+}
+```
+
+If `newTestDaemon` helper doesn't exist or has a different signature, **read the existing tests first** and adapt — don't invent a helper.
+
+**Step 2: Run test to verify it fails**
+
+```bash
+cd server && go test ./internal/daemon/ -run TestDaemon_StartsWithZeroWorkspaces -v
+```
+Expected: FAIL with `daemon exited unexpectedly with zero workspaces: no runtimes registered`.
+
+**Step 3: Commit the failing test (TDD discipline)**
+
+```bash
+git add server/internal/daemon/daemon_test.go
+git commit -m "test(daemon): add failing test for zero-workspace startup"
+```
+
+### Task 1.2: Remove the hard-stop in daemon
+
+**Files:**
+- Modify: `server/internal/daemon/daemon.go:95-101`
+
+**Step 1: Remove the runtime check**
+
+Current code:
+```go
+// Fetch all user workspaces from the API and register runtimes.
+if err := d.syncWorkspacesFromAPI(ctx); err != nil {
+ return err
+}
+if len(d.allRuntimeIDs()) == 0 {
+ return fmt.Errorf("no runtimes registered")
+}
+```
+
+Change to:
+```go
+// Fetch all user workspaces from the API and register runtimes for any that
+// exist. Zero workspaces is a valid state (new user before they create their
+// first workspace) — workspaceSyncLoop below will discover and register
+// runtimes when the user creates one. The 30s tick is acceptable; the
+// desktop renderer additionally triggers a daemon restart on first workspace
+// creation for instant pickup.
+if err := d.syncWorkspacesFromAPI(ctx); err != nil {
+ return err
+}
+```
+
+**Step 2: Run failing test from Task 1.1**
+
+```bash
+cd server && go test ./internal/daemon/ -run TestDaemon_StartsWithZeroWorkspaces -v
+```
+Expected: PASS.
+
+**Step 3: Run full daemon test suite — make sure nothing else broke**
+
+```bash
+cd server && go test ./internal/daemon/ -v
+```
+Expected: all green. If any test relied on "must fail with no runtimes" semantics, update that test to match the new contract (zero workspaces = valid).
+
+**Step 4: Commit**
+
+```bash
+git add server/internal/daemon/daemon.go
+git commit -m "fix(daemon): allow startup with zero workspaces
+
+workspaceSyncLoop already polls every 30s to discover new workspaces,
+but the runtime check at startup was failing fast before that loop
+got a chance to run. This was masked by onboarding always creating a
+workspace first; with onboarding being removed, the bug surfaces.
+
+PR #1001 partially fixed this for the 'server has workspaces but
+local CLI config is empty' case. This finishes the job for the
+true zero-workspace case."
+```
+
+---
+
+## Phase 2: Shared building blocks (no behavior change yet)
+
+Pure additive — nothing breaks until Phase 5/6.
+
+### Task 2.1: Extract CreateWorkspaceForm
+
+**Files:**
+- Create: `packages/views/workspace/create-workspace-form.tsx`
+- Create: `packages/views/workspace/create-workspace-form.test.tsx`
+- Modify: `packages/views/modals/create-workspace.tsx` (use the new form)
+
+**Step 1: Write the failing test**
+
+`packages/views/workspace/create-workspace-form.test.tsx`:
+```tsx
+import { describe, expect, it, vi, beforeEach } from "vitest";
+import { render, screen, fireEvent, waitFor } from "@testing-library/react";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { CreateWorkspaceForm } from "./create-workspace-form";
+
+const mockMutate = vi.fn();
+vi.mock("@multica/core/workspace/mutations", () => ({
+ useCreateWorkspace: () => ({ mutate: mockMutate, isPending: false }),
+}));
+
+function renderForm(onSuccess = vi.fn()) {
+ const qc = new QueryClient();
+ return render(
+ <QueryClientProvider client={qc}>
+ <CreateWorkspaceForm onSuccess={onSuccess} />
+ </QueryClientProvider>,
+ );
+}
+
+describe("CreateWorkspaceForm", () => {
+ beforeEach(() => mockMutate.mockReset());
+
+ it("auto-generates slug from name until user edits slug", () => {
+ renderForm();
+ fireEvent.change(screen.getByLabelText(/workspace name/i), {
+ target: { value: "Acme Corp" },
+ });
+ expect(screen.getByDisplayValue("acme-corp")).toBeInTheDocument();
+ });
+
+ it("calls onSuccess with the created workspace", async () => {
+ const onSuccess = vi.fn();
+ mockMutate.mockImplementation((_args, opts) => {
+ opts?.onSuccess?.({ id: "ws-1", slug: "acme", name: "Acme" });
+ });
+ renderForm(onSuccess);
+ fireEvent.change(screen.getByLabelText(/workspace name/i), {
+ target: { value: "Acme" },
+ });
+ fireEvent.click(screen.getByRole("button", { name: /create workspace/i }));
+ await waitFor(() =>
+ expect(onSuccess).toHaveBeenCalledWith(
+ expect.objectContaining({ slug: "acme" }),
+ ),
+ );
+ });
+
+ it("shows slug-conflict error inline without toast on 409", async () => {
+ mockMutate.mockImplementation((_args, opts) => {
+ opts?.onError?.({ status: 409 });
+ });
+ renderForm();
+ fireEvent.change(screen.getByLabelText(/workspace name/i), {
+ target: { value: "Taken" },
+ });
+ fireEvent.click(screen.getByRole("button", { name: /create workspace/i }));
+ await waitFor(() =>
+ expect(
+ screen.getByText(/already taken/i),
+ ).toBeInTheDocument(),
+ );
+ });
+});
+```
+
+**Step 2: Run to verify failure**
+
+```bash
+pnpm --filter @multica/views exec vitest run workspace/create-workspace-form.test.tsx
+```
+Expected: FAIL — "Cannot find module './create-workspace-form'".
+
+**Step 3: Implement CreateWorkspaceForm**
+
+`packages/views/workspace/create-workspace-form.tsx`:
+```tsx
+"use client";
+
+import { useRef, useState } from "react";
+import { toast } from "sonner";
+import { Input } from "@multica/ui/components/ui/input";
+import { Label } from "@multica/ui/components/ui/label";
+import { Button } from "@multica/ui/components/ui/button";
+import { Card, CardContent } from "@multica/ui/components/ui/card";
+import { useCreateWorkspace } from "@multica/core/workspace/mutations";
+import type { Workspace } from "@multica/core/types";
+import {
+ WORKSPACE_SLUG_CONFLICT_ERROR,
+ WORKSPACE_SLUG_FORMAT_ERROR,
+ WORKSPACE_SLUG_REGEX,
+ isWorkspaceSlugConflict,
+ nameToWorkspaceSlug,
+} from "./slug";
+
+export interface CreateWorkspaceFormProps {
+ onSuccess: (workspace: Workspace) => void;
+}
+
+export function CreateWorkspaceForm({ onSuccess }: CreateWorkspaceFormProps) {
+ const createWorkspace = useCreateWorkspace();
+ const [name, setName] = useState("");
+ const [slug, setSlug] = useState("");
+ const [slugServerError, setSlugServerError] = useState<string | null>(null);
+ const slugTouched = useRef(false);
+
+ const slugValidationError =
+ slug.length > 0 && !WORKSPACE_SLUG_REGEX.test(slug)
+ ? WORKSPACE_SLUG_FORMAT_ERROR
+ : null;
+ const slugError = slugValidationError ?? slugServerError;
+ const canSubmit =
+ name.trim().length > 0 && slug.trim().length > 0 && !slugError;
+
+ const handleNameChange = (value: string) => {
+ setName(value);
+ if (!slugTouched.current) {
+ setSlug(nameToWorkspaceSlug(value));
+ setSlugServerError(null);
+ }
+ };
+
+ const handleSlugChange = (value: string) => {
+ slugTouched.current = true;
+ setSlug(value);
+ setSlugServerError(null);
+ };
+
+ const handleCreate = () => {
+ if (!canSubmit) return;
+ createWorkspace.mutate(
+ { name: name.trim(), slug: slug.trim() },
+ {
+ onSuccess,
+ onError: (error) => {
+ if (isWorkspaceSlugConflict(error)) {
+ setSlugServerError(WORKSPACE_SLUG_CONFLICT_ERROR);
+ toast.error("Choose a different workspace URL");
+ return;
+ }
+ toast.error("Failed to create workspace");
+ },
+ },
+ );
+ };
+
+ return (
+ <Card className="w-full">
+ <CardContent className="space-y-4 pt-6">
+ <div className="space-y-1.5">
+ <Label htmlFor="ws-name">Workspace Name</Label>
+ <Input
+ id="ws-name"
+ autoFocus
+ type="text"
+ value={name}
+ onChange={(e) => handleNameChange(e.target.value)}
+ placeholder="My Workspace"
+ onKeyDown={(e) => e.key === "Enter" && handleCreate()}
+ />
+ </div>
+ <div className="space-y-1.5">
+ <Label htmlFor="ws-slug">Workspace URL</Label>
+ <div className="flex items-center gap-0 rounded-md border bg-background focus-within:ring-2 focus-within:ring-ring">
+ <span className="pl-3 text-sm text-muted-foreground select-none">
+ multica.ai/
+ </span>
+ <Input
+ id="ws-slug"
+ type="text"
+ value={slug}
+ onChange={(e) => handleSlugChange(e.target.value)}
+ placeholder="my-workspace"
+ className="border-0 shadow-none focus-visible:ring-0"
+ onKeyDown={(e) => e.key === "Enter" && handleCreate()}
+ />
+ </div>
+ {slugError && (
+ <p className="text-xs text-destructive">{slugError}</p>
+ )}
+ </div>
+ <Button
+ className="w-full"
+ size="lg"
+ onClick={handleCreate}
+ disabled={createWorkspace.isPending || !canSubmit}
+ >
+ {createWorkspace.isPending ? "Creating..." : "Create workspace"}
+ </Button>
+ </CardContent>
+ </Card>
+ );
+}
+```
+
+**Step 4: Refactor `CreateWorkspaceModal` to use the form**
+
+In `packages/views/modals/create-workspace.tsx`, replace the inline form (current lines 36-181) with:
+```tsx
+import { useNavigation } from "../navigation";
+import { useImmersiveMode } from "../platform";
+import { ArrowLeft } from "lucide-react";
+import { Button } from "@multica/ui/components/ui/button";
+import {
+ Dialog,
+ DialogContent,
+ DialogTitle,
+ DialogDescription,
+} from "@multica/ui/components/ui/dialog";
+import { paths } from "@multica/core/paths";
+import { CreateWorkspaceForm } from "../workspace/create-workspace-form";
+
+export function CreateWorkspaceModal({ onClose }: { onClose: () => void }) {
+ useImmersiveMode();
+ const router = useNavigation();
+
+ return (
+ <Dialog open onOpenChange={(v) => { if (!v) onClose(); }}>
+ <DialogContent
+ finalFocus={false}
+ showCloseButton={false}
+ className="inset-0 flex h-full w-full max-w-none sm:max-w-none translate-0 flex-col items-center justify-center rounded-none bg-background ring-0 shadow-none"
+ >
+ <div
+ aria-hidden
+ className="absolute inset-x-0 top-0 h-10"
+ style={{ WebkitAppRegion: "drag" } as React.CSSProperties}
+ />
+ <Button
+ variant="ghost"
+ size="sm"
+ className="absolute top-12 left-12 text-muted-foreground"
+ style={{ WebkitAppRegion: "no-drag" } as React.CSSProperties}
+ onClick={onClose}
+ >
+ <ArrowLeft className="h-4 w-4" />
+ Back
+ </Button>
+
+ <div className="flex w-full max-w-md flex-col items-center gap-6">
+ <div className="text-center">
+ <DialogTitle className="text-2xl font-semibold">
+ Create a new workspace
+ </DialogTitle>
+ <DialogDescription className="mt-2">
+ Workspaces are shared environments where teams can work on
+ projects and issues.
+ </DialogDescription>
+ </div>
+ <CreateWorkspaceForm
+ onSuccess={(newWs) => {
+ onClose();
+ router.push(paths.workspace(newWs.slug).issues());
+ }}
+ />
+ </div>
+ </DialogContent>
+ </Dialog>
+ );
+}
+```
+
+**Step 5: Run tests**
+
+```bash
+pnpm --filter @multica/views exec vitest run workspace/create-workspace-form.test.tsx
+pnpm --filter @multica/views exec vitest run modals/create-workspace.test.tsx
+```
+Both must pass. If `create-workspace.test.tsx` was relying on internal form structure, fix the test to assert behavior through the now-extracted form.
+
+**Step 6: Commit**
+
+```bash
+git add packages/views/workspace/create-workspace-form.tsx \
+ packages/views/workspace/create-workspace-form.test.tsx \
+ packages/views/modals/create-workspace.tsx
+git commit -m "refactor(views): extract CreateWorkspaceForm for reuse
+
+Modal and the upcoming /new-workspace page share the same form +
+mutation + slug validation. Extract to a shared component so they
+can't drift."
+```
+
+### Task 2.2: NoAccessPage component
+
+**Files:**
+- Create: `packages/views/workspace/no-access-page.tsx`
+- Create: `packages/views/workspace/no-access-page.test.tsx`
+
+**Step 1: Write the failing test**
+
+`packages/views/workspace/no-access-page.test.tsx`:
+```tsx
+import { describe, expect, it, vi } from "vitest";
+import { render, screen, fireEvent } from "@testing-library/react";
+import { NoAccessPage } from "./no-access-page";
+
+const navigate = vi.fn();
+vi.mock("../navigation", () => ({
+ useNavigation: () => ({ push: navigate, replace: navigate }),
+}));
+
+describe("NoAccessPage", () => {
+ it("renders generic message that doesn't leak existence", () => {
+ render(<NoAccessPage />);
+ expect(
+ screen.getByText(/doesn't exist or you don't have access/i),
+ ).toBeInTheDocument();
+ });
+
+ it("navigates to root on 'Go to my workspaces'", () => {
+ navigate.mockReset();
+ render(<NoAccessPage />);
+ fireEvent.click(screen.getByRole("button", { name: /go to my workspaces/i }));
+ expect(navigate).toHaveBeenCalledWith("/");
+ });
+
+ it("navigates to login on 'Sign in as a different user'", () => {
+ navigate.mockReset();
+ render(<NoAccessPage />);
+ fireEvent.click(screen.getByRole("button", { name: /sign in as a different user/i }));
+ expect(navigate).toHaveBeenCalledWith("/login");
+ });
+});
+```
+
+**Step 2: Run to verify failure** — Expected: module not found.
+
+**Step 3: Implement NoAccessPage**
+
+`packages/views/workspace/no-access-page.tsx`:
+```tsx
+"use client";
+
+import { Button } from "@multica/ui/components/ui/button";
+import { paths } from "@multica/core/paths";
+import { useNavigation } from "../navigation";
+
+export function NoAccessPage() {
+ const nav = useNavigation();
+ return (
+ <div className="flex min-h-svh flex-col items-center justify-center gap-6 px-6 text-center">
+ <div className="space-y-2">
+ <h1 className="text-2xl font-semibold tracking-tight">
+ Workspace not available
+ </h1>
+ <p className="max-w-md text-muted-foreground">
+ This workspace doesn't exist or you don't have access.
+ </p>
+ </div>
+ <div className="flex flex-col gap-2 sm:flex-row">
+ <Button onClick={() => nav.push(paths.root())}>
+ Go to my workspaces
+ </Button>
+ <Button variant="outline" onClick={() => nav.push(paths.login())}>
+ Sign in as a different user
+ </Button>
+ </div>
+ </div>
+ );
+}
+```
+
+**Step 4: Run test** — Expected: PASS.
+
+**Step 5: Commit**
+
+```bash
+git add packages/views/workspace/no-access-page.tsx \
+ packages/views/workspace/no-access-page.test.tsx
+git commit -m "feat(views): add NoAccessPage for unknown/inaccessible workspace slugs"
+```
+
+### Task 2.3: Add `paths.newWorkspace()` and update reserved slugs (frontend)
+
+**Files:**
+- Modify: `packages/core/paths/paths.ts`
+- Modify: `packages/core/paths/paths.test.ts`
+- Modify: `packages/core/paths/consistency.test.ts` (verify `/new-workspace` is recognized global path — test file also contains `/onboarding` references that Phase 6 will clean up)
+- Modify: `packages/core/paths/reserved-slugs.ts`
+- Modify: `packages/core/paths/reserved-slugs.test.ts` (if it exists; check first)
+
+**Step 1: Add failing test**
+
+`paths.test.ts` — add:
+```ts
+it("newWorkspace returns /new-workspace", () => {
+ expect(paths.newWorkspace()).toBe("/new-workspace");
+});
+
+it("isGlobalPath recognizes /new-workspace", () => {
+ expect(isGlobalPath("/new-workspace")).toBe(true);
+});
+```
+
+`reserved-slugs.test.ts` — add (or create):
+```ts
+it("reserves new-workspace", () => {
+ expect(isReservedSlug("new-workspace")).toBe(true);
+});
+```
+
+**Step 2: Run to verify failure**
+
+```bash
+pnpm --filter @multica/core exec vitest run paths/paths.test.ts paths/reserved-slugs.test.ts
+```
+
+**Step 3: Implement**
+
+`paths.ts`:
+```ts
+// Add to paths object:
+newWorkspace: () => "/new-workspace",
+// Keep onboarding for now — Phase 6 deletes it. Don't break callers yet.
+
+// Update GLOBAL_PREFIXES:
+const GLOBAL_PREFIXES = [
+ "/login", "/onboarding", "/new-workspace",
+ "/invite/", "/auth/", "/logout", "/signup",
+];
+```
+
+`reserved-slugs.ts`: add `"new-workspace",` to the auth/onboarding section. **Keep `"onboarding"` as reserved** — do not remove.
+
+**Step 4: Run tests** — PASS.
+
+**Step 5: Commit**
+
+```bash
+git add packages/core/paths/
+git commit -m "feat(paths): add /new-workspace route + reserve slug"
+```
+
+### Task 2.4: Update reserved slugs in Go backend
+
+**Files:**
+- Modify: `server/internal/handler/workspace_reserved_slugs.go`
+- Modify: `server/internal/handler/workspace_test.go`
+
+**Step 1: Add failing test**
+
+In `workspace_test.go` (find the existing reserved-slug test and extend):
+```go
+{name: "new-workspace is reserved", slug: "new-workspace", wantReserved: true},
+```
+
+**Step 2: Run to verify failure**
+
+```bash
+cd server && go test ./internal/handler/ -run TestReservedSlug -v
+```
+
+**Step 3: Implement**
+
+`workspace_reserved_slugs.go`: add `"new-workspace": true,` to the Auth + onboarding routes section.
+
+**Step 4: Run test** — PASS.
+
+**Step 5: Commit**
+
+```bash
+git add server/internal/handler/
+git commit -m "feat(workspace): reserve 'new-workspace' slug
+
+Frontend will route /new-workspace to the workspace creation page.
+Reserve here to prevent collision."
+```
+
+### Task 2.5: Database migration for new reserved slug audit
+
+**Files:**
+- Create: `server/migrations/046_audit_new_workspace_reserved.up.sql`
+- Create: `server/migrations/046_audit_new_workspace_reserved.down.sql`
+
+**Step 1: Read existing audit migration as template**
+
+```bash
+cat server/migrations/045_audit_dashboard_route_slugs.up.sql
+```
+
+**Step 2: Write up migration**
+
+`046_audit_new_workspace_reserved.up.sql`:
+```sql
+-- Audit: ensure no existing workspace uses the new reserved slug
+-- "new-workspace" before we wire it as a frontend route.
+DO $$
+DECLARE
+ conflict_count INT;
+BEGIN
+ SELECT COUNT(*) INTO conflict_count
+ FROM workspaces
+ WHERE slug = 'new-workspace';
+
+ IF conflict_count > 0 THEN
+ RAISE EXCEPTION 'cannot reserve slug "new-workspace": % workspace(s) already use it', conflict_count;
+ END IF;
+END $$;
+```
+
+`046_audit_new_workspace_reserved.down.sql`:
+```sql
+-- No-op: the audit is informational; no schema change to revert.
+SELECT 1;
+```
+
+**Step 3: Run the migration locally**
+
+```bash
+make migrate-up
+```
+Expected: clean apply. If it fails because a workspace already exists with that slug, **STOP** and ask the user how to handle the conflict (rename? warn the affected workspace owner?).
+
+**Step 4: Commit**
+
+```bash
+git add server/migrations/046_audit_new_workspace_reserved.up.sql \
+ server/migrations/046_audit_new_workspace_reserved.down.sql
+git commit -m "chore(migrations): audit no existing workspace uses 'new-workspace' slug"
+```
+
+---
+
+## Phase 3: New `/new-workspace` route on both apps
+
+### Task 3.1: Web — `/new-workspace` page
+
+**Files:**
+- Create: `apps/web/app/(auth)/new-workspace/page.tsx`
+- Create: `apps/web/app/(auth)/new-workspace/page.test.tsx` (if web app pattern uses page tests; check)
+
+**Step 1: Read the existing `(auth)/onboarding/page.tsx` as template**
+
+Note its auth check pattern + redirect after success.
+
+**Step 2: Write failing test (if applicable)**
+
+(If web app doesn't have unit tests for these pages, skip — covered by E2E in Phase 8.)
+
+**Step 3: Implement**
+
+`apps/web/app/(auth)/new-workspace/page.tsx`:
+```tsx
+"use client";
+
+import { useRouter } from "next/navigation";
+import { useEffect } from "react";
+import { useAuthStore } from "@multica/core/auth";
+import { paths } from "@multica/core/paths";
+import { CreateWorkspaceForm } from "@multica/views/workspace/create-workspace-form";
+
+export default function NewWorkspacePage() {
+ const router = useRouter();
+ const user = useAuthStore((s) => s.user);
+ const isLoading = useAuthStore((s) => s.isLoading);
+
+ useEffect(() => {
+ if (!isLoading && !user) router.replace(paths.login());
+ }, [isLoading, user, router]);
+
+ if (isLoading || !user) return null;
+
+ return (
+ <div className="flex min-h-svh flex-col items-center justify-center bg-background px-6 py-12">
+ <div className="flex w-full max-w-md flex-col items-center gap-6">
+ <div className="text-center">
+ <h1 className="text-3xl font-semibold tracking-tight">
+ Welcome to Multica
+ </h1>
+ <p className="mt-2 text-muted-foreground">
+ Create your workspace to get started.
+ </p>
+ </div>
+ <CreateWorkspaceForm
+ onSuccess={(ws) => router.push(paths.workspace(ws.slug).issues())}
+ />
+ </div>
+ </div>
+ );
+}
+```
+
+**Step 4: Manual smoke**
+
+```bash
+pnpm dev:web
+# Navigate to http://localhost:3000/new-workspace
+# Verify form renders. (Don't actually create yet — blocked by daemon-management Phase 7.)
+```
+
+**Step 5: Commit**
+
+```bash
+git add apps/web/app/\(auth\)/new-workspace/
+git commit -m "feat(web): add /new-workspace route"
+```
+
+### Task 3.2: Desktop — `/new-workspace` route
+
+**Files:**
+- Modify: `apps/desktop/src/renderer/src/routes.tsx`
+
+**Step 1: Add new route**
+
+In `routes.tsx`, add a sibling to `OnboardingRoute` (don't delete OnboardingRoute yet — Phase 6 does that):
+
+```tsx
+import { CreateWorkspaceForm } from "@multica/views/workspace/create-workspace-form";
+
+function NewWorkspaceRoute() {
+ const nav = useNavigation();
+ return (
+ <div className="flex min-h-svh flex-col items-center justify-center bg-background px-6 py-12">
+ <div className="flex w-full max-w-md flex-col items-center gap-6">
+ <div className="text-center">
+ <h1 className="text-3xl font-semibold tracking-tight">
+ Welcome to Multica
+ </h1>
+ <p className="mt-2 text-muted-foreground">
+ Create your workspace to get started.
+ </p>
+ </div>
+ <CreateWorkspaceForm
+ onSuccess={(ws) => nav.push(paths.workspace(ws.slug).issues())}
+ />
+ </div>
+ </div>
+ );
+}
+
+// In appRoutes children, add (next to onboarding):
+{
+ path: "new-workspace",
+ element: <NewWorkspaceRoute />,
+ handle: { title: "Create Workspace" },
+},
+```
+
+**Step 2: Manual smoke**
+
+```bash
+pnpm dev:desktop
+# In a tab, navigate to /new-workspace
+# Verify form renders
+```
+
+**Step 3: Commit**
+
+```bash
+git add apps/desktop/src/renderer/src/routes.tsx
+git commit -m "feat(desktop): add /new-workspace route"
+```
+
+---
+
+## Phase 4: NoAccessPage wired into workspace layouts
+
+### Task 4.1: Web layout renders NoAccessPage on slug not found
+
+**Files:**
+- Modify: `apps/web/app/[workspaceSlug]/layout.tsx`
+
+**Step 1: Read current layout**
+
+Note lines 63-69 (the `useEffect` that does `router.replace(paths.root())`) and line 76 (`if (!workspace) return null;`).
+
+**Step 2: Replace silent redirect with NoAccessPage render**
+
+Remove the `useEffect` that calls `router.replace(paths.root())`. Replace the `if (!workspace) return null;` block:
+```tsx
+import { NoAccessPage } from "@multica/views/workspace/no-access-page";
+
+// ... earlier code unchanged ...
+
+if (isAuthLoading) return null;
+if (!listFetched) return null;
+if (!workspace) return <NoAccessPage />;
+
+return (
+ <WorkspaceSlugProvider slug={workspaceSlug}>
+ {children}
+ </WorkspaceSlugProvider>
+);
+```
+
+**Step 3: Manual smoke**
+
+```bash
+pnpm dev:web
+# Login. Navigate to /some-fake-slug/issues
+# Verify NoAccessPage renders, URL stays at /some-fake-slug/issues (no auto-redirect)
+# Click "Go to my workspaces" → URL → /
+```
+
+**Step 4: Commit**
+
+```bash
+git add apps/web/app/\[workspaceSlug\]/layout.tsx
+git commit -m "feat(web): show NoAccessPage instead of silently redirecting unknown slugs
+
+Users who hit /unknown-slug/issues now see an explicit message instead
+of being magically bounced to their first workspace. This handles:
+- Workspace doesn't exist
+- Workspace exists but user isn't a member
+- Stale bookmark / shared link from a former teammate"
+```
+
+### Task 4.2: Desktop layout renders NoAccessPage
+
+**Files:**
+- Modify: `apps/desktop/src/renderer/src/components/workspace-route-layout.tsx`
+
+**Step 1: Same change pattern**
+
+Remove the `useEffect` that calls `navigate(paths.root())` (lines 56-59). Replace the `if (!workspace) return null;` (line 68) with `if (!workspace) return <NoAccessPage />;`.
+
+Add import:
+```tsx
+import { NoAccessPage } from "@multica/views/workspace/no-access-page";
+```
+
+**Step 2: Manual smoke**
+
+```bash
+pnpm dev:desktop
+# In a tab, navigate to /unknown-slug/issues
+# Same expected behavior as web
+```
+
+**Step 3: Commit**
+
+```bash
+git add apps/desktop/src/renderer/src/components/workspace-route-layout.tsx
+git commit -m "feat(desktop): show NoAccessPage on unknown workspace slug"
+```
+
+---
+
+## Phase 5: Switch all redirects from `/onboarding` → `/new-workspace`
+
+This phase is mostly find-and-replace, but each touch point needs verification because some have nuance (e.g. dashboard guard previously distinguished "loading" from "no workspace").
+
+### Task 5.1: List all call sites
+
+**Step 1: Find every reference**
+
+```bash
+grep -rn "paths.onboarding" packages apps server
+grep -rn '"/onboarding"' packages apps server # raw strings, e.g. CLI
+```
+
+Expected hits (from earlier investigation):
+- `apps/web/app/(auth)/login/page.tsx` (lines ~42, ~56)
+- `apps/web/app/auth/callback/page.tsx` (line ~73)
+- `apps/web/features/landing/components/redirect-if-authenticated.tsx` (line ~38)
+- `apps/desktop/src/renderer/src/routes.tsx` (`IndexRedirect`, ~line 94)
+- `packages/views/layout/use-dashboard-guard.ts` (~line 44)
+- `packages/views/invite/invite-page.tsx` (~line 37)
+- `packages/core/realtime/use-realtime-sync.ts` (~line 274)
+- `packages/views/settings/components/workspace-tab.tsx` (~line 60)
+- `packages/core/navigation/store.ts` (~line 13, 19 — exclusion list)
+
+**Step 2: For each, change `paths.onboarding()` → `paths.newWorkspace()`**
+
+Mechanical edit. Verify each touched test passes.
+
+**Step 3: Update navigation store exclusion**
+
+`packages/core/navigation/store.ts:13,19` currently filters out `/onboarding` from persisted history. Add `/new-workspace` to that list (and update `store.test.ts` to match).
+
+**Step 4: Run all unit tests**
+
+```bash
+pnpm test
+```
+Expected: green. Fix any test that asserts the old path.
+
+**Step 5: Commit (single commit for all redirect-point changes)**
+
+```bash
+git add packages/ apps/web/ apps/desktop/src/renderer/src/routes.tsx
+git commit -m "refactor: redirect zero-workspace users to /new-workspace instead of /onboarding"
+```
+
+### Task 5.2: CLI — `cmd_login.go`
+
+**Files:**
+- Modify: `server/cmd/multica/cmd_login.go` (line ~128)
+
+**Step 1: Update URL string**
+
+Replace:
+```go
+onboardingURL := appURL + "/onboarding"
+```
+with:
+```go
+onboardingURL := appURL + "/new-workspace"
+```
+
+Rename the variable (`onboardingURL` → `createWorkspaceURL`) and update the user-facing log message:
+```go
+fmt.Fprintln(os.Stderr, "\nNo workspaces found. Opening workspace creation in your browser...")
+```
+
+**Step 2: Run CLI tests**
+
+```bash
+cd server && go test ./cmd/multica/ -v
+```
+Update any test that asserted the old URL/log message.
+
+**Step 3: Commit**
+
+```bash
+git add server/cmd/multica/cmd_login.go
+git commit -m "refactor(cli): point login polling at /new-workspace"
+```
+
+### Task 5.3: Desktop App.tsx — restart daemon on first workspace creation
+
+**Files:**
+- Modify: `apps/desktop/src/renderer/src/App.tsx`
+
+**Step 1: Read current effect**
+
+Lines 57-70: effect depends on `[user]` only.
+
+**Step 2: Add a watcher effect**
+
+Add a separate `useEffect` that subscribes to React Query workspace list and restarts the daemon when count goes from 0 → ≥1. Use the existing query options:
+
+```tsx
+import { useQuery } from "@tanstack/react-query";
+import { workspaceListOptions } from "@multica/core/workspace/queries";
+
+// inside the App component:
+const { data: workspaces } = useQuery({
+ ...workspaceListOptions(),
+ enabled: !!user,
+});
+const wsCount = workspaces?.length ?? 0;
+const prevCountRef = useRef(0);
+
+useEffect(() => {
+ if (!user) {
+ prevCountRef.current = 0;
+ return;
+ }
+ if (prevCountRef.current === 0 && wsCount >= 1) {
+ // First workspace just appeared — bounce daemon so it picks up
+ // the workspace immediately instead of waiting up to 30s for
+ // workspaceSyncLoop's next tick.
+ void window.daemonAPI.restart();
+ }
+ prevCountRef.current = wsCount;
+}, [user, wsCount]);
+```
+
+**Step 3: Manual smoke**
+
+```bash
+pnpm dev:desktop
+# Login as a brand-new user (no workspace).
+# Open daemon panel — should show "stopped" then "starting" once you
+# fill out /new-workspace.
+# After "Create workspace", daemon should transition to "running" within seconds.
+```
+
+**Step 4: Commit**
+
+```bash
+git add apps/desktop/src/renderer/src/App.tsx
+git commit -m "feat(desktop): restart daemon on first workspace creation
+
+Without this, new users wait up to 30s for the daemon's
+workspaceSyncLoop to discover their first workspace. Trigger an
+immediate restart so daemon connects within seconds."
+```
+
+---
+
+## Phase 6: Delete onboarding (point of no return)
+
+After this phase the codebase no longer has any onboarding code. **Verify Phase 5 completely before starting.**
+
+### Task 6.1: Verify no lingering references
+
+```bash
+grep -rn "paths.onboarding\|OnboardingWizard\|StepWorkspace\|StepRuntime\|StepAgent\|StepComplete\|OnboardingGate\|onboarding-wizard\|onboarding-gate" \
+ packages apps server --include='*.ts' --include='*.tsx' --include='*.go' \
+ | grep -v "docs/plans"
+```
+
+Expected: only the files about to be deleted should appear. If anything else hits, **fix in Phase 5** before continuing.
+
+### Task 6.2: Delete onboarding files and remove package export
+
+```bash
+git rm -r packages/views/onboarding/
+git rm -r apps/web/app/\(auth\)/onboarding/
+git rm apps/desktop/src/renderer/src/components/onboarding-gate.tsx
+git rm apps/desktop/src/renderer/src/components/onboarding-gate.test.tsx
+```
+
+Also edit **`packages/views/package.json`** — remove the onboarding export:
+
+```json
+// DELETE this line from the "exports" block:
+"./onboarding": "./onboarding/index.ts",
+```
+
+Without this, `pnpm typecheck` may still report the export as valid and subsequent imports from `@multica/views/onboarding` won't be caught as broken.
+
+### Task 6.3: Remove onboarding hooks from desktop-layout
+
+**Files:**
+- Modify: `apps/desktop/src/renderer/src/components/desktop-layout.tsx`
+
+Remove imports of `StepWorkspace` and `OnboardingGate` (lines 16, 20). Remove the `<OnboardingGate>` wrapper around the shell content (lines 112-144). The `WorkspaceSlugProvider` and inner content stay; just remove the gate wrapper.
+
+### Task 6.4: Remove onboarding route from desktop
+
+**Files:**
+- Modify: `apps/desktop/src/renderer/src/routes.tsx`
+
+- Delete `OnboardingWizard` import (line 23).
+- Delete `OnboardingRoute` function (lines 62-69).
+- Delete the `path: "onboarding"` route entry (lines 122-126).
+- In `IndexRedirect` (line 94), change the fallback from `paths.onboarding()` to `paths.newWorkspace()`.
+
+### Task 6.5: Remove `paths.onboarding()` and `/onboarding` from GLOBAL_PREFIXES
+
+**Files:**
+- Modify: `packages/core/paths/paths.ts`
+- Modify: `packages/core/paths/paths.test.ts`
+- Modify: `packages/core/paths/consistency.test.ts` (remove `/onboarding` from any path arrays)
+- Modify: `packages/core/navigation/store.ts` (remove `/onboarding` from EXCLUDED_PREFIXES)
+- Modify: `packages/core/navigation/store.test.ts` (update test arrays)
+
+Changes:
+
+- In `paths.ts`:
+ - Delete the `onboarding: () => "/onboarding",` line (line ~41)
+ - Remove `"/onboarding"` from `GLOBAL_PREFIXES` (line ~51)
+ - Update the module doc comment (line ~7) — the `paths.onboarding()` example should be removed or replaced with `paths.newWorkspace()`
+- Update `paths.test.ts`: remove the `expect(paths.onboarding()).toBe(...)` and `expect(isGlobalPath("/onboarding")).toBe(true)` cases.
+- Update `consistency.test.ts`: remove any `/onboarding` entry in the paths-to-test array.
+- Update `navigation/store.ts` and `store.test.ts`: remove `/onboarding` from the persist-exclusion list and test assertions.
+
+**DO NOT touch `RESERVED_SLUGS` for `"onboarding"`** — it stays reserved. The frontend `reserved-slugs.ts` and backend `workspace_reserved_slugs.go` both keep `"onboarding"` entries. Reasoning:
+- Frontend + backend must stay in sync (comment in both files says "keep in sync")
+- Removing carries no current benefit but blocks future re-introduction of an `/onboarding` route
+- Cost of keeping: one string entry each side
+- Historical migrations (043, 045) audit for this slug — removing it from the list diverges from the audit's historical truth
+
+### Task 6.6: Verify everything compiles and tests pass
+
+```bash
+pnpm typecheck
+pnpm test
+cd server && go test ./...
+```
+
+Fix any breakage. Common issues:
+- Missing imports (delete unused)
+- Test expectations referring to deleted strings
+
+### Task 6.7: Single commit for the deletion
+
+```bash
+git add -A
+git commit -m "refactor: remove onboarding flow
+
+The 4-step onboarding wizard (workspace → runtime → agent → demo issues)
+is replaced by:
+- /new-workspace: a single-page workspace creation form
+- NoAccessPage: explicit feedback when a slug doesn't resolve
+- daemon zero-workspace bootstrap (Phase 1) so the daemon doesn't
+ crash before the user creates their first workspace
+- desktop daemon restart on first workspace creation for instant pickup
+
+Removed: StepWorkspace, StepRuntime, StepAgent, StepComplete (incl.
+the 4 demo issues), OnboardingWizard, OnboardingGate, /onboarding
+routes, paths.onboarding(), 'onboarding' reserved slug."
+```
+
+---
+
+## Phase 7: Verification
+
+### Task 7.1: Full test suite
+
+```bash
+make check
+```
+
+All four (typecheck, JS unit, Go, E2E) must pass. Don't proceed if any fail.
+
+### Task 7.2: Manual end-to-end smoke (web + desktop)
+
+Three personas to test for **both web and desktop**:
+
+**Persona A — brand-new user**
+1. Sign up (or use a dev account with zero workspaces).
+2. Login → expect to land at `/new-workspace`.
+3. Fill form → submit → expect redirect to `/{slug}/issues`.
+4. **Desktop only:** verify daemon transitions stopped → running within ~5s of workspace creation.
+
+**Persona B — existing user accessing wrong slug**
+1. Login as a user with at least one workspace.
+2. In address bar, type `/total-fake-slug/issues`.
+3. Expect: `NoAccessPage` rendered. URL stays at `/total-fake-slug/issues` (no magic redirect).
+4. Click "Go to my workspaces" → expect bounce to `/` then to your first workspace.
+
+**Persona C — happy path workspace switching**
+1. Login as user with multiple workspaces.
+2. Switch between workspaces via sidebar.
+3. Verify URL updates, data refreshes (no regressions from this change).
+
+### Task 7.3: CLI smoke
+
+```bash
+# Use a dev account with zero workspaces:
+multica login --server-url http://localhost:8080
+# Expect browser to open at /new-workspace
+# Create workspace in browser
+# CLI should detect and continue
+```
+
+### Task 7.4: Update PR-ready commit log
+
+```bash
+git log main..HEAD --oneline
+```
+Expected ~10–12 atomic commits with clear scopes (`fix(daemon)`, `refactor(views)`, `feat(web)`, etc.).
+
+---
+
+## Phase 8: PR
+
+### Task 8.1: Open PR
+
+Use the existing PR template / `superpowers:requesting-code-review` skill.
+
+PR title: `refactor: remove onboarding flow + fix daemon zero-workspace bootstrap`
+
+PR body must include:
+- **Summary** (3 bullets):
+ - Daemon now starts with zero workspaces; `workspaceSyncLoop` discovers new ones (finishes #1001)
+ - Onboarding wizard replaced by `/new-workspace` page (single workspace creation step) + explicit `NoAccessPage` for bad slugs
+ - Desktop now restarts daemon immediately when user creates their first workspace
+- **Test plan** mirroring the three personas in Task 7.2
+- **Migration note**: backend deploy must include migration 046; if any workspace already uses slug `new-workspace`, deploy is blocked (audit migration will fail loudly)
+- **Behavior changes** (visible to existing users):
+ - URL `/{unknown-slug}/...` no longer auto-redirects; shows NoAccessPage
+ - `/onboarding` URL is gone; bookmarks 404 (acceptable — onboarding was a one-time URL nobody bookmarks)
+
+---
+
+## Rollback strategy
+
+If post-deploy a critical issue surfaces:
+
+1. **Quick rollback** — revert the PR. The daemon-bootstrap change (Phase 1) is the only behavioral risk for existing users; reverting restores the old "fail with no runtimes" behavior, but since existing users always have workspaces this is fine.
+2. **Migration 046** is read-only (audit) — no rollback needed.
+3. Any user mid-create at `/new-workspace` when rollback happens will see a 404; rare and acceptable.
+
+---
+
+## Risk register
+
+| Risk | Mitigation |
+|---|---|
+| Daemon `workspaceSyncLoop` 30s gap feels slow on web (no daemon restart there) | Accept — web users don't run a daemon; runtime connection is irrelevant until they configure one |
+| Existing tests assert `paths.onboarding()` | Phase 5/6 updates them; `make check` catches anything missed |
+| Workspace slug "new-workspace" collision in production | Migration 046 fails loudly during deploy; sysadmin renames the offending workspace before retrying |
+| User bookmarks `/onboarding` | 404 — acceptable, onboarding was a single-use URL; nobody bookmarks it |
+| Removing `useEffect` redirect in workspace layouts breaks downstream invariants | Phase 4 manual smoke + E2E catches |
+
+---
+
+## Completion criteria
+
+- [ ] All 8 phases complete; commits atomic and conventional
+- [ ] `make check` green
+- [ ] All three persona smoke tests pass on both web and desktop
+- [ ] CLI smoke passes
+- [ ] PR opened with full body, migration note, and reviewers assigned
+- [ ] No grep hit for `onboarding` anywhere except `docs/plans/` and historical PR descriptions
diff --git a/packages/core/navigation/store.test.ts b/packages/core/navigation/store.test.ts
index a9dce8d539..f5a7cfbc86 100644
--- a/packages/core/navigation/store.test.ts
+++ b/packages/core/navigation/store.test.ts
@@ -5,13 +5,13 @@ import { describe, it, expect } from "vitest";
// persistence — otherwise lastPath could contain /login etc, and on next
// app load we'd "restore" a user to the login page.
describe("useNavigationStore.lastPath excludes global paths", () => {
- it("does not persist /login, /onboarding, /invite/, /auth/, /logout, /signup", async () => {
+ it("does not persist /login, /new-workspace, /invite/, /auth/, /logout, /signup", async () => {
const { useNavigationStore } = await import("./store");
const globalPrefixes = [
"/login",
"/logout",
"/signup",
- "/onboarding",
+ "/new-workspace",
"/invite/abc",
"/auth/callback",
];
diff --git a/packages/core/navigation/store.ts b/packages/core/navigation/store.ts
index 77b659bfb8..1ec008b01b 100644
--- a/packages/core/navigation/store.ts
+++ b/packages/core/navigation/store.ts
@@ -10,13 +10,13 @@ import { defaultStorage } from "../platform/storage";
// Paths that should not be persisted as "last visited":
// - Auth flows (/login, /signup, /logout)
-// - Pre-workspace routes (/onboarding, /auth/, /invite/)
+// - Pre-workspace routes (/new-workspace, /auth/, /invite/)
// - Pair flow (/pair/)
const EXCLUDED_PREFIXES = [
"/login",
"/signup",
"/logout",
- "/onboarding",
+ "/new-workspace",
"/auth/",
"/invite/",
"/pair/",
diff --git a/packages/core/paths/consistency.test.ts b/packages/core/paths/consistency.test.ts
index e284d5fb51..e313fb9a3d 100644
--- a/packages/core/paths/consistency.test.ts
+++ b/packages/core/paths/consistency.test.ts
@@ -66,7 +66,7 @@ describe("global path / reserved slug consistency", () => {
"/login",
"/logout",
"/signup",
- "/onboarding",
+ "/new-workspace",
"/invite/",
"/auth/",
];
diff --git a/packages/core/paths/paths.test.ts b/packages/core/paths/paths.test.ts
index 0a2590aae7..5f603078f1 100644
--- a/packages/core/paths/paths.test.ts
+++ b/packages/core/paths/paths.test.ts
@@ -27,7 +27,7 @@ describe("paths.workspace(slug)", () => {
describe("paths (global)", () => {
it("builds global paths without slug", () => {
expect(paths.login()).toBe("/login");
- expect(paths.onboarding()).toBe("/onboarding");
+ expect(paths.newWorkspace()).toBe("/new-workspace");
expect(paths.invite("inv-1")).toBe("/invite/inv-1");
expect(paths.authCallback()).toBe("/auth/callback");
});
@@ -36,7 +36,7 @@ describe("paths (global)", () => {
describe("isGlobalPath", () => {
it("returns true for pre-workspace routes", () => {
expect(isGlobalPath("/login")).toBe(true);
- expect(isGlobalPath("/onboarding")).toBe(true);
+ expect(isGlobalPath("/new-workspace")).toBe(true);
expect(isGlobalPath("/invite/abc")).toBe(true);
expect(isGlobalPath("/auth/callback")).toBe(true);
});
diff --git a/packages/core/paths/paths.ts b/packages/core/paths/paths.ts
index dcaa56e70a..e0a298869e 100644
--- a/packages/core/paths/paths.ts
+++ b/packages/core/paths/paths.ts
@@ -4,7 +4,7 @@
*
* Two kinds of paths:
* - workspace-scoped: paths.workspace(slug).xxx() — carry workspace in URL
- * - global: paths.login(), paths.onboarding(), paths.invite(id) — pre-workspace routes
+ * - global: paths.login(), paths.newWorkspace(), paths.invite(id) — pre-workspace routes
*
* Why pure functions + builder pattern:
* - Changing a route shape (e.g. adding workspace slug prefix) becomes a single-file edit
@@ -38,7 +38,7 @@ export const paths = {
// Global (pre-workspace) routes
login: () => "/login",
- onboarding: () => "/onboarding",
+ newWorkspace: () => "/new-workspace",
invite: (id: string) => `/invite/${encode(id)}`,
authCallback: () => "/auth/callback",
root: () => "/",
@@ -48,7 +48,7 @@ export type WorkspacePaths = ReturnType<typeof workspaceScoped>;
// Prefixes — not slug names — because we match against full URL paths.
// A path is global if it equals or begins with any of these.
-const GLOBAL_PREFIXES = ["/login", "/onboarding", "/invite/", "/auth/", "/logout", "/signup"];
+const GLOBAL_PREFIXES = ["/login", "/new-workspace", "/invite/", "/auth/", "/logout", "/signup"];
export function isGlobalPath(path: string): boolean {
return GLOBAL_PREFIXES.some((p) => path === p || path.startsWith(p));
diff --git a/packages/core/paths/reserved-slugs.ts b/packages/core/paths/reserved-slugs.ts
index 95bd6c13c1..0903a08623 100644
--- a/packages/core/paths/reserved-slugs.ts
+++ b/packages/core/paths/reserved-slugs.ts
@@ -8,6 +8,7 @@ export const RESERVED_SLUGS = new Set([
"logout",
"signup",
"onboarding",
+ "new-workspace",
"invite",
"auth",
diff --git a/packages/core/realtime/use-realtime-sync.ts b/packages/core/realtime/use-realtime-sync.ts
index 5cf39d4057..c7b10438e9 100644
--- a/packages/core/realtime/use-realtime-sync.ts
+++ b/packages/core/realtime/use-realtime-sync.ts
@@ -261,17 +261,18 @@ export function useRealtimeSync(
// --- Side-effect handlers (toast, navigation) ---
// After the current workspace disappears (deleted or we were kicked out),
- // navigate to another workspace the user still has access to, or to
- // onboarding. We use a full-page navigation: this reliably tears down any
- // in-flight queries / subscriptions tied to the dead workspace without
- // relying on framework-specific routers from here in core.
+ // navigate to another workspace the user still has access to, or to the
+ // create-workspace page. We use a full-page navigation: this reliably
+ // tears down any in-flight queries / subscriptions tied to the dead
+ // workspace without relying on framework-specific routers from here in
+ // core.
const relocateAfterWorkspaceLoss = async (lostWsId: string) => {
const wsList = await qc.fetchQuery({
...workspaceListOptions(),
staleTime: 0,
});
const next = wsList.find((w) => w.id !== lostWsId);
- const target = next ? paths.workspace(next.slug).issues() : paths.onboarding();
+ const target = next ? paths.workspace(next.slug).issues() : paths.newWorkspace();
if (typeof window !== "undefined") {
window.location.assign(target);
}
diff --git a/packages/views/auth/login-page.tsx b/packages/views/auth/login-page.tsx
index c25c71114b..512d9bbbd6 100644
--- a/packages/views/auth/login-page.tsx
+++ b/packages/views/auth/login-page.tsx
@@ -199,7 +199,8 @@ export function LoginPage({
// Normal path: seed the workspace list into the Query cache so the
// caller's onSuccess can read it synchronously to compute a destination
- // URL (first workspace's slug, or onboarding).
+ // URL (first workspace's slug, or /new-workspace for zero-workspace
+ // users).
await useAuthStore.getState().verifyCode(email, value);
const wsList = await api.listWorkspaces();
qc.setQueryData(workspaceKeys.list(), wsList);
diff --git a/packages/views/invite/invite-page.tsx b/packages/views/invite/invite-page.tsx
index 2d1ab16102..5e6dbf7aaa 100644
--- a/packages/views/invite/invite-page.tsx
+++ b/packages/views/invite/invite-page.tsx
@@ -34,7 +34,7 @@ export function InvitePage({ invitationId }: InvitePageProps) {
// page is a pre-workspace global route so we can't rely on WorkspaceSlugProvider.
const { data: wsList = [] } = useQuery(workspaceListOptions());
const fallbackDest =
- wsList[0] ? paths.workspace(wsList[0].slug).issues() : paths.onboarding();
+ wsList[0] ? paths.workspace(wsList[0].slug).issues() : paths.newWorkspace();
const handleAccept = async () => {
setAccepting(true);
diff --git a/packages/views/layout/app-sidebar.tsx b/packages/views/layout/app-sidebar.tsx
index 27681414f4..a6aaf57642 100644
--- a/packages/views/layout/app-sidebar.tsx
+++ b/packages/views/layout/app-sidebar.tsx
@@ -273,7 +273,7 @@ export function AppSidebar({ topSlot, searchSlot, headerClassName, headerStyle }
}
// Clear the last-workspace-slug cookie. Otherwise on a shared device the
// next user gets redirected by the proxy to the previous user's last
- // workspace (then bounced to /onboarding by the layout — flash + confusing).
+ // workspace (then bounced to NoAccessPage by the layout — confusing).
if (typeof document !== "undefined") {
document.cookie = "last_workspace_slug=; path=/; max-age=0; SameSite=Lax";
}
@@ -283,6 +283,11 @@ export function AppSidebar({ topSlot, searchSlot, headerClassName, headerStyle }
defaultStorage.removeItem("multica_tabs");
queryClient.clear();
authLogout();
+ // Navigate to /login explicitly. authLogout() clears state but doesn't
+ // move the URL, and the current URL is a workspace-scoped path that
+ // means nothing without auth — without this redirect the user stays on
+ // /{slug}/... and the layout renders null (blank screen).
+ push(paths.login());
};
// Global "C" shortcut to open create-issue modal (like Linear)
diff --git a/packages/views/layout/use-dashboard-guard.ts b/packages/views/layout/use-dashboard-guard.ts
index e495d8b74b..5967f52b5b 100644
--- a/packages/views/layout/use-dashboard-guard.ts
+++ b/packages/views/layout/use-dashboard-guard.ts
@@ -14,13 +14,13 @@ import { useNavigation } from "../navigation";
* Redirect logic:
* - Auth still loading → wait
* - Not logged in → /login
- * - Logged in but workspace list not yet loaded → wait (don't bounce to /onboarding)
- * - Logged in but URL slug doesn't resolve to any workspace → /onboarding
+ * - Logged in but workspace list not yet loaded → wait (don't bounce prematurely)
+ * - Logged in but URL slug doesn't resolve to any workspace → /new-workspace
*
* We read the workspace list query state directly (rather than relying on
* useCurrentWorkspace's null return) so we can distinguish "list loading"
* from "slug not found". Otherwise users could see a transient redirect
- * to /onboarding before their workspace list arrives.
+ * to /new-workspace before their workspace list arrives.
*/
export function useDashboardGuard() {
const { pathname, replace } = useNavigation();
@@ -41,7 +41,7 @@ export function useDashboardGuard() {
// Wait for workspace list to settle before deciding "no workspace".
if (!workspaceListFetched) return;
if (!workspace) {
- replace(paths.onboarding());
+ replace(paths.newWorkspace());
}
}, [user, isLoading, workspaceListFetched, workspace, replace]);
diff --git a/packages/views/modals/create-workspace.tsx b/packages/views/modals/create-workspace.tsx
index 9f6547e366..9763979d99 100644
--- a/packages/views/modals/create-workspace.tsx
+++ b/packages/views/modals/create-workspace.tsx
@@ -1,12 +1,8 @@
"use client";
-import { useRef, useState } from "react";
import { useNavigation } from "../navigation";
import { useImmersiveMode } from "../platform";
-import { toast } from "sonner";
import { ArrowLeft } from "lucide-react";
-import { Input } from "@multica/ui/components/ui/input";
-import { Label } from "@multica/ui/components/ui/label";
import { Button } from "@multica/ui/components/ui/button";
import {
Dialog,
@@ -14,84 +10,15 @@ import {
DialogTitle,
DialogDescription,
} from "@multica/ui/components/ui/dialog";
-import { Card, CardContent } from "@multica/ui/components/ui/card";
-import { useCreateWorkspace } from "@multica/core/workspace/mutations";
import { paths } from "@multica/core/paths";
-import {
- WORKSPACE_SLUG_CONFLICT_ERROR,
- WORKSPACE_SLUG_FORMAT_ERROR,
- WORKSPACE_SLUG_REGEX,
- isWorkspaceSlugConflict,
- nameToWorkspaceSlug,
-} from "../workspace/slug";
+import { CreateWorkspaceForm } from "../workspace/create-workspace-form";
export function CreateWorkspaceModal({ onClose }: { onClose: () => void }) {
// This modal is full-screen, so it covers the app titlebar. On macOS desktop
// we hide the traffic lights for its lifetime so the Back button in the top-
// left corner isn't stolen by the native controls' hit-test. No-op elsewhere.
useImmersiveMode();
-
const router = useNavigation();
- const createWorkspace = useCreateWorkspace();
- const [name, setName] = useState("");
- const [slug, setSlug] = useState("");
- const [slugServerError, setSlugServerError] = useState<string | null>(null);
- const slugTouched = useRef(false);
-
- const slugValidationError =
- slug.length > 0 && !WORKSPACE_SLUG_REGEX.test(slug)
- ? WORKSPACE_SLUG_FORMAT_ERROR
- : null;
- const slugError = slugValidationError ?? slugServerError;
-
- const canSubmit =
- name.trim().length > 0 && slug.trim().length > 0 && !slugError;
-
- const handleNameChange = (value: string) => {
- setName(value);
- if (!slugTouched.current) {
- setSlug(nameToWorkspaceSlug(value));
- setSlugServerError(null);
- }
- };
-
- const handleSlugChange = (value: string) => {
- slugTouched.current = true;
- setSlug(value);
- setSlugServerError(null);
- };
-
- const handleCreate = () => {
- if (!canSubmit) return;
- // The modal is only reachable from an authenticated workspace context
- // (via the global modal registry). After creating a new workspace the
- // user should land INSIDE it at its issues page, not in /onboarding —
- // onboarding exists only for users with zero workspaces. Navigation is the
- // only way to switch workspaces now (URL is the source of truth), so the
- // push below is sufficient — no imperative store writes needed.
- createWorkspace.mutate(
- { name: name.trim(), slug: slug.trim() },
- {
- onSuccess: (newWs) => {
- onClose();
- // Navigate INTO the new workspace. The mutation's own onSuccess
- // (in core/workspace/mutations.ts) runs before this callback and
- // has already seeded the workspace list cache, so the destination
- // [workspaceSlug]/layout will resolve newWs.slug → workspace
- // synchronously without a loading flash.
- router.push(paths.workspace(newWs.slug).issues());
- },
- onError: (error) => {
- if (isWorkspaceSlugConflict(error)) {
- setSlugServerError(WORKSPACE_SLUG_CONFLICT_ERROR);
- toast.error("Choose a different workspace URL");
- return;
- }
- toast.error("Failed to create workspace");
- },
- },
- );
- };
return (
<Dialog
@@ -135,49 +62,17 @@ export function CreateWorkspaceModal({ onClose }: { onClose: () => void }) {
projects and issues.
</DialogDescription>
</div>
-
- <Card className="w-full">
- <CardContent className="space-y-4 pt-6">
- <div className="space-y-1.5">
- <Label>Workspace Name</Label>
- <Input
- autoFocus
- type="text"
- value={name}
- onChange={(e) => handleNameChange(e.target.value)}
- placeholder="My Workspace"
- />
- </div>
- <div className="space-y-1.5">
- <Label>Workspace URL</Label>
- <div className="flex items-center gap-0 rounded-md border bg-background focus-within:ring-2 focus-within:ring-ring">
- <span className="pl-3 text-sm text-muted-foreground select-none">
- multica.ai/
- </span>
- <Input
- type="text"
- value={slug}
- onChange={(e) => handleSlugChange(e.target.value)}
- placeholder="my-workspace"
- className="border-0 shadow-none focus-visible:ring-0"
- onKeyDown={(e) => e.key === "Enter" && handleCreate()}
- />
- </div>
- {slugError && (
- <p className="text-xs text-destructive">{slugError}</p>
- )}
- </div>
- </CardContent>
- </Card>
-
- <Button
- className="w-full"
- size="lg"
- onClick={handleCreate}
- disabled={createWorkspace.isPending || !canSubmit}
- >
- {createWorkspace.isPending ? "Creating..." : "Create workspace"}
- </Button>
+ <CreateWorkspaceForm
+ onSuccess={(newWs) => {
+ onClose();
+ // Navigate INTO the new workspace. The mutation's own onSuccess
+ // (in core/workspace/mutations.ts) runs before this callback and
+ // has already seeded the workspace list cache, so the destination
+ // [workspaceSlug]/layout will resolve newWs.slug → workspace
+ // synchronously without a loading flash.
+ router.push(paths.workspace(newWs.slug).issues());
+ }}
+ />
</div>
</DialogContent>
</Dialog>
diff --git a/packages/views/onboarding/index.ts b/packages/views/onboarding/index.ts
deleted file mode 100644
index 24e37f0ba2..0000000000
--- a/packages/views/onboarding/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export { OnboardingWizard } from "./onboarding-wizard";
-export type { OnboardingWizardProps } from "./onboarding-wizard";
-export { StepWorkspace } from "./step-workspace";
diff --git a/packages/views/onboarding/onboarding-wizard.test.tsx b/packages/views/onboarding/onboarding-wizard.test.tsx
deleted file mode 100644
index f043078690..0000000000
--- a/packages/views/onboarding/onboarding-wizard.test.tsx
+++ /dev/null
@@ -1,131 +0,0 @@
-import { beforeEach, describe, expect, it, vi } from "vitest";
-import { fireEvent, render, screen } from "@testing-library/react";
-import {
- QueryClient,
- QueryClientProvider,
- type QueryClient as QC,
-} from "@tanstack/react-query";
-import type { ReactNode } from "react";
-import type { Workspace } from "@multica/core/types";
-import { workspaceKeys } from "@multica/core/workspace/queries";
-
-vi.mock("./step-workspace", () => ({
- StepWorkspace: ({ onNext }: { onNext: () => void }) => (
- <button type="button" onClick={onNext}>
- Finish workspace
- </button>
- ),
-}));
-
-vi.mock("./step-runtime", () => ({
- StepRuntime: ({ wsId }: { wsId: string }) => (
- <div>Runtime step for {wsId}</div>
- ),
-}));
-
-vi.mock("./step-agent", () => ({
- StepAgent: () => <div>Agent step</div>,
-}));
-
-vi.mock("./step-complete", () => ({
- StepComplete: () => <div>Complete step</div>,
-}));
-
-// Stub the list query so the wizard reads whatever we seeded in the cache.
-// `listWorkspaces` returns a promise that never resolves so the seeded cache
-// data isn't overwritten by a background refetch during the test.
-vi.mock("@multica/core/api", () => ({
- api: {
- listWorkspaces: vi.fn(() => new Promise(() => {})),
- },
-}));
-
-import { OnboardingWizard } from "./onboarding-wizard";
-
-function makeWorkspace(id: string, slug = id): Workspace {
- return {
- id,
- name: id,
- slug,
- created_at: "",
- updated_at: "",
- } as Workspace;
-}
-
-function renderWithCache(
- wsList: Workspace[],
- onComplete = vi.fn(),
-): { qc: QC } {
- const qc = new QueryClient({
- defaultOptions: { queries: { retry: false } },
- });
- qc.setQueryData(workspaceKeys.list(), wsList);
- const wrapper = ({ children }: { children: ReactNode }) => (
- <QueryClientProvider client={qc}>{children}</QueryClientProvider>
- );
- render(<OnboardingWizard onComplete={onComplete} />, { wrapper });
- return { qc };
-}
-
-describe("OnboardingWizard", () => {
- beforeEach(() => {
- vi.clearAllMocks();
- });
-
- it("starts at workspace creation when no workspace exists", () => {
- renderWithCache([]);
-
- expect(
- screen.getByRole("button", { name: "Finish workspace" }),
- ).toBeInTheDocument();
- });
-
- it("continues setup when a workspace already exists", () => {
- renderWithCache([makeWorkspace("ws-123")]);
-
- expect(screen.getByText("Runtime step for ws-123")).toBeInTheDocument();
- });
-
- it("continues setup when the workspace becomes available after mount", async () => {
- const qc = new QueryClient({
- defaultOptions: { queries: { retry: false } },
- });
- qc.setQueryData(workspaceKeys.list(), []);
- const wrapper = ({ children }: { children: ReactNode }) => (
- <QueryClientProvider client={qc}>{children}</QueryClientProvider>
- );
-
- render(<OnboardingWizard onComplete={vi.fn()} />, { wrapper });
-
- expect(
- screen.getByRole("button", { name: "Finish workspace" }),
- ).toBeInTheDocument();
-
- // Simulate useCreateWorkspace adding the new workspace to the list cache.
- qc.setQueryData(workspaceKeys.list(), [makeWorkspace("ws-456")]);
-
- expect(
- await screen.findByText("Runtime step for ws-456"),
- ).toBeInTheDocument();
- });
-
- it("does not skip runtime when workspace creation also advances step", () => {
- const qc = new QueryClient({
- defaultOptions: { queries: { retry: false } },
- });
- qc.setQueryData(workspaceKeys.list(), []);
- const wrapper = ({ children }: { children: ReactNode }) => (
- <QueryClientProvider client={qc}>{children}</QueryClientProvider>
- );
-
- render(<OnboardingWizard onComplete={vi.fn()} />, { wrapper });
-
- // Mutation's onSuccess populates the cache first, then the step-workspace
- // mock calls onNext — we should land on step 1 (runtime), never step 2.
- qc.setQueryData(workspaceKeys.list(), [makeWorkspace("ws-789")]);
- fireEvent.click(screen.getByRole("button", { name: "Finish workspace" }));
-
- expect(screen.getByText("Runtime step for ws-789")).toBeInTheDocument();
- expect(screen.queryByText("Agent step")).not.toBeInTheDocument();
- });
-});
diff --git a/packages/views/onboarding/onboarding-wizard.tsx b/packages/views/onboarding/onboarding-wizard.tsx
deleted file mode 100644
index 02413e47e4..0000000000
--- a/packages/views/onboarding/onboarding-wizard.tsx
+++ /dev/null
@@ -1,130 +0,0 @@
-"use client";
-
-import { useCallback, useEffect, useState } from "react";
-import { useQuery } from "@tanstack/react-query";
-import { workspaceListOptions } from "@multica/core/workspace/queries";
-import type { Agent, Workspace } from "@multica/core/types";
-import { StepWorkspace } from "./step-workspace";
-import { StepRuntime } from "./step-runtime";
-import { StepAgent } from "./step-agent";
-import { StepComplete } from "./step-complete";
-
-const STEPS = [
- { label: "Workspace" },
- { label: "Runtime" },
- { label: "Agent" },
- { label: "Get Started" },
-] as const;
-
-export interface OnboardingWizardProps {
- /**
- * Called when the user finishes the wizard. The just-configured workspace is
- * passed so the caller can navigate into it (/{slug}/issues). Onboarding is a
- * pre-workspace global route, so the URL has no slug while it runs.
- */
- onComplete: (workspace: Workspace) => void;
-}
-
-export function OnboardingWizard({ onComplete }: OnboardingWizardProps) {
- // Canonical source for workspace existence: the React Query list cache. The
- // onboarding route itself is global (no slug in URL), so useCurrentWorkspace
- // can't help here — we read the list directly. `useCreateWorkspace` adds the
- // new workspace to this cache in its onSuccess, so step 0 → step 1 happens
- // once the list query is populated.
- const { data: wsList = [] } = useQuery(workspaceListOptions());
- // A user arriving at /onboarding normally has 0 workspaces. After the first
- // step they have exactly one. In the rare case the list already has entries
- // (e.g. the user manually navigated to /onboarding), pick the most recent —
- // that's the one the onboarding flow should configure.
- const workspace: Workspace | null = wsList[wsList.length - 1] ?? null;
- const wsId = workspace?.id ?? null;
-
- const [step, setStep] = useState(() => (workspace ? 1 : 0));
- const [createdAgent, setCreatedAgent] = useState<Agent | null>(null);
-
- useEffect(() => {
- if (step === 0 && wsId) {
- setStep(1);
- }
- }, [step, wsId]);
-
- const startWorkspaceSetup = useCallback(() => setStep(1), []);
-
- const next = useCallback(
- () => setStep((s) => Math.min(s + 1, STEPS.length - 1)),
- [],
- );
-
- return (
- <div className="flex min-h-svh flex-col bg-background">
- {/* Progress bar */}
- <div className="flex items-center justify-center gap-2 px-6 pt-8">
- {STEPS.map((s, i) => (
- <div key={s.label} className="flex items-center gap-2">
- <div className="flex items-center gap-1.5">
- <div
- className={`flex h-6 w-6 items-center justify-center rounded-full text-xs font-medium transition-colors ${
- i <= step
- ? "bg-primary text-primary-foreground"
- : "bg-muted text-muted-foreground"
- }`}
- >
- {i < step ? (
- <svg
- className="h-3.5 w-3.5"
- viewBox="0 0 24 24"
- fill="none"
- stroke="currentColor"
- strokeWidth="3"
- strokeLinecap="round"
- strokeLinejoin="round"
- >
- <polyline points="20 6 9 17 4 12" />
- </svg>
- ) : (
- i + 1
- )}
- </div>
- <span
- className={`text-sm ${
- i <= step
- ? "text-foreground font-medium"
- : "text-muted-foreground"
- }`}
- >
- {s.label}
- </span>
- </div>
- {i < STEPS.length - 1 && (
- <div
- className={`h-px w-8 ${i < step ? "bg-primary" : "bg-border"}`}
- />
- )}
- </div>
- ))}
- </div>
-
- {/* Step content */}
- <div className="flex flex-1 items-center justify-center px-6 py-12">
- {step === 0 && <StepWorkspace onNext={startWorkspaceSetup} />}
- {step === 1 && wsId && (
- <StepRuntime wsId={wsId} onNext={next} />
- )}
- {step === 2 && wsId && (
- <StepAgent
- wsId={wsId}
- onNext={next}
- onAgentCreated={setCreatedAgent}
- />
- )}
- {step === 3 && workspace && (
- <StepComplete
- wsId={workspace.id}
- agent={createdAgent}
- onEnter={() => onComplete(workspace)}
- />
- )}
- </div>
- </div>
- );
-}
diff --git a/packages/views/onboarding/step-agent.tsx b/packages/views/onboarding/step-agent.tsx
deleted file mode 100644
index 3b79f278c0..0000000000
--- a/packages/views/onboarding/step-agent.tsx
+++ /dev/null
@@ -1,367 +0,0 @@
-"use client";
-
-import { useState, useEffect } from "react";
-import { useQuery } from "@tanstack/react-query";
-import {
- ChevronDown,
- Globe,
- Lock,
- AlertCircle,
- Crown,
- Code,
-} from "lucide-react";
-import { toast } from "sonner";
-import { Button } from "@multica/ui/components/ui/button";
-import { Card } from "@multica/ui/components/ui/card";
-import { Input } from "@multica/ui/components/ui/input";
-import { Label } from "@multica/ui/components/ui/label";
-import {
- Popover,
- PopoverTrigger,
- PopoverContent,
-} from "@multica/ui/components/ui/popover";
-import { api } from "@multica/core/api";
-import { runtimeListOptions } from "@multica/core/runtimes/queries";
-import { ProviderLogo } from "../runtimes/components/provider-logo";
-import type {
- Agent,
- AgentVisibility,
- CreateAgentRequest,
-} from "@multica/core/types";
-
-interface AgentTemplate {
- id: string;
- name: string;
- description: string;
- instructions: string;
- icon: typeof Crown;
-}
-
-const AGENT_TEMPLATES: AgentTemplate[] = [
- {
- id: "master",
- name: "Master Agent",
- description: "Manages workspace, assigns tasks, and coordinates work",
- instructions:
- "You are a Master Agent for this workspace. Your role is to manage and coordinate tasks, triage incoming issues, and ensure work is distributed effectively across the team.",
- icon: Crown,
- },
- {
- id: "coding",
- name: "Coding Agent",
- description: "Checks out code, implements features, and submits PRs",
- instructions:
- "You are a Coding Agent. Your role is to check out code repositories, implement features and bug fixes based on issue descriptions, write tests, and submit pull requests.",
- icon: Code,
- },
-];
-
-export function StepAgent({
- wsId,
- onNext,
- onAgentCreated,
-}: {
- wsId: string;
- onNext: () => void;
- onAgentCreated: (agent: Agent) => void;
-}) {
- const { data: runtimes = [] } = useQuery(runtimeListOptions(wsId));
- const hasRuntime = runtimes.length > 0;
-
- // Template selection
- const [selectedTemplateId, setSelectedTemplateId] = useState<string | null>(
- null,
- );
-
- // Form state — populated from template, editable
- const [name, setName] = useState("");
- const [description, setDescription] = useState("");
- const [selectedRuntimeId, setSelectedRuntimeId] = useState("");
- const [visibility, setVisibility] = useState<AgentVisibility>("workspace");
- const [creating, setCreating] = useState(false);
- const [runtimeOpen, setRuntimeOpen] = useState(false);
- const [showForm, setShowForm] = useState(false);
-
- // Auto-select first runtime
- useEffect(() => {
- if (!selectedRuntimeId && runtimes[0]) {
- setSelectedRuntimeId(runtimes[0].id);
- }
- }, [runtimes, selectedRuntimeId]);
-
- const selectedRuntime =
- runtimes.find((r) => r.id === selectedRuntimeId) ?? null;
-
- const handleSelectTemplate = (template: AgentTemplate) => {
- setSelectedTemplateId(template.id);
- setName(template.name);
- setDescription(template.description);
- setShowForm(true);
- };
-
- const handleCreate = async () => {
- if (!name.trim() || !selectedRuntime) return;
- const template = AGENT_TEMPLATES.find((t) => t.id === selectedTemplateId);
- setCreating(true);
- try {
- const req: CreateAgentRequest = {
- name: name.trim(),
- description: description.trim() || undefined,
- instructions: template?.instructions,
- runtime_id: selectedRuntime.id,
- visibility,
- };
- const agent = await api.createAgent(req);
- onAgentCreated(agent);
- onNext();
- } catch (err) {
- toast.error(
- err instanceof Error ? err.message : "Failed to create agent",
- );
- setCreating(false);
- }
- };
-
- return (
- <div className="flex w-full max-w-lg flex-col items-center gap-8">
- <div className="text-center">
- <h1 className="text-3xl font-semibold tracking-tight">
- Create Your First Agent
- </h1>
- <p className="mt-2 text-muted-foreground">
- Choose a template to get started, then customize your agent.
- </p>
- </div>
-
- {/* No runtime warning */}
- {!hasRuntime && (
- <div className="flex w-full items-start gap-2 rounded-lg border border-warning/30 bg-warning/5 px-4 py-3 text-sm text-warning">
- <AlertCircle className="mt-0.5 h-4 w-4 shrink-0" />
- <p>
- No runtime connected. Go back to connect a runtime, or skip and set
- one up later.
- </p>
- </div>
- )}
-
- {/* Template cards */}
- {!showForm && (
- <div className="grid w-full grid-cols-2 gap-4">
- {AGENT_TEMPLATES.map((template) => {
- const Icon = template.icon;
- return (
- <Card
- key={template.id}
- role="button"
- tabIndex={0}
- onClick={() => handleSelectTemplate(template)}
- onKeyDown={(e) => {
- if (e.key === "Enter" || e.key === " ") {
- e.preventDefault();
- handleSelectTemplate(template);
- }
- }}
- className="cursor-pointer p-5 transition-all hover:border-foreground/20"
- >
- <div className="mb-3 flex h-10 w-10 items-center justify-center rounded-lg bg-muted text-muted-foreground">
- <Icon className="h-5 w-5" />
- </div>
- <h3 className="font-semibold">{template.name}</h3>
- <p className="mt-1 text-sm text-muted-foreground">
- {template.description}
- </p>
- </Card>
- );
- })}
- </div>
- )}
-
- {/* Agent configuration form */}
- {showForm && (
- <Card className="w-full p-5 space-y-4">
- {/* Name */}
- <div className="space-y-1.5">
- <Label className="text-xs text-muted-foreground">Agent Name</Label>
- <Input
- autoFocus
- type="text"
- value={name}
- onChange={(e) => setName(e.target.value)}
- placeholder="e.g. Coding Agent"
- />
- </div>
-
- {/* Description */}
- <div className="space-y-1.5">
- <Label className="text-xs text-muted-foreground">Description</Label>
- <Input
- type="text"
- value={description}
- onChange={(e) => setDescription(e.target.value)}
- placeholder="What does this agent do?"
- />
- </div>
-
- {/* Runtime selector */}
- <div className="space-y-1.5">
- <Label className="text-xs text-muted-foreground">Runtime</Label>
- <Popover open={runtimeOpen} onOpenChange={setRuntimeOpen}>
- <PopoverTrigger
- disabled={!hasRuntime}
- className="flex w-full min-w-0 items-center gap-3 rounded-lg border border-border bg-background px-3 py-2.5 text-left text-sm transition-colors hover:bg-muted disabled:pointer-events-none disabled:opacity-50"
- >
- {selectedRuntime ? (
- <ProviderLogo
- provider={selectedRuntime.provider}
- className="h-4 w-4 shrink-0"
- />
- ) : (
- <div className="h-4 w-4 shrink-0 rounded-full bg-muted-foreground/30" />
- )}
- <div className="min-w-0 flex-1">
- <div className="flex items-center gap-2">
- <span className="truncate font-medium">
- {selectedRuntime?.name ?? "No runtime available"}
- </span>
- {selectedRuntime?.runtime_mode === "cloud" && (
- <span className="shrink-0 rounded bg-info/10 px-1.5 py-0.5 text-xs font-medium text-info">
- Cloud
- </span>
- )}
- </div>
- <div className="truncate text-xs text-muted-foreground">
- {selectedRuntime
- ? `${selectedRuntime.provider} · ${selectedRuntime.device_info}`
- : "Connect a runtime first"}
- </div>
- </div>
- <ChevronDown
- className={`h-4 w-4 shrink-0 text-muted-foreground transition-transform ${runtimeOpen ? "rotate-180" : ""}`}
- />
- </PopoverTrigger>
- <PopoverContent
- align="start"
- className="w-[var(--anchor-width)] max-h-60 overflow-y-auto p-1"
- >
- {runtimes.map((rt) => (
- <button
- key={rt.id}
- onClick={() => {
- setSelectedRuntimeId(rt.id);
- setRuntimeOpen(false);
- }}
- className={`flex w-full items-center gap-3 rounded-md px-3 py-2.5 text-left text-sm transition-colors ${
- rt.id === selectedRuntimeId
- ? "bg-accent"
- : "hover:bg-accent/50"
- }`}
- >
- <ProviderLogo
- provider={rt.provider}
- className="h-4 w-4 shrink-0"
- />
- <div className="min-w-0 flex-1">
- <div className="flex items-center gap-2">
- <span className="truncate font-medium">{rt.name}</span>
- {rt.runtime_mode === "cloud" && (
- <span className="shrink-0 rounded bg-info/10 px-1.5 py-0.5 text-xs font-medium text-info">
- Cloud
- </span>
- )}
- </div>
- <div className="truncate text-xs text-muted-foreground">
- {rt.provider} · {rt.device_info}
- </div>
- </div>
- <span
- className={`h-2 w-2 shrink-0 rounded-full ${
- rt.status === "online"
- ? "bg-success"
- : "bg-muted-foreground/40"
- }`}
- />
- </button>
- ))}
- </PopoverContent>
- </Popover>
- </div>
-
- {/* Visibility */}
- <div className="space-y-1.5">
- <Label className="text-xs text-muted-foreground">Visibility</Label>
- <div className="flex gap-2">
- <button
- type="button"
- onClick={() => setVisibility("workspace")}
- className={`flex flex-1 items-center gap-2 rounded-lg border px-3 py-2 text-sm transition-colors ${
- visibility === "workspace"
- ? "border-primary bg-primary/5"
- : "border-border hover:bg-muted"
- }`}
- >
- <Globe className="h-4 w-4 shrink-0 text-muted-foreground" />
- <div className="text-left">
- <div className="font-medium">Workspace</div>
- <div className="text-xs text-muted-foreground">
- All members can assign
- </div>
- </div>
- </button>
- <button
- type="button"
- onClick={() => setVisibility("private")}
- className={`flex flex-1 items-center gap-2 rounded-lg border px-3 py-2 text-sm transition-colors ${
- visibility === "private"
- ? "border-primary bg-primary/5"
- : "border-border hover:bg-muted"
- }`}
- >
- <Lock className="h-4 w-4 shrink-0 text-muted-foreground" />
- <div className="text-left">
- <div className="font-medium">Private</div>
- <div className="text-xs text-muted-foreground">
- Only you can assign
- </div>
- </div>
- </button>
- </div>
- </div>
- </Card>
- )}
-
- {/* Actions */}
- <div className="flex w-full flex-col items-center gap-3">
- {showForm ? (
- <>
- <Button
- className="w-full"
- size="lg"
- onClick={handleCreate}
- disabled={creating || !name.trim() || !selectedRuntime}
- >
- {creating ? "Creating..." : "Create Agent"}
- </Button>
- <button
- type="button"
- onClick={() => {
- setShowForm(false);
- setSelectedTemplateId(null);
- }}
- className="text-sm text-muted-foreground underline-offset-4 hover:underline"
- >
- Back to templates
- </button>
- </>
- ) : (
- <button
- type="button"
- onClick={onNext}
- className="text-sm text-muted-foreground underline-offset-4 hover:underline"
- >
- Skip for now
- </button>
- )}
- </div>
- </div>
- );
-}
diff --git a/packages/views/onboarding/step-complete.tsx b/packages/views/onboarding/step-complete.tsx
deleted file mode 100644
index 629c564f4d..0000000000
--- a/packages/views/onboarding/step-complete.tsx
+++ /dev/null
@@ -1,203 +0,0 @@
-"use client";
-
-import { useEffect, useRef, useState } from "react";
-import { Check, ArrowRight, Loader2, Bot } from "lucide-react";
-import { Button } from "@multica/ui/components/ui/button";
-import { Card } from "@multica/ui/components/ui/card";
-import { api } from "@multica/core/api";
-import type { Agent, Issue, CreateIssueRequest } from "@multica/core/types";
-
-interface OnboardingIssueDef {
- title: string;
- description: string;
- /** If true, assigned to the agent with status "todo" so it gets picked up */
- assignToAgent: boolean;
- status: "todo" | "backlog";
-}
-
-function getOnboardingIssues(): OnboardingIssueDef[] {
- return [
- {
- title: "Say hello to the team!",
- description: [
- "Welcome! This is your first automated task.",
- "",
- "Please introduce yourself to the team:",
- "- What's your name and role in this workspace?",
- "- What kinds of tasks can you help with?",
- "- Give 2–3 concrete examples of things the team can ask you to do",
- "",
- "---",
- "",
- "**Try it out!** After the agent responds, reply with one of these to see it in action:",
- '- "Review this function for bugs: `function add(a, b) { return a - b; }`"',
- '- "Draft a short description for a new onboarding feature"',
- '- "What are some best practices for writing clean commit messages?"',
- "",
- "This issue was automatically assigned to verify your agent is working end-to-end.",
- ].join("\n"),
- assignToAgent: true,
- status: "todo",
- },
- {
- title: "Set up your repository connection",
- description: [
- "Connect a code repository so agents can check out code and submit pull requests.",
- "",
- "**Steps:**",
- "1. Go to **Settings** in the sidebar",
- "2. Under **Repositories**, add a Git repository URL",
- "3. The agent daemon will sync the repo locally",
- "",
- "Once connected, your agents can clone, branch, and push code as part of any task.",
- ].join("\n"),
- assignToAgent: false,
- status: "backlog",
- },
- {
- title: "Create a skill for your agent",
- description: [
- "Skills are reusable instructions that make agents better at recurring tasks — deployments, code reviews, migrations, etc.",
- "",
- "**Note:** Skills already installed in your local runtime (e.g., `.claude/skills/`) are automatically available to agents — no need to re-upload them. Workspace skills here are for sharing knowledge across your team.",
- "",
- "**Steps:**",
- "1. Go to **Skills** in the sidebar",
- "2. Click **New Skill**",
- "3. Write a description and instructions (e.g., \"Code Review\" with your team's style guide)",
- "4. Assign the skill to an agent in the agent's settings",
- "",
- "Every skill you create compounds your team's capabilities over time.",
- ].join("\n"),
- assignToAgent: false,
- status: "backlog",
- },
- {
- title: "Invite a teammate",
- description: [
- "Multica works best with a team. Invite a colleague to your workspace so you can collaborate on issues and share agents.",
- "",
- "**Steps:**",
- "1. Go to **Settings → Members**",
- "2. Click **Invite** and enter their email",
- "3. They'll get access to the workspace, all agents, and the issue board",
- ].join("\n"),
- assignToAgent: false,
- status: "backlog",
- },
- ];
-}
-
-export function StepComplete({
- wsId,
- agent,
- onEnter,
-}: {
- wsId: string;
- agent: Agent | null;
- onEnter: () => void;
-}) {
- const [createdIssues, setCreatedIssues] = useState<Issue[]>([]);
- const [loading, setLoading] = useState(true);
- const didCreate = useRef(false);
-
- useEffect(() => {
- if (didCreate.current) return;
- didCreate.current = true;
-
- async function createOnboardingIssues() {
- const defs = getOnboardingIssues();
- const issues: Issue[] = [];
-
- for (const def of defs) {
- try {
- const req: CreateIssueRequest = {
- title: def.title,
- description: def.description,
- status: def.status,
- };
- if (def.assignToAgent && agent) {
- req.assignee_type = "agent";
- req.assignee_id = agent.id;
- }
- const issue = await api.createIssue(req);
- issues.push(issue);
- } catch {
- // Best-effort — continue with remaining issues
- }
- }
-
- setCreatedIssues(issues);
- setLoading(false);
- }
-
- createOnboardingIssues();
- }, [agent, wsId]);
-
- return (
- <div className="flex w-full max-w-md flex-col items-center gap-8">
- {/* Success icon */}
- <div className="flex h-16 w-16 items-center justify-center rounded-full bg-success/10">
- <Check className="h-8 w-8 text-success" />
- </div>
-
- <div className="text-center">
- <h1 className="text-3xl font-semibold tracking-tight">
- You&apos;re all set!
- </h1>
- <p className="mt-2 text-muted-foreground">
- {agent
- ? `Your workspace is ready and ${agent.name} is picking up its first task.`
- : "Your workspace is ready. Create issues and assign them to agents to get started."}
- </p>
- </div>
-
- {/* Created issues */}
- {loading ? (
- <div className="flex items-center gap-2 text-sm text-muted-foreground">
- <Loader2 className="h-4 w-4 animate-spin" />
- <span>Setting up your workspace...</span>
- </div>
- ) : (
- createdIssues.length > 0 && (
- <Card className="w-full divide-y">
- {createdIssues.map((issue) => (
- <div
- key={issue.id}
- className="flex items-center gap-3 px-4 py-3"
- >
- <div className="min-w-0 flex-1">
- <div className="truncate text-sm font-medium">
- {issue.identifier} {issue.title}
- </div>
- <div className="truncate text-xs text-muted-foreground">
- {issue.assignee_id && agent
- ? `Assigned to ${agent.name}`
- : issue.status === "todo"
- ? "To do"
- : "Backlog"}
- </div>
- </div>
- {issue.assignee_id && agent && (
- <div className="flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-violet-100 dark:bg-violet-900/30">
- <Bot className="h-3.5 w-3.5 text-violet-600 dark:text-violet-400" />
- </div>
- )}
- </div>
- ))}
- </Card>
- )
- )}
-
- <Button
- className="w-full"
- size="lg"
- onClick={onEnter}
- disabled={loading}
- >
- Go to Workspace
- <ArrowRight className="ml-2 h-4 w-4" />
- </Button>
- </div>
- );
-}
diff --git a/packages/views/onboarding/step-runtime.tsx b/packages/views/onboarding/step-runtime.tsx
deleted file mode 100644
index 13c6d9cc01..0000000000
--- a/packages/views/onboarding/step-runtime.tsx
+++ /dev/null
@@ -1,204 +0,0 @@
-"use client";
-
-import { useState, useCallback, useMemo } from "react";
-import { useQuery, useQueryClient } from "@tanstack/react-query";
-import { Check, Copy, Terminal, Loader2 } from "lucide-react";
-import { Button } from "@multica/ui/components/ui/button";
-import { Card, CardContent } from "@multica/ui/components/ui/card";
-import { useWSEvent } from "@multica/core/realtime";
-import { api } from "@multica/core/api";
-import { ProviderLogo } from "../runtimes/components/provider-logo";
-import {
- runtimeListOptions,
- runtimeKeys,
-} from "@multica/core/runtimes/queries";
-
-const CLOUD_HOST = "multica.ai";
-
-const INSTALL_STEP = {
- label: "Install the Multica CLI",
- cmd: "curl -fsSL https://raw.githubusercontent.com/multica-ai/multica/main/scripts/install.sh | bash",
-};
-
-function isCloudEnvironment(): boolean {
- if (typeof window === "undefined") return true;
- return window.location.hostname.endsWith(CLOUD_HOST);
-}
-
-function buildSetupCommand(): string {
- if (isCloudEnvironment()) return "multica setup";
-
- const appUrl = typeof window !== "undefined" ? window.location.origin : "";
- const apiBaseUrl = api.getBaseUrl?.() ?? "";
- const serverUrl = apiBaseUrl || appUrl;
-
- if (!serverUrl || serverUrl === "http://localhost:8080") {
- // Default self-host — no flags needed
- return "multica setup self-host";
- }
-
- const parts = ["multica setup self-host"];
- parts.push(`--server-url ${serverUrl}`);
- if (appUrl && appUrl !== serverUrl) {
- parts.push(`--app-url ${appUrl}`);
- }
- return parts.join(" ");
-}
-
-function CopyButton({ text }: { text: string }) {
- const [copied, setCopied] = useState(false);
-
- const handleCopy = () => {
- navigator.clipboard.writeText(text);
- setCopied(true);
- setTimeout(() => setCopied(false), 2000);
- };
-
- return (
- <button
- type="button"
- onClick={handleCopy}
- className="shrink-0 rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground transition-colors"
- >
- {copied ? (
- <Check className="h-3.5 w-3.5 text-success" />
- ) : (
- <Copy className="h-3.5 w-3.5" />
- )}
- </button>
- );
-}
-
-export function StepRuntime({
- wsId,
- onNext,
-}: {
- wsId: string;
- onNext: () => void;
-}) {
- const qc = useQueryClient();
-
- const setupSteps = useMemo(
- () => [
- INSTALL_STEP,
- { label: "Set up and start the daemon", cmd: buildSetupCommand() },
- ],
- [],
- );
-
- const { data: runtimes = [] } = useQuery(runtimeListOptions(wsId));
-
- const handleDaemonEvent = useCallback(() => {
- qc.invalidateQueries({ queryKey: runtimeKeys.all(wsId) });
- }, [qc, wsId]);
-
- useWSEvent("daemon:register", handleDaemonEvent);
-
- const hasRuntimes = runtimes.length > 0;
-
- return (
- <div className="flex w-full max-w-xl flex-col items-center gap-8">
- <div className="text-center">
- <h1 className="text-3xl font-semibold tracking-tight">
- Connect a Runtime
- </h1>
- <p className="mt-2 text-muted-foreground">
- Install the CLI and run the setup command below to connect your
- machine. The daemon auto-detects agent CLIs (Claude Code, Codex,
- etc.) on your PATH.
- </p>
- </div>
-
- {/* Commands */}
- <Card className="w-full">
- <CardContent className="space-y-3 pt-4">
- {setupSteps.map((step, i) => (
- <div key={i}>
- <p className="mb-1.5 text-xs text-muted-foreground">
- {i + 1}. {step.label}
- </p>
- <div className="flex items-start gap-2 rounded-lg bg-muted px-3 py-2.5 font-mono text-sm">
- <Terminal className="mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground" />
- <code className="min-w-0 flex-1 break-all whitespace-pre-wrap">
- {step.cmd}
- </code>
- <CopyButton text={step.cmd} />
- </div>
- </div>
- ))}
- <p className="pt-1 text-xs text-muted-foreground">
- The setup command handles authentication, configuration, and daemon
- startup — all in one step.
- </p>
- </CardContent>
- </Card>
-
- {/* Connected runtimes */}
- <div className="w-full space-y-3">
- <div className="flex items-center gap-2 text-sm">
- {hasRuntimes ? (
- <>
- <div className="h-2 w-2 rounded-full bg-success" />
- <span className="font-medium">
- {runtimes.length} runtime{runtimes.length > 1 ? "s" : ""}{" "}
- connected
- </span>
- </>
- ) : (
- <>
- <Loader2 className="h-4 w-4 animate-spin text-muted-foreground" />
- <span className="text-muted-foreground">
- Waiting for connection...
- </span>
- </>
- )}
- </div>
-
- {hasRuntimes && (
- <Card className="w-full">
- <CardContent className="divide-y pt-0">
- {runtimes.map((rt) => (
- <div
- key={rt.id}
- className="flex items-center gap-3 py-3 first:pt-4 last:pb-4"
- >
- <span
- className={`h-2 w-2 shrink-0 rounded-full ${
- rt.status === "online"
- ? "bg-success"
- : "bg-muted-foreground/40"
- }`}
- />
- <div className="min-w-0 flex-1">
- <div className="flex items-center gap-2">
- <span className="truncate text-sm font-medium">
- {rt.name}
- </span>
- {rt.runtime_mode === "cloud" && (
- <span className="shrink-0 rounded bg-info/10 px-1.5 py-0.5 text-xs font-medium text-info">
- Cloud
- </span>
- )}
- </div>
- <div className="truncate text-xs text-muted-foreground">
- {rt.provider} · {rt.device_info}
- </div>
- </div>
- <ProviderLogo
- provider={rt.provider}
- className="h-5 w-5 shrink-0"
- />
- </div>
- ))}
- </CardContent>
- </Card>
- )}
- </div>
-
- {/* Actions */}
- <Button className="w-full" size="lg" onClick={onNext}>
- {hasRuntimes ? "Continue" : "Skip for now"}
- </Button>
- </div>
- );
-}
diff --git a/packages/views/onboarding/step-workspace.test.tsx b/packages/views/onboarding/step-workspace.test.tsx
deleted file mode 100644
index 043c773ee8..0000000000
--- a/packages/views/onboarding/step-workspace.test.tsx
+++ /dev/null
@@ -1,58 +0,0 @@
-import { describe, expect, it, beforeEach, vi } from "vitest";
-import { render, screen, waitFor } from "@testing-library/react";
-import userEvent from "@testing-library/user-event";
-
-const mockCreateWorkspaceMutate = vi.hoisted(() => vi.fn());
-const mockToastError = vi.hoisted(() => vi.fn());
-
-vi.mock("@multica/core/workspace/mutations", () => ({
- useCreateWorkspace: () => ({
- mutate: mockCreateWorkspaceMutate,
- isPending: false,
- }),
-}));
-
-vi.mock("sonner", () => ({
- toast: {
- error: mockToastError,
- },
-}));
-
-import { StepWorkspace } from "./step-workspace";
-
-describe("StepWorkspace", () => {
- beforeEach(() => {
- vi.clearAllMocks();
- });
-
- it("asks the user to change the slug on conflict", async () => {
- const user = userEvent.setup();
- mockCreateWorkspaceMutate.mockImplementation(
- (
- _data: unknown,
- options: { onError: (error: unknown) => void },
- ) => {
- options.onError({ status: 409 });
- },
- );
-
- render(<StepWorkspace onNext={vi.fn()} />);
-
- await user.type(screen.getByPlaceholderText("My Team"), "My Team");
- await user.click(screen.getByRole("button", { name: "Create Workspace" }));
-
- await waitFor(() => {
- expect(
- screen.getByText("That workspace URL is already taken."),
- ).toBeInTheDocument();
- });
-
- expect(mockToastError).toHaveBeenCalledWith(
- "Choose a different workspace URL",
- );
- expect(mockCreateWorkspaceMutate).toHaveBeenCalledWith(
- { name: "My Team", slug: "my-team" },
- expect.any(Object),
- );
- });
-});
diff --git a/packages/views/package.json b/packages/views/package.json
index d28f4a7218..71ee902619 100644
--- a/packages/views/package.json
+++ b/packages/views/package.json
@@ -28,12 +28,15 @@
"./inbox": "./inbox/index.ts",
"./runtimes": "./runtimes/index.ts",
"./workspace/workspace-avatar": "./workspace/workspace-avatar.tsx",
+ "./workspace/create-workspace-form": "./workspace/create-workspace-form.tsx",
+ "./workspace/no-access-page": "./workspace/no-access-page.tsx",
+ "./workspace/new-workspace-page": "./workspace/new-workspace-page.tsx",
+ "./workspace/use-workspace-seen": "./workspace/use-workspace-seen.ts",
"./layout": "./layout/index.ts",
"./auth": "./auth/index.ts",
"./search": "./search/index.ts",
"./chat": "./chat/index.ts",
"./settings": "./settings/index.ts",
- "./onboarding": "./onboarding/index.ts",
"./invite": "./invite/index.ts",
"./platform": "./platform/index.ts"
},
diff --git a/packages/views/platform/use-immersive-mode.ts b/packages/views/platform/use-immersive-mode.ts
index b0fd39feda..4409a1d7d2 100644
--- a/packages/views/platform/use-immersive-mode.ts
+++ b/packages/views/platform/use-immersive-mode.ts
@@ -13,9 +13,9 @@ function getDesktopAPI(): ImmersiveCapableAPI | undefined {
* Enter "immersive" mode for the lifetime of the component that calls it.
*
* On macOS desktop this hides the traffic-light window controls so full-screen
- * modals (create-workspace, onboarding, etc.) can place UI in the top-left
- * corner without fighting the native controls' hit-test. On web or non-macOS
- * desktop this is a no-op.
+ * modals (e.g. create-workspace) can place UI in the top-left corner without
+ * fighting the native controls' hit-test. On web or non-macOS desktop this
+ * is a no-op.
*/
export function useImmersiveMode(): void {
useEffect(() => {
diff --git a/packages/views/settings/components/workspace-tab.tsx b/packages/views/settings/components/workspace-tab.tsx
index e88cbe5175..2fdf6d9f48 100644
--- a/packages/views/settings/components/workspace-tab.tsx
+++ b/packages/views/settings/components/workspace-tab.tsx
@@ -45,9 +45,10 @@ export function WorkspaceTab() {
/**
* After leaving/deleting the current workspace, send the user to a safe URL:
- * another workspace they still have access to, or onboarding if they have none.
- * The list is freshly fetched (staleTime: 0) because the cache still contains
- * the just-removed workspace until the background invalidation resolves.
+ * another workspace they still have access to, or /new-workspace if none
+ * remain. The list is freshly fetched (staleTime: 0) because the cache still
+ * contains the just-removed workspace until the background invalidation
+ * resolves.
*/
const navigateAwayFromCurrentWorkspace = async () => {
const wsList = await qc.fetchQuery({
@@ -57,7 +58,7 @@ export function WorkspaceTab() {
const remaining = wsList.filter((w) => w.id !== workspace?.id);
const next = remaining[0];
navigation.push(
- next ? paths.workspace(next.slug).issues() : paths.onboarding(),
+ next ? paths.workspace(next.slug).issues() : paths.newWorkspace(),
);
};
diff --git a/packages/views/workspace/create-workspace-form.test.tsx b/packages/views/workspace/create-workspace-form.test.tsx
new file mode 100644
index 0000000000..f9234e024b
--- /dev/null
+++ b/packages/views/workspace/create-workspace-form.test.tsx
@@ -0,0 +1,85 @@
+import { describe, expect, it, vi, beforeEach } from "vitest";
+import { render, screen, fireEvent, waitFor } from "@testing-library/react";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { CreateWorkspaceForm } from "./create-workspace-form";
+
+const mockMutate = vi.fn();
+vi.mock("@multica/core/workspace/mutations", () => ({
+ useCreateWorkspace: () => ({ mutate: mockMutate, isPending: false }),
+}));
+
+function renderForm(onSuccess = vi.fn()) {
+ const qc = new QueryClient();
+ return render(
+ <QueryClientProvider client={qc}>
+ <CreateWorkspaceForm onSuccess={onSuccess} />
+ </QueryClientProvider>,
+ );
+}
+
+describe("CreateWorkspaceForm", () => {
+ beforeEach(() => mockMutate.mockReset());
+
+ it("auto-generates slug from name until user edits slug", () => {
+ renderForm();
+ fireEvent.change(screen.getByLabelText(/workspace name/i), {
+ target: { value: "Acme Corp" },
+ });
+ expect(screen.getByDisplayValue("acme-corp")).toBeInTheDocument();
+ });
+
+ it("stops auto-generating slug once user edits slug directly", () => {
+ renderForm();
+ fireEvent.change(screen.getByLabelText(/workspace url/i), {
+ target: { value: "custom" },
+ });
+ fireEvent.change(screen.getByLabelText(/workspace name/i), {
+ target: { value: "Different Name" },
+ });
+ expect(screen.getByDisplayValue("custom")).toBeInTheDocument();
+ });
+
+ it("calls onSuccess with the created workspace", async () => {
+ const onSuccess = vi.fn();
+ mockMutate.mockImplementation((_args, opts) => {
+ opts?.onSuccess?.({ id: "ws-1", slug: "acme", name: "Acme" });
+ });
+ renderForm(onSuccess);
+ fireEvent.change(screen.getByLabelText(/workspace name/i), {
+ target: { value: "Acme" },
+ });
+ fireEvent.click(screen.getByRole("button", { name: /create workspace/i }));
+ await waitFor(() =>
+ expect(onSuccess).toHaveBeenCalledWith(
+ expect.objectContaining({ slug: "acme" }),
+ ),
+ );
+ });
+
+ it("shows slug-conflict error inline on 409", async () => {
+ mockMutate.mockImplementation((_args, opts) => {
+ opts?.onError?.({ status: 409 });
+ });
+ renderForm();
+ fireEvent.change(screen.getByLabelText(/workspace name/i), {
+ target: { value: "Taken" },
+ });
+ fireEvent.click(screen.getByRole("button", { name: /create workspace/i }));
+ await waitFor(() =>
+ expect(screen.getByText(/already taken/i)).toBeInTheDocument(),
+ );
+ });
+
+ it("disables submit when slug has invalid format", () => {
+ renderForm();
+ fireEvent.change(screen.getByLabelText(/workspace name/i), {
+ target: { value: "Valid Name" },
+ });
+ fireEvent.change(screen.getByLabelText(/workspace url/i), {
+ target: { value: "Invalid Slug!" },
+ });
+ expect(
+ screen.getByRole("button", { name: /create workspace/i }),
+ ).toBeDisabled();
+ });
+});
diff --git a/packages/views/onboarding/step-workspace.tsx b/packages/views/workspace/create-workspace-form.tsx
similarity index 50%
rename from packages/views/onboarding/step-workspace.tsx
rename to packages/views/workspace/create-workspace-form.tsx
index 470887b523..61d9e7ae8e 100644
--- a/packages/views/onboarding/step-workspace.tsx
+++ b/packages/views/workspace/create-workspace-form.tsx
@@ -7,20 +7,24 @@ import { Label } from "@multica/ui/components/ui/label";
import { Button } from "@multica/ui/components/ui/button";
import { Card, CardContent } from "@multica/ui/components/ui/card";
import { useCreateWorkspace } from "@multica/core/workspace/mutations";
+import type { Workspace } from "@multica/core/types";
import {
WORKSPACE_SLUG_CONFLICT_ERROR,
WORKSPACE_SLUG_FORMAT_ERROR,
WORKSPACE_SLUG_REGEX,
isWorkspaceSlugConflict,
nameToWorkspaceSlug,
-} from "../workspace/slug";
+} from "./slug";
-export function StepWorkspace({ onNext }: { onNext: () => void }) {
+export interface CreateWorkspaceFormProps {
+ onSuccess: (workspace: Workspace) => void;
+}
+
+export function CreateWorkspaceForm({ onSuccess }: CreateWorkspaceFormProps) {
const createWorkspace = useCreateWorkspace();
const [name, setName] = useState("");
const [slug, setSlug] = useState("");
const [slugServerError, setSlugServerError] = useState<string | null>(null);
- // Track whether the user has manually edited the slug field.
const slugTouched = useRef(false);
const slugValidationError =
@@ -28,7 +32,6 @@ export function StepWorkspace({ onNext }: { onNext: () => void }) {
? WORKSPACE_SLUG_FORMAT_ERROR
: null;
const slugError = slugValidationError ?? slugServerError;
-
const canSubmit =
name.trim().length > 0 && slug.trim().length > 0 && !slugError;
@@ -51,7 +54,7 @@ export function StepWorkspace({ onNext }: { onNext: () => void }) {
createWorkspace.mutate(
{ name: name.trim(), slug: slug.trim() },
{
- onSuccess: () => onNext(),
+ onSuccess,
onError: (error) => {
if (isWorkspaceSlugConflict(error)) {
setSlugServerError(WORKSPACE_SLUG_CONFLICT_ERROR);
@@ -65,59 +68,49 @@ export function StepWorkspace({ onNext }: { onNext: () => void }) {
};
return (
- <div className="flex w-full max-w-md flex-col items-center gap-8">
- <div className="text-center">
- <h1 className="text-3xl font-semibold tracking-tight">
- Welcome to Multica
- </h1>
- <p className="mt-2 text-muted-foreground">
- Create your workspace to start building with AI agents.
- </p>
- </div>
-
- <Card className="w-full">
- <CardContent className="space-y-4 pt-6">
- <div className="space-y-1.5">
- <Label>Workspace Name</Label>
+ <Card className="w-full">
+ <CardContent className="space-y-4 pt-6">
+ <div className="space-y-1.5">
+ <Label htmlFor="ws-name">Workspace Name</Label>
+ <Input
+ id="ws-name"
+ autoFocus
+ type="text"
+ value={name}
+ onChange={(e) => handleNameChange(e.target.value)}
+ placeholder="My Workspace"
+ onKeyDown={(e) => e.key === "Enter" && handleCreate()}
+ />
+ </div>
+ <div className="space-y-1.5">
+ <Label htmlFor="ws-slug">Workspace URL</Label>
+ <div className="flex items-center gap-0 rounded-md border bg-background focus-within:ring-2 focus-within:ring-ring">
+ <span className="pl-3 text-sm text-muted-foreground select-none">
+ multica.ai/
+ </span>
<Input
- autoFocus
+ id="ws-slug"
type="text"
- value={name}
- onChange={(e) => handleNameChange(e.target.value)}
- placeholder="My Team"
+ value={slug}
+ onChange={(e) => handleSlugChange(e.target.value)}
+ placeholder="my-workspace"
+ className="border-0 shadow-none focus-visible:ring-0"
onKeyDown={(e) => e.key === "Enter" && handleCreate()}
/>
</div>
- <div className="space-y-1.5">
- <Label>Workspace URL</Label>
- <div className="flex items-center gap-0 rounded-md border bg-background focus-within:ring-2 focus-within:ring-ring">
- <span className="pl-3 text-sm text-muted-foreground select-none">
- multica.ai/
- </span>
- <Input
- type="text"
- value={slug}
- onChange={(e) => handleSlugChange(e.target.value)}
- placeholder="my-team"
- className="border-0 shadow-none focus-visible:ring-0"
- onKeyDown={(e) => e.key === "Enter" && handleCreate()}
- />
- </div>
- {slugError && (
- <p className="text-xs text-destructive">{slugError}</p>
- )}
- </div>
- </CardContent>
- </Card>
-
- <Button
- className="w-full"
- size="lg"
- onClick={handleCreate}
- disabled={createWorkspace.isPending || !canSubmit}
- >
- {createWorkspace.isPending ? "Creating..." : "Create Workspace"}
- </Button>
- </div>
+ {slugError && (
+ <p className="text-xs text-destructive">{slugError}</p>
+ )}
+ </div>
+ <Button
+ className="w-full"
+ size="lg"
+ onClick={handleCreate}
+ disabled={createWorkspace.isPending || !canSubmit}
+ >
+ {createWorkspace.isPending ? "Creating..." : "Create workspace"}
+ </Button>
+ </CardContent>
+ </Card>
);
}
diff --git a/packages/views/workspace/new-workspace-page.tsx b/packages/views/workspace/new-workspace-page.tsx
new file mode 100644
index 0000000000..a5ccca43c9
--- /dev/null
+++ b/packages/views/workspace/new-workspace-page.tsx
@@ -0,0 +1,32 @@
+"use client";
+
+import type { Workspace } from "@multica/core/types";
+import { CreateWorkspaceForm } from "./create-workspace-form";
+
+/**
+ * Full-page shell for the /new-workspace route. Shared between web
+ * (Next.js) and desktop (react-router) so the two apps can't drift.
+ * Callers provide the onSuccess handler — that's the only app-specific
+ * piece, because each app uses its own navigation primitive.
+ */
+export function NewWorkspacePage({
+ onSuccess,
+}: {
+ onSuccess: (workspace: Workspace) => void;
+}) {
+ return (
+ <div className="flex min-h-svh flex-col items-center justify-center bg-background px-6 py-12">
+ <div className="flex w-full max-w-md flex-col items-center gap-6">
+ <div className="text-center">
+ <h1 className="text-3xl font-semibold tracking-tight">
+ Welcome to Multica
+ </h1>
+ <p className="mt-2 text-muted-foreground">
+ Create your workspace to get started.
+ </p>
+ </div>
+ <CreateWorkspaceForm onSuccess={onSuccess} />
+ </div>
+ </div>
+ );
+}
diff --git a/packages/views/workspace/no-access-page.test.tsx b/packages/views/workspace/no-access-page.test.tsx
new file mode 100644
index 0000000000..4237e8824e
--- /dev/null
+++ b/packages/views/workspace/no-access-page.test.tsx
@@ -0,0 +1,33 @@
+import { describe, expect, it, vi, beforeEach } from "vitest";
+import { render, screen, fireEvent } from "@testing-library/react";
+import { NoAccessPage } from "./no-access-page";
+
+const navigate = vi.fn();
+vi.mock("../navigation", () => ({
+ useNavigation: () => ({ push: navigate, replace: navigate }),
+}));
+
+describe("NoAccessPage", () => {
+ beforeEach(() => navigate.mockReset());
+
+ it("renders generic message that doesn't leak existence", () => {
+ render(<NoAccessPage />);
+ expect(
+ screen.getByText(/doesn't exist or you don't have access/i),
+ ).toBeInTheDocument();
+ });
+
+ it("navigates to root on 'Go to my workspaces'", () => {
+ render(<NoAccessPage />);
+ fireEvent.click(screen.getByRole("button", { name: /go to my workspaces/i }));
+ expect(navigate).toHaveBeenCalledWith("/");
+ });
+
+ it("navigates to login on 'Sign in as a different user'", () => {
+ render(<NoAccessPage />);
+ fireEvent.click(
+ screen.getByRole("button", { name: /sign in as a different user/i }),
+ );
+ expect(navigate).toHaveBeenCalledWith("/login");
+ });
+});
diff --git a/packages/views/workspace/no-access-page.tsx b/packages/views/workspace/no-access-page.tsx
new file mode 100644
index 0000000000..14dfb74ef3
--- /dev/null
+++ b/packages/views/workspace/no-access-page.tsx
@@ -0,0 +1,35 @@
+"use client";
+
+import { Button } from "@multica/ui/components/ui/button";
+import { paths } from "@multica/core/paths";
+import { useNavigation } from "../navigation";
+
+/**
+ * Rendered when the workspace slug in the URL does not resolve to a workspace
+ * the current user can access. Deliberately doesn't distinguish "workspace
+ * doesn't exist" from "workspace exists but I'm not a member" — showing
+ * either would let attackers enumerate workspace slugs.
+ */
+export function NoAccessPage() {
+ const nav = useNavigation();
+ return (
+ <div className="flex min-h-svh flex-col items-center justify-center gap-6 px-6 text-center">
+ <div className="space-y-2">
+ <h1 className="text-2xl font-semibold tracking-tight">
+ Workspace not available
+ </h1>
+ <p className="max-w-md text-muted-foreground">
+ This workspace doesn't exist or you don't have access.
+ </p>
+ </div>
+ <div className="flex flex-col gap-2 sm:flex-row">
+ <Button onClick={() => nav.push(paths.root())}>
+ Go to my workspaces
+ </Button>
+ <Button variant="outline" onClick={() => nav.push(paths.login())}>
+ Sign in as a different user
+ </Button>
+ </div>
+ </div>
+ );
+}
diff --git a/packages/views/workspace/use-workspace-seen.test.ts b/packages/views/workspace/use-workspace-seen.test.ts
new file mode 100644
index 0000000000..6640509899
--- /dev/null
+++ b/packages/views/workspace/use-workspace-seen.test.ts
@@ -0,0 +1,45 @@
+import { describe, expect, it } from "vitest";
+import { renderHook } from "@testing-library/react";
+import { useWorkspaceSeen } from "./use-workspace-seen";
+
+describe("useWorkspaceSeen", () => {
+ it("returns false when slug has never resolved", () => {
+ const { result } = renderHook(() => useWorkspaceSeen("acme", false));
+ expect(result.current).toBe(false);
+ });
+
+ it("returns true after slug resolved at least once", () => {
+ const { result, rerender } = renderHook(
+ ({ slug, resolved }) => useWorkspaceSeen(slug, resolved),
+ { initialProps: { slug: "acme", resolved: true } },
+ );
+ expect(result.current).toBe(true);
+
+ // Workspace disappears (e.g. just deleted) — hook still reports "seen"
+ rerender({ slug: "acme", resolved: false });
+ expect(result.current).toBe(true);
+ });
+
+ it("remembers multiple slugs independently", () => {
+ const { result, rerender } = renderHook(
+ ({ slug, resolved }) => useWorkspaceSeen(slug, resolved),
+ { initialProps: { slug: "acme", resolved: true } },
+ );
+ // Switch to a different resolved slug
+ rerender({ slug: "beta", resolved: true });
+ expect(result.current).toBe(true);
+
+ // Now check a never-seen slug — should not leak positive
+ rerender({ slug: "gamma", resolved: false });
+ expect(result.current).toBe(false);
+
+ // Back to "acme" (which we saw first) — still seen
+ rerender({ slug: "acme", resolved: false });
+ expect(result.current).toBe(true);
+ });
+
+ it("returns false for undefined slug", () => {
+ const { result } = renderHook(() => useWorkspaceSeen(undefined, true));
+ expect(result.current).toBe(false);
+ });
+});
diff --git a/packages/views/workspace/use-workspace-seen.ts b/packages/views/workspace/use-workspace-seen.ts
new file mode 100644
index 0000000000..bc51602467
--- /dev/null
+++ b/packages/views/workspace/use-workspace-seen.ts
@@ -0,0 +1,29 @@
+import { useRef } from "react";
+
+/**
+ * Tracks workspace slugs that have successfully resolved to a workspace at
+ * least once during this layout instance's lifetime. Used to distinguish:
+ *
+ * - "Active workspace was just removed" (slug seen before, now gone) —
+ * the caller is typically navigating away (delete/leave mutation, or
+ * realtime workspace:deleted event). Rendering NoAccessPage during
+ * that window causes a jarring flash of "Workspace not available"
+ * before the navigate completes. Return `true` so the layout can
+ * render null while the navigate resolves.
+ *
+ * - "URL points to a workspace I've never had access to" (slug never
+ * seen) — genuine access-denial case. Return `false` so the layout
+ * can render NoAccessPage with its recovery buttons.
+ *
+ * Scope: one Set per layout instance. If the workspace layout unmounts
+ * (e.g. desktop tab close), the memory is discarded — correct, since the
+ * user lost that view anyway.
+ */
+export function useWorkspaceSeen(
+ slug: string | undefined,
+ resolved: boolean,
+): boolean {
+ const seenRef = useRef<Set<string>>(new Set());
+ if (resolved && slug) seenRef.current.add(slug);
+ return slug ? seenRef.current.has(slug) : false;
+}
diff --git a/server/cmd/multica/cmd_login.go b/server/cmd/multica/cmd_login.go
index 9930391002..ab9b10cbfa 100644
--- a/server/cmd/multica/cmd_login.go
+++ b/server/cmd/multica/cmd_login.go
@@ -77,7 +77,7 @@ func autoWatchWorkspaces(cmd *cobra.Command) error {
if len(workspaces) == 0 {
var err error
- workspaces, err = waitForOnboarding(cmd, client)
+ workspaces, err = waitForWorkspaceCreation(cmd, client)
if err != nil {
return err
}
@@ -110,9 +110,9 @@ func autoWatchWorkspaces(cmd *cobra.Command) error {
return nil
}
-// waitForOnboarding opens the web onboarding page and polls until the user
-// creates a workspace, returning the new workspace list.
-func waitForOnboarding(cmd *cobra.Command, client *cli.APIClient) ([]struct {
+// waitForWorkspaceCreation opens the web workspace-creation page and polls
+// until the user creates a workspace, returning the new workspace list.
+func waitForWorkspaceCreation(cmd *cobra.Command, client *cli.APIClient) ([]struct {
ID string `json:"id"`
Name string `json:"name"`
}, error) {
@@ -125,13 +125,13 @@ func waitForOnboarding(cmd *cobra.Command, client *cli.APIClient) ([]struct {
return nil, nil
}
- onboardingURL := appURL + "/onboarding"
+ createWorkspaceURL := appURL + "/new-workspace"
- fmt.Fprintln(os.Stderr, "\nNo workspaces found. Opening onboarding in your browser...")
- if err := openBrowser(onboardingURL); err != nil {
+ fmt.Fprintln(os.Stderr, "\nNo workspaces found. Opening workspace creation in your browser...")
+ if err := openBrowser(createWorkspaceURL); err != nil {
fmt.Fprintf(os.Stderr, "Could not open browser automatically.\n")
}
- fmt.Fprintf(os.Stderr, "If the browser didn't open, visit:\n %s\n", onboardingURL)
+ fmt.Fprintf(os.Stderr, "If the browser didn't open, visit:\n %s\n", createWorkspaceURL)
fmt.Fprintln(os.Stderr, "\nWaiting for workspace creation...")
// Poll until a workspace appears or timeout (5 minutes).
diff --git a/server/cmd/server/integration_test.go b/server/cmd/server/integration_test.go
index 042393a13f..dbce566c5d 100644
--- a/server/cmd/server/integration_test.go
+++ b/server/cmd/server/integration_test.go
@@ -347,7 +347,7 @@ func TestVerifyCodeNewUserHasNoWorkspace(t *testing.T) {
}
readJSON(t, resp, &loginResp)
- // New users should have no workspaces (onboarding creates one)
+ // New users should have no workspaces (/new-workspace creates one)
req, _ := http.NewRequest("GET", testServer.URL+"/api/workspaces", nil)
req.Header.Set("Authorization", "Bearer "+loginResp.Token)
workspacesResp, err := http.DefaultClient.Do(req)
diff --git a/server/internal/daemon/daemon.go b/server/internal/daemon/daemon.go
index d0215283c2..32a4fbe66b 100644
--- a/server/internal/daemon/daemon.go
+++ b/server/internal/daemon/daemon.go
@@ -91,13 +91,15 @@ func (d *Daemon) Run(ctx context.Context) error {
return err
}
- // Fetch all user workspaces from the API and register runtimes.
+ // Fetch all user workspaces from the API and register runtimes for any
+ // that exist. Zero workspaces is a valid state — a newly-signed-up user
+ // may start the daemon before creating their first workspace. The
+ // workspaceSyncLoop below polls every 30s and will register runtimes
+ // when a workspace appears, so the daemon stays useful as a long-lived
+ // background process rather than crashing at startup.
if err := d.syncWorkspacesFromAPI(ctx); err != nil {
return err
}
- if len(d.allRuntimeIDs()) == 0 {
- return fmt.Errorf("no runtimes registered")
- }
// Deregister runtimes on shutdown (uses a fresh context since ctx will be cancelled).
defer d.deregisterRuntimes()
diff --git a/server/internal/handler/handler_test.go b/server/internal/handler/handler_test.go
index c7e328f1be..29973444a4 100644
--- a/server/internal/handler/handler_test.go
+++ b/server/internal/handler/handler_test.go
@@ -854,7 +854,7 @@ func TestVerifyCodeNewUserHasNoWorkspace(t *testing.T) {
t.Fatalf("GetUserByEmail: %v", err)
}
- // New users should have no workspaces (onboarding creates one)
+ // New users should have no workspaces (/new-workspace creates one)
workspaces, err := testHandler.Queries.ListWorkspaces(ctx, user.ID)
if err != nil {
t.Fatalf("ListWorkspaces: %v", err)
diff --git a/server/internal/handler/workspace_reserved_slugs.go b/server/internal/handler/workspace_reserved_slugs.go
index 9ad867bf61..d5416ef020 100644
--- a/server/internal/handler/workspace_reserved_slugs.go
+++ b/server/internal/handler/workspace_reserved_slugs.go
@@ -7,12 +7,13 @@ package handler
// Keep this list in sync with packages/core/paths/reserved-slugs.ts.
var reservedSlugs = map[string]bool{
// Auth + onboarding routes
- "login": true,
- "logout": true,
- "signup": true,
- "onboarding": true,
- "invite": true,
- "auth": true,
+ "login": true,
+ "logout": true,
+ "signup": true,
+ "onboarding": true,
+ "new-workspace": true,
+ "invite": true,
+ "auth": true,
// Reserved for future platform routes
"api": true,
diff --git a/server/internal/handler/workspace_test.go b/server/internal/handler/workspace_test.go
index d76e9a24d0..7b202e22e6 100644
--- a/server/internal/handler/workspace_test.go
+++ b/server/internal/handler/workspace_test.go
@@ -12,6 +12,7 @@ func TestCreateWorkspace_RejectsReservedSlug(t *testing.T) {
// Auth + onboarding (covered by migration 043 audit)
"login",
"onboarding",
+ "new-workspace",
"invite",
"api",
"settings",
diff --git a/server/migrations/046_audit_new_workspace_slug.down.sql b/server/migrations/046_audit_new_workspace_slug.down.sql
new file mode 100644
index 0000000000..5b6618be3d
--- /dev/null
+++ b/server/migrations/046_audit_new_workspace_slug.down.sql
@@ -0,0 +1 @@
+-- No-op: 046 is an audit-only migration. Nothing to roll back.
diff --git a/server/migrations/046_audit_new_workspace_slug.up.sql b/server/migrations/046_audit_new_workspace_slug.up.sql
new file mode 100644
index 0000000000..51833a5b29
--- /dev/null
+++ b/server/migrations/046_audit_new_workspace_slug.up.sql
@@ -0,0 +1,22 @@
+-- Audit existing workspace slugs against the newly-added "new-workspace"
+-- reserved slug. The frontend wires /new-workspace as the global workspace
+-- creation page (replacing the old /onboarding flow); reserving the slug
+-- prevents a workspace from being created with slug = "new-workspace" that
+-- would shadow that route.
+--
+-- Keep this slug in sync with:
+-- - server/internal/handler/workspace_reserved_slugs.go
+-- - packages/core/paths/reserved-slugs.ts
+
+DO $$
+DECLARE
+ conflict_count INT;
+BEGIN
+ SELECT COUNT(*) INTO conflict_count
+ FROM workspace
+ WHERE slug = 'new-workspace';
+
+ IF conflict_count > 0 THEN
+ RAISE EXCEPTION 'Found % workspace(s) with slug "new-workspace" that collides with the global route. Rename or delete before deploying.', conflict_count;
+ END IF;
+END $$;