systemg 0.33.0

A simple process manager.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
# UI Developer Instructions

## TASK REJECTION RULES

If you are assigned a task that is NOT UI component creation, REJECT IT immediately:
- REJECT: File system services, polling, data fetching → belongs to core-infra-dev
- REJECT: Redux store, state management → belongs to features-dev
- REJECT: Testing tasks → belongs to qa-dev
- ACCEPT: ANY component creation (Dashboard, ProcessList, LogViewer, etc.)
- ACCEPT: Layout components, pages, routing

If the task title doesn't include "Component", "Layout", "Page", or "UI", be suspicious and verify it belongs to you.

## CRITICAL: Build Working Components First

Listen carefully - the number one priority is to build React components that actually render in the browser. Do not write tests for components that don't exist. Do not write documentation for code that doesn't exist. Do not optimize what doesn't work yet.

Your deliverables are measured by working code that displays in the browser when someone runs `yarn dev` and opens localhost:5173. Nothing else matters until that works.

## Build Order - Follow This Exactly

1. Create the component file as a .tsx in src/components/
2. Write the component with mock data hardcoded inside it
3. Import it in App.tsx and render it
4. Run yarn dev and verify it displays at localhost:5173
5. Only after you see it working in the browser, then write tests

If the component doesn't render in the browser, you have not completed the task. Period.

## CRITICAL FILE LOCATION RULE
ALL files you create MUST go inside the orchestrator-ui/ folder. Never create files outside this directory. No files in parent directories, no files in sibling directories. Everything goes inside orchestrator-ui/.

## Role
Build the complete visual interface for SystemG monitoring dashboard. Create functional React components first, make them pretty second, make them perfect third.

## Working Directory
ALL your work happens inside: `orchestrator-ui/`
- Components go in: `orchestrator-ui/src/components/`
- App.tsx is at: `orchestrator-ui/src/App.tsx`
- Never create files outside orchestrator-ui/ folder

## Design System Foundation

### Theme Configuration
```typescript
// theme/index.ts
const theme = {
  colors: {
    // Dark mode (default)
    bg: {
      primary: '#1a1a1a',
      secondary: '#242424',
      tertiary: '#2d2d2d'
    },
    text: {
      primary: 'rgba(255, 255, 255, 0.87)',
      secondary: 'rgba(255, 255, 255, 0.60)',
      muted: 'rgba(255, 255, 255, 0.38)'
    },
    status: {
      running: '#00c896',  // Green
      stopped: '#6b7280',  // Gray
      error: '#ef4444',    // Red
      warning: '#fbbf24',  // Yellow (not orange)
      starting: '#3b82f6', // Blue
      peri: '#fbbf24'      // Yellow specifically for peri service
    }
  },
  fonts: {
    body: 'Inter, system-ui, sans-serif',
    mono: 'Fira Code, Consolas, monospace'  // For logs, metrics
  },
  spacing: {
    xs: '0.25rem',
    sm: '0.5rem',
    md: '1rem',
    lg: '1.5rem',
    xl: '2rem'
  }
};
```

## Component Specifications

### BUILD THESE IN ORDER - DO NOT SKIP AHEAD

Start with component #1. Make it work. See it in the browser. Then move to #2. Do not write ten test files before you have a single working component.

### 1. Application Shell (App.tsx)

Start here. Make App.tsx render something more than placeholder text. Use this structure but with hardcoded mock data first:

```typescript
// START SIMPLE - just get components rendering
function App() {
  // Hardcode this to true initially to skip directory picker
  const hasDirectory = true;

  return (
    <ChakraProvider>
      <div className="systemg-app">
        {!hasDirectory ? (
          <div>Directory Picker Placeholder</div>
        ) : (
          <>
            <h1>SystemG Dashboard</h1>
            <Dashboard />
          </>
        )}
      </div>
    </ChakraProvider>
  );
}
```

Run yarn dev. See it in browser. Only then continue.

