diff --git a/package-lock.json b/package-lock.json
index c85d3bf7..e3e2e938 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -48,7 +48,7 @@
"@unhead/addons": "^2.0.10",
"@unhead/react": "^2.0.10",
"@webcontainer/api": "^1.6.1",
- "ai": "^5.0.19",
+ "ai": "^5.0.22",
"buffer": "^6.0.3",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
@@ -118,13 +118,31 @@
"license": "MIT"
},
"node_modules/@ai-sdk/gateway": {
- "version": "1.0.9",
- "resolved": "https://registry.npmjs.org/@ai-sdk/gateway/-/gateway-1.0.9.tgz",
- "integrity": "sha512-kIfwunyUUwyBLg2KQcaRtjRQ1bDuJYPNIs4CNWaWPpMZ4SV5cRL1hLGMuX4bhfCJYDXHMGvJGLtUK6+iAJH2ZQ==",
+ "version": "1.0.11",
+ "resolved": "https://registry.npmjs.org/@ai-sdk/gateway/-/gateway-1.0.11.tgz",
+ "integrity": "sha512-ErwWS3sPOuWy42eE3AVxlKkTa1XjjKBEtNCOylVKMO5KNyz5qie8QVlLYbULOG56dtxX4zTKX3rQNJudplhcmQ==",
"license": "Apache-2.0",
"dependencies": {
"@ai-sdk/provider": "2.0.0",
- "@ai-sdk/provider-utils": "3.0.4"
+ "@ai-sdk/provider-utils": "3.0.5"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "peerDependencies": {
+ "zod": "^3.25.76 || ^4"
+ }
+ },
+ "node_modules/@ai-sdk/gateway/node_modules/@ai-sdk/provider-utils": {
+ "version": "3.0.5",
+ "resolved": "https://registry.npmjs.org/@ai-sdk/provider-utils/-/provider-utils-3.0.5.tgz",
+ "integrity": "sha512-HliwB/yzufw3iwczbFVE2Fiwf1XqROB/I6ng8EKUsPM5+2wnIa8f4VbljZcDx+grhFrPV+PnRZH7zBqi8WZM7Q==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@ai-sdk/provider": "2.0.0",
+ "@standard-schema/spec": "^1.0.0",
+ "eventsource-parser": "^3.0.3",
+ "zod-to-json-schema": "^3.24.1"
},
"engines": {
"node": ">=18"
@@ -4356,14 +4374,14 @@
}
},
"node_modules/ai": {
- "version": "5.0.19",
- "resolved": "https://registry.npmjs.org/ai/-/ai-5.0.19.tgz",
- "integrity": "sha512-I0yQO68Z1DdvjMc9be5scMYdsuBvpNneQDh6TUuUVlFXdCxAIm7yATnOaomfYTE2KaRDsrO+OSRPjJm4FSKioA==",
+ "version": "5.0.22",
+ "resolved": "https://registry.npmjs.org/ai/-/ai-5.0.22.tgz",
+ "integrity": "sha512-RZiYhj7Ux7hrLtXkHPcxzdiSZt4NOiC69O5AkNfMCsz3twwz/KRkl9ASptosoOsg833s5yRcTSdIu5z53Sl6Pw==",
"license": "Apache-2.0",
"dependencies": {
- "@ai-sdk/gateway": "1.0.9",
+ "@ai-sdk/gateway": "1.0.11",
"@ai-sdk/provider": "2.0.0",
- "@ai-sdk/provider-utils": "3.0.4",
+ "@ai-sdk/provider-utils": "3.0.5",
"@opentelemetry/api": "1.9.0"
},
"engines": {
@@ -4373,6 +4391,24 @@
"zod": "^3.25.76 || ^4"
}
},
+ "node_modules/ai/node_modules/@ai-sdk/provider-utils": {
+ "version": "3.0.5",
+ "resolved": "https://registry.npmjs.org/@ai-sdk/provider-utils/-/provider-utils-3.0.5.tgz",
+ "integrity": "sha512-HliwB/yzufw3iwczbFVE2Fiwf1XqROB/I6ng8EKUsPM5+2wnIa8f4VbljZcDx+grhFrPV+PnRZH7zBqi8WZM7Q==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@ai-sdk/provider": "2.0.0",
+ "@standard-schema/spec": "^1.0.0",
+ "eventsource-parser": "^3.0.3",
+ "zod-to-json-schema": "^3.24.1"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "peerDependencies": {
+ "zod": "^3.25.76 || ^4"
+ }
+ },
"node_modules/ajv": {
"version": "6.12.6",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
diff --git a/package.json b/package.json
index cdb4e9d4..ee0093f1 100644
--- a/package.json
+++ b/package.json
@@ -50,7 +50,7 @@
"@unhead/addons": "^2.0.10",
"@unhead/react": "^2.0.10",
"@webcontainer/api": "^1.6.1",
- "ai": "^5.0.19",
+ "ai": "^5.0.22",
"buffer": "^6.0.3",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
diff --git a/src/components/ai/StreamingMessageItem.tsx b/src/components/AIMessageItem.tsx
similarity index 53%
rename from src/components/ai/StreamingMessageItem.tsx
rename to src/components/AIMessageItem.tsx
index aa836262..2dc7e772 100644
--- a/src/components/ai/StreamingMessageItem.tsx
+++ b/src/components/AIMessageItem.tsx
@@ -2,29 +2,23 @@ import { memo } from 'react';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
import { Bot, User, Square } from 'lucide-react';
import { Button } from '@/components/ui/button';
-import { ChatMessage } from '@/hooks/useStreamingChat';
-import { AssistantContent } from '@/components/ai/AssistantContent';
+import { AIMessage } from '@/hooks/useAIChat';
-interface StreamingMessageItemProps {
- message: ChatMessage;
+interface AIMessageItemProps {
+ message: AIMessage;
userDisplayName?: string;
userProfileImage?: string;
- isCurrentlyStreaming?: boolean;
- onStopStreaming?: () => void;
+ isCurrentlyLoading?: boolean;
+ onStopGeneration?: () => void;
}
-export const StreamingMessageItem = memo(({
+export const AIMessageItem = memo(({
message,
userDisplayName = 'You',
userProfileImage,
- isCurrentlyStreaming = false,
- onStopStreaming
-}: StreamingMessageItemProps) => {
- // Don't render tool messages as separate items - they're integrated into assistant messages
- if (message.role === 'tool') {
- return null;
- }
-
+ isCurrentlyLoading = false,
+ onStopGeneration
+}: AIMessageItemProps) => {
return (
@@ -51,11 +45,11 @@ export const StreamingMessageItem = memo(({
{message.role === 'user' ? 'User' : message.role === 'assistant' ? 'AI' : 'System'}
- {isCurrentlyStreaming && onStopStreaming && (
+ {isCurrentlyLoading && onStopGeneration && (
- {message.role === 'user' ? (
-
- {typeof message.content === 'string' ? message.content :
- Array.isArray(message.content) ?
- message.content.map(part => part.type === 'text' ? part.text : '').join('') :
- ''}
-
- ) : message.role === 'assistant' ? (
-
- ) : message.role === 'system' ? (
-
- {typeof message.content === 'string' ? message.content : ''}
-
- ) : null}
+
+ {message.content}
+
);
});
-StreamingMessageItem.displayName = 'StreamingMessageItem';
\ No newline at end of file
+AIMessageItem.displayName = 'AIMessageItem';
\ No newline at end of file
diff --git a/src/components/Shakespeare/ChatPane.tsx b/src/components/Shakespeare/ChatPane.tsx
index 00eb07c3..c052a418 100644
--- a/src/components/Shakespeare/ChatPane.tsx
+++ b/src/components/Shakespeare/ChatPane.tsx
@@ -6,11 +6,11 @@ import { useAISettings } from '@/hooks/useAISettings';
import { useFS } from '@/hooks/useFS';
import { useJSRuntime } from '@/hooks/useJSRuntime';
import { useKeepAlive } from '@/hooks/useKeepAlive';
-import { useStreamingChat } from '@/hooks/useStreamingChat';
+import { useAIChat } from '@/hooks/useAIChat';
import { copyDirectory } from '@/lib/copyFiles';
import { generateSecretKey, getPublicKey, nip19 } from 'nostr-tools';
import { bytesToHex } from 'nostr-tools/utils';
-import { StreamingMessageItem } from '@/components/ai/StreamingMessageItem';
+import { AIMessageItem } from '@/components/AIMessageItem';
import { GitHistoryDialog } from '@/components/ai/GitHistoryDialog';
import { TextEditorViewTool } from '@/lib/tools/TextEditorViewTool';
import { TextEditorWriteTool } from '@/lib/tools/TextEditorWriteTool';
@@ -34,7 +34,7 @@ export function ChatPane({ projectId, projectName }: ChatPaneProps) {
const { fs: browserFS } = useFS();
const { runtime } = useJSRuntime();
- // Initialize streaming chat with tools
+ // Initialize AI chat with tools
const cwd = `/projects/${projectId}`;
const tools = {
git_commit: new GitCommitTool(browserFS, cwd),
@@ -77,11 +77,10 @@ When creating new components or pages, follow the existing patterns in the codeb
const {
messages,
- isStreaming,
- currentStreamingMessageId,
+ isLoading,
sendMessage,
- stopStreaming,
- } = useStreamingChat({
+ stopGeneration,
+ } = useAIChat({
projectId,
projectName,
tools,
@@ -93,7 +92,7 @@ When creating new components or pages, follow the existing patterns in the codeb
// Keep-alive functionality to prevent tab throttling during AI processing
const { updateMetadata } = useKeepAlive({
- enabled: isStreaming || isBuildLoading || isDeployLoading,
+ enabled: isLoading || isBuildLoading || isDeployLoading,
title: 'Shakespeare',
artist: `Working on ${projectName}...`,
artwork: [
@@ -190,8 +189,6 @@ BASE_DOMAIN=nostrdeploy.com`);
}
};
- // Note: Message clearing and history loading is now handled in useStreamingChat hook
-
useEffect(() => {
if (scrollAreaRef.current && messages) {
// Check if user was already at or near the bottom (within 100px threshold)
@@ -204,10 +201,10 @@ BASE_DOMAIN=nostrdeploy.com`);
container.scrollTop = container.scrollHeight;
}
}
- }, [messages, isStreaming]);
+ }, [messages, isLoading]);
const handleSend = async () => {
- if (!input.trim() || isStreaming) return;
+ if (!input.trim() || isLoading) return;
const messageContent = input;
setInput('');
@@ -216,7 +213,7 @@ BASE_DOMAIN=nostrdeploy.com`);
await sendMessage(messageContent);
} catch (error) {
console.error('AI chat error:', error);
- // Error handling is done in the useStreamingChat hook
+ // Error handling is done in the useAIChat hook
}
};
@@ -300,7 +297,7 @@ BASE_DOMAIN=nostrdeploy.com`);
className="gap-1 sm:gap-2 hover:bg-primary/10 hover:border-primary/20"
onClick={runBuild}
onMouseDown={handleFirstInteraction}
- disabled={isBuildLoading || isDeployLoading || isStreaming}
+ disabled={isBuildLoading || isDeployLoading || isLoading}
>
{isBuildLoading ? (
@@ -317,7 +314,7 @@ BASE_DOMAIN=nostrdeploy.com`);
className="gap-1 sm:gap-2 hover:bg-accent/10 hover:border-accent/20"
onClick={runDeploy}
onMouseDown={handleFirstInteraction}
- disabled={isDeployLoading || isBuildLoading || isStreaming}
+ disabled={isDeployLoading || isBuildLoading || isLoading}
>
{isDeployLoading ? (
@@ -334,12 +331,12 @@ BASE_DOMAIN=nostrdeploy.com`);
{messages.map((message) => (
-
))}
@@ -354,12 +351,12 @@ BASE_DOMAIN=nostrdeploy.com`);
onFocus={handleFirstInteraction}
placeholder="Ask me to add features, edit files, or build your project..."
className="min-h-[60px] resize-none"
- disabled={isStreaming}
+ disabled={isLoading}
/>