aicodeman 1.33.2 → 1.34.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/dist/config/cli-registry/schema.d.ts +18 -0
- package/dist/config/cli-registry/schema.d.ts.map +1 -1
- package/dist/config/cli-registry/schema.js +27 -0
- 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 +35 -0
- package/dist/config/cli-registry/stock.js.map +1 -1
- package/dist/config/cli-registry/types.d.ts +33 -0
- package/dist/config/cli-registry/types.d.ts.map +1 -1
- package/dist/hooks-config.d.ts.map +1 -1
- package/dist/hooks-config.js +5 -1
- package/dist/hooks-config.js.map +1 -1
- package/dist/mcp-sync.d.ts +105 -0
- package/dist/mcp-sync.d.ts.map +1 -0
- package/dist/mcp-sync.js +619 -0
- package/dist/mcp-sync.js.map +1 -0
- package/dist/mux-interface.d.ts +4 -0
- package/dist/mux-interface.d.ts.map +1 -1
- package/dist/session-cli-builder.d.ts +20 -1
- package/dist/session-cli-builder.d.ts.map +1 -1
- package/dist/session-cli-builder.js +33 -3
- package/dist/session-cli-builder.js.map +1 -1
- package/dist/session-cli-registry-bridge.d.ts +2 -0
- package/dist/session-cli-registry-bridge.d.ts.map +1 -1
- package/dist/session-cli-registry-bridge.js +15 -8
- package/dist/session-cli-registry-bridge.js.map +1 -1
- package/dist/session.d.ts +19 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +29 -2
- package/dist/session.js.map +1 -1
- package/dist/tmux-manager.d.ts +2 -0
- 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/index.d.ts +3 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +3 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/mcp-sync.d.ts +40 -0
- package/dist/types/mcp-sync.d.ts.map +1 -0
- package/dist/types/mcp-sync.js +8 -0
- package/dist/types/mcp-sync.js.map +1 -0
- package/dist/types/push.d.ts +37 -2
- package/dist/types/push.d.ts.map +1 -1
- package/dist/types/push.js +10 -3
- package/dist/types/push.js.map +1 -1
- package/dist/types/session.d.ts +34 -1
- package/dist/types/session.d.ts.map +1 -1
- package/dist/types/session.js +25 -1
- package/dist/types/session.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.cf0db8ce.js +43 -0
- package/dist/web/public/app.cf0db8ce.js.br +0 -0
- package/dist/web/public/app.cf0db8ce.js.gz +0 -0
- package/dist/web/public/approvals-ui.js.gz +0 -0
- package/dist/web/public/{constants.cc927eb8.js → constants.d95fade9.js} +19 -2
- package/dist/web/public/constants.d95fade9.js.br +0 -0
- package/dist/web/public/constants.d95fade9.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/home-sessions.js.gz +0 -0
- package/dist/web/public/host-wake-ui.js.gz +0 -0
- package/dist/web/public/i18n.398b8331.js +1 -0
- package/dist/web/public/i18n.398b8331.js.br +0 -0
- package/dist/web/public/i18n.398b8331.js.gz +0 -0
- package/dist/web/public/image-input.a216cf9e.js.gz +0 -0
- package/dist/web/public/index.html +125 -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.c1e7c7b7.js.gz +0 -0
- package/dist/web/public/mobile-handlers.23a85db1.js.gz +0 -0
- package/dist/web/public/mobile-ime-preview.2dbaf262.js +1 -0
- package/dist/web/public/mobile-ime-preview.2dbaf262.js.br +0 -0
- package/dist/web/public/mobile-ime-preview.2dbaf262.js.gz +0 -0
- package/dist/web/public/mobile-overview.js.gz +0 -0
- package/dist/web/public/mobile.1aa4952d.css.gz +0 -0
- package/dist/web/public/notification-manager.50bb87d8.js.gz +0 -0
- package/dist/web/public/orchestrator-panel.js.gz +0 -0
- package/dist/web/public/{panels-ui.67646701.js → panels-ui.6a5898d9.js} +69 -67
- package/dist/web/public/panels-ui.6a5898d9.js.br +0 -0
- package/dist/web/public/panels-ui.6a5898d9.js.gz +0 -0
- package/dist/web/public/ralph-panel.b350e2ef.js.gz +0 -0
- package/dist/web/public/{ralph-wizard.13a1831e.js → ralph-wizard.b6c0dd19.js} +2 -0
- package/dist/web/public/ralph-wizard.b6c0dd19.js.br +0 -0
- package/dist/web/public/{ralph-wizard.13a1831e.js.gz → 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.ff0dae4c.js.gz +0 -0
- package/dist/web/public/sanitize-html.e7147e76.js +1 -0
- package/dist/web/public/sanitize-html.e7147e76.js.br +0 -0
- package/dist/web/public/sanitize-html.e7147e76.js.gz +0 -0
- package/dist/web/public/session-lineage.js +27 -11
- package/dist/web/public/session-lineage.js.br +0 -0
- package/dist/web/public/session-lineage.js.gz +0 -0
- package/dist/web/public/{session-ui.7575a231.js → session-ui.bf66c13b.js} +4 -4
- package/dist/web/public/session-ui.bf66c13b.js.br +0 -0
- package/dist/web/public/session-ui.bf66c13b.js.gz +0 -0
- package/dist/web/public/{settings-ui.c68e7f59.js → settings-ui.331d3b1d.js} +12 -10
- package/dist/web/public/settings-ui.331d3b1d.js.br +0 -0
- package/dist/web/public/settings-ui.331d3b1d.js.gz +0 -0
- package/dist/web/public/styles.8c485d26.css +1 -0
- package/dist/web/public/styles.8c485d26.css.br +0 -0
- package/dist/web/public/styles.8c485d26.css.gz +0 -0
- package/dist/web/public/subagent-windows.e6ca799f.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.4e0ed50c.js +1 -0
- package/dist/web/public/tab-layout-browser.4e0ed50c.js.br +0 -0
- package/dist/web/public/tab-layout-browser.4e0ed50c.js.gz +0 -0
- package/dist/web/public/tab-rail-resize.dcdc5772.js.gz +0 -0
- package/dist/web/public/terminal-keycode229-recovery.fb91b25b.js.gz +0 -0
- package/dist/web/public/terminal-split.js +248 -15
- package/dist/web/public/terminal-split.js.br +0 -0
- package/dist/web/public/terminal-split.js.gz +0 -0
- package/dist/web/public/terminal-ui.a4535311.js +2 -0
- package/dist/web/public/terminal-ui.a4535311.js.br +0 -0
- package/dist/web/public/terminal-ui.a4535311.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/upload.html.gz +0 -0
- package/dist/web/public/vendor/dompurify.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.bd6882b8.js → xterm-predictive-echo.ae5e3d5d.js} +1 -1
- package/dist/web/public/vendor/{xterm-predictive-echo.bd6882b8.js.br → xterm-predictive-echo.ae5e3d5d.js.br} +0 -0
- package/dist/web/public/vendor/{xterm-predictive-echo.bd6882b8.js.gz → xterm-predictive-echo.ae5e3d5d.js.gz} +0 -0
- package/dist/web/public/vendor/xterm-zerolag-input.bbb5f84c.js +4 -0
- package/dist/web/public/vendor/xterm-zerolag-input.bbb5f84c.js.br +0 -0
- package/dist/web/public/vendor/xterm-zerolag-input.bbb5f84c.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.c4b51eb6.js.gz +0 -0
- package/dist/web/public/voice-pcm-worklet.js.gz +0 -0
- package/dist/web/public/webview-tabs.js +36 -14
- package/dist/web/public/webview-tabs.js.br +0 -0
- package/dist/web/public/webview-tabs.js.gz +0 -0
- package/dist/web/reboot-restore-registry.d.ts +2 -1
- package/dist/web/reboot-restore-registry.d.ts.map +1 -1
- package/dist/web/reboot-restore-registry.js +2 -1
- package/dist/web/reboot-restore-registry.js.map +1 -1
- package/dist/web/routes/file-routes.d.ts.map +1 -1
- package/dist/web/routes/file-routes.js +2 -1
- package/dist/web/routes/file-routes.js.map +1 -1
- package/dist/web/routes/index.d.ts +2 -0
- package/dist/web/routes/index.d.ts.map +1 -1
- package/dist/web/routes/index.js +2 -0
- package/dist/web/routes/index.js.map +1 -1
- package/dist/web/routes/mcp-sync-routes.d.ts +29 -0
- package/dist/web/routes/mcp-sync-routes.d.ts.map +1 -0
- package/dist/web/routes/mcp-sync-routes.js +83 -0
- package/dist/web/routes/mcp-sync-routes.js.map +1 -0
- package/dist/web/routes/ralph-routes.d.ts.map +1 -1
- package/dist/web/routes/ralph-routes.js +2 -1
- package/dist/web/routes/ralph-routes.js.map +1 -1
- package/dist/web/routes/reboot-restore-routes.d.ts.map +1 -1
- package/dist/web/routes/reboot-restore-routes.js +2 -0
- package/dist/web/routes/reboot-restore-routes.js.map +1 -1
- package/dist/web/routes/session-routes.d.ts.map +1 -1
- package/dist/web/routes/session-routes.js +40 -17
- package/dist/web/routes/session-routes.js.map +1 -1
- package/dist/web/routes/webhook-routes.d.ts +21 -0
- package/dist/web/routes/webhook-routes.d.ts.map +1 -0
- package/dist/web/routes/webhook-routes.js +87 -0
- package/dist/web/routes/webhook-routes.js.map +1 -0
- package/dist/web/schemas.d.ts +47 -2
- package/dist/web/schemas.d.ts.map +1 -1
- package/dist/web/schemas.js +64 -0
- package/dist/web/schemas.js.map +1 -1
- package/dist/web/server.d.ts +4 -0
- package/dist/web/server.d.ts.map +1 -1
- package/dist/web/server.js +55 -25
- package/dist/web/server.js.map +1 -1
- package/dist/webhook-notify.d.ts +71 -0
- package/dist/webhook-notify.d.ts.map +1 -0
- package/dist/webhook-notify.js +282 -0
- package/dist/webhook-notify.js.map +1 -0
- package/package.json +2 -1
- package/skills/codeman/SKILL.md +26 -8
- package/skills/codeman/preamble.sh +16 -4
- package/skills/codeman/reference/endpoints.md +11 -3
- package/skills/codeman/reference/recipes.md +1 -1
- package/dist/web/public/app.91131d2c.js +0 -43
- package/dist/web/public/app.91131d2c.js.br +0 -0
- package/dist/web/public/app.91131d2c.js.gz +0 -0
- package/dist/web/public/constants.cc927eb8.js.br +0 -0
- package/dist/web/public/constants.cc927eb8.js.gz +0 -0
- package/dist/web/public/i18n.f094d01f.js +0 -1
- package/dist/web/public/i18n.f094d01f.js.br +0 -0
- package/dist/web/public/i18n.f094d01f.js.gz +0 -0
- package/dist/web/public/panels-ui.67646701.js.br +0 -0
- package/dist/web/public/panels-ui.67646701.js.gz +0 -0
- package/dist/web/public/ralph-wizard.13a1831e.js.br +0 -0
- package/dist/web/public/sanitize-html.bc7078d6.js +0 -1
- package/dist/web/public/sanitize-html.bc7078d6.js.br +0 -0
- package/dist/web/public/sanitize-html.bc7078d6.js.gz +0 -0
- package/dist/web/public/session-ui.7575a231.js.br +0 -0
- package/dist/web/public/session-ui.7575a231.js.gz +0 -0
- package/dist/web/public/settings-ui.c68e7f59.js.br +0 -0
- package/dist/web/public/settings-ui.c68e7f59.js.gz +0 -0
- package/dist/web/public/styles.3fe3312d.css +0 -1
- package/dist/web/public/styles.3fe3312d.css.br +0 -0
- package/dist/web/public/styles.3fe3312d.css.gz +0 -0
- package/dist/web/public/terminal-ui.d5223c0e.js +0 -2
- package/dist/web/public/terminal-ui.d5223c0e.js.br +0 -0
- package/dist/web/public/terminal-ui.d5223c0e.js.gz +0 -0
- package/dist/web/public/vendor/xterm-zerolag-input.6fee72f2.js +0 -4
- package/dist/web/public/vendor/xterm-zerolag-input.6fee72f2.js.br +0 -0
- package/dist/web/public/vendor/xterm-zerolag-input.6fee72f2.js.gz +0 -0
|
Binary file
|
|
Binary file
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";(function(e){const t=/^\x1b\[[\?>=]?[\d;]*[cnR]$/,i=/^\x1b\][\d;]*[^\x07\x1b]*(?:\x07|\x1b\\)$/,s=/^\x1b\[<\d+;\d+;\d+[Mm]$/,n=/^\x1b\[M[\s\S]{3}$/,o=/^\x1b\[[IO]$/,c=["input","textarea","select","button","a[href]",'[contenteditable=""]','[contenteditable="true"]','[tabindex]:not([tabindex="-1"])',".keyboard-accessory-bar",".path-picker-overlay"].join(","),f=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\x1b\[[0-9;?<>=!]*[ -/]*[@-~]|\x1b[()#][0-9A-Za-z]|\x1b[=>78M]/g,b="\x1B[5~",_="\x1B[6~",E=.5,r=3,p=4,d=/^\x1b(?:\[(?:[ABCDHF]|1;[2-8][ABCDHF]|[1-8](?:;[2-8])?~)|O[ABCDHF])$/,S="\x1B[200~";function g(v){return d.test(v)}const y=/^› /;function C(v){const A=Array.from(v);if(A.length===1){const P=A[0].codePointAt(0);return P===127?"backspace":P>=32?"char":"clear"}return v.charCodeAt(0)===27?"clear":v.charCodeAt(0)>=32?"text":"clear"}function w(v){try{const A=v.buffer.active,P=A.getLine(A.baseY+A.cursorY);return!!P&&y.test(P.translateToString(!0))}catch{return!1}}function I(v){return t.test(v)||i.test(v)}function L(v){return I(v)}function M(v){return o.test(v)||s.test(v)||n.test(v)}const x={og:{background:"#0d0d0d",foreground:"#e0e0e0",cursor:"#e0e0e0",cursorAccent:"#0d0d0d",selectionBackground:"rgba(255,255,255,0.3)",black:"#0d0d0d",red:"#ff6b6b",green:"#51cf66",yellow:"#ffd43b",blue:"#339af0",magenta:"#cc5de8",cyan:"#22b8cf",white:"#e0e0e0",brightBlack:"#495057",brightRed:"#ff8787",brightGreen:"#69db7c",brightYellow:"#ffe066",brightBlue:"#5c7cfa",brightMagenta:"#da77f2",brightCyan:"#66d9e8",brightWhite:"#ffffff"},"daylight-green":{background:"#161b23",foreground:"#dfe6ef",cursor:"#2fd3aa",cursorAccent:"#161b23",selectionBackground:"rgba(47,211,170,0.22)",black:"#161b23",red:"#ff8585",green:"#34d8a0",yellow:"#f0c25a",blue:"#5cc6e8",magenta:"#c79af2",cyan:"#2bcbbb",white:"#dfe6ef",brightBlack:"#5b6675",brightRed:"#ffa0a0",brightGreen:"#5fe6b8",brightYellow:"#ffd884",brightBlue:"#82d4ee",brightMagenta:"#d6b3f7",brightCyan:"#5ee0d4",brightWhite:"#f3f6fa"},"daylight-blue":{background:"#161b23",foreground:"#dfe6ef",cursor:"#38b6f0",cursorAccent:"#161b23",selectionBackground:"rgba(56,182,240,0.22)",black:"#161b23",red:"#ff8585",green:"#34d8a0",yellow:"#f0c25a",blue:"#5cc6e8",magenta:"#c79af2",cyan:"#2bcbbb",white:"#dfe6ef",brightBlack:"#5b6675",brightRed:"#ffa0a0",brightGreen:"#5fe6b8",brightYellow:"#ffd884",brightBlue:"#82d4ee",brightMagenta:"#d6b3f7",brightCyan:"#5ee0d4",brightWhite:"#f3f6fa"},"paper-gray":{background:"#f6f8fa",foreground:"#1f2328",cursor:"#0969da",cursorAccent:"#ffffff",selectionBackground:"rgba(9,105,218,0.2)",black:"#24292f",red:"#cf222e",green:"#1a7f37",yellow:"#9a6700",blue:"#0969da",magenta:"#8250df",cyan:"#1b7c83",white:"#59636e",brightBlack:"#6e7781",brightRed:"#a40e26",brightGreen:"#116329",brightYellow:"#7d4e00",brightBlue:"#0550ae",brightMagenta:"#6639ba",brightCyan:"#116b75",brightWhite:"#1f2328"},"solarized-light":{background:"#fdf6e3",foreground:"#586e75",cursor:"#147ba3",cursorAccent:"#fdf6e3",selectionBackground:"rgba(38,139,210,0.2)",black:"#eee8d5",red:"#dc322f",green:"#758600",yellow:"#9b7800",blue:"#147ba3",magenta:"#d33682",cyan:"#2a9189",white:"#073642",brightBlack:"#93a1a1",brightRed:"#cb4b16",brightGreen:"#657b83",brightYellow:"#586e75",brightBlue:"#268bd2",brightMagenta:"#6c71c4",brightCyan:"#2aa198",brightWhite:"#002b36"},"catppuccin-latte":{background:"#eff1f5",foreground:"#4c4f69",cursor:"#1e66f5",cursorAccent:"#ffffff",selectionBackground:"rgba(30,102,245,0.18)",black:"#5c5f77",red:"#d20f39",green:"#3b8f2b",yellow:"#a86605",blue:"#1e66f5",magenta:"#8839ef",cyan:"#177f86",white:"#6c6f85",brightBlack:"#7c7f93",brightRed:"#b50930",brightGreen:"#2f7622",brightYellow:"#8b5604",brightBlue:"#174fbf",brightMagenta:"#6f2bc5",brightCyan:"#116b71",brightWhite:"#4c4f69"},"rose-pine-dawn":{background:"#faf4ed",foreground:"#575279",cursor:"#286983",cursorAccent:"#fffaf3",selectionBackground:"rgba(40,105,131,0.2)",black:"#575279",red:"#b4637a",green:"#286983",yellow:"#96681f",blue:"#477f91",magenta:"#907aa9",cyan:"#3f7f8b",white:"#6e6a86",brightBlack:"#797593",brightRed:"#984d66",brightGreen:"#1f5266",brightYellow:"#7d5417",brightBlue:"#386b7c",brightMagenta:"#765f90",brightCyan:"#326b76",brightWhite:"#575279"}},O=new Set(["paper-gray","solarized-light","catppuccin-latte","rose-pine-dawn"]);function B(){return typeof document<"u"&&document.documentElement.dataset.skin||"daylight-blue"}function D(){const v=B();return x[v]||x["daylight-blue"]}function T(v=B()){return O.has(v)}e.CodemanTerminalInput={isTerminalQueryResponse:I,shouldSuppressTerminalQueryResponse:L,isTerminalFocusOrMouseReport:M,isComposerNavKey:g,classifyPredictInput:C,isCodexComposerRow:w,CODEX_COMPOSER_ROW_RE:y,BRACKETED_PASTE_START:S,USER_SCROLL_STICKY_SUPPRESS_MS:1500,TOUCH_COMPAT_MOUSE_SUPPRESS_MS:450,REPLAY_ESCAPE_RE:f,KEY_PAGE_UP:b,KEY_PAGE_DOWN:_,PAGE_KEY_SCREEN_FRACTION:E,PAGE_KEY_MAX_PER_BATCH:r,TUI_PROMPT_DEFAULT_ROWS_FROM_BOTTOM:p,MOBILE_KEYBOARD_DISMISS_EXEMPT_SELECTOR:c,MOBILE_KEYBOARD_DISMISS_TAP_SLOP:8,TOUCH_SELECT_LONG_PRESS_MS:350,TOUCH_SELECT_FOCUS_GUARD_MS:800},e.CODEMAN_XTERM_THEMES=x,e.codemanCurrentXtermTheme=D,e.codemanCurrentSkinIsLight=T})(window),Object.assign(CodemanApp.prototype,{_destroyKeyCode229Recovery(){try{this._keyCode229Recovery?.destroy?.()}catch{}this._keyCode229Recovery=null},initTerminal(){const e=parseInt(localStorage.getItem("codeman-scrollback")),t=Number.isFinite(e)&&e>0?Math.max(e,DEFAULT_SCROLLBACK):DEFAULT_SCROLLBACK;this._destroyKeyCode229Recovery();const i=this.loadAppSettingsFromStorage?.()||{};if(this.terminal=new Terminal({theme:{...window.codemanCurrentXtermTheme()},fontFamily:window.CodemanTerminalFont.resolve(i.terminalFontFamily),...window.CodemanTerminalFont.resolveWeights(i),fontSize:MobileDetection.getDeviceType()==="mobile"?10:14,lineHeight:1.2,cursorBlink:!1,cursorStyle:"block",minimumContrastRatio:window.codemanCurrentSkinIsLight()?4.5:1,scrollback:t,allowTransparency:!0,allowProposedApi:!0}),this.fitAddon=new FitAddon.FitAddon,this.terminal.loadAddon(this.fitAddon),this._xtermSnapshots=new Map,typeof SerializeAddon<"u")try{this._serializeAddon=new SerializeAddon.SerializeAddon,this.terminal.loadAddon(this._serializeAddon)}catch{this._serializeAddon=null}if(typeof Unicode11Addon<"u")try{const r=new Unicode11Addon.Unicode11Addon;this.terminal.loadAddon(r),this.terminal.unicode.activeVersion="11"}catch{}const s=document.getElementById("terminalContainer");this.terminal.open(s),this._installMobileTapMouseGuard(),this._installShiftDragSelection(),this._installTouchSelectionFocusGuard(),this.terminal.attachCustomKeyEventHandler(r=>{try{this._keyCode229Recovery?.handleKeyEvent?.(r)}catch{}if(r.isComposing||r.key==="Process"||r.keyCode===229)return!0;if(r.altKey&&!r.ctrlKey&&!r.shiftKey&&/^(Digit[1-9]|BracketLeft|BracketRight|KeyK)$/.test(r.code||"")||r.type==="keydown"&&this.shouldOpenCommandPaletteFromShortcut?.(r))return!1;if(this.shouldCopyTerminalSelectionFromShortcut?.(r)){const p=this.terminal?.hasSelection?.()?this.terminal.getSelection():"";return this.cleanedTerminalSelection(p).trim()?(r.preventDefault(),this.copyTerminalSelection(p),!1):(this.terminal?.hasSelection?.()&&(this.terminal.clearSelection?.(),this.showToast("Nothing to copy","warning")),r.shiftKey?(r.preventDefault(),!1):!0)}if(r.type==="keydown"&&this.shouldToggleSessionSidebarFromShortcut?.(r))return!1;if((r.ctrlKey||r.metaKey)&&r.key==="v"&&r.type==="keydown")return this.activeSessionId&&this._handleImagePaste&&this._handleImagePaste(),!1;if(r.type==="keydown"&&r.key.toLowerCase()==="z"&&r.ctrlKey&&!r.altKey&&!r.metaKey&&!r.shiftKey){const p=this.activeSessionId?this.sessions.get(this.activeSessionId):null;if(p&&p.mode!=="shell")return r.preventDefault(),!1}if(r.key==="Enter"&&(r.shiftKey||r.ctrlKey)&&r.type==="keydown"){if(this.activeSessionId)if(this._localEchoEnabled){const p=this._localEchoOverlay?.pendingText||"";this._localEchoOverlay?.clear(),this._localEchoOverlay?.suppressBufferDetection(),this._flushedOffsets?.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId),p&&(this._pendingInput+=p,_()),setTimeout(()=>{fetch(`/api/sessions/${this.activeSessionId}/send-key`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:r.ctrlKey?"C-Enter":"S-Enter"})})},p?80:0)}else fetch(`/api/sessions/${this.activeSessionId}/send-key`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:r.ctrlKey?"C-Enter":"S-Enter"})});return!1}return!0}),this._webglAddon=null;const n=new URLSearchParams(location.search),o=(()=>{try{const r=localStorage.getItem("codeman-webgl-disabled");if(!r)return!1;const{at:p}=JSON.parse(r);return Date.now()-p>WEBGL_FALLBACK.STICKY_EXPIRY_MS?(localStorage.removeItem("codeman-webgl-disabled"),!1):!0}catch{return!1}})(),l=this.loadAppSettingsFromStorage(),a=this.getDefaultSettings(),h=l.webglRendererEnabled??a.webglRendererEnabled,{skip:u,clearSticky:m}=shouldSkipWebGL({deviceType:MobileDetection.getDeviceType(),noWebglParam:n.has("nowebgl"),forceParam:n.get("webgl")==="force",stickyDisabled:o,userPrefEnabled:h});if(m)try{localStorage.removeItem("codeman-webgl-disabled")}catch{}if(u&&o&&console.log("[CRASH-DIAG] WebGL sticky-disabled from prior stalls \u2014 DOM renderer in use. Re-enable: ?webgl=force"),!u)if(typeof WebglAddon<"u")this._initWebGL();else{const r=document.createElement("script");r.src="vendor/xterm-addon-webgl.min.js",r.onload=()=>this._initWebGL(),r.onerror=()=>console.warn("[CRASH-DIAG] Failed to load WebGL addon \u2014 using canvas renderer"),document.head.appendChild(r)}this._localEchoOverlay=new LocalEchoOverlay(this.terminal),this._predictiveEcho=typeof PredictiveEchoOverlay<"u"?new PredictiveEchoOverlay(this.terminal):null,this._predictiveEcho?.setPredictWhen(r=>window.CodemanTerminalInput.isCodexComposerRow(r)),MobileDetection.isTouchDevice()&&(this.terminal.onCursorMove(()=>this._syncMobileHelperTextareaToCursor()),this.terminal.onRender(()=>this._syncMobileHelperTextareaToCursor())),this.terminal.onRender(()=>{this._lastRenderAt=Date.now()}),this._startRenderLivenessWatchdog(),this._cjkInput=null,typeof CjkInput<"u"&&(this._cjkInput=CjkInput.init({send:r=>{this._handleCjkInput(r)}}));const c=this.terminal.focus.bind(this.terminal);this.terminal.focus=()=>{const r=document.getElementById("cjkInput");r?.classList.contains("cjk-input-visible")?r.focus():c()},MobileDetection.getDeviceType()==="mobile"&&document.body.classList.contains("safari-browser")?requestAnimationFrame(()=>{this.syncTerminalGeometry(),requestAnimationFrame(()=>this.syncTerminalGeometry())}):this.syncTerminalGeometry(),this._terminalFontReady=this._awaitTerminalFont(),this.registerFilePathLinkProvider(),this.terminal.onSelectionChange?.(()=>{if(!this.terminal?.hasSelection?.()){this._touchSelecting=!1,this._touchSelectionActive=!1,this._touchSelectionAnchor=null,this._hideTouchSelectionBar(),this._autoCopyPending=!1;return}this._autoCopyPending=!0}),this._autoCopyListenerInstalled||(this._autoCopyListenerInstalled=!0,document.addEventListener("mouseup",()=>this._flushAutoCopySelection())),s.addEventListener("wheel",r=>{const p=this.terminal?.modes?.mouseTrackingMode;if(p&&p!=="none"||this.terminal?.buffer?.active?.type==="alternate")return;if(r.preventDefault(),r.stopPropagation(),this._shouldForwardWheelToApp(r)){this._logScrollRouting("forward-sgr"),this._forwardScrollToApp(r.clientX,r.clientY,this._wheelScrollLines(r));return}const d=this._wheelScrollLinesFloat(r);this._maybePageCliTranscript(r,d)||(this._logScrollRouting("local-scrollback"),this._noteTerminalUserScroll(d),this._smoothScrollBy(d))},{passive:!1,capture:!0});{const r=()=>this.terminal._core?._renderService?.dimensions?.css?.cell?.height||13;let p=0,d=0,S=0,g=0,y=null,C=!1;const w=R=>{const k=g?(R-g)/16.67:1;if(g=R,!C&&Math.abs(S)>.3){const F=Math.round(S/r());F!==0&&(this._shouldForwardWheelToApp({shiftKey:!1})?this._forwardScrollToApp(p,d,F):this._maybePageCliTranscript({shiftKey:!1},F)||(this.terminal.scrollLines(F),this._maybeLoadMoreHistoryOnScroll(F))),S*=.92,y=requestAnimationFrame(w)}else C?y=requestAnimationFrame(w):(y=null,S=0)};let I=0,L=!1,M=null,x=0,O=0,B=0,D=0,T=null;const v=()=>s.classList.contains("term-overflows-x")&&s.scrollWidth-s.clientWidth>1;let A=!1,P=null;const H=window.CodemanTerminalInput.MOBILE_KEYBOARD_DISMISS_TAP_SLOP;s.addEventListener("touchstart",R=>{if(!R.target?.closest?.(".term-select-bar")&&(R.touches.length!==1&&(clearTimeout(M),M=null),R.touches.length===1)){p=R.touches[0].clientX,d=R.touches[0].clientY,B=d,D=p,T=null,S=0,I=0,C=!0,L=!1,A=this._isMobileTerminalInputFocused();const k=this._classifyMobileTerminalTap(p,d);P={x:p,y:d,intent:k},k==="content"&&(R.preventDefault(),this._blurMobileTerminalInput()),x=p,O=d,clearTimeout(M),M=setTimeout(()=>{M=null,this._beginTouchSelection(x,O)},window.CodemanTerminalInput.TOUCH_SELECT_LONG_PRESS_MS),g=0,y&&(cancelAnimationFrame(y),y=null)}},{passive:!1}),s.addEventListener("touchmove",R=>{if(this._touchSelecting){R.preventDefault();const k=R.touches[0];k&&this._extendTouchSelection(k.clientX,k.clientY);return}if(M&&R.touches.length===1){const k=R.touches[0];(Math.abs(k.clientX-x)>H||Math.abs(k.clientY-O)>H)&&(clearTimeout(M),M=null)}if(R.touches.length===1&&C){const k=R.touches[0].clientY,F=R.touches[0].clientX;if(!L){const Y=Math.abs(k-B),U=Math.abs(F-D),$=v()&&U>=H;(Y>=H||$)&&(L=!0,T=$&&U>Y?"x":"y")}if(!L)return;if(R.preventDefault(),T==="x"){s.scrollLeft-=F-p,p=F,d=k;return}const W=d-k;I+=W,S=W*1.2,p=R.touches[0].clientX,d=k;const K=r(),N=Math.trunc(I/K);N!==0&&(this._shouldForwardWheelToApp({shiftKey:!1})?(this._logScrollRouting("forward-sgr"),this._forwardScrollToApp(p,d,N)):this._maybePageCliTranscript({shiftKey:!1},N)||(this._logScrollRouting("local-scrollback"),this._noteTerminalUserScroll(N),this.terminal.scrollLines(N),this._maybeLoadMoreHistoryOnScroll(N)),I-=N*K)}},{passive:!1}),s.addEventListener("touchend",R=>{if(!R.target?.closest?.(".term-select-bar")){if(clearTimeout(M),M=null,C=!1,this._touchSelecting){R.preventDefault(),S=0,this._endTouchSelectionGesture(),A=!1;return}if(!y&&Math.abs(S)>.3&&(y=requestAnimationFrame(w)),!L&&this.terminal){const k=R.changedTouches&&R.changedTouches[0];if(k){this._suppressTrustedTapMouseEvents();const F=P&&P.x===k.clientX&&P.y===k.clientY?P.intent:null;this._handleMobileTerminalTap(k,A,F)}}A=!1}},{passive:!1}),s.addEventListener("contextmenu",R=>{if(M!==null||this._touchSelecting||this._touchSelectionActive){R.preventDefault();return}if(!this.terminal?.hasSelection?.())return;const k=this.terminal.getSelection();k&&(R.preventDefault(),this.copyTerminalSelection(k))}),s.addEventListener("touchcancel",()=>{clearTimeout(M),M=null,C=!1,this._touchSelecting=!1,S=0,I=0,A=!1},{passive:!0})}s.addEventListener("click",r=>this._handleDesktopTerminalClick(r)),this._installMobileKeyboardDismiss(),this.showWelcome(),this.initImageInput(),this._chunkedWriteGen=0,this._bufferLoadSeq=0,this._bufferLoadOwner=null,this._lastUserScrollUpAt=null,this._resizeTimeout=null,this._lastResizeDims=null;const b=()=>{this._tabRailResizeOwnsObserver||(this._resizeTimeout&&clearTimeout(this._resizeTimeout),this._resizeTimeout=setTimeout(()=>{this._resizeTimeout=null,this.flickerFilterBuffer&&(this.flickerFilterTimeout&&(clearTimeout(this.flickerFilterTimeout),this.flickerFilterTimeout=null),this.flushFlickerBuffer());const r=typeof KeyboardHandler<"u"&&KeyboardHandler.keyboardVisible,p=!this.isSoloWindow&&this.detachedSessions?.has(this.activeSessionId),d=this.activeSessionId&&!r&&!p?this._geometryForResizeRequest():null;if(d){const{cols:S,rows:g}=d;if(!this._lastResizeDims||S!==this._lastResizeDims.cols||g!==this._lastResizeDims.rows){const y=this.activeSessionId?this.sessions.get(this.activeSessionId):null;y&&y.mode!=="shell"&&!this._paneWidthRefused&&this.terminal&&this.isTerminalAtBottom()&&this.terminal.write("\x1B[3J\x1B[H\x1B[2J"),this._lastResizeDims={cols:S,rows:g};const C=typeof MobileDetection<"u"&&MobileDetection.getDeviceType?MobileDetection.getDeviceType():"desktop";let w=!1;if(this._wsReady&&this._wsSessionId===this.activeSessionId)try{this._ws.send(JSON.stringify({t:"z",c:S,r:g,v:C})),w=!0}catch{}if(!w){const I=this.activeSessionId;fetch(`/api/sessions/${this.activeSessionId}/resize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cols:S,rows:g,viewportType:C})}).then(async L=>{const M=(await L.json())?.data??{};this._onPtyGeometryReport(I,M.cols,M.rows)}).catch(()=>{})}}}this.applyLineageLineSettings?.(),this.updateConnectionLines(),this._localEchoOverlay?.hasPending&&this._localEchoOverlay.rerender(),this._splitPane?.fit()},300))};window.addEventListener("resize",b),this.terminalResizeObserver&&this.terminalResizeObserver.disconnect(),this.terminalResizeObserver=new ResizeObserver(b),this.terminalResizeObserver.observe(s),this._pendingInput="",this._inputFlushTimeout=null,this._lastKeystrokeTime=0;const _=()=>{if(this._inputFlushTimeout=null,this._pendingInput&&this.activeSessionId){const r=this._pendingInput,p=this.activeSessionId;this._pendingInput="",this._sendInputAsync(p,r)}},E=r=>{if(!/^\x1b\[<\d+;\d+;\d+[Mm]$/.test(r)&&(window.cjkActive||document.activeElement?.id==="cjkInput")){const d=document.getElementById("cjkInput");d?.classList.contains("cjk-input-visible")&&document.activeElement===this.terminal.textarea&&!window.CodemanTerminalInput?.shouldSuppressTerminalQueryResponse(r)&&(_crashDiag.log("CJK regain-focus (onData swallowed input)"),d.focus());return}if(this.activeSessionId){if(window.CodemanTerminalInput?.shouldSuppressTerminalQueryResponse(r))return;typeof KeyboardAccessoryBar<"u"&&KeyboardAccessoryBar.isCtrlArmed?.()&&!window.CodemanTerminalInput?.isTerminalFocusOrMouseReport(r)&&(r=KeyboardAccessoryBar.consumeCtrl(r)),this._lastTerminalData={data:r,time:performance.now()};const d=this._localEchoEnabled&&this._echoPassthroughSessions?.has(this.activeSessionId);if(d&&(r==="\r"||r==="")&&this._echoPassthroughSessions.delete(this.activeSessionId),this._localEchoEnabled&&!d){if(r==="\x7F"){const g=this._localEchoOverlay?.removeChar();if(g==="flushed"){const{count:y,text:C}=this._localEchoOverlay.getFlushed();this._flushedOffsets?.has(this.activeSessionId)&&(y===0?(this._flushedOffsets.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId)):(this._flushedOffsets.set(this.activeSessionId,y),this._flushedTexts?.set(this.activeSessionId,C))),this._pendingInput+=r,_()}else g===!1&&(this._pendingInput+=r,_());return}if(/^[\r\n]+$/.test(r)){const g=this._localEchoOverlay?.pendingText||"";this._localEchoOverlay?.clear(),this._localEchoOverlay?.suppressBufferDetection(),this._flushedOffsets?.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId),this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null),g&&(this._pendingInput+=g,_()),setTimeout(()=>{this._pendingInput+="\r",_()},80);return}if(r.length>1&&r.charCodeAt(0)>=32){this._localEchoOverlay?.appendText(r);return}if(r.charCodeAt(0)<32){if(r.length>1&&r.charCodeAt(0)===27){if(r.startsWith(window.CodemanTerminalInput.BRACKETED_PASTE_START)){const y=!!this._localEchoOverlay?.pendingText;this._flushLocalEchoPending(),y?(_(),setTimeout(()=>{this._pendingInput+=r,_()},80)):(this._pendingInput+=r,_());return}if(window.CodemanTerminalInput.isComposerNavKey(r)){this._flushLocalEchoPending(),this._echoPassthroughSessions||(this._echoPassthroughSessions=new Set),this._echoPassthroughSessions.add(this.activeSessionId),this._pendingInput+=r,_();return}this._pendingInput+=r,_();return}if(this._restoringFlushedState){this._pendingInput+=r,_();return}if(r===" "){const y=this._localEchoOverlay?.pendingText||"";this._localEchoOverlay?.clear(),this._flushedOffsets?.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId),y&&(this._pendingInput+=y),this._pendingInput+=r,this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null);let C="";try{const I=this._localEchoOverlay?.findPrompt?.();if(I){const L=this.terminal.buffer.active,M=L.getLine(L.viewportY+I.row);M&&(C=M.translateToString(!0).slice(I.col+2).trimEnd())}}catch{}this._tabCompletionBaseText=C,_(),this._tabCompletionSessionId=this.activeSessionId,this._tabCompletionRetries=0,this._tabCompletionFallback&&clearTimeout(this._tabCompletionFallback);const w=this;this._tabCompletionFallback=setTimeout(()=>{if(w._tabCompletionFallback=null,!w._tabCompletionSessionId||w._tabCompletionSessionId!==w.activeSessionId)return;const I=w._localEchoOverlay;!I||I.pendingText||w.terminal.write("",()=>{if(!w._tabCompletionSessionId)return;I.resetBufferDetection();const L=I.detectBufferText();L&&L!==w._tabCompletionBaseText&&(w._tabCompletionSessionId=null,w._tabCompletionRetries=0,w._tabCompletionBaseText=null,I.rerender())})},300);return}const g=this._localEchoOverlay?.pendingText||"";this._localEchoOverlay?.clear(),this._localEchoOverlay?.suppressBufferDetection(),this._flushedOffsets?.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId),g&&(this._pendingInput+=g),this._pendingInput+=r,this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null),_();return}if(r.length===1&&r.charCodeAt(0)>=32){this._localEchoOverlay?.addChar(r);return}}if(this._predictHookOnData(r),this._pendingInput+=r,r.charCodeAt(0)<32||r.length>1){this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null),_();return}const S=performance.now();S-this._lastKeystrokeTime>50?(this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null),this._lastKeystrokeTime=S,_()):(this._lastKeystrokeTime=S,this._inputFlushTimeout||(this._inputFlushTimeout=setTimeout(_,0)))}};try{this._keyCode229Recovery=window.CodemanKeyCode229Recovery?.create?.({textarea:this.terminal.textarea,emitRecovered:r=>E(r),isScreenReaderMode:()=>this.terminal?.options?.screenReaderMode===!0})}catch{this._keyCode229Recovery=null}this.terminal.onData(r=>{try{const p=window.CodemanTerminalInput;!p?.shouldSuppressTerminalQueryResponse(r)&&!p?.isTerminalFocusOrMouseReport(r)&&this._keyCode229Recovery?.notifyCanonicalData?.()}catch{}E(r)})},registerFilePathLinkProvider(){const e=this;let t=-1;const i={provideLinks(s,n){s!==t&&(t=s,console.debug("[LinkProvider] Checking line:",s));const o=e.terminal.buffer.active;if(!o.getLine(s-1)){n(void 0);return}const h=window.CodemanTerminalLines?.terminalLogicalLine(o,s-1,e.terminal.cols,12);if(!h){n(void 0);return}const u=h.text,m=S=>{const g=h.offsetToCell(S);return{x:g.col+1,y:g.row+1}};if(!u||!u.includes("/")){n(void 0);return}const c=[],f=/https?:\/\/(?:[^\s"'<>|;&)\]\x00-\x1f]|&(?!&))+/g,b=(S,g)=>{const y=S.replace(/[.,;:!?)&]+$/,""),C=u.indexOf(y,g);if(C===-1)return;const w=m(C),I=m(C+y.length);c.some(L=>L.range.start.x===w.x&&L.range.start.y===w.y)||c.push({text:y,range:{start:w,end:I},decorations:{pointerCursor:!0,underline:!0},activate(L,M){e.openLinkThroughWebTabIfLoopback?.(M)||window.open(M,"_blank","noopener,noreferrer")},hover(){e._linkHovered=!0},leave(){e._linkHovered=!1}})},_=/\b(tail|cat|head|less|grep|watch|vim|nano)\s+(?:[^\s\/]+\s+){0,4}(\/[^\s"'<>|;&\n\x00-\x1f]+)/g,E=absoluteFilePathPattern(),r=/Bash\([^)]*?(\/(?:home|tmp|var|etc|opt)[^\s"'<>|;&\)\n\x00-\x1f]+)/g,p=(S,g)=>{const y=u.indexOf(S,g);if(y===-1)return;const C=m(y),w=m(y+S.length);c.some(I=>I.range.start.x===C.x&&I.range.start.y===C.y)||c.push({text:S,range:{start:C,end:w},decorations:{pointerCursor:!0,underline:!0},activate(I,L){if(previewsInFileViewer(L)||e._isExternalPreviewPath(L,e.activeSessionId)){e.openFilePreview(L,e.activeSessionId);return}e.openLogViewerWindow(L,e.activeSessionId)},hover(){e._linkHovered=!0},leave(){e._linkHovered=!1}})};let d;for(f.lastIndex=0;(d=f.exec(u))!==null;)b(d[0],d.index);for(_.lastIndex=0;(d=_.exec(u))!==null;)p(d[2],d.index);for(E.lastIndex=0;(d=E.exec(u))!==null;)p(d[1],d.index);for(r.lastIndex=0;(d=r.exec(u))!==null;)p(d[1],d.index);c.length>0&&console.debug("[LinkProvider] Found links:",c.map(S=>S.text)),n(c.length>0?c:void 0)}};this._terminalLinkProvider=i,this.terminal.registerLinkProvider(i),console.log("[LinkProvider] File path link provider registered")},_terminalLinkAtPoint(e,t){const i=this._terminalLinkProvider,s=this.terminal?.buffer?.active;if(!i||!s)return null;const n=this._clientPointToCell(e,t);if(!n)return null;const o=(s.viewportY||0)+n.row;let l=null;try{i.provideLinks(o,u=>{l=u||[]})}catch{return null}if(!l||l.length===0)return null;const a=Math.max(1,this.terminal.cols||1),h=o*a+n.col;return l.find(u=>{const m=u?.range?.start,c=u?.range?.end;return!m||!c?!1:m.y*a+m.x<=h&&h<=c.y*a+c.x})||null},_tapIsOnCaretLine(e,t){const i=this.terminal?.buffer?.active;if(!i?.getLine)return!1;const s=this._clientPointToCell(e,t);if(!s)return!1;const n=Math.max(1,this.terminal.rows||1),o=Math.max(0,Math.min(n-1,i.cursorY||0)),l=s.row-1;if(l===o)return!0;let a=o;for(;a>0&&i.getLine(i.viewportY+a)?.isWrapped;)a--;let h=o;for(;h+1<n&&i.getLine(i.viewportY+h+1)?.isWrapped;)h++;return l>=a&&l<=h},_activateTerminalLinkAtPoint(e,t){const i=this._terminalLinkAtPoint(e,t);if(!i||typeof i.activate!="function")return!1;try{i.activate(null,i.text)}catch(s){return console.warn("[LinkProvider] tap activation failed:",s),!1}return!0},_installTouchSelectionFocusGuard(){const e=this.terminal?.textarea;!e||e._codemanSelectionFocusGuard||(e._codemanSelectionFocusGuard=!0,e.addEventListener("focus",()=>{this._touchSelectionFocusGuarded()&&this._blurMobileTerminalInput()}))},_touchSelectionFocusGuarded(){return this._touchSelecting?!0:performance.now()<(this._touchSelectionFocusGuardUntil||0)},_armTouchSelectionFocusGuard(){this._touchSelectionFocusGuardUntil=performance.now()+(window.CodemanTerminalInput?.TOUCH_SELECT_FOCUS_GUARD_MS||800)},_touchSelectionCellAt(e,t){const i=this._clientPointToCell(e,t),s=this.terminal?.buffer?.active;return!i||!s?null:{col:i.col-1,row:(s.viewportY||0)+i.row-1}},_touchSelectionLogicalLine(e){const t=this.terminal?.buffer?.active,i=Math.max(1,this.terminal?.cols||1);return!t||typeof window.CodemanTerminalLines?.terminalLogicalLine!="function"?null:window.CodemanTerminalLines.terminalLogicalLine(t,e,i)},_touchSelectionWordAt(e){const t=Math.max(1,this.terminal?.cols||1),i=this._touchSelectionLogicalLine(e.row);if(!i)return null;const s=i.cellToOffset(e.row,e.col);if(s<0)return null;const n=i.text[s];if(!n||!n.trim())return null;let o=s;for(;o>0&&i.text[o-1]&&i.text[o-1].trim();)o--;let l=s;for(;l+1<i.text.length&&i.text[l+1]&&i.text[l+1].trim();)l++;const a=i.offsetToCell(o),h=i.offsetToCell(l),u=a.row*t+a.col,m=h.row*t+h.col-u+1;return m>0?{index:u,length:m}:null},_applyTouchSelection(e,t){const i=Math.max(1,this.terminal?.cols||1);t<=0||this.terminal?.select?.(e%i,Math.floor(e/i),t)},_beginTouchSelection(e,t){this._blurMobileTerminalInput(),this._suppressTrustedTapMouseEvents(),this._armTouchSelectionFocusGuard(),this._touchSelecting=!0;const i=this._touchSelectionCellAt(e,t);if(!i)return!1;const s=this._touchSelectionWordAt(i);if(!s)return!1;this._touchSelectionAnchor=s,this._touchSelectionActive=!0,this._applyTouchSelection(s.index,s.length);try{navigator.vibrate?.(15)}catch{}return this._showTouchSelectionBar(),!0},_extendTouchSelection(e,t){const i=this._touchSelectionAnchor,s=this._touchSelectionCellAt(e,t);if(!i||!s)return;const n=Math.max(1,this.terminal?.cols||1),o=s.row*n+s.col,l=Math.min(i.index,o),a=Math.max(i.index+i.length,o+1);this._applyTouchSelection(l,a-l),this._armTouchSelectionFocusGuard(),this._positionTouchSelectionBar()},_endTouchSelectionGesture(){this._touchSelecting=!1,this._suppressTrustedTapMouseEvents(),this._armTouchSelectionFocusGuard(),this._positionTouchSelectionBar(),this._flushAutoCopySelection()},_selectTouchSelectionLine(){const e=this._touchSelectionAnchor,t=Math.max(1,this.terminal?.cols||1);if(!e)return;const i=this._touchSelectionLogicalLine(Math.floor(e.index/t));if(!i)return;const n=(this.terminal?.buffer?.active?.getLine(i.endRow)?.translateToString(!0)||"").length,o=i.startRow*t,l=i.endRow*t+Math.max(0,n-1)-o+1;l<=0||(this._touchSelectionAnchor={index:o,length:l},this._applyTouchSelection(o,l),this._positionTouchSelectionBar(),this._flushAutoCopySelection())},async _copyTouchSelection(){const e=await this.copyTerminalSelection();return this._clearTouchSelection(),typeof MobileDetection<"u"&&MobileDetection.isTouchDevice?.()&&this._blurMobileTerminalInput(),e},_clearTouchSelection(){this._touchSelecting=!1,this._touchSelectionActive=!1,this._touchSelectionAnchor=null,this.terminal?.clearSelection?.(),this._hideTouchSelectionBar()},_ensureTouchSelectionBar(){if(this._touchSelectionBar?.isConnected)return this._touchSelectionBar;const e=document.getElementById("terminalContainer");if(!e)return null;const t=document.createElement("div");return t.className="term-select-bar",t.setAttribute("role","toolbar"),t.innerHTML='<button type="button" class="term-select-btn" data-act="copy">Copy</button><button type="button" class="term-select-btn" data-act="line">Line</button><button type="button" class="term-select-btn term-select-btn--close" data-act="close" aria-label="Clear selection">\u2715</button>',t.addEventListener("click",i=>{const s=i.target?.closest?.("[data-act]")?.dataset?.act;s&&(i.preventDefault(),i.stopPropagation(),s==="copy"?this._copyTouchSelection():s==="line"?this._selectTouchSelectionLine():this._clearTouchSelection())}),e.appendChild(t),this._touchSelectionBar=t,t},_showTouchSelectionBar(){const e=this._ensureTouchSelectionBar();e&&(e.classList.add("visible"),this._positionTouchSelectionBar())},_hideTouchSelectionBar(){this._touchSelectionBar?.classList.remove("visible")},_positionTouchSelectionBar(){const e=this._touchSelectionBar,t=document.getElementById("terminalContainer"),i=this.terminal?.element?.querySelector(".xterm-screen"),s=this.terminal?._core?._renderService?.dimensions?.css?.cell,n=this.terminal?.getSelectionPosition?.(),o=this.terminal?.buffer?.active;if(!e||!t||!i||!s?.height||!n||!o)return;const l=i.getBoundingClientRect(),a=t.getBoundingClientRect(),h=r=>r-(o.viewportY||0),u=l.top-a.top+h(n.start.y)*s.height,m=l.top-a.top+(h(n.end.y)+1)*s.height,c=e.offsetHeight||36,f=6;let b=u-c-f;b<0&&(b=m+f),b=Math.max(0,Math.min(b,a.height-c));const _=l.left-a.left+n.start.x*(s.width||8),E=e.offsetWidth||150;e.style.top=`${Math.round(b)}px`,e.style.left=`${Math.round(Math.max(0,Math.min(_,a.width-E)))}px`},showWelcome(){if(this.shouldUseMobileOverview?.()){const t=document.getElementById("welcomeOverlay");t&&t.classList.remove("visible"),this.hideHomeSessions?.(),this.showMobileOverview(),this._updateCjkInputState?.();return}this.hideMobileOverview?.();const e=document.getElementById("welcomeOverlay");e&&(e.classList.add("visible"),this.loadTunnelStatus(),this.applyWelcomeCliVisibility(),this.loadHistorySessions(),this.initSearchPanel(),this.showHomeSessions?.()),this._updateCjkInputState?.()},hideWelcome(){this.hideMobileOverview?.(),this.hideHomeSessions?.();const e=document.getElementById("welcomeOverlay");e&&e.classList.remove("visible");const t=document.getElementById("welcomeQr");t&&(clearTimeout(this._welcomeQrShrinkTimer),t.classList.remove("expanded")),this._updateCjkInputState?.()},async _fetchHistorySessions(){const i=(await(await fetch("/api/history/sessions")).json()).data?.sessions||[];if(i.length===0)return[];const s=new Map;for(const o of i){const l=o.projectKey||o.workingDir;s.has(l)||s.set(l,[]),s.get(l).push(o)}const n=[];for(const[,o]of s)n.push(...o.slice(0,3));return n.sort((o,l)=>new Date(l.lastModified)-new Date(o.lastModified)),n},async _fetchUnifiedSessions(e=60){const t=await fetch("/api/sessions/unified?limit="+e),i=await t.json().catch(()=>null);if(!t.ok||!i||i.success===!1||!i.data)throw new Error(i?.error||`unified sessions request failed (HTTP ${t.status})`);return i.data.sessions||[]},_worktreeLabel(e){const t=e&&e.worktreeName;if(!t)return"";let i=e.gitBranch||"";return(i===t||i===`worktree-${t}`)&&(i=""),i.length>24&&(i=i.slice(0,23)+"\u2026"),"\u2442 "+[t,i].filter(Boolean).join(" \xB7 ")},_resolveCaseLabel(e,t){if(!e)return"";let i=null;for(const s of t||[])if(!(!s||!s.path)){if(e===s.path)return`#${s.name}`;if(e.startsWith(s.path+"/")){const n=s.path.length;(!i||n>i.len)&&(i={name:s.name,suffix:e.slice(n),len:n})}}return i?`#${i.name}${i.suffix}`:e.split("/").pop()||e},_shortenHomePath(e){return(e||"").replace(/^\/(?:home|Users)\/[^/]+(?=\/|$)/,"~")},_buildHistoryItem(e,t,i){const s=i?.showViewAll!==!1,n=typeof e.sizeBytes=="number",o=n?e.sizeBytes<1024?`${e.sizeBytes}B`:e.sizeBytes<1048576?`${(e.sizeBytes/1024).toFixed(0)}K`:`${(e.sizeBytes/1048576).toFixed(1)}M`:"",l=typeof e.lastActivityAt=="number"?e.lastActivityAt:e.lastModified?Date.parse(e.lastModified):NaN;let a="";if(!Number.isNaN(l)){const T=new Date(l);a=T.toLocaleDateString("en",{month:"short",day:"numeric"})+" "+T.toLocaleTimeString("en",{hour:"2-digit",minute:"2-digit",hour12:!1})}const h=this._shortenHomePath(e.workingDir),u=this._resolveCaseLabel(e.workingDir,t),m=Array.isArray(e.sources)&&e.sources.includes("live"),c=e.pinned===!0,f=document.createElement("div");f.className="history-item"+(c?" is-pinned":""),f.title=e.workingDir||"";const b=document.createElement("div");b.className="history-item-main",b.addEventListener("click",i?.onActivate||(()=>{m&&this.sessions.has(e.sessionId)?this.selectSession(e.sessionId):this.resumeHistorySession(e.claudeSessionId||e.sessionId,e.workingDir||"",e.name,e.mode,e.resumeId)}));const _=document.createElement("div");_.className="history-item-text";const E=document.createElement("span");if(E.className="history-item-title",c){const T=document.createElement("span");T.className="history-item-pin",T.textContent="\u{1F4CC}",T.setAttribute("aria-label","Pinned"),T.title="Pinned",E.appendChild(T)}E.appendChild(document.createTextNode(this._historyRowLabel(e,h)));const r=document.createElement("div");if(r.className="history-item-badges",e.mode){const T=document.createElement("span");T.className="history-item-badge history-item-badge-mode",T.textContent=e.mode,r.appendChild(T)}const p=this._worktreeLabel(e);if(p){const T=document.createElement("span");T.className="history-item-badge history-item-badge-worktree",T.textContent=p,T.title=e.worktreeRepo?`worktree of ${e.worktreeRepo}`:p,r.appendChild(T)}if(m){const T=document.createElement("span");T.className="history-item-badge history-item-badge-live",T.textContent="LIVE",r.appendChild(T)}const d=document.createElement("span");d.className="history-item-subtitle",u.startsWith("#")&&d.classList.add("is-case"),d.textContent=u,_.append(E),r.childElementCount>0&&_.append(r),_.append(d);const S=document.createElement("span");S.className="history-item-meta",S.textContent=a;const g=document.createElement("button");g.className="history-item-expand",g.type="button",g.setAttribute("aria-haspopup","menu"),g.setAttribute("aria-label","Session actions"),g.setAttribute("aria-expanded","false"),g.textContent="\u22EF",b.append(_,S,g);const y=document.createElement("div");y.className="history-item-detail",y.hidden=!0;const C=document.createElement("div");C.className="history-detail-row";const w=document.createElement("span");w.className="history-detail-label",w.textContent="Prompt";const I=document.createElement("span");I.className="history-detail-value history-detail-prompt",I.textContent=e.firstPrompt||"(no prompt captured)",C.append(w,I);let L=null;if(e.lastPrompt&&e.lastPrompt!==e.firstPrompt){L=document.createElement("div"),L.className="history-detail-row";const T=document.createElement("span");T.className="history-detail-label",T.textContent="Last prompt";const v=document.createElement("span");v.className="history-detail-value history-detail-prompt",v.textContent=e.lastPrompt,L.append(T,v)}const M=document.createElement("div");M.className="history-detail-row";const x=document.createElement("span");x.className="history-detail-label",x.textContent="Path";const O=document.createElement("span");O.className="history-detail-value history-detail-path",O.textContent=h,M.append(x,O);const B=document.createElement("div");B.className="history-detail-row history-detail-meta";const D=[];if(a&&D.push(a),n&&D.push(o),D.push(e.sessionId.slice(0,8)),B.textContent=D.join(" \xB7 "),y.append(C),L&&y.append(L),y.append(M,B),s&&e.projectKey){const T=document.createElement("div");T.className="history-detail-row history-detail-actions";const v=document.createElement("button");v.type="button",v.className="history-view-all-btn",v.textContent="View all in this folder",v.addEventListener("click",A=>{A.stopPropagation(),this.openFolderHistoryModal(e.projectKey,e.workingDir,t)}),T.appendChild(v),y.appendChild(T)}return g.addEventListener("click",T=>{T.stopPropagation(),T.preventDefault(),this._openSessionRowMenu(T.currentTarget,e,t,f,y)}),f.append(b,y),f},_openSessionRowMenu(e,t,i,s,n){if(this._openRowMenuClose)try{this._openRowMenuClose()}catch{}const o=Array.isArray(t.sources)&&t.sources.includes("live")&&this.sessions.has(t.sessionId),l=document.createElement("div");l.className="session-row-menu",l.setAttribute("role","menu");let a=null,h=null,u=null;const m=()=>{document.removeEventListener("mousedown",a,!0),document.removeEventListener("keydown",h,!0),window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u,!0);try{l.remove()}catch{}this._openRowMenuEl===l&&(this._openRowMenuEl=null,this._openRowMenuClose=null)},c=(d,S,g)=>{const y=document.createElement("button");y.type="button",y.className="session-row-menu-item",y.setAttribute("role","menuitem");const C=document.createElement("span");if(C.className="session-row-menu-label",C.textContent=d,y.appendChild(C),g&&g.sublabel){const w=document.createElement("span");w.className="session-row-menu-sublabel",w.textContent=g.sublabel,y.appendChild(w)}y.addEventListener("click",async w=>{w.stopPropagation(),w.preventDefault(),await S()}),l.appendChild(y)};c(o?"Switch to session":"Resume session",()=>{o?this.selectSession(t.sessionId):this.resumeHistorySession(t.claudeSessionId||t.sessionId,t.workingDir||"",t.name,t.mode,t.resumeId),this.closeSessionManager?.(),m()});const f=t.pinned===!0;c(f?"Unpin session":"Pin to top",async()=>{await this._setSessionPinned(t.sessionId,!f)?(t.pinned=!f,this.showToast(f?"Unpinned":"Pinned to top","success")):this.showToast("Pin failed","error"),m()}),o&&c("Open folder",()=>{this.selectSession(t.sessionId),this.loadFileBrowser?.(t.sessionId),this.closeSessionManager?.(),m()}),t.workingDir&&c("Copy path",async()=>{const d=await this._copyText(t.workingDir);this.showToast(d?"Path copied":"Copy failed",d?"success":"error"),m()}),c("Show details",()=>{const d=s.classList.toggle("expanded");n.hidden=!d,e.setAttribute("aria-expanded",d?"true":"false"),m()}),document.body.appendChild(l);const b=e.getBoundingClientRect(),_=l.getBoundingClientRect(),E=4;let r=b.bottom+E;r+_.height>window.innerHeight&&b.top-E-_.height>=0&&(r=b.top-E-_.height);let p=b.right-_.width;p<E&&(p=E),p+_.width>window.innerWidth-E&&(p=Math.max(E,window.innerWidth-E-_.width)),l.style.top=`${Math.max(E,r)}px`,l.style.left=`${p}px`,a=d=>{l.contains(d.target)||e.contains(d.target)||m()},h=d=>{d.key==="Escape"&&(d.stopPropagation(),m())},u=()=>m(),document.addEventListener("mousedown",a,!0),document.addEventListener("keydown",h,!0),window.addEventListener("scroll",u,!0),window.addEventListener("resize",u,!0),this._openRowMenuEl=l,this._openRowMenuClose=m},async _setSessionPinned(e,t){try{const i=await fetch(`/api/sessions/${encodeURIComponent(e)}/pin`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify({pinned:t})});return i.ok?(await i.json())?.success===!0:!1}catch(i){return console.error("[_setSessionPinned]",i),!1}},_HISTORY_INITIAL_COUNT:10,_HISTORY_FETCH_LIMIT:200,_HISTORY_SORT_KEY:"codeman:historySort",async loadHistorySessions(){const e=document.getElementById("historySessions"),t=document.getElementById("historyList");if(!(!e||!t))try{const i=Array.isArray(this.cases)&&this.cases.length>0?Promise.resolve(this.cases):fetch("/api/cases").then(o=>o.ok?o.json():null).then(o=>o?.data||[]).catch(()=>[]),[s,n]=await Promise.all([this._fetchUnifiedSessions(this._HISTORY_FETCH_LIMIT),i]);if(s.length===0){e.style.display="none";return}this._historyAll=s,this._historyCases=n,this._wireHistoryControls(),this._renderHistoryList(),e.style.display=""}catch(i){console.error("[loadHistorySessions]",i),e.style.display="none"}},_wireHistoryControls(){if(this._historyControlsWired)return;const e=document.getElementById("historyFilter"),t=document.getElementById("historySort");if(!(!e&&!t)){if(this._historyControlsWired=!0,t)try{const i=localStorage.getItem(this._HISTORY_SORT_KEY);i&&Array.from(t.options).some(s=>s.value===i)&&(t.value=i)}catch{}e&&(e.addEventListener("input",()=>this._renderHistoryList()),e.addEventListener("keydown",i=>{i.key==="Escape"&&e.value&&(i.stopPropagation(),e.value="",this._renderHistoryList())})),t&&t.addEventListener("change",()=>{try{localStorage.setItem(this._HISTORY_SORT_KEY,t.value)}catch{}this._renderHistoryList()})}},_historyRowMatches(e,t,i){return[e.name,e.workingDir,this._resolveCaseLabel(e.workingDir,i),e.firstPrompt,e.lastPrompt,e.sessionId].some(n=>typeof n=="string"&&n.toLowerCase().includes(t))},_historyRowLabel(e,t){return e.name||e.firstPrompt||t||""},_sortHistoryRows(e,t){const n=t==="name"?a=>this._historyRowLabel(a,this._shortenHomePath(a.workingDir)).toLowerCase():a=>((a.workingDir||"").split("/").pop()||"").toLowerCase(),o=t==="recent"?e.slice():e.slice().sort((a,h)=>n(a).localeCompare(n(h),void 0,{sensitivity:"base",numeric:!0})),l=o.filter(a=>a.pinned);return l.length===0?o:l.concat(o.filter(a=>!a.pinned))},_renderHistoryList(){const e=document.getElementById("historyList");if(!e)return;const t=this._historyAll||[],i=this._historyCases||[],s=document.getElementById("historyCount"),n=(document.getElementById("historyFilter")?.value||"").trim().toLowerCase(),o=document.getElementById("historySort")?.value||"recent",l=n?t.filter(c=>this._historyRowMatches(c,n,i)):t,a=this._sortHistoryRows(l,o),h=!!this._historyExpanded||n.length>0,u=h?a:a.slice(0,this._HISTORY_INITIAL_COUNT);if(e.replaceChildren(),e.classList.toggle("expanded",h),a.length===0){const c=document.createElement("div");c.className="history-empty",c.textContent=`No conversations match "${n}"`,e.appendChild(c)}for(const c of u)e.appendChild(this._buildHistoryItem(c,i));const m=a.length-u.length;if(m>0){const c=document.createElement("button");c.className="history-show-more",c.textContent=`Show ${m} more`,c.addEventListener("click",()=>{this._historyExpanded=!0,this._renderHistoryList()}),e.appendChild(c)}else if(h&&!n&&a.length>this._HISTORY_INITIAL_COUNT){const c=document.createElement("button");c.className="history-show-more",c.textContent="Show less",c.addEventListener("click",()=>{this._historyExpanded=!1,this._renderHistoryList(),e.scrollTop=0}),e.appendChild(c)}s&&(s.textContent=n?`${a.length} of ${t.length}`:a.length>u.length?`${u.length} of ${a.length}`:String(a.length))},_FOLDER_HISTORY_PAGE_SIZE:20,openFolderHistoryModal(e,t,i){this._closeFolderHistoryModal();const s=document.createElement("div");s.className="modal active folder-history-modal",s.id="folderHistoryModal";const n=document.createElement("div");n.className="modal-backdrop",n.addEventListener("click",()=>this._closeFolderHistoryModal());const o=document.createElement("div");o.className="modal-content modal-lg";const l=document.createElement("div");l.className="modal-header";const a=document.createElement("h3");a.textContent="Folder History";const h=document.createElement("div");h.className="folder-history-subtitle",h.textContent=this._shortenHomePath(t);const u=document.createElement("button");u.className="modal-close",u.setAttribute("aria-label","Close"),u.innerHTML="×",u.addEventListener("click",()=>this._closeFolderHistoryModal()),l.append(a,u);const m=document.createElement("div");m.className="modal-body";const c=document.createElement("div");c.className="folder-history-list",c.setAttribute("data-loading","true"),c.textContent="Loading...",m.append(h,c),o.append(l,m),s.append(n,o),document.body.appendChild(s),this._folderHistoryState={projectKey:e,workingDir:t,cases:i||[],offset:0,total:null,list:c},this._folderHistoryEscHandler=f=>{f.key==="Escape"&&this._closeFolderHistoryModal()},document.addEventListener("keydown",this._folderHistoryEscHandler),this._loadFolderHistoryPage()},async _loadFolderHistoryPage(){const e=this._folderHistoryState;if(!e)return;const{projectKey:t,cases:i,list:s}=e,n=this._FOLDER_HISTORY_PAGE_SIZE,o=e.offset,l=s.querySelector(".folder-history-more");l&&l.remove(),o===0&&(s.replaceChildren(),s.removeAttribute("data-loading"));try{const a=`/api/history/sessions?projectKey=${encodeURIComponent(t)}&offset=${o}&limit=${n}`,u=await(await fetch(a)).json(),m=u.data?.sessions||[];if(e.total=typeof u.data?.total=="number"?u.data.total:m.length+o,o===0&&m.length===0){const c=document.createElement("div");c.className="folder-history-empty",c.textContent="No conversations found in this folder.",s.appendChild(c);return}for(const c of m)s.appendChild(this._buildHistoryItem(c,i,{showViewAll:!1}));if(e.offset=o+m.length,e.offset<e.total){const c=e.total-e.offset,f=document.createElement("button");f.className="history-show-more folder-history-more",f.textContent=`Show ${Math.min(n,c)} more (${c} remaining)`,f.addEventListener("click",()=>this._loadFolderHistoryPage()),s.appendChild(f)}}catch(a){console.error("[loadFolderHistoryPage]",a);const h=document.createElement("div");h.className="folder-history-empty",h.textContent="Failed to load folder history.",s.appendChild(h)}},_closeFolderHistoryModal(){const e=document.getElementById("folderHistoryModal");e&&e.remove(),this._folderHistoryEscHandler&&(document.removeEventListener("keydown",this._folderHistoryEscHandler),this._folderHistoryEscHandler=null),this._folderHistoryState=null},_resolveResumeName(e,t){if(typeof e=="string"&&e.trim())return e;const i=(t||"").split("/").pop()||"session";let s=1;for(const[,n]of this.sessions){const o=n.name&&n.name.match(/^w(\d+)-/);if(o){const l=parseInt(o[1]);l>=s&&(s=l+1)}}return`w${s}-${i}`},async resumeHistorySession(e,t,i,s,n){document.getElementById("runModeMenu")?.classList.remove("active"),this._closeFolderHistoryModal();try{this.terminal.clear(),this.terminal.writeln(`\x1B[1;32m Resuming conversation ${e.slice(0,8)}...\x1B[0m`);const o=this._resolveResumeName(i,t),a=(this.cases||[]).find(S=>S.path===t)?.name||t.split("/").pop()||"",h=this.loadAppSettingsFromStorage(),u=this.buildEnvOverrides(this.getCaseSettings(a),h),m=this.getEffortSetting(h),c=s||"claude",f={opencode:"openCodeConfig",pi:"piConfig",grok:"grokConfig",omp:"ompConfig"}[c],b=c==="codex"?n:void 0,_=f?{[f]:{continueSession:!0}}:c==="deepseek"?{deepSeekConfig:{resumeSession:!0}}:b?{codexConfig:{resumeSessionId:b}}:{},E=!!f||c==="deepseek"||!!b,p=await(await fetch("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workingDir:t,name:o,mode:c,...c==="claude"?{resumeSessionId:e}:{},..._,...Object.keys(u).length>0?{envOverrides:u}:{},...m?{effort:m}:{}})})).json();if(!p.success)throw new Error(p.error);const d=p.data.session.id;await fetch(`/api/sessions/${d}/interactive`,{method:"POST"}),c!=="claude"&&E&&e!==d&&fetch(`/api/sessions/${e}?killMux=true`,{method:"DELETE"}).catch(()=>{}),this.terminal.writeln(`\x1B[90m Session ${o} ready\x1B[0m`),await this.selectSession(d),this.terminal.focus()}catch(o){this.terminal.writeln(`\x1B[1;31m Error: ${o.message}\x1B[0m`)}},isTerminalAtBottom(){if(!this.terminal)return!0;const e=this.terminal.buffer.active;return e.viewportY>=e.baseY-2},_syncStickyScrollBaseline(){this._wasAtBottomBeforeWrite=this.isTerminalAtBottom()},_noteTerminalUserScroll(e){e<0?this._lastUserScrollUpAt=performance.now():this.isTerminalAtBottom()&&(this._lastUserScrollUpAt=null)},_maybeLoadMoreHistoryOnScroll(e){e>=0||this.terminal?.buffer?.active?.viewportY===0&&this._maybeRefetchFullHistory?.()},_estimateReplayRows(e,t){if(typeof e!="string"||!e)return 0;const i=t>0?t:80,s=e.replace(window.CodemanTerminalInput.REPLAY_ESCAPE_RE,"");let n=0;for(const o of s.split(`
|
|
2
|
-
`)){const l=o.endsWith("\r")?o.length-1:o.length;n+=l>i?Math.ceil(l/i):1}return n},_replayWouldShrinkBuffer(e,t){const i=this.terminal,s=i?.buffer?.active?.length||0;if(!s)return!1;const n=i?.rows||24;return(t??this._estimateReplayRows(e,i?.cols))+n<s},_smoothScrollBy(e){if(!e||(this._smoothScrollPending=(this._smoothScrollPending||0)+e,this._smoothScrollSession=this.activeSessionId,this._smoothScrollFrame))return;const t=()=>{this._smoothScrollFrame=null;const i=this._smoothScrollPending||0;if(!i)return;if(this.activeSessionId!==this._smoothScrollSession){this._smoothScrollPending=0;return}if(Math.abs(i)<1)return;const s=i*.22,n=i>0?Math.max(1,Math.floor(s)):Math.min(-1,Math.ceil(s));this._smoothScrollPending=i-n,this.terminal.scrollLines(n),this._maybeLoadMoreHistoryOnScroll(n),Math.abs(this._smoothScrollPending)>=1&&(this._smoothScrollFrame=requestAnimationFrame(t))};this._smoothScrollFrame=requestAnimationFrame(t)},_forwardScrollToApp(e,t,i){this._terminalViewportAtBottom()||this.terminal.scrollToBottom(),this._sendSyntheticSgrWheel(e,t,i)},_hasRecentUserScrollUp(){return typeof this._lastUserScrollUpAt!="number"?!1:performance.now()-this._lastUserScrollUpAt<window.CodemanTerminalInput.USER_SCROLL_STICKY_SUPPRESS_MS},_startRenderLivenessWatchdog(){this._stopRenderLivenessWatchdog(),this._lastRenderAt=Date.now(),this._lastTerminalWriteAt=0,this._renderLivenessTimer=setInterval(()=>{try{if(typeof CodemanRenderLiveness>"u"||!CodemanRenderLiveness.shouldKickRenderer({wroteAt:this._lastTerminalWriteAt||0,renderedAt:this._lastRenderAt||0,now:Date.now(),visible:document.visibilityState==="visible"&&!!this.terminal?.element?.isConnected}))return;const t=this._kickRenderer();_crashDiag.log(`RENDER STALL: kick=${t}`),this._lastRenderAt=Date.now()}catch{}},RENDER_LIVENESS_POLL_MS)},_stopRenderLivenessWatchdog(){this._renderLivenessTimer&&(clearInterval(this._renderLivenessTimer),this._renderLivenessTimer=null)},_kickRenderer(){try{const e=this.terminal?._core?._renderService,t=e?._renderDebouncer;if(!t||typeof e.refreshRows!="function")return!1;const i=t._animationFrame;if(i===void 0)return!1;try{cancelAnimationFrame(i)}catch{}return t._animationFrame=void 0,e.refreshRows(0,Math.max(0,(this.terminal.rows||1)-1)),!0}catch{return!1}},batchTerminalWrite(e){if(this._lastTerminalWriteAt=Date.now(),this._isLoadingBuffer){this._loadBufferQueue&&this._loadBufferQueue.push({at:performance.now(),data:e});return}if(this.writeFrameScheduled||(this._wasAtBottomBeforeWrite=this.isTerminalAtBottom()),(this.activeSessionId?this.sessions.get(this.activeSessionId):null)?.flickerFilterEnabled??!1){if(e.includes("\x1B[2J")||e.includes("\x1B[H\x1B[J")||e.includes("\x1B[H")&&e.includes("\x1B[?25l")){this.flickerFilterActive=!0,this.flickerFilterBuffer+=e,this.flickerFilterTimeout&&clearTimeout(this.flickerFilterTimeout),this.flickerFilterTimeout=setTimeout(()=>{this.flickerFilterTimeout=null,this.flushFlickerBuffer()},SYNC_WAIT_TIMEOUT_MS);return}if(this.flickerFilterActive){this.flickerFilterBuffer+=e;return}}this.pendingWrites.push(e),this._scheduleTerminalWriteFlush()},_scheduleTerminalWriteFlush(){this._terminalWriteInFlight||this.writeFrameScheduled||this.pendingWrites.length===0||(this.writeFrameScheduled=!0,this._safeYield(()=>{this.writeFrameScheduled=!1,this.flushPendingWrites()}))},flushFlickerBuffer(){this.flickerFilterBuffer&&(this.pendingWrites.push(this.flickerFilterBuffer),this.flickerFilterBuffer="",this.flickerFilterActive=!1,this._scheduleTerminalWriteFlush())},_flushLocalEchoPending(){const e=this._localEchoOverlay?.pendingText||"";this._localEchoOverlay?.clear(),this._localEchoOverlay?.suppressBufferDetection(),this._flushedOffsets?.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId),e&&(this._pendingInput+=e)},_updateLocalEchoState(){const e=this.loadAppSettingsFromStorage(),t=this.activeSessionId?this.sessions.get(this.activeSessionId):null,i=e.localEchoEnabled??MobileDetection.isTouchDevice(),s=!!(i&&t);this._localEchoEnabled&&!s&&this._localEchoOverlay?.clear(),this._localEchoEnabled=s,this._localEchoOverlay&&t&&(t.mode==="opencode"?this._localEchoOverlay.setPrompt({type:"custom",offset:3,find:o=>{try{const l=o.buffer.active,a=l.cursorY,h=l.getLine(l.viewportY+a);if(!h)return null;const m=h.translateToString(!0).indexOf("\u2503");return m>=0?{row:a,col:m}:null}catch{return null}}}):t.mode==="shell"||t.mode==="codex"?(this._localEchoOverlay.clear(),this._localEchoEnabled=!1):this._localEchoOverlay.setPrompt({type:"custom",offset:0,find:o=>{try{const l=o.buffer.active;for(let a=o.rows-1;a>=0;a--){const h=l.getLine(l.viewportY+a);if(!h)continue;const m=h.translateToString(!0).lastIndexOf("\u276F");if(m>=0)return{row:a,col:m+2}}return{row:Math.max(0,Math.min(o.rows-1,l.cursorY)),col:Math.max(0,Math.min(o.cols-1,l.cursorX))}}catch{return null}}}));let n="off";t&&i&&(t.mode==="codex"?n="predict":t.mode!=="shell"&&(n="buffer")),this._localEchoPolicy=n,n!=="predict"&&this._predictiveEcho?.clearPredictions()},_predictHookOnData(e){if(!(this._localEchoPolicy!=="predict"||!this._predictiveEcho))try{const t=window.CodemanTerminalInput.classifyPredictInput(e);t==="char"?this._predictiveEcho.predictChar(e):t==="backspace"?this._predictiveEcho.predictBackspace():this._predictiveEcho.clearPredictions()}catch{}},_handleCjkInput(e){if(!this.activeSessionId){_crashDiag.log(`CJK send DROP no-session len=${e.length}`);return}typeof KeyboardAccessoryBar<"u"&&KeyboardAccessoryBar.isCtrlArmed?.()&&(e=KeyboardAccessoryBar.consumeCtrl(e)),this._localEchoPolicy==="predict"&&this._predictiveEcho?.clearPredictions(),_crashDiag.log(`CJK send\u2192${this.activeSessionId.slice(0,8)} len=${e.length}`),this._sendInputAsync(this.activeSessionId,e)},_restoreTerminalViewport(e,t){e!=null&&(t!==void 0&&t!==this.activeSessionId||this._isLoadingBuffer||typeof this.terminal?.scrollToLine=="function"&&this.terminal.buffer?.active?.viewportY!==e&&this.terminal.scrollToLine(e))},flushPendingWrites(){if(this._terminalWriteInFlight||this.pendingWrites.length===0||!this.terminal)return;const e=performance.now(),t=this.pendingWrites.join("");this.pendingWrites=[];const i=t.length;i>16384&&_crashDiag.log(`FLUSH: ${(i/1024).toFixed(0)}KB`);const n=(this.activeSessionId&&this.sessions?this.sessions.get(this.activeSessionId):null)?.mode==="codex"?32768:65536;let o=!1;const l=this.terminal.buffer?.active&&!this.isTerminalAtBottom()?this.terminal.buffer.active.viewportY:null,a=this.activeSessionId,h=t.slice(0,n);i>n&&(this.pendingWrites.push(t.slice(n)),o=!0),this._terminalWriteInFlight=!0,this._terminalWriteInFlightBytes=h.length;try{this.terminal.write(h,()=>{this._terminalWriteInFlight=!1,this._terminalWriteInFlightBytes=0,this._restoreTerminalViewport(l,a),this._scheduleTerminalWriteFlush()})}catch(c){throw this._terminalWriteInFlight=!1,this._terminalWriteInFlightBytes=0,c}const u=o?n:i,m=performance.now()-e;if((m>100||o)&&console.warn(`[CRASH-DIAG] flushPendingWrites: ${m.toFixed(0)}ms, ${(u/1024).toFixed(0)}KB written${o?", rest deferred":""} (total ${(i/1024).toFixed(0)}KB)`),l===null&&this._wasAtBottomBeforeWrite&&!this._hasRecentUserScrollUp()&&this.terminal.scrollToBottom(),this._localEchoOverlay?.hasPending&&this._localEchoOverlay.rerender(),this._tabCompletionSessionId&&this._tabCompletionSessionId===this.activeSessionId&&this._localEchoOverlay&&!this._localEchoOverlay.pendingText){const c=this._localEchoOverlay,f=this;this.terminal.write("",()=>{if(!f._tabCompletionSessionId)return;c.resetBufferDetection();const b=c.detectBufferText();b?b===f._tabCompletionBaseText?(c.undoDetection(),f._tabCompletionRetries=(f._tabCompletionRetries||0)+1,f._tabCompletionRetries>60&&(f._tabCompletionSessionId=null,f._tabCompletionRetries=0)):(f._tabCompletionSessionId=null,f._tabCompletionRetries=0,f._tabCompletionBaseText=null,f._tabCompletionFallback&&(clearTimeout(f._tabCompletionFallback),f._tabCompletionFallback=null),c.rerender()):(f._tabCompletionRetries=(f._tabCompletionRetries||0)+1,f._tabCompletionRetries>60&&(f._tabCompletionSessionId=null,f._tabCompletionRetries=0))})}},_safeYield(e){let t=!1;const i=()=>{t||(t=!0,e())};requestAnimationFrame(i),setTimeout(i,50),this._workerYield(i)},_workerYield(e){try{if(this._yieldWorker===void 0){const t="onmessage=()=>setTimeout(()=>postMessage(0),0);",i=new Blob([t],{type:"application/javascript"}),s=URL.createObjectURL(i);this._yieldWorker=new Worker(s),URL.revokeObjectURL(s),this._yieldQueue=[],this._yieldWorker.onmessage=()=>{const n=this._yieldQueue.shift();n&&n()}}if(!this._yieldWorker)return;this._yieldQueue.push(e),this._yieldWorker.postMessage(0)}catch{this._yieldWorker=null}},scrollToLastNonEmptyLine(){if(!this.terminal?.buffer?.active){this.terminal?.scrollToBottom?.();return}const e=this.terminal.buffer.active,t=e.length;let i=-1;for(let s=t-1;s>=0;s--)if(e.getLine(s)?.translateToString(!0).trim()){i=s;break}if(i>=0&&typeof this.terminal.scrollToLine=="function"){let s=Math.max(0,i-this.terminal.rows+2);const n=Math.max(0,i);for(;s<n&&!e.getLine(s)?.translateToString(!0).trim();)s++;this.terminal.scrollToLine(s)}else this.terminal.scrollToBottom()},chunkedTerminalWrite(e,t=TERMINAL_CHUNK_SIZE,i,s){const n=++this._chunkedWriteGen,o=this._beginBufferLoad(i);return new Promise(l=>{const a=(b=this._chunkedWriteGen===n)=>({parsedAt:performance.now(),bufferLength:this.terminal?.buffer?.active?.length??0,completed:b});if(!e||e.length===0){this._finishBufferLoad(o,s),l(a());return}const h=e.replace(DEC_SYNC_STRIP_RE,"");if(h.length<=t){this.terminal.write(h,()=>l(a())),this._finishBufferLoad(o,s);return}let u=0;const m=performance.now();let c=0;const f=()=>{if(this._chunkedWriteGen!==n){l(a(!1));return}const b=h.slice(u,u+t);if(u+=b.length,c++,this.terminal.write(b),u>=h.length){this.terminal.write("",()=>{const _=a(),E=_.parsedAt-m;console.log(`[CRASH-DIAG] chunkedTerminalWrite complete: ${h.length} bytes in ${c} chunks, ${E.toFixed(0)}ms parsed`),l(_)}),this._finishBufferLoad(o,s);return}this._safeYield(f)};this._safeYield(f)})},_beginBufferLoad(e){this._bufferLoadSeq===void 0&&(this._bufferLoadSeq=0);const t=e===void 0?`buffer-${++this._bufferLoadSeq}`:e,i=this._bufferLoadOwner===t&&Array.isArray(this._loadBufferQueue);return this._bufferLoadOwner=t,this._isLoadingBuffer=!0,i||(this._loadBufferQueue=[]),t},_finishBufferLoad(e,t){if(e!==void 0&&this._bufferLoadOwner!==e)return!1;const i=this._loadBufferQueue;if(this._isLoadingBuffer=!1,this._loadBufferQueue=null,this._bufferLoadOwner=null,t?.flushQueued&&i&&i.length){const s=typeof t.since=="number"?t.since:0;for(const n of i)n.at<s||this.batchTerminalWrite(n.data)}return!0},clearTerminal(){this.terminal.clear()},insertTerminalText(e){!this.activeSessionId||!e||(this._localEchoPolicy==="predict"&&this._predictiveEcho?.clearPredictions(),this._localEchoEnabled&&this._localEchoOverlay&&!this._echoPassthroughSessions?.has(this.activeSessionId)?this._localEchoOverlay.appendText(e):this.sendInput(e).catch(()=>{}),this.terminal?.focus())},clearTerminalInput(){if(this.activeSessionId){if(typeof CjkInput<"u"&&CjkInput.clear(),this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null),this._pendingInput="",this._localEchoPolicy==="predict"&&this._predictiveEcho?.clearPredictions(),this._localEchoEnabled&&this._localEchoOverlay){const e=this._localEchoOverlay.getFlushed?.()||{count:0,text:""};this._localEchoOverlay.clear(),this._localEchoOverlay.suppressBufferDetection(),this._flushedOffsets?.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId);const t=Array.from(e.text||"").length;t>0&&this.sendInput("\x7F".repeat(t)).catch(()=>{})}else this.sendInput("").catch(()=>{});this.showToast?.("Input cleared","success"),this.terminal?.focus()}},async restoreTerminalSize(){if(!this.activeSessionId){this.showToast("No active session","warning");return}if(!this.isSoloWindow&&this.detachedSessions?.has(this.activeSessionId)){this.showToast("This session is sized by its own window","warning");return}const e=this.getTerminalDimensions();if(!e){this.showToast("Could not determine terminal size","error");return}try{await this.sendResize(this.activeSessionId,{force:!0}),this.showToast(`Terminal restored to ${e.cols}x${e.rows}`,"success")}catch(t){console.error("Failed to restore terminal size:",t),this.showToast("Failed to restore terminal size","error")}},sendPendingCtrlL(e){},shouldCopyTerminalSelectionFromShortcut(e){if(!e||e.type!=="keydown"||!e.ctrlKey&&!e.metaKey&&!e.altKey)return!1;const i=typeof this.getShortcutRegistry=="function"&&typeof this.matchesShortcutEvent=="function"?this.getShortcutRegistry().find(s=>s.id==="copy-selection"):null;return i?!i.disabled&&this.matchesShortcutEvent(e,i):!e.altKey&&(e.key||"").toLowerCase()==="c"},cleanedTerminalSelection(e){const t=e??(this.terminal?.hasSelection?.()?this.terminal.getSelection():"");if(!t)return"";if(this.terminal?._core?._selectionService?._activeSelectionMode===3)return t;const i=window.CodemanCopySelection?.clean;if(!i)return t;const s=this._normalisedSelectionRange();return i(t,{margin:this._cliGutterColumns(),firstLinePartial:!!s&&s.start.x>0})},_normalisedSelectionRange(e){const t=(e??this.terminal)?.getSelectionPosition?.();if(!t?.start||!t?.end)return null;const{start:i,end:s}=t;return s.y<i.y||s.y===i.y&&s.x<i.x?{start:s,end:i}:{start:i,end:s}},_cliGutterColumns(e){if(!this._copyStripMarginEnabled())return 0;const t=window.__codemanTranscriptGutter;if(!t||typeof t!="object")return 0;const i=this.sessions?.get(e??this.activeSessionId)?.mode,s=i?t[i]:0;return Number.isInteger(s)&&s>0?s:0},async copyTerminalSelection(e){const t=this.cleanedTerminalSelection(e);if(!t.trim())return this.terminal?.clearSelection?.(),this.showToast("Nothing to copy","warning"),!1;const i=await this._copyText(t);return i?(this.terminal.clearSelection?.(),this.showToast("Copied to clipboard","success")):this.showToast("Failed to copy","error"),this.terminal.focus(),i},_copyStripMarginEnabled(){try{return this.loadAppSettingsFromStorage?.()?.copyStripMargin!==!1}catch{return!0}},_autoCopySelectionEnabled(){try{return this.loadAppSettingsFromStorage?.()?.autoCopySelection===!0}catch{return!1}},async _flushAutoCopySelection(){const e=window.CodemanAutoCopy?.decide;if(!e||!this.terminal)return;const t=this._autoCopySelectionEnabled(),i=t?this.cleanedTerminalSelection():"",s=e({enabled:t,text:i,lastCopied:this._autoCopyLastText,pending:!!this._autoCopyPending});if(this._autoCopyPending=!1,s==="skip")return;if(s==="too-large"){this._autoCopyNotify("Selection too large to copy automatically. Press Ctrl+C.","warning");return}this._autoCopyLastText=i;const n=document.activeElement,o=await this._copyText(i);if(n&&n!==document.activeElement&&n.isConnected&&typeof n.focus=="function")try{n.focus()}catch{}if(!o){this._autoCopyLastText="",this._autoCopyNotify("Auto Copy failed: the browser blocked clipboard access","error");return}this._autoCopyHintShown||(this._autoCopyHintShown=!0,this.showToast("Auto Copy: selection copied","success"))},_autoCopyNotify(e,t){const i=Date.now(),s=this._autoCopyNotifiedAt;s!==void 0&&i-s<1e4||(this._autoCopyNotifiedAt=i,this.showToast(e,t))},_syncMobileHelperTextareaToCursor(){if(!(!MobileDetection.isTouchDevice()||!this.terminal?.element))try{const e=this.terminal.element,t=this.terminal.element.querySelector(".xterm-cursor"),i=this.terminal.element.querySelector(".xterm-screen");if(!(e instanceof HTMLElement)||!(t instanceof HTMLElement)||!(i instanceof HTMLElement))return;const s=t.getBoundingClientRect(),n=i.getBoundingClientRect();if(!s.width&&!s.height)return;const o=Math.max(0,Math.round(s.left-n.left)),l=Math.max(0,Math.round(s.top-n.top));e.style.setProperty("--xterm-helper-left",`${o}px`),e.style.setProperty("--xterm-helper-top",`${l}px`)}catch{}},_isMobileTerminalInputFocused(){const e=document.activeElement;return e===this.terminal?.textarea||e?.classList?.contains("xterm-helper-textarea")||e?.id==="cjkInput"},_classifyMobileTerminalTap(e,t){if(!this._terminalViewportAtBottom())return"history";const i=this._clientPointToCell(e,t);if(!i||!this.terminal)return"input";const s=this.terminal.modes?.mouseTrackingMode;if(!(!!s&&s!=="none")&&!this._shouldReportMouseToCli())return"input";const o=this.terminal.buffer?.active;if(!o?.getLine)return"input";const l=Math.max(1,this.terminal.rows||1),a=[],h=[];let u=!1;for(let d=0;d<l;d++){const S=o.getLine(o.viewportY+d),g=S?.translateToString?.(!0)||"";a.push(g),h.push(!!S?.isWrapped),g.trim()&&(u=!0)}if(!u)return"input";const m=Math.max(0,Math.min(l-1,o.cursorY||0)),c=this.sessions?.get(this.activeSessionId)?.mode||"claude";let f=-1,b=!1;if(c==="opencode")a[m]?.includes("\u2503")&&(f=m);else for(let d=l-1;d>=0;d--){const S=a[d].match(/^\s*[❯›]/);if(!S)continue;const g=a[d].slice(S[0].length).trim(),y=a.some((C,w)=>w!==d&&/^\s+\d+[.)]\s/.test(C));if(/^\d+[.)]\s/.test(g)&&y){b=!0;break}f=d;break}const _=i.row-1;let E=_;for(;E>0&&h[E];)E--;let r=_;for(;r+1<l&&h[r+1];)r++;const p=a.slice(E,r+1).join("");if(c==="claude"&&/\b(?:esc to interrupt|background)\b/i.test(p)||b)return"content";if(f>=0){const d=m>=f?m:f;if(_>=f&&_<=d)return"input"}else if(_===m||_>=Math.max(0,l-window.CodemanTerminalInput.TUI_PROMPT_DEFAULT_ROWS_FROM_BOTTOM))return"input";return"content"},_blurMobileTerminalInput(){const e=document.activeElement;(e===this.terminal?.textarea||e?.classList?.contains("xterm-helper-textarea")||e?.id==="cjkInput")&&e.blur?.()},_installMobileKeyboardDismiss(){if(this._mobileKeyboardDismissHandler)return;let e=0,t=0,i=!1;this._mobileKeyboardDismissStart=s=>{if(s.touches.length!==1){i=!0;return}e=s.touches[0].clientX,t=s.touches[0].clientY,i=!1},this._mobileKeyboardDismissMove=s=>{if(i||!s.touches.length)return;const n=s.touches[0].clientX-e,o=s.touches[0].clientY-t,l=window.CodemanTerminalInput.MOBILE_KEYBOARD_DISMISS_TAP_SLOP;(Math.abs(n)>l||Math.abs(o)>l)&&(i=!0)},this._mobileKeyboardDismissHandler=s=>{if(i||!this._isMobileTerminalInputFocused())return;const n=s.target;!n||typeof n.closest!="function"||n.closest("#terminalContainer")||n.closest(window.CodemanTerminalInput.MOBILE_KEYBOARD_DISMISS_EXEMPT_SELECTOR)||this._blurMobileTerminalInput()},document.addEventListener("touchstart",this._mobileKeyboardDismissStart,{passive:!0}),document.addEventListener("touchmove",this._mobileKeyboardDismissMove,{passive:!0}),document.addEventListener("touchend",this._mobileKeyboardDismissHandler,{passive:!0})},_isActionableMobileTerminalTap(e,t){const i=this._clientPointToCell(e,t),s=this.terminal?.buffer?.active;if(!i||!s?.getLine)return!1;const n=Math.max(1,this.terminal.rows||1),o=[],l=[];for(let r=0;r<n;r++){const p=s.getLine(s.viewportY+r);o.push(p?.translateToString?.(!0)||""),l.push(!!p?.isWrapped)}const a=i.row-1;let h=a;for(;h>0&&l[h];)h--;let u=a;for(;u+1<n&&l[u+1];)u++;const m=o.slice(h,u+1).join(""),c=/\b(?:ctrl\+\w+|shift\+\w+|esc|enter|tab|tap)\s+to\s+(?:expand|collapse|view|open|interrupt|see)\b/i,f=Math.max(0,h-1),b=Math.min(n-1,u+1);for(let r=f;r<=b;r++)if(c.test(o[r]))return!0;const _=o.some(r=>/^\s*[❯›]\s+\d+[.)]\s/.test(r)),E=o.some(r=>/^\s+\d+[.)]\s/.test(r));return _&&E&&/^\s*(?:[❯›]\s*)?\d+[.)]\s/.test(m)},_focusMobileTerminalInput(){this._syncMobileHelperTextareaToCursor();const e=document.getElementById("cjkInput");e?.classList.contains("cjk-input-visible")?e.focus():this.terminal?.focus()},_handleMobileTerminalTap(e,t,i=null){if(!e||!this.terminal)return null;if(this._touchSelectionActive)return this._extendTouchSelection(e.clientX,e.clientY),"select";const s=i??this._classifyMobileTerminalTap(e.clientX,e.clientY),n=this._isActionableMobileTerminalTap(e.clientX,e.clientY);if(!n&&!this._tapIsOnCaretLine(e.clientX,e.clientY)&&this._activateTerminalLinkAtPoint(e.clientX,e.clientY))return"link";if(s==="history")return this._focusMobileTerminalInput(),s;const o=this.terminal.modes?.mouseTrackingMode,l=!!o&&o!=="none",a=s==="content"||t;return a&&l?this._dispatchSyntheticTerminalClick(e.clientX,e.clientY):a&&this._shouldReportMouseToCli()&&this._sendSyntheticSgrTap(e.clientX,e.clientY),s==="content"&&n?this._blurMobileTerminalInput():s==="content"&&t?this._blurMobileTerminalInput():this._focusMobileTerminalInput(),s},_dispatchSyntheticTerminalClick(e,t){const i=this.terminal?.element;if(!i||!Number.isFinite(e)||!Number.isFinite(t))return;const s={bubbles:!0,cancelable:!0,view:window,clientX:e,clientY:t,screenX:e,screenY:t,button:0,detail:1};try{i.dispatchEvent(new MouseEvent("mousedown",{...s,buttons:1})),i.dispatchEvent(new MouseEvent("mouseup",{...s,buttons:0}))}catch{}},_shouldReportMouseToCli(){const e=this.sessions?.get(this.activeSessionId),t=e?.mode||"claude";return t!=="claude"&&t!=="codex"&&t!=="gemini"?!1:e?.cliMouseTracking===!0},_terminalViewportAtBottom(){const e=this.terminal?.buffer?.active;return!e||e.viewportY>=e.baseY},_clientPointToCell(e,t){if(!this.terminal||!Number.isFinite(e)||!Number.isFinite(t))return null;const i=this.terminal.element?.querySelector(".xterm-screen"),s=this.terminal._core?._renderService?.dimensions?.css?.cell;if(!i||!s?.width||!s?.height)return null;const n=i.getBoundingClientRect(),o=Math.max(1,Math.min(this.terminal.cols,Math.floor((e-n.left)/s.width)+1)),l=Math.max(1,Math.min(this.terminal.rows,Math.floor((t-n.top)/s.height)+1));return{col:o,row:l}},_sendSyntheticSgrTap(e,t){if(!this.activeSessionId||!this._terminalViewportAtBottom())return;const i=this._clientPointToCell(e,t);i&&this._sendInputAsync(this.activeSessionId,`\x1B[<0;${i.col};${i.row}M\x1B[<0;${i.col};${i.row}m`)},_cliVersionAtLeast(e,t){if(typeof e!="string")return!1;const i=e.trim().replace(/^v/,"").split(".").map(Number);if(i.length!==3||i.some(n=>!Number.isFinite(n)))return!1;const s=t.split(".").map(Number);for(let n=0;n<3;n++)if(i[n]!==s[n])return i[n]>s[n];return!0},_wheelScrollLines(e){const t=this._wheelScrollLinesFloat(e);return t?Math.round(t)||(t>0?1:-1):0},_wheelScrollLinesFloat(e){const t=e.shiftKey&&Math.abs(e.deltaX)>Math.abs(e.deltaY)?e.deltaX:e.deltaY;return t?e.deltaMode===1?t:e.deltaMode===2?t*(this.terminal?.rows||24):t/25:0},_shouldForwardWheelToApp(e){if(e.shiftKey||this.loadAppSettingsFromStorage?.()?.terminalWheelLocalScrollback)return!1;const t=this.terminal?.modes?.mouseTrackingMode;if(t&&t!=="none")return!1;const i=this.sessions?.get(this.activeSessionId);return!((i?.mode||"claude")!=="claude"||!this._cliVersionAtLeast(i?.cliVersion,"2.1.187")||i?.cliMouseTracking!==!0)},_sendSyntheticSgrWheel(e,t,i){if(!this.activeSessionId||!i)return;const s=this._clientPointToCell(e,t);if(!s)return;const n=i<0?64:65,o=Math.min(Math.abs(i),5);this._queueScrollBytes(`\x1B[<${n};${s.col};${s.row}M`.repeat(o))},_queueScrollBytes(e){if(!e||!this.activeSessionId)return;const t=this._wheelSgrQueue||"";t.length>512||(this._wheelSgrQueue=t+e,!this._wheelSgrFlushTimer&&(this._wheelSgrFlushTimer=setTimeout(()=>this._flushWheelSgrQueue(),40)))},_localScrollbackIsHollow(){if((this.sessions?.get(this.activeSessionId)?.mode||"claude")!=="claude")return!1;const t=this.terminal?.buffer?.active;return!t||t.type==="alternate"?!1:(t.baseY||0)===0},_maybePageCliTranscript(e,t){if(!t||e?.shiftKey||!this.activeSessionId||!this._localScrollbackIsHollow())return!1;this._pageKeySession!==this.activeSessionId&&(this._pageKeySession=this.activeSessionId,this._pageKeyPending=0);const i=window.CodemanTerminalInput,s=Math.max(2,Math.round((this.terminal?.rows||24)*i.PAGE_KEY_SCREEN_FRACTION)),n=(this._pageKeyPending||0)+t,o=Math.trunc(n/s);if(this._pageKeyPending=n-o*s,o){const l=o<0?i.KEY_PAGE_UP:i.KEY_PAGE_DOWN;this._queueScrollBytes(l.repeat(Math.min(Math.abs(o),i.PAGE_KEY_MAX_PER_BATCH)))}return this._logScrollRouting("page-keys"),!0},_logScrollRouting(e){const t=this.activeSessionId||"(none)",i=this.sessions?.get(t),s=!!this.loadAppSettingsFromStorage?.()?.terminalWheelLocalScrollback,n=this.terminal?.modes?.mouseTrackingMode||"none",o=i?.cliMouseTracking===!0,l=this.terminal?.buffer?.active?.baseY??-1,a=`${e}|${i?.mode}|${i?.cliVersion}|${s}|${n}|${o}|${l>0}`;this._scrollRoutingLogged||(this._scrollRoutingLogged=new Map),this._scrollRoutingLogged.get(t)!==a&&(this._scrollRoutingLogged.set(t,a),console.log(`[scroll] ${t} \u2192 ${e} (mode=${i?.mode||"?"}, cliVersion=${i?.cliVersion||"unknown"}, localScrollbackOptOut=${s}, mouseTracking=${n}, cliMouseTracking=${o}, localScrollbackRows=${l})`))},_flushWheelSgrQueue(){this._wheelSgrFlushTimer=null;const e=this._wheelSgrQueue;this._wheelSgrQueue="",e&&this.activeSessionId&&this._sendInputEphemeral(this.activeSessionId,e)},_handleDesktopTerminalClick(e){if(!this.terminal||!e?.isTrusted||e.button!==0||e.detail!==1||e.shiftKey||e.altKey||e.ctrlKey||e.metaKey)return;const t=this.terminal.modes?.mouseTrackingMode;t&&t!=="none"||this._shouldReportMouseToCli()&&(this.terminal.hasSelection?.()||this._linkHovered||performance.now()<=(this._trustedTapMouseSuppressUntil||0)||e.target?.closest?.(".xterm-screen")&&this._sendSyntheticSgrTap(e.clientX,e.clientY))},_installShiftDragSelection(){const e=this.terminal?.element;!e||e._codemanShiftDragInstalled||(e._codemanShiftDragInstalled=!0,e.addEventListener("mousedown",t=>{if(!t.isTrusted||t.button!==0||!t.shiftKey||t.altKey||t.ctrlKey||t.metaKey||this.terminal?.hasSelection?.())return;const i=this._clientPointToCell(t.clientX,t.clientY);if(!i)return;const s=this.terminal.buffer?.active?.viewportY??0;this.terminal.select(i.col-1,i.row-1+s,0)},!0))},_installMobileTapMouseGuard(){const e=this.terminal?.element;if(!e||e._codemanTapMouseGuardInstalled||typeof MobileDetection<"u"&&MobileDetection.isTouchDevice&&!MobileDetection.isTouchDevice())return;e._codemanTapMouseGuardInstalled=!0;const t=i=>{const s=this._trustedTapMouseSuppressUntil||0;!i.isTrusted||performance.now()>s||(i.preventDefault(),i.stopImmediatePropagation())};e.addEventListener("mousedown",t,!0),e.addEventListener("mouseup",t,!0)},_suppressTrustedTapMouseEvents(){const e=window.CodemanTerminalInput?.TOUCH_COMPAT_MOUSE_SUPPRESS_MS||450;this._trustedTapMouseSuppressUntil=performance.now()+e},increaseFontSize(){const e=this.terminal.options.fontSize||14;this.setFontSize(Math.min(e+2,24))},decreaseFontSize(){const e=this.terminal.options.fontSize||14;this.setFontSize(Math.max(e-2,10))},setFontSize(e){this.terminal.options.fontSize=e,document.getElementById("fontSizeDisplay").textContent=e,this._refitAfterCellSizeChange(),localStorage.setItem("codeman-font-size",e),this._localEchoOverlay?.refreshFont(),this._predictiveEcho?.refreshFont(),this._splitPane?.terminal&&(this._splitPane.terminal.options.fontSize=e,this._splitPane.fitAddon?.fit())},applyTerminalFontFamily(e){const t=window.CodemanTerminalFont.resolve(e);!this.terminal||this.terminal.options.fontFamily===t||(this.terminal.options.fontFamily=t,this._terminalFontReady=this._awaitTerminalFont().then(()=>{this.terminal?.options?.fontFamily===t&&this._refitAfterCellSizeChange()}),this._refitAfterCellSizeChange(),this._localEchoOverlay?.refreshFont(),this._predictiveEcho?.refreshFont(),this._splitPane?.terminal&&(this._splitPane.terminal.options.fontFamily=t,this._splitPane.fitAddon?.fit()))},applyTerminalFontWeights(e){const{fontWeight:t,fontWeightBold:i}=window.CodemanTerminalFont.resolveWeights(e);if(this.terminal&&!(this.terminal.options.fontWeight===t&&this.terminal.options.fontWeightBold===i)){this.terminal.options.fontWeight=t,this.terminal.options.fontWeightBold=i,this._terminalFontReady=this._awaitTerminalFont().then(()=>{this.terminal?.options?.fontWeight===t&&this._refitAfterCellSizeChange()}),this._refitAfterCellSizeChange(),this._localEchoOverlay?.refreshFont(),this._predictiveEcho?.refreshFont();for(const[,s]of this.teammateTerminals||[])if(s?.terminal){s.terminal.options.fontWeight=t,s.terminal.options.fontWeightBold=i;try{s.fitAddon?.fit()}catch{}}this._splitPane?.terminal&&(this._splitPane.terminal.options.fontWeight=t,this._splitPane.terminal.options.fontWeightBold=i,this._splitPane.fitAddon?.fit())}},loadFontSize(){const e=localStorage.getItem("codeman-font-size");if(e){const t=parseInt(e,10);t>=10&&t<=24&&(this.terminal.options.fontSize=t,document.getElementById("fontSizeDisplay").textContent=t)}},async _awaitTerminalFont(){try{if(typeof document>"u"||!document.fonts?.load)return;const e=this.terminal?.options?.fontSize||14,t=String(this.terminal?.options?.fontFamily||"").split(",").map(s=>s.trim().replace(/^["']|["']$/g,"")).filter(Boolean).filter(s=>!TERMINAL_FONT_UNMEASURED.has(s.toLowerCase())),i=Promise.all(t.map(s=>document.fonts.load(`${e}px "${s}"`).catch(()=>{}))).then(()=>document.fonts.ready);await Promise.race([i,new Promise(s=>setTimeout(s,TERMINAL_FONT_WAIT_MS))])}catch{}try{this.terminal?._core?._charSizeService?.measure()}catch{}},getTerminalDimensions(){try{return window.CodemanTerminalGeometry.clampTerminalDimensions(this.fitAddon?.proposeDimensions())}catch{return null}},syncTerminalGeometry(){if(!this.fitAddon||!this.terminal)return null;try{this.fitAddon.fit()}catch{}const e=this.getTerminalDimensions();return!e||!this._resizeTerminalTo(e)?null:(this._scheduleOverflowAffordanceSync(),e)},_geometryForResizeRequest(){if(!this._paneWidthRefused)return this.syncTerminalGeometry();const e=this.getTerminalDimensions();return!e||!this.terminal||!this._resizeTerminalTo({cols:this.terminal.cols,rows:e.rows})?null:(this._scheduleOverflowAffordanceSync(),e)},_refitAfterCellSizeChange(){if(this.activeSessionId){this.sendResize(this.activeSessionId)?.catch?.(()=>{});return}this.syncTerminalGeometry()},_resizeTerminalTo(e){if(!this.terminal||!e)return null;if(this.terminal.cols===e.cols&&this.terminal.rows===e.rows)return e;try{return this.terminal.resize(e.cols,e.rows),e}catch{return null}},async sendResize(e,t={}){if(!this.isSoloWindow&&this.detachedSessions?.has(e))return!1;const i=this._geometryForResizeRequest();if(!i)return!1;const s=this._lastResizeDims,n=!s||s.cols!==i.cols||s.rows!==i.rows;this._lastResizeDims={cols:i.cols,rows:i.rows};const o=typeof MobileDetection<"u"&&MobileDetection.getDeviceType?MobileDetection.getDeviceType():window.innerWidth<600?"mobile":window.innerWidth<768?"tablet":"desktop";if(!t.forceHttp&&this._wsReady&&this._wsSessionId===e)try{const h={t:"z",c:i.cols,r:i.rows,v:o};return t.force&&(h.f=!0),this._ws.send(JSON.stringify(h)),n}catch{}const l={...i,viewportType:o};t.force&&(l.force=!0);const a=await fetch(`/api/sessions/${e}/resize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});try{const h=(await a.json())?.data??{};this._onPtyGeometryReport(e,h.cols,h.rows)}catch{}return n},_onPtyGeometryReport(e,t,i){if(!this.terminal||e!==this.activeSessionId)return;const s={cols:this.terminal.cols,rows:this.terminal.rows},{adopt:n}=window.CodemanTerminalGeometry.reconcilePtyGeometry(s,{cols:t,rows:i});n&&this._resizeTerminalTo({cols:t,rows:s.rows})&&(this._lastResizeDims={cols:t,rows:s.rows});const o=this.getTerminalDimensions();this._paneWidthRefused=!!o&&Number.isFinite(t)&&t!==o.cols,this._scheduleOverflowAffordanceSync()},_scheduleOverflowAffordanceSync(){if(typeof requestAnimationFrame!="function"){this._syncTerminalOverflowAffordance();return}this._overflowAffordanceFrame||(this._overflowAffordanceFrame=requestAnimationFrame(()=>{this._overflowAffordanceFrame=null,this._syncTerminalOverflowAffordance()}))},_syncTerminalOverflowAffordance(){let e=null,t=!1;try{e=document.getElementById("terminalContainer");const i=e?.querySelector(".xterm-screen");e&&i&&(t=i.getBoundingClientRect().width-e.clientWidth>1)}catch{}if(e?.classList.toggle("term-overflows-x",t),!t||!this._paneWidthRefused){this._paneOwnedElsewhere=!1;return}this._notePaneOwnedElsewhere()},_notePaneOwnedElsewhere(){this._paneOwnedElsewhere||(this._paneOwnedElsewhere=!0,this.showToast("Another device is setting the width \u2014 scroll sideways","info"))},async sendInput(e){!this.activeSessionId||!e||this._sendInputAsync(this.activeSessionId,e,{useMux:!0})},toggleDirInput(){const e=document.querySelector("#dirDisplay").parentElement,t=document.getElementById("dirInput");t.classList.contains("hidden")&&(t.classList.remove("hidden"),e.style.display="none",t.focus())},hideDirInput(){const e=document.querySelector("#dirDisplay").parentElement,t=document.getElementById("dirInput");setTimeout(()=>{t.classList.add("hidden"),e.style.display="";const i=t.value.trim();document.getElementById("dirDisplay").textContent=i||"No directory"},100)},applyTerminalSkin(e){const t={...window.CODEMAN_XTERM_THEMES[e]||window.CODEMAN_XTERM_THEMES["daylight-blue"]},i=window.codemanCurrentSkinIsLight(e)?4.5:1;if(this.terminal){this.terminal.options.minimumContrastRatio=i,this.terminal.options.theme=t,this._localEchoOverlay?.refreshFont(),this._predictiveEcho?.refreshFont();try{this.terminal.refresh(0,this.terminal.rows-1)}catch{}}if(this.teammateTerminals){for(const[,s]of this.teammateTerminals)if(s&&s.terminal){s.terminal.options.minimumContrastRatio=i,s.terminal.options.theme={...t};try{s.terminal.refresh(0,s.terminal.rows-1)}catch{}}}if(this._splitPane?.terminal){this._splitPane.terminal.options.minimumContrastRatio=i,this._splitPane.terminal.options.theme={...t};try{this._splitPane.terminal.refresh(0,this._splitPane.terminal.rows-1)}catch{}}}}),(function(e){const s={session:"Sessions",event:"Events",file:"Files"};function n(o){if(!Number.isFinite(o))return"";const l=new Date(o);return l.toLocaleDateString("en",{month:"short",day:"numeric"})+" "+l.toLocaleTimeString("en",{hour:"2-digit",minute:"2-digit",hour12:!1})}e.CodemanSearch={SEARCH_DEBOUNCE_MS:250,SEARCH_LIMIT:60,SOURCE_LABELS:s,formatSearchTime:n}})(window),Object.assign(CodemanApp.prototype,{initSearchPanel(){const e=document.getElementById("searchInput");if(!e||this._searchPanelWired){this._searchPanelWired&&this._populateSearchCaseFilter();return}this._searchPanelWired=!0,this._searchTypes=new Set(["session","event","file"]),this._searchSecondary={caseLabel:"",status:"",days:""},this._searchDebounceTimer=null,this._searchSeq=0,this._searchLastData=null;const t=document.getElementById("searchClearBtn"),i=document.getElementById("searchResults");e.addEventListener("input",()=>{t&&(t.hidden=e.value.length===0),this._scheduleSearch()}),e.addEventListener("keydown",l=>{l.key==="Escape"&&e.value&&(l.stopPropagation(),this._clearSearch())}),t&&t.addEventListener("click",()=>this._clearSearch()),document.querySelectorAll("#searchFilters .search-filter-chip").forEach(l=>{l.addEventListener("click",()=>{const a=l.dataset.typeFilter;this._searchTypes.has(a)&&this._searchTypes.size===1||(this._searchTypes.has(a)?(this._searchTypes.delete(a),l.classList.remove("active")):(this._searchTypes.add(a),l.classList.add("active")),this._runSearch())})});const s=document.getElementById("searchCaseFilter"),n=document.getElementById("searchStatusFilter"),o=document.getElementById("searchDateFilter");s&&s.addEventListener("change",()=>{this._searchSecondary.caseLabel=s.value,this._renderSearch(this._searchLastData)}),n&&n.addEventListener("change",()=>{this._searchSecondary.status=n.value,this._renderSearch(this._searchLastData)}),o&&o.addEventListener("change",()=>{this._searchSecondary.days=o.value,this._renderSearch(this._searchLastData)}),this._populateSearchCaseFilter(),i&&(i.hidden=!0)},_populateSearchCaseFilter(){const e=document.getElementById("searchCaseFilter");if(!e)return;const t=Array.isArray(this.cases)?this.cases:[],i=Array.from(new Set(t.map(o=>o&&o.name).filter(Boolean))).sort(),s=e.value;e.innerHTML="";const n=document.createElement("option");n.value="",n.textContent="All cases",e.appendChild(n);for(const o of i){const l=document.createElement("option");l.value=o,l.textContent="#"+o,e.appendChild(l)}s&&i.includes(s)&&(e.value=s)},_scheduleSearch(){clearTimeout(this._searchDebounceTimer),this._searchDebounceTimer=setTimeout(()=>this._runSearch(),window.CodemanSearch.SEARCH_DEBOUNCE_MS)},_clearSearch(){const e=document.getElementById("searchInput"),t=document.getElementById("searchClearBtn");e&&(e.value=""),t&&(t.hidden=!0),this._searchLastData=null,this._renderSearch(null)},async _runSearch(){const e=document.getElementById("searchInput");if(!e)return;const t=e.value.trim();if(t.length===0){this._searchLastData=null,this._renderSearch(null);return}const i=Array.from(this._searchTypes),s=new URLSearchParams;s.set("q",t.slice(0,200)),i.length>0&&i.length<3&&s.set("types",i.join(",")),s.set("limit",String(window.CodemanSearch.SEARCH_LIMIT));const n=++this._searchSeq,o=await this._apiJson("/api/search?"+s.toString());n===this._searchSeq&&(o?this._searchLastData=o:this._searchLastData={query:t,groups:[],totalResults:0,truncated:!1,_error:!0},this._renderSearch(this._searchLastData))},_applySecondaryFilters(e){const{caseLabel:t,status:i,days:s}=this._searchSecondary;let n=e;if(t){const o="#"+t;n=n.filter(l=>(l.sessionName||"").includes(o)||l.sessionName===t)}if(i){const o=new Set((this.sessionOrder||[]).concat(Object.keys(this.sessions||{})));n=n.filter(l=>{const a=o.has(l.sessionId);return i==="active"?a:!a})}if(s){const o=Date.now()-Number(s)*24*60*60*1e3;n=n.filter(l=>Number.isFinite(l.timestamp)&&l.timestamp>=o)}return n},_renderSearch(e){const t=document.getElementById("searchResults"),i=document.getElementById("historyHeader")||document.getElementById("historyTitle"),s=document.getElementById("historyList");if(!t)return;const n=!!e;if(i&&(i.style.display=n?"none":""),s&&(s.style.display=n?"none":""),t.innerHTML="",!e){t.hidden=!0;return}if(t.hidden=!1,e._error){const a=document.createElement("div");a.className="search-empty",a.textContent="Search unavailable \u2014 check the query and try again.",t.appendChild(a);return}const o=(e.groups||[]).map(a=>({type:a.type,results:this._applySecondaryFilters(a.results||[])})).filter(a=>a.results.length>0);if(o.reduce((a,h)=>a+h.results.length,0)===0){const a=document.createElement("div");a.className="search-empty",a.textContent='No results for "'+(e.query||"")+'"',t.appendChild(a);return}for(const a of o){const h=document.createElement("div");h.className="search-group-header";const u=document.createElement("span");u.className="search-group-label",u.textContent=window.CodemanSearch.SOURCE_LABELS[a.type]||a.type;const m=document.createElement("span");m.className="search-group-count",m.textContent=String(a.results.length),h.append(u,m),t.appendChild(h);for(const c of a.results)t.appendChild(this._buildSearchResultCard(c))}if(e.truncated){const a=document.createElement("div");a.className="search-truncated",a.textContent="Showing the top matches \u2014 refine your search to narrow results.",t.appendChild(a)}},_buildSearchResultCard(e){const t=document.createElement("div");t.className="search-result-card",t.dataset.type=e.type,t.tabIndex=0,t.setAttribute("role","button");const i=document.createElement("div");i.className="search-result-top";const s=e.jumpTo&&e.jumpTo.kind==="resume-session",n=document.createElement("span");n.className="search-result-badge search-badge-"+e.type+(s?" search-badge-past":""),n.textContent=s?"Resume":(window.CodemanSearch.SOURCE_LABELS[e.type]||e.type).replace(/s$/,"");const o=document.createElement("span");o.className="search-result-name",o.textContent=e.sessionName||e.sessionId||"(session)";const l=document.createElement("span");l.className="search-result-time",l.textContent=window.CodemanSearch.formatSearchTime(e.timestamp),i.append(n,o,l);const a=document.createElement("div");a.className="search-result-snippet",a.textContent=e.snippet||"",t.append(i,a);const h=()=>this._jumpToSearchResult(e);return t.addEventListener("click",h),t.addEventListener("keydown",u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),h())}),t},_jumpToSearchResult(e){const t=e&&e.jumpTo;if(t){if(t.kind==="resume-session"){this.resumeHistorySession(t.claudeSessionId||t.sessionId,t.workingDir||"",e.sessionName);return}typeof this.hideWelcome=="function"&&this.hideWelcome();try{t.kind==="run-summary"?this.openRunSummary(t.sessionId):t.kind==="file-preview"?this.openFilePreview(t.relativePath||"",t.sessionId,t.targetId||null):this.selectSession(t.sessionId)}catch(i){console.error("[search] jump failed",i)}}}});
|
|
Binary file
|
|
Binary file
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
"use strict";var XtermZerolagInput=(()=>{var C=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var z=(r,e)=>{for(var t in e)C(r,t,{get:e[t],enumerable:!0})},A=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of W(e))!I.call(r,i)&&i!==t&&C(r,i,{get:()=>e[i],enumerable:!(s=M(e,i))||s.enumerable});return r};var B=r=>A(C({},"__esModule",{value:!0}),r);var V={};z(V,{ZerolagInputAddon:()=>S});function L(r){let e=r,t=typeof devicePixelRatio=="number"&&devicePixelRatio>0?devicePixelRatio:1;if(e.dimensions?.css?.cell){let s=e.dimensions.css.cell.height;return{width:e.dimensions.css.cell.width,height:s,charTop:(e.dimensions?.device?.char?.top??0)/t,charHeight:(e.dimensions?.device?.char?.height??s*t)/t}}try{let s=e._core?._renderService?.dimensions;if(s?.css?.cell){let i=s.css.cell.height;return{width:s.css.cell.width,height:i,charTop:(s.device?.char?.top??0)/t,charHeight:(s.device?.char?.height??i*t)/t}}}catch{}return null}function F(r,e){try{let t=r.buffer.active,s=t.viewportY;switch(e.type){case"character":{for(let i=r.rows-1;i>=0;i--){let o=t.getLine(s+i);if(!o)continue;let _=o.translateToString(!0).lastIndexOf(e.char);if(_>=0)return{row:i,col:_}}return null}case"regex":{let i=e.pattern,o=i.global?new RegExp(i.source,i.flags.replace("g","")):i;for(let f=r.rows-1;f>=0;f--){let _=t.getLine(s+f);if(!_)continue;let d=_.translateToString(!0).match(o);if(d){let l=d.index??0;return{row:f,col:l}}}return null}case"custom":return e.find(r);default:return null}}catch{return null}}function O(r,e,t){try{let s=r.buffer.active,i=s.viewportY+e.row,o=s.getLine(i);return o?o.translateToString(!0).slice(e.col+t).trimEnd():""}catch{return""}}function w(r,e){if(r?.unicode?.getStringCellWidth)return r.unicode.getStringCellWidth(e);let t=e.codePointAt(0);return t!==void 0&&t>=4352&&(t<=4447||t>=11904&&t<=12350||t>=12352&&t<=13247||t>=13312&&t<=19903||t>=19968&&t<=42191||t>=43360&&t<=43388||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65072&&t<=65135||t>=65281&&t<=65376||t>=65504&&t<=65510||t>=126976&&t<=130047||t>=131072&&t<=196607||t>=196608&&t<=262143)?2:1}function K(r,e){let t=0;for(let s of e)t+=w(r,s);return t}function R(r,e){let{lines:t,startCol:s,totalCols:i,cellW:o,cellH:f,charTop:_,charHeight:u,promptRow:d,totalRows:l,font:m,showCursor:y,cursorColor:v,terminal:n}=e,c=l&&l>0?l:n?.rows,p=t,a=!0,P=d;c&&c>0&&(t.length>c?(p=t.slice(t.length-c),a=!1,P=0):d+t.length>c&&(P=c-t.length)),P=Math.max(0,P),r.style.left="0px",r.style.top=P*f+"px",r.innerHTML="";let x=i*o;for(let h=0;h<p.length;h++){let g=h===0&&a,b=g?s*o:0,T=g?x-b:x,k=h*f,X=U(p[h],b,k,T,f,o,_,u,m,n);r.appendChild(X)}if(y){let h=p[p.length-1],b=(p.length===1&&a?s:0)+K(n,h);if(b<i){let T=document.createElement("span");T.style.cssText="position:absolute;display:inline-block",T.style.left=b*o+"px",T.style.top=(p.length-1)*f+"px",T.style.width=o+"px",T.style.height=f+"px",T.style.backgroundColor=v,r.appendChild(T)}}r.style.display=""}function U(r,e,t,s,i,o,f,_,u,d){let l=document.createElement("div");l.style.cssText="position:absolute;pointer-events:none",l.style.backgroundColor=u.backgroundColor,l.style.left=e+"px",l.style.top=t+"px",l.style.width=s+"px",l.style.height=i+1+"px";let m=0;for(let y of r){let v=w(d,y),n=document.createElement("span");n.style.cssText="position:absolute;display:inline-block;text-align:center;pointer-events:none;font-feature-settings:'liga' 0,'calt' 0",n.style.left=m*o+"px",n.style.top="0px",n.style.width=v*o+"px",n.style.height=i+"px",n.style.lineHeight=i+"px",n.style.fontFamily=u.fontFamily,n.style.fontSize=u.fontSize,n.style.fontWeight=u.fontWeight,n.style.color=u.color,u.letterSpacing&&(n.style.letterSpacing=u.letterSpacing),n.textContent=y,l.appendChild(n),m+=v}return l}var D={type:"character",char:">",offset:2},$=7,Y=50,E="#0d0d0d",H="#eeeeee",Z="#e0e0e0",S=class{_terminal=null;_overlay=null;_options;_pendingText="";_flushedOffset=0;_flushedText="";_bufferDetectDone=!1;_lastRenderKey="";_lastPromptPos=null;_font={fontFamily:"monospace",fontSize:"14px",fontWeight:"normal",color:H,backgroundColor:E,letterSpacing:""};_scrollTimer=null;_scrollHandler=null;_scrollViewport=null;constructor(e){this._options={prompt:e?.prompt??D,zIndex:e?.zIndex??$,showCursor:e?.showCursor??!0,scrollDebounceMs:e?.scrollDebounceMs??Y,backgroundColor:e?.backgroundColor,foregroundColor:e?.foregroundColor,cursorColor:e?.cursorColor}}activate(e){this._terminal=e,this._overlay=document.createElement("div"),this._overlay.style.cssText=`position:absolute;z-index:${this._options.zIndex};pointer-events:none;display:none`;let t=e.element?.querySelector(".xterm-screen");t&&t.appendChild(this._overlay),this._cacheFont(),this._scrollHandler=()=>{try{let i=this._terminal.buffer.active;i.viewportY!==i.baseY?(this._overlay.style.display="none",this._scrollTimer&&(clearTimeout(this._scrollTimer),this._scrollTimer=null)):(this._pendingText||this._flushedOffset>0)&&(this._scrollTimer&&clearTimeout(this._scrollTimer),this._scrollTimer=setTimeout(()=>{this._scrollTimer=null,this._lastRenderKey="",this._render()},this._options.scrollDebounceMs))}catch{}};let s=e.element?.querySelector(".xterm-viewport");s&&(s.addEventListener("scroll",this._scrollHandler,{passive:!0}),this._scrollViewport=s)}dispose(){this.clear(),this._scrollTimer&&(clearTimeout(this._scrollTimer),this._scrollTimer=null),this._scrollViewport&&this._scrollHandler&&this._scrollViewport.removeEventListener("scroll",this._scrollHandler),this._overlay?.remove(),this._overlay=null,this._scrollViewport=null,this._scrollHandler=null,this._terminal=null}addChar(e){!this._pendingText&&!this._flushedOffset&&this._detectBufferText(),this._pendingText+=e,this._render()}appendText(e){e&&(!this._pendingText&&!this._flushedOffset&&this._detectBufferText(),this._pendingText+=e,this._render())}removeChar(){return this._pendingText.length>0?(this._pendingText=this._pendingText.slice(0,-1),this._pendingText.length>0||this._flushedOffset>0?this._render():this._hide(),"pending"):this._flushedOffset>0?(this._flushedOffset--,this._flushedText=this._flushedText.slice(0,-1),this._flushedOffset>0?this._render():this._hide(),"flushed"):(this._detectBufferText(),this._flushedOffset>0?(this._flushedOffset--,this._flushedText=this._flushedText.slice(0,-1),this._flushedOffset>0?this._render():this._hide(),"flushed"):!1)}clear(){this._pendingText="",this._flushedOffset=0,this._flushedText="",this._bufferDetectDone=!1,this._lastRenderKey="",this._lastPromptPos=null,this._hide()}setFlushed(e,t,s=!0){this._flushedOffset=e,this._flushedText=t,s&&this._render()}getFlushed(){return{count:this._flushedOffset,text:this._flushedText}}clearFlushed(){this._flushedOffset=0,this._flushedText="",this._pendingText?this._render():this._hide()}rerender(){(this._pendingText||this._flushedOffset>0)&&(this._lastRenderKey="",this._render())}refreshFont(){this._cacheFont(),this._lastRenderKey="",(this._pendingText||this._flushedOffset>0)&&this._render()}detectBufferText(){return this._detectBufferText()}resetBufferDetection(){this._bufferDetectDone=!1}undoDetection(){this._flushedOffset=0,this._flushedText="",this._bufferDetectDone=!1}suppressBufferDetection(){this._bufferDetectDone=!0}setPrompt(e){this._options.prompt=e,this._lastPromptPos=null,this._lastRenderKey="",(this._pendingText||this._flushedOffset>0)&&this._render()}findPrompt(){return this._terminal?F(this._terminal,this._options.prompt??D):null}readPromptText(){if(!this._terminal)return null;let e=this.findPrompt();if(!e)return null;let t=this._getPromptOffset();return O(this._terminal,e,t)||null}get pendingText(){return this._pendingText}get hasPending(){return this._pendingText.length>0||this._flushedOffset>0}get state(){return{pendingText:this._pendingText,flushedLength:this._flushedOffset,flushedText:this._flushedText,visible:this._overlay!==null&&this._overlay.style.display!=="none",promptPosition:this._lastPromptPos?{...this._lastPromptPos}:null}}_getPromptOffset(){return(this._options.prompt??D).offset??2}_detectBufferText(){if(this._bufferDetectDone||!this._terminal)return null;try{let e=this.findPrompt();if(!e)return null;let t=this._getPromptOffset(),s=O(this._terminal,e,t);if(s.length>0)return this._flushedOffset=s.length,this._flushedText=s,this._lastPromptPos=e,this._bufferDetectDone=!0,s}catch{}return null}_cacheFont(){if(!this._terminal)return;let e=this._terminal;this._font.fontFamily=e.options.fontFamily||"monospace",this._font.fontSize=(e.options.fontSize||14)+"px",this._font.fontWeight=String(e.options.fontWeight||"normal"),this._font.backgroundColor=this._options.backgroundColor??e.options.theme?.background??E,this._font.color=this._options.foregroundColor??e.options.theme?.foreground??H,this._font.letterSpacing="";let t=e.element?.querySelector(".xterm-rows");if(t){let s=getComputedStyle(t);this._font.letterSpacing=s.letterSpacing,!this._options.foregroundColor&&s.color&&(this._font.color=s.color)}}_hide(){this._overlay&&(this._lastRenderKey="",this._lastPromptPos=null,this._overlay.innerHTML="",this._overlay.style.display="none")}_render(){if(!(!this._terminal||!this._overlay)){if(!this._pendingText&&!(this._flushedOffset>0)){this._overlay.style.display="none";return}try{let e=this._terminal.buffer.active;if(e.viewportY!==e.baseY){this._overlay.style.display="none";return}let t=this.findPrompt();if(t)this._lastPromptPos&&this._flushedOffset>0?this._lastPromptPos={row:t.row,col:this._lastPromptPos.col}:this._lastPromptPos=t;else if(!this._lastPromptPos){this._overlay.style.display="none";return}let s=this._lastPromptPos,i=L(this._terminal);if(!i){this._overlay.style.display="none";return}let{width:o,height:f,charTop:_,charHeight:u}=i,d=this._terminal.cols,l=this._getPromptOffset(),m=s.col+l,y=this._pendingText;if(this._flushedOffset>0)if(this._flushedText&&this._flushedText.length===this._flushedOffset)y=this._flushedText+this._pendingText;else{let x=e.viewportY+s.row,h=e.getLine(x);h&&(y=h.translateToString(!0).slice(m,m+this._flushedOffset)+this._pendingText)}let v=`${y}:${m}:${s.row}:${s.col}:${d}:${this._terminal.rows}:${this._flushedOffset}`;if(v===this._lastRenderKey&&this._overlay.style.display!=="none")return;this._lastRenderKey=v;let n=Math.max(1,d-m),c=[...y],p=[],a=0;{let x="",h=0;for(;a<c.length;){let g=w(this._terminal,c[a]);if(h+g>n)break;x+=c[a],h+=g,a++}p.push(x)}for(;a<c.length;){let x="",h=0;for(;a<c.length;){let g=w(this._terminal,c[a]);if(h+g>d)break;x+=c[a],h+=g,a++}p.push(x)}let P=this._options.cursorColor??this._terminal.options.theme?.cursor??Z;R(this._overlay,{lines:p,startCol:m,totalCols:d,cellW:o,cellH:f,charTop:_,charHeight:u,promptRow:s.row,totalRows:this._terminal.rows,font:this._font,showCursor:this._options.showCursor,cursorColor:P,terminal:this._terminal})}catch{this._overlay&&(this._overlay.innerHTML="",this._overlay.style.display="none")}}}};return B(V);})();
|
|
2
|
-
|
|
3
|
-
// Global aliases for browser usage
|
|
4
|
-
if(typeof window!=="undefined"){window.ZerolagInputAddon=XtermZerolagInput.ZerolagInputAddon;window.LocalEchoOverlay=class extends XtermZerolagInput.ZerolagInputAddon{constructor(terminal){super({prompt:{type:"character",char:"\u276f",offset:2}});this.activate(terminal);}};}
|
|
Binary file
|
|
Binary file
|