"use client"; import { useEffect, useState, useCallback } from "react"; import { useAppStore } from "@/store/app-store"; import { getElectronAPI } from "@/lib/electron"; import { Button } from "@/components/ui/button"; import { Card } from "@/components/ui/card"; import { Save, RefreshCw, FileText } from "lucide-react"; export function SpecView() { const { currentProject, appSpec, setAppSpec } = useAppStore(); const [isLoading, setIsLoading] = useState(true); const [isSaving, setIsSaving] = useState(false); const [hasChanges, setHasChanges] = useState(false); // Load spec from file const loadSpec = useCallback(async () => { if (!currentProject) return; setIsLoading(true); try { const api = getElectronAPI(); const result = await api.readFile( `${currentProject.path}/.automaker/app_spec.txt` ); if (result.success && result.content) { setAppSpec(result.content); setHasChanges(false); } } catch (error) { console.error("Failed to load spec:", error); } finally { setIsLoading(false); } }, [currentProject, setAppSpec]); useEffect(() => { loadSpec(); }, [loadSpec]); // Save spec to file const saveSpec = async () => { if (!currentProject) return; setIsSaving(true); try { const api = getElectronAPI(); await api.writeFile( `${currentProject.path}/.automaker/app_spec.txt`, appSpec ); setHasChanges(false); } catch (error) { console.error("Failed to save spec:", error); } finally { setIsSaving(false); } }; const handleChange = (value: string) => { setAppSpec(value); setHasChanges(true); }; if (!currentProject) { return (
No project selected
{currentProject.path}/.automaker/app_spec.txt