pi-web-ui 0.62.0 → 0.62.1
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-web-ui",
|
|
3
|
-
"version": "0.62.
|
|
3
|
+
"version": "0.62.1",
|
|
4
4
|
"description": "Web chat interface for the pi coding agent, powered by the pi SDK (@earendil-works/pi-coding-agent) — one-command run, Docker/systemd/launchd deployable",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as c,j as s}from"./markdown-DRBrS2Nf.js";import{b as R,T as I,u as L,F as J,a as K,c as X,d as Q,e as U,f as V,g as W,h as Y,r as Z}from"./index-
|
|
1
|
+
import{a as c,j as s}from"./markdown-DRBrS2Nf.js";import{b as R,T as I,u as L,F as J,a as K,c as X,d as Q,e as U,f as V,g as W,h as Y,r as Z}from"./index-eRkSgiu6.js";import{D as ee,o as se}from"./xterm-D1D2FVe3.js";import"./react-C9ovnpIm.js";function ne({conversationId:t,terminalId:o,command:f,cwd:a,title:N,active:m,send:x,register:j}){const g=c.useRef(null),w=c.useRef(null),C=f?JSON.stringify(f):"";return c.useEffect(()=>{const u=g.current;if(!u)return;const n=new ee({theme:R(),fontFamily:'"SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace',fontSize:13,cursorBlink:!0,scrollback:8e3}),p=new se;n.loadAddon(p),n.open(u),w.current={term:n,fit:p},m&&n.focus();const v=()=>{n.options.theme=R()};window.addEventListener(I,v),n.attachCustomKeyEventHandler(r=>{var F;if(r.type!=="keydown")return!0;const E=(F=r.key)==null?void 0:F.toLowerCase();if((r.ctrlKey||r.metaKey)&&E==="v")return!1;if(r.ctrlKey&&!r.shiftKey&&!r.altKey&&E==="c"&&n.hasSelection()){const b=n.textarea;return b&&(b.value=n.getSelection(),b.select()),!1}return!0});const T=j(t,o,{write:r=>n.write(r),dispose:()=>n.dispose()}),h=()=>{try{p.fit(),x({type:"terminal_resize",terminalId:o,conversationId:t,cols:n.cols,rows:n.rows})}catch{}},k=requestAnimationFrame(()=>{try{p.fit()}catch{}x(f?{type:"run_command",terminalId:o,conversationId:t,command:f,cols:n.cols,rows:n.rows}:{type:"terminal_create",terminalId:o,title:N,conversationId:t,cwd:a,cols:n.cols,rows:n.rows})}),S=n.onData(r=>{x({type:"terminal_input",terminalId:o,conversationId:t,data:r})});let y=null;return typeof ResizeObserver<"u"&&(y=new ResizeObserver(()=>{u.offsetWidth>0&&u.offsetHeight>0&&h()}),y.observe(u)),()=>{cancelAnimationFrame(k),S.dispose(),window.removeEventListener(I,v),y==null||y.disconnect(),T(),n.dispose(),w.current=null}},[t,o,C,x,j]),c.useEffect(()=>{if(!m)return;const u=requestAnimationFrame(()=>{const n=w.current;if(n){try{n.fit.fit(),x({type:"terminal_resize",terminalId:o,conversationId:t,cols:n.term.cols,rows:n.term.rows})}catch{}n.term.focus()}});return()=>cancelAnimationFrame(u)},[m]),s.jsx("div",{ref:g,className:`term-xterm ${m?"":"hidden"}`})}const B={name:"",command:"",cwd:"${pwd}"};function re({chat:t,send:o,terminal:f}){const a=L(),[N,m]=c.useState(null),[x,j]=c.useState(!1),[g,w]=c.useState(!1),[C,u]=c.useState(null),[n,p]=c.useState(B),[v,T]=c.useState(null),h=c.useRef(null),[k,S]=c.useState(!0);c.useEffect(()=>{t.terminals.length===0?m(null):t.terminals.some(e=>e.id===N)||m(t.terminals[t.terminals.length-1].id)},[t.terminals,N]),c.useEffect(()=>{t.terminalActiveId&&(m(t.terminalActiveId),j(!1))},[t.terminalActiveId]),c.useEffect(()=>()=>{h.current&&clearTimeout(h.current)},[]);const y=t.terminals.filter(e=>!e.agentBash),r=t.terminals.filter(e=>e.agentBash),E=e=>{var d;if(!t.ready)return;const i=Z(),l=t.activeConversationId||((d=t.state)==null?void 0:d.conversationId)||"";f.create({...e,id:i,conversationId:l,cols:e.cols??80,rows:e.rows??24,running:!0,exitCode:null}),m(i),j(!1)},F=()=>{var e;return E({title:a("terminalTitle",{n:y.length+1}),cwd:((e=t.state)==null?void 0:e.cwd)??""})},b=e=>{var d;const i=e.name||e.command,l=t.terminals.find($=>$.title===i);if(l){f.restart(l.id),m(l.id),o({type:"run_command",terminalId:l.id,conversationId:l.conversationId,command:e,cols:80,rows:24});return}E({title:i,cwd:((d=t.state)==null?void 0:d.cwd)??"",command:e})},O=e=>{const i=t.terminals.find(l=>l.id===e);if(i&&o({type:"terminal_kill",terminalId:e,conversationId:i.conversationId}),f.close(e),N===e){const l=t.terminals.filter(d=>d.id!==e);m(l.length>0?l[l.length-1].id:null)}},D=e=>s.jsxs("div",{className:`term-tab ${e.id===N?"active":""}`,children:[s.jsxs("button",{type:"button",className:"term-tab-main",title:`${e.cwd}${e.command?`
|
|
2
2
|
> ${e.command.command}`:""}`,onClick:()=>{m(e.id),j(!1)},children:[s.jsx("span",{className:`term-tab-dot ${e.running?"run":"exit"}`}),s.jsxs("span",{className:"term-tab-title",children:[e.title,!e.running&&s.jsx("span",{className:"term-tab-exit",children:a("exited",{code:e.exitCode===null?"":` ${e.exitCode}`})})]})]}),s.jsx("button",{type:"button",className:"term-tab-close",title:a("closeTerminal"),onClick:()=>O(e.id),children:s.jsx(Y,{})})]},e.id),M=()=>{w(!0),u(null),p(B)},z=e=>{const i=t.commands[e];i&&(w(!1),u(e),p({name:i.name,command:i.command,cwd:i.cwd??""}))},A=()=>{w(!1),u(null)},_=()=>{const e=n.name.trim(),i=n.command.trim();if(!e||!i)return;const l=n.cwd.trim(),d={name:e,command:i,cwd:l||void 0},$=g?[...t.commands,d]:C!==null?t.commands.map((q,G)=>G===C?d:q):t.commands;o({type:"save_commands",commands:$}),A()},H=e=>{if(v===e){const i=t.commands.filter((l,d)=>d!==e);o({type:"save_commands",commands:i}),T(null),h.current&&clearTimeout(h.current)}else T(e),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>T(null),2500)},P=g||C!==null;return s.jsxs("div",{className:"terminal-view",children:[s.jsxs("aside",{className:`term-side term-commands ${x?"open":""}`,children:[s.jsxs("div",{className:"panel-header",children:[s.jsx("span",{className:"panel-title",children:a("commands")}),s.jsxs("div",{className:"panel-header-actions",children:[s.jsx("button",{type:"button",className:"panel-refresh",title:a("rerun"),onClick:()=>o({type:"list_commands"}),children:s.jsx(J,{})}),s.jsx("button",{type:"button",className:"panel-new",title:a("newCommand"),onClick:M,children:s.jsx(K,{})})]})]}),s.jsx("div",{className:"panel-body",children:P?s.jsxs("div",{className:"cmd-form",children:[s.jsx("label",{htmlFor:"cmd-name",children:a("name")}),s.jsx("input",{id:"cmd-name",className:"cmd-input",value:n.name,placeholder:a("exampleName"),autoFocus:!0,onChange:e=>p({...n,name:e.target.value})}),s.jsx("label",{htmlFor:"cmd-command",children:a("command")}),s.jsx("input",{id:"cmd-command",className:"cmd-input",value:n.command,placeholder:a("exampleCommand"),onChange:e=>p({...n,command:e.target.value}),onKeyDown:e=>{e.key==="Enter"&&!e.nativeEvent.isComposing&&_()}}),s.jsxs("label",{htmlFor:"cmd-cwd",children:[a("directory")," ",s.jsx("span",{className:"cmd-hint",children:a("cwdHint")})]}),s.jsx("input",{id:"cmd-cwd",className:"cmd-input",value:n.cwd,placeholder:"${pwd}",onChange:e=>p({...n,cwd:e.target.value}),onKeyDown:e=>{e.key==="Enter"&&!e.nativeEvent.isComposing&&_()}}),s.jsxs("div",{className:"cmd-form-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:A,children:a("cancel")}),s.jsx("button",{type:"button",className:"btn primary",disabled:!n.name.trim()||!n.command.trim(),onClick:_,children:a("save")})]})]}):s.jsxs(s.Fragment,{children:[t.commands.length===0&&s.jsx("div",{className:"panel-empty",children:a("noCommands")}),t.commands.map((e,i)=>s.jsxs("div",{className:"cmd-item",children:[s.jsx("button",{type:"button",className:"cmd-run",title:a("clickToRun"),onClick:()=>b(e),children:s.jsx(X,{})}),s.jsxs("button",{type:"button",className:"cmd-main",title:a("clickToRun"),onClick:()=>b(e),children:[s.jsx("span",{className:"cmd-name",children:e.name}),s.jsx("span",{className:"cmd-command",children:e.command}),e.cwd&&s.jsx("span",{className:"cmd-cwd",children:e.cwd})]}),s.jsx("button",{type:"button",className:"cmd-act",title:a("edit"),onClick:()=>z(i),children:s.jsx(Q,{})}),s.jsx("button",{type:"button",className:`cmd-act del ${v===i?"confirm":""}`,title:a("delete"),onClick:()=>H(i),children:v===i?a("confirmQ"):s.jsx(U,{})})]},i))]})}),s.jsxs("div",{className:"term-tabs-block",children:[s.jsxs("div",{className:"panel-header",children:[s.jsx("span",{className:"panel-title",children:a("terminal")}),s.jsx("button",{type:"button",className:"panel-new",title:a("newTerminal"),onClick:F,children:s.jsx(K,{})})]}),s.jsxs("div",{className:"panel-body",children:[t.terminals.length===0&&s.jsx("div",{className:"panel-empty",children:a("noTerminal")}),y.map(D),r.length>0&&s.jsxs("div",{className:"term-folder",children:[s.jsxs("button",{type:"button",className:`term-folder-header ${k?"open":""}`,title:a("aiBashGroup"),onClick:()=>S(e=>!e),children:[s.jsx("span",{className:"term-folder-caret",children:k?"▾":"▸"}),s.jsx("span",{className:"term-folder-title",children:a("aiBashGroup")}),s.jsx("span",{className:"term-folder-count",children:r.length})]}),k&&s.jsx("div",{className:"term-folder-body",children:r.map(D)})]})]})]})]}),s.jsxs("div",{className:"term-main",children:[x&&s.jsx("div",{className:"drawer-backdrop",onClick:()=>j(!1)}),s.jsx("button",{type:"button",className:"term-side-toggle",title:a("commands"),onClick:()=>j(e=>!e),children:s.jsx(V,{})}),t.terminals.length===0?s.jsxs("div",{className:"term-empty",children:[s.jsx(W,{className:"term-empty-icon"}),s.jsx("div",{className:"term-empty-title",children:a("builtinTerminal")}),s.jsx("div",{className:"term-empty-sub",children:a("termEmptySub")})]}):t.terminals.map(e=>s.jsx(ne,{conversationId:e.conversationId,terminalId:e.id,command:e.command,cwd:e.cwd,title:e.title,active:e.id===N,send:o,register:f.register},`${e.conversationId}:${e.id}`))]})]})}export{re as TerminalPanel};
|