feat(workspace-dialog): route new workspace from llm_setup and seed query cache

This commit is contained in:
Anish Sarkar 2026-07-12 20:30:20 +05:30
parent b010468a96
commit 6f34bdf6b5

View file

@ -28,6 +28,8 @@ import {
import { Input } from "@/components/ui/input";
import { Spinner } from "@/components/ui/spinner";
import { trackWorkspaceCreated } from "@/lib/posthog/events";
import { cacheKeys } from "@/lib/query-client/cache-keys";
import { queryClient } from "@/lib/query-client/client";
const formSchema = z.object({
name: z.string().min(1, "Name is required"),
@ -67,7 +69,20 @@ export function CreateWorkspaceDialog({ open, onOpenChange }: CreateWorkspaceDia
trackWorkspaceCreated(result.id, values.name);
router.push(`/dashboard/${result.id}/new-chat`);
// Seed the gate's query so it resolves without a loader flash, and
// route straight to onboarding vs. new-chat on the first hop.
if (result.llm_setup) {
queryClient.setQueryData(
cacheKeys.modelConnections.setupStatus(result.id),
result.llm_setup
);
}
const needsSetup = result.llm_setup?.status === "needs_setup";
router.push(
needsSetup
? `/dashboard/${result.id}/onboard`
: `/dashboard/${result.id}/new-chat`
);
} catch (error) {
console.error("Failed to create workspace:", error);
setIsSubmitting(false);