aicodeman 1.42.0 → 1.43.0
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/README.md +10 -10
- package/dist/claude-session-title.d.ts +6 -4
- package/dist/claude-session-title.d.ts.map +1 -1
- package/dist/claude-session-title.js +6 -4
- package/dist/claude-session-title.js.map +1 -1
- package/dist/config/cli-registry/patterns.d.ts +1 -1
- package/dist/config/cli-registry/patterns.d.ts.map +1 -1
- package/dist/config/cli-registry/patterns.js +3 -0
- package/dist/config/cli-registry/patterns.js.map +1 -1
- package/dist/config/cli-registry/schema.d.ts +1 -0
- package/dist/config/cli-registry/schema.d.ts.map +1 -1
- package/dist/config/cli-registry/schema.js +5 -3
- package/dist/config/cli-registry/schema.js.map +1 -1
- package/dist/config/cli-registry/stock.d.ts.map +1 -1
- package/dist/config/cli-registry/stock.js +255 -1
- package/dist/config/cli-registry/stock.js.map +1 -1
- package/dist/config/cli-registry/types.d.ts +11 -3
- package/dist/config/cli-registry/types.d.ts.map +1 -1
- package/dist/hooks-config.d.ts +9 -0
- package/dist/hooks-config.d.ts.map +1 -1
- package/dist/hooks-config.js +12 -0
- package/dist/hooks-config.js.map +1 -1
- package/dist/mcp-sync-targets.d.ts +6 -3
- package/dist/mcp-sync-targets.d.ts.map +1 -1
- package/dist/mcp-sync-targets.js +6 -3
- package/dist/mcp-sync-targets.js.map +1 -1
- package/dist/mux-interface.d.ts +7 -3
- package/dist/mux-interface.d.ts.map +1 -1
- package/dist/session-cli-registry-bridge.d.ts +2 -1
- package/dist/session-cli-registry-bridge.d.ts.map +1 -1
- package/dist/session-cli-registry-bridge.js.map +1 -1
- package/dist/session.d.ts +23 -8
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +38 -9
- package/dist/session.js.map +1 -1
- package/dist/tmux-manager.d.ts +3 -2
- package/dist/tmux-manager.d.ts.map +1 -1
- package/dist/tmux-manager.js +4 -2
- package/dist/tmux-manager.js.map +1 -1
- package/dist/types/session.d.ts +32 -4
- package/dist/types/session.d.ts.map +1 -1
- package/dist/types/session.js +2 -1
- package/dist/types/session.js.map +1 -1
- package/dist/utils/cli-installed-probes.d.ts +1 -1
- package/dist/utils/cli-installed-probes.d.ts.map +1 -1
- package/dist/utils/cli-installed-probes.js +4 -2
- package/dist/utils/cli-installed-probes.js.map +1 -1
- package/dist/utils/copilot-cli-resolver.d.ts +48 -0
- package/dist/utils/copilot-cli-resolver.d.ts.map +1 -0
- package/dist/utils/copilot-cli-resolver.js +112 -0
- package/dist/utils/copilot-cli-resolver.js.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/web/case-path.d.ts +4 -2
- package/dist/web/case-path.d.ts.map +1 -1
- package/dist/web/case-path.js +13 -4
- package/dist/web/case-path.js.map +1 -1
- package/dist/web/public/admin-ui.js.gz +0 -0
- package/dist/web/public/api-client.c9b1cddc.js.gz +0 -0
- package/dist/web/public/{app.f04bb2a5.js → app.ae50029a.js} +7 -7
- package/dist/web/public/app.ae50029a.js.br +0 -0
- package/dist/web/public/app.ae50029a.js.gz +0 -0
- package/dist/web/public/approvals-ui.js.gz +0 -0
- package/dist/web/public/{constants.12b0c247.js → constants.e5e588db.js} +156 -2
- package/dist/web/public/constants.e5e588db.js.br +0 -0
- package/dist/web/public/constants.e5e588db.js.gz +0 -0
- package/dist/web/public/cron-ui.js.gz +0 -0
- package/dist/web/public/entrance-animations.js.gz +0 -0
- package/dist/web/public/git-status-ui.js.gz +0 -0
- package/dist/web/public/home-sessions.js.gz +0 -0
- package/dist/web/public/host-wake-ui.js.gz +0 -0
- package/dist/web/public/i18n.8f291f06.js +2 -0
- package/dist/web/public/i18n.8f291f06.js.br +0 -0
- package/dist/web/public/i18n.8f291f06.js.gz +0 -0
- package/dist/web/public/{image-input.fcdcb46c.js → image-input.941386e7.js} +24 -14
- package/dist/web/public/image-input.941386e7.js.br +0 -0
- package/dist/web/public/image-input.941386e7.js.gz +0 -0
- package/dist/web/public/index.html +23 -14
- package/dist/web/public/index.html.br +0 -0
- package/dist/web/public/index.html.gz +0 -0
- package/dist/web/public/input-cjk.8bc46081.js.gz +0 -0
- package/dist/web/public/{keyboard-accessory.b42f539b.js → keyboard-accessory.c283e827.js} +28 -17
- package/dist/web/public/keyboard-accessory.c283e827.js.br +0 -0
- package/dist/web/public/keyboard-accessory.c283e827.js.gz +0 -0
- package/dist/web/public/mobile-handlers.0ef9c311.js.gz +0 -0
- package/dist/web/public/mobile-ime-preview.2dbaf262.js.gz +0 -0
- package/dist/web/public/mobile-overview.js +1 -0
- package/dist/web/public/mobile-overview.js.br +0 -0
- package/dist/web/public/mobile-overview.js.gz +0 -0
- package/dist/web/public/mobile.13514863.css +1 -0
- package/dist/web/public/mobile.13514863.css.br +0 -0
- package/dist/web/public/mobile.13514863.css.gz +0 -0
- package/dist/web/public/notification-manager.feb82c04.js.gz +0 -0
- package/dist/web/public/orchestrator-panel.js.gz +0 -0
- package/dist/web/public/{panels-ui.73ec0137.js → panels-ui.b7bfb9da.js} +6 -6
- package/dist/web/public/panels-ui.b7bfb9da.js.br +0 -0
- package/dist/web/public/panels-ui.b7bfb9da.js.gz +0 -0
- package/dist/web/public/ralph-panel.b350e2ef.js.gz +0 -0
- package/dist/web/public/ralph-wizard.b6c0dd19.js.gz +0 -0
- package/dist/web/public/readmymind-ui.js.gz +0 -0
- package/dist/web/public/reboot-restore-ui.js.gz +0 -0
- package/dist/web/public/respawn-ui.d7adcf6a.js.gz +0 -0
- package/dist/web/public/sanitize-html.e7147e76.js.gz +0 -0
- package/dist/web/public/security-notices.json +21 -0
- package/dist/web/public/session-lineage.js.gz +0 -0
- package/dist/web/public/{session-ui.d52ff6aa.js → session-ui.be076c88.js} +2 -2
- package/dist/web/public/session-ui.be076c88.js.br +0 -0
- package/dist/web/public/session-ui.be076c88.js.gz +0 -0
- package/dist/web/public/{settings-ui.3a22bd2a.js → settings-ui.fc4cc50a.js} +2 -2
- package/dist/web/public/settings-ui.fc4cc50a.js.br +0 -0
- package/dist/web/public/settings-ui.fc4cc50a.js.gz +0 -0
- package/dist/web/public/spreadsheet-preview-worker.js.gz +0 -0
- package/dist/web/public/spreadsheet-preview.75c751de.js.gz +0 -0
- package/dist/web/public/spreadsheet-xlsx-core.js.gz +0 -0
- package/dist/web/public/styles.dcfa907f.css +1 -0
- package/dist/web/public/styles.dcfa907f.css.br +0 -0
- package/dist/web/public/styles.dcfa907f.css.gz +0 -0
- package/dist/web/public/subagent-windows.07277a58.js.gz +0 -0
- package/dist/web/public/sw.js +2 -2
- package/dist/web/public/sw.js.br +0 -0
- package/dist/web/public/sw.js.gz +0 -0
- package/dist/web/public/tab-layout-browser.2d6189f7.js.gz +0 -0
- package/dist/web/public/tab-rail-resize.7157e0bd.js.gz +0 -0
- package/dist/web/public/terminal-keycode229-recovery.af09f99a.js.gz +0 -0
- package/dist/web/public/terminal-split.js.gz +0 -0
- package/dist/web/public/terminal-tile.js.gz +0 -0
- package/dist/web/public/{terminal-ui.0a7ccc29.js → terminal-ui.ae01a7d1.js} +2 -2
- package/dist/web/public/terminal-ui.ae01a7d1.js.br +0 -0
- package/dist/web/public/terminal-ui.ae01a7d1.js.gz +0 -0
- package/dist/web/public/tile-grid.js +3 -6
- package/dist/web/public/tile-grid.js.br +0 -0
- package/dist/web/public/tile-grid.js.gz +0 -0
- package/dist/web/public/ultracode-panel.js.gz +0 -0
- package/dist/web/public/ultracode-windows.js.gz +0 -0
- package/dist/web/public/vendor/dompurify.min.js.gz +0 -0
- package/dist/web/public/vendor/exceljs.min.js.gz +0 -0
- package/dist/web/public/vendor/fflate.min.js.gz +0 -0
- package/dist/web/public/vendor/marked.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-fit.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-serialize.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-predictive-echo.ae5e3d5d.js.gz +0 -0
- package/dist/web/public/vendor/xterm-zerolag-input.0b69623c.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.2342c37b.js.gz +0 -0
- package/dist/web/public/voice-pcm-worklet.js.gz +0 -0
- package/dist/web/public/webview-tabs.js.gz +0 -0
- package/dist/web/public/whats-new.json +9 -9
- package/dist/web/response-viewer-transcript.d.ts +6 -0
- package/dist/web/response-viewer-transcript.d.ts.map +1 -1
- package/dist/web/response-viewer-transcript.js +134 -1
- package/dist/web/response-viewer-transcript.js.map +1 -1
- package/dist/web/routes/mcp-sync-routes.d.ts +4 -4
- package/dist/web/routes/mcp-sync-routes.js +4 -4
- package/dist/web/routes/session-routes.d.ts +12 -2
- package/dist/web/routes/session-routes.d.ts.map +1 -1
- package/dist/web/routes/session-routes.js +45 -15
- package/dist/web/routes/session-routes.js.map +1 -1
- package/dist/web/routes/system-routes.d.ts.map +1 -1
- package/dist/web/routes/system-routes.js +11 -0
- package/dist/web/routes/system-routes.js.map +1 -1
- package/dist/web/schemas.d.ts +13 -0
- package/dist/web/schemas.d.ts.map +1 -1
- package/dist/web/schemas.js +33 -2
- package/dist/web/schemas.js.map +1 -1
- package/dist/web/server.d.ts.map +1 -1
- package/dist/web/server.js +11 -1
- package/dist/web/server.js.map +1 -1
- package/package.json +1 -1
- package/skills/codeman/SKILL.md +3 -2
- package/skills/codeman/reference/endpoints.md +8 -8
- package/skills/codeman/reference/messaging.md +5 -5
- package/skills/codeman/reference/recipes.md +1 -1
- package/skills/codeman/reference/verbs.md +4 -4
- package/dist/web/public/app.f04bb2a5.js.br +0 -0
- package/dist/web/public/app.f04bb2a5.js.gz +0 -0
- package/dist/web/public/constants.12b0c247.js.br +0 -0
- package/dist/web/public/constants.12b0c247.js.gz +0 -0
- package/dist/web/public/i18n.06659676.js +0 -2
- package/dist/web/public/i18n.06659676.js.br +0 -0
- package/dist/web/public/i18n.06659676.js.gz +0 -0
- package/dist/web/public/image-input.fcdcb46c.js.br +0 -0
- package/dist/web/public/image-input.fcdcb46c.js.gz +0 -0
- package/dist/web/public/keyboard-accessory.b42f539b.js.br +0 -0
- package/dist/web/public/keyboard-accessory.b42f539b.js.gz +0 -0
- package/dist/web/public/mobile.2dff1580.css +0 -1
- package/dist/web/public/mobile.2dff1580.css.br +0 -0
- package/dist/web/public/mobile.2dff1580.css.gz +0 -0
- package/dist/web/public/panels-ui.73ec0137.js.br +0 -0
- package/dist/web/public/panels-ui.73ec0137.js.gz +0 -0
- package/dist/web/public/session-ui.d52ff6aa.js.br +0 -0
- package/dist/web/public/session-ui.d52ff6aa.js.gz +0 -0
- package/dist/web/public/settings-ui.3a22bd2a.js.br +0 -0
- package/dist/web/public/settings-ui.3a22bd2a.js.gz +0 -0
- package/dist/web/public/styles.ba6a9b84.css +0 -1
- package/dist/web/public/styles.ba6a9b84.css.br +0 -0
- package/dist/web/public/styles.ba6a9b84.css.gz +0 -0
- package/dist/web/public/terminal-ui.0a7ccc29.js.br +0 -0
- package/dist/web/public/terminal-ui.0a7ccc29.js.gz +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.assign(CodemanApp.prototype,{_onHookIdlePrompt(e){e.acknowledgedReason||(e.sessionId&&this.setPendingHook(e.sessionId,"idle_prompt"),this._notifySession(e.sessionId,"warning","hook-idle","Waiting for Input",e.message||"Claude is idle and waiting for a prompt"))},_onHookPermissionPrompt(e){e.sessionId&&this.setPendingHook(e.sessionId,"permission_prompt");const t=e.tool?`${e.tool}${e.command?": "+e.command:e.file?": "+e.file:""}`:"",n=e.source==="screen"&&e.message?e.message:"";this._notifySession(e.sessionId,"critical","hook-permission","Permission Required",t||n||"Claude needs tool approval to continue")},_onHookElicitationDialog(e){e.sessionId&&this.setPendingHook(e.sessionId,"elicitation_dialog"),this._notifySession(e.sessionId,"critical","hook-elicitation","Question Asked",e.question||"Claude is asking a question and waiting for your answer")},_onHookElicitationComplete(e){e.sessionId&&(this.clearPendingHooks(e.sessionId,"elicitation_dialog"),this.clearPendingHooks(e.sessionId,"permission_prompt"))},_onHookElicitationResponse(e){this._onHookElicitationComplete(e)},_onHookStop(e){e.sessionId&&this.clearPendingHooks(e.sessionId),this._notifySession(e.sessionId,"info","hook-stop","Response Complete",e.reason||"Claude has finished responding")},_onHookAgentWorking(e){e.sessionId&&(this.clearPendingHooks(e.sessionId,"elicitation_dialog"),this.clearPendingHooks(e.sessionId,"permission_prompt"),this.clearPendingHooks(e.sessionId,"idle_prompt"))},_onHookTeammateIdle(e){const t=this.sessions.get(e.sessionId);this._notifySession(e.sessionId,"warning","hook-teammate-idle","Teammate Idle",`A teammate is idle in ${t?.name||e.sessionId}`)},_onHookTaskCompleted(e){const t=this.sessions.get(e.sessionId);this._notifySession(e.sessionId,"info","hook-task-completed","Task Completed",`A team task completed in ${t?.name||e.sessionId}`)},_onTunnelStarted(e){console.log("[Tunnel] Started:",e.url),this._tunnelUrl=e.url,this._dismissTunnelConnecting(),this._updateTunnelUrlDisplay(e.url),this._updateTunnelIndicator(!0),document.getElementById("welcomeOverlay")?.classList.contains("visible")?(this._updateWelcomeTunnelBtn(!0,e.url,!0),this.showToast("Tunnel active","success")):(this._updateWelcomeTunnelBtn(!0,e.url),this.showToast(`Tunnel active: ${e.url}`,"success"),this.showTunnelQR())},_onTunnelStopped(){console.log("[Tunnel] Stopped"),this._tunnelUrl=null,this._dismissTunnelConnecting(),this._updateTunnelUrlDisplay(null),this._updateWelcomeTunnelBtn(!1),this._updateTunnelIndicator(!1),this.closeTunnelPanel(),this.closeTunnelQR()},_onTunnelProgress(e){console.log("[Tunnel] Progress:",e.message);const t=document.getElementById("tunnelConnectingToast");t&&(t.innerHTML=`<span class="tunnel-spinner"></span> ${e.message}`);const n=document.getElementById("welcomeTunnelBtn");n?.classList.contains("connecting")&&(n.innerHTML=`<span class="tunnel-spinner"></span> ${e.message}`)},_onTunnelError(e){console.warn("[Tunnel] Error:",e.message),this._dismissTunnelConnecting(),this.showToast(`Tunnel error: ${e.message}`,"error");const t=document.getElementById("welcomeTunnelBtn");t&&(t.disabled=!1,t.classList.remove("connecting"))},_onTunnelQrRotated(e){if(e.svg){const t=document.getElementById("tunnelQrContainer");t&&(t.innerHTML=e.svg);const n=document.getElementById("welcomeQrInner");n&&(n.innerHTML=e.svg)}else this._refreshTunnelQrFromApi();this._resetQrCountdown()},_onTunnelQrRegenerated(e){if(e.svg){const t=document.getElementById("tunnelQrContainer");t&&(t.innerHTML=e.svg);const n=document.getElementById("welcomeQrInner");n&&(n.innerHTML=e.svg)}else this._refreshTunnelQrFromApi();this._resetQrCountdown()},_onTunnelQrAuthUsed(e){const n=(e.ua||"Unknown device").match(/Chrome|Firefox|Safari|Edge|Mobile/)?.[0]||"Browser";this.showToast(`Device authenticated via QR (${n}, ${e.ip}). Not you?`,"warning",{duration:1e4,action:{label:"Revoke All",onClick:()=>{fetch("/api/auth/revoke",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"}).then(()=>this.showToast("All sessions revoked","success")).catch(()=>this.showToast("Failed to revoke sessions","error"))}}})},registerServiceWorker(){if(!("serviceWorker"in navigator))return;const e=window.CodemanBase?.base||"";navigator.serviceWorker.register(e+"/sw.js",{scope:e+"/"}).then(t=>{this._swRegistration=t,navigator.serviceWorker.addEventListener("message",n=>{if(n.data?.type==="notification-click"){const{sessionId:s,action:o,approvalId:i}=n.data;o?this.handleNotificationAction?.(o,i,s):s&&this.sessions.has(s)&&this.selectSession(s),window.focus()}}),t.pushManager.getSubscription().then(n=>{n&&(this._pushSubscription=n,this._updatePushUI(!0))})}).catch(()=>{})},async subscribeToPush(){if(!this._swRegistration){this.showToast("Service worker not available. HTTPS or localhost required.","error");return}try{const e=await this._apiJson("/api/push/vapid-key");if(!e)throw new Error("Failed to get VAPID key");const t=urlBase64ToUint8Array(e.publicKey),n=await this._swRegistration.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:t}),s=n.toJSON(),o=await this._apiJson("/api/push/subscribe",{method:"POST",body:{endpoint:s.endpoint,keys:s.keys,userAgent:navigator.userAgent,pushPreferences:this._buildPushPreferences()}});if(!o)throw new Error("Failed to register subscription");this._pushSubscription=n,this._pushSubscriptionId=o.id,localStorage.setItem("codeman-push-subscription-id",o.id),this._updatePushUI(!0),this.showToast("Push notifications enabled","success")}catch(e){this.showToast("Push subscription failed: "+(e.message||e),"error")}},async unsubscribeFromPush(){try{this._pushSubscription&&await this._pushSubscription.unsubscribe();const e=this._pushSubscriptionId||localStorage.getItem("codeman-push-subscription-id");e&&await fetch(`/api/push/subscribe/${e}`,{method:"DELETE"}).catch(()=>{}),this._pushSubscription=null,this._pushSubscriptionId=null,localStorage.removeItem("codeman-push-subscription-id"),this._updatePushUI(!1),this.showToast("Push notifications disabled","success")}catch(e){this.showToast("Failed to unsubscribe: "+(e.message||e),"error")}},async togglePushSubscription(){this._pushSubscription?await this.unsubscribeFromPush():await this.subscribeToPush()},async _syncPushPreferences(){const e=this._pushSubscriptionId||localStorage.getItem("codeman-push-subscription-id");if(e)try{await fetch(`/api/push/subscribe/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({pushPreferences:this._buildPushPreferences()})})}catch{}},_buildPushPreferences(){const e={},t={"hook:permission_prompt":"eventPermissionPush","hook:elicitation_dialog":"eventQuestionPush","hook:idle_prompt":"eventIdlePush","hook:stop":"eventStopPush","respawn:blocked":"eventRespawnPush","session:ralphCompletionDetected":"eventRalphPush"};for(const[n,s]of Object.entries(t)){const o=document.getElementById(s);e[n]=o?o.checked:!0}return e["session:error"]=!0,e},_updatePushUI(e){const t=document.getElementById("pushSubscribeBtn"),n=document.getElementById("pushSubscriptionStatus");t&&(t.textContent=e?"Unsubscribe":"Subscribe"),n&&(n.textContent=e?"active":"off",n.classList.remove("granted","denied"),e&&n.classList.add("granted"))},populateTerminalFontWeight(e,t){if(!e)return;const n=t==null?"":String(t).trim();if(n&&!Array.from(e.options).some(s=>s.value===n)){const s=document.createElement("option");s.value=n,s.textContent=`${n} (custom)`,e.appendChild(s)}e.value=n},readTerminalFontWeight(e){return e?.value.trim()||""},async checkWhatsNew(e){if(this._whatsNewChecked)return;this._whatsNewChecked=!0;const t="codeman-whats-new-seen";let n=null;try{n=localStorage.getItem(t)}catch{return}if(n===e)return;const s=()=>{try{localStorage.setItem(t,e)}catch{}};if(!n){s();return}try{const o=await fetch("/whats-new.json",{cache:"no-cache"});if(!o.ok)return;const i=await o.json();if(i?.version!==e||!Array.isArray(i.highlights)||!i.highlights.length)return;const a=i.highlights.slice(0,3).join(" \xB7 "),l=i.highlights.length>3?` (+${i.highlights.length-3} more)`:"";s(),this.showToast(`Codeman updated to v${e}: ${a}${l}`,"info",{duration:2e4,action:{label:"See what's new",onClick:()=>window.open(`https://github.com/Ark0N/Codeman/releases/tag/codeman%40${e}`,"_blank","noopener")}})}catch{}},openAppSettings(){const e=this.loadAppSettingsFromStorage();document.getElementById("appSettingsDisplayName").value=e.displayName||"Codeman",document.getElementById("appSettingsLanguage").value=e.language==="zh-CN"?"zh-CN":"en",document.getElementById("appSettingsClaudeMdPath").value=e.defaultClaudeMdPath||"",document.getElementById("appSettingsDefaultDir").value=e.defaultWorkingDir||"";const t=this.getDefaultSettings();document.getElementById("appSettingsRalphEnabled").checked=e.ralphTrackerEnabled??t.ralphTrackerEnabled??!1,document.getElementById("appSettingsShowFontControls").checked=e.showFontControls??t.showFontControls??!1,document.getElementById("appSettingsShowSystemStats").checked=e.showSystemStats??t.showSystemStats??!0,document.getElementById("appSettingsHeaderStatsStyle").value=this.resolveHeaderStatsStyle(e),document.getElementById("appSettingsShowLifecycleLog").checked=e.showLifecycleLog??t.showLifecycleLog??!1,document.getElementById("appSettingsShowResponseViewer").checked=e.showResponseViewer??t.showResponseViewer??!1,document.getElementById("appSettingsShowFileViewerButton").checked=e.showFileViewerButton??t.showFileViewerButton??!0,document.getElementById("appSettingsShowAttachmentsButton").checked=e.showAttachmentsButton??t.showAttachmentsButton??!1,document.getElementById("appSettingsSkin").value=e.skin??t.skin??"daylight-blue",this._syncEntranceAnimSetting?.(),document.getElementById("appSettingsWebglRenderer").checked=e.webglRendererEnabled??t.webglRendererEnabled??!0;const n=document.getElementById("appSettingsWebglRendererItem");n&&(n.style.display=MobileDetection.getDeviceType()==="desktop"?"":"none"),document.getElementById("appSettingsShowMonitor").checked=e.showMonitor??t.showMonitor??!1,document.getElementById("appSettingsShowProjectInsights").checked=e.showProjectInsights??t.showProjectInsights??!1,document.getElementById("appSettingsShowFileBrowser").checked=e.showFileBrowser??t.showFileBrowser??!1,document.getElementById("appSettingsShowSubagents").checked=e.showSubagents??t.showSubagents??!1,document.getElementById("appSettingsShowUltracodeAgents").checked=e.showUltracodeAgents??t.showUltracodeAgents??!1,document.getElementById("appSettingsApprovalsInbox").checked=e.approvalsInboxEnabled===!0,document.getElementById("appSettingsCustomModelEndpoints").checked=e.customModelEndpointsEnabled===!0,this.applyCustomModelEndpointsVisibility(),document.getElementById("appSettingsCliManagement").checked=e.cliManagementEnabled===!0,this.applyCliManagementVisibility(),this._mcpSyncSavedOn=e.mcpSyncEnabled===!0,document.getElementById("appSettingsMcpSync").checked=this._mcpSyncSavedOn,this.applyMcpSyncVisibility(),this._applyDoctorAdminGate(),this.loadWebhook(),document.getElementById("appSettingsReadMyMind").checked=e.readMyMindEnabled===!0,document.getElementById("appSettingsUltracodeFloatingWindows").checked=e.ultracodeFloatingWindows??t.ultracodeFloatingWindows??!1,document.getElementById("appSettingsShowMultiMonitorButton").checked=e.showMultiMonitorButton??t.showMultiMonitorButton??!1,document.getElementById("appSettingsShowSplitButton").checked=e.showSplitButton??t.showSplitButton??!1,document.getElementById("appSettingsShowTileGridButton").checked=e.showTileGridButton??t.showTileGridButton??!0,document.getElementById("appSettingsShowPlanUsageLimits").checked=this.planUsageChipEnabled(e),document.getElementById("appSettingsShowRedrawButton").checked=e.showRedrawButton??t.showRedrawButton??!1,document.getElementById("appSettingsLineageLines").checked=e.sessionLineageLines??t.sessionLineageLines??!0,document.getElementById("appSettingsAutoNameSessions").checked=e.autoNameSessions===!0,document.getElementById("appSettingsSpawnedTabsFollowParent").checked=e.spawnedTabsFollowParent===!0;const s=document.getElementById("appSettingsLineageLinesItem");s&&(s.style.display=MobileDetection.getDeviceType()==="desktop"?"":"none"),document.getElementById("appSettingsMobileOverview").checked=e.mobileOverviewEnabled??t.mobileOverviewEnabled??!1;const o=document.getElementById("appSettingsMobileOverviewItem");o&&(o.style.display=MobileDetection.getDeviceType()==="mobile"?"":"none"),document.getElementById("appSettingsShowSessionButton").checked=e.showSessionButton??t.showSessionButton??!1,document.getElementById("appSettingsShowAwayDigestButton").checked=e.showAwayDigestButton??t.showAwayDigestButton??!1,document.getElementById("appSettingsShowCronButton").checked=e.showCronButton??t.showCronButton??!1,document.getElementById("appSettingsShowGitStatus").checked=e.showGitStatus??t.showGitStatus??!1,document.getElementById("appSettingsGitStatusTree").checked=e.gitStatusTree??t.gitStatusTree??!0,document.getElementById("appSettingsGitStatusMaxRepos").value=e.gitStatusMaxRepos??t.gitStatusMaxRepos??12,document.getElementById("appSettingsGitStatusTimeout").value=e.gitStatusTimeoutSeconds??t.gitStatusTimeoutSeconds??30;const i=document.getElementById("appSettingsGestureControlItem");i&&(i.style.display=window.__codemanGestureAvailable?"":"none"),document.getElementById("appSettingsGestureControl").checked=e.gestureControlEnabled??t.gestureControlEnabled??!1,document.getElementById("appSettingsSubagentTracking").checked=e.subagentTrackingEnabled??t.subagentTrackingEnabled??!0,document.getElementById("appSettingsSubagentActiveTabOnly").checked=e.subagentActiveTabOnly??t.subagentActiveTabOnly??!0,document.getElementById("appSettingsImageWatcherEnabled").checked=e.imageWatcherEnabled??t.imageWatcherEnabled??!1,document.getElementById("appSettingsTunnelEnabled").checked=e.tunnelEnabled??!1,this.loadTunnelStatus(),document.getElementById("appSettingsLocalEcho").checked=e.localEchoEnabled??MobileDetection.isTouchDevice(),document.getElementById("appSettingsAutoCopySelection").checked=e.autoCopySelection===!0,document.getElementById("appSettingsCopyStripMargin").checked=e.copyStripMargin!==!1,document.getElementById("appSettingsTerminalFont").value=e.terminalFontFamily||"",this.populateTerminalFontWeight(document.getElementById("appSettingsTerminalFontWeight"),e.terminalFontWeight),this.populateTerminalFontWeight(document.getElementById("appSettingsTerminalFontWeightBold"),e.terminalFontWeightBold),document.getElementById("appSettingsTerminalWheelLocal").checked=e.terminalWheelLocalScrollback??t.terminalWheelLocalScrollback??!1,document.getElementById("appSettingsCjkInput").checked=e.cjkInputEnabled??t.cjkInputEnabled??!1,document.getElementById("appSettingsExtendedKeyboardBar").checked=e.extendedKeyboardBar??!1,document.getElementById("appSettingsTabTwoRows").checked=e.tabTwoRows??t.tabTwoRows??!1,document.getElementById("appSettingsShowTabCliLogos").checked=this.tabCliLogosEnabled(e),document.getElementById("appSettingsTabOrientation").value=e.tabOrientation??t.tabOrientation??"horizontal";const a=window.CodemanTabRail?.resolveWidth({width:e.tabRailWidth??this._defaultTabRailWidth?.()??t.tabRailWidth??256})??256;this.syncTabRailWidthSetting?.(a),document.getElementById("appSettingsTabRailDetail").value=e.tabRailDetail??t.tabRailDetail??"rich",document.getElementById("appSettingsTabRailSort").value=e.tabRailSort??t.tabRailSort??"activity",document.getElementById("appSettingsTabArrangement").value=this.resolveTabArrangement(e),document.getElementById("appSettingsTabStateOrder").value=this.resolveTabStateOrder(e),document.getElementById("appSettingsShowTabDetachButton").checked=this.tabDetachButtonEnabled?.(e,t)??e.showTabDetachButton??t.showTabDetachButton??!1,document.getElementById("appSettingsTileDetach").checked=e.tileDetachEnabled===!0;const l=document.getElementById("appSettingsTileDetachItem");l&&(l.style.display=MobileDetection.getDeviceType()==="desktop"?"":"none"),document.getElementById("appSettingsSessionListLayout").value=e.sessionListLayout??t.sessionListLayout??"header";const d=this.resolveSessionSidebarFontSize(e.sessionSidebarFontSize??t.sessionSidebarFontSize);document.getElementById("appSettingsSessionSidebarFontSize").value=String(d),document.getElementById("appSettingsSessionSidebarFontSizeValue").textContent=`${d} px`;const c=document.getElementById("appSettingsClaudeMode"),r=document.getElementById("allowedToolsRow");c.value=e.claudeMode||"dangerously-skip-permissions",document.getElementById("appSettingsAllowedTools").value=e.allowedTools||"",r.style.display=c.value==="allowedTools"?"":"none",c.onchange=()=>{r.style.display=c.value==="allowedTools"?"":"none"},document.getElementById("appSettingsCodexDangerouslyBypassApprovals").checked=e.codexDangerouslyBypassApprovals??!1,document.getElementById("appSettingsCodexAnimations").checked=e.codexAnimationsEnabled??!1,document.getElementById("appSettingsCodexModel").value=e.codexModel??"",document.getElementById("appSettingsCodexReasoningEffort").value=e.codexReasoningEffort??"",this._applyCodexSettingsVisibility(),document.getElementById("appSettingsAgentTeams").checked=e.agentTeamsEnabled??!1,document.getElementById("appSettingsAgentSkill").checked=e.agentSkillEnabled??!1,document.getElementById("appSettingsWorkspaceHooks").checked=e.workspaceHooksEnabled!==!1,document.getElementById("appSettingsClaudeModel").value=e.claudeModel??"",document.getElementById("appSettingsOpusContext1m").checked=e.opusContext1mEnabled??!1,document.getElementById("appSettingsRemoteAutoReconnect").checked=e.remoteAutoReconnect??!0,document.getElementById("appSettingsThinkingEffort").value=e.thinkingEffort??"",document.getElementById("appSettingsClaudeAdvisor").value=e.claudeAdvisorModel??"";const u=e.nice||{};document.getElementById("appSettingsNiceEnabled").checked=u.enabled??!1,document.getElementById("appSettingsNiceValue").value=u.niceValue??10,this.loadModelConfigForSettings();const p=this.notificationManager?.preferences||{};document.getElementById("appSettingsNotifEnabled").checked=p.enabled??!0,document.getElementById("appSettingsNotifBrowser").checked=p.browserNotifications??!1,document.getElementById("appSettingsNotifAudio").checked=p.audioAlerts??!1,document.getElementById("appSettingsNotifStuckMins").value=Math.round((p.stuckThresholdMs||6e5)/6e4),document.getElementById("appSettingsNotifToastSecs").value=Math.round((this.notificationManager?.getToastDurationMs?.()??DEFAULT_TOAST_DURATION_MS)/1e3),document.getElementById("appSettingsNotifBrowserSecs").value=Math.round((p.browserAutoCloseMs??AUTO_CLOSE_NOTIFICATION_MS)/1e3),document.getElementById("appSettingsNotifCritical").checked=!p.muteCritical,document.getElementById("appSettingsNotifWarning").checked=!p.muteWarning,document.getElementById("appSettingsNotifInfo").checked=!p.muteInfo,document.getElementById("appSettingsPushEnabled").checked=!!this._pushSubscription,this._updatePushUI(!!this._pushSubscription);const m=p.eventTypes||{},g=m.permission_prompt||{};document.getElementById("eventPermissionEnabled").checked=g.enabled??!0,document.getElementById("eventPermissionBrowser").checked=g.browser??!0,document.getElementById("eventPermissionPush").checked=g.push??!1,document.getElementById("eventPermissionAudio").checked=g.audio??!0;const f=m.elicitation_dialog||{};document.getElementById("eventQuestionEnabled").checked=f.enabled??!0,document.getElementById("eventQuestionBrowser").checked=f.browser??!0,document.getElementById("eventQuestionPush").checked=f.push??!1,document.getElementById("eventQuestionAudio").checked=f.audio??!0;const h=m.idle_prompt||{};document.getElementById("eventIdleEnabled").checked=h.enabled??!0,document.getElementById("eventIdleBrowser").checked=h.browser??!0,document.getElementById("eventIdlePush").checked=h.push??!1,document.getElementById("eventIdleAudio").checked=h.audio??!1;const y=m.stop||{};document.getElementById("eventStopEnabled").checked=y.enabled??!1,document.getElementById("eventStopBrowser").checked=y.browser??!1,document.getElementById("eventStopPush").checked=y.push??!1,document.getElementById("eventStopAudio").checked=y.audio??!1;const b=m.respawn_cycle||{};document.getElementById("eventRespawnEnabled").checked=b.enabled??!0,document.getElementById("eventRespawnBrowser").checked=b.browser??!1,document.getElementById("eventRespawnPush").checked=b.push??!1,document.getElementById("eventRespawnAudio").checked=b.audio??!1;const S=m.ralph_complete||{};document.getElementById("eventRalphEnabled").checked=S.enabled??!0,document.getElementById("eventRalphBrowser").checked=S.browser??!0,document.getElementById("eventRalphPush").checked=S.push??!1,document.getElementById("eventRalphAudio").checked=S.audio??!0;const E=m.subagent_spawn||{};document.getElementById("eventSubagentEnabled").checked=E.enabled??!1,document.getElementById("eventSubagentBrowser").checked=E.browser??!1,document.getElementById("eventSubagentPush").checked=E.push??!1,document.getElementById("eventSubagentAudio").checked=E.audio??!1;const w=document.getElementById("notifPermissionStatus");if(w&&typeof Notification<"u"){const k=Notification.permission;w.textContent=k==="granted"?"\u2713":k==="denied"?"\u2717":"?",w.classList.remove("granted","denied"),k==="granted"?w.classList.add("granted"):k==="denied"&&w.classList.add("denied")}const v=VoiceInput._getDeepgramConfig();document.getElementById("voiceDeepgramKey").value=v.apiKey||"",document.getElementById("voiceLanguage").value=v.language||"en-US",document.getElementById("voiceKeyterms").value=v.keyterms||DEFAULT_VOICE_KEYTERMS,document.getElementById("voiceInsertMode").value=v.insertMode||"direct",document.getElementById("voiceProvider").value=v.provider||"auto",document.getElementById("appSettingsClaudeVoice").checked=e.claudeVoiceEnabled??!1;const B=document.getElementById("voiceDeepgramKey");B.type="password",document.getElementById("voiceKeyToggleBtn").textContent="Show",this._renderVoiceProviderStatus(),VoiceInput.refreshClaudeStatus().then(()=>this._renderVoiceProviderStatus()),this._initUpdatesSection(),this._initSettingsNav(),this._syncSettingsChips(),this._syncModelCards(),this._syncEffortSegment(),this._syncAdvisorSegment(),this.switchSettingsTab("settings-updates");const I=document.getElementById("appSettingsModal");I.classList.add("active"),this.activeFocusTrap=new FocusTrap(I),this.activeFocusTrap.activate(),this._captureSettingsFormBaseline()},_applyCodexSettingsVisibility(){const e=document.getElementById("appSettingsCodexGroup");e&&(e.style.display=window.__codemanCliAvailable?.codex===!0?"":"none")},switchSettingsTab(e){e==="settings-shortcuts"&&this.renderShortcutSettingsList?.();const t=document.getElementById("appSettingsDoc"),n=document.getElementById(e);if(t&&n&&typeof n.offsetTop=="number"){const s=document.getElementById("appSettingsJump"),o=s&&s.offsetParent?s.offsetHeight+16:6;t.scrollTop=Math.max(0,n.offsetTop-o)}this._setActiveSettingsSection(e)},_setActiveSettingsSection(e){const t=document.getElementById("appSettingsModal");if(!t||typeof t.querySelectorAll!="function")return;let n=null;t.querySelectorAll(".set-rail-item").forEach(a=>{const l=a.dataset.section===e;a.classList.toggle("active",l),l&&(n=a)}),t.querySelectorAll(".set-jump-row").forEach(a=>{a.classList.toggle("active",a.dataset.section===e)});const s=document.getElementById("appSettingsJump")?.querySelector(".set-jump-label");s&&n&&(s.textContent=n.textContent.trim());const o=document.getElementById("appSettingsJump")?.querySelector(".set-jump-ico"),i=n?.querySelector("svg");o&&i&&(o.innerHTML=i.innerHTML)},_initSettingsNav(){const e=document.getElementById("appSettingsModal"),t=document.getElementById("appSettingsDoc");if(!e||!t||typeof e.querySelectorAll!="function"||(this._buildModelCards(),this._buildEffortSegment(),this._buildAdvisorSegment(),this._buildSettingsJumpMenu(),e.dataset.navReady==="1"))return;e.dataset.navReady="1",e.querySelector(".set-rail-items")?.addEventListener("click",i=>{const a=i.target.closest?.(".set-rail-item");a?.dataset.section&&this.switchSettingsTab(a.dataset.section)}),document.getElementById("appSettingsJumpMenu")?.addEventListener("click",i=>{const a=i.target.closest?.(".set-jump-row");a?.dataset.section&&(this._toggleSettingsJump(!1),this.switchSettingsTab(a.dataset.section))}),document.getElementById("appSettingsJump")?.addEventListener("click",()=>this._toggleSettingsJump()),document.getElementById("appSettingsJumpVeil")?.addEventListener("click",()=>this._toggleSettingsJump(!1)),t.addEventListener("scroll",()=>{this._settingsSpyQueued||(this._settingsSpyQueued=!0,requestAnimationFrame(()=>{this._settingsSpyQueued=!1;const i=[...t.querySelectorAll(".set-section")].filter(l=>l.offsetParent!==null);if(!i.length)return;let a=i[0].id;for(const l of i)l.offsetTop-t.scrollTop<=140&&(a=l.id);this._setActiveSettingsSection(a)}))});const n=document.getElementById("appSettingsSearch");n?.addEventListener("input",()=>this._filterSettings(n.value)),e.querySelectorAll(".set-chip input").forEach(i=>{i.addEventListener("change",()=>this._syncSettingsChips())});const s=e.querySelector(".set-group-head-toggle"),o=s?.closest(".set-group-advanced");if(s&&o){const i=()=>{const a=o.classList.toggle("open");s.setAttribute("aria-expanded",a?"true":"false")};s.addEventListener("click",i),s.addEventListener("keydown",a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),i())})}document.getElementById("appSettingsOpusContext1m")?.addEventListener("change",()=>this._applyModelSelection())},_buildSettingsJumpMenu(){const e=document.getElementById("appSettingsModal"),t=document.getElementById("appSettingsJumpMenu");!e||!t||(t.innerHTML="",e.querySelectorAll(".set-rail-item").forEach(n=>{const s=document.createElement("button");s.type="button",s.className="set-jump-row",s.dataset.section=n.dataset.section,s.innerHTML=n.innerHTML;const o=document.getElementById(n.dataset.section),i=o?o.querySelectorAll("input, select").length:0;if(i){const a=document.createElement("span");a.className="set-jump-count",a.textContent=String(i),s.appendChild(a)}t.appendChild(s)}))},_toggleSettingsJump(e){const t=document.getElementById("appSettingsModal");if(!t)return;const n=e===void 0?!t.classList.contains("jump-open"):e;t.classList.toggle("jump-open",n),document.getElementById("appSettingsJump")?.setAttribute("aria-expanded",n?"true":"false")},_syncSettingsChips(){document.querySelectorAll("#appSettingsModal .set-chip, #sessionOptionsModal .set-chip").forEach(e=>{e.classList.toggle("is-on",!!e.querySelector("input")?.checked)}),this._syncLayoutPreview()},_syncLayoutPreview(){const e=document.getElementById("appSettingsModal");if(!e||typeof e.querySelectorAll!="function")return;const t={header:document.getElementById("appSettingsPreviewHeader"),panel:document.getElementById("appSettingsPreviewPanels"),toolbar:document.getElementById("appSettingsPreviewToolbar"),float:document.getElementById("appSettingsPreviewFloats")};if(!t.header)return;Object.values(t).forEach(i=>{i&&(i.innerHTML="")});const n=[...e.querySelectorAll(".set-chip[data-preview]")].filter(i=>i.querySelector("input")?.checked).sort((i,a)=>(Number(i.dataset.previewOrder)||0)-(Number(a.dataset.previewOrder)||0));let s=0;for(const i of n){const a=i.dataset.preview,l=t[a];if(!l)continue;const d=i.querySelectorAll("span"),c=(d[d.length-1]?.textContent||"").trim(),r=document.createElement("span");if(r.title=c,a==="header"){const u=i.dataset.previewText;r.className=u?"set-preview-chip":"set-preview-btn",u?r.textContent=u:this._appendPreviewIcon(r,i)}else{r.className=`set-preview-${a}`,this._appendPreviewIcon(r,i);const u=document.createElement("span");u.textContent=c,r.appendChild(u)}l.appendChild(r),s++}const o=document.getElementById("appSettingsPreviewEmpty");o&&(o.hidden=s>0)},_appendPreviewIcon(e,t){const n=t.querySelector(".set-chip-ico");if(!n)return;const s=n.cloneNode(!0);s.classList.remove("set-chip-ico"),s.classList.add("set-preview-ico"),e.appendChild(s)},_buildModelCards(){const e=document.getElementById("appSettingsClaudeModel"),t=document.getElementById("appSettingsModelCards");!e||!t||t.dataset.built==="1"||!e.options||(t.innerHTML="",[...e.options].filter(n=>n.dataset.variant!=="1m").forEach(n=>{const s=document.createElement("button");s.type="button",s.className="set-modelcard",s.setAttribute("role","radio"),s.dataset.value=n.value,n.dataset.ctx==="1"&&(s.dataset.ctx="1");const o=document.createElement("span");o.className="set-mc-top";const i=document.createElement("span");i.className="set-mc-name",i.textContent=n.textContent,o.appendChild(i);const a=document.createElement("span");a.className="set-mc-dot",o.appendChild(a),s.appendChild(o);const l=document.createElement("span");if(l.className="set-mc-meta",l.textContent=n.dataset.meta||"",s.appendChild(l),n.dataset.ctx==="1"){const d=document.createElement("span");d.className="set-mc-ctx",d.textContent="1M capable",s.appendChild(d)}s.addEventListener("click",()=>{this._settingsModelBase=n.value,this._applyModelSelection()}),t.appendChild(s)}),t.dataset.built="1")},_syncModelCards(){const e=document.getElementById("appSettingsClaudeModel");if(!e)return;const t=e.value||"";if(this._settingsModelBase=t.endsWith("[1m]")?t.slice(0,-4):t,t.endsWith("[1m]")){const n=document.getElementById("appSettingsOpusContext1m");n&&(n.checked=!0)}this._applyModelSelection()},_applyModelSelection(){const e=document.getElementById("appSettingsClaudeModel"),t=document.getElementById("appSettingsModelCards");if(!e||!t)return;const n=this._settingsModelBase||"";let s=!1;t.querySelectorAll(".set-modelcard").forEach(d=>{const c=d.dataset.value===n;d.classList.toggle("selected",c),d.setAttribute("aria-checked",c?"true":"false"),c&&(s=d.dataset.ctx==="1")});const o=!!document.getElementById("appSettingsOpusContext1m")?.checked;e.value=n&&s&&o?`${n}[1m]`:n;const i=document.getElementById("appSettingsContextRow"),a=document.getElementById("appSettingsContextDesc"),l=!!n&&!s;i?.classList.toggle("set-row-disabled",l),a&&(a.textContent=l?"The selected model has no 1M variant.":n?"Available for Fable 5.1, Fable 5, Opus 5.5, Opus and Opus 4.6.":"With no model pinned, this starts new sessions on Opus with a 1M window.")},_buildEffortSegment(){this._buildSelectSegment("appSettingsThinkingEffort","appSettingsEffortSegment")},_syncEffortSegment(){this._syncSelectSegment("appSettingsThinkingEffort","appSettingsEffortSegment")},_buildAdvisorSegment(){this._buildSelectSegment("appSettingsClaudeAdvisor","appSettingsAdvisorSegment")},_syncAdvisorSegment(){this._syncSelectSegment("appSettingsClaudeAdvisor","appSettingsAdvisorSegment")},_buildSelectSegment(e,t){const n=document.getElementById(e),s=document.getElementById(t);!n||!s||s.dataset.built==="1"||!n.options||(s.innerHTML="",[...n.options].forEach(o=>{const i=document.createElement("button");i.type="button",i.setAttribute("role","radio"),i.dataset.value=o.value,i.textContent=o.textContent,i.addEventListener("click",()=>{n.value=o.value,this._syncSelectSegment(e,t)}),s.appendChild(i)}),s.dataset.built="1")},_syncSelectSegment(e,t){const n=document.getElementById(e),s=document.getElementById(t);!n||!s||s.querySelectorAll("button").forEach(o=>{const i=o.dataset.value===(n.value||"");o.classList.toggle("selected",i),o.setAttribute("aria-checked",i?"true":"false")})},_filterSettings(e){const t=document.getElementById("appSettingsDoc");if(!t)return;const n=(e||"").trim().toLowerCase(),s=".set-row, .set-chip, .set-modelgrid, .set-minigrid, .event-type-grid, #appSettingsShortcutsList",o=[...t.querySelectorAll(s)];let i=!1;o.forEach(l=>{if(!n){l.classList.remove("set-hit-hidden");return}const c=`${l.dataset?.search||""} ${l.textContent||""}`.toLowerCase().includes(n);l.classList.toggle("set-hit-hidden",!c),c&&(i=!0)}),t.querySelectorAll(".set-chips").forEach(l=>{const d=[...l.querySelectorAll(".set-chip")].some(c=>!c.classList.contains("set-hit-hidden"));l.classList.toggle("set-hit-hidden",!!n&&!d)}),t.querySelectorAll(".set-group").forEach(l=>{const d=[...l.querySelectorAll(s)].some(c=>!c.classList.contains("set-hit-hidden"));l.classList.toggle("set-hit-hidden",!!n&&!d),n&&d&&l.classList.add("open")}),t.querySelectorAll(".set-section").forEach(l=>{const d=[...l.querySelectorAll(".set-group")].some(c=>!c.classList.contains("set-hit-hidden"));l.classList.toggle("set-hit-hidden",!!n&&!d)}),t.querySelectorAll(".set-preview").forEach(l=>l.classList.toggle("set-hit-hidden",!!n));const a=document.getElementById("appSettingsSearchEmpty");a&&(a.hidden=!n||i),n||t.querySelectorAll(".set-group-advanced").forEach(l=>l.classList.remove("open"))},closeAppSettings(){this._toggleSettingsJump(!1),document.getElementById("appSettingsModal").classList.remove("active"),this.activeFocusTrap&&(this.activeFocusTrap.deactivate(),this.activeFocusTrap=null)},_updatePhaseText(e){return{queued:"Queued\u2026",preparing:"Preparing\u2026",stashing:"Stashing local changes\u2026",fetching:"Fetching release\u2026",checkout:"Checking out release\u2026",installing:"Installing dependencies\u2026",building:"Building\u2026",restarting:"Restarting Codeman\u2026"}[e]||e},_initUpdatesSection(){const e=this.$("updateCurrentVersion");e&&(e.textContent=(this.$("versionDisplay")?.textContent||"").trim()||"\u2014");for(const t of["updateResult","updateActionRow","updateNotes","updateProgress"]){const n=this.$(t);n&&(n.style.display="none")}this._updateCheck=null},keyTesterEvent(e){const t=document.getElementById("keyTesterLog");if(!t)return;const n=["ctrlKey","shiftKey","altKey","metaKey"].filter(i=>e[i]).map(i=>i.replace("Key","")),s=`${e.type.padEnd(8)} key=${JSON.stringify(e.key)} code=${e.code||"-"} mods=${n.join("+")||"none"}`+(e.type==="keypress"?` charCode=${e.charCode}`:"")+(e.repeat?" (repeat)":""),o=(t.textContent?t.textContent.split(`
|
|
1
|
+
"use strict";Object.assign(CodemanApp.prototype,{_onHookIdlePrompt(e){e.acknowledgedReason||(e.sessionId&&this.setPendingHook(e.sessionId,"idle_prompt"),this._notifySession(e.sessionId,"warning","hook-idle","Waiting for Input",e.message||"Claude is idle and waiting for a prompt"))},_onHookPermissionPrompt(e){e.sessionId&&this.setPendingHook(e.sessionId,"permission_prompt");const t=e.tool?`${e.tool}${e.command?": "+e.command:e.file?": "+e.file:""}`:"",n=e.source==="screen"&&e.message?e.message:"";this._notifySession(e.sessionId,"critical","hook-permission","Permission Required",t||n||"Claude needs tool approval to continue")},_onHookElicitationDialog(e){e.sessionId&&this.setPendingHook(e.sessionId,"elicitation_dialog"),this._notifySession(e.sessionId,"critical","hook-elicitation","Question Asked",e.question||"Claude is asking a question and waiting for your answer")},_onHookElicitationComplete(e){e.sessionId&&(this.clearPendingHooks(e.sessionId,"elicitation_dialog"),this.clearPendingHooks(e.sessionId,"permission_prompt"))},_onHookElicitationResponse(e){this._onHookElicitationComplete(e)},_onHookStop(e){e.sessionId&&this.clearPendingHooks(e.sessionId),this._notifySession(e.sessionId,"info","hook-stop","Response Complete",e.reason||"Claude has finished responding")},_onHookAgentWorking(e){e.sessionId&&(this.clearPendingHooks(e.sessionId,"elicitation_dialog"),this.clearPendingHooks(e.sessionId,"permission_prompt"),this.clearPendingHooks(e.sessionId,"idle_prompt"))},_onHookTeammateIdle(e){const t=this.sessions.get(e.sessionId);this._notifySession(e.sessionId,"warning","hook-teammate-idle","Teammate Idle",`A teammate is idle in ${t?.name||e.sessionId}`)},_onHookTaskCompleted(e){const t=this.sessions.get(e.sessionId);this._notifySession(e.sessionId,"info","hook-task-completed","Task Completed",`A team task completed in ${t?.name||e.sessionId}`)},_onTunnelStarted(e){console.log("[Tunnel] Started:",e.url),this._tunnelUrl=e.url,this._dismissTunnelConnecting(),this._updateTunnelUrlDisplay(e.url),this._updateTunnelIndicator(!0),document.getElementById("welcomeOverlay")?.classList.contains("visible")?(this._updateWelcomeTunnelBtn(!0,e.url,!0),this.showToast("Tunnel active","success")):(this._updateWelcomeTunnelBtn(!0,e.url),this.showToast(`Tunnel active: ${e.url}`,"success"),this.showTunnelQR())},_onTunnelStopped(){console.log("[Tunnel] Stopped"),this._tunnelUrl=null,this._dismissTunnelConnecting(),this._updateTunnelUrlDisplay(null),this._updateWelcomeTunnelBtn(!1),this._updateTunnelIndicator(!1),this.closeTunnelPanel(),this.closeTunnelQR()},_onTunnelProgress(e){console.log("[Tunnel] Progress:",e.message);const t=document.getElementById("tunnelConnectingToast");t&&(t.innerHTML=`<span class="tunnel-spinner"></span> ${e.message}`);const n=document.getElementById("welcomeTunnelBtn");n?.classList.contains("connecting")&&(n.innerHTML=`<span class="tunnel-spinner"></span> ${e.message}`)},_onTunnelError(e){console.warn("[Tunnel] Error:",e.message),this._dismissTunnelConnecting(),this.showToast(`Tunnel error: ${e.message}`,"error");const t=document.getElementById("welcomeTunnelBtn");t&&(t.disabled=!1,t.classList.remove("connecting"))},_onTunnelQrRotated(e){if(e.svg){const t=document.getElementById("tunnelQrContainer");t&&(t.innerHTML=e.svg);const n=document.getElementById("welcomeQrInner");n&&(n.innerHTML=e.svg)}else this._refreshTunnelQrFromApi();this._resetQrCountdown()},_onTunnelQrRegenerated(e){if(e.svg){const t=document.getElementById("tunnelQrContainer");t&&(t.innerHTML=e.svg);const n=document.getElementById("welcomeQrInner");n&&(n.innerHTML=e.svg)}else this._refreshTunnelQrFromApi();this._resetQrCountdown()},_onTunnelQrAuthUsed(e){const n=(e.ua||"Unknown device").match(/Chrome|Firefox|Safari|Edge|Mobile/)?.[0]||"Browser";this.showToast(`Device authenticated via QR (${n}, ${e.ip}). Not you?`,"warning",{duration:1e4,action:{label:"Revoke All",onClick:()=>{fetch("/api/auth/revoke",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"}).then(()=>this.showToast("All sessions revoked","success")).catch(()=>this.showToast("Failed to revoke sessions","error"))}}})},registerServiceWorker(){if(!("serviceWorker"in navigator))return;const e=window.CodemanBase?.base||"";navigator.serviceWorker.register(e+"/sw.js",{scope:e+"/"}).then(t=>{this._swRegistration=t,navigator.serviceWorker.addEventListener("message",n=>{if(n.data?.type==="notification-click"){const{sessionId:s,action:o,approvalId:i}=n.data;o?this.handleNotificationAction?.(o,i,s):s&&this.sessions.has(s)&&this.selectSession(s),window.focus()}}),t.pushManager.getSubscription().then(n=>{n&&(this._pushSubscription=n,this._updatePushUI(!0))})}).catch(()=>{})},async subscribeToPush(){if(!this._swRegistration){this.showToast("Service worker not available. HTTPS or localhost required.","error");return}try{const e=await this._apiJson("/api/push/vapid-key");if(!e)throw new Error("Failed to get VAPID key");const t=urlBase64ToUint8Array(e.publicKey),n=await this._swRegistration.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:t}),s=n.toJSON(),o=await this._apiJson("/api/push/subscribe",{method:"POST",body:{endpoint:s.endpoint,keys:s.keys,userAgent:navigator.userAgent,pushPreferences:this._buildPushPreferences()}});if(!o)throw new Error("Failed to register subscription");this._pushSubscription=n,this._pushSubscriptionId=o.id,localStorage.setItem("codeman-push-subscription-id",o.id),this._updatePushUI(!0),this.showToast("Push notifications enabled","success")}catch(e){this.showToast("Push subscription failed: "+(e.message||e),"error")}},async unsubscribeFromPush(){try{this._pushSubscription&&await this._pushSubscription.unsubscribe();const e=this._pushSubscriptionId||localStorage.getItem("codeman-push-subscription-id");e&&await fetch(`/api/push/subscribe/${e}`,{method:"DELETE"}).catch(()=>{}),this._pushSubscription=null,this._pushSubscriptionId=null,localStorage.removeItem("codeman-push-subscription-id"),this._updatePushUI(!1),this.showToast("Push notifications disabled","success")}catch(e){this.showToast("Failed to unsubscribe: "+(e.message||e),"error")}},async togglePushSubscription(){this._pushSubscription?await this.unsubscribeFromPush():await this.subscribeToPush()},async _syncPushPreferences(){const e=this._pushSubscriptionId||localStorage.getItem("codeman-push-subscription-id");if(e)try{await fetch(`/api/push/subscribe/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({pushPreferences:this._buildPushPreferences()})})}catch{}},_buildPushPreferences(){const e={},t={"hook:permission_prompt":"eventPermissionPush","hook:elicitation_dialog":"eventQuestionPush","hook:idle_prompt":"eventIdlePush","hook:stop":"eventStopPush","respawn:blocked":"eventRespawnPush","session:ralphCompletionDetected":"eventRalphPush"};for(const[n,s]of Object.entries(t)){const o=document.getElementById(s);e[n]=o?o.checked:!0}return e["session:error"]=!0,e},_updatePushUI(e){const t=document.getElementById("pushSubscribeBtn"),n=document.getElementById("pushSubscriptionStatus");t&&(t.textContent=e?"Unsubscribe":"Subscribe"),n&&(n.textContent=e?"active":"off",n.classList.remove("granted","denied"),e&&n.classList.add("granted"))},populateTerminalFontWeight(e,t){if(!e)return;const n=t==null?"":String(t).trim();if(n&&!Array.from(e.options).some(s=>s.value===n)){const s=document.createElement("option");s.value=n,s.textContent=`${n} (custom)`,e.appendChild(s)}e.value=n},readTerminalFontWeight(e){return e?.value.trim()||""},async checkWhatsNew(e){if(this._whatsNewChecked)return;this._whatsNewChecked=!0;const t="codeman-whats-new-seen";let n=null;try{n=localStorage.getItem(t)}catch{return}const s=()=>{try{localStorage.setItem(t,e)}catch{}},[o,i]=await Promise.all([n&&n!==e?this._fetchWhatsNewNotes():null,this._loadSecurityNotices()]);if(this.isSoloWindow&&i.length)return;const a=window.CodemanSecurityNotices.plan({seenVersion:n,runningVersion:e,notes:o,notices:i});if(a.recordVersion&&s(),a.update){const l=o.highlights.slice(0,3).join(" \xB7 "),d=o.highlights.length>3?` (+${o.highlights.length-3} more)`:"",c=`Codeman updated to v${e}: ${l}${d}`,r=`https://github.com/Ark0N/Codeman/releases/tag/codeman%40${e}`;a.updateNotices.length?this.showUpdateNotice({text:c,releaseUrl:r,notices:a.updateNotices,onNoticeSeen:u=>this._rememberSecurityNotice(u)}):this.showToast(c,"info",{duration:2e4,action:{label:"See what's new",onClick:()=>window.open(r,"_blank","noopener")}})}for(const l of a.cards)this.showSecurityNotice(l,{onClose:()=>this._rememberSecurityNotice(l.id)})},async _fetchWhatsNewNotes(){try{const e=await fetch("/whats-new.json",{cache:"no-cache"});return e.ok?await e.json():null}catch{return null}},async _loadSecurityNotices(){let e;try{e=this._readSecurityNoticesSeen()}catch{return[]}try{const t=await fetch(CodemanBase.url("/security-notices.json"),{cache:"no-cache"});if(!t.ok)return[];const n=await t.json(),s=Array.isArray(n?.notices)?n.notices:[],o=this.isSoloWindow?Object.fromEntries(s.filter(i=>typeof i?.cli=="string").map(i=>[i.cli,!0])):window.__codemanCliAvailable;return window.CodemanSecurityNotices.select(n?.notices,{available:o,seen:e,now:Date.now(),lang:window.CodemanI18n?.language||window.__codemanLanguage})}catch{return[]}},_readSecurityNoticesSeen(){const e=localStorage.getItem("codeman-security-notices-seen");let t=[];try{t=e?JSON.parse(e):[]}catch{}return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]},_rememberSecurityNotice(e){try{const t=this._readSecurityNoticesSeen();t.includes(e)||t.push(e),localStorage.setItem("codeman-security-notices-seen",JSON.stringify(t))}catch{}},openAppSettings(){const e=this.loadAppSettingsFromStorage();document.getElementById("appSettingsDisplayName").value=e.displayName||"Codeman",document.getElementById("appSettingsLanguage").value=e.language==="zh-CN"?"zh-CN":"en",document.getElementById("appSettingsClaudeMdPath").value=e.defaultClaudeMdPath||"",document.getElementById("appSettingsDefaultDir").value=e.defaultWorkingDir||"";const t=this.getDefaultSettings();document.getElementById("appSettingsRalphEnabled").checked=e.ralphTrackerEnabled??t.ralphTrackerEnabled??!1,document.getElementById("appSettingsShowFontControls").checked=e.showFontControls??t.showFontControls??!1,document.getElementById("appSettingsShowSystemStats").checked=e.showSystemStats??t.showSystemStats??!0,document.getElementById("appSettingsHeaderStatsStyle").value=this.resolveHeaderStatsStyle(e),document.getElementById("appSettingsShowLifecycleLog").checked=e.showLifecycleLog??t.showLifecycleLog??!1,document.getElementById("appSettingsShowResponseViewer").checked=e.showResponseViewer??t.showResponseViewer??!1,document.getElementById("appSettingsShowFileViewerButton").checked=e.showFileViewerButton??t.showFileViewerButton??!0,document.getElementById("appSettingsShowAttachmentsButton").checked=e.showAttachmentsButton??t.showAttachmentsButton??!1,document.getElementById("appSettingsSkin").value=e.skin??t.skin??"daylight-blue",this._syncEntranceAnimSetting?.(),document.getElementById("appSettingsWebglRenderer").checked=e.webglRendererEnabled??t.webglRendererEnabled??!0;const n=document.getElementById("appSettingsWebglRendererItem");n&&(n.style.display=MobileDetection.getDeviceType()==="desktop"?"":"none"),document.getElementById("appSettingsShowMonitor").checked=e.showMonitor??t.showMonitor??!1,document.getElementById("appSettingsShowProjectInsights").checked=e.showProjectInsights??t.showProjectInsights??!1,document.getElementById("appSettingsShowFileBrowser").checked=e.showFileBrowser??t.showFileBrowser??!1,document.getElementById("appSettingsShowSubagents").checked=e.showSubagents??t.showSubagents??!1,document.getElementById("appSettingsShowUltracodeAgents").checked=e.showUltracodeAgents??t.showUltracodeAgents??!1,document.getElementById("appSettingsApprovalsInbox").checked=e.approvalsInboxEnabled===!0,document.getElementById("appSettingsCustomModelEndpoints").checked=e.customModelEndpointsEnabled===!0,this.applyCustomModelEndpointsVisibility(),document.getElementById("appSettingsCliManagement").checked=e.cliManagementEnabled===!0,this.applyCliManagementVisibility(),this._mcpSyncSavedOn=e.mcpSyncEnabled===!0,document.getElementById("appSettingsMcpSync").checked=this._mcpSyncSavedOn,this.applyMcpSyncVisibility(),this._applyDoctorAdminGate(),this.loadWebhook(),document.getElementById("appSettingsReadMyMind").checked=e.readMyMindEnabled===!0,document.getElementById("appSettingsUltracodeFloatingWindows").checked=e.ultracodeFloatingWindows??t.ultracodeFloatingWindows??!1,document.getElementById("appSettingsShowMultiMonitorButton").checked=e.showMultiMonitorButton??t.showMultiMonitorButton??!1,document.getElementById("appSettingsShowSplitButton").checked=e.showSplitButton??t.showSplitButton??!1,document.getElementById("appSettingsShowTileGridButton").checked=e.showTileGridButton??t.showTileGridButton??!0,document.getElementById("appSettingsShowPlanUsageLimits").checked=this.planUsageChipEnabled(e),document.getElementById("appSettingsShowRedrawButton").checked=e.showRedrawButton??t.showRedrawButton??!1,document.getElementById("appSettingsLineageLines").checked=e.sessionLineageLines??t.sessionLineageLines??!0,document.getElementById("appSettingsAutoNameSessions").checked=e.autoNameSessions===!0,document.getElementById("appSettingsSpawnedTabsFollowParent").checked=e.spawnedTabsFollowParent===!0;const s=document.getElementById("appSettingsLineageLinesItem");s&&(s.style.display=MobileDetection.getDeviceType()==="desktop"?"":"none"),document.getElementById("appSettingsMobileOverview").checked=e.mobileOverviewEnabled??t.mobileOverviewEnabled??!1;const o=document.getElementById("appSettingsMobileOverviewItem");o&&(o.style.display=MobileDetection.getDeviceType()==="mobile"?"":"none"),document.getElementById("appSettingsShowSessionButton").checked=e.showSessionButton??t.showSessionButton??!1,document.getElementById("appSettingsShowAwayDigestButton").checked=e.showAwayDigestButton??t.showAwayDigestButton??!1,document.getElementById("appSettingsShowCronButton").checked=e.showCronButton??t.showCronButton??!1,document.getElementById("appSettingsShowGitStatus").checked=e.showGitStatus??t.showGitStatus??!1,document.getElementById("appSettingsGitStatusTree").checked=e.gitStatusTree??t.gitStatusTree??!0,document.getElementById("appSettingsGitStatusMaxRepos").value=e.gitStatusMaxRepos??t.gitStatusMaxRepos??12,document.getElementById("appSettingsGitStatusTimeout").value=e.gitStatusTimeoutSeconds??t.gitStatusTimeoutSeconds??30;const i=document.getElementById("appSettingsGestureControlItem");i&&(i.style.display=window.__codemanGestureAvailable?"":"none"),document.getElementById("appSettingsGestureControl").checked=e.gestureControlEnabled??t.gestureControlEnabled??!1,document.getElementById("appSettingsSubagentTracking").checked=e.subagentTrackingEnabled??t.subagentTrackingEnabled??!0,document.getElementById("appSettingsSubagentActiveTabOnly").checked=e.subagentActiveTabOnly??t.subagentActiveTabOnly??!0,document.getElementById("appSettingsImageWatcherEnabled").checked=e.imageWatcherEnabled??t.imageWatcherEnabled??!1,document.getElementById("appSettingsTunnelEnabled").checked=e.tunnelEnabled??!1,this.loadTunnelStatus(),document.getElementById("appSettingsLocalEcho").checked=e.localEchoEnabled??MobileDetection.isTouchDevice(),document.getElementById("appSettingsAutoCopySelection").checked=e.autoCopySelection===!0,document.getElementById("appSettingsCopyStripMargin").checked=e.copyStripMargin!==!1,document.getElementById("appSettingsTerminalFont").value=e.terminalFontFamily||"",this.populateTerminalFontWeight(document.getElementById("appSettingsTerminalFontWeight"),e.terminalFontWeight),this.populateTerminalFontWeight(document.getElementById("appSettingsTerminalFontWeightBold"),e.terminalFontWeightBold),document.getElementById("appSettingsTerminalWheelLocal").checked=e.terminalWheelLocalScrollback??t.terminalWheelLocalScrollback??!1,document.getElementById("appSettingsCjkInput").checked=e.cjkInputEnabled??t.cjkInputEnabled??!1,document.getElementById("appSettingsExtendedKeyboardBar").checked=e.extendedKeyboardBar??!1,document.getElementById("appSettingsTabTwoRows").checked=e.tabTwoRows??t.tabTwoRows??!1,document.getElementById("appSettingsShowTabCliLogos").checked=this.tabCliLogosEnabled(e),document.getElementById("appSettingsTabOrientation").value=e.tabOrientation??t.tabOrientation??"horizontal";const a=window.CodemanTabRail?.resolveWidth({width:e.tabRailWidth??this._defaultTabRailWidth?.()??t.tabRailWidth??256})??256;this.syncTabRailWidthSetting?.(a),document.getElementById("appSettingsTabRailDetail").value=e.tabRailDetail??t.tabRailDetail??"rich",document.getElementById("appSettingsTabRailSort").value=e.tabRailSort??t.tabRailSort??"activity",document.getElementById("appSettingsTabArrangement").value=this.resolveTabArrangement(e),document.getElementById("appSettingsTabStateOrder").value=this.resolveTabStateOrder(e),document.getElementById("appSettingsShowTabDetachButton").checked=this.tabDetachButtonEnabled?.(e,t)??e.showTabDetachButton??t.showTabDetachButton??!1,document.getElementById("appSettingsTileDetach").checked=e.tileDetachEnabled===!0;const l=document.getElementById("appSettingsTileDetachItem");l&&(l.style.display=MobileDetection.getDeviceType()==="desktop"?"":"none"),document.getElementById("appSettingsSessionListLayout").value=e.sessionListLayout??t.sessionListLayout??"header";const d=this.resolveSessionSidebarFontSize(e.sessionSidebarFontSize??t.sessionSidebarFontSize);document.getElementById("appSettingsSessionSidebarFontSize").value=String(d),document.getElementById("appSettingsSessionSidebarFontSizeValue").textContent=`${d} px`;const c=document.getElementById("appSettingsClaudeMode"),r=document.getElementById("allowedToolsRow");c.value=e.claudeMode||"dangerously-skip-permissions",document.getElementById("appSettingsAllowedTools").value=e.allowedTools||"",r.style.display=c.value==="allowedTools"?"":"none",c.onchange=()=>{r.style.display=c.value==="allowedTools"?"":"none"},document.getElementById("appSettingsCodexDangerouslyBypassApprovals").checked=e.codexDangerouslyBypassApprovals??!1,document.getElementById("appSettingsCodexAnimations").checked=e.codexAnimationsEnabled??!1,document.getElementById("appSettingsCodexModel").value=e.codexModel??"",document.getElementById("appSettingsCodexReasoningEffort").value=e.codexReasoningEffort??"",this._applyCodexSettingsVisibility(),document.getElementById("appSettingsAgentTeams").checked=e.agentTeamsEnabled??!1,document.getElementById("appSettingsAgentSkill").checked=e.agentSkillEnabled??!1,document.getElementById("appSettingsWorkspaceHooks").checked=e.workspaceHooksEnabled!==!1,document.getElementById("appSettingsPinCliSessionName").checked=e.pinCliSessionName===!0,document.getElementById("appSettingsClaudeModel").value=e.claudeModel??"",document.getElementById("appSettingsOpusContext1m").checked=e.opusContext1mEnabled??!1,document.getElementById("appSettingsRemoteAutoReconnect").checked=e.remoteAutoReconnect??!0,document.getElementById("appSettingsThinkingEffort").value=e.thinkingEffort??"",document.getElementById("appSettingsClaudeAdvisor").value=e.claudeAdvisorModel??"";const u=e.nice||{};document.getElementById("appSettingsNiceEnabled").checked=u.enabled??!1,document.getElementById("appSettingsNiceValue").value=u.niceValue??10,this.loadModelConfigForSettings();const p=this.notificationManager?.preferences||{};document.getElementById("appSettingsNotifEnabled").checked=p.enabled??!0,document.getElementById("appSettingsNotifBrowser").checked=p.browserNotifications??!1,document.getElementById("appSettingsNotifAudio").checked=p.audioAlerts??!1,document.getElementById("appSettingsNotifStuckMins").value=Math.round((p.stuckThresholdMs||6e5)/6e4),document.getElementById("appSettingsNotifToastSecs").value=Math.round((this.notificationManager?.getToastDurationMs?.()??DEFAULT_TOAST_DURATION_MS)/1e3),document.getElementById("appSettingsNotifBrowserSecs").value=Math.round((p.browserAutoCloseMs??AUTO_CLOSE_NOTIFICATION_MS)/1e3),document.getElementById("appSettingsNotifCritical").checked=!p.muteCritical,document.getElementById("appSettingsNotifWarning").checked=!p.muteWarning,document.getElementById("appSettingsNotifInfo").checked=!p.muteInfo,document.getElementById("appSettingsPushEnabled").checked=!!this._pushSubscription,this._updatePushUI(!!this._pushSubscription);const m=p.eventTypes||{},g=m.permission_prompt||{};document.getElementById("eventPermissionEnabled").checked=g.enabled??!0,document.getElementById("eventPermissionBrowser").checked=g.browser??!0,document.getElementById("eventPermissionPush").checked=g.push??!1,document.getElementById("eventPermissionAudio").checked=g.audio??!0;const f=m.elicitation_dialog||{};document.getElementById("eventQuestionEnabled").checked=f.enabled??!0,document.getElementById("eventQuestionBrowser").checked=f.browser??!0,document.getElementById("eventQuestionPush").checked=f.push??!1,document.getElementById("eventQuestionAudio").checked=f.audio??!0;const h=m.idle_prompt||{};document.getElementById("eventIdleEnabled").checked=h.enabled??!0,document.getElementById("eventIdleBrowser").checked=h.browser??!0,document.getElementById("eventIdlePush").checked=h.push??!1,document.getElementById("eventIdleAudio").checked=h.audio??!1;const y=m.stop||{};document.getElementById("eventStopEnabled").checked=y.enabled??!1,document.getElementById("eventStopBrowser").checked=y.browser??!1,document.getElementById("eventStopPush").checked=y.push??!1,document.getElementById("eventStopAudio").checked=y.audio??!1;const b=m.respawn_cycle||{};document.getElementById("eventRespawnEnabled").checked=b.enabled??!0,document.getElementById("eventRespawnBrowser").checked=b.browser??!1,document.getElementById("eventRespawnPush").checked=b.push??!1,document.getElementById("eventRespawnAudio").checked=b.audio??!1;const S=m.ralph_complete||{};document.getElementById("eventRalphEnabled").checked=S.enabled??!0,document.getElementById("eventRalphBrowser").checked=S.browser??!0,document.getElementById("eventRalphPush").checked=S.push??!1,document.getElementById("eventRalphAudio").checked=S.audio??!0;const E=m.subagent_spawn||{};document.getElementById("eventSubagentEnabled").checked=E.enabled??!1,document.getElementById("eventSubagentBrowser").checked=E.browser??!1,document.getElementById("eventSubagentPush").checked=E.push??!1,document.getElementById("eventSubagentAudio").checked=E.audio??!1;const w=document.getElementById("notifPermissionStatus");if(w&&typeof Notification<"u"){const k=Notification.permission;w.textContent=k==="granted"?"\u2713":k==="denied"?"\u2717":"?",w.classList.remove("granted","denied"),k==="granted"?w.classList.add("granted"):k==="denied"&&w.classList.add("denied")}const v=VoiceInput._getDeepgramConfig();document.getElementById("voiceDeepgramKey").value=v.apiKey||"",document.getElementById("voiceLanguage").value=v.language||"en-US",document.getElementById("voiceKeyterms").value=v.keyterms||DEFAULT_VOICE_KEYTERMS,document.getElementById("voiceInsertMode").value=v.insertMode||"direct",document.getElementById("voiceProvider").value=v.provider||"auto",document.getElementById("appSettingsClaudeVoice").checked=e.claudeVoiceEnabled??!1;const B=document.getElementById("voiceDeepgramKey");B.type="password",document.getElementById("voiceKeyToggleBtn").textContent="Show",this._renderVoiceProviderStatus(),VoiceInput.refreshClaudeStatus().then(()=>this._renderVoiceProviderStatus()),this._initUpdatesSection(),this._initSettingsNav(),this._syncSettingsChips(),this._syncModelCards(),this._syncEffortSegment(),this._syncAdvisorSegment(),this.switchSettingsTab("settings-updates");const I=document.getElementById("appSettingsModal");I.classList.add("active"),this.activeFocusTrap=new FocusTrap(I),this.activeFocusTrap.activate(),this._captureSettingsFormBaseline()},_applyCodexSettingsVisibility(){const e=document.getElementById("appSettingsCodexGroup");e&&(e.style.display=window.__codemanCliAvailable?.codex===!0?"":"none")},switchSettingsTab(e){e==="settings-shortcuts"&&this.renderShortcutSettingsList?.();const t=document.getElementById("appSettingsDoc"),n=document.getElementById(e);if(t&&n&&typeof n.offsetTop=="number"){const s=document.getElementById("appSettingsJump"),o=s&&s.offsetParent?s.offsetHeight+16:6;t.scrollTop=Math.max(0,n.offsetTop-o)}this._setActiveSettingsSection(e)},_setActiveSettingsSection(e){const t=document.getElementById("appSettingsModal");if(!t||typeof t.querySelectorAll!="function")return;let n=null;t.querySelectorAll(".set-rail-item").forEach(a=>{const l=a.dataset.section===e;a.classList.toggle("active",l),l&&(n=a)}),t.querySelectorAll(".set-jump-row").forEach(a=>{a.classList.toggle("active",a.dataset.section===e)});const s=document.getElementById("appSettingsJump")?.querySelector(".set-jump-label");s&&n&&(s.textContent=n.textContent.trim());const o=document.getElementById("appSettingsJump")?.querySelector(".set-jump-ico"),i=n?.querySelector("svg");o&&i&&(o.innerHTML=i.innerHTML)},_initSettingsNav(){const e=document.getElementById("appSettingsModal"),t=document.getElementById("appSettingsDoc");if(!e||!t||typeof e.querySelectorAll!="function"||(this._buildModelCards(),this._buildEffortSegment(),this._buildAdvisorSegment(),this._buildSettingsJumpMenu(),e.dataset.navReady==="1"))return;e.dataset.navReady="1",e.querySelector(".set-rail-items")?.addEventListener("click",i=>{const a=i.target.closest?.(".set-rail-item");a?.dataset.section&&this.switchSettingsTab(a.dataset.section)}),document.getElementById("appSettingsJumpMenu")?.addEventListener("click",i=>{const a=i.target.closest?.(".set-jump-row");a?.dataset.section&&(this._toggleSettingsJump(!1),this.switchSettingsTab(a.dataset.section))}),document.getElementById("appSettingsJump")?.addEventListener("click",()=>this._toggleSettingsJump()),document.getElementById("appSettingsJumpVeil")?.addEventListener("click",()=>this._toggleSettingsJump(!1)),t.addEventListener("scroll",()=>{this._settingsSpyQueued||(this._settingsSpyQueued=!0,requestAnimationFrame(()=>{this._settingsSpyQueued=!1;const i=[...t.querySelectorAll(".set-section")].filter(l=>l.offsetParent!==null);if(!i.length)return;let a=i[0].id;for(const l of i)l.offsetTop-t.scrollTop<=140&&(a=l.id);this._setActiveSettingsSection(a)}))});const n=document.getElementById("appSettingsSearch");n?.addEventListener("input",()=>this._filterSettings(n.value)),e.querySelectorAll(".set-chip input").forEach(i=>{i.addEventListener("change",()=>this._syncSettingsChips())});const s=e.querySelector(".set-group-head-toggle"),o=s?.closest(".set-group-advanced");if(s&&o){const i=()=>{const a=o.classList.toggle("open");s.setAttribute("aria-expanded",a?"true":"false")};s.addEventListener("click",i),s.addEventListener("keydown",a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),i())})}document.getElementById("appSettingsOpusContext1m")?.addEventListener("change",()=>this._applyModelSelection())},_buildSettingsJumpMenu(){const e=document.getElementById("appSettingsModal"),t=document.getElementById("appSettingsJumpMenu");!e||!t||(t.innerHTML="",e.querySelectorAll(".set-rail-item").forEach(n=>{const s=document.createElement("button");s.type="button",s.className="set-jump-row",s.dataset.section=n.dataset.section,s.innerHTML=n.innerHTML;const o=document.getElementById(n.dataset.section),i=o?o.querySelectorAll("input, select").length:0;if(i){const a=document.createElement("span");a.className="set-jump-count",a.textContent=String(i),s.appendChild(a)}t.appendChild(s)}))},_toggleSettingsJump(e){const t=document.getElementById("appSettingsModal");if(!t)return;const n=e===void 0?!t.classList.contains("jump-open"):e;t.classList.toggle("jump-open",n),document.getElementById("appSettingsJump")?.setAttribute("aria-expanded",n?"true":"false")},_syncSettingsChips(){document.querySelectorAll("#appSettingsModal .set-chip, #sessionOptionsModal .set-chip").forEach(e=>{e.classList.toggle("is-on",!!e.querySelector("input")?.checked)}),this._syncLayoutPreview()},_syncLayoutPreview(){const e=document.getElementById("appSettingsModal");if(!e||typeof e.querySelectorAll!="function")return;const t={header:document.getElementById("appSettingsPreviewHeader"),panel:document.getElementById("appSettingsPreviewPanels"),toolbar:document.getElementById("appSettingsPreviewToolbar"),float:document.getElementById("appSettingsPreviewFloats")};if(!t.header)return;Object.values(t).forEach(i=>{i&&(i.innerHTML="")});const n=[...e.querySelectorAll(".set-chip[data-preview]")].filter(i=>i.querySelector("input")?.checked).sort((i,a)=>(Number(i.dataset.previewOrder)||0)-(Number(a.dataset.previewOrder)||0));let s=0;for(const i of n){const a=i.dataset.preview,l=t[a];if(!l)continue;const d=i.querySelectorAll("span"),c=(d[d.length-1]?.textContent||"").trim(),r=document.createElement("span");if(r.title=c,a==="header"){const u=i.dataset.previewText;r.className=u?"set-preview-chip":"set-preview-btn",u?r.textContent=u:this._appendPreviewIcon(r,i)}else{r.className=`set-preview-${a}`,this._appendPreviewIcon(r,i);const u=document.createElement("span");u.textContent=c,r.appendChild(u)}l.appendChild(r),s++}const o=document.getElementById("appSettingsPreviewEmpty");o&&(o.hidden=s>0)},_appendPreviewIcon(e,t){const n=t.querySelector(".set-chip-ico");if(!n)return;const s=n.cloneNode(!0);s.classList.remove("set-chip-ico"),s.classList.add("set-preview-ico"),e.appendChild(s)},_buildModelCards(){const e=document.getElementById("appSettingsClaudeModel"),t=document.getElementById("appSettingsModelCards");!e||!t||t.dataset.built==="1"||!e.options||(t.innerHTML="",[...e.options].filter(n=>n.dataset.variant!=="1m").forEach(n=>{const s=document.createElement("button");s.type="button",s.className="set-modelcard",s.setAttribute("role","radio"),s.dataset.value=n.value,n.dataset.ctx==="1"&&(s.dataset.ctx="1");const o=document.createElement("span");o.className="set-mc-top";const i=document.createElement("span");i.className="set-mc-name",i.textContent=n.textContent,o.appendChild(i);const a=document.createElement("span");a.className="set-mc-dot",o.appendChild(a),s.appendChild(o);const l=document.createElement("span");if(l.className="set-mc-meta",l.textContent=n.dataset.meta||"",s.appendChild(l),n.dataset.ctx==="1"){const d=document.createElement("span");d.className="set-mc-ctx",d.textContent="1M capable",s.appendChild(d)}s.addEventListener("click",()=>{this._settingsModelBase=n.value,this._applyModelSelection()}),t.appendChild(s)}),t.dataset.built="1")},_syncModelCards(){const e=document.getElementById("appSettingsClaudeModel");if(!e)return;const t=e.value||"";if(this._settingsModelBase=t.endsWith("[1m]")?t.slice(0,-4):t,t.endsWith("[1m]")){const n=document.getElementById("appSettingsOpusContext1m");n&&(n.checked=!0)}this._applyModelSelection()},_applyModelSelection(){const e=document.getElementById("appSettingsClaudeModel"),t=document.getElementById("appSettingsModelCards");if(!e||!t)return;const n=this._settingsModelBase||"";let s=!1;t.querySelectorAll(".set-modelcard").forEach(d=>{const c=d.dataset.value===n;d.classList.toggle("selected",c),d.setAttribute("aria-checked",c?"true":"false"),c&&(s=d.dataset.ctx==="1")});const o=!!document.getElementById("appSettingsOpusContext1m")?.checked;e.value=n&&s&&o?`${n}[1m]`:n;const i=document.getElementById("appSettingsContextRow"),a=document.getElementById("appSettingsContextDesc"),l=!!n&&!s;i?.classList.toggle("set-row-disabled",l),a&&(a.textContent=l?"The selected model has no 1M variant.":n?"Available for Fable 5.1, Fable 5, Opus 5.5, Opus and Opus 4.6.":"With no model pinned, this starts new sessions on Opus with a 1M window.")},_buildEffortSegment(){this._buildSelectSegment("appSettingsThinkingEffort","appSettingsEffortSegment")},_syncEffortSegment(){this._syncSelectSegment("appSettingsThinkingEffort","appSettingsEffortSegment")},_buildAdvisorSegment(){this._buildSelectSegment("appSettingsClaudeAdvisor","appSettingsAdvisorSegment")},_syncAdvisorSegment(){this._syncSelectSegment("appSettingsClaudeAdvisor","appSettingsAdvisorSegment")},_buildSelectSegment(e,t){const n=document.getElementById(e),s=document.getElementById(t);!n||!s||s.dataset.built==="1"||!n.options||(s.innerHTML="",[...n.options].forEach(o=>{const i=document.createElement("button");i.type="button",i.setAttribute("role","radio"),i.dataset.value=o.value,i.textContent=o.textContent,i.addEventListener("click",()=>{n.value=o.value,this._syncSelectSegment(e,t)}),s.appendChild(i)}),s.dataset.built="1")},_syncSelectSegment(e,t){const n=document.getElementById(e),s=document.getElementById(t);!n||!s||s.querySelectorAll("button").forEach(o=>{const i=o.dataset.value===(n.value||"");o.classList.toggle("selected",i),o.setAttribute("aria-checked",i?"true":"false")})},_filterSettings(e){const t=document.getElementById("appSettingsDoc");if(!t)return;const n=(e||"").trim().toLowerCase(),s=".set-row, .set-chip, .set-modelgrid, .set-minigrid, .event-type-grid, #appSettingsShortcutsList",o=[...t.querySelectorAll(s)];let i=!1;o.forEach(l=>{if(!n){l.classList.remove("set-hit-hidden");return}const c=`${l.dataset?.search||""} ${l.textContent||""}`.toLowerCase().includes(n);l.classList.toggle("set-hit-hidden",!c),c&&(i=!0)}),t.querySelectorAll(".set-chips").forEach(l=>{const d=[...l.querySelectorAll(".set-chip")].some(c=>!c.classList.contains("set-hit-hidden"));l.classList.toggle("set-hit-hidden",!!n&&!d)}),t.querySelectorAll(".set-group").forEach(l=>{const d=[...l.querySelectorAll(s)].some(c=>!c.classList.contains("set-hit-hidden"));l.classList.toggle("set-hit-hidden",!!n&&!d),n&&d&&l.classList.add("open")}),t.querySelectorAll(".set-section").forEach(l=>{const d=[...l.querySelectorAll(".set-group")].some(c=>!c.classList.contains("set-hit-hidden"));l.classList.toggle("set-hit-hidden",!!n&&!d)}),t.querySelectorAll(".set-preview").forEach(l=>l.classList.toggle("set-hit-hidden",!!n));const a=document.getElementById("appSettingsSearchEmpty");a&&(a.hidden=!n||i),n||t.querySelectorAll(".set-group-advanced").forEach(l=>l.classList.remove("open"))},closeAppSettings(){this._toggleSettingsJump(!1),document.getElementById("appSettingsModal").classList.remove("active"),this.activeFocusTrap&&(this.activeFocusTrap.deactivate(),this.activeFocusTrap=null)},_updatePhaseText(e){return{queued:"Queued\u2026",preparing:"Preparing\u2026",stashing:"Stashing local changes\u2026",fetching:"Fetching release\u2026",checkout:"Checking out release\u2026",installing:"Installing dependencies\u2026",building:"Building\u2026",restarting:"Restarting Codeman\u2026"}[e]||e},_initUpdatesSection(){const e=this.$("updateCurrentVersion");e&&(e.textContent=(this.$("versionDisplay")?.textContent||"").trim()||"\u2014");for(const t of["updateResult","updateActionRow","updateNotes","updateProgress"]){const n=this.$(t);n&&(n.style.display="none")}this._updateCheck=null},keyTesterEvent(e){const t=document.getElementById("keyTesterLog");if(!t)return;const n=["ctrlKey","shiftKey","altKey","metaKey"].filter(i=>e[i]).map(i=>i.replace("Key","")),s=`${e.type.padEnd(8)} key=${JSON.stringify(e.key)} code=${e.code||"-"} mods=${n.join("+")||"none"}`+(e.type==="keypress"?` charCode=${e.charCode}`:"")+(e.repeat?" (repeat)":""),o=(t.textContent?t.textContent.split(`
|
|
2
2
|
`):[]).concat(s);t.textContent=o.slice(-14).join(`
|
|
3
3
|
`),t.style.display="block"},applyMcpSyncVisibility(){const e=document.getElementById("appSettingsMcpSync")?.checked??!1,t=document.getElementById("mcpSyncActionRow");t&&(t.style.display=e?"":"none");const n=this.$("mcpSyncResult");!e&&n&&(n.style.display="none",n.innerHTML=""),this._applyMcpSyncAdminGate()},_applyMcpSyncAdminGate(){const e=document.getElementById("mcpSyncGroup");if(!e)return;const t=window.__codemanUser||{};e.style.display=t.multiUser&&t.role!=="admin"?"none":""},_applyDoctorAdminGate(){const e=document.getElementById("doctorGroup");if(!e)return;const t=window.__codemanUser||{};e.style.display=t.multiUser&&t.role!=="admin"?"none":""},async mcpSync(e){const t=this.$("mcpSyncResult"),n=(r,u="")=>{t&&(t.style.display="block",t.innerHTML=r,t.dataset.hint=u)};if(!this._mcpSyncSavedOn){n("Apply or Save settings to turn MCP sync on first, then preview or sync.","save-first");return}if(e&&!confirm("Add missing MCP servers to every installed, enabled CLI's config file (and GitHub Copilot CLI's, when it is installed)? Env values and headers on those servers are copied too."))return;n("Working\u2026");const s=e?await this._apiPost("/api/mcp-sync",{}):await this._api("/api/mcp-sync");let o=null;try{o=s?await s.json():null}catch{}if(!s||!s.ok||!o||o.success===!1){n(escapeHtml(o?.error||"MCP sync failed."));return}const i=o.data,a=i.targets.map(r=>{if(r.status==="absent")return`<li><b>${escapeHtml(r.label)}</b>: not installed, skipped</li>`;if(r.status==="skipped")return`<li><b>${escapeHtml(r.label)}</b>: not touched (${escapeHtml(r.error||"config location unknown")})</li>`;if(r.status==="unreadable")return`<li><b>${escapeHtml(r.label)}</b>: not touched, file can't be read safely (${escapeHtml(r.error||"unreadable")})</li>`;if(r.status==="failed")return`<li><b>${escapeHtml(r.label)}</b>: failed (${escapeHtml(r.error||"error")}); the file may be unchanged</li>`;const u=i.applied?"added":"would add",p=[r.added.length?`${u} ${r.added.map(escapeHtml).join(", ")}`:"up to date"];r.skipped.length&&p.push(`can't express ${r.skipped.map(escapeHtml).join(", ")}`);const m=`${r.servers.length} server${r.servers.length===1?"":"s"}`;return`<li><b>${escapeHtml(r.label)}</b> (${m}): ${p.join("; ")}</li>`}),l=i.conflicts.length?`<p>Defined differently across CLIs (each existing definition is kept; the first CLI's is copied where the name is missing): ${i.conflicts.map(escapeHtml).join(", ")}</p>`:"",d=i.disabled?.length?`<p>Switched off in their own CLI, so not copied: ${i.disabled.map(escapeHtml).join(", ")}</p>`:"",c=i.unsupported?.length?`<p>No MCP config support for: ${i.unsupported.map(escapeHtml).join(", ")}</p>`:"";n(`<ul>${a.join("")}</ul>${l}${d}${c}`)},_webhookSay(e,t=!1){const n=document.getElementById("webhookResult");n&&(n.textContent=e,n.style.display=e?"block":"none",n.style.color=t?"var(--danger, #e5534b)":"")},async loadWebhook(){const e=document.getElementById("webhookGroup");if(!e)return;const t=await this._api("/api/webhook");if(!t||!t.ok){this._webhookLoaded=null,e.style.display="none";return}let n=null;try{n=await t.json()}catch{}if(!n||n.success===!1){this._webhookLoaded=null,e.style.display="none";return}const s=n.data;e.style.display="",document.getElementById("webhookEnabled").checked=s.enabled===!0,document.getElementById("webhookKind").value=s.kind,document.getElementById("webhookScope").value=s.scope;const o=document.getElementById("webhookUrl");o.value="",o.placeholder=s.hasUrl?"Saved. Paste a new URL to replace it":"https://ntfy.sh/your-topic",document.getElementById("webhookUrlHint").textContent=s.hasUrl?`Saved: ${s.urlMasked}`:"Nothing saved yet.";const i=document.getElementById("webhookClearBtn");if(i&&(i.style.display=s.hasUrl?"":"none"),this._webhookLoaded={enabled:document.getElementById("webhookEnabled").checked,kind:document.getElementById("webhookKind").value,scope:document.getElementById("webhookScope").value},s.lastResult){const a=new Date(s.lastResult.at).toLocaleString();this._webhookSay(s.lastResult.ok?`Last delivery succeeded (${a}).`:`Last delivery failed (${a}): ${s.lastResult.error}`,!s.lastResult.ok)}else this._webhookSay("")},_webhookPending(){const e=document.getElementById("webhookGroup"),t=this._webhookLoaded;return!e||e.style.display==="none"||!t?!1:document.getElementById("webhookUrl").value.trim()!==""||document.getElementById("webhookEnabled").checked!==t.enabled||document.getElementById("webhookKind").value!==t.kind||document.getElementById("webhookScope").value!==t.scope},async saveWebhook(){const e={enabled:document.getElementById("webhookEnabled").checked,kind:document.getElementById("webhookKind").value,scope:document.getElementById("webhookScope").value},t=document.getElementById("webhookUrl").value.trim();t&&(e.url=t);const n=await this._api("/api/webhook",{method:"PUT",body:e});let s=null;try{s=n?await n.json():null}catch{}if(!n||!n.ok||!s||s.success===!1){const o=s?.error||"Could not save the webhook.";return this._webhookSay(o,!0),o}return await this.loadWebhook(),this._webhookSay("Saved."),""},async clearWebhook(){if(!confirm("Remove the saved webhook URL from the server? Webhook alerts stop until you save a new one."))return;const e=await this._api("/api/webhook",{method:"PUT",body:{url:"",enabled:!1}});let t=null;try{t=e?await e.json():null}catch{}if(!e||!e.ok||!t||t.success===!1){this._webhookSay(t?.error||"Could not remove the webhook URL.",!0);return}await this.loadWebhook(),this._webhookSay("Webhook URL removed.")},async testWebhook(){const e=document.getElementById("webhookTestBtn");e&&(e.disabled=!0);try{if(this._webhookPending()&&await this.saveWebhook())return;this._webhookSay("Sending\u2026");const t=await this._apiPost("/api/webhook/test",{});let n=null;try{n=t?await t.json():null}catch{}if(!t||!t.ok||!n||n.success===!1){this._webhookSay(n?.error||"Could not send the test.",!0);return}const s=n.data;this._webhookSay(s.ok?"Test sent. Check your phone or channel.":`Delivery failed: ${s.error}`,!s.ok)}finally{e&&(e.disabled=!1)}},async runDoctor(){const e=document.getElementById("doctorResult"),t=document.getElementById("doctorRunBtn");if(!e)return;const n=s=>{e.replaceChildren(document.createTextNode(s)),e.style.display="block"};t&&(t.disabled=!0),n("Checking\u2026");try{const s=await this._api("/api/doctor");let o=null;try{o=s?await s.json():null}catch{}if(!s||!s.ok||!o||o.success===!1){n(o?.error||"The check failed.");return}const{tools:i,summary:a,platform:l}=o.data,d={ok:"\u2713",missing:"\u2717",outdated:"!",error:"!",skipped:"\u2013"},c=document.createElement("ul");c.style.margin="0",c.style.paddingLeft="1.2em";for(const u of i){const p=document.createElement("li"),m=document.createElement("b"),g=u.status==="missing"&&!u.required?"\u25CB":d[u.status]||"?";m.textContent=`${g} ${u.label}`,p.append(m);const f=[u.status];if(u.version&&f.push(u.version),u.status!=="ok"&&u.status!=="skipped"&&f.push(u.required?"required":"optional"),u.reason&&f.push(u.reason),p.append(document.createTextNode(` ${f.join(" \xB7 ")}`)),u.path){const h=document.createElement("div");h.className="mono",h.textContent=u.path,p.append(h)}if(u.status==="missing"&&u.installHint){const h=document.createElement("div");h.textContent=`Install: ${u.installHint}`,p.append(h)}c.append(p)}const r=document.createElement("p");r.textContent=`${a.ok} ok \xB7 ${a.requiredMissing} required missing \xB7 ${a.optionalMissing} optional missing (${l.environment})`,e.replaceChildren(r,c),e.style.display="block"}finally{t&&(t.disabled=!1)}},_setUpdateResult(e){const t=this.$("updateResult");t&&(t.style.display="block",t.innerHTML=e)},_setUpdateProgress(e){const t=this.$("updateProgress");t&&(t.style.display="block",t.innerHTML=e)},async checkForUpdate(){const e=this.$("updateCheckBtn");e&&(e.disabled=!0,e.textContent="Checking\u2026");const t=await this._apiJson("/api/system/update/check");e&&(e.disabled=!1,e.textContent="Check now");const n=this.$("updateActionRow"),s=this.$("updateNotes");if(n&&(n.style.display="none"),s&&(s.style.display="none"),!t){this._setUpdateResult("Could not check for updates. Try again later.");return}this._updateCheck=t;const o=this.$("updateCurrentVersion");if(o&&t.currentVersion&&(o.textContent=`v${t.currentVersion}`),t.installKind&&t.installKind!=="git"&&t.installKind!=="docker-compose"){const a=t.supervisor==="docker-compose"?"Update from the Docker host with <code>docker/Start-Codeman.sh</code>.":"Update with <code>npm i -g aicodeman@latest</code>.";this._setUpdateResult(`This install can't update itself (${escapeHtml(t.installKind)}). ${a}`);return}if(t.selfUpdateEnabled===!1){this._setUpdateResult("In-app updates are disabled on this server (CODEMAN_DISABLE_SELF_UPDATE=1).");return}if(t.error&&!t.updateAvailable){this._setUpdateResult(escapeHtml(t.error));return}const i=t.environment?.blockers||[];if(t.updateAvailable&&i.length>0){const a=i.map(l=>{const d=l.details?.length?`<br><code>${escapeHtml(l.details.join(" "))}</code>`:"";return`<li>${escapeHtml(l.message)}${d}</li>`}).join("");this._setUpdateResult(`<strong>v${escapeHtml(t.latestVersion||"")}</strong> needs a rebuild on the Docker host (current v${escapeHtml(t.currentVersion||"")}):<ul>${a}</ul>Run <code>${escapeHtml(t.environment?.hostCommand||"docker/Start-Codeman.sh")}</code> there to apply it.`),s&&t.notes&&(s.style.display="block",s.textContent=t.notes);return}if(t.updateAvailable&&t.latestVersion){this._setUpdateResult(`Update available: <strong>v${escapeHtml(t.latestVersion)}</strong> (current v${escapeHtml(t.currentVersion||"")})`);const a=this.$("updateActionLabel");a&&(a.textContent=`Update to v${t.latestVersion}`),n&&(n.style.display="flex");const l=this.$("updateNowBtn");l&&(l.disabled=!1,l.textContent="Update now"),s&&t.notes&&(s.style.display="block",s.textContent=t.notes)}else this._setUpdateResult(`You're up to date (v${escapeHtml(t.currentVersion||"")}).`)},async startSelfUpdate(){const e=this._updateCheck?.latestVersion?`v${this._updateCheck.latestVersion}`:"the latest release";if(!confirm(`Update Codeman to ${e}? The server will restart and this page will reload.`))return;const t=this.$("updateNowBtn");t&&(t.disabled=!0,t.textContent="Starting\u2026");const n=await this._apiPost("/api/system/update",{});if(!n||!n.ok){let i="Failed to start the update.";try{const a=await n.json();typeof a?.error=="string"&&a.error&&(i=a.error)}catch{}this._setUpdateProgress(`<span style="color:var(--danger,#e5534b)">${escapeHtml(i)}</span>`),t&&(t.disabled=!1,t.textContent="Update now");return}const s=this.$("updateActionRow");s&&(s.style.display="none");const o=this.$("updateNotes");o&&(o.style.display="none"),this._setUpdateProgress("Starting update\u2026"),this._pollUpdateStatus()},_stopUpdatePolling(){this._updatePollTimer&&(clearInterval(this._updatePollTimer),this._updatePollTimer=null)},_pollUpdateStatus(){this._stopUpdatePolling();const e=new Set(["completed","completed-needs-manual-restart","failed","idle"]),t=async()=>{let n=null;try{const s=await fetch("/api/system/update/status");if(s.ok){const o=await s.json();n=o&&o.success===!0?o.data:o}}catch{}if(!n){this._setUpdateProgress("\u21BB Restarting Codeman\u2026");return}if(!e.has(n.phase)){const s=n.message&&n.message.trim()?n.message.trim():this._updatePhaseText(n.phase);let o="";n.startedAt&&(o=` <span style="color:var(--text-secondary)">\xB7 ${Math.max(0,Math.round((Date.now()-n.startedAt)/1e3))}s</span>`),this._setUpdateProgress(`<span class="tunnel-spinner"></span> ${escapeHtml(s)}${o}`);return}if(this._stopUpdatePolling(),n.phase==="completed"){let s=`<span style="color:var(--success,#3fb950)">\u2713 Updated to v${escapeHtml(n.toVersion||"")}. Reloading\u2026</span>`;n.stashRef&&(s+=`<br><span style="color:var(--text-secondary)">Local changes stashed as <code>${escapeHtml(n.stashRef)}</code> \u2014 run <code>git stash pop</code> to restore.</span>`),this._setUpdateProgress(s),setTimeout(()=>location.reload(),2500)}else if(n.phase==="completed-needs-manual-restart")this._setUpdateProgress(`Update staged. Restart Codeman to apply:<br><code>${escapeHtml(n.manualRestartCommand||"restart codeman web")}</code>`);else if(n.phase==="failed"){let s=`<span style="color:var(--danger,#e5534b)">\u2717 ${escapeHtml(n.message||"Update failed")}.</span>`;n.error&&(s+=`<br><span style="color:var(--text-secondary)">${escapeHtml(n.error)}</span>`),s+='<br><span style="color:var(--text-secondary)">The previous version is still running.</span>',n.stashRef&&(s+=`<br><span style="color:var(--text-secondary)">Local changes stashed as <code>${escapeHtml(n.stashRef)}</code>.</span>`),this._setUpdateProgress(s);const o=this.$("updateNowBtn"),i=this.$("updateActionRow");o&&(o.disabled=!1,o.textContent="Try again"),i&&(i.style.display="flex")}};t(),this._updatePollTimer=setInterval(t,1500)},isCliAvailable(e){const t=window.__codemanCliAvailable;return!t||typeof t!="object"?!0:t[e]!==!1},renderWelcomeCliActions(){const e=document.getElementById("welcomeCliActions");if(!e)return;const n=(Array.isArray(window.__codemanCliCatalog)?window.__codemanCliCatalog:[]).filter(p=>p.enabled&&this.isCliAvailable(p.id)),s=n.find(p=>p.kind!=="shell")||n[0],o=p=>`Run ${p.kind==="shell"?"Shell":p.label}`,i=p=>{const m=document.createElement("span");return m.className=`run-mode-dot ${p.id}`,m.setAttribute("aria-hidden","true"),m},a=p=>()=>{this.setRunMode(p.id),this.run()};if(e.replaceChildren(),!s)return;const l=document.createElement("button");l.type="button",l.className="welcome-primary",l.dataset.mode=s.id;const d=document.createElement("span");d.className="welcome-primary-logo",d.appendChild(i(s)),l.appendChild(d);const c=document.createElement("span");c.className="welcome-label",c.textContent=o(s),l.appendChild(c),l.onclick=a(s),e.appendChild(l);const r=n.filter(p=>p!==s);if(!r.length)return;const u=document.createElement("div");u.className="welcome-chips",u.setAttribute("role","group"),u.setAttribute("aria-label","More tools");for(const p of r){const m=document.createElement("button");m.type="button",m.className="welcome-chip",m.dataset.mode=p.id,m.title=o(p),m.setAttribute("aria-label",o(p)),m.appendChild(i(p));const g=document.createElement("span");g.className="welcome-label",g.textContent=p.kind==="shell"?"Shell":p.label,m.appendChild(g),m.onclick=a(p),u.appendChild(m)}e.appendChild(u)},applyWelcomeCliVisibility(){this.renderWelcomeCliActions();const e=document.getElementById("welcomeTunnelBtn");e&&(e.style.display=this.isCliAvailable("cloudflared")?"flex":"none")},async loadTunnelStatus(){try{const t=await(await fetch("/api/tunnel/status")).json(),n=t?.success===!0?t.data:t,s=n.running&&n.url;this._tunnelUrl=s?n.url:null,this._updateTunnelUrlDisplay(this._tunnelUrl),this._updateWelcomeTunnelBtn(!!s,this._tunnelUrl),this._updateTunnelIndicator(!!s)}catch{this._tunnelUrl=null,this._updateTunnelUrlDisplay(null),this._updateWelcomeTunnelBtn(!1),this._updateTunnelIndicator(!1)}},_updateTunnelUrlDisplay(e){const t=document.getElementById("tunnelUrlRow"),n=document.getElementById("tunnelUrlDisplay");!t||!n||(e?(t.style.display="",n.textContent=e,n.onclick=()=>{navigator.clipboard.writeText(e).then(()=>{this.showToast("Tunnel URL copied","success")})}):(t.style.display="none",n.textContent="",n.onclick=null))},showTunnelQR(){this.closeTunnelQR();const e=document.createElement("div");e.id="tunnelQrOverlay",e.style.cssText="position:fixed;inset:0;background:rgba(0,0,0,0.7);z-index:5000;display:flex;align-items:center;justify-content:center;cursor:pointer",e.onclick=n=>{n.target===e&&this.closeTunnelQR()};const t=document.createElement("div");t.style.cssText="background:var(--bg-card);border:1px solid var(--border);border-radius:12px;padding:24px;text-align:center;max-width:340px;width:90vw;box-shadow:var(--shadow-lg);cursor:default",t.innerHTML=`
|
|
4
4
|
<div style="font-size:14px;font-weight:600;color:var(--text-primary);margin-bottom:16px">Scan to connect</div>
|
|
@@ -60,7 +60,7 @@ Enable the unauthenticated public tunnel anyway?`))return this._dismissTunnelCon
|
|
|
60
60
|
<td style="padding:3px 8px;color:#e0e0e0" title="${c.sessionId}">${p}</td>
|
|
61
61
|
<td style="padding:3px 8px;color:#aaa">${c.reason||""}</td>
|
|
62
62
|
<td style="padding:3px 8px;color:#666">${m.join(", ")}</td>
|
|
63
|
-
</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 applyAppSettings(){if(!this._applyInFlight){this._applyInFlight=!0,this._keepSettingsOpenOnce=!0;try{await this.saveAppSettings()}finally{this._applyInFlight=!1,this._keepSettingsOpenOnce=!1}}},async saveAppSettings(){const e=this._keepSettingsOpenOnce===!0;this._keepSettingsOpenOnce=!1;const t=this.loadAppSettingsFromStorage(),n=(t.gestureControlEnabled??!1)===!0,s=(t.webglRendererEnabled??!0)===!0,o={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,headerStatsStyle:document.getElementById("appSettingsHeaderStatsStyle").value,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,customModelEndpointsEnabled:document.getElementById("appSettingsCustomModelEndpoints").checked,cliManagementEnabled:document.getElementById("appSettingsCliManagement").checked,mcpSyncEnabled:document.getElementById("appSettingsMcpSync").checked,readMyMindEnabled:document.getElementById("appSettingsReadMyMind").checked,ultracodeFloatingWindows:document.getElementById("appSettingsUltracodeFloatingWindows").checked,showMultiMonitorButton:document.getElementById("appSettingsShowMultiMonitorButton").checked,showSplitButton:document.getElementById("appSettingsShowSplitButton").checked,showTileGridButton:document.getElementById("appSettingsShowTileGridButton").checked,showPlanUsageLimits:document.getElementById("appSettingsShowPlanUsageLimits").checked,showRedrawButton:document.getElementById("appSettingsShowRedrawButton").checked,mobileOverviewEnabled:document.getElementById("appSettingsMobileOverview").checked,sessionLineageLines:document.getElementById("appSettingsLineageLines").checked,autoNameSessions:document.getElementById("appSettingsAutoNameSessions").checked,spawnedTabsFollowParent:document.getElementById("appSettingsSpawnedTabsFollowParent").checked,showSessionButton:document.getElementById("appSettingsShowSessionButton").checked,showAwayDigestButton:document.getElementById("appSettingsShowAwayDigestButton").checked,showCronButton:document.getElementById("appSettingsShowCronButton").checked,showGitStatus:document.getElementById("appSettingsShowGitStatus").checked,gitStatusTree:document.getElementById("appSettingsGitStatusTree").checked,gitStatusMaxRepos:Math.min(50,Math.max(1,parseInt(document.getElementById("appSettingsGitStatusMaxRepos").value,10)||12)),gitStatusTimeoutSeconds:Math.min(120,Math.max(5,parseInt(document.getElementById("appSettingsGitStatusTimeout").value,10)||30)),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,copyStripMargin:document.getElementById("appSettingsCopyStripMargin").checked,terminalFontFamily:document.getElementById("appSettingsTerminalFont").value.trim(),terminalFontWeight:this.readTerminalFontWeight(document.getElementById("appSettingsTerminalFontWeight")),terminalFontWeightBold:this.readTerminalFontWeight(document.getElementById("appSettingsTerminalFontWeightBold")),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,showTabCliLogos:document.getElementById("appSettingsShowTabCliLogos").checked,tabOrientation:document.getElementById("appSettingsTabOrientation").value,tabRailWidth:this.readTabRailWidthSetting?.()??256,tabRailDetail:document.getElementById("appSettingsTabRailDetail").value,tabRailSort:document.getElementById("appSettingsTabRailSort").value,tabArrangement:document.getElementById("appSettingsTabArrangement").value,tabStateOrder:document.getElementById("appSettingsTabStateOrder").value,showTabDetachButton:document.getElementById("appSettingsShowTabDetachButton").checked,tileDetachEnabled:document.getElementById("appSettingsTileDetach").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(),codexModel:document.getElementById("appSettingsCodexModel").value.trim(),codexReasoningEffort:document.getElementById("appSettingsCodexReasoningEffort").value,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,claudeAdvisorModel:document.getElementById("appSettingsClaudeAdvisor").value,nice:{enabled:document.getElementById("appSettingsNiceEnabled").checked,niceValue:parseInt(document.getElementById("appSettingsNiceValue").value)||10}};if(this._readSettingsFormOnce===!0)return this._readSettingsFormOnce=!1,o;if(!/^[A-Za-z0-9._\/-]*$/.test(o.codexModel)){this.showToast('Default Codex model may only contain letters, digits, ".", "_", "-" and "/"',"error"),document.getElementById("appSettingsCodexModel")?.focus();return}t.showTokenCount!==void 0&&(o.showTokenCount=t.showTokenCount),t.showCost!==void 0&&(o.showCost=t.showCost),t.shortcutOverrides!==void 0&&(o.shortcutOverrides=t.shortcutOverrides);const i=this._settingsReadOnly(),a=i&&this._keepServerSyncedSettings(o,t);if(this.saveAppSettingsToStorage(o),this._updateLocalEchoState(),this.applyTerminalFontFamily?.(o.terminalFontFamily),this.applyTerminalFontWeights?.(o),!s&&o.webglRendererEnabled)try{localStorage.removeItem("codeman-webgl-disabled")}catch{}const l={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(l);const d={enabled:document.getElementById("appSettingsNotifEnabled").checked,browserNotifications:document.getElementById("appSettingsNotifBrowser").checked,audioAlerts:document.getElementById("appSettingsNotifAudio").checked,stuckThresholdMs:(parseInt(document.getElementById("appSettingsNotifStuckMins").value)||10)*6e4,toastDurationMs:(parseInt(document.getElementById("appSettingsNotifToastSecs").value)||3)*1e3,browserAutoCloseMs:(parseInt(document.getElementById("appSettingsNotifBrowserSecs").value)||8)*1e3,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=this.notificationManager.normalizePreferences(d),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(o.extendedKeyboardBar?"extended":"simple");const c=this.planUsageCollectionFlip(t,o.showPlanUsageLimits),{localEchoEnabled:r,cjkInputEnabled:u,extendedKeyboardBar:p,skin:m,language:g,showPlanUsageLimits:f,showAttachmentsButton:h,showFileViewerButton:y,showSplitButton:b,showTileGridButton:S,webglRendererEnabled:E,terminalWheelLocalScrollback:w,autoCopySelection:v,copyStripMargin:B,terminalFontFamily:I,terminalFontWeight:k,terminalFontWeightBold:M,showSessionButton:$,showAwayDigestButton:L,showCronButton:H,showGitStatus:A,gitStatusTree:D,gitStatusMaxRepos:P,gitStatusTimeoutSeconds:O,showTabDetachButton:R,tileDetachEnabled:x,mobileOverviewEnabled:W,sessionLineageLines:F,shortcutOverrides:K,...j}=o;let T="",U=!1;try{const C=i?null:await this._apiPut("/api/settings",{...j,...c!==void 0?{showPlanUsageLimits:c}:{},notificationPreferences:d,voiceSettings:l}),_=!i&&await this._noteSettingsWriteRefusal(C);if(_&&(this._keepServerSyncedSettings(o,t),this.saveAppSettingsToStorage(o)),!_&&o.tunnelEnabled&&await this._handleTunnelEnableRefusal(C)){o.tunnelEnabled=!1,this.saveAppSettingsToStorage(o);const N=document.getElementById("appSettingsTunnelEnabled");N&&(N.checked=!1),e||this.closeAppSettings();return}U=!!C?.ok;const V=await this.saveModelConfigFromSettings()===!0;T=this._webhookPending()?await this.saveWebhook():"",T?this.showToast(`Settings saved, but not the webhook: ${T}`,"warning"):a||V||_?this.showToast("Saved on this device. Server-wide settings can only be changed by an admin.","warning"):this.showToast(e?"Settings applied":"Settings saved","success"),o.tunnelEnabled&&!i&&!_&&this.showToast("Tunnel starting \u2014 QR code will appear when ready...","info")}catch{this.showToast("Settings saved locally","warning")}e&&U&&this._refreshSettingsAfterApply(o),T?document.getElementById("webhookGroup")?.scrollIntoView({block:"center"}):e||this.closeAppSettings(),VoiceInput.refreshClaudeStatus(),(o.gestureControlEnabled??!1)!==n&&(this.showToast(o.gestureControlEnabled?"Enabling gesture control \u2014 reloading\u2026":"Disabling gesture control \u2014 reloading\u2026","info"),setTimeout(()=>location.reload(),400))},_settingsReadOnly(){if(this._settingsWriteForbidden===!0)return!0;const e=typeof window<"u"&&window.__codemanUser||{};return!!(e.multiUser&&e.role!=="admin")},async _noteSettingsWriteRefusal(e){if(!e||e.status!==403)return!1;let t=null;try{t=await(typeof e.clone=="function"?e.clone():e).json()}catch{return!1}return t?.errorCode!=="FORBIDDEN"?!1:(this._settingsWriteForbidden=!0,!0)},_ownSettingsKey(){return`codeman:own-settings:${(typeof window<"u"&&window.__codemanUser||{}).username||""}`},_readOwnSettings(){try{const e=JSON.parse(localStorage.getItem(this._ownSettingsKey())||"{}");return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}},_rememberOwnSetting(e,t){try{const n=this._readOwnSettings();n[e]=t,localStorage.setItem(this._ownSettingsKey(),JSON.stringify(n))}catch{}},_applyOwnSettings(){if(!this._settingsReadOnly())return;const e=this._readOwnSettings();if(Array.isArray(e.respawnPresets)){this._serverRespawnPresets=e.respawnPresets;try{localStorage.setItem("codeman-respawn-presets",JSON.stringify(e.respawnPresets))}catch{}}if(typeof e.runMode=="string"&&e.runMode){this.runMode=e.runMode;try{localStorage.setItem("codeman_runMode",e.runMode)}catch{}this._applyRunMode?.()}},_captureSettingsFormBaseline(){if(this._settingsFormBaseline=null,!this._settingsReadOnly())return;this._readSettingsFormOnce=!0;let e;try{e=this.saveAppSettings()}finally{this._readSettingsFormOnce=!1}Promise.resolve(e).then(t=>{this._settingsFormBaseline=t&&typeof t=="object"?t:null}).catch(()=>{})},_keepServerSyncedSettings(e,t){const n=this._displaySettingKeySet(),s=this._settingsFormBaseline||t||{};let o=!1;for(const i of Object.keys(e))n.has(i)||i==="shortcutOverrides"||(i in s&&JSON.stringify(e[i])!==JSON.stringify(s[i])&&(o=!0),t&&i in t?e[i]=t[i]:delete e[i]);return o},_refreshSettingsAfterApply(e){this._mcpSyncSavedOn=e.mcpSyncEnabled===!0;const t=this.$("mcpSyncResult");this._mcpSyncSavedOn&&t&&t.dataset?.hint==="save-first"&&(t.style.display="none",t.innerHTML=""),this.applyMcpSyncVisibility(),this.applyCustomModelEndpointsVisibility(),this.applyCliManagementVisibility(),this._applyDoctorAdminGate()},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"),d=document.getElementById("appSettingsModelTest"),c=document.getElementById("appSettingsModelReview");a&&(a.value=i.explore||""),l&&(l.value=i.implement||""),d&&(d.value=i.test||""),c&&(c.value=i.review||"")}}catch(e){console.warn("Failed to load model config:",e)}this._modelConfigBaseline=JSON.stringify(this._modelConfigFromSettingsForm())},_modelConfigFromSettingsForm(){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={};return n?.value&&(a.explore=n.value),s?.value&&(a.implement=s.value),o?.value&&(a.test=o.value),i?.value&&(a.review=i.value),{defaultModel:e?.value||"",showRecommendations:t?.checked??!0,agentTypeOverrides:a}},async saveModelConfigFromSettings(){const e=this._modelConfigFromSettingsForm();if(this._settingsReadOnly()){const t=this._modelConfigBaseline;return typeof t=="string"&&JSON.stringify(e)!==t}try{await fetch("/api/execution/model-config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(t){console.warn("Failed to save model config:",t)}},applyCustomModelEndpointsVisibility(){const e=document.getElementById("appSettingsCustomModelEndpoints").checked,t=document.getElementById("customModelEndpointsBody");t&&(t.style.display=e?"":"none"),e?this.loadCustomModelEndpointsForSettings():this.closeCustomModelHostEditor(),this._applyCustomModelAdminGate()},_applyCustomModelAdminGate(){const e=document.getElementById("customModelHostAddBtn");if(!e)return;const t=window.__codemanUser||{},n=t.multiUser&&t.role!=="admin";e.style.display=n?"none":""},async loadCustomModelEndpointsForSettings(){const e=await this._apiJson("/api/model-endpoints");this._customModelHosts=Array.isArray(e)?e:[],this.renderCustomModelHostsList()},renderCustomModelHostsList(){const e=document.getElementById("customModelHostsList");if(!e)return;const t=this._customModelHosts||[];if(t.length===0){e.innerHTML='<p class="set-group-hint">No endpoints yet. Add one below to point a harness at a local or cloud OpenAI-compatible server.</p>';return}e.innerHTML=t.map(n=>{const s=(n.models||[]).length,o=s===0?"No models discovered yet":`${s} model${s===1?"":"s"}${n.defaultModelId?` \xB7 default: ${escapeHtml(n.defaultModelId)}`:" \xB7 no default set"}`,i=escapeHtml(JSON.stringify(n.id));return`
|
|
63
|
+
</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 applyAppSettings(){if(!this._applyInFlight){this._applyInFlight=!0,this._keepSettingsOpenOnce=!0;try{await this.saveAppSettings()}finally{this._applyInFlight=!1,this._keepSettingsOpenOnce=!1}}},async saveAppSettings(){const e=this._keepSettingsOpenOnce===!0;this._keepSettingsOpenOnce=!1;const t=this.loadAppSettingsFromStorage(),n=(t.gestureControlEnabled??!1)===!0,s=(t.webglRendererEnabled??!0)===!0,o={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,headerStatsStyle:document.getElementById("appSettingsHeaderStatsStyle").value,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,customModelEndpointsEnabled:document.getElementById("appSettingsCustomModelEndpoints").checked,cliManagementEnabled:document.getElementById("appSettingsCliManagement").checked,mcpSyncEnabled:document.getElementById("appSettingsMcpSync").checked,readMyMindEnabled:document.getElementById("appSettingsReadMyMind").checked,ultracodeFloatingWindows:document.getElementById("appSettingsUltracodeFloatingWindows").checked,showMultiMonitorButton:document.getElementById("appSettingsShowMultiMonitorButton").checked,showSplitButton:document.getElementById("appSettingsShowSplitButton").checked,showTileGridButton:document.getElementById("appSettingsShowTileGridButton").checked,showPlanUsageLimits:document.getElementById("appSettingsShowPlanUsageLimits").checked,showRedrawButton:document.getElementById("appSettingsShowRedrawButton").checked,mobileOverviewEnabled:document.getElementById("appSettingsMobileOverview").checked,sessionLineageLines:document.getElementById("appSettingsLineageLines").checked,autoNameSessions:document.getElementById("appSettingsAutoNameSessions").checked,spawnedTabsFollowParent:document.getElementById("appSettingsSpawnedTabsFollowParent").checked,showSessionButton:document.getElementById("appSettingsShowSessionButton").checked,showAwayDigestButton:document.getElementById("appSettingsShowAwayDigestButton").checked,showCronButton:document.getElementById("appSettingsShowCronButton").checked,showGitStatus:document.getElementById("appSettingsShowGitStatus").checked,gitStatusTree:document.getElementById("appSettingsGitStatusTree").checked,gitStatusMaxRepos:Math.min(50,Math.max(1,parseInt(document.getElementById("appSettingsGitStatusMaxRepos").value,10)||12)),gitStatusTimeoutSeconds:Math.min(120,Math.max(5,parseInt(document.getElementById("appSettingsGitStatusTimeout").value,10)||30)),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,copyStripMargin:document.getElementById("appSettingsCopyStripMargin").checked,terminalFontFamily:document.getElementById("appSettingsTerminalFont").value.trim(),terminalFontWeight:this.readTerminalFontWeight(document.getElementById("appSettingsTerminalFontWeight")),terminalFontWeightBold:this.readTerminalFontWeight(document.getElementById("appSettingsTerminalFontWeightBold")),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,showTabCliLogos:document.getElementById("appSettingsShowTabCliLogos").checked,tabOrientation:document.getElementById("appSettingsTabOrientation").value,tabRailWidth:this.readTabRailWidthSetting?.()??256,tabRailDetail:document.getElementById("appSettingsTabRailDetail").value,tabRailSort:document.getElementById("appSettingsTabRailSort").value,tabArrangement:document.getElementById("appSettingsTabArrangement").value,tabStateOrder:document.getElementById("appSettingsTabStateOrder").value,showTabDetachButton:document.getElementById("appSettingsShowTabDetachButton").checked,tileDetachEnabled:document.getElementById("appSettingsTileDetach").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(),codexModel:document.getElementById("appSettingsCodexModel").value.trim(),codexReasoningEffort:document.getElementById("appSettingsCodexReasoningEffort").value,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,pinCliSessionName:document.getElementById("appSettingsPinCliSessionName").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,claudeAdvisorModel:document.getElementById("appSettingsClaudeAdvisor").value,nice:{enabled:document.getElementById("appSettingsNiceEnabled").checked,niceValue:parseInt(document.getElementById("appSettingsNiceValue").value)||10}};if(this._readSettingsFormOnce===!0)return this._readSettingsFormOnce=!1,o;if(!/^[A-Za-z0-9._\/-]*$/.test(o.codexModel)){this.showToast('Default Codex model may only contain letters, digits, ".", "_", "-" and "/"',"error"),document.getElementById("appSettingsCodexModel")?.focus();return}t.showTokenCount!==void 0&&(o.showTokenCount=t.showTokenCount),t.showCost!==void 0&&(o.showCost=t.showCost),t.shortcutOverrides!==void 0&&(o.shortcutOverrides=t.shortcutOverrides);const i=this._settingsReadOnly(),a=i&&this._keepServerSyncedSettings(o,t);if(this.saveAppSettingsToStorage(o),this._updateLocalEchoState(),this.applyTerminalFontFamily?.(o.terminalFontFamily),this.applyTerminalFontWeights?.(o),!s&&o.webglRendererEnabled)try{localStorage.removeItem("codeman-webgl-disabled")}catch{}const l={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(l);const d={enabled:document.getElementById("appSettingsNotifEnabled").checked,browserNotifications:document.getElementById("appSettingsNotifBrowser").checked,audioAlerts:document.getElementById("appSettingsNotifAudio").checked,stuckThresholdMs:(parseInt(document.getElementById("appSettingsNotifStuckMins").value)||10)*6e4,toastDurationMs:(parseInt(document.getElementById("appSettingsNotifToastSecs").value)||3)*1e3,browserAutoCloseMs:(parseInt(document.getElementById("appSettingsNotifBrowserSecs").value)||8)*1e3,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=this.notificationManager.normalizePreferences(d),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(o.extendedKeyboardBar?"extended":"simple");const c=this.planUsageCollectionFlip(t,o.showPlanUsageLimits),{localEchoEnabled:r,cjkInputEnabled:u,extendedKeyboardBar:p,skin:m,language:g,showPlanUsageLimits:f,showAttachmentsButton:h,showFileViewerButton:y,showSplitButton:b,showTileGridButton:S,webglRendererEnabled:E,terminalWheelLocalScrollback:w,autoCopySelection:v,copyStripMargin:B,terminalFontFamily:I,terminalFontWeight:k,terminalFontWeightBold:M,showSessionButton:$,showAwayDigestButton:L,showCronButton:H,showGitStatus:A,gitStatusTree:D,gitStatusMaxRepos:P,gitStatusTimeoutSeconds:O,showTabDetachButton:R,tileDetachEnabled:x,mobileOverviewEnabled:W,sessionLineageLines:F,shortcutOverrides:K,...j}=o;let T="",U=!1;try{const C=i?null:await this._apiPut("/api/settings",{...j,...c!==void 0?{showPlanUsageLimits:c}:{},notificationPreferences:d,voiceSettings:l}),_=!i&&await this._noteSettingsWriteRefusal(C);if(_&&(this._keepServerSyncedSettings(o,t),this.saveAppSettingsToStorage(o)),!_&&o.tunnelEnabled&&await this._handleTunnelEnableRefusal(C)){o.tunnelEnabled=!1,this.saveAppSettingsToStorage(o);const N=document.getElementById("appSettingsTunnelEnabled");N&&(N.checked=!1),e||this.closeAppSettings();return}U=!!C?.ok;const V=await this.saveModelConfigFromSettings()===!0;T=this._webhookPending()?await this.saveWebhook():"",T?this.showToast(`Settings saved, but not the webhook: ${T}`,"warning"):a||V||_?this.showToast("Saved on this device. Server-wide settings can only be changed by an admin.","warning"):this.showToast(e?"Settings applied":"Settings saved","success"),o.tunnelEnabled&&!i&&!_&&this.showToast("Tunnel starting \u2014 QR code will appear when ready...","info")}catch{this.showToast("Settings saved locally","warning")}e&&U&&this._refreshSettingsAfterApply(o),T?document.getElementById("webhookGroup")?.scrollIntoView({block:"center"}):e||this.closeAppSettings(),VoiceInput.refreshClaudeStatus(),(o.gestureControlEnabled??!1)!==n&&(this.showToast(o.gestureControlEnabled?"Enabling gesture control \u2014 reloading\u2026":"Disabling gesture control \u2014 reloading\u2026","info"),setTimeout(()=>location.reload(),400))},_settingsReadOnly(){if(this._settingsWriteForbidden===!0)return!0;const e=typeof window<"u"&&window.__codemanUser||{};return!!(e.multiUser&&e.role!=="admin")},async _noteSettingsWriteRefusal(e){if(!e||e.status!==403)return!1;let t=null;try{t=await(typeof e.clone=="function"?e.clone():e).json()}catch{return!1}return t?.errorCode!=="FORBIDDEN"?!1:(this._settingsWriteForbidden=!0,!0)},_ownSettingsKey(){return`codeman:own-settings:${(typeof window<"u"&&window.__codemanUser||{}).username||""}`},_readOwnSettings(){try{const e=JSON.parse(localStorage.getItem(this._ownSettingsKey())||"{}");return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}},_rememberOwnSetting(e,t){try{const n=this._readOwnSettings();n[e]=t,localStorage.setItem(this._ownSettingsKey(),JSON.stringify(n))}catch{}},_applyOwnSettings(){if(!this._settingsReadOnly())return;const e=this._readOwnSettings();if(Array.isArray(e.respawnPresets)){this._serverRespawnPresets=e.respawnPresets;try{localStorage.setItem("codeman-respawn-presets",JSON.stringify(e.respawnPresets))}catch{}}if(typeof e.runMode=="string"&&e.runMode){this.runMode=e.runMode;try{localStorage.setItem("codeman_runMode",e.runMode)}catch{}this._applyRunMode?.()}},_captureSettingsFormBaseline(){if(this._settingsFormBaseline=null,!this._settingsReadOnly())return;this._readSettingsFormOnce=!0;let e;try{e=this.saveAppSettings()}finally{this._readSettingsFormOnce=!1}Promise.resolve(e).then(t=>{this._settingsFormBaseline=t&&typeof t=="object"?t:null}).catch(()=>{})},_keepServerSyncedSettings(e,t){const n=this._displaySettingKeySet(),s=this._settingsFormBaseline||t||{};let o=!1;for(const i of Object.keys(e))n.has(i)||i==="shortcutOverrides"||(i in s&&JSON.stringify(e[i])!==JSON.stringify(s[i])&&(o=!0),t&&i in t?e[i]=t[i]:delete e[i]);return o},_refreshSettingsAfterApply(e){this._mcpSyncSavedOn=e.mcpSyncEnabled===!0;const t=this.$("mcpSyncResult");this._mcpSyncSavedOn&&t&&t.dataset?.hint==="save-first"&&(t.style.display="none",t.innerHTML=""),this.applyMcpSyncVisibility(),this.applyCustomModelEndpointsVisibility(),this.applyCliManagementVisibility(),this._applyDoctorAdminGate()},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"),d=document.getElementById("appSettingsModelTest"),c=document.getElementById("appSettingsModelReview");a&&(a.value=i.explore||""),l&&(l.value=i.implement||""),d&&(d.value=i.test||""),c&&(c.value=i.review||"")}}catch(e){console.warn("Failed to load model config:",e)}this._modelConfigBaseline=JSON.stringify(this._modelConfigFromSettingsForm())},_modelConfigFromSettingsForm(){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={};return n?.value&&(a.explore=n.value),s?.value&&(a.implement=s.value),o?.value&&(a.test=o.value),i?.value&&(a.review=i.value),{defaultModel:e?.value||"",showRecommendations:t?.checked??!0,agentTypeOverrides:a}},async saveModelConfigFromSettings(){const e=this._modelConfigFromSettingsForm();if(this._settingsReadOnly()){const t=this._modelConfigBaseline;return typeof t=="string"&&JSON.stringify(e)!==t}try{await fetch("/api/execution/model-config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(t){console.warn("Failed to save model config:",t)}},applyCustomModelEndpointsVisibility(){const e=document.getElementById("appSettingsCustomModelEndpoints").checked,t=document.getElementById("customModelEndpointsBody");t&&(t.style.display=e?"":"none"),e?this.loadCustomModelEndpointsForSettings():this.closeCustomModelHostEditor(),this._applyCustomModelAdminGate()},_applyCustomModelAdminGate(){const e=document.getElementById("customModelHostAddBtn");if(!e)return;const t=window.__codemanUser||{},n=t.multiUser&&t.role!=="admin";e.style.display=n?"none":""},async loadCustomModelEndpointsForSettings(){const e=await this._apiJson("/api/model-endpoints");this._customModelHosts=Array.isArray(e)?e:[],this.renderCustomModelHostsList()},renderCustomModelHostsList(){const e=document.getElementById("customModelHostsList");if(!e)return;const t=this._customModelHosts||[];if(t.length===0){e.innerHTML='<p class="set-group-hint">No endpoints yet. Add one below to point a harness at a local or cloud OpenAI-compatible server.</p>';return}e.innerHTML=t.map(n=>{const s=(n.models||[]).length,o=s===0?"No models discovered yet":`${s} model${s===1?"":"s"}${n.defaultModelId?` \xB7 default: ${escapeHtml(n.defaultModelId)}`:" \xB7 no default set"}`,i=escapeHtml(JSON.stringify(n.id));return`
|
|
64
64
|
<div class="set-row" data-endpoint-id="${escapeHtml(n.id)}">
|
|
65
65
|
<div class="set-row-text">
|
|
66
66
|
<span class="set-row-label">${escapeHtml(n.label)}</span>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|