Files
autocoder/ui/src/components/ProjectSetupRequired.tsx
Auto cf62885e83 feat: add project reset functionality with quick and full reset options
Add the ability to reset a project to its initial state with two options:
- Quick Reset: Clears features.db, assistant.db, and settings files while
  preserving app spec and prompts
- Full Reset: Deletes everything including prompts directory, triggering
  the setup wizard for project reconfiguration

Backend changes:
- Add POST /{name}/reset endpoint to projects router with full_reset query param
- Validate agent lock file to prevent reset while agent is running (409 Conflict)
- Dispose database engines before deleting files to release Windows file locks
- Add engine caching to api/database.py for better connection management
- Add dispose_engine() functions to both database modules
- Delete WAL mode journal files (*.db-wal, *.db-shm) during reset

Frontend changes:
- Add ResetProjectModal component with toggle between Quick/Full reset modes
- Add ProjectSetupRequired component shown when has_spec is false
- Add resetProject API function and useResetProject React Query hook
- Integrate reset button in header (disabled when agent running)
- Add 'R' keyboard shortcut to open reset modal
- Show ProjectSetupRequired when project needs setup after full reset

This implements the feature from PR #4 directly on master to avoid merge
conflicts.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 10:42:05 +02:00

91 lines
3.6 KiB
TypeScript

import { Sparkles, FileEdit, FolderOpen } from 'lucide-react'
import { Button } from '@/components/ui/button'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
interface ProjectSetupRequiredProps {
projectName: string
projectPath?: string
onCreateWithClaude: () => void
onEditManually: () => void
}
export function ProjectSetupRequired({
projectName,
projectPath,
onCreateWithClaude,
onEditManually,
}: ProjectSetupRequiredProps) {
return (
<div className="max-w-2xl mx-auto mt-8">
<Card className="border-2">
<CardHeader className="text-center">
<CardTitle className="text-2xl font-display">
Project Setup Required
</CardTitle>
<CardDescription className="text-base">
<span className="font-semibold">{projectName}</span> needs an app spec to get started
</CardDescription>
{projectPath && (
<div className="flex items-center justify-center gap-2 text-sm text-muted-foreground mt-2">
<FolderOpen size={14} />
<code className="bg-muted px-2 py-0.5 rounded text-xs">{projectPath}</code>
</div>
)}
</CardHeader>
<CardContent className="space-y-4">
<p className="text-center text-muted-foreground">
Choose how you want to create your app specification:
</p>
<div className="grid gap-4 md:grid-cols-2">
{/* Create with Claude Option */}
<Card
className="cursor-pointer border-2 transition-all hover:border-primary hover:shadow-md"
onClick={onCreateWithClaude}
>
<CardContent className="pt-6 text-center space-y-3">
<div className="w-12 h-12 mx-auto bg-primary/10 rounded-full flex items-center justify-center">
<Sparkles className="text-primary" size={24} />
</div>
<h3 className="font-semibold text-lg">Create with Claude</h3>
<p className="text-sm text-muted-foreground">
Describe your app idea and Claude will help create a detailed specification
</p>
<Button className="w-full">
<Sparkles size={16} className="mr-2" />
Start Chat
</Button>
</CardContent>
</Card>
{/* Edit Manually Option */}
<Card
className="cursor-pointer border-2 transition-all hover:border-primary hover:shadow-md"
onClick={onEditManually}
>
<CardContent className="pt-6 text-center space-y-3">
<div className="w-12 h-12 mx-auto bg-muted rounded-full flex items-center justify-center">
<FileEdit className="text-muted-foreground" size={24} />
</div>
<h3 className="font-semibold text-lg">Edit Templates Manually</h3>
<p className="text-sm text-muted-foreground">
Create the prompts directory and edit template files yourself
</p>
<Button variant="outline" className="w-full">
<FileEdit size={16} className="mr-2" />
View Templates
</Button>
</CardContent>
</Card>
</div>
<p className="text-center text-xs text-muted-foreground pt-4">
The app spec tells the agent what to build. It includes the application name,
description, tech stack, and feature requirements.
</p>
</CardContent>
</Card>
</div>
)
}