Fix lint errors

This commit is contained in:
Alex Gleason committed 2025-07-16 16:29:20 -05:00
1 parent 08024d2269
commit 96b7d31475
16 files changed
+152 -106

No files matched your search

+12 -6
View File
@@ -10,12 +10,18 @@ import { useAISettings } from '@/contexts/AISettingsContext';
import { aiTools } from '@/lib/ai-tools';
import { z } from 'zod';
interface ToolCall {
toolCallId: string;
toolName: string;
args: Record<string, unknown>;
}
interface Message {
id: string;
role: 'user' | 'assistant';
content: string;
timestamp: Date;
toolCalls?: any[];
toolCalls?: ToolCall[];
}
interface ChatPaneProps {
@@ -48,7 +54,7 @@ export function ChatPane({ projectId, projectName }: ChatPaneProps) {
}
}, [messages]);
const createAIChat = async (projectId: string, messages: any[]) => {
const createAIChat = async (projectId: string, messages: Array<{ role: 'user' | 'assistant'; content: string }>) => {
if (!isConfigured) {
throw new Error('AI settings not configured');
}
@@ -224,9 +230,9 @@ When creating new components or pages, follow the existing patterns in the codeb
];
const result = await createAIChat(projectId, aiMessages);
let assistantContent = '';
const toolCalls: any[] = [];
const toolCalls: ToolCall[] = [];
for await (const part of result.fullStream) {
if (part.type === 'text-delta') {
@@ -290,7 +296,7 @@ When creating new components or pages, follow the existing patterns in the codeb
Settings
</Button>
</div>
<div className="flex-1 flex items-center justify-center">
<div className="text-center space-y-4">
<Bot className="h-12 w-12 mx-auto text-muted-foreground" />
@@ -389,7 +395,7 @@ When creating new components or pages, follow the existing patterns in the codeb
</div>
</div>
))}
{isLoading && (
<div className="flex gap-2">
<div className="w-8 h-8 rounded-full bg-muted flex items-center justify-center flex-shrink-0">
+1 -1
View File
@@ -1,7 +1,7 @@
import { useState, useEffect } from 'react';
import { Button } from '@/components/ui/button';
import { Textarea } from '@/components/ui/textarea';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { Save, Loader2 } from 'lucide-react';
import { cn } from '@/lib/utils';
+24 -24
View File
@@ -1,4 +1,4 @@
import { useState, useEffect } from 'react';
import { useState, useEffect, useCallback } from 'react';
import { fsManager } from '@/lib/fs';
import { ChevronRight, ChevronDown, File, Folder } from 'lucide-react';
import { cn } from '@/lib/utils';
@@ -21,33 +21,17 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp
const [tree, setTree] = useState<FileNode[]>([]);
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
loadFileTree();
}, [projectId]);
const loadFileTree = async () => {
setIsLoading(true);
try {
const structure = await buildFileTree(projectId, '');
setTree(structure);
} catch (error) {
console.error('Failed to load file tree:', error);
} finally {
setIsLoading(false);
}
};
const buildFileTree = async (projectId: string, dirPath: string): Promise<FileNode[]> => {
const buildFileTree = useCallback(async (projectId: string, dirPath: string): Promise<FileNode[]> => {
const items = await fsManager.listFiles(projectId, dirPath);
const nodes: FileNode[] = [];
for (const item of items) {
const itemPath = dirPath ? `${dirPath}/${item}` : item;
const fullPath = `${fsManager['dir']}/${projectId}/${itemPath}`;
try {
const stat = await fsManager['fs'].promises.stat(fullPath);
if (stat.isDirectory()) {
const children = await buildFileTree(projectId, itemPath);
nodes.push({
@@ -64,7 +48,7 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp
type: 'file',
});
}
} catch (error) {
} catch {
// Skip inaccessible items
}
}
@@ -75,7 +59,23 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp
}
return a.name.localeCompare(b.name);
});
};
}, [projectId]);
const loadFileTree = useCallback(async () => {
setIsLoading(true);
try {
const structure = await buildFileTree(projectId, '');
setTree(structure);
} catch (_error) {
console.error('Failed to load file tree:', _error);
} finally {
setIsLoading(false);
}
}, [projectId, buildFileTree]);
useEffect(() => {
loadFileTree();
}, [loadFileTree]);
const toggleDirectory = (path: string) => {
const toggleNode = (nodes: FileNode[]): FileNode[] => {
@@ -103,7 +103,7 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp
const renderNode = (node: FileNode, depth: number = 0) => {
const isSelected = selectedFile === node.path;
return (
<div key={node.path}>
<div
@@ -132,7 +132,7 @@ export function FileTree({ projectId, onFileSelect, selectedFile }: FileTreeProp
)}
<span className="text-sm truncate">{node.name}</span>
</div>
{node.type === 'directory' && node.isOpen && node.children && (
<div>
{node.children.map(child => renderNode(child, depth + 1))}
+15 -15
View File
@@ -1,8 +1,8 @@
import { useState, useEffect } from 'react';
import { useState, useEffect, useCallback } from 'react';
import { fsManager } from '@/lib/fs';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
import { Tabs, TabsContent } from '@/components/ui/tabs';
import { ScrollArea } from '@/components/ui/scroll-area';
import { Card } from '@/components/ui/card';
import { FileTree } from './FileTree';
import { FileEditor } from './FileEditor';
@@ -16,24 +16,24 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) {
const [fileContent, setFileContent] = useState<string>('');
const [isLoading, setIsLoading] = useState(false);
useEffect(() => {
if (selectedFile) {
loadFileContent(selectedFile);
}
}, [selectedFile, projectId]);
const loadFileContent = async (filePath: string) => {
const loadFileContent = useCallback(async (filePath: string) => {
setIsLoading(true);
try {
const content = await fsManager.readFile(projectId, filePath);
setFileContent(content);
} catch (error) {
console.error('Failed to load file:', error);
} catch (_error) {
console.error('Failed to load file:', _error);
setFileContent('');
} finally {
setIsLoading(false);
}
};
}, [projectId]);
useEffect(() => {
if (selectedFile) {
loadFileContent(selectedFile);
}
}, [selectedFile, loadFileContent]);
const handleFileSelect = (filePath: string) => {
setSelectedFile(filePath);
@@ -41,7 +41,7 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) {
const handleFileSave = async (content: string) => {
if (!selectedFile) return;
try {
await fsManager.writeFile(projectId, selectedFile, content);
setFileContent(content);
@@ -83,7 +83,7 @@ export function PreviewPane({ projectId, activeTab }: PreviewPaneProps) {
/>
</ScrollArea>
</div>
<div className="flex-1">
{selectedFile ? (
<FileEditor