aicodeman 0.4.1 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/api.d.ts +0 -6
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/api.js +1 -1
- package/dist/types/api.js.map +1 -1
- package/dist/web/public/{api-client.eb389d1b.js → api-client.3adebdc2.js} +1 -1
- package/dist/web/public/api-client.3adebdc2.js.br +0 -0
- package/dist/web/public/api-client.3adebdc2.js.gz +0 -0
- package/dist/web/public/app.9dab4ee2.js +26 -0
- package/dist/web/public/app.9dab4ee2.js.br +0 -0
- package/dist/web/public/app.9dab4ee2.js.gz +0 -0
- package/dist/web/public/{constants.7555acc0.js → constants.cd61abbc.js} +4 -2
- package/dist/web/public/constants.cd61abbc.js.br +0 -0
- package/dist/web/public/constants.cd61abbc.js.gz +0 -0
- package/dist/web/public/index.html +17 -11
- package/dist/web/public/index.html.br +0 -0
- package/dist/web/public/index.html.gz +0 -0
- package/dist/web/public/input-cjk.92544c51.js.gz +0 -0
- package/dist/web/public/{keyboard-accessory.30cd57bd.js → keyboard-accessory.9fb81db6.js} +1 -1
- package/dist/web/public/keyboard-accessory.9fb81db6.js.br +0 -0
- package/dist/web/public/keyboard-accessory.9fb81db6.js.gz +0 -0
- package/dist/web/public/{mobile-handlers.91ad48b8.js → mobile-handlers.d4830fd3.js} +1 -1
- package/dist/web/public/mobile-handlers.d4830fd3.js.br +0 -0
- package/dist/web/public/mobile-handlers.d4830fd3.js.gz +0 -0
- package/dist/web/public/mobile.42fde818.css.gz +0 -0
- package/dist/web/public/{notification-manager.2e817554.js → notification-manager.2d5ea8ec.js} +1 -1
- package/dist/web/public/notification-manager.2d5ea8ec.js.br +0 -0
- package/dist/web/public/notification-manager.2d5ea8ec.js.gz +0 -0
- package/dist/web/public/panels-ui.d7f6be08.js +240 -0
- package/dist/web/public/panels-ui.d7f6be08.js.br +0 -0
- package/dist/web/public/panels-ui.d7f6be08.js.gz +0 -0
- package/dist/web/public/ralph-panel.7b014f16.js +69 -0
- package/dist/web/public/ralph-panel.7b014f16.js.br +0 -0
- package/dist/web/public/ralph-panel.7b014f16.js.gz +0 -0
- package/dist/web/public/{ralph-wizard.44a8d04a.js → ralph-wizard.f31ab90e.js} +1 -1
- package/dist/web/public/ralph-wizard.f31ab90e.js.br +0 -0
- package/dist/web/public/ralph-wizard.f31ab90e.js.gz +0 -0
- package/dist/web/public/respawn-ui.372c6ea7.js +47 -0
- package/dist/web/public/respawn-ui.372c6ea7.js.br +0 -0
- package/dist/web/public/respawn-ui.372c6ea7.js.gz +0 -0
- package/dist/web/public/session-ui.0a07c3b7.js +16 -0
- package/dist/web/public/session-ui.0a07c3b7.js.br +0 -0
- package/dist/web/public/session-ui.0a07c3b7.js.gz +0 -0
- package/dist/web/public/settings-ui.94c57184.js +55 -0
- package/dist/web/public/settings-ui.94c57184.js.br +0 -0
- package/dist/web/public/settings-ui.94c57184.js.gz +0 -0
- package/dist/web/public/styles.b8ec2f5a.css.gz +0 -0
- package/dist/web/public/{subagent-windows.eb8470b0.js → subagent-windows.a366a4ad.js} +2 -2
- package/dist/web/public/subagent-windows.a366a4ad.js.br +0 -0
- package/dist/web/public/subagent-windows.a366a4ad.js.gz +0 -0
- package/dist/web/public/sw.js.gz +0 -0
- package/dist/web/public/terminal-ui.e4565c7b.js +3 -0
- package/dist/web/public/terminal-ui.e4565c7b.js.br +0 -0
- package/dist/web/public/terminal-ui.e4565c7b.js.gz +0 -0
- package/dist/web/public/upload.html.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-fit.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-unicode11.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-webgl.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-zerolag-input.137ad9f0.js.gz +0 -0
- package/dist/web/public/vendor/xterm.css.gz +0 -0
- package/dist/web/public/vendor/xterm.min.js.gz +0 -0
- package/dist/web/public/{voice-input.4c22ccd8.js → voice-input.085e9e73.js} +1 -1
- package/dist/web/public/voice-input.085e9e73.js.br +0 -0
- package/dist/web/public/voice-input.085e9e73.js.gz +0 -0
- package/dist/web/routes/case-routes.d.ts.map +1 -1
- package/dist/web/routes/case-routes.js +40 -91
- package/dist/web/routes/case-routes.js.map +1 -1
- package/dist/web/routes/system-routes.js +3 -3
- package/dist/web/routes/system-routes.js.map +1 -1
- package/package.json +1 -1
- package/dist/web/public/api-client.eb389d1b.js.br +0 -0
- package/dist/web/public/api-client.eb389d1b.js.gz +0 -0
- package/dist/web/public/app.f3a26c70.js +0 -450
- package/dist/web/public/app.f3a26c70.js.br +0 -0
- package/dist/web/public/app.f3a26c70.js.gz +0 -0
- package/dist/web/public/constants.7555acc0.js.br +0 -0
- package/dist/web/public/constants.7555acc0.js.gz +0 -0
- package/dist/web/public/keyboard-accessory.30cd57bd.js.br +0 -0
- package/dist/web/public/keyboard-accessory.30cd57bd.js.gz +0 -0
- package/dist/web/public/mobile-handlers.91ad48b8.js.br +0 -0
- package/dist/web/public/mobile-handlers.91ad48b8.js.gz +0 -0
- package/dist/web/public/notification-manager.2e817554.js.br +0 -0
- package/dist/web/public/notification-manager.2e817554.js.gz +0 -0
- package/dist/web/public/ralph-wizard.44a8d04a.js.br +0 -0
- package/dist/web/public/ralph-wizard.44a8d04a.js.gz +0 -0
- package/dist/web/public/subagent-windows.eb8470b0.js.br +0 -0
- package/dist/web/public/subagent-windows.eb8470b0.js.gz +0 -0
- package/dist/web/public/voice-input.4c22ccd8.js.br +0 -0
- package/dist/web/public/voice-input.4c22ccd8.js.gz +0 -0
package/dist/types/api.d.ts
CHANGED
|
@@ -82,12 +82,6 @@ export interface CaseInfo {
|
|
|
82
82
|
/** Whether CLAUDE.md exists */
|
|
83
83
|
hasClaudeMd?: boolean;
|
|
84
84
|
}
|
|
85
|
-
/**
|
|
86
|
-
* Type guard to check if a value is an Error instance
|
|
87
|
-
* @param value The value to check
|
|
88
|
-
* @returns True if the value is an Error instance
|
|
89
|
-
*/
|
|
90
|
-
export declare function isError(value: unknown): value is Error;
|
|
91
85
|
/**
|
|
92
86
|
* Safely extracts an error message from an unknown caught value.
|
|
93
87
|
* Handles the TypeScript 4.4+ unknown error type in catch blocks.
|
package/dist/types/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/types/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;GAEG;AACH,oBAAY,YAAY;IACtB,yBAAyB;IACzB,SAAS,cAAc;IACvB,6BAA6B;IAC7B,aAAa,kBAAkB;IAC/B,gCAAgC;IAChC,YAAY,iBAAiB;IAC7B,uBAAuB;IACvB,gBAAgB,qBAAqB;IACrC,8BAA8B;IAC9B,cAAc,mBAAmB;IACjC,4BAA4B;IAC5B,cAAc,mBAAmB;CAClC;AAcD;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,aAAa,GACb,mBAAmB,GACnB,oBAAoB,GACpB,MAAM,GACN,eAAe,GACf,gBAAgB,CAAC;AAIrB;;;GAGG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,GAAG,OAAO,IAC/B;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,CAAC,EAAE,CAAC,CAAA;CAAE,GAC3B;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,YAAY,CAAA;CAAE,CAAC;AAE/D;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC,KAAK,CAAC,CAM5F;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,oCAAoC;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,yBAAyB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,gBAAgB;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/types/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;GAEG;AACH,oBAAY,YAAY;IACtB,yBAAyB;IACzB,SAAS,cAAc;IACvB,6BAA6B;IAC7B,aAAa,kBAAkB;IAC/B,gCAAgC;IAChC,YAAY,iBAAiB;IAC7B,uBAAuB;IACvB,gBAAgB,qBAAqB;IACrC,8BAA8B;IAC9B,cAAc,mBAAmB;IACjC,4BAA4B;IAC5B,cAAc,mBAAmB;CAClC;AAcD;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,aAAa,GACb,mBAAmB,GACnB,oBAAoB,GACpB,MAAM,GACN,eAAe,GACf,gBAAgB,CAAC;AAIrB;;;GAGG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,GAAG,OAAO,IAC/B;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,CAAC,EAAE,CAAC,CAAA;CAAE,GAC3B;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,YAAY,CAAA;CAAE,CAAC;AAE/D;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC,KAAK,CAAC,CAM5F;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,oCAAoC;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,yBAAyB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,gBAAgB;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAaD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAWtD"}
|
package/dist/types/api.js
CHANGED
package/dist/types/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/types/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;GAEG;AACH,MAAM,CAAN,IAAY,YAaX;AAbD,WAAY,YAAY;IACtB,yBAAyB;IACzB,uCAAuB,CAAA;IACvB,6BAA6B;IAC7B,+CAA+B,CAAA;IAC/B,gCAAgC;IAChC,6CAA6B,CAAA;IAC7B,uBAAuB;IACvB,qDAAqC,CAAA;IACrC,8BAA8B;IAC9B,iDAAiC,CAAA;IACjC,4BAA4B;IAC5B,iDAAiC,CAAA;AACnC,CAAC,EAbW,YAAY,KAAZ,YAAY,QAavB;AAED;;GAEG;AACH,MAAM,aAAa,GAAiC;IAClD,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,sCAAsC;IAChE,CAAC,YAAY,CAAC,aAAa,CAAC,EAAE,wBAAwB;IACtD,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,2BAA2B;IACxD,CAAC,YAAY,CAAC,gBAAgB,CAAC,EAAE,sBAAsB;IACvD,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE,yBAAyB;IACxD,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE,4BAA4B;CAC5D,CAAC;AAuBF;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAkB,EAAE,OAAgB;IACtE,OAAO;QACL,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC;QACrC,SAAS,EAAE,IAAI;KAChB,CAAC;AACJ,CAAC;AA8BD,iDAAiD;AAEjD;;;;GAIG;AACH,
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/types/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;GAEG;AACH,MAAM,CAAN,IAAY,YAaX;AAbD,WAAY,YAAY;IACtB,yBAAyB;IACzB,uCAAuB,CAAA;IACvB,6BAA6B;IAC7B,+CAA+B,CAAA;IAC/B,gCAAgC;IAChC,6CAA6B,CAAA;IAC7B,uBAAuB;IACvB,qDAAqC,CAAA;IACrC,8BAA8B;IAC9B,iDAAiC,CAAA;IACjC,4BAA4B;IAC5B,iDAAiC,CAAA;AACnC,CAAC,EAbW,YAAY,KAAZ,YAAY,QAavB;AAED;;GAEG;AACH,MAAM,aAAa,GAAiC;IAClD,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,sCAAsC;IAChE,CAAC,YAAY,CAAC,aAAa,CAAC,EAAE,wBAAwB;IACtD,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,2BAA2B;IACxD,CAAC,YAAY,CAAC,gBAAgB,CAAC,EAAE,sBAAsB;IACvD,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE,yBAAyB;IACxD,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE,4BAA4B;CAC5D,CAAC;AAuBF;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAkB,EAAE,OAAgB;IACtE,OAAO;QACL,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC;QACrC,SAAS,EAAE,IAAI;KAChB,CAAC;AACJ,CAAC;AA8BD,iDAAiD;AAEjD;;;;GAIG;AACH,SAAS,OAAO,CAAC,KAAc;IAC7B,OAAO,KAAK,YAAY,KAAK,CAAC;AAChC,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACnB,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,SAAS,IAAI,KAAK,EAAE,CAAC;QAC7D,OAAO,MAAM,CAAE,KAA8B,CAAC,OAAO,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,2BAA2B,CAAC;AACrC,CAAC"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @mixin Extends CodemanApp.prototype via Object.assign
|
|
9
9
|
* @dependency app.js (CodemanApp class must be defined)
|
|
10
|
-
* @loadorder
|
|
10
|
+
* @loadorder 14 of 15 — loaded after ralph-wizard.js
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
// Codeman — Centralized API fetch helpers for CodemanApp
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";const _crashDiag={_entries:[],_maxEntries:50,log(l){const e=`${new Date().toISOString().slice(11,23)} ${l}`;this._entries.push(e),this._entries.length>this._maxEntries&&this._entries.shift();try{localStorage.setItem("codeman-crash-diag",this._entries.join(`
|
|
2
|
+
`))}catch{}}};try{const l=localStorage.getItem("codeman-crash-diag");l&&console.log(`[CRASH-DIAG] Previous session breadcrumbs:
|
|
3
|
+
`+l)}catch{}if(_crashDiag.log("PAGE LOAD"),setInterval(()=>{try{localStorage.setItem("codeman-crash-heartbeat",String(Date.now())),_crashDiag._entries.length>0&&navigator.sendBeacon("/api/crash-diag",JSON.stringify({data:_crashDiag._entries.join(`
|
|
4
|
+
`)}))}catch{}},2e3),window.addEventListener("error",l=>{_crashDiag.log(`ERROR: ${l.message} at ${l.filename}:${l.lineno}`),console.error("[CRASH-DIAG] Uncaught error:",l.message,`
|
|
5
|
+
File:`,l.filename,":",l.lineno,":",l.colno,`
|
|
6
|
+
Stack:`,l.error?.stack)}),window.addEventListener("unhandledrejection",l=>{_crashDiag.log(`UNHANDLED: ${l.reason?.message||l.reason}`),console.error("[CRASH-DIAG] Unhandled promise rejection:",l.reason?.message||l.reason,`
|
|
7
|
+
Stack:`,l.reason?.stack)}),typeof PerformanceObserver<"u")try{new PerformanceObserver(e=>{for(const t of e.getEntries())t.duration>200&&(_crashDiag.log(`LONG_TASK: ${t.duration.toFixed(0)}ms`),console.warn(`[CRASH-DIAG] Long task: ${t.duration.toFixed(0)}ms (type: ${t.entryType}, name: ${t.name})`))}).observe({type:"longtask",buffered:!0})}catch{}const _origGetContext=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=function(l,...e){const t=_origGetContext.call(this,l,...e);return(l==="webgl2"||l==="webgl")&&(this.addEventListener("webglcontextlost",s=>{_crashDiag.log(`WEBGL_LOST: ${this.width}x${this.height}`),console.error("[CRASH-DIAG] WebGL context LOST on canvas",this.width,"x",this.height,"\u2014 prevented:",s.defaultPrevented)}),this.addEventListener("webglcontextrestored",()=>{_crashDiag.log("WEBGL_RESTORED"),console.warn("[CRASH-DIAG] WebGL context restored")})),t};const _SSE_HANDLER_MAP=[[SSE_EVENTS.INIT,"_onInit"],[SSE_EVENTS.SESSION_CREATED,"_onSessionCreated"],[SSE_EVENTS.SESSION_UPDATED,"_onSessionUpdated"],[SSE_EVENTS.SESSION_DELETED,"_onSessionDeleted"],[SSE_EVENTS.SESSION_TERMINAL,"_onSSETerminal"],[SSE_EVENTS.SESSION_NEEDS_REFRESH,"_onSSENeedsRefresh"],[SSE_EVENTS.SESSION_CLEAR_TERMINAL,"_onSSEClearTerminal"],[SSE_EVENTS.SESSION_COMPLETION,"_onSessionCompletion"],[SSE_EVENTS.SESSION_ERROR,"_onSessionError"],[SSE_EVENTS.SESSION_EXIT,"_onSessionExit"],[SSE_EVENTS.SESSION_IDLE,"_onSessionIdle"],[SSE_EVENTS.SESSION_WORKING,"_onSessionWorking"],[SSE_EVENTS.SESSION_AUTO_CLEAR,"_onSessionAutoClear"],[SSE_EVENTS.SESSION_CLI_INFO,"_onSessionCliInfo"],[SSE_EVENTS.SCHEDULED_CREATED,"_onScheduledCreated"],[SSE_EVENTS.SCHEDULED_UPDATED,"_onScheduledUpdated"],[SSE_EVENTS.SCHEDULED_COMPLETED,"_onScheduledCompleted"],[SSE_EVENTS.SCHEDULED_STOPPED,"_onScheduledStopped"],[SSE_EVENTS.RESPAWN_STARTED,"_onRespawnStarted"],[SSE_EVENTS.RESPAWN_STOPPED,"_onRespawnStopped"],[SSE_EVENTS.RESPAWN_STATE_CHANGED,"_onRespawnStateChanged"],[SSE_EVENTS.RESPAWN_CYCLE_STARTED,"_onRespawnCycleStarted"],[SSE_EVENTS.RESPAWN_BLOCKED,"_onRespawnBlocked"],[SSE_EVENTS.RESPAWN_AUTO_ACCEPT_SENT,"_onRespawnAutoAcceptSent"],[SSE_EVENTS.RESPAWN_DETECTION_UPDATE,"_onRespawnDetectionUpdate"],[SSE_EVENTS.RESPAWN_TIMER_STARTED,"_onRespawnTimerStarted"],[SSE_EVENTS.RESPAWN_TIMER_CANCELLED,"_onRespawnTimerCancelled"],[SSE_EVENTS.RESPAWN_TIMER_COMPLETED,"_onRespawnTimerCompleted"],[SSE_EVENTS.RESPAWN_ERROR,"_onRespawnError"],[SSE_EVENTS.RESPAWN_ACTION_LOG,"_onRespawnActionLog"],[SSE_EVENTS.TASK_CREATED,"_onTaskCreated"],[SSE_EVENTS.TASK_COMPLETED,"_onTaskCompleted"],[SSE_EVENTS.TASK_FAILED,"_onTaskFailed"],[SSE_EVENTS.TASK_UPDATED,"_onTaskUpdated"],[SSE_EVENTS.MUX_CREATED,"_onMuxCreated"],[SSE_EVENTS.MUX_KILLED,"_onMuxKilled"],[SSE_EVENTS.MUX_DIED,"_onMuxDied"],[SSE_EVENTS.MUX_STATS_UPDATED,"_onMuxStatsUpdated"],[SSE_EVENTS.SESSION_RALPH_LOOP_UPDATE,"_onRalphLoopUpdate"],[SSE_EVENTS.SESSION_RALPH_TODO_UPDATE,"_onRalphTodoUpdate"],[SSE_EVENTS.SESSION_RALPH_COMPLETION_DETECTED,"_onRalphCompletionDetected"],[SSE_EVENTS.SESSION_RALPH_STATUS_UPDATE,"_onRalphStatusUpdate"],[SSE_EVENTS.SESSION_CIRCUIT_BREAKER_UPDATE,"_onCircuitBreakerUpdate"],[SSE_EVENTS.SESSION_EXIT_GATE_MET,"_onExitGateMet"],[SSE_EVENTS.SESSION_BASH_TOOL_START,"_onBashToolStart"],[SSE_EVENTS.SESSION_BASH_TOOL_END,"_onBashToolEnd"],[SSE_EVENTS.SESSION_BASH_TOOLS_UPDATE,"_onBashToolsUpdate"],[SSE_EVENTS.HOOK_IDLE_PROMPT,"_onHookIdlePrompt"],[SSE_EVENTS.HOOK_PERMISSION_PROMPT,"_onHookPermissionPrompt"],[SSE_EVENTS.HOOK_ELICITATION_DIALOG,"_onHookElicitationDialog"],[SSE_EVENTS.HOOK_STOP,"_onHookStop"],[SSE_EVENTS.HOOK_TEAMMATE_IDLE,"_onHookTeammateIdle"],[SSE_EVENTS.HOOK_TASK_COMPLETED,"_onHookTaskCompleted"],[SSE_EVENTS.SUBAGENT_DISCOVERED,"_onSubagentDiscovered"],[SSE_EVENTS.SUBAGENT_UPDATED,"_onSubagentUpdated"],[SSE_EVENTS.SUBAGENT_TOOL_CALL,"_onSubagentToolCall"],[SSE_EVENTS.SUBAGENT_PROGRESS,"_onSubagentProgress"],[SSE_EVENTS.SUBAGENT_MESSAGE,"_onSubagentMessage"],[SSE_EVENTS.SUBAGENT_TOOL_RESULT,"_onSubagentToolResult"],[SSE_EVENTS.SUBAGENT_COMPLETED,"_onSubagentCompleted"],[SSE_EVENTS.IMAGE_DETECTED,"_onImageDetected"],[SSE_EVENTS.TUNNEL_STARTED,"_onTunnelStarted"],[SSE_EVENTS.TUNNEL_STOPPED,"_onTunnelStopped"],[SSE_EVENTS.TUNNEL_PROGRESS,"_onTunnelProgress"],[SSE_EVENTS.TUNNEL_ERROR,"_onTunnelError"],[SSE_EVENTS.TUNNEL_QR_ROTATED,"_onTunnelQrRotated"],[SSE_EVENTS.TUNNEL_QR_REGENERATED,"_onTunnelQrRegenerated"],[SSE_EVENTS.TUNNEL_QR_AUTH_USED,"_onTunnelQrAuthUsed"],[SSE_EVENTS.PLAN_SUBAGENT,"_onPlanSubagent"],[SSE_EVENTS.PLAN_PROGRESS,"_onPlanProgress"],[SSE_EVENTS.PLAN_STARTED,"_onPlanStarted"],[SSE_EVENTS.PLAN_CANCELLED,"_onPlanCancelled"],[SSE_EVENTS.PLAN_COMPLETED,"_onPlanCompleted"]];class CodemanApp{constructor(){this.sessions=new Map,this._shortIdCache=new Map,this.sessionOrder=[],this.draggedTabId=null,this.cases=[],this.currentRun=null,this.totalTokens=0,this.globalStats=null,this.eventSource=null,this.terminal=null,this.fitAddon=null,this.activeSessionId=null,this._initGeneration=0,this._initFallbackTimer=null,this._selectGeneration=0,this.respawnStatus={},this.respawnTimers={},this.respawnCountdownTimers={},this.respawnActionLogs={},this.timerCountdownInterval=null,this.terminalBuffers=new Map,this.editingSessionId=null,this.pendingCloseSessionId=null,this.muxSessions=[],this.ralphStates=new Map,this.subagents=new Map,this.subagentActivity=new Map,this.subagentToolResults=new Map,this.activeSubagentId=null,this.subagentPanelVisible=!1,this.subagentWindows=new Map,this.subagentWindowZIndex=ZINDEX_SUBAGENT_BASE,this.minimizedSubagents=new Map,this._subagentHideTimeout=null,this.subagentParentMap=new Map,this.teams=new Map,this.teamTasks=new Map,this.teammateMap=new Map,this.teammatePanesByName=new Map,this.teammateTerminals=new Map,this.terminalBufferCache=new Map,this.ralphStatePanelCollapsed=!0,this.ralphClosedSessions=new Set,this.planSubagents=new Map,this.planSubagentWindowZIndex=ZINDEX_PLAN_SUBAGENT_BASE,this.planGenerationStopped=!1,this.planAgentsMinimized=!1,this.wizardDragState=null,this.wizardDragListeners=null,this.wizardPosition=null,this.projectInsights=new Map,this.logViewerWindows=new Map,this.logViewerWindowZIndex=ZINDEX_LOG_VIEWER_BASE,this.projectInsightsPanelVisible=!1,this.currentSessionWorkingDir=null,this.imagePopups=new Map,this.imagePopupZIndex=ZINDEX_IMAGE_POPUP_BASE,this.fileBrowserData=null,this.fileBrowserExpandedDirs=new Set,this.fileBrowserFilter="",this.fileBrowserAllExpanded=!1,this.fileBrowserDragListeners=null,this.filePreviewContent="",this._toastContainer=null,this._tunnelUrl=null,this.tabAlerts=new Map,this.pendingHooks=new Map,this._ws=null,this._wsSessionId=null,this._wsReady=!1,this.pendingWrites=[],this.writeFrameScheduled=!1,this._wasAtBottomBeforeWrite=!0,this.syncWaitTimeout=null,this._isLoadingBuffer=!1,this._loadBufferQueue=null,this.flickerFilterBuffer="",this.flickerFilterActive=!1,this.flickerFilterTimeout=null,this.renderSessionTabsTimeout=null,this.renderRalphStatePanelTimeout=null,this.renderTaskPanelTimeout=null,this.renderMuxSessionsTimeout=null,this.systemStatsInterval=null,this.sseReconnectTimeout=null,this._sseListenerCleanup=null,this.reconnectAttempts=0,this.maxReconnectAttempts=10,this.isOnline=navigator.onLine,this._inputQueue=new Map,this._inputQueueMaxBytes=64*1024,this._connectionStatus="connected",this._inputSendChain=Promise.resolve(),this._localEchoOverlay=null,this._localEchoEnabled=!1,this._restoringFlushedState=!1,this.activeFocusTrap=null,this.notificationManager=new NotificationManager(this),this.idleTimers=new Map,this._elemCache={},this.init()}$(e){return this._elemCache[e]||(this._elemCache[e]=document.getElementById(e)),this._elemCache[e]}formatTokens(e){if(e>=1e6){const t=e/1e6;return t>=10?`${t.toFixed(1)}m`:`${t.toFixed(2)}m`}else if(e>=1e3){const t=e/1e3;return t>=100?`${t.toFixed(0)}k`:`${t.toFixed(1)}k`}return String(e)}estimateCost(e,t){const s=e/1e6*15,i=t/1e6*75;return s+i}setPendingHook(e,t){this.pendingHooks.has(e)||this.pendingHooks.set(e,new Set),this.pendingHooks.get(e).add(t),this.updateTabAlertFromHooks(e)}clearPendingHooks(e,t=null){const s=this.pendingHooks.get(e);s&&(t?s.delete(t):s.clear(),s.size===0&&this.pendingHooks.delete(e),this.updateTabAlertFromHooks(e))}updateTabAlertFromHooks(e){const t=this.pendingHooks.get(e);!t||t.size===0?this.tabAlerts.delete(e):t.has("permission_prompt")||t.has("elicitation_dialog")?this.tabAlerts.set(e,"action"):t.has("idle_prompt")&&this.tabAlerts.set(e,"idle"),this.renderSessionTabs()}init(){MobileDetection.init(),KeyboardHandler.init(),SwipeHandler.init(),VoiceInput.init(),KeyboardAccessoryBar.init(),this.applyHeaderVisibilitySettings(),this.applyTabWrapSettings(),this.applyMonitorVisibility(),document.documentElement.classList.remove("mobile-init"),requestAnimationFrame(()=>{this.initTerminal(),this.loadFontSize(),this.connectSSE(),this._initFallbackTimer=setTimeout(()=>{this._initGeneration===0&&this.loadState()},3e3)}),this.registerServiceWorker(),this.loadTunnelStatus();const e=fetch("/api/settings").then(t=>t.ok?t.json():null).catch(()=>null);if(this.loadQuickStartCases(null,e),this._initRunMode(),this.setupEventListeners(),MobileDetection.isTouchDevice()){const t=s=>{s&&s.addEventListener("touchstart",i=>{if(!KeyboardHandler.keyboardVisible)return;const a=i.target.closest("button");a&&(i.preventDefault(),a.click(),typeof app<"u"&&app.terminal&&app.terminal.focus())},{passive:!1})};t(document.querySelector(".toolbar")),t(document.querySelector(".welcome-overlay"))}this.setupOnlineDetection(),this.loadAppSettingsFromServer(e).then(()=>{this.applyHeaderVisibilitySettings(),this.applyTabWrapSettings(),this.applyMonitorVisibility()}),document.body.classList.add("app-loaded")}_initWebGL(){if(!(typeof WebglAddon>"u"))try{this._webglAddon=new WebglAddon.WebglAddon,this._webglAddon.onContextLoss(()=>{console.error("[CRASH-DIAG] WebGL context LOST \u2014 falling back to canvas renderer"),this._webglAddon.dispose(),this._webglAddon=null}),this.terminal.loadAddon(this._webglAddon),console.log("[CRASH-DIAG] WebGL renderer enabled")}catch{}}setupEventListeners(){document.addEventListener("keydown",t=>{t.isComposing||t.keyCode===229||(t.key==="Escape"&&(this.closeAllPanels(),this.closeHelp()),(t.ctrlKey||t.metaKey)&&(t.key==="?"||t.key==="/")&&(t.preventDefault(),this.showHelp()),(t.ctrlKey||t.metaKey)&&t.key==="Enter"&&(t.preventDefault(),this.quickStart()),(t.ctrlKey||t.metaKey)&&t.key==="w"&&(t.preventDefault(),this.killActiveSession()),(t.ctrlKey||t.metaKey)&&t.key==="Tab"&&(t.preventDefault(),this.nextSession()),(t.ctrlKey||t.metaKey)&&t.key==="k"&&(t.preventDefault(),this.killAllSessions()),(t.ctrlKey||t.metaKey)&&t.key==="l"&&(t.preventDefault(),this.clearTerminal()),(t.ctrlKey||t.metaKey)&&t.shiftKey&&t.key==="R"&&(t.preventDefault(),this.restoreTerminalSize()),(t.ctrlKey||t.metaKey)&&(t.key==="="||t.key==="+")&&(t.preventDefault(),this.increaseFontSize()),(t.ctrlKey||t.metaKey)&&t.key==="-"&&(t.preventDefault(),this.decreaseFontSize()),(t.ctrlKey||t.metaKey)&&t.shiftKey&&t.key==="V"&&(t.preventDefault(),VoiceInput.toggle()))},!0);const e=this.$("headerTokens");e&&!e._statsHandlerAttached&&(e.classList.add("clickable"),e._statsHandlerAttached=!0,e.addEventListener("click",()=>this.openTokenStats())),this.setupColorPicker()}connectSSE(){if(!navigator.onLine){this.setConnectionStatus("offline");return}this.sseReconnectTimeout&&(clearTimeout(this.sseReconnectTimeout),this.sseReconnectTimeout=null),this._sseListenerCleanup&&(this._sseListenerCleanup(),this._sseListenerCleanup=null),this.eventSource&&(this.eventSource.close(),this.eventSource=null),this.reconnectAttempts===0?this.setConnectionStatus("connecting"):this.setConnectionStatus("reconnecting"),this.eventSource=new EventSource("/api/events");const e=[],t=(s,i)=>{this.eventSource.addEventListener(s,i),e.push({event:s,handler:i})};if(this._sseListenerCleanup=()=>{for(const{event:s,handler:i}of e)this.eventSource&&this.eventSource.removeEventListener(s,i);e.length=0},this.eventSource.onopen=()=>{this.reconnectAttempts=0,this.setConnectionStatus("connected")},this.eventSource.onerror=()=>{this.reconnectAttempts++,this.reconnectAttempts>=this.maxReconnectAttempts?this.setConnectionStatus("disconnected"):this.setConnectionStatus("reconnecting"),this.eventSource&&(this.eventSource.close(),this.eventSource=null),this.sseReconnectTimeout&&clearTimeout(this.sseReconnectTimeout);const s=this.reconnectAttempts<=1?200:Math.min(500*Math.pow(2,this.reconnectAttempts-2),3e4);this.sseReconnectTimeout=setTimeout(()=>this.connectSSE(),s)},!this._sseHandlerWrappers){this._sseHandlerWrappers=new Map;for(const[s,i]of _SSE_HANDLER_MAP){const a=this[i];this._sseHandlerWrappers.set(s,n=>{try{a.call(this,n.data?JSON.parse(n.data):{})}catch(r){console.error(`[SSE] Error handling ${s}:`,r)}})}}for(const[s]of _SSE_HANDLER_MAP)t(s,this._sseHandlerWrappers.get(s))}_onInit(e){_crashDiag.log(`INIT: ${e.sessions?.length||0} sessions`),this.handleInit(e)}_onSessionCreated(e){this.sessions.set(e.id,e),this.sessionOrder.includes(e.id)||(this.sessionOrder.push(e.id),this.saveSessionOrder()),this.renderSessionTabs(),this.updateCost(),this.sessions.size===1&&this.startSystemStatsPolling()}_onSessionUpdated(e){const t=e.session||e,s=this.sessions.get(t.id),i=t.claudeSessionId&&(!s||!s.claudeSessionId);this.sessions.set(t.id,t),this.renderSessionTabs(),this.updateCost(),t.id===this.activeSessionId&&t.tokens&&this.updateRespawnTokens(t.tokens),this.updateSubagentParentNames(t.id),i&&(this.recheckOrphanSubagents(),requestAnimationFrame(()=>{this.updateConnectionLines()}))}_onSessionDeleted(e){if(this._wsSessionId===e.id&&this._disconnectWs(),this._cleanupSessionData(e.id),this.activeSessionId===e.id){this.activeSessionId=null;try{localStorage.removeItem("codeman-active-session")}catch{}this.terminal.clear(),this.showWelcome()}this.renderSessionTabs(),this.renderRalphStatePanel(),this.renderProjectInsightsPanel(),this.sessions.size===0&&this.stopSystemStatsPolling()}_onSSETerminal(e){this._wsReady&&this._wsSessionId===e.id||this._onSessionTerminal(e)}_onSSENeedsRefresh(e){this._wsReady&&this._wsSessionId===e?.id||this._onSessionNeedsRefresh(e)}_onSSEClearTerminal(e){this._wsReady&&this._wsSessionId===e?.id||this._onSessionClearTerminal(e)}_onSessionTerminal(e){if(e.id===this.activeSessionId){if(e.data.length>32768&&_crashDiag.log(`TERMINAL: ${(e.data.length/1024).toFixed(0)}KB`),(this.pendingWrites?.reduce((s,i)=>s+i.length,0)||0)+(this.flickerFilterBuffer?.length||0)>131072){this._clientDropRecoveryTimer||(this._clientDropRecoveryTimer=setTimeout(()=>{this._clientDropRecoveryTimer=null,this._onSessionNeedsRefresh()},2e3));return}this.batchTerminalWrite(e.data)}}async _onSessionNeedsRefresh(){if(!(!this.activeSessionId||!this.terminal))try{const t=await(await fetch(`/api/sessions/${this.activeSessionId}/terminal?tail=${TERMINAL_TAIL_SIZE}`)).json();t.terminalBuffer&&(this.terminal.clear(),this.terminal.reset(),await this.chunkedTerminalWrite(t.terminalBuffer),this.terminal.scrollToBottom(),this._localEchoOverlay?.rerender(),this.activeSessionId&&this.sendResize(this.activeSessionId))}catch(e){console.error("needsRefresh reload failed:",e)}}async _onSessionClearTerminal(e){if(e.id===this.activeSessionId)try{const s=await(await fetch(`/api/sessions/${e.id}/terminal`)).json();if(this.terminal.clear(),this.terminal.reset(),s.terminalBuffer){const i=s.terminalBuffer.replace(DEC_SYNC_STRIP_RE,"");await this.chunkedTerminalWrite(i)}this.sendResize(e.id),this._localEchoOverlay?.rerender()}catch(t){console.error("clearTerminal refresh failed:",t)}}_onSessionCompletion(e){this.totalCost+=e.cost||0,this.updateCost(),e.id===this.activeSessionId&&(this.terminal.writeln(""),this.terminal.writeln(`\x1B[1;32m Done (Cost: $${(e.cost||0).toFixed(4)})\x1B[0m`))}_onSessionError(e){e.id===this.activeSessionId&&this.terminal.writeln(`\x1B[1;31m Error: ${e.error}\x1B[0m`);const t=this.sessions.get(e.id);this.notificationManager?.notify({urgency:"critical",category:"session-error",sessionId:e.id,sessionName:t?.name||this.getShortId(e.id),title:"Session Error",message:e.error||"Unknown error"})}_onSessionExit(e){this._wsSessionId===e.id&&this._disconnectWs();const t=this.sessions.get(e.id);t&&(t.status="stopped",this.renderSessionTabs(),e.id===this.activeSessionId&&this._updateLocalEchoState()),e.code&&e.code!==0&&this.notificationManager?.notify({urgency:"critical",category:"session-crash",sessionId:e.id,sessionName:t?.name||this.getShortId(e.id),title:"Session Crashed",message:`Exited with code ${e.code}`})}_onSessionIdle(e){const t=this.sessions.get(e.id);if(t&&(t.status="idle",this.renderSessionTabs(),this.sendPendingCtrlL(e.id),e.id===this.activeSessionId&&this._updateLocalEchoState()),!this.respawnStatus[e.id]?.enabled){const s=this.notificationManager?.preferences?.stuckThresholdMs||6e5;clearTimeout(this.idleTimers.get(e.id)),this.idleTimers.set(e.id,setTimeout(()=>{const i=this.sessions.get(e.id);this.notificationManager?.notify({urgency:"warning",category:"session-stuck",sessionId:e.id,sessionName:i?.name||this.getShortId(e.id),title:"Session Idle",message:`Idle for ${Math.round(s/6e4)}+ minutes`}),this.idleTimers.delete(e.id)},s))}}_onSessionWorking(e){const t=this.sessions.get(e.id);t&&(t.status="busy",this.pendingHooks.has(e.id)||this.tabAlerts.delete(e.id),this.renderSessionTabs(),this.sendPendingCtrlL(e.id),e.id===this.activeSessionId&&this._updateLocalEchoState());const s=this.idleTimers.get(e.id);s&&(clearTimeout(s),this.idleTimers.delete(e.id))}_onSessionAutoClear(e){e.sessionId===this.activeSessionId&&(this.showToast(`Auto-cleared at ${e.tokens.toLocaleString()} tokens`,"info"),this.updateRespawnTokens(0));const t=this.sessions.get(e.sessionId);this.notificationManager?.notify({urgency:"info",category:"auto-clear",sessionId:e.sessionId,sessionName:t?.name||this.getShortId(e.sessionId),title:"Auto-Cleared",message:`Context reset at ${(e.tokens||0).toLocaleString()} tokens`})}_onSessionCliInfo(e){const t=this.sessions.get(e.sessionId);t&&(e.version&&(t.cliVersion=e.version),e.model&&(t.cliModel=e.model),e.accountType&&(t.cliAccountType=e.accountType),e.latestVersion&&(t.cliLatestVersion=e.latestVersion)),e.sessionId===this.activeSessionId&&this.updateCliInfoDisplay()}_onScheduledCreated(e){this.currentRun=e,this.showTimer()}_onScheduledUpdated(e){this.currentRun=e,this.updateTimer()}_onScheduledCompleted(e){this.currentRun=e,this.hideTimer(),this.showToast("Scheduled run completed!","success")}_onScheduledStopped(){this.currentRun=null,this.hideTimer()}setConnectionStatus(e){this._connectionStatus=e,this._updateConnectionIndicator(),e==="connected"&&this._inputQueue.size>0&&this._drainInputQueues()}_connectWs(e){this._disconnectWs();const s=`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}/ws/sessions/${e}/terminal`,i=new WebSocket(s);this._ws=i,this._wsSessionId=e,i.onopen=()=>{this._ws===i&&(this._wsReady=!0,this._wsReconnectAttempts=0)},i.onmessage=a=>{if(this._ws===i)try{const n=JSON.parse(a.data);n.t==="o"?this._onSessionTerminal({id:e,data:n.d}):n.t==="c"?this._onSessionClearTerminal({id:e}):n.t==="r"&&this._onSessionNeedsRefresh({id:e})}catch{}},i.onclose=a=>{if(this._ws===i&&(this._ws=null,this._wsSessionId=null,this._wsReady=!1,a.code<4004&&this.activeSessionId===e)){const n=Math.min(1e3*Math.pow(2,this._wsReconnectAttempts||0),1e4);this._wsReconnectAttempts=(this._wsReconnectAttempts||0)+1,this._wsReconnectTimer=setTimeout(()=>{this._wsReconnectTimer=null,this.activeSessionId===e&&this._connectWs(e)},n)}},i.onerror=()=>{}}_disconnectWs(){this._wsReconnectTimer&&(clearTimeout(this._wsReconnectTimer),this._wsReconnectTimer=null),this._wsReconnectAttempts=0,this._ws&&(this._ws.onclose=null,this._ws.close(),this._ws=null,this._wsSessionId=null,this._wsReady=!1)}_sendInputAsync(e,t){if(!this.isOnline||this._connectionStatus==="disconnected"){this._enqueueInput(e,t);return}if(this._wsReady&&this._wsSessionId===e)try{this._ws.send(JSON.stringify({t:"i",d:t})),this.clearPendingHooks(e);return}catch{}this._inputSendChain=this._inputSendChain.then(()=>{fetch(`/api/sessions/${e}/input`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:t}),keepalive:t.length<65536}).then(i=>{i.ok?this.clearPendingHooks(e):this._enqueueInput(e,t)}).catch(()=>{this._enqueueInput(e,t)})})}_enqueueInput(e,t){let i=(this._inputQueue.get(e)||"")+t;i.length>this._inputQueueMaxBytes&&(i=i.slice(i.length-this._inputQueueMaxBytes)),this._inputQueue.set(e,i),this._updateConnectionIndicator()}async _drainInputQueues(){if(this._inputQueue.size===0)return;const e=new Map(this._inputQueue);this._inputQueue.clear(),this._updateConnectionIndicator();for(const[t,s]of e)(await this._apiPost(`/api/sessions/${t}/input`,{input:s}))?.ok||this._enqueueInput(t,s);this._updateConnectionIndicator()}_updateConnectionIndicator(){const e=this.$("connectionIndicator"),t=this.$("connectionDot"),s=this.$("connectionText");if(!e||!t||!s)return;let i=0;for(const o of this._inputQueue.values())i+=o.length;const a=this._connectionStatus,n=i>0;if((a==="connected"||a==="connecting")&&!n){e.style.display="none";return}e.style.display="flex",t.className="connection-dot";const r=o=>o<1024?`${o}B`:`${(o/1024).toFixed(1)}KB`;a==="connected"&&n?(t.classList.add("draining"),s.textContent=`Sending ${r(i)}...`):a==="reconnecting"?(t.classList.add("reconnecting"),s.textContent=n?`Reconnecting (${r(i)} queued)`:"Reconnecting..."):(t.classList.add("offline"),s.textContent=n?`Offline (${r(i)} queued)`:"Offline")}setupOnlineDetection(){window.addEventListener("online",()=>{this.isOnline=!0,this.reconnectAttempts=0,this.connectSSE()}),window.addEventListener("offline",()=>{this.isOnline=!1,this.setConnectionStatus("offline")})}handleInit(e){this._initFallbackTimer&&(clearTimeout(this._initFallbackTimer),this._initFallbackTimer=null);const t=++this._initGeneration,s=document.getElementById("cjkInput");if(s&&(s.style.display=e.inputCjkForm?"block":"none",e.inputCjkForm||(window.cjkActive=!1)),e.version){const n=this.$("versionDisplay"),r=this.$("headerVersion");n&&(n.textContent=`v${e.version}`,n.title=`Codeman v${e.version}`),r&&(r.textContent=`v${e.version}`,r.title=`Codeman v${e.version}`)}VoiceInput.cleanup(),this.sessions.clear(),this.ralphStates.clear(),this.terminalBuffers.clear(),this.terminalBufferCache.clear(),this.projectInsights.clear(),this.teams.clear(),this.teamTasks.clear();for(const n of this.idleTimers.values())clearTimeout(n);if(this.idleTimers.clear(),this.flickerFilterTimeout&&(clearTimeout(this.flickerFilterTimeout),this.flickerFilterTimeout=null),this.flickerFilterBuffer="",this.flickerFilterActive=!1,this.syncWaitTimeout&&(clearTimeout(this.syncWaitTimeout),this.syncWaitTimeout=null),this.pendingWrites=[],this.writeFrameScheduled=!1,this._isLoadingBuffer=!1,this._loadBufferQueue=null,this._localEchoOverlay?.rerender(),this.pendingHooks.clear(),this._parentNameCache&&this._parentNameCache.clear(),this.subagentActivity.clear(),this.subagentToolResults.clear(),MobileDetection.cleanup(),KeyboardHandler.cleanup(),MobileDetection.init(),KeyboardHandler.init(),this.tabAlerts.clear(),this._shownCompletions&&this._shownCompletions.clear(),this.notificationManager?.titleFlashInterval&&(clearInterval(this.notificationManager.titleFlashInterval),this.notificationManager.titleFlashInterval=null),this.notificationManager?.groupingMap){for(const{timeout:n}of this.notificationManager.groupingMap.values())clearTimeout(n);this.notificationManager.groupingMap.clear()}this.terminalResizeObserver&&(this.terminalResizeObserver.disconnect(),this.terminalResizeObserver=null),this.planLoadingTimer&&(clearInterval(this.planLoadingTimer),this.planLoadingTimer=null),this.timerCountdownInterval&&(clearInterval(this.timerCountdownInterval),this.timerCountdownInterval=null),this.runSummaryAutoRefreshTimer&&(clearInterval(this.runSummaryAutoRefreshTimer),this.runSummaryAutoRefreshTimer=null),e.sessions.forEach(n=>{this.sessions.set(n.id,n),(n.ralphLoop||n.ralphTodos)&&!this.ralphClosedSessions.has(n.id)&&this.ralphStates.set(n.id,{loop:n.ralphLoop||null,todos:n.ralphTodos||[]})}),this._restoreEndedTabs(),this.syncSessionOrder(),e.respawnStatus?this.respawnStatus=e.respawnStatus:this.respawnStatus={},this.respawnTimers={},this.respawnCountdownTimers={},this.respawnActionLogs={},e.globalStats&&(this.globalStats=e.globalStats),this.totalCost=e.sessions.reduce((n,r)=>n+(r.totalCost||0),0),this.totalCost+=e.scheduledRuns.reduce((n,r)=>n+(r.totalCost||0),0);const i=e.scheduledRuns.find(n=>n.status==="running");if(i&&(this.currentRun=i,this.showTimer()),this.updateCost(),this.renderSessionTabs(),this.sessions.size>0?this.startSystemStatsPolling():this.stopSystemStatsPolling(),this.cleanupAllFloatingWindows(),e.subagents&&(this.subagents.clear(),this.subagentActivity.clear(),this.subagentToolResults.clear(),e.subagents.forEach(n=>{this.subagents.set(n.agentId,n)}),this.renderSubagentPanel(),this.subagentParentMap.clear(),this.loadSubagentParentMap().then(()=>{for(const[n,r]of this.subagentParentMap){const o=this.subagents.get(n);if(o&&this.sessions.has(r)){o.parentSessionId=r;const h=this.sessions.get(r);h&&(o.parentSessionName=this.getSessionName(h)),this.subagents.set(n,o)}}for(const[n]of this.subagents)this.subagentParentMap.has(n)||this.findParentSessionForSubagent(n);this.restoreSubagentWindowStates()})),t!==this._initGeneration)return;const a=this.activeSessionId;if(this.activeSessionId=null,this.sessionOrder.length>0){let n=a;if(!n||!this.sessions.has(n))try{n=localStorage.getItem("codeman-active-session")}catch{}n&&this.sessions.has(n)?this.selectSession(n):this.selectSession(this.sessionOrder[0])}}async loadState(){try{const t=await(await fetch("/api/status")).json();this.handleInit(t)}catch(e){console.error("Failed to load state:",e)}}renderSessionTabs(){this.renderSessionTabsTimeout&&clearTimeout(this.renderSessionTabsTimeout),this.renderSessionTabsTimeout=setTimeout(()=>{this._renderSessionTabsImmediate()},100)}_updateActiveTabImmediate(e){const t=this.$("sessionTabs");if(!t)return;const s=t.querySelectorAll(".session-tab[data-id]");for(const i of s)i.dataset.id===e?i.classList.add("active"):i.classList.remove("active")}_renderSessionTabsImmediate(){const e=this.$("sessionTabs"),t=e.querySelectorAll(".session-tab[data-id]"),s=new Set([...t].map(n=>n.dataset.id)),i=new Set(this.sessions.keys());if(s.size===i.size&&[...s].every(n=>i.has(n)))for(const[n,r]of this.sessions){const o=e.querySelector(`.session-tab[data-id="${n}"]`);if(!o)continue;const h=n===this.activeSessionId,c=r.status||"idle",d=this.getSessionName(r),u=r.taskStats||{running:0,total:0},f=u.running>0;h&&!o.classList.contains("active")?o.classList.add("active"):!h&&o.classList.contains("active")&&o.classList.remove("active");const E=this.tabAlerts.get(n),S=E==="action",_=E==="idle",p=o.classList.contains("tab-alert-action"),m=o.classList.contains("tab-alert-idle");S&&!p?(o.classList.add("tab-alert-action"),o.classList.remove("tab-alert-idle")):_&&!m?(o.classList.add("tab-alert-idle"),o.classList.remove("tab-alert-action")):!E&&(p||m)&&o.classList.remove("tab-alert-action","tab-alert-idle");const C=o.querySelector(".tab-status");C&&!C.classList.contains(c)&&(C.className=`tab-status ${c}`);const w=o.querySelector(".tab-name");w&&w.textContent!==d&&(w.textContent=d);const g=o.querySelector(".tab-badge");if(f)if(g)g.textContent!==String(u.running)&&(g.textContent=u.running);else{this._fullRenderSessionTabs();return}else if(g){this._fullRenderSessionTabs();return}const T=o.querySelector(".tab-subagent-badge"),A=this.minimizedSubagents.get(n),b=A?.size||0;if(b>0&&T){const v=T.querySelector(".subagent-label"),y=b===1?"AGENT":`AGENTS (${b})`;v&&v.textContent!==y&&(v.textContent=y);const I=T.querySelector(".subagent-dropdown");if(I){const k=this.renderSubagentTabBadge(n,A),R=document.createElement("div");R.innerHTML=k;const N=R.querySelector(".subagent-dropdown");N&&(I.innerHTML=N.innerHTML)}}else if(b>0&&!T){const v=this.renderSubagentTabBadge(n,A),y=o.querySelector(".tab-gear");y&&y.insertAdjacentHTML("beforebegin",v)}else b===0&&T&&T.remove()}else this._fullRenderSessionTabs()}_fullRenderSessionTabs(){const e=this.$("sessionTabs");document.querySelectorAll("body > .subagent-dropdown").forEach(i=>i.remove()),this.cancelHideSubagentDropdown();const t=[];let s=this.sessionOrder;MobileDetection.getDeviceType()==="mobile"&&this.activeSessionId&&(s=[this.activeSessionId,...this.sessionOrder.filter(i=>i!==this.activeSessionId)]);for(const i of s){const a=this.sessions.get(i);if(!a)continue;const n=i===this.activeSessionId,r=a.status||"idle",o=this.getSessionName(a),h=a.mode||"claude",c=a.color||"default",d=a.taskStats||{running:0,total:0},u=d.running>0,f=this.tabAlerts.get(i),E=f==="action"?" tab-alert-action":f==="idle"?" tab-alert-idle":"",S=this.minimizedSubagents.get(i),p=(S?.size||0)>0?this.renderSubagentTabBadge(i,S):"",m=a.workingDir&&a.workingDir.split("/").pop()||"",w=(this._tallTabsEnabled??!1)&&a.name&&m&&m!==o,g=a._ended?' data-ended="1"':"";t.push(`<div class="session-tab ${n?"active":""}${E}" data-id="${i}" data-color="${c}"${g} onclick="app.selectSession('${escapeHtml(i)}')" oncontextmenu="event.preventDefault(); app.startInlineRename('${escapeHtml(i)}')" tabindex="0" role="tab" aria-selected="${n?"true":"false"}" aria-label="${escapeHtml(o)} session" ${a.workingDir?`title="${escapeHtml(a.workingDir)}"`:""}>
|
|
8
|
+
<span class="tab-status ${r}" aria-hidden="true"></span>
|
|
9
|
+
<span class="tab-info">
|
|
10
|
+
<span class="tab-name-row">
|
|
11
|
+
${h==="shell"?'<span class="tab-mode shell" aria-hidden="true">sh</span>':h==="opencode"?'<span class="tab-mode opencode" aria-hidden="true">oc</span>':""}
|
|
12
|
+
<span class="tab-name" data-session-id="${i}">${escapeHtml(o)}</span>
|
|
13
|
+
</span>
|
|
14
|
+
${w?`<span class="tab-folder">\u{1F4C1} ${escapeHtml(m)}</span>`:""}
|
|
15
|
+
</span>
|
|
16
|
+
${u?`<span class="tab-badge" onclick="event.stopPropagation(); app.toggleTaskPanel()" aria-label="${d.running} running tasks">${d.running}</span>`:""}
|
|
17
|
+
${p}
|
|
18
|
+
<span class="tab-gear" onclick="event.stopPropagation(); app.openSessionOptions('${escapeHtml(i)}')" title="Session options" aria-label="Session options" tabindex="0">⚙</span>
|
|
19
|
+
<span class="tab-close" onclick="event.stopPropagation(); app.requestCloseSession('${escapeHtml(i)}')" title="Close session" aria-label="Close session" tabindex="0">×</span>
|
|
20
|
+
</div>`)}e.innerHTML=t.join(""),this._saveTabMetadata(),this.setupTabDragHandlers(),this.setupTabKeyboardNavigation(e),this.updateConnectionLines()}setupTabKeyboardNavigation(e){this._tabKeydownHandler&&e.removeEventListener("keydown",this._tabKeydownHandler),this._tabKeydownHandler=t=>{if(!["ArrowLeft","ArrowRight","Home","End","Enter"," "].includes(t.key))return;const s=[...e.querySelectorAll(".session-tab")],i=s.indexOf(document.activeElement);if((t.key==="Enter"||t.key===" ")&&i>=0){t.preventDefault();const n=s[i].dataset.id;this.selectSession(n);return}if(i<0)return;let a;switch(t.key){case"ArrowLeft":a=i>0?i-1:s.length-1;break;case"ArrowRight":a=i<s.length-1?i+1:0;break;case"Home":a=0;break;case"End":a=s.length-1;break;default:return}t.preventDefault(),s[a]?.focus()},e.addEventListener("keydown",this._tabKeydownHandler)}syncSessionOrder(){const e=new Set(this.sessions.keys()),s=this.loadSessionOrder().filter(n=>e.has(n)),i=new Set(s),a=[...e].filter(n=>!i.has(n));this.sessionOrder=[...s,...a]}loadSessionOrder(){try{const e=localStorage.getItem("codeman-session-order");return e?JSON.parse(e):[]}catch{return[]}}saveSessionOrder(){try{localStorage.setItem("codeman-session-order",JSON.stringify(this.sessionOrder))}catch{}}_saveTabMetadata(){try{const e={};for(const[t,s]of this.sessions)s._ended||(e[t]={id:t,name:s.name||"",workingDir:s.workingDir||"",mode:s.mode||"claude",color:s.color||"default"});localStorage.setItem("codeman-tab-meta",JSON.stringify(e))}catch{}}_restoreEndedTabs(){try{const e=localStorage.getItem("codeman-tab-meta");if(!e)return;const t=JSON.parse(e);for(const[s,i]of Object.entries(t))this.sessions.has(s)||this.sessions.set(s,{id:s,name:i.name,workingDir:i.workingDir,mode:i.mode,color:i.color,status:"ended",_ended:!0})}catch{}}setupTabDragHandlers(){const e=this.$("sessionTabs");e.querySelectorAll(".session-tab[data-id]").forEach(s=>{s.setAttribute("draggable","true"),s.addEventListener("dragstart",i=>{this.draggedTabId=s.dataset.id,s.classList.add("dragging"),i.dataTransfer.effectAllowed="move",i.dataTransfer.setData("text/plain",s.dataset.id)}),s.addEventListener("dragend",()=>{s.classList.remove("dragging"),this.draggedTabId=null,e.querySelectorAll(".session-tab").forEach(i=>{i.classList.remove("drag-over-left","drag-over-right")})}),s.addEventListener("dragover",i=>{if(i.preventDefault(),!this.draggedTabId||this.draggedTabId===s.dataset.id)return;i.dataTransfer.dropEffect="move";const a=s.getBoundingClientRect(),n=a.left+a.width/2,r=i.clientX<n;s.classList.toggle("drag-over-left",r),s.classList.toggle("drag-over-right",!r)}),s.addEventListener("dragleave",()=>{s.classList.remove("drag-over-left","drag-over-right")}),s.addEventListener("drop",i=>{if(i.preventDefault(),s.classList.remove("drag-over-left","drag-over-right"),!this.draggedTabId||this.draggedTabId===s.dataset.id)return;const a=s.dataset.id,n=this.draggedTabId,r=s.getBoundingClientRect(),o=r.left+r.width/2,h=i.clientX<o,c=this.sessionOrder.indexOf(n);let d=this.sessionOrder.indexOf(a);c===-1||d===-1||(this.sessionOrder.splice(c,1),d=this.sessionOrder.indexOf(a),d!==-1&&(h?this.sessionOrder.splice(d,0,n):this.sessionOrder.splice(d+1,0,n),this.saveSessionOrder(),this._fullRenderSessionTabs()))})})}getShortId(e){if(!e)return"";let t=this._shortIdCache.get(e);return t||(t=e.slice(0,8),this._shortIdCache.set(e,t)),t}getSessionName(e){return e.name?e.name:e.workingDir?e.workingDir.split("/").pop()||e.workingDir:this.getShortId(e.id)}async selectSession(e){if(this.activeSessionId===e)return;const t=performance.now(),s=this.sessions.get(e)?.name||e.slice(0,8);_crashDiag.log(`SELECT: ${s}`),console.log(`[CRASH-DIAG] selectSession START: ${e.slice(0,8)}`);const i=++this._selectGeneration;if(i!==this._selectGeneration)return;this._disconnectWs();const a=document.getElementById("cjkInput");a&&(a.value=""),this.flickerFilterTimeout&&(clearTimeout(this.flickerFilterTimeout),this.flickerFilterTimeout=null),this.flickerFilterBuffer="",this.flickerFilterActive=!1,this._tabCompletionSessionId=null,this._tabCompletionRetries=0,this._tabCompletionBaseText=null,this._tabCompletionFallback&&(clearTimeout(this._tabCompletionFallback),this._tabCompletionFallback=null),this._clientDropRecoveryTimer&&(clearTimeout(this._clientDropRecoveryTimer),this._clientDropRecoveryTimer=null),this.syncWaitTimeout&&(clearTimeout(this.syncWaitTimeout),this.syncWaitTimeout=null),this.pendingWrites=[],this.writeFrameScheduled=!1,this._isLoadingBuffer=!1,this._loadBufferQueue=null;try{const o=this.terminal?._core?._compositionHelper;if(o?._isComposing){o._isComposing=!1;const h=this.terminal?.element?.querySelector(".xterm-helper-textarea");h&&h.dispatchEvent(new CompositionEvent("compositionend",{data:""}))}}catch{}if(this.activeSessionId){const o=this._localEchoOverlay?.pendingText||"",h=this._localEchoOverlay?.getFlushed()?.count||0,c=this._localEchoOverlay?.getFlushed()?.text||"";o&&this._sendInputAsync(this.activeSessionId,o);const d=h+o.length;d>0&&(this._flushedOffsets||(this._flushedOffsets=new Map),this._flushedTexts||(this._flushedTexts=new Map),this._flushedOffsets.set(this.activeSessionId,d),this._flushedTexts.set(this.activeSessionId,c+o))}this._localEchoOverlay?.clear(),this._localEchoOverlay&&!this._flushedOffsets?.has(e)&&this._localEchoOverlay.suppressBufferDetection(),this.activeSessionId=e;try{localStorage.setItem("codeman-active-session",e)}catch{}this.hideWelcome(),this.clearPendingHooks(e,"idle_prompt"),this._updateActiveTabImmediate(e),this.renderSessionTabs(),this._updateLocalEchoState(),this._flushedOffsets?.has(e)&&this._localEchoOverlay&&this._localEchoOverlay.setFlushed(this._flushedOffsets.get(e),this._flushedTexts?.get(e)||"",!1);const n=document.querySelector(`.session-tab.active[data-id="${e}"]`);n&&(n.classList.add("tab-glow"),n.addEventListener("animationend",()=>n.classList.remove("tab-glow"),{once:!0}));const r=this.sessions.get(e);if(r?._ended){this.terminal.clear(),this.terminal.write(`\r
|
|
21
|
+
\x1B[2mSession ended. Close tab or click to reopen.\x1B[0m\r
|
|
22
|
+
`);return}if(this.currentSessionWorkingDir=r?.workingDir||null,r&&r.pid===null&&r.status==="idle")try{const o=r.mode==="shell"?`/api/sessions/${e}/shell`:`/api/sessions/${e}/interactive`;await fetch(o,{method:"POST"}),r.status="busy"}catch(o){console.error("Failed to attach to restored session:",o)}this._restoringFlushedState=!0,this._isLoadingBuffer=!0,this._loadBufferQueue=[];try{const o=this.terminalBufferCache.get(e);if(o){if(_crashDiag.log(`CACHE_WRITE: ${(o.length/1024).toFixed(0)}KB`),this.terminal.clear(),this.terminal.reset(),await this.chunkedTerminalWrite(o),i!==this._selectGeneration){this._isLoadingBuffer&&this._finishBufferLoad(),this._restoringFlushedState=!1;return}this.terminal.scrollToBottom(),_crashDiag.log("CACHE_DONE")}_crashDiag.log("FETCH_START");const h=await fetch(`/api/sessions/${e}/terminal?tail=${TERMINAL_TAIL_SIZE}`);if(i!==this._selectGeneration){this._isLoadingBuffer&&this._finishBufferLoad(),this._restoringFlushedState=!1;return}const c=await h.json();if(_crashDiag.log(`FETCH_DONE: ${c.terminalBuffer?(c.terminalBuffer.length/1024).toFixed(0)+"KB":"empty"} truncated=${c.truncated}`),c.terminalBuffer){if(c.terminalBuffer!==o){if(_crashDiag.log(`REWRITE: ${(c.terminalBuffer.length/1024).toFixed(0)}KB`),this.terminal.clear(),this.terminal.reset(),c.truncated&&this.terminal.write(`\x1B[90m... (earlier output truncated for performance) ...\x1B[0m\r
|
|
23
|
+
\r
|
|
24
|
+
`),await this.chunkedTerminalWrite(c.terminalBuffer),i!==this._selectGeneration){this._isLoadingBuffer&&this._finishBufferLoad(),this._restoringFlushedState=!1;return}this.terminal.scrollToBottom()}if(this.terminalBufferCache.set(e,c.terminalBuffer),this.terminalBufferCache.size>20){const f=this.terminalBufferCache.keys().next().value;this.terminalBufferCache.delete(f)}}else o||(this.terminal.clear(),this.terminal.reset());if(this._isLoadingBuffer&&this._finishBufferLoad(),this._restoringFlushedState=!1,this._flushedOffsets?.has(e)&&this._localEchoOverlay){this._localEchoOverlay.setFlushed(this._flushedOffsets.get(e),this._flushedTexts?.get(e)||"",!1);const u=this._localEchoOverlay;this.terminal.write("",()=>{u.hasPending&&u.rerender()})}this.sendResize(e),(typeof requestIdleCallback=="function"?requestIdleCallback:u=>setTimeout(u,16))(()=>{if(i!==this._selectGeneration)return;this.respawnStatus[e]?(this.showRespawnBanner(),this.updateRespawnBanner(this.respawnStatus[e].state),document.getElementById("respawnCycleCount").textContent=this.respawnStatus[e].cycleCount||0,this.updateCountdownTimerDisplay(),this.updateActionLogDisplay(),Object.keys(this.respawnCountdownTimers[e]||{}).length>0&&this.startCountdownInterval()):(this.hideRespawnBanner(),this.stopCountdownInterval());const u=document.getElementById("taskPanel");u&&u.classList.contains("open")&&this.renderTaskPanel();const f=this.sessions.get(e);if(f&&(f.ralphLoop||f.ralphTodos)&&this.updateRalphState(e,{loop:f.ralphLoop,todos:f.ralphTodos}),this.renderRalphStatePanel(),this.updateCliInfoDisplay(),this.renderProjectInsightsPanel(),this.updateSubagentWindowVisibility(),this.loadAppSettingsFromStorage().showFileBrowser){const S=this.$("fileBrowserPanel");if(S&&(S.classList.add("visible"),this.loadFileBrowser(e),!this.fileBrowserDragListeners)){const _=S.querySelector(".file-browser-header");if(_){const p=()=>{if(!S.style.left){const m=S.getBoundingClientRect();S.style.left=`${m.left}px`,S.style.top=`${m.top}px`,S.style.right="auto"}};_.addEventListener("mousedown",p),_.addEventListener("touchstart",p,{passive:!0}),this.fileBrowserDragListeners=this.makeWindowDraggable(S,_),this.fileBrowserDragListeners._onFirstDrag=p}}}}),this._connectWs(e),_crashDiag.log("FOCUS"),this.terminal.focus(),this.terminal.scrollToBottom(),_crashDiag.log(`SELECT_DONE: ${(performance.now()-t).toFixed(0)}ms`),console.log(`[CRASH-DIAG] selectSession DONE: ${e.slice(0,8)} in ${(performance.now()-t).toFixed(0)}ms`)}catch(o){this._isLoadingBuffer&&this._finishBufferLoad(),this._restoringFlushedState=!1,console.error("Failed to load session terminal:",o)}}_cleanupSessionData(e){this.sessions.delete(e);const t=this.sessionOrder.indexOf(e);t!==-1&&(this.sessionOrder.splice(t,1),this.saveSessionOrder()),this.terminalBuffers.delete(e),this.terminalBufferCache.delete(e),this._flushedOffsets?.delete(e),this._flushedTexts?.delete(e),this._inputQueue.delete(e),this.ralphStates.delete(e),this.ralphClosedSessions.delete(e),this.projectInsights.delete(e),this.pendingHooks.delete(e),this.tabAlerts.delete(e),this.clearCountdownTimers(e),this.closeSessionLogViewerWindows(e),this.closeSessionImagePopups(e),this.closeSessionSubagentWindows(e,!0);const s=this.idleTimers.get(e);s&&(clearTimeout(s),this.idleTimers.delete(e)),delete this.respawnStatus[e],delete this.respawnTimers[e],delete this.respawnCountdownTimers[e],delete this.respawnActionLogs[e]}async closeSession(e,t=!0){try{if(await this._apiDelete(`/api/sessions/${e}?killMux=${t}`),this._cleanupSessionData(e),this.activeSessionId===e){this.activeSessionId=null;try{localStorage.removeItem("codeman-active-session")}catch{}if(this.sessionOrder.length>0&&this.sessions.size>0){const s=this.sessionOrder[0];this.selectSession(s)}else this.terminal.clear(),this.showWelcome(),this.renderRalphStatePanel()}this.renderSessionTabs(),t?this.showToast("Session closed and tmux killed","success"):this.showToast("Tab hidden, tmux still running","info")}catch{this.showToast("Failed to close session","error")}}requestCloseSession(e){const t=this.sessions.get(e);if(!t)return;this.pendingCloseSessionId=e;const s=this.getSessionName(t),i=document.getElementById("closeConfirmSessionName");i.textContent=s;const a=document.getElementById("closeConfirmKillTitle");a&&(a.textContent=t.mode==="opencode"?"Kill Tmux & OpenCode":"Kill Tmux & Claude Code"),document.getElementById("closeConfirmModal").classList.add("active")}cancelCloseSession(){this.pendingCloseSessionId=null,document.getElementById("closeConfirmModal").classList.remove("active")}async confirmCloseSession(e=!0){const t=this.pendingCloseSessionId;this.cancelCloseSession(),t&&await this.closeSession(t,e)}nextSession(){if(this.sessionOrder.length<=1)return;const t=(this.sessionOrder.indexOf(this.activeSessionId)+1)%this.sessionOrder.length;this.selectSession(this.sessionOrder[t])}prevSession(){if(this.sessionOrder.length<=1)return;const t=(this.sessionOrder.indexOf(this.activeSessionId)-1+this.sessionOrder.length)%this.sessionOrder.length;this.selectSession(this.sessionOrder[t])}goHome(){this.activeSessionId=null;try{localStorage.removeItem("codeman-active-session")}catch{}this.terminal.clear(),this.showWelcome(),this.renderSessionTabs(),this.renderRalphStatePanel()}ralphWizardStep=1;ralphWizardConfig={taskDescription:"",completionPhrase:"COMPLETE",maxIterations:10,caseName:"testcase",enableRespawn:!1,generatedPlan:null,planGenerated:!1,skipPlanGeneration:!1,planDetailLevel:"detailed",existingPlan:null,useExistingPlan:!1};planLoadingTimer=null;planLoadingStartTime=null;async killActiveSession(){if(!this.activeSessionId){this.showToast("No active session","warning");return}await this.closeSession(this.activeSessionId)}async killAllSessions(){if(this.sessions.size!==0&&confirm(`Kill all ${this.sessions.size} session(s)?`))try{await this._apiDelete("/api/sessions"),this.sessions.clear(),this.terminalBuffers.clear(),this.terminalBufferCache.clear(),this.activeSessionId=null;try{localStorage.removeItem("codeman-active-session")}catch{}this.respawnStatus={},this.respawnCountdownTimers={},this.respawnActionLogs={},this.stopCountdownInterval(),this.hideRespawnBanner(),this.renderSessionTabs(),this.terminal.clear(),this.showWelcome(),this.showToast("All sessions killed","success")}catch{this.showToast("Failed to kill sessions","error")}}showTimer(){document.getElementById("timerBanner").style.display="flex",this.updateTimer(),this.timerInterval=setInterval(()=>this.updateTimer(),1e3)}hideTimer(){document.getElementById("timerBanner").style.display="none",this.timerInterval&&(clearInterval(this.timerInterval),this.timerInterval=null)}updateTimer(){if(!this.currentRun||this.currentRun.status!=="running")return;const e=Date.now(),t=Math.max(0,this.currentRun.endAt-e),s=this.currentRun.endAt-this.currentRun.startedAt,i=e-this.currentRun.startedAt,a=Math.min(100,i/s*100);document.getElementById("timerValue").textContent=this.formatTime(t),document.getElementById("timerProgress").style.width=`${a}%`,document.getElementById("timerMeta").textContent=`${this.currentRun.completedTasks} tasks | $${this.currentRun.totalCost.toFixed(2)}`}async stopCurrentRun(){if(this.currentRun)try{await fetch(`/api/scheduled/${this.currentRun.id}`,{method:"DELETE"})}catch{this.showToast("Failed to stop run","error")}}formatTime(e){const t=Math.floor(e/1e3),s=Math.floor(t/3600),i=Math.floor(t%3600/60),a=t%60;return`${s.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`}updateCost(){this.updateTokens()}updateTokens(){this._updateTokensTimeout&&clearTimeout(this._updateTokensTimeout),this._updateTokensTimeout=setTimeout(()=>{this._updateTokensTimeout=null,this._updateTokensImmediate()},200)}_updateTokensImmediate(){let e=0,t=0;this.globalStats?(e=this.globalStats.totalInputTokens||0,t=this.globalStats.totalOutputTokens||0):this.sessions.forEach(r=>{r.tokens&&(e+=r.tokens.input||0,t+=r.tokens.output||0)});const s=e+t;this.totalTokens=s;const i=this.formatTokens(s),a=this.estimateCost(e,t),n=this.$("headerTokens");if(n){const o=this.loadAppSettingsFromStorage().showCost??!1;n.textContent=s>0?o?`${i} tokens \xB7 $${a.toFixed(2)}`:`${i} tokens`:"0 tokens",n.title=this.globalStats?`Lifetime: ${this.globalStats.totalSessionsCreated} sessions created${o?`
|
|
25
|
+
Estimated cost based on Claude Opus pricing`:""}`:`Token usage across active sessions${o?`
|
|
26
|
+
Estimated cost based on Claude Opus pricing`:""}`}}}try{for(let l=0;l<localStorage.length;l++){const e=localStorage.key(l);if(e&&(e.startsWith("claudeman-")||e.startsWith("claudeman_"))){const t=e.replace(/^claudeman[-_]/,s=>"codeman"+s.charAt(s.length-1));localStorage.getItem(t)===null&&localStorage.setItem(t,localStorage.getItem(e))}}}catch{}let app;document.addEventListener("DOMContentLoaded",()=>{app=new CodemanApp,window.app=app}),window.MobileDetection=MobileDetection;
|
|
Binary file
|
|
Binary file
|
|
@@ -14,8 +14,10 @@
|
|
|
14
14
|
* @globals {Array} BUILTIN_RESPAWN_PRESETS - Built-in respawn configuration presets
|
|
15
15
|
*
|
|
16
16
|
* @dependency None (first in load order)
|
|
17
|
-
* @loadorder 1 of
|
|
18
|
-
* → keyboard-accessory.js →
|
|
17
|
+
* @loadorder 1 of 15 — constants.js → mobile-handlers.js → voice-input.js → notification-manager.js
|
|
18
|
+
* → keyboard-accessory.js → input-cjk.js → app.js → terminal-ui.js → respawn-ui.js
|
|
19
|
+
* → ralph-panel.js → settings-ui.js → panels-ui.js → session-ui.js → ralph-wizard.js
|
|
20
|
+
* → api-client.js → subagent-windows.js
|
|
19
21
|
*/
|
|
20
22
|
|
|
21
23
|
// Codeman — Shared constants and utility functions for frontend modules
|
|
Binary file
|
|
Binary file
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
<!-- Preload critical resources — lets browser discover these during HTML parse
|
|
18
18
|
instead of waiting until <script> tags at bottom-of-body are reached. -->
|
|
19
19
|
<link rel="preload" href="vendor/xterm.min.js" as="script">
|
|
20
|
-
<link rel="preload" href="constants.
|
|
21
|
-
<link rel="preload" href="app.
|
|
20
|
+
<link rel="preload" href="constants.cd61abbc.js" as="script">
|
|
21
|
+
<link rel="preload" href="app.9dab4ee2.js" as="script">
|
|
22
22
|
<!-- Self-hosted xterm.js — eliminates CDN DNS/TLS latency (~100ms).
|
|
23
23
|
'defer' preserves execution order (xterm loads before fit addon). -->
|
|
24
24
|
<script defer src="vendor/xterm.min.js"></script>
|
|
@@ -1694,15 +1694,21 @@
|
|
|
1694
1694
|
<!-- Lines drawn dynamically -->
|
|
1695
1695
|
</svg>
|
|
1696
1696
|
|
|
1697
|
-
<script defer src="constants.
|
|
1698
|
-
<script defer src="mobile-handlers.
|
|
1699
|
-
<script defer src="voice-input.
|
|
1700
|
-
<script defer src="notification-manager.
|
|
1701
|
-
<script defer src="keyboard-accessory.
|
|
1697
|
+
<script defer src="constants.cd61abbc.js"></script>
|
|
1698
|
+
<script defer src="mobile-handlers.d4830fd3.js"></script>
|
|
1699
|
+
<script defer src="voice-input.085e9e73.js"></script>
|
|
1700
|
+
<script defer src="notification-manager.2d5ea8ec.js"></script>
|
|
1701
|
+
<script defer src="keyboard-accessory.9fb81db6.js"></script>
|
|
1702
1702
|
<script defer src="input-cjk.92544c51.js"></script>
|
|
1703
|
-
<script defer src="app.
|
|
1704
|
-
<script defer src="
|
|
1705
|
-
<script defer src="
|
|
1706
|
-
<script defer src="
|
|
1703
|
+
<script defer src="app.9dab4ee2.js"></script>
|
|
1704
|
+
<script defer src="terminal-ui.e4565c7b.js"></script>
|
|
1705
|
+
<script defer src="respawn-ui.372c6ea7.js"></script>
|
|
1706
|
+
<script defer src="ralph-panel.7b014f16.js"></script>
|
|
1707
|
+
<script defer src="settings-ui.94c57184.js"></script>
|
|
1708
|
+
<script defer src="panels-ui.d7f6be08.js"></script>
|
|
1709
|
+
<script defer src="session-ui.0a07c3b7.js"></script>
|
|
1710
|
+
<script defer src="ralph-wizard.f31ab90e.js"></script>
|
|
1711
|
+
<script defer src="api-client.3adebdc2.js"></script>
|
|
1712
|
+
<script defer src="subagent-windows.a366a4ad.js"></script>
|
|
1707
1713
|
</body>
|
|
1708
1714
|
</html>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*
|
|
19
19
|
* @dependency mobile-handlers.js (MobileDetection.isTouchDevice)
|
|
20
20
|
* @dependency app.js (uses global `app` for sendInput, activeSessionId, terminal)
|
|
21
|
-
* @loadorder 5 of
|
|
21
|
+
* @loadorder 5 of 15 — loaded after notification-manager.js, before app.js
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
// Codeman — Keyboard accessory bar and focus trap for modals
|
|
Binary file
|
|
Binary file
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* @globals {object} SwipeHandler
|
|
20
20
|
*
|
|
21
21
|
* @dependency keyboard-accessory.js (KeyboardAccessoryBar reference in KeyboardHandler.onKeyboardShow, soft — guarded with typeof check)
|
|
22
|
-
* @loadorder 2 of
|
|
22
|
+
* @loadorder 2 of 15 — loaded after constants.js, before voice-input.js
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
// Codeman — Mobile detection, keyboard handling, and swipe navigation
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/web/public/{notification-manager.2e817554.js → notification-manager.2d5ea8ec.js}
RENAMED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
*
|
|
23
23
|
* @dependency constants.js (STUCK_THRESHOLD_DEFAULT_MS, timing constants)
|
|
24
24
|
* @dependency mobile-handlers.js (MobileDetection.getDeviceType for device-specific defaults)
|
|
25
|
-
* @loadorder 4 of
|
|
25
|
+
* @loadorder 4 of 15 — loaded after voice-input.js, before keyboard-accessory.js
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
28
|
// Codeman — Multi-layer notification system
|
|
Binary file
|
|
Binary file
|