aicodeman 1.23.0 → 1.23.2

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.
Files changed (102) hide show
  1. package/README.md +2 -2
  2. package/dist/usage-telemetry.d.ts +7 -2
  3. package/dist/usage-telemetry.d.ts.map +1 -1
  4. package/dist/usage-telemetry.js +30 -2
  5. package/dist/usage-telemetry.js.map +1 -1
  6. package/dist/utils/codex-cli-resolver.d.ts +7 -0
  7. package/dist/utils/codex-cli-resolver.d.ts.map +1 -1
  8. package/dist/utils/codex-cli-resolver.js +81 -1
  9. package/dist/utils/codex-cli-resolver.js.map +1 -1
  10. package/dist/utils/index.d.ts +1 -1
  11. package/dist/utils/index.d.ts.map +1 -1
  12. package/dist/utils/index.js +1 -1
  13. package/dist/utils/index.js.map +1 -1
  14. package/dist/web/plan-usage-latest.d.ts +7 -5
  15. package/dist/web/plan-usage-latest.d.ts.map +1 -1
  16. package/dist/web/plan-usage-latest.js +12 -5
  17. package/dist/web/plan-usage-latest.js.map +1 -1
  18. package/dist/web/public/admin-ui.js.gz +0 -0
  19. package/dist/web/public/api-client.c9b1cddc.js.gz +0 -0
  20. package/dist/web/public/app.3734fd6f.js +38 -0
  21. package/dist/web/public/app.3734fd6f.js.br +0 -0
  22. package/dist/web/public/app.3734fd6f.js.gz +0 -0
  23. package/dist/web/public/approvals-ui.js.gz +0 -0
  24. package/dist/web/public/constants.f4ea0a19.js.gz +0 -0
  25. package/dist/web/public/cron-ui.js.gz +0 -0
  26. package/dist/web/public/entrance-animations.js.gz +0 -0
  27. package/dist/web/public/home-sessions.js.gz +0 -0
  28. package/dist/web/public/i18n.9ae15b51.js.gz +0 -0
  29. package/dist/web/public/image-input.ee16ad88.js.gz +0 -0
  30. package/dist/web/public/index.html +7 -7
  31. package/dist/web/public/index.html.br +0 -0
  32. package/dist/web/public/index.html.gz +0 -0
  33. package/dist/web/public/input-cjk.87f14251.js.gz +0 -0
  34. package/dist/web/public/keyboard-accessory.0454a3e9.js.gz +0 -0
  35. package/dist/web/public/mobile-handlers.0f83a608.js.gz +0 -0
  36. package/dist/web/public/mobile-overview.js.gz +0 -0
  37. package/dist/web/public/mobile.cab92e3f.css.gz +0 -0
  38. package/dist/web/public/notification-manager.5d229063.js.gz +0 -0
  39. package/dist/web/public/orchestrator-panel.js.gz +0 -0
  40. package/dist/web/public/{panels-ui.50200a8d.js → panels-ui.344de87d.js} +40 -32
  41. package/dist/web/public/panels-ui.344de87d.js.br +0 -0
  42. package/dist/web/public/panels-ui.344de87d.js.gz +0 -0
  43. package/dist/web/public/ralph-panel.6de2d0f8.js.gz +0 -0
  44. package/dist/web/public/ralph-wizard.13a1831e.js.gz +0 -0
  45. package/dist/web/public/readmymind-ui.js.gz +0 -0
  46. package/dist/web/public/respawn-ui.ff0dae4c.js.gz +0 -0
  47. package/dist/web/public/sanitize-html.bc7078d6.js.gz +0 -0
  48. package/dist/web/public/session-lineage.js.gz +0 -0
  49. package/dist/web/public/session-ui.103656d3.js.gz +0 -0
  50. package/dist/web/public/{settings-ui.45f311a7.js → settings-ui.3261b896.js} +1 -1
  51. package/dist/web/public/settings-ui.3261b896.js.br +0 -0
  52. package/dist/web/public/{settings-ui.45f311a7.js.gz → settings-ui.3261b896.js.gz} +0 -0
  53. package/dist/web/public/styles.0d71ea9a.css +1 -0
  54. package/dist/web/public/styles.0d71ea9a.css.br +0 -0
  55. package/dist/web/public/styles.0d71ea9a.css.gz +0 -0
  56. package/dist/web/public/subagent-windows.e6ca799f.js.gz +0 -0
  57. package/dist/web/public/sw.js.gz +0 -0
  58. package/dist/web/public/tab-rail-resize.42c24949.js.gz +0 -0
  59. package/dist/web/public/terminal-ui.5e0c230c.js +2 -0
  60. package/dist/web/public/terminal-ui.5e0c230c.js.br +0 -0
  61. package/dist/web/public/terminal-ui.5e0c230c.js.gz +0 -0
  62. package/dist/web/public/ultracode-panel.js.gz +0 -0
  63. package/dist/web/public/ultracode-windows.js.gz +0 -0
  64. package/dist/web/public/upload.html.gz +0 -0
  65. package/dist/web/public/vendor/dompurify.min.js.gz +0 -0
  66. package/dist/web/public/vendor/marked.min.js.gz +0 -0
  67. package/dist/web/public/vendor/xterm-addon-fit.min.js.gz +0 -0
  68. package/dist/web/public/vendor/xterm-addon-serialize.min.js.gz +0 -0
  69. package/dist/web/public/vendor/xterm-addon-unicode11.min.js.gz +0 -0
  70. package/dist/web/public/vendor/xterm-addon-webgl.min.js.gz +0 -0
  71. package/dist/web/public/vendor/xterm-predictive-echo.bd6882b8.js.gz +0 -0
  72. package/dist/web/public/vendor/xterm-zerolag-input.6fee72f2.js.gz +0 -0
  73. package/dist/web/public/vendor/xterm.css.gz +0 -0
  74. package/dist/web/public/vendor/xterm.min.js.gz +0 -0
  75. package/dist/web/public/voice-input.4ec670b0.js.gz +0 -0
  76. package/dist/web/public/voice-pcm-worklet.js.gz +0 -0
  77. package/dist/web/public/webview-tabs.js.gz +0 -0
  78. package/dist/web/routes/status-telemetry-routes.js +3 -3
  79. package/dist/web/routes/status-telemetry-routes.js.map +1 -1
  80. package/dist/web/schemas.js +1 -1
  81. package/dist/web/schemas.js.map +1 -1
  82. package/dist/web/server.d.ts +3 -0
  83. package/dist/web/server.d.ts.map +1 -1
  84. package/dist/web/server.js +33 -1
  85. package/dist/web/server.js.map +1 -1
  86. package/dist/web/sse-events.d.ts +1 -1
  87. package/dist/web/sse-events.d.ts.map +1 -1
  88. package/dist/web/sse-events.js +1 -1
  89. package/dist/web/sse-events.js.map +1 -1
  90. package/package.json +1 -1
  91. package/dist/web/public/app.360ece48.js +0 -36
  92. package/dist/web/public/app.360ece48.js.br +0 -0
  93. package/dist/web/public/app.360ece48.js.gz +0 -0
  94. package/dist/web/public/panels-ui.50200a8d.js.br +0 -0
  95. package/dist/web/public/panels-ui.50200a8d.js.gz +0 -0
  96. package/dist/web/public/settings-ui.45f311a7.js.br +0 -0
  97. package/dist/web/public/styles.1938fd02.css +0 -1
  98. package/dist/web/public/styles.1938fd02.css.br +0 -0
  99. package/dist/web/public/styles.1938fd02.css.gz +0 -0
  100. package/dist/web/public/terminal-ui.ef68a666.js +0 -2
  101. package/dist/web/public/terminal-ui.ef68a666.js.br +0 -0
  102. package/dist/web/public/terminal-ui.ef68a666.js.gz +0 -0
