mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-03 08:53:36 +00:00
style: refine sidebar and dropdown menu components for improved UI
- Simplified the sidebar button's class structure by removing unnecessary overflow styling. - Enhanced the visual representation of the trashed projects count with updated styling for better visibility. - Wrapped the dropdown menu's subcontent in a portal for improved rendering and performance.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { Sparkles } from "lucide-react";
|
import { Sparkles, Clock } from "lucide-react";
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
@@ -11,6 +11,19 @@ import {
|
|||||||
} from "@/components/ui/dialog";
|
} from "@/components/ui/dialog";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from "@/components/ui/checkbox";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
// Feature count options
|
||||||
|
export type FeatureCount = 20 | 50 | 100;
|
||||||
|
const FEATURE_COUNT_OPTIONS: {
|
||||||
|
value: FeatureCount;
|
||||||
|
label: string;
|
||||||
|
warning?: string;
|
||||||
|
}[] = [
|
||||||
|
{ value: 20, label: "20" },
|
||||||
|
{ value: 50, label: "50", warning: "May take up to 5 minutes" },
|
||||||
|
{ value: 100, label: "100", warning: "May take up to 5 minutes" },
|
||||||
|
];
|
||||||
|
|
||||||
interface ProjectSetupDialogProps {
|
interface ProjectSetupDialogProps {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@@ -19,6 +32,8 @@ interface ProjectSetupDialogProps {
|
|||||||
onProjectOverviewChange: (value: string) => void;
|
onProjectOverviewChange: (value: string) => void;
|
||||||
generateFeatures: boolean;
|
generateFeatures: boolean;
|
||||||
onGenerateFeaturesChange: (value: boolean) => void;
|
onGenerateFeaturesChange: (value: boolean) => void;
|
||||||
|
featureCount: FeatureCount;
|
||||||
|
onFeatureCountChange: (value: FeatureCount) => void;
|
||||||
onCreateSpec: () => void;
|
onCreateSpec: () => void;
|
||||||
onSkip: () => void;
|
onSkip: () => void;
|
||||||
isCreatingSpec: boolean;
|
isCreatingSpec: boolean;
|
||||||
@@ -31,6 +46,8 @@ export function ProjectSetupDialog({
|
|||||||
onProjectOverviewChange,
|
onProjectOverviewChange,
|
||||||
generateFeatures,
|
generateFeatures,
|
||||||
onGenerateFeaturesChange,
|
onGenerateFeaturesChange,
|
||||||
|
featureCount,
|
||||||
|
onFeatureCountChange,
|
||||||
onCreateSpec,
|
onCreateSpec,
|
||||||
onSkip,
|
onSkip,
|
||||||
isCreatingSpec,
|
isCreatingSpec,
|
||||||
@@ -94,16 +111,52 @@ export function ProjectSetupDialog({
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Feature Count Selection - only shown when generateFeatures is enabled */}
|
||||||
|
{generateFeatures && (
|
||||||
|
<div className="space-y-2 pt-2 pl-7">
|
||||||
|
<label className="text-sm font-medium">Number of Features</label>
|
||||||
|
<div className="flex gap-2">
|
||||||
|
{FEATURE_COUNT_OPTIONS.map((option) => (
|
||||||
|
<Button
|
||||||
|
key={option.value}
|
||||||
|
type="button"
|
||||||
|
variant={
|
||||||
|
featureCount === option.value ? "default" : "outline"
|
||||||
|
}
|
||||||
|
size="sm"
|
||||||
|
onClick={() => onFeatureCountChange(option.value)}
|
||||||
|
className={cn(
|
||||||
|
"flex-1 transition-all",
|
||||||
|
featureCount === option.value
|
||||||
|
? "bg-primary hover:bg-primary/90 text-primary-foreground"
|
||||||
|
: "bg-muted/30 hover:bg-muted/50 border-border"
|
||||||
|
)}
|
||||||
|
data-testid={`feature-count-${option.value}`}
|
||||||
|
>
|
||||||
|
{option.label}
|
||||||
|
</Button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
{FEATURE_COUNT_OPTIONS.find((o) => o.value === featureCount)
|
||||||
|
?.warning && (
|
||||||
|
<p className="text-xs text-amber-500 flex items-center gap-1">
|
||||||
|
<Clock className="w-3 h-3" />
|
||||||
|
{
|
||||||
|
FEATURE_COUNT_OPTIONS.find((o) => o.value === featureCount)
|
||||||
|
?.warning
|
||||||
|
}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
<Button variant="ghost" onClick={onSkip}>
|
<Button variant="ghost" onClick={onSkip}>
|
||||||
Skip for now
|
Skip for now
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button onClick={onCreateSpec} disabled={!projectOverview.trim()}>
|
||||||
onClick={onCreateSpec}
|
|
||||||
disabled={!projectOverview.trim()}
|
|
||||||
>
|
|
||||||
<Sparkles className="w-4 h-4 mr-2" />
|
<Sparkles className="w-4 h-4 mr-2" />
|
||||||
Generate Spec
|
Generate Spec
|
||||||
</Button>
|
</Button>
|
||||||
@@ -112,4 +165,3 @@ export function ProjectSetupDialog({
|
|||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,10 @@ import { themeOptions } from "@/config/theme-options";
|
|||||||
import type { SpecRegenerationEvent } from "@/types/electron";
|
import type { SpecRegenerationEvent } from "@/types/electron";
|
||||||
import { DeleteProjectDialog } from "@/components/views/settings-view/components/delete-project-dialog";
|
import { DeleteProjectDialog } from "@/components/views/settings-view/components/delete-project-dialog";
|
||||||
import { NewProjectModal } from "@/components/new-project-modal";
|
import { NewProjectModal } from "@/components/new-project-modal";
|
||||||
import { ProjectSetupDialog } from "@/components/layout/project-setup-dialog";
|
import {
|
||||||
|
ProjectSetupDialog,
|
||||||
|
type FeatureCount,
|
||||||
|
} from "@/components/layout/project-setup-dialog";
|
||||||
import {
|
import {
|
||||||
DndContext,
|
DndContext,
|
||||||
DragEndEvent,
|
DragEndEvent,
|
||||||
@@ -261,6 +264,7 @@ export function Sidebar() {
|
|||||||
const [setupProjectPath, setSetupProjectPath] = useState("");
|
const [setupProjectPath, setSetupProjectPath] = useState("");
|
||||||
const [projectOverview, setProjectOverview] = useState("");
|
const [projectOverview, setProjectOverview] = useState("");
|
||||||
const [generateFeatures, setGenerateFeatures] = useState(true);
|
const [generateFeatures, setGenerateFeatures] = useState(true);
|
||||||
|
const [featureCount, setFeatureCount] = useState<FeatureCount>(50);
|
||||||
const [showSpecIndicator, setShowSpecIndicator] = useState(true);
|
const [showSpecIndicator, setShowSpecIndicator] = useState(true);
|
||||||
|
|
||||||
// Derive isCreatingSpec from store state
|
// Derive isCreatingSpec from store state
|
||||||
@@ -466,7 +470,9 @@ export function Sidebar() {
|
|||||||
const result = await api.specRegeneration.create(
|
const result = await api.specRegeneration.create(
|
||||||
setupProjectPath,
|
setupProjectPath,
|
||||||
projectOverview.trim(),
|
projectOverview.trim(),
|
||||||
generateFeatures
|
generateFeatures,
|
||||||
|
undefined, // analyzeProject - use default
|
||||||
|
generateFeatures ? featureCount : undefined // only pass maxFeatures if generating features
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
@@ -490,7 +496,13 @@ export function Sidebar() {
|
|||||||
description: error instanceof Error ? error.message : "Unknown error",
|
description: error instanceof Error ? error.message : "Unknown error",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [setupProjectPath, projectOverview, setSpecCreatingForProject]);
|
}, [
|
||||||
|
setupProjectPath,
|
||||||
|
projectOverview,
|
||||||
|
generateFeatures,
|
||||||
|
featureCount,
|
||||||
|
setSpecCreatingForProject,
|
||||||
|
]);
|
||||||
|
|
||||||
// Handle skipping setup
|
// Handle skipping setup
|
||||||
const handleSkipSetup = useCallback(() => {
|
const handleSkipSetup = useCallback(() => {
|
||||||
@@ -1453,7 +1465,7 @@ export function Sidebar() {
|
|||||||
onClick={() => setShowTrashDialog(true)}
|
onClick={() => setShowTrashDialog(true)}
|
||||||
className={cn(
|
className={cn(
|
||||||
"group flex items-center justify-center px-3 h-[42px] rounded-xl",
|
"group flex items-center justify-center px-3 h-[42px] rounded-xl",
|
||||||
"relative overflow-hidden",
|
"relative",
|
||||||
"text-muted-foreground hover:text-destructive",
|
"text-muted-foreground hover:text-destructive",
|
||||||
// Subtle background that turns red on hover
|
// Subtle background that turns red on hover
|
||||||
"bg-accent/20 hover:bg-destructive/15",
|
"bg-accent/20 hover:bg-destructive/15",
|
||||||
@@ -1467,7 +1479,7 @@ export function Sidebar() {
|
|||||||
>
|
>
|
||||||
<Recycle className="size-4 shrink-0 transition-transform duration-200 group-hover:rotate-12" />
|
<Recycle className="size-4 shrink-0 transition-transform duration-200 group-hover:rotate-12" />
|
||||||
{trashedProjects.length > 0 && (
|
{trashedProjects.length > 0 && (
|
||||||
<span className="absolute -top-1.5 -right-1.5 flex items-center justify-center min-w-4 h-4 px-1 text-[9px] font-bold rounded-full bg-destructive text-destructive-foreground shadow-sm">
|
<span className="absolute -top-1.5 -right-1.5 z-10 flex items-center justify-center min-w-4 h-4 px-1 text-[9px] font-bold rounded-full bg-red-500 text-white shadow-md ring-1 ring-red-600/50">
|
||||||
{trashedProjects.length > 9 ? "9+" : trashedProjects.length}
|
{trashedProjects.length > 9 ? "9+" : trashedProjects.length}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
@@ -2248,6 +2260,8 @@ export function Sidebar() {
|
|||||||
onProjectOverviewChange={setProjectOverview}
|
onProjectOverviewChange={setProjectOverview}
|
||||||
generateFeatures={generateFeatures}
|
generateFeatures={generateFeatures}
|
||||||
onGenerateFeaturesChange={setGenerateFeatures}
|
onGenerateFeaturesChange={setGenerateFeatures}
|
||||||
|
featureCount={featureCount}
|
||||||
|
onFeatureCountChange={setFeatureCount}
|
||||||
onCreateSpec={handleCreateInitialSpec}
|
onCreateSpec={handleCreateInitialSpec}
|
||||||
onSkip={handleSkipSetup}
|
onSkip={handleSkipSetup}
|
||||||
isCreatingSpec={isCreatingSpec}
|
isCreatingSpec={isCreatingSpec}
|
||||||
|
|||||||
@@ -43,14 +43,16 @@ const DropdownMenuSubContent = React.forwardRef<
|
|||||||
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
|
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
|
||||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
|
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
|
||||||
>(({ className, ...props }, ref) => (
|
>(({ className, ...props }, ref) => (
|
||||||
<DropdownMenuPrimitive.SubContent
|
<DropdownMenuPrimitive.Portal>
|
||||||
ref={ref}
|
<DropdownMenuPrimitive.SubContent
|
||||||
className={cn(
|
ref={ref}
|
||||||
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
className={cn(
|
||||||
className
|
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
||||||
)}
|
className
|
||||||
{...props}
|
)}
|
||||||
/>
|
{...props}
|
||||||
|
/>
|
||||||
|
</DropdownMenuPrimitive.Portal>
|
||||||
))
|
))
|
||||||
DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName
|
DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName
|
||||||
|
|
||||||
|
|||||||
@@ -2180,7 +2180,7 @@ export function BoardView() {
|
|||||||
data-testid="start-next-button"
|
data-testid="start-next-button"
|
||||||
>
|
>
|
||||||
<FastForward className="w-3 h-3 mr-1" />
|
<FastForward className="w-3 h-3 mr-1" />
|
||||||
Pull Top
|
Make
|
||||||
</HotkeyButton>
|
</HotkeyButton>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -148,15 +148,17 @@ export interface SpecRegenerationAPI {
|
|||||||
projectPath: string,
|
projectPath: string,
|
||||||
projectOverview: string,
|
projectOverview: string,
|
||||||
generateFeatures?: boolean,
|
generateFeatures?: boolean,
|
||||||
analyzeProject?: boolean
|
analyzeProject?: boolean,
|
||||||
|
maxFeatures?: number
|
||||||
) => Promise<{ success: boolean; error?: string }>;
|
) => Promise<{ success: boolean; error?: string }>;
|
||||||
generate: (
|
generate: (
|
||||||
projectPath: string,
|
projectPath: string,
|
||||||
projectDefinition: string,
|
projectDefinition: string,
|
||||||
generateFeatures?: boolean,
|
generateFeatures?: boolean,
|
||||||
analyzeProject?: boolean
|
analyzeProject?: boolean,
|
||||||
|
maxFeatures?: number
|
||||||
) => Promise<{ success: boolean; error?: string }>;
|
) => Promise<{ success: boolean; error?: string }>;
|
||||||
generateFeatures: (projectPath: string) => Promise<{
|
generateFeatures: (projectPath: string, maxFeatures?: number) => Promise<{
|
||||||
success: boolean;
|
success: boolean;
|
||||||
error?: string;
|
error?: string;
|
||||||
}>;
|
}>;
|
||||||
@@ -1836,7 +1838,9 @@ function createMockSpecRegenerationAPI(): SpecRegenerationAPI {
|
|||||||
create: async (
|
create: async (
|
||||||
projectPath: string,
|
projectPath: string,
|
||||||
projectOverview: string,
|
projectOverview: string,
|
||||||
generateFeatures = true
|
generateFeatures = true,
|
||||||
|
_analyzeProject?: boolean,
|
||||||
|
maxFeatures?: number
|
||||||
) => {
|
) => {
|
||||||
if (mockSpecRegenerationRunning) {
|
if (mockSpecRegenerationRunning) {
|
||||||
return { success: false, error: "Spec creation is already running" };
|
return { success: false, error: "Spec creation is already running" };
|
||||||
@@ -1844,7 +1848,7 @@ function createMockSpecRegenerationAPI(): SpecRegenerationAPI {
|
|||||||
|
|
||||||
mockSpecRegenerationRunning = true;
|
mockSpecRegenerationRunning = true;
|
||||||
console.log(
|
console.log(
|
||||||
`[Mock] Creating initial spec for: ${projectPath}, generateFeatures: ${generateFeatures}`
|
`[Mock] Creating initial spec for: ${projectPath}, generateFeatures: ${generateFeatures}, maxFeatures: ${maxFeatures}`
|
||||||
);
|
);
|
||||||
|
|
||||||
// Simulate async spec creation
|
// Simulate async spec creation
|
||||||
@@ -1856,7 +1860,9 @@ function createMockSpecRegenerationAPI(): SpecRegenerationAPI {
|
|||||||
generate: async (
|
generate: async (
|
||||||
projectPath: string,
|
projectPath: string,
|
||||||
projectDefinition: string,
|
projectDefinition: string,
|
||||||
generateFeatures = false
|
generateFeatures = false,
|
||||||
|
_analyzeProject?: boolean,
|
||||||
|
maxFeatures?: number
|
||||||
) => {
|
) => {
|
||||||
if (mockSpecRegenerationRunning) {
|
if (mockSpecRegenerationRunning) {
|
||||||
return {
|
return {
|
||||||
@@ -1867,7 +1873,7 @@ function createMockSpecRegenerationAPI(): SpecRegenerationAPI {
|
|||||||
|
|
||||||
mockSpecRegenerationRunning = true;
|
mockSpecRegenerationRunning = true;
|
||||||
console.log(
|
console.log(
|
||||||
`[Mock] Regenerating spec for: ${projectPath}, generateFeatures: ${generateFeatures}`
|
`[Mock] Regenerating spec for: ${projectPath}, generateFeatures: ${generateFeatures}, maxFeatures: ${maxFeatures}`
|
||||||
);
|
);
|
||||||
|
|
||||||
// Simulate async spec regeneration
|
// Simulate async spec regeneration
|
||||||
@@ -1880,7 +1886,7 @@ function createMockSpecRegenerationAPI(): SpecRegenerationAPI {
|
|||||||
return { success: true };
|
return { success: true };
|
||||||
},
|
},
|
||||||
|
|
||||||
generateFeatures: async (projectPath: string) => {
|
generateFeatures: async (projectPath: string, maxFeatures?: number) => {
|
||||||
if (mockSpecRegenerationRunning) {
|
if (mockSpecRegenerationRunning) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
@@ -1890,7 +1896,7 @@ function createMockSpecRegenerationAPI(): SpecRegenerationAPI {
|
|||||||
|
|
||||||
mockSpecRegenerationRunning = true;
|
mockSpecRegenerationRunning = true;
|
||||||
console.log(
|
console.log(
|
||||||
`[Mock] Generating features from existing spec for: ${projectPath}`
|
`[Mock] Generating features from existing spec for: ${projectPath}, maxFeatures: ${maxFeatures}`
|
||||||
);
|
);
|
||||||
|
|
||||||
// Simulate async feature generation
|
// Simulate async feature generation
|
||||||
|
|||||||
@@ -582,28 +582,32 @@ export class HttpApiClient implements ElectronAPI {
|
|||||||
projectPath: string,
|
projectPath: string,
|
||||||
projectOverview: string,
|
projectOverview: string,
|
||||||
generateFeatures?: boolean,
|
generateFeatures?: boolean,
|
||||||
analyzeProject?: boolean
|
analyzeProject?: boolean,
|
||||||
|
maxFeatures?: number
|
||||||
) =>
|
) =>
|
||||||
this.post("/api/spec-regeneration/create", {
|
this.post("/api/spec-regeneration/create", {
|
||||||
projectPath,
|
projectPath,
|
||||||
projectOverview,
|
projectOverview,
|
||||||
generateFeatures,
|
generateFeatures,
|
||||||
analyzeProject,
|
analyzeProject,
|
||||||
|
maxFeatures,
|
||||||
}),
|
}),
|
||||||
generate: (
|
generate: (
|
||||||
projectPath: string,
|
projectPath: string,
|
||||||
projectDefinition: string,
|
projectDefinition: string,
|
||||||
generateFeatures?: boolean,
|
generateFeatures?: boolean,
|
||||||
analyzeProject?: boolean
|
analyzeProject?: boolean,
|
||||||
|
maxFeatures?: number
|
||||||
) =>
|
) =>
|
||||||
this.post("/api/spec-regeneration/generate", {
|
this.post("/api/spec-regeneration/generate", {
|
||||||
projectPath,
|
projectPath,
|
||||||
projectDefinition,
|
projectDefinition,
|
||||||
generateFeatures,
|
generateFeatures,
|
||||||
analyzeProject,
|
analyzeProject,
|
||||||
|
maxFeatures,
|
||||||
}),
|
}),
|
||||||
generateFeatures: (projectPath: string) =>
|
generateFeatures: (projectPath: string, maxFeatures?: number) =>
|
||||||
this.post("/api/spec-regeneration/generate-features", { projectPath }),
|
this.post("/api/spec-regeneration/generate-features", { projectPath, maxFeatures }),
|
||||||
stop: () => this.post("/api/spec-regeneration/stop"),
|
stop: () => this.post("/api/spec-regeneration/stop"),
|
||||||
status: () => this.get("/api/spec-regeneration/status"),
|
status: () => this.get("/api/spec-regeneration/status"),
|
||||||
onEvent: (callback: (event: SpecRegenerationEvent) => void) => {
|
onEvent: (callback: (event: SpecRegenerationEvent) => void) => {
|
||||||
|
|||||||
8
apps/app/src/types/electron.d.ts
vendored
8
apps/app/src/types/electron.d.ts
vendored
@@ -267,7 +267,8 @@ export interface SpecRegenerationAPI {
|
|||||||
projectPath: string,
|
projectPath: string,
|
||||||
projectOverview: string,
|
projectOverview: string,
|
||||||
generateFeatures?: boolean,
|
generateFeatures?: boolean,
|
||||||
analyzeProject?: boolean
|
analyzeProject?: boolean,
|
||||||
|
maxFeatures?: number
|
||||||
) => Promise<{
|
) => Promise<{
|
||||||
success: boolean;
|
success: boolean;
|
||||||
error?: string;
|
error?: string;
|
||||||
@@ -277,13 +278,14 @@ export interface SpecRegenerationAPI {
|
|||||||
projectPath: string,
|
projectPath: string,
|
||||||
projectDefinition: string,
|
projectDefinition: string,
|
||||||
generateFeatures?: boolean,
|
generateFeatures?: boolean,
|
||||||
analyzeProject?: boolean
|
analyzeProject?: boolean,
|
||||||
|
maxFeatures?: number
|
||||||
) => Promise<{
|
) => Promise<{
|
||||||
success: boolean;
|
success: boolean;
|
||||||
error?: string;
|
error?: string;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
generateFeatures: (projectPath: string) => Promise<{
|
generateFeatures: (projectPath: string, maxFeatures?: number) => Promise<{
|
||||||
success: boolean;
|
success: boolean;
|
||||||
error?: string;
|
error?: string;
|
||||||
}>;
|
}>;
|
||||||
|
|||||||
@@ -13,15 +13,18 @@ import { parseAndCreateFeatures } from "./parse-and-create-features.js";
|
|||||||
|
|
||||||
const logger = createLogger("SpecRegeneration");
|
const logger = createLogger("SpecRegeneration");
|
||||||
|
|
||||||
const MAX_FEATURES = 100;
|
const DEFAULT_MAX_FEATURES = 50;
|
||||||
|
|
||||||
export async function generateFeaturesFromSpec(
|
export async function generateFeaturesFromSpec(
|
||||||
projectPath: string,
|
projectPath: string,
|
||||||
events: EventEmitter,
|
events: EventEmitter,
|
||||||
abortController: AbortController
|
abortController: AbortController,
|
||||||
|
maxFeatures?: number
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
const featureCount = maxFeatures ?? DEFAULT_MAX_FEATURES;
|
||||||
logger.debug("========== generateFeaturesFromSpec() started ==========");
|
logger.debug("========== generateFeaturesFromSpec() started ==========");
|
||||||
logger.debug("projectPath:", projectPath);
|
logger.debug("projectPath:", projectPath);
|
||||||
|
logger.debug("maxFeatures:", featureCount);
|
||||||
|
|
||||||
// Read existing spec
|
// Read existing spec
|
||||||
const specPath = path.join(projectPath, ".automaker", "app_spec.txt");
|
const specPath = path.join(projectPath, ".automaker", "app_spec.txt");
|
||||||
@@ -73,7 +76,7 @@ Format as JSON:
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
Generate ${MAX_FEATURES} features that build on each other logically.
|
Generate ${featureCount} features that build on each other logically.
|
||||||
|
|
||||||
IMPORTANT: Do not ask for clarification. The specification is provided above. Generate the JSON immediately.`;
|
IMPORTANT: Do not ask for clarification. The specification is provided above. Generate the JSON immediately.`;
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ export async function generateSpec(
|
|||||||
events: EventEmitter,
|
events: EventEmitter,
|
||||||
abortController: AbortController,
|
abortController: AbortController,
|
||||||
generateFeatures?: boolean,
|
generateFeatures?: boolean,
|
||||||
analyzeProject?: boolean
|
analyzeProject?: boolean,
|
||||||
|
maxFeatures?: number
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
logger.info("========== generateSpec() started ==========");
|
logger.info("========== generateSpec() started ==========");
|
||||||
logger.info("projectPath:", projectPath);
|
logger.info("projectPath:", projectPath);
|
||||||
@@ -28,6 +29,7 @@ export async function generateSpec(
|
|||||||
logger.info("projectOverview preview:", projectOverview.substring(0, 300));
|
logger.info("projectOverview preview:", projectOverview.substring(0, 300));
|
||||||
logger.info("generateFeatures:", generateFeatures);
|
logger.info("generateFeatures:", generateFeatures);
|
||||||
logger.info("analyzeProject:", analyzeProject);
|
logger.info("analyzeProject:", analyzeProject);
|
||||||
|
logger.info("maxFeatures:", maxFeatures);
|
||||||
|
|
||||||
// Build the prompt based on whether we should analyze the project
|
// Build the prompt based on whether we should analyze the project
|
||||||
let analysisInstructions = "";
|
let analysisInstructions = "";
|
||||||
@@ -252,7 +254,8 @@ ${getAppSpecFormatInstruction()}`;
|
|||||||
await generateFeaturesFromSpec(
|
await generateFeaturesFromSpec(
|
||||||
projectPath,
|
projectPath,
|
||||||
events,
|
events,
|
||||||
featureAbortController
|
featureAbortController,
|
||||||
|
maxFeatures
|
||||||
);
|
);
|
||||||
// Final completion will be emitted by generateFeaturesFromSpec -> parseAndCreateFeatures
|
// Final completion will be emitted by generateFeaturesFromSpec -> parseAndCreateFeatures
|
||||||
} catch (featureError) {
|
} catch (featureError) {
|
||||||
|
|||||||
@@ -22,12 +22,13 @@ export function createCreateHandler(events: EventEmitter) {
|
|||||||
logger.debug("Request body:", JSON.stringify(req.body, null, 2));
|
logger.debug("Request body:", JSON.stringify(req.body, null, 2));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { projectPath, projectOverview, generateFeatures, analyzeProject } =
|
const { projectPath, projectOverview, generateFeatures, analyzeProject, maxFeatures } =
|
||||||
req.body as {
|
req.body as {
|
||||||
projectPath: string;
|
projectPath: string;
|
||||||
projectOverview: string;
|
projectOverview: string;
|
||||||
generateFeatures?: boolean;
|
generateFeatures?: boolean;
|
||||||
analyzeProject?: boolean;
|
analyzeProject?: boolean;
|
||||||
|
maxFeatures?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
logger.debug("Parsed params:");
|
logger.debug("Parsed params:");
|
||||||
@@ -38,6 +39,7 @@ export function createCreateHandler(events: EventEmitter) {
|
|||||||
);
|
);
|
||||||
logger.debug(" generateFeatures:", generateFeatures);
|
logger.debug(" generateFeatures:", generateFeatures);
|
||||||
logger.debug(" analyzeProject:", analyzeProject);
|
logger.debug(" analyzeProject:", analyzeProject);
|
||||||
|
logger.debug(" maxFeatures:", maxFeatures);
|
||||||
|
|
||||||
if (!projectPath || !projectOverview) {
|
if (!projectPath || !projectOverview) {
|
||||||
logger.error("Missing required parameters");
|
logger.error("Missing required parameters");
|
||||||
@@ -68,7 +70,8 @@ export function createCreateHandler(events: EventEmitter) {
|
|||||||
events,
|
events,
|
||||||
abortController,
|
abortController,
|
||||||
generateFeatures,
|
generateFeatures,
|
||||||
analyzeProject
|
analyzeProject,
|
||||||
|
maxFeatures
|
||||||
)
|
)
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
logError(error, "Generation failed with error");
|
logError(error, "Generation failed with error");
|
||||||
|
|||||||
@@ -22,9 +22,13 @@ export function createGenerateFeaturesHandler(events: EventEmitter) {
|
|||||||
logger.debug("Request body:", JSON.stringify(req.body, null, 2));
|
logger.debug("Request body:", JSON.stringify(req.body, null, 2));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { projectPath } = req.body as { projectPath: string };
|
const { projectPath, maxFeatures } = req.body as {
|
||||||
|
projectPath: string;
|
||||||
|
maxFeatures?: number;
|
||||||
|
};
|
||||||
|
|
||||||
logger.debug("projectPath:", projectPath);
|
logger.debug("projectPath:", projectPath);
|
||||||
|
logger.debug("maxFeatures:", maxFeatures);
|
||||||
|
|
||||||
if (!projectPath) {
|
if (!projectPath) {
|
||||||
logger.error("Missing projectPath parameter");
|
logger.error("Missing projectPath parameter");
|
||||||
@@ -45,7 +49,12 @@ export function createGenerateFeaturesHandler(events: EventEmitter) {
|
|||||||
setRunningState(true, abortController);
|
setRunningState(true, abortController);
|
||||||
logger.info("Starting background feature generation task...");
|
logger.info("Starting background feature generation task...");
|
||||||
|
|
||||||
generateFeaturesFromSpec(projectPath, events, abortController)
|
generateFeaturesFromSpec(
|
||||||
|
projectPath,
|
||||||
|
events,
|
||||||
|
abortController,
|
||||||
|
maxFeatures
|
||||||
|
)
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
logError(error, "Feature generation failed with error");
|
logError(error, "Feature generation failed with error");
|
||||||
events.emit("spec-regeneration:event", {
|
events.emit("spec-regeneration:event", {
|
||||||
|
|||||||
@@ -27,11 +27,13 @@ export function createGenerateHandler(events: EventEmitter) {
|
|||||||
projectDefinition,
|
projectDefinition,
|
||||||
generateFeatures,
|
generateFeatures,
|
||||||
analyzeProject,
|
analyzeProject,
|
||||||
|
maxFeatures,
|
||||||
} = req.body as {
|
} = req.body as {
|
||||||
projectPath: string;
|
projectPath: string;
|
||||||
projectDefinition: string;
|
projectDefinition: string;
|
||||||
generateFeatures?: boolean;
|
generateFeatures?: boolean;
|
||||||
analyzeProject?: boolean;
|
analyzeProject?: boolean;
|
||||||
|
maxFeatures?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
logger.debug("Parsed params:");
|
logger.debug("Parsed params:");
|
||||||
@@ -42,6 +44,7 @@ export function createGenerateHandler(events: EventEmitter) {
|
|||||||
);
|
);
|
||||||
logger.debug(" generateFeatures:", generateFeatures);
|
logger.debug(" generateFeatures:", generateFeatures);
|
||||||
logger.debug(" analyzeProject:", analyzeProject);
|
logger.debug(" analyzeProject:", analyzeProject);
|
||||||
|
logger.debug(" maxFeatures:", maxFeatures);
|
||||||
|
|
||||||
if (!projectPath || !projectDefinition) {
|
if (!projectPath || !projectDefinition) {
|
||||||
logger.error("Missing required parameters");
|
logger.error("Missing required parameters");
|
||||||
@@ -71,7 +74,8 @@ export function createGenerateHandler(events: EventEmitter) {
|
|||||||
events,
|
events,
|
||||||
abortController,
|
abortController,
|
||||||
generateFeatures,
|
generateFeatures,
|
||||||
analyzeProject
|
analyzeProject,
|
||||||
|
maxFeatures
|
||||||
)
|
)
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
logError(error, "Generation failed with error");
|
logError(error, "Generation failed with error");
|
||||||
|
|||||||
Reference in New Issue
Block a user