Add comprehensive tests for the cleanup patterns used to prevent
memory leaks in long-running sessions:
- Task description cache with TTL expiration
- Promise callback null-after-rejection pattern
- Event listener tracking and removal
- DOM handler storage for frontend cleanup
- Timer/interval management
- Map cleanup patterns and safe iteration
- WeakRef/WeakMap usage patterns
- Cleanup order verification (LIFO)
Update CLAUDE.md with reference to new test file.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Added `contain: layout paint` to modal, subagent-window, log-viewer-window,
image-popup-window, plan-file-window, and plan-file-manager. This tells
the browser that these elements' layout and paint are independent from
the rest of the page, enabling rendering optimizations.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The imagePopups Map was not being cleaned up during SSE reconnects,
causing memory leaks from orphaned drag event listeners on document.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Backend fixes:
- Session: clear _recentTaskDescriptions Map in stop() and clearBuffers()
- Session: null promise callbacks after rejection in runPrompt() catch block
- Server: store subagent/image watcher listener refs and remove on shutdown
Frontend fixes:
- Plan file windows: store drag/resize handlers and clean up on close
- Plan file manager: store drag handler and clean up on close
- cleanupAllFloatingWindows: now cleans up plan file windows
These prevent unbounded memory growth in long-running sessions.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Previously killOrphanedTestScreens() would kill ANY detached claudeman
screen that wasn't in preExistingScreens. This was dangerous because:
- User screens can become temporarily detached (web server reconnect)
- Tests might start before user creates sessions
- Race conditions between screen status and cleanup timing
Now we ONLY kill screens that tests explicitly register via
registerTestScreen(). Orphaned screens are warned about but not killed.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add --session-id flag to Claude CLI startup so Claudeman and Claude share the same session ID
- Set claudeSessionId immediately on session start (no waiting for JSON messages)
- Add persistent subagentParentMap to store agent-to-tab associations permanently
- Add /api/subagent-parents endpoints for server-side persistence
- Add fallback: use active session when claudeSessionId matching fails
- Connection lines now reliably connect agent windows to their parent tabs
- Survives page refresh, reconnect, and server restart
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Change cursor to default arrow when hovering close button
- Increase clickable area with more padding
- Add subtle background highlight on hover
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove TUI from git (moved to .gitignore for local development)
- Remove React/Ink dependencies (unused in published version)
- Remove tui command from CLI
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Reduce getRecentSubagents window from 60 to 15 minutes
- Skip old/completed agents when restoring window states (10 min cutoff)
- Clear old activity data when new agent with same ID is discovered
- Force close existing window for agentId before opening fresh one
Fixes issue where old prompts/input from previous Ralph Loop runs
were displayed when clicking on subagent windows.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Localhost is treated as a secure context by browsers, so notifications
and all browser APIs work without HTTPS. Updated README, CLI help,
install script, and systemd service to default to HTTP.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When multiple Claudeman sessions share the same workingDir, subagents were
incorrectly attaching to the newest session instead of the actual parent.
Now uses direct claudeSessionId matching for reliable parent detection.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Create src/utils/regex-patterns.ts with ANSI_ESCAPE_PATTERN_FULL,
ANSI_ESCAPE_PATTERN_SIMPLE, TOKEN_PATTERN, and helper functions
- Create src/utils/token-validation.ts with MAX_SESSION_TOKENS and
validation utilities
- Update session.ts, respawn-controller.ts, ai-checker-base.ts,
ralph-tracker.ts, state-store.ts to use shared utilities
- Export all new utilities from src/utils/index.ts
Reduces code duplication while maintaining pre-compiled patterns
for performance.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- execution-bridge: track and cleanup retry timers to prevent memory leaks
- model-selector: add exhaustive type check for ModelTier
- ralph-tracker: fix division by zero when summary.total is 0
- respawn-controller: remove event listeners on stop to prevent memory leaks
- screen-manager: use Promise.allSettled for better error handling in stats
- session-manager: use Promise.allSettled for stopAllSessions resilience
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements the Execution Optimizer Rework plan that enables the system
to actually use the optimizer metadata (parallelGroups, agentType,
recommendedModel, requiresFreshContext, estimatedTokens) that was
previously generated but ignored.
New components:
- ExecutionBridge: Central coordinator that loads optimized plans,
manages parallel execution within groups, and coordinates with
SpawnOrchestrator for session-based execution
- ModelSelector: Routes tasks to appropriate models (opus/sonnet/haiku)
based on user defaults and agent type overrides. Optimizer
recommendations are advisory only - user preferences always win
- GroupScheduler: Builds topologically ordered execution groups,
manages dependencies, determines execution mode (session vs task-tool)
- ContextManager: Handles fresh context requirements via /clear+/init
or new session spawning
Features:
- Parallel task execution within groups (configurable limit)
- Group-level dependency tracking (lower groups complete first)
- Partial failure handling (continue with non-dependent tasks)
- Model configuration in App Settings > Models tab
- Agent type overrides (explore, implement, test, review)
- Execution control API endpoints (start, pause, resume, cancel)
- SSE events for real-time execution progress visibility
- Execution history tracking
API endpoints:
- GET/POST/PUT /api/execution/* for execution control
- GET/PUT /api/execution/model-config for model settings
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Verification, execution optimizer, and final review agents were receiving
the raw taskDescription instead of effectiveTaskDescription (which includes
research context). This caused them to work with outdated/wrong prompts
when regenerating plans.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add minimize button to Ralph wizard modal header
- Minimized indicator shows at bottom of screen with elapsed time
- Click indicator to restore wizard
- Add retry logic (3 attempts with exponential backoff) for plan generation
- Shows "Connection lost, retrying..." message during retries
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Session updates (like renaming) were broadcasting toDetailedState() which
doesn't include respawn controller state. The frontend would then overwrite
the session object, losing respawnEnabled/respawnConfig/respawn fields.
Added getSessionStateWithRespawn() helper that includes respawn controller
state in all session:updated broadcasts.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add _awaitingIdleConfirmation flag to prevent status bar redraws from
resetting the 2-second idle detection timeout
- Strip ANSI/OSC escape sequences before checking working patterns to
avoid false positives from window titles like '3 File Reading Task'
- Reset _awaitingIdleConfirmation on PTY exit for proper cleanup
chore: bump version to 0.1412
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
setTimeout isn't exact, so the remaining TTL after 100ms wait may be
slightly more than expected (901ms instead of ≤900ms). Adding 10ms
tolerance to prevent flaky test failures.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Automatically removes entries not accessed within TTL
- Periodic cleanup with configurable interval
- Optional onExpire callback for cleanup notifications
- Refresh TTL on get (configurable)
- Touch, peek, getAge, getRemainingTtl methods
- Full iteration support
- Implements Disposable interface
Useful for caching ephemeral data like pending tool calls, subagent activity.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace local BufferAccumulator in session.ts with shared utility
- Replace local BufferAccumulator in respawn-controller.ts with shared utility
- Import buffer constants from config/buffer-limits.ts
- Reduces code duplication and centralizes buffer management
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add Disposable, BufferConfig, MemoryMetrics, CleanupRegistration types
- Create src/config/buffer-limits.ts with consolidated buffer size constants
- Create src/config/map-limits.ts with Map size limits to prevent unbounded growth
- Implement BufferAccumulator utility with configurable trim and onTrim callback
- Implement LRUMap with automatic eviction and O(1) operations
- Implement CleanupManager for unified resource cleanup with isStopped guard
- Add comprehensive tests for all new utilities
This lays the foundation for memory leak prevention and performance improvements.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Research agent now explores local project first (CLAUDE.md priority)
- Added {WORKING_DIR} placeholder to research prompt
- New "Auto-Start After Plan" checkbox in advanced options
- Increased /init timeout from 10s to 3 minutes
- Added 3s delay after /init completes for stability
chore: bump version to 0.1409
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Each prompt now lives in its own file under src/prompts/ for easier
editing and iteration. Includes index.ts for convenient re-exports.
chore: bump version to 0.1408
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Removed depth:0 restriction so images saved in src/, assets/, etc.
are detected. Added filtering for node_modules, .git, dist, .next
for performance.
chore: bump version to 0.1407
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>