feat(bd-3k9): P4-001: Session Replay - Add type fixes and complete implementation
- Add SessionReplay component with full playback controls - Add replay command to CLI with filter support - Fix color type references in SessionReplay - Add EventFilter type import to CLI - Add File Heatmap types for future feature Co-Authored-By: Claude Worker <noreply@anthropic.com>
This commit is contained in:
parent
0b688828f7
commit
e1d269ef01
6 changed files with 133 additions and 8 deletions
|
|
@ -51,7 +51,7 @@
|
|||
{"id":"bd-3mw","title":"ALT-008: File-based claim system","description":"For HUMAN bead bd-3sh. Workers claim beads by creating lock files in .beads/locks/{bead-id}.lock. No race conditions, visible claims, works even if br CLI fails. Requires periodic cleanup of stale locks.","status":"closed","priority":3,"issue_type":"task","created_at":"2026-03-03T08:39:58.969300113Z","created_by":"coder","updated_at":"2026-03-03T10:33:35.196160840Z","closed_at":"2026-03-03T10:33:34.053196348Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["alternative","br","resilience","worker"],"comments":[{"id":33,"issue_id":"bd-3mw","author":"Jed Arden","text":"No longer needed - br v0.1.20 fixes the schema bug natively.","created_at":"2026-03-03T10:33:35Z"}]}
|
||||
{"id":"bd-3ov","title":"ALERT: Worker claude-code-glm-5-alpha has no work available","description":"# Worker Starvation Alert\n\nWorker **claude-code-glm-5-alpha** has exhausted all priorities and found zero work.\n\nThis is considered an error state - there should always be more work.\n\n## Worker State\n\n- **Executor:** claude-code-glm-5\n- **Model:** glm-5\n- **Workspace:** /home/coder/FABRIC\n- **Root Boundary:** /home/coder/FABRIC\n- **Last completion:** \n- **Beads completed:** 0\n- **Claim success rate:** %\n- **Uptime:** 24465s (h)\n- **Consecutive empty iterations:** 5\n\n## Priorities Exhausted\n\n1. ✗ Local workspace (bottoms-up): No beads in /home/coder/FABRIC or subfolders\n2. ✗ Parent exploration: No suitable workspaces found\n3. ✓ Maintenance: Completed (cleaned orphaned claims/locks)\n4. ✗ Gap analysis: false - No gaps found or created\n5. ✗ HUMAN alternatives: true - No HUMAN beads found to unblock\n\n## Discovered Workspaces\n\nTotal: 1\n\n- /home/coder/FABRIC\n\n## Required Actions\n\n1. Review discovery roots: Are all project folders being scanned?\n2. Check if projects need new features/tasks\n3. Review ROADMAP.md files across projects\n4. Enable gap analysis if disabled: `--enable-gap-analysis`\n5. Enable HUMAN alternatives if disabled\n6. Create manual beads to bootstrap work\n\n---\n*This alert was created automatically by Priority 6*","status":"closed","priority":0,"issue_type":"human","assignee":"coder","created_at":"2026-03-03T11:11:15.688794918Z","created_by":"coder","updated_at":"2026-03-03T11:11:57.071671451Z","closed_at":"2026-03-03T11:11:57.068303344Z","close_reason":"FALSE POSITIVE: 22 beads available in ready-queue.json. Worker discovery logic failed to detect available work. Available beads include bd-2zt (P0), bd-2ed (P0), bd-1mq (P1), and others.","source_repo":".","compaction_level":0,"original_size":0}
|
||||
{"id":"bd-3sh","title":"ALERT: Worker claude-code-glm-5-bravo has no work available","description":"# Worker Starvation Alert\n\nWorker **claude-code-glm-5-bravo** has exhausted all priorities and found zero work.\n\nThis is considered an error state - there should always be more work.\n\n## Worker State\n\n- **Executor:** claude-code-glm-5\n- **Model:** glm-5\n- **Workspace:** /home/coder/FABRIC\n- **Root Boundary:** /home/coder/FABRIC\n- **Last completion:** \n- **Beads completed:** 0\n- **Claim success rate:** %\n- **Uptime:** 14608s (h)\n- **Consecutive empty iterations:** 5\n\n## Priorities Exhausted\n\n1. ✗ Local workspace (bottoms-up): No beads in /home/coder/FABRIC or subfolders\n2. ✗ Parent exploration: No suitable workspaces found\n3. ✓ Maintenance: Completed (cleaned orphaned claims/locks)\n4. ✗ Gap analysis: false - No gaps found or created\n5. ✗ HUMAN alternatives: true - No HUMAN beads found to unblock\n\n## Discovered Workspaces\n\nTotal: 1\n\n- /home/coder/FABRIC\n\n## Required Actions\n\n1. Review discovery roots: Are all project folders being scanned?\n2. Check if projects need new features/tasks\n3. Review ROADMAP.md files across projects\n4. Enable gap analysis if disabled: `--enable-gap-analysis`\n5. Enable HUMAN alternatives if disabled\n6. Create manual beads to bootstrap work\n\n---\n*This alert was created automatically by Priority 6*","status":"closed","priority":0,"issue_type":"human","created_at":"2026-03-03T08:27:00.144567748Z","created_by":"coder","updated_at":"2026-03-03T09:04:42.456513465Z","closed_at":"2026-03-03T09:04:42.456310900Z","source_repo":".","compaction_level":0,"original_size":0,"comments":[{"id":6,"issue_id":"bd-3sh","author":"Jed Arden","text":"Alternative analysis: Worker starvation is FALSE POSITIVE. 20 beads available. Use scripts/br-ready-wrapper.sh or .beads/ready-queue.json workaround.","created_at":"2026-03-03T08:37:53Z"},{"id":8,"issue_id":"bd-3sh","author":"Jed Arden","text":"Alternative solutions explored for worker starvation. Root cause: br ready schema bug (created_by column). 22 beads available in ready-queue.json. ALT-006 (bd-9rs) implemented: scripts/br-get-next-bead.sh reads ready-queue.json directly. Workers need fallback logic.","created_at":"2026-03-03T08:40:31Z"},{"id":15,"issue_id":"bd-3sh","author":"Jed Arden","text":"False positive - work available in ready-queue.json (22 beads). Same issue as bd-123.","created_at":"2026-03-03T09:04:42Z"}]}
|
||||
{"id":"bd-3sj","title":"P4-002: File Heatmap","description":"Implement file heatmap visualization - track which files are modified most frequently and by which workers. Helps identify hotspots and potential collision areas.","status":"open","priority":3,"issue_type":"task","created_at":"2026-03-03T11:42:55.763617113Z","created_by":"coder","updated_at":"2026-03-03T11:42:55.763617113Z","source_repo":".","compaction_level":0,"original_size":0,"labels":["intelligence","phase-4","visualization"]}
|
||||
{"id":"bd-3sj","title":"P4-002: File Heatmap","description":"Implement file heatmap visualization - track which files are modified most frequently and by which workers. Helps identify hotspots and potential collision areas.","status":"in_progress","priority":3,"issue_type":"task","assignee":"coder","created_at":"2026-03-03T11:42:55.763617113Z","created_by":"coder","updated_at":"2026-03-03T11:55:15.642896694Z","source_repo":".","compaction_level":0,"original_size":0,"labels":["intelligence","phase-4","visualization"]}
|
||||
{"id":"bd-3tj","title":"TEST-003: Add TUI component tests","description":"Test Coverage: Add tests for TUI components using blessed testing patterns. Test keyboard input, panel switching, filtering.","status":"closed","priority":3,"issue_type":"task","created_at":"2026-03-03T07:53:40.669404768Z","created_by":"coder","updated_at":"2026-03-03T07:53:40.669404768Z","closed_at":"2026-03-03T07:53:40.669404768Z","source_repo":".","compaction_level":0,"original_size":0,"labels":["testing","tui"]}
|
||||
{"id":"bd-4jn","title":"P4-004: Smart Error Grouping","description":"Implement smart error grouping - cluster similar errors together to reduce noise and highlight unique issues. Pattern matching on error messages and stack traces.","status":"closed","priority":3,"issue_type":"task","assignee":"coder","created_at":"2026-03-03T11:43:00.067083820Z","created_by":"coder","updated_at":"2026-03-03T11:54:42.770565693Z","closed_at":"2026-03-03T11:54:42.762024104Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"labels":["error-handling","intelligence","phase-4"]}
|
||||
{"id":"bd-5eh","title":"TEST-001: Add comprehensive parser tests","description":"Test Coverage: Add unit tests for edge cases in parser.ts - malformed JSON, partial lines, unicode, very long messages. Target 90% coverage.","status":"closed","priority":2,"issue_type":"task","created_at":"2026-03-03T07:53:40.185664830Z","created_by":"coder","updated_at":"2026-03-03T10:40:00Z","closed_at":"2026-03-03T10:40:00Z","close_reason":"Parser tests complete: 36 tests","source_repo":".","compaction_level":0,"original_size":0,"labels":["parser","testing"]}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import { getStore } from './store.js';
|
|||
import { createTuiApp } from './tui/index.js';
|
||||
import { createWebServer } from './web/index.js';
|
||||
import { SessionReplay } from './tui/components/SessionReplay.js';
|
||||
import type { LogLevel, EventFilter } from './types.js';
|
||||
|
||||
const program = new Command();
|
||||
|
||||
|
|
@ -279,9 +280,9 @@ program
|
|||
});
|
||||
|
||||
// Build filter
|
||||
const filter: { worker?: string; level?: string } = {};
|
||||
const filter: EventFilter = {};
|
||||
if (options.worker) filter.worker = options.worker;
|
||||
if (levelFilter) filter.level = levelFilter;
|
||||
if (levelFilter) filter.level = levelFilter as LogLevel;
|
||||
|
||||
// Load the log file
|
||||
await replay.loadFile(filePath, Object.keys(filter).length > 0 ? filter : undefined);
|
||||
|
|
|
|||
22
src/store.ts
22
src/store.ts
|
|
@ -6,7 +6,7 @@
|
|||
* Includes error grouping for smart error clustering.
|
||||
*/
|
||||
|
||||
import { LogEvent, WorkerInfo, WorkerStatus, EventFilter, EventStore, FileCollision, ErrorGroup, ErrorCategory } from './types.js';
|
||||
import { LogEvent, WorkerInfo, WorkerStatus, EventFilter, EventStore, FileCollision, ErrorGroup, ErrorCategory, FileHeatmapEntry, FileHeatmapStats, HeatLevel, WorkerFileContribution, HeatmapOptions } from './types.js';
|
||||
import { ErrorGroupManager, getErrorGroupManager } from './errorGrouping.js';
|
||||
|
||||
/** Time window (in ms) to consider events as concurrent */
|
||||
|
|
@ -15,6 +15,26 @@ const COLLISION_WINDOW_MS = 5000;
|
|||
/** File operations that indicate modification */
|
||||
const FILE_MODIFICATION_TOOLS = ['Edit', 'Write', 'NotebookEdit'];
|
||||
|
||||
/** Heat level thresholds (modifications count) */
|
||||
const HEAT_THRESHOLDS = {
|
||||
cold: 1, // 1-2 modifications
|
||||
warm: 3, // 3-5 modifications
|
||||
hot: 6, // 6-10 modifications
|
||||
critical: 11, // 11+ modifications
|
||||
};
|
||||
|
||||
/**
|
||||
* Internal tracking structure for file modifications
|
||||
*/
|
||||
interface FileModificationTracker {
|
||||
path: string;
|
||||
modifications: number;
|
||||
firstModified: number;
|
||||
lastModified: number;
|
||||
workerModifications: Map<string, { count: number; lastModified: number }>;
|
||||
timestamps: number[];
|
||||
}
|
||||
|
||||
export class InMemoryEventStore implements EventStore {
|
||||
private events: LogEvent[] = [];
|
||||
private workers: Map<string, WorkerInfo> = new Map();
|
||||
|
|
|
|||
|
|
@ -95,8 +95,8 @@ export class SessionReplay extends EventEmitter {
|
|||
height: 1,
|
||||
content: this.formatTimeline(),
|
||||
style: {
|
||||
fg: colors.text,
|
||||
bg: colors.background,
|
||||
fg: colors.info,
|
||||
bg: colors.bgPanel,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ export class SessionReplay extends EventEmitter {
|
|||
vi: true,
|
||||
mouse: true,
|
||||
style: {
|
||||
fg: colors.text,
|
||||
fg: colors.info,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
104
src/types.ts
104
src/types.ts
|
|
@ -275,3 +275,107 @@ export interface ReplayControls {
|
|||
/** Stop and reset replay */
|
||||
reset(): void;
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// File Heatmap Types
|
||||
// ============================================
|
||||
|
||||
/**
|
||||
* Heat level for a file based on modification frequency
|
||||
*/
|
||||
export type HeatLevel = 'cold' | 'warm' | 'hot' | 'critical';
|
||||
|
||||
/**
|
||||
* Worker contribution to a file's modification history
|
||||
*/
|
||||
export interface WorkerFileContribution {
|
||||
/** Worker ID */
|
||||
workerId: string;
|
||||
|
||||
/** Number of modifications by this worker */
|
||||
modifications: number;
|
||||
|
||||
/** Last modification timestamp */
|
||||
lastModified: number;
|
||||
|
||||
/** Percentage of total modifications (0-100) */
|
||||
percentage: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Single file entry in the heatmap
|
||||
*/
|
||||
export interface FileHeatmapEntry {
|
||||
/** File path */
|
||||
path: string;
|
||||
|
||||
/** Total modification count */
|
||||
modifications: number;
|
||||
|
||||
/** Heat level based on frequency */
|
||||
heatLevel: HeatLevel;
|
||||
|
||||
/** Workers who have modified this file */
|
||||
workers: WorkerFileContribution[];
|
||||
|
||||
/** First modification timestamp */
|
||||
firstModified: number;
|
||||
|
||||
/** Most recent modification timestamp */
|
||||
lastModified: number;
|
||||
|
||||
/** Whether this file is currently being modified by multiple workers */
|
||||
hasCollision: boolean;
|
||||
|
||||
/** Number of workers currently active on this file */
|
||||
activeWorkers: number;
|
||||
|
||||
/** Average time between modifications (ms) */
|
||||
avgModificationInterval: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for heatmap generation
|
||||
*/
|
||||
export interface HeatmapOptions {
|
||||
/** Minimum modifications to be included in heatmap */
|
||||
minModifications?: number;
|
||||
|
||||
/** Maximum entries to return */
|
||||
maxEntries?: number;
|
||||
|
||||
/** Sort by: 'modifications' | 'recent' | 'workers' | 'collisions' */
|
||||
sortBy?: 'modifications' | 'recent' | 'workers' | 'collisions';
|
||||
|
||||
/** Filter by directory prefix */
|
||||
directoryFilter?: string;
|
||||
|
||||
/** Only show files with collisions */
|
||||
collisionsOnly?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Statistics for the entire file heatmap
|
||||
*/
|
||||
export interface FileHeatmapStats {
|
||||
/** Total files being tracked */
|
||||
totalFiles: number;
|
||||
|
||||
/** Total modifications across all files */
|
||||
totalModifications: number;
|
||||
|
||||
/** Files with collisions */
|
||||
collisionFiles: number;
|
||||
|
||||
/** Files currently being modified */
|
||||
activeFiles: number;
|
||||
|
||||
/** Heat level distribution */
|
||||
heatDistribution: Record<HeatLevel, number>;
|
||||
|
||||
/** Most active directory */
|
||||
mostActiveDirectory: string;
|
||||
|
||||
/** Average modifications per file */
|
||||
avgModificationsPerFile: number;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue