aicodeman 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/buffer-limits.d.ts +6 -1
- package/dist/config/buffer-limits.d.ts.map +1 -1
- package/dist/config/buffer-limits.js +10 -5
- package/dist/config/buffer-limits.js.map +1 -1
- package/dist/web/public/api-client.3adebdc2.js.gz +0 -0
- package/dist/web/public/app.e09fd4a6.js +26 -0
- package/dist/web/public/app.e09fd4a6.js.br +0 -0
- package/dist/web/public/app.e09fd4a6.js.gz +0 -0
- package/dist/web/public/constants.64161167.js.gz +0 -0
- package/dist/web/public/index.html +18 -8
- package/dist/web/public/index.html.br +0 -0
- package/dist/web/public/index.html.gz +0 -0
- package/dist/web/public/input-cjk.88082175.js +1 -0
- package/dist/web/public/input-cjk.88082175.js.br +0 -0
- package/dist/web/public/input-cjk.88082175.js.gz +0 -0
- package/dist/web/public/keyboard-accessory.9fb81db6.js.gz +0 -0
- package/dist/web/public/mobile-handlers.1e2a8ef8.js.gz +0 -0
- package/dist/web/public/{mobile.fdd28a54.css → mobile.0b213796.css} +1 -1
- package/dist/web/public/mobile.0b213796.css.br +0 -0
- package/dist/web/public/{mobile.fdd28a54.css.gz → mobile.0b213796.css.gz} +0 -0
- package/dist/web/public/notification-manager.2d5ea8ec.js.gz +0 -0
- package/dist/web/public/orchestrator-panel.js.gz +0 -0
- package/dist/web/public/panels-ui.8204db1e.js.gz +0 -0
- package/dist/web/public/ralph-panel.a2733fd5.js.gz +0 -0
- package/dist/web/public/ralph-wizard.f31ab90e.js.gz +0 -0
- package/dist/web/public/respawn-ui.372c6ea7.js.gz +0 -0
- package/dist/web/public/session-ui.72f2f538.js +16 -0
- package/dist/web/public/session-ui.72f2f538.js.br +0 -0
- package/dist/web/public/session-ui.72f2f538.js.gz +0 -0
- package/dist/web/public/{settings-ui.94c57184.js → settings-ui.bd3eaadb.js} +4 -4
- package/dist/web/public/settings-ui.bd3eaadb.js.br +0 -0
- package/dist/web/public/settings-ui.bd3eaadb.js.gz +0 -0
- package/dist/web/public/styles.111ff326.css +1 -0
- package/dist/web/public/styles.111ff326.css.br +0 -0
- package/dist/web/public/styles.111ff326.css.gz +0 -0
- package/dist/web/public/subagent-windows.a366a4ad.js.gz +0 -0
- package/dist/web/public/sw.js.gz +0 -0
- package/dist/web/public/terminal-ui.474f79df.js +3 -0
- package/dist/web/public/terminal-ui.474f79df.js.br +0 -0
- package/dist/web/public/terminal-ui.474f79df.js.gz +0 -0
- package/dist/web/public/upload.html.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-fit.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-unicode11.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-webgl.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-zerolag-input.137ad9f0.js.gz +0 -0
- package/dist/web/public/vendor/xterm.css.gz +0 -0
- package/dist/web/public/vendor/xterm.min.js.gz +0 -0
- package/dist/web/public/voice-input.085e9e73.js.gz +0 -0
- package/package.json +1 -1
- package/dist/web/public/app.916baeb9.js +0 -26
- package/dist/web/public/app.916baeb9.js.br +0 -0
- package/dist/web/public/app.916baeb9.js.gz +0 -0
- package/dist/web/public/input-cjk.92544c51.js +0 -1
- package/dist/web/public/input-cjk.92544c51.js.br +0 -0
- package/dist/web/public/input-cjk.92544c51.js.gz +0 -0
- package/dist/web/public/mobile.fdd28a54.css.br +0 -0
- package/dist/web/public/session-ui.0a07c3b7.js +0 -16
- package/dist/web/public/session-ui.0a07c3b7.js.br +0 -0
- package/dist/web/public/session-ui.0a07c3b7.js.gz +0 -0
- package/dist/web/public/settings-ui.94c57184.js.br +0 -0
- package/dist/web/public/settings-ui.94c57184.js.gz +0 -0
- package/dist/web/public/styles.5c87d847.css +0 -1
- package/dist/web/public/styles.5c87d847.css.br +0 -0
- package/dist/web/public/styles.5c87d847.css.gz +0 -0
- package/dist/web/public/terminal-ui.b66dbf4e.js +0 -3
- package/dist/web/public/terminal-ui.b66dbf4e.js.br +0 -0
- package/dist/web/public/terminal-ui.b66dbf4e.js.gz +0 -0
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use strict";Object.assign(CodemanApp.prototype,{initTerminal(){const t=parseInt(localStorage.getItem("codeman-scrollback"))||DEFAULT_SCROLLBACK;if(this.terminal=new Terminal({theme:{background:"#0d0d0d",foreground:"#e0e0e0",cursor:"#e0e0e0",cursorAccent:"#0d0d0d",selection:"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"},fontFamily:'"Fira Code", "Cascadia Code", "JetBrains Mono", "SF Mono", Monaco, monospace',fontSize:MobileDetection.getDeviceType()==="mobile"?10:14,lineHeight:1.2,cursorBlink:!1,cursorStyle:"block",scrollback:t,allowTransparency:!0,allowProposedApi:!0}),this.fitAddon=new FitAddon.FitAddon,this.terminal.loadAddon(this.fitAddon),typeof Unicode11Addon<"u")try{const e=new Unicode11Addon.Unicode11Addon;this.terminal.loadAddon(e),this.terminal.unicode.activeVersion="11"}catch{}const i=document.getElementById("terminalContainer");if(this.terminal.open(i),this.terminal.attachCustomKeyEventHandler(e=>!(e.isComposing||e.keyCode===229)),this._webglAddon=null,!(MobileDetection.getDeviceType()!=="desktop")&&!new URLSearchParams(location.search).has("nowebgl"))if(typeof WebglAddon<"u")this._initWebGL();else{const e=document.createElement("script");e.src="vendor/xterm-addon-webgl.min.js",e.onload=()=>this._initWebGL(),e.onerror=()=>console.warn("[CRASH-DIAG] Failed to load WebGL addon \u2014 using canvas renderer"),document.head.appendChild(e)}this._localEchoOverlay=new LocalEchoOverlay(this.terminal),this._cjkInput=null,typeof CjkInput<"u"&&(this._cjkInput=CjkInput.init({send:e=>{this.activeSessionId&&this._sendInputAsync(this.activeSessionId,e)}})),MobileDetection.getDeviceType()==="mobile"&&document.body.classList.contains("safari-browser")?requestAnimationFrame(()=>{this.fitAddon.fit(),requestAnimationFrame(()=>this.fitAddon.fit())}):this.fitAddon.fit(),this.registerFilePathLinkProvider(),i.addEventListener("wheel",e=>{e.preventDefault();const a=Math.round(e.deltaY/25)||(e.deltaY>0?1:-1);this.terminal.scrollLines(a)},{passive:!1});{const e=()=>this.terminal._core?._renderService?.dimensions?.css?.cell?.height||13;let a=0,c=0,u=0,l=null,h=!1;const p=_=>{const g=u?(_-u)/16.67:1;if(u=_,!h&&Math.abs(c)>.3){const y=Math.round(c/e());y!==0&&this.terminal.scrollLines(y),c*=.92,l=requestAnimationFrame(p)}else h?l=requestAnimationFrame(p):(l=null,c=0)};let m=0;i.addEventListener("touchstart",_=>{_.touches.length===1&&(a=_.touches[0].clientY,c=0,m=0,h=!0,u=0,l&&(cancelAnimationFrame(l),l=null))},{passive:!0}),i.addEventListener("touchmove",_=>{if(_.touches.length===1&&h){const g=_.touches[0].clientY,y=a-g;m+=y,c=y*1.2,a=g;const S=e(),b=Math.trunc(m/S);b!==0&&(this.terminal.scrollLines(b),m-=b*S)}},{passive:!0}),i.addEventListener("touchend",()=>{h=!1,!l&&Math.abs(c)>.3&&(l=requestAnimationFrame(p))},{passive:!0}),i.addEventListener("touchcancel",()=>{h=!1,c=0,m=0},{passive:!0})}this.showWelcome(),this._chunkedWriteGen=0,this._resizeTimeout=null,this._lastResizeDims=null;const d=40,f=10,o=()=>{this._resizeTimeout&&clearTimeout(this._resizeTimeout),this._resizeTimeout=setTimeout(()=>{this._resizeTimeout=null,this.fitAddon&&this.fitAddon.fit(),this.flickerFilterBuffer&&(this.flickerFilterTimeout&&(clearTimeout(this.flickerFilterTimeout),this.flickerFilterTimeout=null),this.flushFlickerBuffer());const e=this.activeSessionId?this.sessions.get(this.activeSessionId):null;e&&e.mode!=="shell"&&!e._ended&&this.terminal&&this.isTerminalAtBottom()&&this.terminal.write("\x1B[3J\x1B[H\x1B[2J");const a=typeof KeyboardHandler<"u"&&KeyboardHandler.keyboardVisible;if(this.activeSessionId&&!a){const c=this.fitAddon.proposeDimensions(),u=c?Math.max(c.cols,d):d,l=c?Math.max(c.rows,f):f;(!this._lastResizeDims||u!==this._lastResizeDims.cols||l!==this._lastResizeDims.rows)&&(this._lastResizeDims={cols:u,rows:l},fetch(`/api/sessions/${this.activeSessionId}/resize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cols:u,rows:l})}).catch(()=>{}))}this.updateConnectionLines(),this._localEchoOverlay?.hasPending&&this._localEchoOverlay.rerender()},300)};window.addEventListener("resize",o),this.terminalResizeObserver&&this.terminalResizeObserver.disconnect(),this.terminalResizeObserver=new ResizeObserver(o),this.terminalResizeObserver.observe(i),this._pendingInput="",this._inputFlushTimeout=null,this._lastKeystrokeTime=0;const r=()=>{if(this._inputFlushTimeout=null,this._pendingInput&&this.activeSessionId){const e=this._pendingInput,a=this.activeSessionId;this._pendingInput="",this._sendInputAsync(a,e)}};this.terminal.onData(e=>{if(!(window.cjkActive||document.activeElement?.id==="cjkInput")&&this.activeSessionId){if(/^\x1b\[[\?>=]?[\d;]*[cnR]$/.test(e))return;if(this._localEchoEnabled){if(e==="\x7F"){if(this._localEchoOverlay?.removeChar()==="flushed"){const{count:u,text:l}=this._localEchoOverlay.getFlushed();this._flushedOffsets?.has(this.activeSessionId)&&(u===0?(this._flushedOffsets.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId)):(this._flushedOffsets.set(this.activeSessionId,u),this._flushedTexts?.set(this.activeSessionId,l))),this._pendingInput+=e,r()}return}if(/^[\r\n]+$/.test(e)){const c=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),c&&(this._pendingInput+=c,r()),setTimeout(()=>{this._pendingInput+="\r",r()},80);return}if(e.length>1&&e.charCodeAt(0)>=32){this._localEchoOverlay?.appendText(e);return}if(e.charCodeAt(0)<32){if(e.length>1&&e.charCodeAt(0)===27){this._pendingInput+=e,r();return}if(this._restoringFlushedState){this._pendingInput+=e,r();return}if(e===" "){const u=this._localEchoOverlay?.pendingText||"";this._localEchoOverlay?.clear(),this._flushedOffsets?.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId),u&&(this._pendingInput+=u),this._pendingInput+=e,this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null);let l="";try{const p=this._localEchoOverlay?.findPrompt?.();if(p){const m=this.terminal.buffer.active,_=m.getLine(m.viewportY+p.row);_&&(l=_.translateToString(!0).slice(p.col+2).trimEnd())}}catch{}this._tabCompletionBaseText=l,r(),this._tabCompletionSessionId=this.activeSessionId,this._tabCompletionRetries=0,this._tabCompletionFallback&&clearTimeout(this._tabCompletionFallback);const h=this;this._tabCompletionFallback=setTimeout(()=>{if(h._tabCompletionFallback=null,!h._tabCompletionSessionId||h._tabCompletionSessionId!==h.activeSessionId)return;const p=h._localEchoOverlay;!p||p.pendingText||h.terminal.write("",()=>{if(!h._tabCompletionSessionId)return;p.resetBufferDetection();const m=p.detectBufferText();m&&m!==h._tabCompletionBaseText&&(h._tabCompletionSessionId=null,h._tabCompletionRetries=0,h._tabCompletionBaseText=null,p.rerender())})},300);return}const c=this._localEchoOverlay?.pendingText||"";this._localEchoOverlay?.clear(),this._localEchoOverlay?.suppressBufferDetection(),this._flushedOffsets?.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId),c&&(this._pendingInput+=c),this._pendingInput+=e,this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null),r();return}if(e.length===1&&e.charCodeAt(0)>=32){this._localEchoOverlay?.addChar(e);return}}if(this._pendingInput+=e,e.charCodeAt(0)<32||e.length>1){this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null),r();return}const a=performance.now();a-this._lastKeystrokeTime>50?(this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null),this._lastKeystrokeTime=a,r()):(this._lastKeystrokeTime=a,this._inputFlushTimeout||(this._inputFlushTimeout=setTimeout(r,0)))}})},registerFilePathLinkProvider(){const t=this;let i=-1;this.terminal.registerLinkProvider({provideLinks(n,s){n!==i&&(i=n,console.debug("[LinkProvider] Checking line:",n));const f=t.terminal.buffer.active.getLine(n);if(!f){s(void 0);return}const o=f.translateToString(!0);if(!o||!o.includes("/")){s(void 0);return}const r=[],e=/(tail|cat|head|less|grep|watch|vim|nano)\s+(?:[^\s\/]*\s+)*(\/[^\s"'<>|;&\n\x00-\x1f]+)/g,a=/(\/(?:home|tmp|var|etc|opt)[^\s"'<>|;&\n\x00-\x1f]*\.(?:log|txt|json|md|yaml|yml|csv|xml|sh|py|ts|js))\b/g,c=/Bash\([^)]*?(\/(?:home|tmp|var|etc|opt)[^\s"'<>|;&\)\n\x00-\x1f]+)/g,u=(h,p)=>{const m=o.indexOf(h,p);m!==-1&&(r.some(_=>_.range.start.x===m+1)||r.push({text:h,range:{start:{x:m+1,y:n},end:{x:m+h.length+1,y:n}},decorations:{pointerCursor:!0,underline:!0},activate(_,g){t.openLogViewerWindow(g,t.activeSessionId)}}))};let l;for(e.lastIndex=0;(l=e.exec(o))!==null;)u(l[2],l.index);for(a.lastIndex=0;(l=a.exec(o))!==null;)u(l[1],l.index);for(c.lastIndex=0;(l=c.exec(o))!==null;)u(l[1],l.index);r.length>0&&console.debug("[LinkProvider] Found links:",r.map(h=>h.text)),s(r.length>0?r:void 0)}}),console.log("[LinkProvider] File path link provider registered")},showWelcome(){const t=document.getElementById("welcomeOverlay");t&&(t.classList.add("visible"),this.loadTunnelStatus(),this.loadHistorySessions())},hideWelcome(){const t=document.getElementById("welcomeOverlay");t&&t.classList.remove("visible");const i=document.getElementById("welcomeQr");i&&(clearTimeout(this._welcomeQrShrinkTimer),i.classList.remove("expanded"))},async _fetchHistorySessions(t=12){const s=(await(await fetch("/api/history/sessions")).json()).sessions||[];if(s.length===0)return[];const d=new Map;for(const o of s)d.has(o.workingDir)||d.set(o.workingDir,[]),d.get(o.workingDir).push(o);const f=[];for(const[,o]of d)f.push(...o.slice(0,2));return f.sort((o,r)=>new Date(r.lastModified)-new Date(o.lastModified)),f.slice(0,t)},async loadHistorySessions(){const t=document.getElementById("historySessions"),i=document.getElementById("historyList");if(!(!t||!i))try{const n=await this._fetchHistorySessions(12);if(n.length===0){t.style.display="none";return}i.replaceChildren();for(const s of n){const d=s.sizeBytes<1024?`${s.sizeBytes}B`:s.sizeBytes<1048576?`${(s.sizeBytes/1024).toFixed(0)}K`:`${(s.sizeBytes/1048576).toFixed(1)}M`,f=new Date(s.lastModified),o=f.toLocaleDateString("en",{month:"short",day:"numeric"})+" "+f.toLocaleTimeString("en",{hour:"2-digit",minute:"2-digit",hour12:!1}),r=s.workingDir.replace(/^\/home\/[^/]+\//,"~/"),e=document.createElement("div");e.className="history-item",e.title=s.workingDir,e.addEventListener("click",()=>this.resumeHistorySession(s.sessionId,s.workingDir));const a=document.createElement("div");a.className="history-item-text";const c=document.createElement("span");c.className="history-item-title",c.textContent=s.firstPrompt||r;const u=document.createElement("span");u.className="history-item-subtitle",u.textContent=r,a.append(c,u);const l=document.createElement("span");l.className="history-item-meta",l.textContent=o;const h=document.createElement("span");h.className="history-item-size",h.textContent=d,e.append(a,l,h),i.appendChild(e)}t.style.display=""}catch(n){console.error("[loadHistorySessions]",n),t.style.display="none"}},async resumeHistorySession(t,i){document.getElementById("runModeMenu")?.classList.remove("active");try{this.terminal.clear(),this.terminal.writeln(`\x1B[1;32m Resuming conversation ${t.slice(0,8)}...\x1B[0m`);const n=i.split("/").pop()||"session";let s=1;for(const[,e]of this.sessions){const a=e.name&&e.name.match(/^w(\d+)-/);if(a){const c=parseInt(a[1]);c>=s&&(s=c+1)}}const d=`w${s}-${n}`,o=await(await fetch("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workingDir:i,name:d,resumeSessionId:t})})).json();if(!o.success)throw new Error(o.error);const r=o.session.id;await fetch(`/api/sessions/${r}/interactive`,{method:"POST"}),this.terminal.writeln(`\x1B[90m Session ${d} ready\x1B[0m`),await this.selectSession(r),this.terminal.focus()}catch(n){this.terminal.writeln(`\x1B[1;31m Error: ${n.message}\x1B[0m`)}},isTerminalAtBottom(){if(!this.terminal)return!0;const t=this.terminal.buffer.active;return t.viewportY>=t.baseY-2},batchTerminalWrite(t){if(this._isLoadingBuffer){this._loadBufferQueue&&this._loadBufferQueue.push(t);return}if(this.writeFrameScheduled||(this._wasAtBottomBeforeWrite=this.isTerminalAtBottom()),(this.activeSessionId?this.sessions.get(this.activeSessionId):null)?.flickerFilterEnabled??!1){if(t.includes("\x1B[2J")||t.includes("\x1B[H\x1B[J")||t.includes("\x1B[H")&&t.includes("\x1B[?25l")){this.flickerFilterActive=!0,this.flickerFilterBuffer+=t,this.flickerFilterTimeout&&clearTimeout(this.flickerFilterTimeout),this.flickerFilterTimeout=setTimeout(()=>{this.flickerFilterTimeout=null,this.flushFlickerBuffer()},SYNC_WAIT_TIMEOUT_MS);return}if(this.flickerFilterActive){this.flickerFilterBuffer+=t;return}}this.pendingWrites.push(t),this.writeFrameScheduled||(this.writeFrameScheduled=!0,requestAnimationFrame(()=>{this.flushPendingWrites(),this.writeFrameScheduled=!1}))},flushFlickerBuffer(){this.flickerFilterBuffer&&(this.pendingWrites.push(this.flickerFilterBuffer),this.flickerFilterBuffer="",this.flickerFilterActive=!1,this.writeFrameScheduled||(this.writeFrameScheduled=!0,requestAnimationFrame(()=>{this.flushPendingWrites(),this.writeFrameScheduled=!1})))},_updateLocalEchoState(){const t=this.loadAppSettingsFromStorage(),i=this.activeSessionId?this.sessions.get(this.activeSessionId):null,s=!!((t.localEchoEnabled??MobileDetection.isTouchDevice())&&i);this._localEchoEnabled&&!s&&this._localEchoOverlay?.clear(),this._localEchoEnabled=s,this._localEchoOverlay&&i&&(i.mode==="opencode"?this._localEchoOverlay.setPrompt({type:"custom",offset:3,find:d=>{try{const f=d.buffer.active,o=f.cursorY,r=f.getLine(f.viewportY+o);if(!r)return null;const a=r.translateToString(!0).indexOf("\u2503");return a>=0?{row:o,col:a}:null}catch{return null}}}):i.mode==="shell"?(this._localEchoOverlay.clear(),this._localEchoEnabled=!1):this._localEchoOverlay.setPrompt({type:"character",char:"\u276F",offset:2}))},flushPendingWrites(){if(this.pendingWrites.length===0||!this.terminal)return;const t=performance.now(),i=this.pendingWrites.join("");this.pendingWrites=[];const n=i.length;n>16384&&_crashDiag.log(`FLUSH: ${(n/1024).toFixed(0)}KB`);const s=65536;let d=!1;n<=s?this.terminal.write(i):(this.terminal.write(i.slice(0,s)),this.pendingWrites.push(i.slice(s)),d=!0,this.writeFrameScheduled||(this.writeFrameScheduled=!0,requestAnimationFrame(()=>{this.flushPendingWrites(),this.writeFrameScheduled=!1})));const f=d?s:n,o=performance.now()-t;if((o>100||d)&&console.warn(`[CRASH-DIAG] flushPendingWrites: ${o.toFixed(0)}ms, ${(f/1024).toFixed(0)}KB written${d?", rest deferred":""} (total ${(n/1024).toFixed(0)}KB)`),this._wasAtBottomBeforeWrite&&this.terminal.scrollToBottom(),this._localEchoOverlay?.hasPending&&this._localEchoOverlay.rerender(),this._tabCompletionSessionId&&this._tabCompletionSessionId===this.activeSessionId&&this._localEchoOverlay&&!this._localEchoOverlay.pendingText){const r=this._localEchoOverlay,e=this;this.terminal.write("",()=>{if(!e._tabCompletionSessionId)return;r.resetBufferDetection();const a=r.detectBufferText();a?a===e._tabCompletionBaseText?(r.undoDetection(),e._tabCompletionRetries=(e._tabCompletionRetries||0)+1,e._tabCompletionRetries>60&&(e._tabCompletionSessionId=null,e._tabCompletionRetries=0)):(e._tabCompletionSessionId=null,e._tabCompletionRetries=0,e._tabCompletionBaseText=null,e._tabCompletionFallback&&(clearTimeout(e._tabCompletionFallback),e._tabCompletionFallback=null),r.rerender()):(e._tabCompletionRetries=(e._tabCompletionRetries||0)+1,e._tabCompletionRetries>60&&(e._tabCompletionSessionId=null,e._tabCompletionRetries=0))})}},chunkedTerminalWrite(t,i=TERMINAL_CHUNK_SIZE){const n=++this._chunkedWriteGen;return new Promise(s=>{if(!t||t.length===0){this._finishBufferLoad(),s();return}this._isLoadingBuffer=!0,this._loadBufferQueue=[];const d=t.replace(DEC_SYNC_STRIP_RE,""),f=()=>{this._chunkedWriteGen===n&&this._finishBufferLoad(),s()};if(d.length<=i){this.terminal.write(d),f();return}let o=0;const r=performance.now();let e=0;const a=()=>{if(this._chunkedWriteGen!==n){s();return}if(o>=d.length){const h=performance.now()-r;console.log(`[CRASH-DIAG] chunkedTerminalWrite complete: ${d.length} bytes in ${e} chunks, ${h.toFixed(0)}ms total`),requestAnimationFrame(f);return}const c=performance.now(),u=d.slice(o,o+i);this.terminal.write(u);const l=performance.now()-c;e++,l>50&&console.warn(`[CRASH-DIAG] chunk #${e} write took ${l.toFixed(0)}ms (${u.length} bytes at offset ${o})`),o+=i,requestAnimationFrame(a)};requestAnimationFrame(a)})},_finishBufferLoad(){const t=this._loadBufferQueue;if(this._isLoadingBuffer=!1,this._loadBufferQueue=null,t&&t.length>0)for(const i of t)this.batchTerminalWrite(i)},clearTerminal(){this.terminal.clear()},async restoreTerminalSize(){if(!this.activeSessionId){this.showToast("No active session","warning");return}const t=this.getTerminalDimensions();if(!t){this.showToast("Could not determine terminal size","error");return}try{await this.sendResize(this.activeSessionId),await fetch(`/api/sessions/${this.activeSessionId}/input`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:"\f"})}),this.showToast(`Terminal restored to ${t.cols}x${t.rows}`,"success")}catch(i){console.error("Failed to restore terminal size:",i),this.showToast("Failed to restore terminal size","error")}},sendPendingCtrlL(t){!this.pendingCtrlL||!this.pendingCtrlL.has(t)||(this.pendingCtrlL.delete(t),t===this.activeSessionId&&this.sendResize(t).then(()=>{fetch(`/api/sessions/${t}/input`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:"\f"})})}))},async copyTerminal(){try{const t=this.terminal.buffer.active;let i="";for(let n=0;n<t.length;n++){const s=t.getLine(n);s&&(i+=s.translateToString(!0)+`
|
|
2
|
-
`)}await navigator.clipboard.writeText(i.replace(/\n+$/,`
|
|
3
|
-
`)),this.showToast("Copied to clipboard","success")}catch{this.showToast("Failed to copy","error")}},increaseFontSize(){const t=this.terminal.options.fontSize||14;this.setFontSize(Math.min(t+2,24))},decreaseFontSize(){const t=this.terminal.options.fontSize||14;this.setFontSize(Math.max(t-2,10))},setFontSize(t){this.terminal.options.fontSize=t,document.getElementById("fontSizeDisplay").textContent=t,this.fitAddon.fit(),localStorage.setItem("codeman-font-size",t),this._localEchoOverlay?.refreshFont()},loadFontSize(){const t=localStorage.getItem("codeman-font-size");if(t){const i=parseInt(t,10);i>=10&&i<=24&&(this.terminal.options.fontSize=i,document.getElementById("fontSizeDisplay").textContent=i)}},getTerminalDimensions(){const n=this.fitAddon?.proposeDimensions();return n?{cols:Math.max(n.cols,40),rows:Math.max(n.rows,10)}:null},async sendResize(t){this.fitAddon&&this.fitAddon.fit();const i=this.getTerminalDimensions();if(i){if(this._wsReady&&this._wsSessionId===t)try{this._ws.send(JSON.stringify({t:"z",c:i.cols,r:i.rows}));return}catch{}await fetch(`/api/sessions/${t}/resize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}},async sendInput(t){this.activeSessionId&&await fetch(`/api/sessions/${this.activeSessionId}/input`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:t,useMux:!0})})},toggleDirInput(){const t=document.querySelector("#dirDisplay").parentElement,i=document.getElementById("dirInput");i.classList.contains("hidden")&&(i.classList.remove("hidden"),t.style.display="none",i.focus())},hideDirInput(){const t=document.querySelector("#dirDisplay").parentElement,i=document.getElementById("dirInput");setTimeout(()=>{i.classList.add("hidden"),t.style.display="";const n=i.value.trim();document.getElementById("dirDisplay").textContent=n||"No directory"},100)}});
|
|
Binary file
|
|
Binary file
|