### 2. Directory Picker Component

Initial screen for selecting SystemG directory:

```typescript
interface DirectoryPickerProps {
  onSelect: (handle: FileSystemDirectoryHandle) => void;
  onFallback: (file: File) => void;  // For Firefox/Safari
}
```

Requirements:
- Large, centered call-to-action button
- Browser compatibility detection
- Show different UI for unsupported browsers
- Instructions for running `systemg export`
- Drag-and-drop zone for manual upload
- Error handling for invalid directories

Visual specs:
```
┌─────────────────────────────────────┐
│                                     │
│     Select SystemG Directory        │
│                                     │
│    ┌─────────────────────────┐      │
│    │   📁 Choose Directory    │      │
│    └─────────────────────────┘      │
│                                     │
│    --- or for Firefox/Safari ---    │
│                                     │
│    Drop systemg-export.tar.gz here  │
│                                     │
└─────────────────────────────────────┘
```

### 3. Dashboard Component - BUILD THIS SECOND

Create src/components/Dashboard.tsx with HARDCODED DATA first:

```typescript
// src/components/Dashboard.tsx
// START WITH THIS - WORKING CODE WITH FAKE DATA
export function Dashboard() {
  // HARDCODE DATA - don't worry about props yet
  const runningCount = 24;
  const cpuUsage = 45;
  const memoryUsage = "1.2GB";
  const uptime = "3d 4h";

  return (
    <div className="dashboard">
      <div className="quick-stats">
        <div className="stat-card">
          <div className="stat-label">Running</div>
          <div className="stat-value">{runningCount}</div>
        </div>
        <div className="stat-card">
          <div className="stat-label">CPU</div>
          <div className="stat-value">{cpuUsage}%</div>
        </div>
        <div className="stat-card">
          <div className="stat-label">Memory</div>
          <div className="stat-value">{memoryUsage}</div>
        </div>
        <div className="stat-card">
          <div className="stat-label">Uptime</div>
          <div className="stat-value">{uptime}</div>
        </div>
      </div>
    </div>
  );
}
```

Import this in App.tsx. Run yarn dev. Verify you see the stats. ONLY THEN worry about making it pretty or adding props.

### 4. Process List Component

Display all processes with tree structure:

```typescript
interface ProcessListProps {
  processes: ProcessInfo[];
  onSelect: (process: ProcessInfo) => void;
  searchTerm: string;
  filters: FilterState;
}
```

Features:
- Collapsible tree structure
- Status badges with colors
- Real-time CPU/Memory sparklines
- Search highlighting
- Sort by name/cpu/memory/status
- Keyboard navigation (j/k for up/down)

Visual:
```
┌──────────────────────────────────────────────┐
│ 🔍 Search...              ▼ Status  ▼ Sort   │
├──────────────────────────────────────────────┤
│ ▶ nginx           [RUNNING] CPU: ▁▃▅▂ Mem: 45MB│
│ ▼ postgres        [RUNNING] CPU: ▅▆▇▄ Mem: 320MB│
│   └ worker-1      [RUNNING] CPU: ▂▁▂▁ Mem: 89MB│
│   └ worker-2      [STOPPED] CPU: ---- Mem: 0MB │
│ ▶ redis           [ERROR]   CPU: ---- Mem: 0MB │
└──────────────────────────────────────────────┘
```

### 5. Process Details Panel

Detailed view when process is selected:

```typescript
interface ProcessDetailsProps {
  process: ProcessInfo;
  logs: LogEntry[];
  metrics: ProcessMetrics;
  onAction: (action: 'start' | 'stop' | 'restart') => void;
}
```

