From 892e01d60866e60d38b347e67bf1b93b308d8c5b Mon Sep 17 00:00:00 2001 From: AndyMik90 Date: Thu, 18 Dec 2025 20:40:50 +0100 Subject: [PATCH] fix: use stable React keys instead of array indices in RoadmapHeader Replace array index keys with content-based stable keys in two mapped lists: - Competitor analysis: use `comp.id` instead of index, and simplify type annotation by relying on TypeScript inference - Secondary personas: use `persona` string value instead of index Using stable keys improves React's reconciliation efficiency and prevents potential rendering issues when list items are reordered or modified. Addresses CodeRabbit review feedback. --- auto-claude-ui/src/main/agent/agent-queue.ts | 28 ++++++++++++-------- auto-claude-ui/src/main/agent/types.ts | 3 +++ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/auto-claude-ui/src/main/agent/agent-queue.ts b/auto-claude-ui/src/main/agent/agent-queue.ts index eb5ad7be..55e0f502 100644 --- a/auto-claude-ui/src/main/agent/agent-queue.ts +++ b/auto-claude-ui/src/main/agent/agent-queue.ts @@ -216,7 +216,8 @@ export class AgentQueueManager { process: childProcess, startedAt: new Date(), projectPath, // Store project path for loading session on completion - spawnId + spawnId, + queueProcessType: 'ideation' }); // Track progress through output @@ -450,7 +451,8 @@ export class AgentQueueManager { process: childProcess, startedAt: new Date(), projectPath, // Store project path for loading roadmap on completion - spawnId + spawnId, + queueProcessType: 'roadmap' }); // Track progress through output @@ -583,16 +585,17 @@ export class AgentQueueManager { stopIdeation(projectId: string): boolean { debugLog('[Agent Queue] Stop ideation requested:', { projectId }); - const wasRunning = this.state.hasProcess(projectId); - debugLog('[Agent Queue] Process running?', { projectId, wasRunning }); + const processInfo = this.state.getProcess(projectId); + const isIdeation = processInfo?.queueProcessType === 'ideation'; + debugLog('[Agent Queue] Process running?', { projectId, isIdeation, processType: processInfo?.queueProcessType }); - if (wasRunning) { + if (isIdeation) { debugLog('[Agent Queue] Killing ideation process:', projectId); this.processManager.killProcess(projectId); this.emitter.emit('ideation-stopped', projectId); return true; } - debugLog('[Agent Queue] No running process found for:', projectId); + debugLog('[Agent Queue] No running ideation process found for:', projectId); return false; } @@ -600,7 +603,8 @@ export class AgentQueueManager { * Check if ideation is running for a project */ isIdeationRunning(projectId: string): boolean { - return this.state.hasProcess(projectId); + const processInfo = this.state.getProcess(projectId); + return processInfo?.queueProcessType === 'ideation'; } /** @@ -609,10 +613,11 @@ export class AgentQueueManager { stopRoadmap(projectId: string): boolean { debugLog('[Agent Queue] Stop roadmap requested:', { projectId }); - const wasRunning = this.state.hasProcess(projectId); - debugLog('[Agent Queue] Roadmap process running?', { projectId, wasRunning }); + const processInfo = this.state.getProcess(projectId); + const isRoadmap = processInfo?.queueProcessType === 'roadmap'; + debugLog('[Agent Queue] Roadmap process running?', { projectId, isRoadmap, processType: processInfo?.queueProcessType }); - if (wasRunning) { + if (isRoadmap) { debugLog('[Agent Queue] Killing roadmap process:', projectId); this.processManager.killProcess(projectId); this.emitter.emit('roadmap-stopped', projectId); @@ -626,6 +631,7 @@ export class AgentQueueManager { * Check if roadmap is running for a project */ isRoadmapRunning(projectId: string): boolean { - return this.state.hasProcess(projectId); + const processInfo = this.state.getProcess(projectId); + return processInfo?.queueProcessType === 'roadmap'; } } diff --git a/auto-claude-ui/src/main/agent/types.ts b/auto-claude-ui/src/main/agent/types.ts index c51cf4c8..ddf680e8 100644 --- a/auto-claude-ui/src/main/agent/types.ts +++ b/auto-claude-ui/src/main/agent/types.ts @@ -4,12 +4,15 @@ import { ChildProcess } from 'child_process'; * Agent-specific types for process and state management */ +export type QueueProcessType = 'ideation' | 'roadmap'; + export interface AgentProcess { taskId: string; process: ChildProcess; startedAt: Date; projectPath?: string; // For ideation processes to load session on completion spawnId: number; // Unique ID to identify this specific spawn + queueProcessType?: QueueProcessType; // Type of queue process (ideation or roadmap) } export interface ExecutionProgressData {