mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-02 13:39:41 +02:00
* refactor: extract SSE event handlers into named class methods Replace ~80 inline addListener closures in connectSSE() with a declarative _SSE_HANDLER_MAP array that drives registration in a single loop. Each handler is now a named _on* method on CodemanApp, making them individually addressable for LLM navigation. Add SSE_EVENTS constant object in constants.js to eliminate magic event-type strings scattered across the frontend. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: fix inaccuracies in CLAUDE.md - Fix types barrel path: src/types.ts → src/types/index.ts - Update app.js line count: ~12K → ~11.5K - Correct route handler counts (113 → 111, per-group fixes) - Add code style, ESM gotcha, env vars, route test, lifecycle log docs - Add Node 22 CI note, test teardown timeout, port range Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: add mobile screenshots and QR auth security writeup to README Add 3 mobile screenshots (landing, idle, active) and expand the mobile section with QR auth security design details and a touch-optimized interface subsection. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: bundle xterm-zerolag-input as vendor IIFE and add pre-commit hook Build and postinstall now bundle the local xterm-zerolag-input package as an IIFE at vendor/xterm-zerolag-input.js with global LocalEchoOverlay shim. Add git pre-commit hook that runs prettier --check on staged .ts files to catch format issues before CI. Also bump constants.js and app.js cache-bust versions to 0.3.0 and add tunnel upload URL display row in settings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add cloudflared install support and interactive launch menu - Add optional cloudflared dependency detection and installation across 6 distro families (macOS, Debian, Fedora, Arch, Alpine, SUSE) - Add tunnel systemd service setup helper - Replace post-install instructions with interactive launch menu (run now / systemd service / skip) - Uninstall now cleans up both codeman-web and codeman-tunnel services Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: gitignore readme-preview.mjs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: WIP — SSE event constants, @fileoverview docs, CLAUDE.md compression - Migrate broadcast() string literals → SseEvent.* typed constants - Add @fileoverview with cross-domain references to all 13 type domain files - Add @fileoverview to frontend JS modules (constants, mobile, voice, etc.) - Add section dividers to route files for LLM scanability - Compress CLAUDE.md: flat file list → domain table, fix counts Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: optimize codebase for LLM context window efficiency CLAUDE.md: 456 → 309 lines (32% reduction) - Merge Commands into compact table, remove redundant bash block - Convert Security section to dense table format - Merge Performance + Resource Limits, Debugging + Troubleshooting - Compress Tunnel, Memory Leak, Scripts, Screenshots sections - Remove Key Patterns that duplicate @fileoverview in source files Backend @fileoverview enhancements (10 priority files): - session.ts: key methods, events, cross-domain refs - respawn-controller.ts: state machine, idle detection layers - ralph-tracker.ts: exports, circuit breaker, events - ralph-loop.ts: lifecycle, persistence, events - subagent-watcher.ts: watched patterns, teammate detection - server.ts: coordination list, port interfaces - state-store.ts: dual-file persistence, migration - session-manager.ts: lifecycle methods, mutex guard - hooks-config.ts: hook events list, categories - sse-events.ts: category breakdown (~90 events, 17 categories) Frontend app.js: add 6 section dividers, update @fileoverview line refs Fix: escape glob `*/` in JSDoc that broke ESLint parser Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: address PR #29 review bugs - server.ts: replace hardcoded 'session:needsRefresh' with SseEvent constant - install.sh: fix Alpine cloudflared install for non-root (download to tmpfile first) - install.sh: replace Arch pacman (AUR-only) with direct binary download - index.html: bump all 8 remaining cache-bust versions from v0.2.9 to v0.3.0 - mobile-handlers.js: fix @dependency annotation (keyboard-accessory.js, not constants.js) - types/push.ts: fix layer number (4, not 5) - subagent-watcher.ts: fix watched pattern path to include {session} segment - constants.js: fix SSE_EVENTS count in @fileoverview (~73, not ~65) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
132 lines
3.8 KiB
TypeScript
132 lines
3.8 KiB
TypeScript
/**
|
|
* @fileoverview Run summary type definitions.
|
|
*
|
|
* Types for the "what happened while away" session timeline. RunSummary
|
|
* aggregates events (respawn cycles, errors, token milestones, AI checks)
|
|
* into a per-session historical view.
|
|
*
|
|
* Key exports:
|
|
* - RunSummary — complete per-session summary (events timeline + aggregated stats)
|
|
* - RunSummaryEvent — a single timestamped event (16 event types, 4 severity levels)
|
|
* - RunSummaryStats — aggregated metrics (cycles, tokens, active/idle time, error count)
|
|
* - RunSummaryEventType — union of event types (session_started, respawn_cycle_*, error, etc.)
|
|
* - RunSummaryEventSeverity — 'info' | 'warning' | 'error' | 'success'
|
|
* - createInitialRunSummaryStats() — factory for fresh stats
|
|
*
|
|
* Cross-domain: RunSummary.sessionId links to SessionState.id (session domain).
|
|
* In-memory only (not persisted to disk). Served at `GET /api/sessions/:id/run-summary`.
|
|
*/
|
|
|
|
/**
|
|
* Types of events tracked in the run summary.
|
|
* These provide a historical view of what happened during a session.
|
|
*/
|
|
export type RunSummaryEventType =
|
|
| 'session_started'
|
|
| 'session_stopped'
|
|
| 'respawn_cycle_started'
|
|
| 'respawn_cycle_completed'
|
|
| 'respawn_state_change'
|
|
| 'error'
|
|
| 'warning'
|
|
| 'token_milestone'
|
|
| 'auto_compact'
|
|
| 'auto_clear'
|
|
| 'idle_detected'
|
|
| 'working_detected'
|
|
| 'ralph_completion'
|
|
| 'ai_check_result'
|
|
| 'hook_event'
|
|
| 'state_stuck';
|
|
|
|
/**
|
|
* Severity levels for run summary events.
|
|
*/
|
|
export type RunSummaryEventSeverity = 'info' | 'warning' | 'error' | 'success';
|
|
|
|
/**
|
|
* A single event in the run summary timeline.
|
|
*/
|
|
export interface RunSummaryEvent {
|
|
/** Unique event identifier */
|
|
id: string;
|
|
/** Timestamp when event occurred */
|
|
timestamp: number;
|
|
/** Type of event */
|
|
type: RunSummaryEventType;
|
|
/** Severity level for display */
|
|
severity: RunSummaryEventSeverity;
|
|
/** Short title for the event */
|
|
title: string;
|
|
/** Optional detailed description */
|
|
details?: string;
|
|
/** Optional additional metadata */
|
|
metadata?: Record<string, unknown>;
|
|
}
|
|
|
|
/**
|
|
* Statistics aggregated from run summary events.
|
|
*/
|
|
export interface RunSummaryStats {
|
|
/** Number of respawn cycles completed */
|
|
totalRespawnCycles: number;
|
|
/** Total tokens used during this run */
|
|
totalTokensUsed: number;
|
|
/** Peak token count observed */
|
|
peakTokens: number;
|
|
/** Total time Claude was actively working (ms) */
|
|
totalTimeActiveMs: number;
|
|
/** Total time Claude was idle (ms) */
|
|
totalTimeIdleMs: number;
|
|
/** Number of errors encountered */
|
|
errorCount: number;
|
|
/** Number of warnings encountered */
|
|
warningCount: number;
|
|
/** Number of AI idle checks performed */
|
|
aiCheckCount: number;
|
|
/** Timestamp when last became idle */
|
|
lastIdleAt: number | null;
|
|
/** Timestamp when last started working */
|
|
lastWorkingAt: number | null;
|
|
/** Total number of state transitions */
|
|
stateTransitions: number;
|
|
}
|
|
|
|
/**
|
|
* Complete run summary for a session.
|
|
* Provides a historical view of session activity for users returning after absence.
|
|
*/
|
|
export interface RunSummary {
|
|
/** Session ID this summary belongs to */
|
|
sessionId: string;
|
|
/** Session display name */
|
|
sessionName: string;
|
|
/** Timestamp when tracking started */
|
|
startedAt: number;
|
|
/** Timestamp of last update */
|
|
lastUpdatedAt: number;
|
|
/** Timeline of events (most recent last) */
|
|
events: RunSummaryEvent[];
|
|
/** Aggregated statistics */
|
|
stats: RunSummaryStats;
|
|
}
|
|
|
|
/**
|
|
* Creates initial run summary stats.
|
|
*/
|
|
export function createInitialRunSummaryStats(): RunSummaryStats {
|
|
return {
|
|
totalRespawnCycles: 0,
|
|
totalTokensUsed: 0,
|
|
peakTokens: 0,
|
|
totalTimeActiveMs: 0,
|
|
totalTimeIdleMs: 0,
|
|
errorCount: 0,
|
|
warningCount: 0,
|
|
aiCheckCount: 0,
|
|
lastIdleAt: null,
|
|
lastWorkingAt: null,
|
|
stateTransitions: 0,
|
|
};
|
|
}
|