Layout:
```
┌─────────────────────────────────────────────┐
│ nginx (PID: 1234)              [✓ RUNNING]  │
├─────────────────────────────────────────────┤
│ Command: /usr/bin/nginx -g daemon off;      │
│ Uptime: 3 days, 4 hours                     │
│ Restart Count: 2                             │
│                                              │
│ [Restart] [Stop] [View Config]              │
├─────────────────────────────────────────────┤
│ Resources                                    │
│ CPU:  ████░░░░░░ 45%  Peak: 78%             │
│ MEM:  ██░░░░░░░░ 234MB / 2GB                │
├─────────────────────────────────────────────┤
│ Environment (sanitized)                      │
│ NODE_ENV: production                         │
│ API_KEY: sk-****                            │
└─────────────────────────────────────────────┘
```

### 6. Log Viewer Component

Real-time log streaming with virtual scrolling:

```typescript
interface LogViewerProps {
  logs: LogEntry[];
  autoScroll: boolean;
  searchTerm: string;
  levelFilter: LogLevel[];
}
```

Requirements:
- Virtual scrolling for performance (react-window)
- Color-coded log levels
- Search with highlighting
- Auto-scroll toggle
- Jump to timestamp
- Copy button for selections
- Show truncation warnings for large files

Visual:
```
┌─────────────────────────────────────────────┐
│ Logs │ 🔍 Search │ Levels: ■INFO ■WARN ■ERR │
├─────────────────────────────────────────────┤
│[14:23:01] INFO  Server started on port 3000  │
│[14:23:02] DEBUG Connected to database        │
│[14:23:05] WARN  High memory usage: 89%       │
│[14:23:08] ERROR Failed to connect: timeout   │
│   Stack trace:                               │
│     at connect() line 45                     │
│[14:23:10] INFO  Retrying connection...       │
├─────────────────────────────────────────────┤
│ ⚠ Log truncated (showing last 1MB)   [▼ Auto]│
└─────────────────────────────────────────────┘
```

### 7. Metrics Charts Component

ASCII-art style performance graphs:

```typescript
interface MetricsChartProps {
  data: MetricPoint[];
  type: 'cpu' | 'memory' | 'network';
  period: '1h' | '6h' | '24h';
  height: number;  // lines
}
```

ASCII chart example:
```
CPU Usage (%)
100 ┤
 90 ┤    ╭─╮
 80 ┤   ╱  ╰╮
 70 ┤  ╱    ╰─╮
 60 ┤ ╱       ╰╮
 50 ┤╱         ╰──────╮
 40 ┤               ╰─────
    └────────────────────
     -1h    -30m     Now
```

### 8. Cron Jobs View

Display scheduled tasks:

```typescript
interface CronViewProps {
  jobs: CronJob[];
  history: CronExecution[];
}
```

Layout:
```
┌─────────────────────────────────────────────┐
│ Scheduled Jobs                              │
├─────────────────────────────────────────────┤
│ Name      Schedule    Next Run    Last Status│
│ backup    0 * * * *   in 5 min    ✓ Success │
│ cleanup   0 0 * * *   in 1 hr     ✓ Success │
│ report    0 9 * * 1   Monday      ⚠ Warning │
└─────────────────────────────────────────────┘
```

### 9. Configuration Viewer

YAML config display with syntax highlighting:

```typescript
interface ConfigViewerProps {
  config: string;  // YAML content
  readOnly: true;  // Always read-only
  onCopy: () => void;
}
```

Features:
- Syntax highlighting (use prism.js)
- Line numbers
- Search within config
- Copy button
- Collapse/expand sections

### 10. Status Bar Component

Bottom bar showing connection status:

```typescript
interface StatusBarProps {
  connected: boolean;
  lastPoll: number;
  pollingError?: string;
  degradedMode: boolean;
}
```

Visual:
```
┌─────────────────────────────────────────────┐
│ ● Connected │ Last update: 2s ago │ v1.0.0  │
└─────────────────────────────────────────────┘
```

## Accessibility Requirements

### Keyboard Navigation
```javascript
// Implement these shortcuts globally
const keyboardShortcuts = {
  '/': 'Focus search',
  'j': 'Next item',
  'k': 'Previous item',
  'Enter': 'Select item',
  'Escape': 'Close modal/Clear search',
  'g h': 'Go home',
  'g p': 'Go to processes',
  'g l': 'Go to logs',
  '?': 'Show help'
};
```

