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>
Adds "Subagents for Active Tab Only" toggle in App Settings → Display:
- OFF (default): windows visible regardless of active tab (original behavior)
- ON: windows only visible when their parent tab is selected
Also improves parent session detection by checking active session first,
which fixes connection lines going to wrong tabs when multiple sessions
share the same working directory.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add 300-char rolling window to catch working patterns split across PTY chunks
- Check completion message BEFORE working patterns (priority fix)
- Clear rolling window on completion message (transition point)
- Increase working pattern absence threshold from 3s to 8s
- Add Session.isWorking safety check before confirming idle
- Add 20+ more working patterns (Compiling, Building, Processing, etc.)
- Make AI idle checker prompt more conservative (err toward WORKING)
- Update documentation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Rename Active Tools panel to Project Insights with updated styling
- Make panel bigger (450x350px) and resizable with drag handle
- Add settings toggle in Display tab to enable/disable panel
- Close subagent windows when parent session is killed/closed
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Enter the Matrix. Subagent windows now feature a full cyberpunk
terminal aesthetic:
- Deep black (#0a0a0a) background
- Phosphor green (#00ff41) text with glow effect
- Tool names pulse with neon intensity
- Timestamps in muted matrix green
- Progress lines shimmer like digital rain
Your AI agents now look like they're hacking the mainframe.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Subagent windows now visually connect to their parent session tabs with
glowing matrix-green lines that pulse with life. Windows automatically
arrange in a non-overlapping grid, and each shows its origin with a
clickable "from [session]" header.
Watch your AI agents spawn and dance across the screen, tethered to
their creators by neon threads of digital consciousness.
Changes:
- Matrix green (#00ff41) connection lines with glow effect
- Smart grid positioning prevents window overlap
- Smaller default window size (420x350) for better density
- Auto-sizing activity columns for cleaner logs
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Show "from [session name]" header in subagent windows
- Add spawn animation from parent tab position
- Draw curved SVG connection lines from tabs to windows
- Update connection lines on drag, resize, minimize, close
- Fix API response parsing (data.data not data.subagents)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The run summary tracker wasn't tracking respawn events for restored
sessions because the tracker didn't exist when setupRespawnListeners
was called during session restoration. Changed to lazy lookup so
the tracker is retrieved each time an event fires.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Export to JSON: Full data dump with all events and stats
- Export to Markdown: Formatted report with stats table and event timeline
- Downloads file directly to browser
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Server wraps SSE terminal batches with DEC 2026 sync markers
- Client extracts and strips markers, writes atomically via RAF batching
- Native terminals (WezTerm, Kitty, etc.) get full sync support
- xterm.js web gets application-layer sync via marker extraction
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements a "what happened while you were away" view for sessions:
- Track significant events: session start/stop, respawn cycles, state changes,
idle/working transitions, token milestones, auto-compact/clear, Ralph
completions, AI check results, hook events, errors/warnings
- Stats dashboard: respawn cycles, peak tokens, active/idle time, issue counts
- Timeline view with color-coded severity and emoji icons
- Filter events by type (all/errors/warnings/respawn/idle)
- State stuck detection (warns when state unchanged for 10+ minutes)
Click the chart icon on any session tab to open the Run Summary modal.
Files:
- src/run-summary.ts: RunSummaryTracker class with event tracking
- src/types.ts: RunSummary, RunSummaryEvent types
- src/web/server.ts: Integration with session/respawn events, API endpoint
- src/web/public/: Modal UI, timeline rendering, filter controls
- docs/run-summary-plan.md: Implementation plan
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement multi-phase improvement to respawn controller's idle detection:
Phase 1 - Stop Hook Detection:
- Add signalStopHook() method - definitive signal when Claude finishes
- 3s confirmation timer to handle race conditions
- Skip AI check when hook received (100% confidence)
Phase 2 - idle_prompt Detection:
- Add signalIdlePrompt() method - fires after 60s+ of idle
- Immediately confirms idle (no confirmation timer needed)
Phase 3 - Transcript File Monitoring:
- New TranscriptWatcher class watches session JSONL files
- Detects: completion, tool execution, plan mode, errors
- Signals respawn controller for supporting detection
Web UI Updates:
- Hook indicator with purple styling and pulse animation
- Shows "Stop hook received" or "idle_prompt hook received"
- 100% confidence displayed with hook-confirmed style
This significantly improves idle detection reliability by using
definitive signals from Claude Code rather than parsing terminal output.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Loosen filter to show AI check verdicts, detection confirmations
- Increase history from 20 to 50 entries
- Increase display height from 100px to 150px
- Fix subagents panel toggle icon (down when open)
- Increase subagents panel height when expanded
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add TokenUsageEntry and TokenStats types for daily tracking
- Add state-store methods for recording and retrieving daily usage
- Add /api/token-stats endpoint with daily breakdown and totals
- Add token stats modal with summary cards, 7-day bar chart, and table
- Record tokens periodically (5min) and on session delete
- Make header tokens clickable to open stats modal
- Fix subagents panel toggle icon direction (down when open)
- Increase subagents panel height when expanded
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Format tokens: 1000k → 1m, 1450k → 1.45m, etc.
- Estimate cost using Claude Sonnet pricing ($3/M input, $15/M output)
- Show estimated cost in respawn banner and header
- More accurate than stored cost which doesn't update in interactive mode
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Revert timers row to horizontal layout (timers left, action log right)
- Make detection status text more readable:
- Larger font (0.75rem)
- Better contrast (--text color)
- Semi-bold weight
- Subtle background pill
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Stack timers row vertically (timers on top, action log below)
- Reduce action log height to 60px since it's now full width
- Filter action log to show only important entries:
- Commands sent to console
- Plan-check with action taken
- Step completions
- Skip timer starts/cancels, detection updates, ai-check status
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add 100ms debounce for new file detection to allow content to be written
- Add subagent:updated event for retroactive description updates
- Extract description in processEntry when first user message is processed
- Add extractDescriptionFromFile helper with retry in file change handler
- Update SubagentTranscriptEntry.content type to support string | array
- Add test coverage for subagent:updated event
Fixes 43% failure rate where subagents displayed raw IDs instead of descriptions
due to race condition when files were discovered before first line was written.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Move Subagents panel to right side (same as Monitor)
- Add detach/float functionality with drag support
- Add resize handle for detached mode
- Clean up duplicate CSS
- Bump version to 0.1358
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Move subagents view into its own independent panel
- Position subagents panel to the left of monitor panel
- Add collapsible/closeable behavior for subagents panel
- Add responsive stacking on small screens
- Simplify monitor panel (now just Screen Sessions + Background Tasks)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Move COM shorthand to prominent position after safety warning
- Add version sync note (must match package.json)
- Consolidate Key Files into 4 logical categories
- Clarify next available test port (3128)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Condenses long prompts to ~45 chars while preserving meaning
- Removes filler words (the, a, please, I need you to, etc.)
- Cuts at natural boundaries (colons, dashes, commas)
- Falls back to word-boundary truncation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The JSONL files have message.content as a direct string, not an array
of content blocks. Now handles both formats correctly.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Double-click on subagent items in the Subagents tab to open
the floating tracking window. Includes tooltip hint.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Extract better titles from task description (first line/sentence)
- Make subagent window text white for better readability
- Expand monitor panel to 700px when subagents tab is active
- Add smooth width transition when switching tabs
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add SubagentWatcher service that discovers and tails Claude Code's subagent
transcript files (~/.claude/projects/.../subagents/agent-*.jsonl)
- Track tool calls, progress events, and messages in real-time via file watching
- Add SSE events for subagent:discovered, subagent:tool_call, subagent:progress,
subagent:message, subagent:completed
- Add REST API endpoints: GET /api/subagents, /api/subagents/:id,
/api/subagents/:id/transcript
- Add subagent panel in Monitor section showing active agents and their activity
- Add floating draggable windows that auto-open for each active agent
- Add standalone CLI tool: scripts/watch-subagents.ts for terminal monitoring
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Added documentation about test cleanup patterns, known issues with
session/case cleanup in specific test files, and manual cleanup commands
for orphaned test resources.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add isTerminalAtBottom() helper and modify batchTerminalWrite() to implement
sticky scroll behavior. When SSE terminal data arrives after tab switch,
terminal now stays scrolled to Claude input if user was already at bottom.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add AiCheckerBase abstract class to eliminate ~700 lines of duplication
between AiIdleChecker and AiPlanChecker
- Fix missing persistence fields (completionConfirmMs, noOutputTimeoutMs)
that caused custom timing values to be lost on server restart
- Extract restoreRespawnController() helper to dedupe session restoration
logic between state.json and screens.json paths
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When /respawn/stop was called, the controller was stopped but remained
in the respawnControllers map. This caused persistSessionState() to
still read config.enabled=true and save respawnEnabled=true to state.json.
On server restart, the respawn controller would be re-enabled because
state.json had respawnEnabled=true.
Fix: Remove controller from map and clear any timed respawn when
/respawn/stop is called, so persistSessionState() correctly sets
respawnEnabled=false.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add ai-plan-checker.ts to CLAUDE.md Key Files table
- Document test utilities (MockSession, MockAiIdleChecker, MockAiPlanChecker)
- Update port allocation (3127 reserved for respawn-integration)
- Add ai_checking state to respawn state diagram
- Document AI Plan Checker in respawn-state-machine.md
- Add references to test documentation files
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The ai-plan-checker.ts was passing the prompt directly as a shell argument,
which can cause E2BIG errors when the terminal buffer is large (8KB+).
This fix applies the same temp file approach already used in ai-idle-checker.ts:
- Write prompt to a temp file instead of passing as shell argument
- Pipe the file to claude via stdin: `cat prompt.txt | claude -p ...`
- Clean up prompt file after check completes
Also fixes a race condition in the cancel() method of both AI checkers where
the poll timer could fire between setting checkCancelled and clearing timers.
Now timers are cleared before resolving the promise to prevent this race.
Includes test utilities and analysis documents for the respawn controller
created by other agents:
- test/respawn-test-utils.ts - MockSession, MockAiIdleChecker utilities
- test/respawn-analysis.md - Code analysis and issue identification
- test/respawn-scenarios.md - Test scenario documentation
- test/respawn-test-plan.md - Testing architecture documentation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- persistSessionState() now saves respawnEnabled based on config.enabled
(user intent) instead of controller.state (running state)
- cleanupSession() saves respawn config BEFORE removing controller
- AiIdleChecker and AiPlanChecker constructors filter undefined values
to prevent overwriting defaults (fixes "timed out after undefinedms")
- updateConfig() methods also filter undefined values
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When respawn config objects had explicit undefined values for fields like
aiIdleCheckTimeoutMs, the spread operator would overwrite defaults with
undefined, causing "AI check timed out after undefinedms" errors.
- Add default fallbacks when saving pre-config in server.ts
- Filter out undefined values before spreading in RespawnController
- Add tests verifying undefined filtering works correctly
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add restoreTokens() method to Session class for recovery after restart
- Add GlobalStats type for cumulative usage tracking across all sessions
- Accumulate tokens from deleted sessions into global stats
- Track lifetime session count with incrementSessionsCreated()
- Add /api/stats endpoint for global stats
- Include globalStats in /api/status response
- Frontend shows aggregate tokens + cost in header
- Fix respawn controller config to filter undefined values
- Add 7 new tests for global stats functionality (v0.1343)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The AI idle checker was passing the prompt (including up to 16KB of terminal
buffer) as a command-line argument to bash -c, which exceeded the Linux
argument size limit causing "spawn E2BIG" errors.
Now writes the prompt to a temp file and pipes it to claude via stdin,
avoiding the argument size limit entirely. Temp file is cleaned up both
in the normal case (by the shell command) and on cancellation/timeout.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add state check in startPlanCheck() to prevent Enter if state changed
- sendAutoAcceptEnter() now cancels pending AI idle checks and resets state
- Log auto-accept as [command] type for visibility in action log
- Highlight command entries with blue background in action log
- Show action log row when there are actions (not just timers)
- Increase action log height and opacity for better visibility
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add 100ms delay between text and carriage return to prevent race conditions
- Add retry logic (up to 3 attempts) for carriage return with increasing delays
- Trim trailing whitespace from text to avoid spurious spaces
- Better error logging for debugging input delivery issues
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- State label now white on green pill for better visibility
- AI check shows detailed status with color-coded badges:
- Blue: Analyzing terminal output
- Green: Idle confirmed
- Yellow: Working detected
- Gray: Disabled
- Shows time since last check when recent (<2min)
- Bump version to 0.1338
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>