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