Skip to content

Commit c8f9bc7

Browse files
author
catlog22
committed
feat: 添加左侧面板选项卡状态管理,更新流程节点数据结构
1 parent a9b9ec4 commit c8f9bc7

4 files changed

Lines changed: 171 additions & 6 deletions

File tree

assets/wechat-group-qr.png

-2.32 KB
Loading

ccw/frontend/src/stores/flowStore.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const initialState = {
4444
// UI state
4545
isPaletteOpen: true,
4646
isPropertyPanelOpen: true,
47+
leftPanelTab: 'nodes' as const,
4748
};
4849

4950
export const useFlowStore = create<FlowStore>()(
@@ -429,6 +430,10 @@ export const useFlowStore = create<FlowStore>()(
429430
set({ isPropertyPanelOpen: open }, false, 'setIsPropertyPanelOpen');
430431
},
431432

433+
setLeftPanelTab: (tab) => {
434+
set({ leftPanelTab: tab }, false, 'setLeftPanelTab');
435+
},
436+
432437
// ========== Utility ==========
433438

434439
resetFlow: () => {

ccw/frontend/src/types/flow.ts

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,24 @@ export interface PromptTemplateNodeData {
125125
*/
126126
executionResult?: unknown;
127127

128+
/** Node description, more detailed than label */
129+
description?: string;
130+
131+
/** Phase assignment for canvas grouping */
132+
phase?: 'session' | 'context' | 'plan' | 'execute' | 'review';
133+
134+
/** Node classification for panel organization */
135+
nodeCategory?: 'phase' | 'tool' | 'command';
136+
137+
/** Tag list for categorization and search */
138+
tags?: string[];
139+
140+
/** Precondition expression */
141+
condition?: string;
142+
143+
/** Artifact definition list */
144+
artifacts?: string[];
145+
128146
/**
129147
* Index signature for React Flow compatibility
130148
*/
@@ -197,6 +215,7 @@ export interface FlowState {
197215
// UI state
198216
isPaletteOpen: boolean;
199217
isPropertyPanelOpen: boolean;
218+
leftPanelTab: 'templates' | 'nodes';
200219
}
201220

202221
export interface FlowActions {
@@ -231,6 +250,7 @@ export interface FlowActions {
231250
// UI state
232251
setIsPaletteOpen: (open: boolean) => void;
233252
setIsPropertyPanelOpen: (open: boolean) => void;
253+
setLeftPanelTab: (tab: 'templates' | 'nodes') => void;
234254

235255
// Utility
236256
resetFlow: () => void;
@@ -293,6 +313,8 @@ export interface QuickTemplate {
293313
icon: string;
294314
color: string;
295315
data: Partial<PromptTemplateNodeData>;
316+
/** Category for palette organization */
317+
category: 'phase' | 'tool' | 'command';
296318
}
297319

298320
/**
@@ -306,12 +328,14 @@ export const QUICK_TEMPLATES: QuickTemplate[] = [
306328
description: 'Execute /workflow commands (main thread)',
307329
icon: 'Terminal',
308330
color: 'bg-rose-500',
331+
category: 'command',
309332
data: {
310333
label: 'Slash Command',
311334
instruction: '',
312335
slashCommand: '',
313336
slashArgs: '',
314337
mode: 'mainprocess',
338+
nodeCategory: 'command',
315339
},
316340
},
317341
{
@@ -320,12 +344,14 @@ export const QUICK_TEMPLATES: QuickTemplate[] = [
320344
description: 'Execute /workflow commands (background)',
321345
icon: 'Terminal',
322346
color: 'bg-rose-400',
347+
category: 'command',
323348
data: {
324349
label: 'Slash Command (Async)',
325350
instruction: '',
326351
slashCommand: '',
327352
slashArgs: '',
328353
mode: 'async',
354+
nodeCategory: 'command',
329355
},
330356
},
331357
{
@@ -334,11 +360,13 @@ export const QUICK_TEMPLATES: QuickTemplate[] = [
334360
description: 'Code review, architecture analysis',
335361
icon: 'Search',
336362
color: 'bg-emerald-500',
363+
category: 'command',
337364
data: {
338365
label: 'Analyze',
339366
instruction: 'Analyze the code for:\n1. Architecture patterns\n2. Code quality\n3. Potential issues',
340367
tool: 'gemini',
341368
mode: 'analysis',
369+
nodeCategory: 'command',
342370
},
343371
},
344372
{
@@ -347,11 +375,149 @@ export const QUICK_TEMPLATES: QuickTemplate[] = [
347375
description: 'Write code, create files',
348376
icon: 'Code',
349377
color: 'bg-violet-500',
378+
category: 'command',
350379
data: {
351380
label: 'Implement',
352381
instruction: 'Implement the following:\n\n[Describe what to implement]',
353382
tool: 'codex',
354383
mode: 'write',
384+
nodeCategory: 'command',
385+
},
386+
},
387+
// ========== Phase Templates ==========
388+
{
389+
id: 'phase-session',
390+
label: 'Session',
391+
description: 'Initialize workflow session and environment',
392+
icon: 'FolderOpen',
393+
color: 'bg-sky-500',
394+
category: 'phase',
395+
data: {
396+
label: 'Session Setup',
397+
instruction: 'Initialize workflow session:\n- Set project context\n- Load configuration\n- Validate environment',
398+
phase: 'session',
399+
nodeCategory: 'phase',
400+
mode: 'mainprocess',
401+
},
402+
},
403+
{
404+
id: 'phase-context',
405+
label: 'Context',
406+
description: 'Collect and prepare context information',
407+
icon: 'Database',
408+
color: 'bg-cyan-500',
409+
category: 'phase',
410+
data: {
411+
label: 'Context Gathering',
412+
instruction: 'Gather context:\n- Analyze codebase structure\n- Identify relevant files\n- Build context package',
413+
phase: 'context',
414+
nodeCategory: 'phase',
415+
mode: 'analysis',
416+
tool: 'gemini',
417+
artifacts: ['context-package.json'],
418+
},
419+
},
420+
{
421+
id: 'phase-plan',
422+
label: 'Plan',
423+
description: 'Generate execution plan and task breakdown',
424+
icon: 'ListTodo',
425+
color: 'bg-amber-500',
426+
category: 'phase',
427+
data: {
428+
label: 'Planning',
429+
instruction: 'Create execution plan:\n- Break requirements into tasks\n- Identify dependencies\n- Evaluate complexity',
430+
phase: 'plan',
431+
nodeCategory: 'phase',
432+
mode: 'analysis',
433+
tool: 'gemini',
434+
artifacts: ['execution-plan.md'],
435+
},
436+
},
437+
{
438+
id: 'phase-execute',
439+
label: 'Execute',
440+
description: 'Execute tasks according to plan',
441+
icon: 'Play',
442+
color: 'bg-green-500',
443+
category: 'phase',
444+
data: {
445+
label: 'Execution',
446+
instruction: 'Execute planned tasks:\n- Follow dependency order\n- Apply code changes\n- Run validation',
447+
phase: 'execute',
448+
nodeCategory: 'phase',
449+
mode: 'write',
450+
tool: 'codex',
451+
},
452+
},
453+
{
454+
id: 'phase-review',
455+
label: 'Review',
456+
description: 'Review results and validate output',
457+
icon: 'CheckCircle',
458+
color: 'bg-purple-500',
459+
category: 'phase',
460+
data: {
461+
label: 'Review',
462+
instruction: 'Review execution results:\n- Validate code changes\n- Run tests\n- Check regressions',
463+
phase: 'review',
464+
nodeCategory: 'phase',
465+
mode: 'analysis',
466+
tool: 'gemini',
467+
},
468+
},
469+
// ========== Tool Templates ==========
470+
{
471+
id: 'tool-context-gather',
472+
label: 'Context Gather',
473+
description: 'Automated context collection tool',
474+
icon: 'FolderSearch',
475+
color: 'bg-teal-500',
476+
category: 'tool',
477+
data: {
478+
label: 'Context Gather',
479+
instruction: 'Collect project context:\n- Scan file structure\n- Identify key modules\n- Extract type definitions\n- Map dependencies',
480+
tool: 'gemini',
481+
mode: 'analysis',
482+
nodeCategory: 'tool',
483+
phase: 'context',
484+
outputName: 'context',
485+
artifacts: ['context-package.json'],
486+
},
487+
},
488+
{
489+
id: 'tool-conflict-resolution',
490+
label: 'Conflict Resolution',
491+
description: 'Resolve code conflicts and inconsistencies',
492+
icon: 'GitMerge',
493+
color: 'bg-orange-500',
494+
category: 'tool',
495+
data: {
496+
label: 'Conflict Resolution',
497+
instruction: 'Resolve conflicts:\n- Identify conflicting changes\n- Analyze intent of each side\n- Generate merge solution\n- Verify consistency',
498+
tool: 'gemini',
499+
mode: 'analysis',
500+
nodeCategory: 'tool',
501+
phase: 'execute',
502+
outputName: 'resolution',
503+
},
504+
},
505+
{
506+
id: 'tool-task-generate',
507+
label: 'Task Generate',
508+
description: 'Generate task breakdown from requirements',
509+
icon: 'ListChecks',
510+
color: 'bg-indigo-500',
511+
category: 'tool',
512+
data: {
513+
label: 'Task Generation',
514+
instruction: 'Generate tasks:\n- Parse requirements\n- Break into atomic tasks\n- Set dependencies\n- Assign priorities',
515+
tool: 'gemini',
516+
mode: 'analysis',
517+
nodeCategory: 'tool',
518+
phase: 'plan',
519+
outputName: 'tasks',
520+
artifacts: ['task-list.json'],
355521
},
356522
},
357523
];

ccw/src/core/routes/cli-routes.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,9 @@ type ActiveExecutionDto = Omit<ActiveExecution, 'output'> & { output: string };
6868

6969
const activeExecutions = new Map<string, ActiveExecution>();
7070
const EXECUTION_RETENTION_MS = 5 * 60 * 1000; // 5 minutes
71-
const CLEANUP_INTERVAL_MS = 60 * 1000; // 1 minute - periodic cleanup interval
7271
const MAX_OUTPUT_BUFFER_LINES = 1000; // Max lines to keep in memory per execution
7372
const MAX_ACTIVE_EXECUTIONS = 200; // Max concurrent executions in memory
7473

75-
// Enable periodic cleanup to prevent memory buildup
76-
setInterval(() => {
77-
cleanupStaleExecutions();
78-
}, CLEANUP_INTERVAL_MS);
79-
8074
/**
8175
* Cleanup stale completed executions older than retention period
8276
* Runs periodically to prevent memory buildup

0 commit comments

Comments
 (0)