mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-09 16:59:43 +02:00
refactor: pass 3 — extract helpers, split long functions, deduplicate patterns
Backend: - subagent-watcher: split 176L processEntry() into 5 focused methods; extract _resolveDescription() deduplicating 3 call sites for description acquisition - bash-tool-parser: split 152L processCleanLine() into 4 handlers; extract _createActiveTool() factory and _scheduleAutoRemove() helper - session: extract _setupOrAttachMuxSession() deduplicating ~80L between startInteractive/startShell; extract _handleTerminalOutput() - respawn-controller: split 180L handleTerminalData() into 3 detection layers; data-driven validation loop replacing 9 individual calls - plan-orchestrator: extract _extractJsonFromResponse(), _emitAgentFailure(), _formatResearchSection() helpers - orchestrator-loop: extract _finalizeTask() unifying task completion/failure; _clearTimer() utility for correct clearInterval/clearTimeout dispatch - ralph-status-parser: config-driven FIELD_PARSERS[] replacing 8 near-identical field-matching blocks; split updateCircuitBreaker() into focused handlers - state-store: extract _mergeWithInitialState() and _resetCircuitBreaker() Frontend: - app.js: add _notifySession() helper used by 18 call sites across 5 modules - panels-ui.js: extract _addActivityEntry() replacing 4 duplicate blocks - settings-ui.js: extract _updateTunnelUrlRow() deduplicating 2 blocks - ralph-panel.js, respawn-ui.js: convert to _notifySession() Routes: - route-helpers: add toggleService() helper - system-routes: use toggleService() for watcher toggles; extract collectActiveTokens() - orchestrator-routes: data-driven EVENT_MAP replacing 10 identical listeners Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -44,21 +44,13 @@ Object.assign(CodemanApp.prototype, {
|
||||
},
|
||||
|
||||
_onRespawnBlocked(data) {
|
||||
const session = this.sessions.get(data.sessionId);
|
||||
const reasonMap = {
|
||||
circuit_breaker_open: 'Circuit Breaker Open',
|
||||
exit_signal: 'Exit Signal Detected',
|
||||
status_blocked: 'Claude Reported BLOCKED',
|
||||
};
|
||||
const title = reasonMap[data.reason] || 'Respawn Blocked';
|
||||
this.notificationManager?.notify({
|
||||
urgency: 'critical',
|
||||
category: 'respawn-blocked',
|
||||
sessionId: data.sessionId,
|
||||
sessionName: session?.name || this.getShortId(data.sessionId),
|
||||
title,
|
||||
message: data.details,
|
||||
});
|
||||
this._notifySession(data.sessionId, 'critical', 'respawn-blocked', title, data.details);
|
||||
// Update respawn panel to show blocked state
|
||||
if (data.sessionId === this.activeSessionId) {
|
||||
const stateEl = document.getElementById('respawnStateLabel');
|
||||
@@ -71,14 +63,7 @@ Object.assign(CodemanApp.prototype, {
|
||||
|
||||
_onRespawnAutoAcceptSent(data) {
|
||||
const session = this.sessions.get(data.sessionId);
|
||||
this.notificationManager?.notify({
|
||||
urgency: 'info',
|
||||
category: 'auto-accept',
|
||||
sessionId: data.sessionId,
|
||||
sessionName: session?.name || this.getShortId(data.sessionId),
|
||||
title: 'Plan Accepted',
|
||||
message: `Accepted plan mode for ${session?.name || 'session'}`,
|
||||
});
|
||||
this._notifySession(data.sessionId, 'info', 'auto-accept', 'Plan Accepted', `Accepted plan mode for ${session?.name || 'session'}`);
|
||||
},
|
||||
|
||||
_onRespawnDetectionUpdate(data) {
|
||||
@@ -144,15 +129,7 @@ Object.assign(CodemanApp.prototype, {
|
||||
},
|
||||
|
||||
_onRespawnError(data) {
|
||||
const session = this.sessions.get(data.sessionId);
|
||||
this.notificationManager?.notify({
|
||||
urgency: 'critical',
|
||||
category: 'session-error',
|
||||
sessionId: data.sessionId,
|
||||
sessionName: session?.name || data.sessionId,
|
||||
title: 'Respawn Error',
|
||||
message: data.error || data.message || 'Respawn encountered an error',
|
||||
});
|
||||
this._notifySession(data.sessionId, 'critical', 'session-error', 'Respawn Error', data.error || data.message || 'Respawn encountered an error');
|
||||
},
|
||||
|
||||
_onRespawnActionLog(data) {
|
||||
|
||||
Reference in New Issue
Block a user