The plan generation API (/api/generate-plan-detailed) was incorrectly
detecting client disconnection because it listened to req.raw.on('close')
which fires when the HTTP request body finishes parsing, not when the
actual TCP connection closes.
This caused the error "Failed to parse plan - no JSON array found" because
the server would cancel all subagent sessions almost immediately after
starting them.
Fix:
- Changed from req.raw.on('close') to socket.on('close')
- Added responseSent flag to only cancel if response hasn't been sent
- Added E2E test to verify the fix
Tested with:
- Simple plan generation: 61 items, 138.5s, quality 0.82
- Smartphone app plan: 53 items, 93.4s, quality 0.75
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- SSE event listener cleanup: Track all listeners and remove on reconnect
to prevent listener accumulation (60+ listeners per connect cycle)
- Floating window cleanup: Remove drag listeners, ResizeObservers on close
- Session creation mutex: Prevent race conditions from concurrent requests
- Screen kill verification: Confirm processes are dead after kill signals
- State store circuit breaker: Prevent cascading failures with backup/recovery
- PTY spawn error handling: Wrap all spawn calls with proper error emission
- SSE graceful shutdown: Notify clients before server stops
- Async file writes: Replace blocking writeFileSync in hot paths
- DocumentFragment optimization: Batch DOM updates for plan rendering
- Timer cleanup: Clear notification/countdown timers on SSE reconnect
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add plan-orchestrator.ts with parallel subagent spawning
- Phase 1: 4 specialist subagents analyze in parallel (requirements, architecture, testing, risks)
- Phase 2: Synthesis merges and deduplicates outputs
- Phase 3: Verification subagent assigns priorities and identifies gaps
- New /api/generate-plan-detailed endpoint with SSE progress updates
- Auto-regenerate plan when switching between Standard/Enhanced modes
- Show quality score, warnings, and gaps from verification
- Rename "Detailed" to "Enhanced" button with tooltip
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add /api/sessions/:id/ralph-prompt/write endpoint to write prompt to @ralph_prompt.md
- Wizard now writes full prompt to file, then sends simple read command to Claude
- Fix session readiness check to wait for prompt character instead of notWorking flag
- Add E2E test infrastructure for ralph-loop workflow (port 3190)
- Add ralph-wizard-prod.mjs script for production testing
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix screen creation failing when using cpulimit/nice (env vars were passed
as command args instead of shell variables)
- Fix session status never becoming 'idle' after startInteractive()
- Add automatic state file cleanup on startup (removes orphaned sessions)
- Add /api/cleanup-state endpoint for manual cleanup
- Make frontend session readiness check more robust (20 attempts, multiple checks)
- Add fallback to direct PTY write if writeViaScreen fails
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
CPU Limiting:
- Add CpuLimitConfig type and settings in App Settings
- Use nice command for process priority (-20 to 19)
- Optional cpulimit integration for hard CPU limits (if installed)
- Applied to new sessions via screen-manager and session modules
Ralph Loop Wizard:
- 3-step wizard: Describe → Plan → Launch
- New /api/generate-plan endpoint generates implementation steps via Claude
- Plan editor with checkboxes, priorities (P0/P1/P2), reordering
- Skip plan option for manual workflows
- Compact wizard modal layout
UI Updates:
- Form section headers for grouped settings
- CPU limit status indicator (cpulimit availability)
- Wizard modal wider layout and inline fields
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Bug 1 - Wrong parent attachment with same workingDir:
- Rewrote findParentSessionForSubagent() with two-strategy approach
- Strategy 1: Sibling matching - check if another subagent with same
Claude sessionId already has a parent assigned, use that
- Strategy 2: Heuristic fallback - if multiple sessions match by
workingDir, prefer the most recently created session
- Removes bias toward active session that caused wrong attachment
Bug 2 - Stale parentSessionName after rename:
- Added updateSubagentParentNames() method to refresh cached names
- Called from session:updated SSE handler when session changes
- Updates both the agent object and window header DOM element
- Refreshes connection lines after name updates
Also includes unrelated plan generation wizard changes that were
already staged in app.js.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add File Browser panel (right-side) showing project files in a tree view
- API endpoints: /api/sessions/:id/files, /api/sessions/:id/file-content
- Tree view with expand/collapse, filtering, file icons by type
- File preview overlay for text, images, and video
- Excludes common large directories (.git, node_modules, etc.)
- Refactor App Settings with compact 2-column grid layout
- Display tab: Header Displays, Panels, Subagent Options sections
- Notifications tab: Master Control, Alerts, Notification Levels sections
- Smaller switches (28x16px) with tooltips instead of form hints
- ~35% vertical space reduction
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
API Endpoints:
- GET /api/sessions/:id/fix-plan - Generate fix plan markdown from todos
- POST /api/sessions/:id/fix-plan/import - Import todos from markdown
- POST /api/sessions/:id/fix-plan/write - Write @fix_plan.md to working dir
- POST /api/sessions/:id/fix-plan/read - Read and import from working dir
RalphTracker Methods:
- generateFixPlanMarkdown() - Creates structured markdown with priority sections
- importFixPlanMarkdown() - Parses markdown and imports todos with priorities
UI Features:
- Menu dropdown in Ralph panel (hamburger icon)
- View Fix Plan modal with copy/write buttons
- Import from file button
- Reset Circuit Breaker button
- Fix plan modal with syntax-highlighted textarea
Bump version to 0.1392
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Smart Respawn Integration (2.5):
- Check circuit breaker OPEN state before respawn (blocks cycle)
- Check RALPH_STATUS EXIT_SIGNAL=true to stop respawn
- Check STATUS=BLOCKED to pause respawn for human intervention
- Use RECOMMENDATION from RALPH_STATUS in update prompt
- Emit respawn:blocked SSE event with reason and details
- Show notification when respawn is blocked
- Visual blocked state with pulsing red indicator
Priority-based Todos (part of 2.3):
- Add RalphTodoPriority type (P0/P1/P2/null)
- Parse priority from todo content (P0:, Critical:, High Priority, etc.)
- Add priority field to RalphTodoItem interface
- Update frontend to display priority badges with colors
- Sort todos by priority (P0 > P1 > P2) then by status
- Add CSS for priority badges and highlighted cards
Bump version to 0.1391
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Phase 1 Ralph enhancement implementation:
- Parse RALPH_STATUS blocks from Claude output (status, tasks, files, tests)
- Circuit breaker state machine (CLOSED → HALF_OPEN → OPEN) for stuck detection
- Dual-condition exit gate (completion indicators >= 2 AND EXIT_SIGNAL)
- Frontend: circuit breaker badge (yellow warning, red stuck), status block display
- API: circuit breaker reset endpoint, ralph status endpoint
- Notifications when circuit breaker opens or exit gate is met
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- restoreSubagentWindowStates now discovers parent sessions before restoring
- closeSubagentWindow discovers parent before minimizing to prevent wrong tab
- Fixed async handling in subagent:completed event handler
chore: bump version to 0.1389
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement pending hooks state machine to track hook events per session.
Tab alerts now derive from pending hooks rather than being set directly,
so session:working events don't clear alerts when prompts are still pending.
- Add pendingHooks Map to track permission_prompt, elicitation_dialog, idle_prompt
- Action hooks (permission/elicitation) take priority over idle for alert type
- hook:stop clears all pending hooks when Claude finishes responding
- selectSession() only clears idle hooks; action hooks persist until user input
- User input clears all pending hooks (they've addressed the prompt)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add Live Agent Visualization section with floating windows, connection lines, status indicators
- Add Project Insights Panel section for real-time tool visibility
- Add Run Summary section for "what happened while away" feature
- Add Subagents API endpoints documentation
- Add Run Summary API endpoint
- Update architecture diagram with Subagent Watcher and Background Agents
- Update tagline to include "Visualize agents"
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add getLightState() and getLightSessionsState() methods
- SSE init payload reduced from ~1.9MB to ~5KB (~400x smaller)
- Terminal buffers are fetched on-demand when switching tabs
- Fixes UI becoming unresponsive on SSE reconnect
chore: bump version to 0.1388
- Subagent windows now always minimize instead of being removed
- restoreSubagentWindow recreates window if it was deleted
- Badge now shows "Agent 1" instead of just "1"
- Use activeSessionId as fallback parent for orphan agents
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Session creation now parallelized (3x faster for multiple tabs)
- Minimized agents badge: compact, hover-triggered, auto-hide
- Removed "Minimized Agents" header, status dots instead of text
- Click to pin dropdown open, hover for quick access
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add warningTimer to AgentContext and clean it up in cleanupAgent
- Clear all state in subagent-watcher stop() for clean restart
- Add cleanupStaleAgents() to remove completed agents older than 24h
- Delete pendingToolCalls entries after lookup to prevent memory leak
- Add FSWatcher error handlers to prevent unhandled exceptions
- Bump version to 0.1382
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Session Manager:
- Store event handlers for proper cleanup on session stop
- Add resetSessionManager() for test isolation
State Store:
- Use atomic write pattern (temp file + rename) to prevent corruption
- Add tokenStats to AppState interface
Subagent Watcher:
- Clean up pendingToolCalls on agent completion
- Add cleanupStaleAgents() for 24h+ old agents
- Clear all state maps on stop() for clean restart
Web Server:
- Remove listeners from transcript watcher before stopping
- Clean up respawn timers when session is deleted
- Use cleanupSession() in spawn orchestrator for proper resource cleanup
Frontend:
- Close existing EventSource before reconnecting to prevent duplicates
- Close failed connection before scheduling reconnect
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add max 500k tokens per session limit (Claude's context is ~200k)
- Add max 100k tokens per update to prevent sudden jumps from parsing errors
- Reject "M" suffix values > 0.5M to prevent false matches in output text
- Add validation to restoreTokens() to reject corrupted values from state.json
- Add validation to addToGlobalStats() for negative and absurd values
- Fix daily sessions count: track unique session IDs instead of incrementing
on every 5-minute recording interval
- Pass sessionId to recordDailyUsage() for accurate session counting
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Instead of timing-based correlation between terminal output and subagent
files, now reads the Task tool's description parameter directly from the
parent session's transcript. This provides 100% reliable mapping between
agent IDs and their short descriptions, fixing issues where multiple
agents spawned in quick succession would get the same window title.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add parseTaskDescriptionsFromTerminalData() to parse raw terminal data in
interactive sessions (not just one-shot mode)
- Strip ANSI codes before regex matching since terminal output has embedded
codes like [1mExplore[0m
- Fix getTaskDescriptionForSubagent() to check ALL sessions with matching
project hash (not just the first one found) since multiple sessions can
share the same working directory
- Add tool_result event forwarding for subagent SSE broadcasts
The pattern Explore(Description) in terminal output is now correctly parsed
and used as the subagent window title instead of extracting from the prompt.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Extract short description from TaskTracker (params.description) for subagent windows
- Correlate subagents with sessions by working directory and timing
- Auto-minimize subagent windows when agents complete
- Persist minimized/open window states to server for cross-browser sync
- Restore window states on reconnection/page reload
- New API: GET/PUT /api/subagent-window-states
- State file: ~/.claudeman/subagent-window-states.json
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Subagents (Task tool background agents) are autonomous and cannot
receive input mid-execution. They complete and return results to
the parent session. Removed the input UI and API endpoint.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add install.sh with curl one-liner installation
- Supports macOS (Homebrew), Debian/Ubuntu (apt), Fedora (dnf), Arch (pacman), Alpine (apk)
- Auto-detects OS, architecture, and Linux distro
- Checks/installs Node.js 18+, GNU Screen, warns about Claude CLI
- Clones to ~/.claudeman/app, builds, adds to PATH
- Optional systemd service setup on Linux
- Add postinstall.js for npm install verification
- Update README with simplified installation section
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add idle (yellow) and completed (blue) status colors to match the
minimized robot tab styling. Also use var(--green) for active status
for consistency with dropdown badges.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When sessions were restored after server restart, lastRecordedTokens
was not initialized, causing the periodic token recording to treat
the entire restored token count as new usage. This inflated daily
stats by re-counting tokens on every server restart.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Prevents false idle detection when server is rebuilt/restarted.
Previously, restored respawn controllers would start immediately
and trigger after 30s of "no output" because the session wasn't
fully connected yet.
Now waits 2 minutes from server startup before activating restored
respawn controllers, giving sessions time to reconnect and stabilize.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The .session-tabs container has contain:layout which creates a new
containing block, breaking position:fixed on the dropdown. Fixed by
moving the dropdown to document.body when opened (portal pattern),
then moving it back when closed.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The dropdown was being clipped by .session-tabs overflow-y:auto.
Changed from position:absolute to position:fixed and calculate
position dynamically in JS using getBoundingClientRect().
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>