@@ -58,7 +58,7 @@ Enable the unauthenticated public tunnel anyway?`))return this._dismissTunnelCon
58
58
  <td style="padding:3px 8px;color:#e0e0e0" title="${d.sessionId}">${p}</td>
59
59
  <td style="padding:3px 8px;color:#aaa">${d.reason||""}</td>
60
60
  <td style="padding:3px 8px;color:#666">${h.join(", ")}</td>
61
- </tr>`}).join("")}catch(s){console.error("Failed to load lifecycle log:",s)}},_renderVoiceProviderStatus(){const e=document.getElementById("voiceProviderStatus");if(e){const o=VoiceInput.getActiveProviderName();e.textContent=o;const i=o.startsWith("Deepgram Nova")||o.startsWith("Claude (this");e.className="voice-provider-status"+(i?" active":"")}const t=document.getElementById("voiceClaudeStatus");if(!t)return;const n=VoiceInput._claudeStatus,s=n?n.available?`Ready${n.subscriptionType?` (${n.subscriptionType})`:""}`:n.reason==="expired"?"Login expired - run a Claude session to refresh":n.reason==="no-credentials"?"No Claude Code login on the server":n.reason==="malformed"?"Claude credentials unreadable":"Off - enable it above":"Checking...";t.textContent=s,t.className="voice-provider-status"+(n?.available?" active":"")},async saveAppSettings(){const e=this.loadAppSettingsFromStorage(),t=(e.gestureControlEnabled??!1)===!0,n=(e.webglRendererEnabled??!0)===!0,s={displayName:window.CodemanI18n?.normalizeDisplayName(document.getElementById("appSettingsDisplayName").value)||"Codeman",language:window.CodemanI18n?.normalizeLanguage(document.getElementById("appSettingsLanguage").value)||"en",defaultClaudeMdPath:document.getElementById("appSettingsClaudeMdPath").value.trim(),defaultWorkingDir:document.getElementById("appSettingsDefaultDir").value.trim(),ralphTrackerEnabled:document.getElementById("appSettingsRalphEnabled").checked,showFontControls:document.getElementById("appSettingsShowFontControls").checked,showSystemStats:document.getElementById("appSettingsShowSystemStats").checked,showLifecycleLog:document.getElementById("appSettingsShowLifecycleLog").checked,showResponseViewer:document.getElementById("appSettingsShowResponseViewer").checked,showFileViewerButton:document.getElementById("appSettingsShowFileViewerButton").checked,showAttachmentsButton:document.getElementById("appSettingsShowAttachmentsButton").checked,showMonitor:document.getElementById("appSettingsShowMonitor").checked,showProjectInsights:document.getElementById("appSettingsShowProjectInsights").checked,showFileBrowser:document.getElementById("appSettingsShowFileBrowser").checked,showSubagents:document.getElementById("appSettingsShowSubagents").checked,showUltracodeAgents:document.getElementById("appSettingsShowUltracodeAgents").checked,approvalsInboxEnabled:document.getElementById("appSettingsApprovalsInbox").checked,readMyMindEnabled:document.getElementById("appSettingsReadMyMind").checked,ultracodeFloatingWindows:document.getElementById("appSettingsUltracodeFloatingWindows").checked,showMultiMonitorButton:document.getElementById("appSettingsShowMultiMonitorButton").checked,showPlanUsageLimits:document.getElementById("appSettingsShowPlanUsageLimits").checked,showRedrawButton:document.getElementById("appSettingsShowRedrawButton").checked,mobileOverviewEnabled:document.getElementById("appSettingsMobileOverview").checked,sessionLineageLines:document.getElementById("appSettingsLineageLines").checked,showSessionButton:document.getElementById("appSettingsShowSessionButton").checked,showAwayDigestButton:document.getElementById("appSettingsShowAwayDigestButton").checked,showCronButton:document.getElementById("appSettingsShowCronButton").checked,gestureControlEnabled:document.getElementById("appSettingsGestureControl").checked,subagentTrackingEnabled:document.getElementById("appSettingsSubagentTracking").checked,subagentActiveTabOnly:document.getElementById("appSettingsSubagentActiveTabOnly").checked,imageWatcherEnabled:document.getElementById("appSettingsImageWatcherEnabled").checked,tunnelEnabled:document.getElementById("appSettingsTunnelEnabled").checked,localEchoEnabled:document.getElementById("appSettingsLocalEcho").checked,autoCopySelection:document.getElementById("appSettingsAutoCopySelection").checked,terminalFontFamily:document.getElementById("appSettingsTerminalFont").value.trim(),terminalWheelLocalScrollback:document.getElementById("appSettingsTerminalWheelLocal").checked,cjkInputEnabled:document.getElementById("appSettingsCjkInput").checked,webglRendererEnabled:document.getElementById("appSettingsWebglRenderer").checked,extendedKeyboardBar:document.getElementById("appSettingsExtendedKeyboardBar").checked,tabTwoRows:document.getElementById("appSettingsTabTwoRows").checked,tabOrientation:document.getElementById("appSettingsTabOrientation").value,tabRailWidth:this.readTabRailWidthSetting?.()??256,tabRailDetail:document.getElementById("appSettingsTabRailDetail").value,showTabDetachButton:document.getElementById("appSettingsShowTabDetachButton").checked,sessionListLayout:document.getElementById("appSettingsSessionListLayout").value,sessionSidebarFontSize:this.resolveSessionSidebarFontSize(document.getElementById("appSettingsSessionSidebarFontSize").value),skin:document.getElementById("appSettingsSkin").value,claudeMode:document.getElementById("appSettingsClaudeMode").value,allowedTools:document.getElementById("appSettingsAllowedTools").value.trim(),codexDangerouslyBypassApprovals:document.getElementById("appSettingsCodexDangerouslyBypassApprovals").checked,codexAnimationsEnabled:document.getElementById("appSettingsCodexAnimations").checked,agentTeamsEnabled:document.getElementById("appSettingsAgentTeams").checked,agentSkillEnabled:document.getElementById("appSettingsAgentSkill").checked,workspaceHooksEnabled:document.getElementById("appSettingsWorkspaceHooks").checked,claudeVoiceEnabled:document.getElementById("appSettingsClaudeVoice").checked,claudeModel:document.getElementById("appSettingsClaudeModel").value,opusContext1mEnabled:document.getElementById("appSettingsOpusContext1m").checked,remoteAutoReconnect:document.getElementById("appSettingsRemoteAutoReconnect").checked,thinkingEffort:document.getElementById("appSettingsThinkingEffort").value,nice:{enabled:document.getElementById("appSettingsNiceEnabled").checked,niceValue:parseInt(document.getElementById("appSettingsNiceValue").value)||10}};if(e.showTokenCount!==void 0&&(s.showTokenCount=e.showTokenCount),e.showCost!==void 0&&(s.showCost=e.showCost),e.shortcutOverrides!==void 0&&(s.shortcutOverrides=e.shortcutOverrides),this.saveAppSettingsToStorage(s),this._updateLocalEchoState(),this.applyTerminalFontFamily?.(s.terminalFontFamily),!n&&s.webglRendererEnabled)try{localStorage.removeItem("codeman-webgl-disabled")}catch{}const o={provider:document.getElementById("voiceProvider").value,apiKey:document.getElementById("voiceDeepgramKey").value.trim(),language:document.getElementById("voiceLanguage").value,keyterms:document.getElementById("voiceKeyterms").value.trim(),insertMode:document.getElementById("voiceInsertMode").value};VoiceInput._saveDeepgramConfig(o);const i={enabled:document.getElementById("appSettingsNotifEnabled").checked,browserNotifications:document.getElementById("appSettingsNotifBrowser").checked,audioAlerts:document.getElementById("appSettingsNotifAudio").checked,stuckThresholdMs:(parseInt(document.getElementById("appSettingsNotifStuckMins").value)||10)*6e4,muteCritical:!document.getElementById("appSettingsNotifCritical").checked,muteWarning:!document.getElementById("appSettingsNotifWarning").checked,muteInfo:!document.getElementById("appSettingsNotifInfo").checked,eventTypes:{permission_prompt:{enabled:document.getElementById("eventPermissionEnabled").checked,browser:document.getElementById("eventPermissionBrowser").checked,push:document.getElementById("eventPermissionPush").checked,audio:document.getElementById("eventPermissionAudio").checked},elicitation_dialog:{enabled:document.getElementById("eventQuestionEnabled").checked,browser:document.getElementById("eventQuestionBrowser").checked,push:document.getElementById("eventQuestionPush").checked,audio:document.getElementById("eventQuestionAudio").checked},idle_prompt:{enabled:document.getElementById("eventIdleEnabled").checked,browser:document.getElementById("eventIdleBrowser").checked,push:document.getElementById("eventIdlePush").checked,audio:document.getElementById("eventIdleAudio").checked},stop:{enabled:document.getElementById("eventStopEnabled").checked,browser:document.getElementById("eventStopBrowser").checked,push:document.getElementById("eventStopPush").checked,audio:document.getElementById("eventStopAudio").checked},session_error:{enabled:!0,browser:this.notificationManager?.preferences?.eventTypes?.session_error?.browser??!0,push:this.notificationManager?.preferences?.eventTypes?.session_error?.push??!1,audio:!1},respawn_cycle:{enabled:document.getElementById("eventRespawnEnabled").checked,browser:document.getElementById("eventRespawnBrowser").checked,push:document.getElementById("eventRespawnPush").checked,audio:document.getElementById("eventRespawnAudio").checked},token_milestone:{enabled:!0,browser:!1,push:!1,audio:!1},ralph_complete:{enabled:document.getElementById("eventRalphEnabled").checked,browser:document.getElementById("eventRalphBrowser").checked,push:document.getElementById("eventRalphPush").checked,audio:document.getElementById("eventRalphAudio").checked},subagent_spawn:{enabled:document.getElementById("eventSubagentEnabled").checked,browser:document.getElementById("eventSubagentBrowser").checked,push:document.getElementById("eventSubagentPush").checked,audio:document.getElementById("eventSubagentAudio").checked},subagent_complete:{enabled:document.getElementById("eventSubagentEnabled").checked,browser:document.getElementById("eventSubagentBrowser").checked,push:document.getElementById("eventSubagentPush").checked,audio:document.getElementById("eventSubagentAudio").checked}},_version:5};this.notificationManager&&(this.notificationManager.preferences=i,this.notificationManager.savePreferences()),this._syncPushPreferences(),this.applyHeaderVisibilitySettings(),this.applySkin(),this.applyLocalization(),this.applySessionListLayout(),this.applyTabOrientation({settleRailWidth:!0}),this.applyLineageLineSettings?.(),this._updateTokensImmediate(),this.applyMonitorVisibility(),this.renderApprovals?.(),this.renderProjectInsightsPanel(),this.updateSubagentWindowVisibility(),this._updateCjkInputState(),this.activeSessionId||this.showWelcome(),KeyboardAccessoryBar.setMode(s.extendedKeyboardBar?"extended":"simple");const{localEchoEnabled:a,cjkInputEnabled:l,extendedKeyboardBar:c,skin:d,language:r,showPlanUsageLimits:u,showAttachmentsButton:p,showFileViewerButton:h,webglRendererEnabled:m,terminalWheelLocalScrollback:g,autoCopySelection:S,terminalFontFamily:b,showSessionButton:E,showAwayDigestButton:w,showCronButton:v,showTabDetachButton:y,mobileOverviewEnabled:B,sessionLineageLines:I,...f}=s;try{const k=await this._apiPut("/api/settings",{...f,...s.showPlanUsageLimits?{statusLineTelemetry:!0}:{},notificationPreferences:i,voiceSettings:o});if(s.tunnelEnabled&&await this._handleTunnelEnableRefusal(k)){s.tunnelEnabled=!1,this.saveAppSettingsToStorage(s);const T=document.getElementById("appSettingsTunnelEnabled");T&&(T.checked=!1),this.closeAppSettings();return}await this.saveModelConfigFromSettings(),this.showToast("Settings saved","success"),s.tunnelEnabled&&this.showToast("Tunnel starting \u2014 QR code will appear when ready...","info")}catch{this.showToast("Settings saved locally","warning")}this.closeAppSettings(),VoiceInput.refreshClaudeStatus(),s.gestureControlEnabled!==t&&(this.showToast(s.gestureControlEnabled?"Enabling gesture control \u2014 reloading\u2026":"Disabling gesture control \u2014 reloading\u2026","info"),setTimeout(()=>location.reload(),400))},async loadModelConfigForSettings(){try{const t=await(await fetch("/api/execution/model-config")).json();if(t.success&&t.data){const n=t.data,s=document.getElementById("appSettingsDefaultModel");s&&(s.value=n.defaultModel||"");const o=document.getElementById("appSettingsShowModelRecommendations");o&&(o.checked=n.showRecommendations??!0);const i=n.agentTypeOverrides||{},a=document.getElementById("appSettingsModelExplore"),l=document.getElementById("appSettingsModelImplement"),c=document.getElementById("appSettingsModelTest"),d=document.getElementById("appSettingsModelReview");a&&(a.value=i.explore||""),l&&(l.value=i.implement||""),c&&(c.value=i.test||""),d&&(d.value=i.review||"")}}catch(e){console.warn("Failed to load model config:",e)}},async saveModelConfigFromSettings(){const e=document.getElementById("appSettingsDefaultModel"),t=document.getElementById("appSettingsShowModelRecommendations"),n=document.getElementById("appSettingsModelExplore"),s=document.getElementById("appSettingsModelImplement"),o=document.getElementById("appSettingsModelTest"),i=document.getElementById("appSettingsModelReview"),a={};n?.value&&(a.explore=n.value),s?.value&&(a.implement=s.value),o?.value&&(a.test=o.value),i?.value&&(a.review=i.value);const l={defaultModel:e?.value||"",showRecommendations:t?.checked??!0,agentTypeOverrides:a};try{await fetch("/api/execution/model-config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)})}catch(c){console.warn("Failed to save model config:",c)}},isRalphTrackerEnabledByDefault(){return this.loadAppSettingsFromStorage().ralphTrackerEnabled??!1},getSettingsStorageKey(){return MobileDetection.isHandheldDevice?.()??MobileDetection.getDeviceType()==="mobile"?"codeman-app-settings-mobile":"codeman-app-settings"},getDefaultSettings(){return MobileDetection.isHandheldDevice?.()??MobileDetection.getDeviceType()==="mobile"?{showFontControls:!1,showSystemStats:!1,showTokenCount:!1,showCost:!1,showMonitor:!1,showProjectInsights:!1,showFileBrowser:!1,showSubagents:!1,showUltracodeAgents:!1,ultracodeFloatingWindows:!1,showMultiMonitorButton:!1,showPlanUsageLimits:!1,showAttachmentsButton:!1,showFileViewerButton:!1,showRedrawButton:!1,showSessionButton:!1,showAwayDigestButton:!1,showCronButton:!1,mobileOverviewEnabled:!0,remoteAutoReconnect:!0,gestureControlEnabled:!1,subagentTrackingEnabled:!0,subagentActiveTabOnly:!0,imageWatcherEnabled:!1,ralphTrackerEnabled:!1,tabTwoRows:!1,tabOrientation:"horizontal",tabRailWidth:256,tabRailDetail:"rich",sessionListLayout:"header",sessionSidebarFontSize:12,cjkInputEnabled:!1,terminalWheelLocalScrollback:!1,webglRendererEnabled:!1,skin:"daylight-blue"}:{}},loadAppSettingsFromStorage(){if(this._cachedAppSettings)return this._cachedAppSettings;try{const e=this.getSettingsStorageKey(),t=localStorage.getItem(e);if(t)return this._cachedAppSettings=JSON.parse(t),this._cachedAppSettings}catch(e){console.error("Failed to load app settings:",e)}return this._cachedAppSettings=this.getDefaultSettings(),this._cachedAppSettings},saveAppSettingsToStorage(e){this._cachedAppSettings=e;try{const t=this.getSettingsStorageKey();localStorage.setItem(t,JSON.stringify(e))}catch(t){console.error("Failed to save app settings:",t)}},applySkin(){const e=this.loadAppSettingsFromStorage(),t=this.getDefaultSettings(),n=e.skin??t.skin??"daylight-blue";document.documentElement.setAttribute("data-skin",n),window.__codemanSkin=n;const s=getComputedStyle(document.documentElement).getPropertyValue("--bg-dark").trim();s&&document.querySelector('meta[name="theme-color"]')?.setAttribute("content",s);try{localStorage.setItem("codeman:skin",n)}catch{}typeof this.applyTerminalSkin=="function"&&this.applyTerminalSkin(n)},applyLocalization(){const e=this.loadAppSettingsFromStorage();window.CodemanI18n?.configure({language:e.language,displayName:e.displayName})&&this.notificationManager&&(this.notificationManager.originalTitle=document.title)},planUsageChipEnabled(e=null){return(e??this.loadAppSettingsFromStorage()).showPlanUsageLimits??this.getDefaultSettings().showPlanUsageLimits??!0},applyHeaderVisibilitySettings(){const e=this.loadAppSettingsFromStorage(),t=this.getDefaultSettings(),n=e.showTabDetachButton??t.showTabDetachButton??!1;document.documentElement.classList.toggle("tabs-show-detach",n);const s=MobileDetection.getDeviceType()!=="desktop",o=s?!1:e.showFontControls??t.showFontControls??!1,i=s?!1:e.showSystemStats??t.showSystemStats??!0,a=s?!1:e.showTokenCount??t.showTokenCount??!1,l=document.querySelector(".header-font-controls"),c=document.getElementById("headerSystemStats"),d=document.getElementById("headerTokens");l&&(l.style.display=o?"":"none"),c&&(c.style.display=i?"":"none"),d&&(d.style.display=a?"":"none");const r=e.showLifecycleLog??t.showLifecycleLog??!1,u=document.querySelector(".btn-lifecycle-log");u&&(u.style.display=r?"":"none");const p=e.showResponseViewer??t.showResponseViewer??!1,h=document.querySelector(".btn-response-viewer-header");h&&h.classList.toggle("btn-response-viewer-header--hidden",!p);const m=e.showAttachmentsButton??t.showAttachmentsButton??!1,g=document.getElementById("attachmentsHistoryBtn");g&&g.classList.toggle("btn-attachments-history--hidden",!m);const S=e.showFileViewerButton??t.showFileViewerButton??!0,b=document.querySelector(".btn-file-viewer");b&&b.classList.toggle("btn-file-viewer--hidden",!S);const E=e.showMultiMonitorButton??t.showMultiMonitorButton??!1,w=document.querySelector(".btn-multimonitor");w&&w.classList.toggle("btn-multimonitor--hidden",!E);const v=e.showUltracodeAgents??t.showUltracodeAgents??!1,y=document.querySelector(".btn-ultracode-agents");y&&y.classList.toggle("btn-ultracode-agents--hidden",!v);const B=document.querySelector(".btn-readmymind");B&&B.classList.toggle("btn-readmymind--hidden",e.readMyMindEnabled!==!0),typeof KeyboardAccessoryBar<"u"&&KeyboardAccessoryBar.syncReadMyMind?.();const I=this.planUsageChipEnabled(e),f=document.getElementById("planUsageChip");f&&f.classList.toggle("header-plan-usage--hidden",!I);const k=e.showRedrawButton??t.showRedrawButton??!1,T=document.querySelector(".btn-redraw-terminal");T&&T.classList.toggle("btn-redraw-terminal--hidden",!k);const M=e.showSessionButton??t.showSessionButton??!1,_=document.querySelector(".btn-session-manager");_&&_.classList.toggle("btn-session-manager--hidden",!M);const x=e.showAwayDigestButton??t.showAwayDigestButton??!1,C=document.querySelector(".btn-away-digest");C&&C.classList.toggle("btn-away-digest--hidden",!x);const R=e.showCronButton??t.showCronButton??!1,L=document.querySelector(".btn-cron");L&&L.classList.toggle("btn-cron--hidden",!R);const P=document.querySelector(".btn-notifications");if(P&&(P.style.display="none"),!(this.notificationManager?.preferences?.enabled??!0)){const A=document.getElementById("notifDrawer");A&&A.classList.remove("open")}},applyTabOrientation(e={}){const t=this.loadAppSettingsFromStorage(),n=this.getDefaultSettings(),s=this.isSessionSidebarActive?.()===!0,o=!this.isSoloWindow&&!s&&window.CodemanTabOverflow?.resolveTabOrientation?window.CodemanTabOverflow.resolveTabOrientation({deviceType:MobileDetection.getDeviceType(),setting:t.tabOrientation??n.tabOrientation??"horizontal"}):"horizontal",i=document.documentElement,a=i.getAttribute("data-tab-orientation")||"horizontal";i.setAttribute("data-tab-orientation",o);const l=i.dataset.tabRailDetail||"rich",c=(t.tabRailDetail??n.tabRailDetail??"rich")==="simple"?"simple":"rich";i.dataset.tabRailDetail=c;const d=document.getElementById("sessionTabs"),r=document.getElementById("tabRail"),u=document.getElementById("sessionTabsHost");!s&&d&&r&&u&&(o==="vertical"?d.parentElement!==r&&r.appendChild(d):d.parentElement!==u&&u.appendChild(d)),d&&d.setAttribute("aria-orientation",s||o==="vertical"?"vertical":"horizontal");const p=e.settleRailWidth===!0&&(o==="vertical"||a!==o);this.applyTabRailWidth?.({settle:p});const h=a!==o,m=h||l!==c;h&&(this.updateTabOverflowMode?.(),p||this.fitAddon?.fit());const g=this._tallTabsEnabled;m&&this.applyTabWrapSettings?.(),m&&(g!==void 0&&g!==this._tallTabsEnabled||this._fullRenderSessionTabs?.(),this._updateConnectionLinesImmediate?.(),this._refreshHomeSessionsIfVisible?.()),this.isRichTabRows?.()?this._startSidebarRichClock?.():this._stopSidebarRichClock?.()},applyTabWrapSettings(){const e=this.loadAppSettingsFromStorage(),t=this.getDefaultSettings(),n=MobileDetection.getDeviceType(),s=this.isSessionSidebarActive?.()===!0,o=!s&&n==="desktop"?e.tabTwoRows??t.tabTwoRows??!1:!1,i=this.isTabRailRich?.()===!0,a=s||o||i,l=this._tallTabsEnabled;this._tallTabsEnabled=a;const c=document.getElementById("sessionTabs");c&&(c.classList.toggle("tabs-two-rows",o),c.classList.toggle("tabs-show-folder",a)),l!==void 0&&l!==a&&this._fullRenderSessionTabs()},applyMonitorVisibility(){const e=this.loadAppSettingsFromStorage(),t=this.getDefaultSettings(),n=e.showMonitor??t.showMonitor??!1,s=e.showSubagents??t.showSubagents??!1,o=e.showFileBrowser??t.showFileBrowser??!1,i=document.getElementById("monitorPanel");i&&(i.style.display=n?"":"none",n?i.classList.add("open"):i.classList.remove("open"));const a=document.getElementById("subagentsPanel");a&&(s?a.classList.remove("hidden"):a.classList.add("hidden"));const l=e.showUltracodeAgents??t.showUltracodeAgents??!1,c=document.getElementById("ultracodeAgentsPanel");c&&(l?c.classList.remove("hidden"):(c.classList.remove("open"),c.classList.add("hidden"))),e.ultracodeFloatingWindows??t.ultracodeFloatingWindows??!1?typeof this.syncAllUltracodeFloatingWindows=="function"&&this.syncAllUltracodeFloatingWindows():typeof this.removeAllUltracodeWindows=="function"&&this.removeAllUltracodeWindows();const r=document.getElementById("fileBrowserPanel");if(r)if(o&&this.activeSessionId){if(r.classList.add("visible"),this.loadFileBrowser(this.activeSessionId),!this.fileBrowserDragListeners){const u=r.querySelector(".file-browser-header");if(u){const p=()=>{if(!r.style.left){const h=r.getBoundingClientRect();r.style.left=`${h.left}px`,r.style.top=`${h.top}px`,r.style.right="auto"}};u.addEventListener("mousedown",p),u.addEventListener("touchstart",p,{passive:!0}),this.fileBrowserDragListeners=this.makeWindowDraggable(r,u),this.fileBrowserDragListeners._onFirstDrag=p}}}else r.classList.remove("visible")},closeMonitor(){const e=document.getElementById("monitorPanel");e&&(e.classList.remove("open"),e.style.display="none");const t=this.loadAppSettingsFromStorage();t.showMonitor=!1,this.saveAppSettingsToStorage(t)},closeSubagentsPanel(){const e=document.getElementById("subagentsPanel");e&&(e.classList.remove("open"),e.classList.add("hidden")),this.subagentPanelVisible=!1;const t=this.loadAppSettingsFromStorage();t.showSubagents=!1,this.saveAppSettingsToStorage(t)},async clearAllSubagents(){const e=this.subagents.size;if(e===0){this.showToast("No subagents to clear","info");return}if(confirm(`Clear all ${e} tracked subagent(s)? This removes them from the UI but does not affect running processes.`))try{const n=await(await fetch("/api/subagents",{method:"DELETE"})).json();n.success?(this.subagents.clear(),this.subagentActivity.clear(),this.subagentToolResults.clear(),this.cleanupAllFloatingWindows(),this.renderSubagentPanel(),this.renderMonitorSubagents(),this.updateSubagentBadge(),this.showToast(`Cleared ${n.data.cleared} subagent(s)`,"success")):this.showToast("Failed to clear subagents: "+n.error,"error")}catch{this.showToast("Failed to clear subagents","error")}},toggleSubagentsPanel(){const e=document.getElementById("subagentsPanel"),t=document.getElementById("subagentsToggleBtn");if(e){if(e.classList.contains("hidden")){e.classList.remove("hidden");const n=this.loadAppSettingsFromStorage();n.showSubagents=!0,this.saveAppSettingsToStorage(n)}e.classList.toggle("open"),this.subagentPanelVisible=e.classList.contains("open"),t&&(t.innerHTML=this.subagentPanelVisible?"&#x25BC;":"&#x25B2;"),this.subagentPanelVisible&&this.renderSubagentPanel()}},async loadAppSettingsFromServer(e=null){try{if((MobileDetection.isHandheldDevice?.()??MobileDetection.getDeviceType()==="mobile")&&!localStorage.getItem("codeman:planUsagePerDeviceMigrated")){const t=this.loadAppSettingsFromStorage();t&&t.showPlanUsageLimits&&(t.showPlanUsageLimits=!1,this.saveAppSettingsToStorage(t)),localStorage.setItem("codeman:planUsagePerDeviceMigrated","1")}}catch{}try{const t=e?await e:await fetch("/api/settings").then(n=>n.ok?n.json():null).then(n=>n?.success===!0?n.data:n);if(t){const{notificationPreferences:n,voiceSettings:s,respawnPresets:o,runMode:i,...a}=t,l=new Set(["showFontControls","showSystemStats","showTokenCount","showCost","showLifecycleLog","showResponseViewer","showRedrawButton","showMonitor","showProjectInsights","showFileBrowser","showSubagents","subagentActiveTabOnly","tabTwoRows","tabOrientation","tabRailWidth","tabRailDetail","sessionListLayout","sessionSidebarFontSize","localEchoEnabled","cjkInputEnabled","extendedKeyboardBar","skin","showPlanUsageLimits","showAttachmentsButton","showFileViewerButton","webglRendererEnabled","terminalFontFamily","language","terminalWheelLocalScrollback","autoCopySelection","showSessionButton","showAwayDigestButton","showCronButton","showTabDetachButton","mobileOverviewEnabled","sessionLineageLines"]);delete a.showPlanUsageLimits;const c=this.loadAppSettingsFromStorage(),d={...c};for(const[r,u]of Object.entries(a))l.has(r)&&r in c||(d[r]=u);if(this.saveAppSettingsToStorage(d),n&&this.notificationManager&&(localStorage.getItem(this.notificationManager.getStorageKey())||(this.notificationManager.preferences=this.notificationManager.normalizePreferences(n),this.notificationManager.savePreferences())),s){const r=localStorage.getItem("codeman-voice-settings");(!r||!JSON.parse(r).apiKey)&&VoiceInput._saveDeepgramConfig(s)}if(o&&Array.isArray(o))this._serverRespawnPresets=o,localStorage.setItem("codeman-respawn-presets",JSON.stringify(o));else{const r=localStorage.getItem("codeman-respawn-presets");if(r){const u=JSON.parse(r);u.length>0&&(this._serverRespawnPresets=u,this._apiPut("/api/settings",{respawnPresets:u}).catch(()=>{}))}}if(i){this.runMode=i;try{localStorage.setItem("codeman_runMode",i)}catch{}this._applyRunMode()}return d}}catch(t){console.error("Failed to load settings from server:",t)}return this.loadAppSettingsFromStorage()},async loadSubagentWindowStates(){let e=null;try{const t=await fetch("/api/subagent-window-states");if(t.ok){const n=await t.json();e=n?.success===!0?n.data:n,localStorage.setItem("codeman-subagent-window-states",JSON.stringify(e))}}catch(t){console.error("Failed to load subagent window states from server:",t)}if(!e)try{const t=localStorage.getItem("codeman-subagent-window-states");t&&(e=JSON.parse(t))}catch(t){console.error("Failed to load subagent window states from localStorage:",t)}return e||{minimized:{},open:[]}},async saveSubagentParentMap(){const e=Object.fromEntries(this.subagentParentMap);try{localStorage.setItem("codeman-subagent-parents",JSON.stringify(e))}catch(t){console.error("Failed to save subagent parents to localStorage:",t)}try{await fetch("/api/subagent-parents",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(t){console.error("Failed to save subagent parents to server:",t)}},async loadSubagentParentMap(){let e=null;try{const t=await fetch("/api/subagent-parents");if(t.ok){const n=await t.json();e=n?.success===!0?n.data:n,localStorage.setItem("codeman-subagent-parents",JSON.stringify(e))}}catch(t){console.error("Failed to load subagent parents from server:",t)}if(!e)try{const t=localStorage.getItem("codeman-subagent-parents");t&&(e=JSON.parse(t))}catch(t){console.error("Failed to load subagent parents from localStorage:",t)}if(e&&typeof e=="object")for(const[t,n]of Object.entries(e))this.sessions.has(n)&&this.subagents.has(t)&&this.subagentParentMap.set(t,n)},getAgentParentSessionId(e){return this.subagentParentMap.get(e)||null},setAgentParentSessionId(e,t){if(!e||!t||this.subagentParentMap.has(e))return;this.subagentParentMap.set(e,t),this.saveSubagentParentMap();const n=this.subagents.get(e);if(n){n.parentSessionId=t;const s=this.sessions.get(t);s&&(n.parentSessionName=this.getSessionName(s)),this.subagents.set(e,n)}},showHelp(){const e=document.getElementById("helpModal");e.classList.add("active"),this.activeFocusTrap=new FocusTrap(e),this.activeFocusTrap.activate()},closeHelp(){document.getElementById("helpModal").classList.remove("active"),this.activeFocusTrap&&(this.activeFocusTrap.deactivate(),this.activeFocusTrap=null)},renderShortcutSettingsList(){const e=document.getElementById("appSettingsShortcutsList");if(!e)return;const t=this.getShortcutRegistry?this.getShortcutRegistry():typeof DEFAULT_SHORTCUTS<"u"?DEFAULT_SHORTCUTS:[],n=this.readShortcutOverridesFromSettings();e.innerHTML=t.map(s=>{const o=s.displayBindings?s.displayBindings.join(" / "):(s.bindings||[]).map(c=>[...c.modifiers||[],c.key||c.code||""].join("+")).join(" / "),i=!!s.action&&Array.isArray(s.bindings),a=!!n[s.id],l=i?`<button type="button" class="shortcut-capture-btn" data-shortcut-action="capture" title="Capture new binding">Edit</button>
61
+ </tr>`}).join("")}catch(s){console.error("Failed to load lifecycle log:",s)}},_renderVoiceProviderStatus(){const e=document.getElementById("voiceProviderStatus");if(e){const o=VoiceInput.getActiveProviderName();e.textContent=o;const i=o.startsWith("Deepgram Nova")||o.startsWith("Claude (this");e.className="voice-provider-status"+(i?" active":"")}const t=document.getElementById("voiceClaudeStatus");if(!t)return;const n=VoiceInput._claudeStatus,s=n?n.available?`Ready${n.subscriptionType?` (${n.subscriptionType})`:""}`:n.reason==="expired"?"Login expired - run a Claude session to refresh":n.reason==="no-credentials"?"No Claude Code login on the server":n.reason==="malformed"?"Claude credentials unreadable":"Off - enable it above":"Checking...";t.textContent=s,t.className="voice-provider-status"+(n?.available?" active":"")},async saveAppSettings(){const e=this.loadAppSettingsFromStorage(),t=(e.gestureControlEnabled??!1)===!0,n=(e.webglRendererEnabled??!0)===!0,s={displayName:window.CodemanI18n?.normalizeDisplayName(document.getElementById("appSettingsDisplayName").value)||"Codeman",language:window.CodemanI18n?.normalizeLanguage(document.getElementById("appSettingsLanguage").value)||"en",defaultClaudeMdPath:document.getElementById("appSettingsClaudeMdPath").value.trim(),defaultWorkingDir:document.getElementById("appSettingsDefaultDir").value.trim(),ralphTrackerEnabled:document.getElementById("appSettingsRalphEnabled").checked,showFontControls:document.getElementById("appSettingsShowFontControls").checked,showSystemStats:document.getElementById("appSettingsShowSystemStats").checked,showLifecycleLog:document.getElementById("appSettingsShowLifecycleLog").checked,showResponseViewer:document.getElementById("appSettingsShowResponseViewer").checked,showFileViewerButton:document.getElementById("appSettingsShowFileViewerButton").checked,showAttachmentsButton:document.getElementById("appSettingsShowAttachmentsButton").checked,showMonitor:document.getElementById("appSettingsShowMonitor").checked,showProjectInsights:document.getElementById("appSettingsShowProjectInsights").checked,showFileBrowser:document.getElementById("appSettingsShowFileBrowser").checked,showSubagents:document.getElementById("appSettingsShowSubagents").checked,showUltracodeAgents:document.getElementById("appSettingsShowUltracodeAgents").checked,approvalsInboxEnabled:document.getElementById("appSettingsApprovalsInbox").checked,readMyMindEnabled:document.getElementById("appSettingsReadMyMind").checked,ultracodeFloatingWindows:document.getElementById("appSettingsUltracodeFloatingWindows").checked,showMultiMonitorButton:document.getElementById("appSettingsShowMultiMonitorButton").checked,showPlanUsageLimits:document.getElementById("appSettingsShowPlanUsageLimits").checked,showRedrawButton:document.getElementById("appSettingsShowRedrawButton").checked,mobileOverviewEnabled:document.getElementById("appSettingsMobileOverview").checked,sessionLineageLines:document.getElementById("appSettingsLineageLines").checked,showSessionButton:document.getElementById("appSettingsShowSessionButton").checked,showAwayDigestButton:document.getElementById("appSettingsShowAwayDigestButton").checked,showCronButton:document.getElementById("appSettingsShowCronButton").checked,gestureControlEnabled:document.getElementById("appSettingsGestureControl").checked,subagentTrackingEnabled:document.getElementById("appSettingsSubagentTracking").checked,subagentActiveTabOnly:document.getElementById("appSettingsSubagentActiveTabOnly").checked,imageWatcherEnabled:document.getElementById("appSettingsImageWatcherEnabled").checked,tunnelEnabled:document.getElementById("appSettingsTunnelEnabled").checked,localEchoEnabled:document.getElementById("appSettingsLocalEcho").checked,autoCopySelection:document.getElementById("appSettingsAutoCopySelection").checked,terminalFontFamily:document.getElementById("appSettingsTerminalFont").value.trim(),terminalWheelLocalScrollback:document.getElementById("appSettingsTerminalWheelLocal").checked,cjkInputEnabled:document.getElementById("appSettingsCjkInput").checked,webglRendererEnabled:document.getElementById("appSettingsWebglRenderer").checked,extendedKeyboardBar:document.getElementById("appSettingsExtendedKeyboardBar").checked,tabTwoRows:document.getElementById("appSettingsTabTwoRows").checked,tabOrientation:document.getElementById("appSettingsTabOrientation").value,tabRailWidth:this.readTabRailWidthSetting?.()??256,tabRailDetail:document.getElementById("appSettingsTabRailDetail").value,showTabDetachButton:document.getElementById("appSettingsShowTabDetachButton").checked,sessionListLayout:document.getElementById("appSettingsSessionListLayout").value,sessionSidebarFontSize:this.resolveSessionSidebarFontSize(document.getElementById("appSettingsSessionSidebarFontSize").value),skin:document.getElementById("appSettingsSkin").value,claudeMode:document.getElementById("appSettingsClaudeMode").value,allowedTools:document.getElementById("appSettingsAllowedTools").value.trim(),codexDangerouslyBypassApprovals:document.getElementById("appSettingsCodexDangerouslyBypassApprovals").checked,codexAnimationsEnabled:document.getElementById("appSettingsCodexAnimations").checked,agentTeamsEnabled:document.getElementById("appSettingsAgentTeams").checked,agentSkillEnabled:document.getElementById("appSettingsAgentSkill").checked,workspaceHooksEnabled:document.getElementById("appSettingsWorkspaceHooks").checked,claudeVoiceEnabled:document.getElementById("appSettingsClaudeVoice").checked,claudeModel:document.getElementById("appSettingsClaudeModel").value,opusContext1mEnabled:document.getElementById("appSettingsOpusContext1m").checked,remoteAutoReconnect:document.getElementById("appSettingsRemoteAutoReconnect").checked,thinkingEffort:document.getElementById("appSettingsThinkingEffort").value,nice:{enabled:document.getElementById("appSettingsNiceEnabled").checked,niceValue:parseInt(document.getElementById("appSettingsNiceValue").value)||10}};if(e.showTokenCount!==void 0&&(s.showTokenCount=e.showTokenCount),e.showCost!==void 0&&(s.showCost=e.showCost),e.shortcutOverrides!==void 0&&(s.shortcutOverrides=e.shortcutOverrides),this.saveAppSettingsToStorage(s),this._updateLocalEchoState(),this.applyTerminalFontFamily?.(s.terminalFontFamily),!n&&s.webglRendererEnabled)try{localStorage.removeItem("codeman-webgl-disabled")}catch{}const o={provider:document.getElementById("voiceProvider").value,apiKey:document.getElementById("voiceDeepgramKey").value.trim(),language:document.getElementById("voiceLanguage").value,keyterms:document.getElementById("voiceKeyterms").value.trim(),insertMode:document.getElementById("voiceInsertMode").value};VoiceInput._saveDeepgramConfig(o);const i={enabled:document.getElementById("appSettingsNotifEnabled").checked,browserNotifications:document.getElementById("appSettingsNotifBrowser").checked,audioAlerts:document.getElementById("appSettingsNotifAudio").checked,stuckThresholdMs:(parseInt(document.getElementById("appSettingsNotifStuckMins").value)||10)*6e4,muteCritical:!document.getElementById("appSettingsNotifCritical").checked,muteWarning:!document.getElementById("appSettingsNotifWarning").checked,muteInfo:!document.getElementById("appSettingsNotifInfo").checked,eventTypes:{permission_prompt:{enabled:document.getElementById("eventPermissionEnabled").checked,browser:document.getElementById("eventPermissionBrowser").checked,push:document.getElementById("eventPermissionPush").checked,audio:document.getElementById("eventPermissionAudio").checked},elicitation_dialog:{enabled:document.getElementById("eventQuestionEnabled").checked,browser:document.getElementById("eventQuestionBrowser").checked,push:document.getElementById("eventQuestionPush").checked,audio:document.getElementById("eventQuestionAudio").checked},idle_prompt:{enabled:document.getElementById("eventIdleEnabled").checked,browser:document.getElementById("eventIdleBrowser").checked,push:document.getElementById("eventIdlePush").checked,audio:document.getElementById("eventIdleAudio").checked},stop:{enabled:document.getElementById("eventStopEnabled").checked,browser:document.getElementById("eventStopBrowser").checked,push:document.getElementById("eventStopPush").checked,audio:document.getElementById("eventStopAudio").checked},session_error:{enabled:!0,browser:this.notificationManager?.preferences?.eventTypes?.session_error?.browser??!0,push:this.notificationManager?.preferences?.eventTypes?.session_error?.push??!1,audio:!1},respawn_cycle:{enabled:document.getElementById("eventRespawnEnabled").checked,browser:document.getElementById("eventRespawnBrowser").checked,push:document.getElementById("eventRespawnPush").checked,audio:document.getElementById("eventRespawnAudio").checked},token_milestone:{enabled:!0,browser:!1,push:!1,audio:!1},ralph_complete:{enabled:document.getElementById("eventRalphEnabled").checked,browser:document.getElementById("eventRalphBrowser").checked,push:document.getElementById("eventRalphPush").checked,audio:document.getElementById("eventRalphAudio").checked},subagent_spawn:{enabled:document.getElementById("eventSubagentEnabled").checked,browser:document.getElementById("eventSubagentBrowser").checked,push:document.getElementById("eventSubagentPush").checked,audio:document.getElementById("eventSubagentAudio").checked},subagent_complete:{enabled:document.getElementById("eventSubagentEnabled").checked,browser:document.getElementById("eventSubagentBrowser").checked,push:document.getElementById("eventSubagentPush").checked,audio:document.getElementById("eventSubagentAudio").checked}},_version:5};this.notificationManager&&(this.notificationManager.preferences=i,this.notificationManager.savePreferences()),this._syncPushPreferences(),this.applyHeaderVisibilitySettings(),this.applySkin(),this.applyLocalization(),this.applySessionListLayout(),this.applyTabOrientation({settleRailWidth:!0}),this.applyLineageLineSettings?.(),this._updateTokensImmediate(),this.applyMonitorVisibility(),this.renderApprovals?.(),this.renderProjectInsightsPanel(),this.updateSubagentWindowVisibility(),this._updateCjkInputState(),this.activeSessionId||this.showWelcome(),KeyboardAccessoryBar.setMode(s.extendedKeyboardBar?"extended":"simple");const{localEchoEnabled:a,cjkInputEnabled:l,extendedKeyboardBar:c,skin:d,language:r,showPlanUsageLimits:u,showAttachmentsButton:p,showFileViewerButton:h,webglRendererEnabled:m,terminalWheelLocalScrollback:g,autoCopySelection:S,terminalFontFamily:b,showSessionButton:E,showAwayDigestButton:w,showCronButton:v,showTabDetachButton:y,mobileOverviewEnabled:B,sessionLineageLines:I,...f}=s;try{const k=await this._apiPut("/api/settings",{...f,...s.showPlanUsageLimits?{statusLineTelemetry:!0}:{},notificationPreferences:i,voiceSettings:o});if(s.tunnelEnabled&&await this._handleTunnelEnableRefusal(k)){s.tunnelEnabled=!1,this.saveAppSettingsToStorage(s);const T=document.getElementById("appSettingsTunnelEnabled");T&&(T.checked=!1),this.closeAppSettings();return}await this.saveModelConfigFromSettings(),this.showToast("Settings saved","success"),s.tunnelEnabled&&this.showToast("Tunnel starting \u2014 QR code will appear when ready...","info")}catch{this.showToast("Settings saved locally","warning")}this.closeAppSettings(),VoiceInput.refreshClaudeStatus(),s.gestureControlEnabled!==t&&(this.showToast(s.gestureControlEnabled?"Enabling gesture control \u2014 reloading\u2026":"Disabling gesture control \u2014 reloading\u2026","info"),setTimeout(()=>location.reload(),400))},async loadModelConfigForSettings(){try{const t=await(await fetch("/api/execution/model-config")).json();if(t.success&&t.data){const n=t.data,s=document.getElementById("appSettingsDefaultModel");s&&(s.value=n.defaultModel||"");const o=document.getElementById("appSettingsShowModelRecommendations");o&&(o.checked=n.showRecommendations??!0);const i=n.agentTypeOverrides||{},a=document.getElementById("appSettingsModelExplore"),l=document.getElementById("appSettingsModelImplement"),c=document.getElementById("appSettingsModelTest"),d=document.getElementById("appSettingsModelReview");a&&(a.value=i.explore||""),l&&(l.value=i.implement||""),c&&(c.value=i.test||""),d&&(d.value=i.review||"")}}catch(e){console.warn("Failed to load model config:",e)}},async saveModelConfigFromSettings(){const e=document.getElementById("appSettingsDefaultModel"),t=document.getElementById("appSettingsShowModelRecommendations"),n=document.getElementById("appSettingsModelExplore"),s=document.getElementById("appSettingsModelImplement"),o=document.getElementById("appSettingsModelTest"),i=document.getElementById("appSettingsModelReview"),a={};n?.value&&(a.explore=n.value),s?.value&&(a.implement=s.value),o?.value&&(a.test=o.value),i?.value&&(a.review=i.value);const l={defaultModel:e?.value||"",showRecommendations:t?.checked??!0,agentTypeOverrides:a};try{await fetch("/api/execution/model-config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)})}catch(c){console.warn("Failed to save model config:",c)}},isRalphTrackerEnabledByDefault(){return this.loadAppSettingsFromStorage().ralphTrackerEnabled??!1},getSettingsStorageKey(){return MobileDetection.isHandheldDevice?.()??MobileDetection.getDeviceType()==="mobile"?"codeman-app-settings-mobile":"codeman-app-settings"},getDefaultSettings(){return MobileDetection.isHandheldDevice?.()??MobileDetection.getDeviceType()==="mobile"?{showFontControls:!1,showSystemStats:!1,showTokenCount:!1,showCost:!1,showMonitor:!1,showProjectInsights:!1,showFileBrowser:!1,showSubagents:!1,showUltracodeAgents:!1,ultracodeFloatingWindows:!1,showMultiMonitorButton:!1,showPlanUsageLimits:!1,showAttachmentsButton:!1,showFileViewerButton:!1,showRedrawButton:!1,showSessionButton:!1,showAwayDigestButton:!1,showCronButton:!1,mobileOverviewEnabled:!0,remoteAutoReconnect:!0,gestureControlEnabled:!1,subagentTrackingEnabled:!0,subagentActiveTabOnly:!0,imageWatcherEnabled:!1,ralphTrackerEnabled:!1,tabTwoRows:!1,tabOrientation:"horizontal",tabRailWidth:256,tabRailDetail:"rich",sessionListLayout:"header",sessionSidebarFontSize:12,cjkInputEnabled:!1,terminalWheelLocalScrollback:!1,webglRendererEnabled:!1,skin:"daylight-blue"}:{}},loadAppSettingsFromStorage(){if(this._cachedAppSettings)return this._cachedAppSettings;try{const e=this.getSettingsStorageKey(),t=localStorage.getItem(e);if(t)return this._cachedAppSettings=JSON.parse(t),this._cachedAppSettings}catch(e){console.error("Failed to load app settings:",e)}return this._cachedAppSettings=this.getDefaultSettings(),this._cachedAppSettings},saveAppSettingsToStorage(e){this._cachedAppSettings=e;try{const t=this.getSettingsStorageKey();localStorage.setItem(t,JSON.stringify(e))}catch(t){console.error("Failed to save app settings:",t)}},applySkin(){const e=this.loadAppSettingsFromStorage(),t=this.getDefaultSettings(),n=e.skin??t.skin??"daylight-blue";document.documentElement.setAttribute("data-skin",n),window.__codemanSkin=n;const s=getComputedStyle(document.documentElement).getPropertyValue("--bg-dark").trim();s&&document.querySelector('meta[name="theme-color"]')?.setAttribute("content",s);try{localStorage.setItem("codeman:skin",n)}catch{}typeof this.applyTerminalSkin=="function"&&this.applyTerminalSkin(n)},applyLocalization(){const e=this.loadAppSettingsFromStorage();window.CodemanI18n?.configure({language:e.language,displayName:e.displayName})&&this.notificationManager&&(this.notificationManager.originalTitle=document.title)},planUsageChipEnabled(e=null){return(e??this.loadAppSettingsFromStorage()).showPlanUsageLimits??this.getDefaultSettings().showPlanUsageLimits??!0},applyHeaderVisibilitySettings(){const e=this.loadAppSettingsFromStorage(),t=this.getDefaultSettings(),n=e.showTabDetachButton??t.showTabDetachButton??!1;document.documentElement.classList.toggle("tabs-show-detach",n);const s=MobileDetection.getDeviceType()!=="desktop",o=s?!1:e.showFontControls??t.showFontControls??!1,i=s?!1:e.showSystemStats??t.showSystemStats??!0,a=s?!1:e.showTokenCount??t.showTokenCount??!1,l=document.querySelector(".header-font-controls"),c=document.getElementById("headerSystemStats"),d=document.getElementById("headerTokens");l&&(l.style.display=o?"":"none"),c&&(c.style.display=i?"":"none"),d&&(d.style.display=a?"":"none");const r=e.showLifecycleLog??t.showLifecycleLog??!1,u=document.querySelector(".btn-lifecycle-log");u&&(u.style.display=r?"":"none");const p=e.showResponseViewer??t.showResponseViewer??!1,h=document.querySelector(".btn-response-viewer-header");h&&h.classList.toggle("btn-response-viewer-header--hidden",!p);const m=e.showAttachmentsButton??t.showAttachmentsButton??!1,g=document.getElementById("attachmentsHistoryBtn");g&&g.classList.toggle("btn-attachments-history--hidden",!m);const S=e.showFileViewerButton??t.showFileViewerButton??!0,b=document.querySelector(".btn-file-viewer");b&&b.classList.toggle("btn-file-viewer--hidden",!S);const E=e.showMultiMonitorButton??t.showMultiMonitorButton??!1,w=document.querySelector(".btn-multimonitor");w&&w.classList.toggle("btn-multimonitor--hidden",!E);const v=e.showUltracodeAgents??t.showUltracodeAgents??!1,y=document.querySelector(".btn-ultracode-agents");y&&y.classList.toggle("btn-ultracode-agents--hidden",!v);const B=document.querySelector(".btn-readmymind");B&&B.classList.toggle("btn-readmymind--hidden",e.readMyMindEnabled!==!0),typeof KeyboardAccessoryBar<"u"&&KeyboardAccessoryBar.syncReadMyMind?.();const I=this.planUsageChipEnabled(e),f=document.getElementById("planUsageChip");f&&f.classList.toggle("header-plan-usage--hidden",!I);const k=e.showRedrawButton??t.showRedrawButton??!1,T=document.querySelector(".btn-redraw-terminal");T&&T.classList.toggle("btn-redraw-terminal--hidden",!k);const M=e.showSessionButton??t.showSessionButton??!1,_=document.querySelector(".btn-session-manager");_&&_.classList.toggle("btn-session-manager--hidden",!M);const x=e.showAwayDigestButton??t.showAwayDigestButton??!1,C=document.querySelector(".btn-away-digest");C&&C.classList.toggle("btn-away-digest--hidden",!x);const R=e.showCronButton??t.showCronButton??!1,L=document.querySelector(".btn-cron");L&&L.classList.toggle("btn-cron--hidden",!R);const P=document.querySelector(".btn-notifications");if(P&&(P.style.display="none"),!(this.notificationManager?.preferences?.enabled??!0)){const A=document.getElementById("notifDrawer");A&&A.classList.remove("open")}},applyTabOrientation(e={}){const t=this.loadAppSettingsFromStorage(),n=this.getDefaultSettings(),s=this.isSessionSidebarActive?.()===!0,o=!this.isSoloWindow&&!s&&window.CodemanTabOverflow?.resolveTabOrientation?window.CodemanTabOverflow.resolveTabOrientation({deviceType:MobileDetection.getDeviceType(),setting:t.tabOrientation??n.tabOrientation??"horizontal"}):"horizontal",i=document.documentElement,a=i.getAttribute("data-tab-orientation")||"horizontal";i.setAttribute("data-tab-orientation",o);const l=i.dataset.tabRailDetail||"rich",c=(t.tabRailDetail??n.tabRailDetail??"rich")==="simple"?"simple":"rich";i.dataset.tabRailDetail=c;const d=document.getElementById("sessionTabs"),r=document.getElementById("tabRail"),u=document.getElementById("sessionTabsHost");!s&&d&&r&&u&&(o==="vertical"?d.parentElement!==r&&r.appendChild(d):d.parentElement!==u&&u.appendChild(d)),d&&d.setAttribute("aria-orientation",s||o==="vertical"?"vertical":"horizontal");const p=e.settleRailWidth===!0&&(o==="vertical"||a!==o);this.applyTabRailWidth?.({settle:p});const h=a!==o,m=h||l!==c;h&&(this.updateTabOverflowMode?.(),p||this.fitAddon?.fit());const g=this._tallTabsEnabled;m&&this.applyTabWrapSettings?.(),m&&(g!==void 0&&g!==this._tallTabsEnabled||this._fullRenderSessionTabs?.(),this._updateConnectionLinesImmediate?.(),this._refreshHomeSessionsIfVisible?.()),this.isRichTabRows?.()?this._startSidebarRichClock?.():this._stopSidebarRichClock?.()},applyTabWrapSettings(){const e=this.loadAppSettingsFromStorage(),t=this.getDefaultSettings(),n=MobileDetection.getDeviceType(),s=this.isSessionSidebarActive?.()===!0,o=!s&&n==="desktop"?e.tabTwoRows??t.tabTwoRows??!1:!1,i=this.isTabRailRich?.()===!0,a=s||o||i,l=this._tallTabsEnabled;this._tallTabsEnabled=a;const c=document.getElementById("sessionTabs");c&&(c.classList.toggle("tabs-two-rows",o),c.classList.toggle("tabs-show-folder",a)),l!==void 0&&l!==a&&this._fullRenderSessionTabs()},applyMonitorVisibility(){const e=this.loadAppSettingsFromStorage(),t=this.getDefaultSettings(),n=e.showMonitor??t.showMonitor??!1,s=e.showSubagents??t.showSubagents??!1,o=e.showFileBrowser??t.showFileBrowser??!1,i=document.getElementById("monitorPanel");i&&(i.style.display=n?"":"none",n?i.classList.add("open"):i.classList.remove("open"));const a=document.getElementById("subagentsPanel");a&&(s?a.classList.remove("hidden"):a.classList.add("hidden"));const l=e.showUltracodeAgents??t.showUltracodeAgents??!1,c=document.getElementById("ultracodeAgentsPanel");c&&(l?c.classList.remove("hidden"):(c.classList.remove("open"),c.classList.add("hidden"))),e.ultracodeFloatingWindows??t.ultracodeFloatingWindows??!1?typeof this.syncAllUltracodeFloatingWindows=="function"&&this.syncAllUltracodeFloatingWindows():typeof this.removeAllUltracodeWindows=="function"&&this.removeAllUltracodeWindows();const r=document.getElementById("fileBrowserPanel");if(r)if(o&&this.activeSessionId){if(r.classList.add("visible"),this.loadFileBrowser(this.activeSessionId),!this.fileBrowserDragListeners){const u=r.querySelector(".file-browser-header");if(u){const p=()=>{if(!r.style.left){const h=r.getBoundingClientRect();r.style.left=`${h.left}px`,r.style.top=`${h.top}px`,r.style.right="auto"}};u.addEventListener("mousedown",p),u.addEventListener("touchstart",p,{passive:!0}),this.fileBrowserDragListeners=this.makeWindowDraggable(r,u),this.fileBrowserDragListeners._onFirstDrag=p}}}else r.classList.contains("visible")&&(this._resetFileBrowserForHide?.(),r.classList.remove("visible"))},closeMonitor(){const e=document.getElementById("monitorPanel");e&&(e.classList.remove("open"),e.style.display="none");const t=this.loadAppSettingsFromStorage();t.showMonitor=!1,this.saveAppSettingsToStorage(t)},closeSubagentsPanel(){const e=document.getElementById("subagentsPanel");e&&(e.classList.remove("open"),e.classList.add("hidden")),this.subagentPanelVisible=!1;const t=this.loadAppSettingsFromStorage();t.showSubagents=!1,this.saveAppSettingsToStorage(t)},async clearAllSubagents(){const e=this.subagents.size;if(e===0){this.showToast("No subagents to clear","info");return}if(confirm(`Clear all ${e} tracked subagent(s)? This removes them from the UI but does not affect running processes.`))try{const n=await(await fetch("/api/subagents",{method:"DELETE"})).json();n.success?(this.subagents.clear(),this.subagentActivity.clear(),this.subagentToolResults.clear(),this.cleanupAllFloatingWindows(),this.renderSubagentPanel(),this.renderMonitorSubagents(),this.updateSubagentBadge(),this.showToast(`Cleared ${n.data.cleared} subagent(s)`,"success")):this.showToast("Failed to clear subagents: "+n.error,"error")}catch{this.showToast("Failed to clear subagents","error")}},toggleSubagentsPanel(){const e=document.getElementById("subagentsPanel"),t=document.getElementById("subagentsToggleBtn");if(e){if(e.classList.contains("hidden")){e.classList.remove("hidden");const n=this.loadAppSettingsFromStorage();n.showSubagents=!0,this.saveAppSettingsToStorage(n)}e.classList.toggle("open"),this.subagentPanelVisible=e.classList.contains("open"),t&&(t.innerHTML=this.subagentPanelVisible?"&#x25BC;":"&#x25B2;"),this.subagentPanelVisible&&this.renderSubagentPanel()}},async loadAppSettingsFromServer(e=null){try{if((MobileDetection.isHandheldDevice?.()??MobileDetection.getDeviceType()==="mobile")&&!localStorage.getItem("codeman:planUsagePerDeviceMigrated")){const t=this.loadAppSettingsFromStorage();t&&t.showPlanUsageLimits&&(t.showPlanUsageLimits=!1,this.saveAppSettingsToStorage(t)),localStorage.setItem("codeman:planUsagePerDeviceMigrated","1")}}catch{}try{const t=e?await e:await fetch("/api/settings").then(n=>n.ok?n.json():null).then(n=>n?.success===!0?n.data:n);if(t){const{notificationPreferences:n,voiceSettings:s,respawnPresets:o,runMode:i,...a}=t,l=new Set(["showFontControls","showSystemStats","showTokenCount","showCost","showLifecycleLog","showResponseViewer","showRedrawButton","showMonitor","showProjectInsights","showFileBrowser","showSubagents","subagentActiveTabOnly","tabTwoRows","tabOrientation","tabRailWidth","tabRailDetail","sessionListLayout","sessionSidebarFontSize","localEchoEnabled","cjkInputEnabled","extendedKeyboardBar","skin","showPlanUsageLimits","showAttachmentsButton","showFileViewerButton","webglRendererEnabled","terminalFontFamily","language","terminalWheelLocalScrollback","autoCopySelection","showSessionButton","showAwayDigestButton","showCronButton","showTabDetachButton","mobileOverviewEnabled","sessionLineageLines"]);delete a.showPlanUsageLimits;const c=this.loadAppSettingsFromStorage(),d={...c};for(const[r,u]of Object.entries(a))l.has(r)&&r in c||(d[r]=u);if(this.saveAppSettingsToStorage(d),n&&this.notificationManager&&(localStorage.getItem(this.notificationManager.getStorageKey())||(this.notificationManager.preferences=this.notificationManager.normalizePreferences(n),this.notificationManager.savePreferences())),s){const r=localStorage.getItem("codeman-voice-settings");(!r||!JSON.parse(r).apiKey)&&VoiceInput._saveDeepgramConfig(s)}if(o&&Array.isArray(o))this._serverRespawnPresets=o,localStorage.setItem("codeman-respawn-presets",JSON.stringify(o));else{const r=localStorage.getItem("codeman-respawn-presets");if(r){const u=JSON.parse(r);u.length>0&&(this._serverRespawnPresets=u,this._apiPut("/api/settings",{respawnPresets:u}).catch(()=>{}))}}if(i){this.runMode=i;try{localStorage.setItem("codeman_runMode",i)}catch{}this._applyRunMode()}return d}}catch(t){console.error("Failed to load settings from server:",t)}return this.loadAppSettingsFromStorage()},async loadSubagentWindowStates(){let e=null;try{const t=await fetch("/api/subagent-window-states");if(t.ok){const n=await t.json();e=n?.success===!0?n.data:n,localStorage.setItem("codeman-subagent-window-states",JSON.stringify(e))}}catch(t){console.error("Failed to load subagent window states from server:",t)}if(!e)try{const t=localStorage.getItem("codeman-subagent-window-states");t&&(e=JSON.parse(t))}catch(t){console.error("Failed to load subagent window states from localStorage:",t)}return e||{minimized:{},open:[]}},async saveSubagentParentMap(){const e=Object.fromEntries(this.subagentParentMap);try{localStorage.setItem("codeman-subagent-parents",JSON.stringify(e))}catch(t){console.error("Failed to save subagent parents to localStorage:",t)}try{await fetch("/api/subagent-parents",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(t){console.error("Failed to save subagent parents to server:",t)}},async loadSubagentParentMap(){let e=null;try{const t=await fetch("/api/subagent-parents");if(t.ok){const n=await t.json();e=n?.success===!0?n.data:n,localStorage.setItem("codeman-subagent-parents",JSON.stringify(e))}}catch(t){console.error("Failed to load subagent parents from server:",t)}if(!e)try{const t=localStorage.getItem("codeman-subagent-parents");t&&(e=JSON.parse(t))}catch(t){console.error("Failed to load subagent parents from localStorage:",t)}if(e&&typeof e=="object")for(const[t,n]of Object.entries(e))this.sessions.has(n)&&this.subagents.has(t)&&this.subagentParentMap.set(t,n)},getAgentParentSessionId(e){return this.subagentParentMap.get(e)||null},setAgentParentSessionId(e,t){if(!e||!t||this.subagentParentMap.has(e))return;this.subagentParentMap.set(e,t),this.saveSubagentParentMap();const n=this.subagents.get(e);if(n){n.parentSessionId=t;const s=this.sessions.get(t);s&&(n.parentSessionName=this.getSessionName(s)),this.subagents.set(e,n)}},showHelp(){const e=document.getElementById("helpModal");e.classList.add("active"),this.activeFocusTrap=new FocusTrap(e),this.activeFocusTrap.activate()},closeHelp(){document.getElementById("helpModal").classList.remove("active"),this.activeFocusTrap&&(this.activeFocusTrap.deactivate(),this.activeFocusTrap=null)},renderShortcutSettingsList(){const e=document.getElementById("appSettingsShortcutsList");if(!e)return;const t=this.getShortcutRegistry?this.getShortcutRegistry():typeof DEFAULT_SHORTCUTS<"u"?DEFAULT_SHORTCUTS:[],n=this.readShortcutOverridesFromSettings();e.innerHTML=t.map(s=>{const o=s.displayBindings?s.displayBindings.join(" / "):(s.bindings||[]).map(c=>[...c.modifiers||[],c.key||c.code||""].join("+")).join(" / "),i=!!s.action&&Array.isArray(s.bindings),a=!!n[s.id],l=i?`<button type="button" class="shortcut-capture-btn" data-shortcut-action="capture" title="Capture new binding">Edit</button>
62
62
  <button type="button" class="shortcut-reset-btn" data-shortcut-action="reset" title="Reset to default"${a?"":" disabled"}>Reset</button>
63
63
  <input class="shortcut-enabled-checkbox" type="checkbox" ${s.disabled?"":"checked"} data-shortcut-action="toggle" title="Enable/disable">`:"";return`<div class="shortcut-setting-row${i?"":" shortcut-setting-row--fixed"}" data-shortcut-id="${escapeHtml(s.id)}">
64
64
  <label class="shortcut-setting-label">${escapeHtml(s.label)}</label>