diff --git a/src/components/AIChat.tsx b/src/components/AIChat.tsx index 49ed590..6793131 100644 --- a/src/components/AIChat.tsx +++ b/src/components/AIChat.tsx @@ -33,6 +33,10 @@ export function AIChat({ currentCode }: AIChatProps) { setIsLoading(true); try { + if (typeof window === 'undefined' || !window.spark?.llm) { + throw new Error('AI service is not available'); + } + const promptText = `You are an expert Roblox Lua developer helping a user with their code. The user is working on this code: \`\`\`lua @@ -46,7 +50,6 @@ Provide helpful, concise answers. Include code examples when relevant. Keep resp const response = await window.spark.llm(promptText, 'gpt-4o-mini'); setMessages((prev) => [...prev, { role: 'assistant', content: response }]); } catch (error) { - console.error('AI Error:', error); toast.error('Failed to get AI response. Please try again.'); setMessages((prev) => [...prev, { role: 'assistant', content: 'Sorry, I encountered an error. Please try asking again.' }]); } finally { diff --git a/src/components/CodeEditor.tsx b/src/components/CodeEditor.tsx index 676668b..2e2e5bb 100644 --- a/src/components/CodeEditor.tsx +++ b/src/components/CodeEditor.tsx @@ -45,7 +45,7 @@ end) value={code} onChange={handleEditorChange} options={{ - minimap: { enabled: window.innerWidth >= 768 }, + minimap: { enabled: typeof window !== 'undefined' && window.innerWidth >= 768 }, fontSize: 14, lineNumbers: 'on', automaticLayout: true, diff --git a/src/components/ConsolePanel.tsx b/src/components/ConsolePanel.tsx index 1d485b7..1e48bf0 100644 --- a/src/components/ConsolePanel.tsx +++ b/src/components/ConsolePanel.tsx @@ -35,11 +35,11 @@ export function ConsolePanel({ collapsed, onToggle }: ConsolePanelProps) { message: 'Player joined the game!', }, ]); - const scrollRef = useRef(null); + const autoScrollRef = useRef(null); useEffect(() => { - if (scrollRef.current) { - scrollRef.current.scrollTop = scrollRef.current.scrollHeight; + if (autoScrollRef.current) { + autoScrollRef.current.scrollIntoView({ behavior: 'smooth' }); } }, [logs]); @@ -118,7 +118,7 @@ export function ConsolePanel({ collapsed, onToggle }: ConsolePanelProps) { - +
{logs.map((log) => (
@@ -133,6 +133,7 @@ export function ConsolePanel({ collapsed, onToggle }: ConsolePanelProps) {
))} +
diff --git a/src/components/NewProjectModal.tsx b/src/components/NewProjectModal.tsx index 34628c1..9039835 100644 --- a/src/components/NewProjectModal.tsx +++ b/src/components/NewProjectModal.tsx @@ -206,7 +206,7 @@ export function NewProjectModal({ open, onClose, onCreateProject }: NewProjectMo id="platform-roblox" checked={platforms.roblox} onCheckedChange={(checked) => - setPlatforms((p) => ({ ...p, roblox: checked as boolean })) + setPlatforms((p) => ({ ...p, roblox: checked === true })) } />