Skip to content

Commit 1ee0b99

Browse files
committed
more pr changes
1 parent 1680c7e commit 1ee0b99

6 files changed

Lines changed: 34 additions & 16 deletions

File tree

apps/dashboard/public/dashboard-ui-components.iife.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/dashboard/src/components/commands/create-dashboard/create-dashboard-preview.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { captureError, throwErr } from "@stackframe/stack-shared/dist/utils/erro
1616
import { typedEntries } from "@stackframe/stack-shared/dist/utils/objects";
1717
import { runAsynchronouslyWithAlert } from "@stackframe/stack-shared/dist/utils/promises";
1818
import { generateUuid } from "@stackframe/stack-shared/dist/utils/uuids";
19-
import { memo, useCallback, useMemo, useState } from "react";
19+
import { memo, useCallback, useMemo, useRef, useState } from "react";
2020
import { CmdKPreviewProps } from "../../cmdk-commands";
2121
import { DashboardSandboxHost } from "./dashboard-sandbox-host";
2222

@@ -61,18 +61,26 @@ const CreateDashboardPreviewInner = memo(function CreateDashboardPreviewInner({
6161
const [errorText, setErrorText] = useState<string | null>(null);
6262
const [artifact, setArtifact] = useState<DashboardArtifact | null>(null);
6363
const [isSaving, setIsSaving] = useState(false);
64+
const abortControllerRef = useRef<AbortController | null>(null);
6465

6566
const generateDashboard = useCallback(async () => {
6667
if (!projectId || !prompt) {
6768
return;
6869
}
70+
71+
abortControllerRef.current?.abort();
72+
const controller = new AbortController();
73+
abortControllerRef.current = controller;
74+
6975
setState("generating");
7076
setErrorText(null);
7177
setArtifact(null);
7278

7379
try {
7480
const userMessages: Array<{ role: string, content: string }> = [{ role: "user", content: prompt }];
75-
const { toolCall } = await generateDashboardCode(backendBaseUrl, currentUser, userMessages, { enabledAppIds });
81+
const { toolCall } = await generateDashboardCode(backendBaseUrl, currentUser, userMessages, { enabledAppIds, abortSignal: controller.signal });
82+
83+
if (controller.signal.aborted) return;
7684

7785
if (!toolCall?.args?.content) {
7886
setState("error");
@@ -91,6 +99,7 @@ const CreateDashboardPreviewInner = memo(function CreateDashboardPreviewInner({
9199
});
92100
setState("ready");
93101
} catch (error) {
102+
if (controller.signal.aborted) return;
94103
captureError("create-dashboard-preview", error);
95104
setState("error");
96105
setErrorText("Failed to generate dashboard. Please try again.");

apps/dashboard/src/components/commands/create-dashboard/dashboard-sandbox-host.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ function getDependencyScripts(esmVersion: string, esmFallbackVersion: string, da
2525
if (isDev) {
2626
return html`
2727
<script type="module">
28-
import React from 'https://esm.sh/react@18';
29-
import * as ReactDOM from 'https://esm.sh/react-dom@18?deps=react@18';
30-
import * as ReactDOMClient from 'https://esm.sh/react-dom@18/client?deps=react@18';
31-
import * as Recharts from 'https://esm.sh/recharts@2.15.4?deps=react@18,react-dom@18';
28+
import React from 'https://esm.sh/react@19.2.3';
29+
import * as ReactDOM from 'https://esm.sh/react-dom@19.2.3?deps=react@19.2.3';
30+
import * as ReactDOMClient from 'https://esm.sh/react-dom@19.2.3/client?deps=react@19.2.3';
31+
import * as Recharts from 'https://esm.sh/recharts@2.15.4?deps=react@19.2.3,react-dom@19.2.3';
3232
3333
window.React = React;
3434
window.ReactDOM = { ...ReactDOM, ...ReactDOMClient };
@@ -72,10 +72,10 @@ function getDependencyScripts(esmVersion: string, esmFallbackVersion: string, da
7272

7373
return html`
7474
<script type="module">
75-
import React from 'https://esm.sh/react@18';
76-
import * as ReactDOM from 'https://esm.sh/react-dom@18?deps=react@18';
77-
import * as ReactDOMClient from 'https://esm.sh/react-dom@18/client?deps=react@18';
78-
import * as Recharts from 'https://esm.sh/recharts@2.15.4?deps=react@18,react-dom@18';
75+
import React from 'https://esm.sh/react@19.2.3';
76+
import * as ReactDOM from 'https://esm.sh/react-dom@19.2.3?deps=react@19.2.3';
77+
import * as ReactDOMClient from 'https://esm.sh/react-dom@19.2.3/client?deps=react@19.2.3';
78+
import * as Recharts from 'https://esm.sh/recharts@2.15.4?deps=react@19.2.3,react-dom@19.2.3';
7979
8080
window.React = React;
8181
window.ReactDOM = { ...ReactDOM, ...ReactDOMClient };
@@ -85,13 +85,13 @@ function getDependencyScripts(esmVersion: string, esmFallbackVersion: string, da
8585
let DashboardUIComponents, StackSDK;
8686
try {
8787
[DashboardUIComponents, StackSDK] = await Promise.all([
88-
import('https://esm.sh/@stackframe/dashboard-ui-components@${esmVersion}?deps=react@18,react-dom@18'),
88+
import('https://esm.sh/@stackframe/dashboard-ui-components@${esmVersion}?deps=react@19.2.3,react-dom@19.2.3'),
8989
import('https://esm.sh/@stackframe/js@${esmVersion}'),
9090
]);
9191
} catch (e) {
9292
window.parent.postMessage({ type: 'dashboard-error-boundary', message: '[sandbox] Failed to load at version ${esmVersion}, trying fallback ${esmFallbackVersion}: ' + e?.message }, '*');
9393
[DashboardUIComponents, StackSDK] = await Promise.all([
94-
import('https://esm.sh/@stackframe/dashboard-ui-components@${esmFallbackVersion}?deps=react@18,react-dom@18'),
94+
import('https://esm.sh/@stackframe/dashboard-ui-components@${esmFallbackVersion}?deps=react@19.2.3,react-dom@19.2.3'),
9595
import('https://esm.sh/@stackframe/js@${esmFallbackVersion}'),
9696
]);
9797
}
@@ -243,7 +243,7 @@ function getSandboxDocument(artifact: DashboardArtifact, baseUrl: string, dashbo
243243
};
244244
// Controls visibility flag — only true in the full dashboard viewer (not cmd+K preview)
245245
window.__showControls = ${showControls};
246-
window.__chatOpen = false;
246+
window.__chatOpen = ${initialChatOpen};
247247
248248
// Theme syncing and chat state from parent window
249249
window.addEventListener('message', (event) => {

apps/dashboard/src/components/vibe-coding/chat-adapters.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ async function sendAiRequest(
8484
body: JSON.stringify(body),
8585
});
8686

87+
if (!response.ok) {
88+
throw new Error(`AI request failed: ${response.status} ${response.statusText}`);
89+
}
90+
8791
const json = await response.json() as { content?: ChatContent };
8892
return Array.isArray(json.content) ? json.content : [];
8993
}
@@ -323,6 +327,10 @@ Please update the source code to change "${oldText}" to "${newText}" at the spec
323327
}),
324328
});
325329

330+
if (!response.ok) {
331+
throw new Error(`Wysiwyg edit request failed: ${response.status} ${response.statusText}`);
332+
}
333+
326334
const json = await response.json() as { content?: Array<{ type: string, text?: string }> };
327335
const textBlock = Array.isArray(json.content)
328336
? json.content.find((b) => b.type === "text" && b.text)

apps/dashboard/src/generated/bundled-type-definitions.ts

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

packages/dashboard-ui-components/src/components/skeleton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import { cn } from "@stackframe/stack-ui";
4+
import type React from "react";
45

56
export type DesignSkeletonProps = React.HTMLAttributes<HTMLDivElement>;
67

0 commit comments

Comments
 (0)