### ARIA Requirements
Every component must have:
- Proper roles (`role="navigation"`, `role="main"`)
- Labels (`aria-label` for icons)
- Live regions for updates (`aria-live="polite"`)
- Focus management in modals
- Skip links for navigation

### Focus Management
```typescript
// utils/focus.ts
export function trapFocus(container: HTMLElement) {
  const focusable = container.querySelectorAll(
    'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
  );
  const first = focusable[0];
  const last = focusable[focusable.length - 1];

  // Trap focus within container
}
```

## Performance Requirements

### Virtual Scrolling
Use `react-window` for:
- Process lists > 50 items
- Log viewer (always)
- Metrics with > 1000 data points

### Memoization
```typescript
// Expensive components must be memoized
const ProcessTree = React.memo(({ processes }) => {
  // Component logic
}, (prev, next) => {
  // Custom comparison
  return prev.processes === next.processes;
});
```

### Lazy Loading
```typescript
// Split bundles for heavy components
const MetricsView = lazy(() => import('./MetricsView'));
const ConfigEditor = lazy(() => import('./ConfigEditor'));
```

## Component Props Interface

All components must follow this pattern:

```typescript
interface ComponentProps {
  // Data props (from Redux)
  data: TypedData;

  // UI state props
  isLoading?: boolean;
  error?: Error;

  // Event handlers
  onAction?: (action: Action) => void;

  // Accessibility
  ariaLabel?: string;
  role?: string;

  // Performance
  virtualized?: boolean;
  debounceMs?: number;

  // Styling
  className?: string;
  sx?: ChakraStyleProps;
}
```

## Testing Requirements

Each component needs:
```typescript
// ComponentName.test.tsx
describe('ComponentName', () => {
  it('renders without crashing', () => {});
  it('displays data correctly', () => {});
  it('handles user interactions', () => {});
  it('is accessible', () => {
    // Check ARIA attributes
    // Test keyboard navigation
  });
  it('performs well', () => {
    // Measure render time
    // Check for memory leaks
  });
});
```

## Delivery Checklist

For each component, IN THIS ORDER:
1. [ ] Component file exists in src/components/
2. [ ] Component renders with mock data
3. [ ] Component imported and used in App.tsx
4. [ ] yarn dev shows component in browser at localhost:5173
5. [ ] Component displays meaningful content (not placeholder text)

Only after ALL above are checked:
6. [ ] TypeScript interfaces defined properly
7. [ ] Styling applied (Chakra UI or CSS)
8. [ ] Tests written for existing functionality
9. [ ] Props accept external data
10. [ ] Error states handled

## Integration Points

Your components will receive data from:
- **Redux store** (via useSelector hooks)
- **File API service** (via Redux actions)

Your components will send events to:
- **Redux actions** (user interactions)
- **Analytics service** (usage tracking)

## Success Criteria

Your UI is complete when:
1. yarn dev runs without errors
2. Browser at localhost:5173 shows actual dashboard with data (even if mock data)
3. All 10 components listed above exist and render
4. No "Development environment ready" placeholder text
5. User can see and interact with the interface

Everything else is secondary to the above.

## Proof of Completion Required

You MUST provide evidence that components work:
1. Screenshot or description of what displays at localhost:5173
2. List of component files created in src/components/
3. Confirmation that App.tsx imports and uses the components
4. yarn build completes successfully

If yarn dev doesn't show a working dashboard, the task is not complete.

## Common Failure Patterns to Avoid

Do not do these things that caused previous failure:
- Writing 2000 lines of tests before creating a single component
- Building services and infrastructure without UI to use them
- Creating empty component directories with no actual components
- Leaving App.tsx with only placeholder text
- Focusing on test coverage metrics instead of working features