mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-05 09:33:07 +00:00
refactor: update ideation dashboard and prompt list to use project-specific job retrieval
- Modified IdeationDashboard and PromptList components to fetch generation jobs specific to the current project. - Updated addGenerationJob function to include projectPath as a parameter for better job management. - Introduced getJobsForProject function in the ideation store to streamline job filtering by project.
This commit is contained in:
@@ -168,15 +168,16 @@ function TagFilter({
|
|||||||
|
|
||||||
export function IdeationDashboard({ onGenerateIdeas }: IdeationDashboardProps) {
|
export function IdeationDashboard({ onGenerateIdeas }: IdeationDashboardProps) {
|
||||||
const currentProject = useAppStore((s) => s.currentProject);
|
const currentProject = useAppStore((s) => s.currentProject);
|
||||||
const { generationJobs, removeSuggestionFromJob } = useIdeationStore();
|
const { getJobsForProject, removeSuggestionFromJob } = useIdeationStore();
|
||||||
const [addingId, setAddingId] = useState<string | null>(null);
|
const [addingId, setAddingId] = useState<string | null>(null);
|
||||||
const [selectedTags, setSelectedTags] = useState<Set<string>>(new Set());
|
const [selectedTags, setSelectedTags] = useState<Set<string>>(new Set());
|
||||||
|
|
||||||
|
// Get jobs for current project only
|
||||||
|
const projectJobs = currentProject?.path ? getJobsForProject(currentProject.path) : [];
|
||||||
|
|
||||||
// Separate generating/error jobs from ready jobs with suggestions
|
// Separate generating/error jobs from ready jobs with suggestions
|
||||||
const activeJobs = generationJobs.filter(
|
const activeJobs = projectJobs.filter((j) => j.status === 'generating' || j.status === 'error');
|
||||||
(j) => j.status === 'generating' || j.status === 'error'
|
const readyJobs = projectJobs.filter((j) => j.status === 'ready' && j.suggestions.length > 0);
|
||||||
);
|
|
||||||
const readyJobs = generationJobs.filter((j) => j.status === 'ready' && j.suggestions.length > 0);
|
|
||||||
|
|
||||||
// Flatten all suggestions with their parent job
|
// Flatten all suggestions with their parent job
|
||||||
const allSuggestions = useMemo(
|
const allSuggestions = useMemo(
|
||||||
@@ -203,7 +204,7 @@ export function IdeationDashboard({ onGenerateIdeas }: IdeationDashboardProps) {
|
|||||||
return allSuggestions.filter(({ job }) => selectedTags.has(job.prompt.title));
|
return allSuggestions.filter(({ job }) => selectedTags.has(job.prompt.title));
|
||||||
}, [allSuggestions, selectedTags]);
|
}, [allSuggestions, selectedTags]);
|
||||||
|
|
||||||
const generatingCount = generationJobs.filter((j) => j.status === 'generating').length;
|
const generatingCount = projectJobs.filter((j) => j.status === 'generating').length;
|
||||||
|
|
||||||
const handleToggleTag = (tag: string) => {
|
const handleToggleTag = (tag: string) => {
|
||||||
setSelectedTags((prev) => {
|
setSelectedTags((prev) => {
|
||||||
@@ -316,6 +317,16 @@ export function IdeationDashboard({ onGenerateIdeas }: IdeationDashboardProps) {
|
|||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Generate More Ideas Button - shown when there are items */}
|
||||||
|
{!isEmpty && (
|
||||||
|
<div className="pt-2">
|
||||||
|
<Button onClick={onGenerateIdeas} variant="outline" className="w-full gap-2">
|
||||||
|
<Lightbulb className="w-4 h-4" />
|
||||||
|
Generate More Ideas
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Empty State */}
|
{/* Empty State */}
|
||||||
{isEmpty && (
|
{isEmpty && (
|
||||||
<Card>
|
<Card>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ interface PromptListProps {
|
|||||||
|
|
||||||
export function PromptList({ category, onBack }: PromptListProps) {
|
export function PromptList({ category, onBack }: PromptListProps) {
|
||||||
const currentProject = useAppStore((s) => s.currentProject);
|
const currentProject = useAppStore((s) => s.currentProject);
|
||||||
const { setMode, addGenerationJob, updateJobStatus, generationJobs } = useIdeationStore();
|
const { setMode, addGenerationJob, updateJobStatus, getJobsForProject } = useIdeationStore();
|
||||||
const [loadingPromptId, setLoadingPromptId] = useState<string | null>(null);
|
const [loadingPromptId, setLoadingPromptId] = useState<string | null>(null);
|
||||||
const [startedPrompts, setStartedPrompts] = useState<Set<string>>(new Set());
|
const [startedPrompts, setStartedPrompts] = useState<Set<string>>(new Set());
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -32,9 +32,10 @@ export function PromptList({ category, onBack }: PromptListProps) {
|
|||||||
|
|
||||||
const prompts = getPromptsByCategory(category);
|
const prompts = getPromptsByCategory(category);
|
||||||
|
|
||||||
// Check which prompts are already generating
|
// Get jobs for current project only and check which prompts are already generating
|
||||||
|
const projectJobs = currentProject?.path ? getJobsForProject(currentProject.path) : [];
|
||||||
const generatingPromptIds = new Set(
|
const generatingPromptIds = new Set(
|
||||||
generationJobs.filter((j) => j.status === 'generating').map((j) => j.prompt.id)
|
projectJobs.filter((j) => j.status === 'generating').map((j) => j.prompt.id)
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleSelectPrompt = async (prompt: IdeationPrompt) => {
|
const handleSelectPrompt = async (prompt: IdeationPrompt) => {
|
||||||
@@ -48,7 +49,7 @@ export function PromptList({ category, onBack }: PromptListProps) {
|
|||||||
setLoadingPromptId(prompt.id);
|
setLoadingPromptId(prompt.id);
|
||||||
|
|
||||||
// Add a job and navigate to dashboard
|
// Add a job and navigate to dashboard
|
||||||
const jobId = addGenerationJob(prompt);
|
const jobId = addGenerationJob(currentProject.path, prompt);
|
||||||
setStartedPrompts((prev) => new Set(prev).add(prompt.id));
|
setStartedPrompts((prev) => new Set(prev).add(prompt.id));
|
||||||
|
|
||||||
// Show toast and navigate to dashboard
|
// Show toast and navigate to dashboard
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ export type GenerationJobStatus = 'generating' | 'ready' | 'error';
|
|||||||
|
|
||||||
export interface GenerationJob {
|
export interface GenerationJob {
|
||||||
id: string;
|
id: string;
|
||||||
|
projectPath: string;
|
||||||
prompt: IdeationPrompt;
|
prompt: IdeationPrompt;
|
||||||
status: GenerationJobStatus;
|
status: GenerationJobStatus;
|
||||||
suggestions: AnalysisSuggestion[];
|
suggestions: AnalysisSuggestion[];
|
||||||
@@ -76,7 +77,8 @@ interface IdeationActions {
|
|||||||
getSelectedIdea: () => Idea | null;
|
getSelectedIdea: () => Idea | null;
|
||||||
|
|
||||||
// Generation Jobs
|
// Generation Jobs
|
||||||
addGenerationJob: (prompt: IdeationPrompt) => string;
|
addGenerationJob: (projectPath: string, prompt: IdeationPrompt) => string;
|
||||||
|
getJobsForProject: (projectPath: string) => GenerationJob[];
|
||||||
updateJobStatus: (
|
updateJobStatus: (
|
||||||
jobId: string,
|
jobId: string,
|
||||||
status: GenerationJobStatus,
|
status: GenerationJobStatus,
|
||||||
@@ -172,10 +174,11 @@ export const useIdeationStore = create<IdeationState & IdeationActions>()(
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Generation Jobs
|
// Generation Jobs
|
||||||
addGenerationJob: (prompt) => {
|
addGenerationJob: (projectPath, prompt) => {
|
||||||
const jobId = `job-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
const jobId = `job-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
||||||
const job: GenerationJob = {
|
const job: GenerationJob = {
|
||||||
id: jobId,
|
id: jobId,
|
||||||
|
projectPath,
|
||||||
prompt,
|
prompt,
|
||||||
status: 'generating',
|
status: 'generating',
|
||||||
suggestions: [],
|
suggestions: [],
|
||||||
@@ -189,6 +192,11 @@ export const useIdeationStore = create<IdeationState & IdeationActions>()(
|
|||||||
return jobId;
|
return jobId;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getJobsForProject: (projectPath) => {
|
||||||
|
const state = get();
|
||||||
|
return state.generationJobs.filter((job) => job.projectPath === projectPath);
|
||||||
|
},
|
||||||
|
|
||||||
updateJobStatus: (jobId, status, suggestions, error) =>
|
updateJobStatus: (jobId, status, suggestions, error) =>
|
||||||
set((state) => ({
|
set((state) => ({
|
||||||
generationJobs: state.generationJobs.map((job) =>
|
generationJobs: state.generationJobs.map((job) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user