@wrongstack/webui 0.7.0 → 0.7.3
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/assets/{index-CFyVAbSB.js → index-B9lEIHt9.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/server/entry.js +77 -21
- package/dist/server/entry.js.map +1 -1
- package/dist/server/index.js +77 -21
- package/dist/server/index.js.map +1 -1
- package/package.json +5 -5
|
@@ -67,7 +67,7 @@ ${n.join("")}
|
|
|
67
67
|
</body></html>`,i=new Blob([r],{type:"text/html;charset=utf-8"}),c=URL.createObjectURL(i),l=document.createElement("a");l.href=c,l.download=`wrongstack-chat-${s}.html`,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(c)}function Pn({query:o,onPick:t,onClose:s}){const a=fe(),n=Q(x=>x.wsUrl),[r,i]=u.useState([]),[c,l]=u.useState(0),d=u.useRef(null),m=u.useRef(null);return u.useEffect(()=>{const p=pe(n).on("files.list",f=>{var w;const v=f.payload;i(v.files??[]),l(0),(w=m.current)==null||w.resolve(v.files??[]),m.current=null});return()=>p()},[n]),u.useEffect(()=>(d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{a.client.listFiles(o,50)},80),()=>{d.current&&clearTimeout(d.current)}),[o,a.client]),u.useEffect(()=>{const x=p=>{if(p.key==="ArrowDown")p.preventDefault(),l(f=>(f+1)%Math.max(1,r.length));else if(p.key==="ArrowUp")p.preventDefault(),l(f=>(f-1+Math.max(1,r.length))%Math.max(1,r.length));else if(p.key==="Enter"||p.key==="Tab"){if(r.length===0)return;p.preventDefault(),t(r[c])}else p.key==="Escape"&&(p.preventDefault(),s())};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[r,c,t,s]),e.jsxs("div",{className:"absolute bottom-full left-0 right-0 mb-2 rounded-lg border bg-popover shadow-md p-1 text-sm max-h-72 overflow-auto",children:[e.jsxs("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-muted-foreground border-b mb-1 flex items-center justify-between",children:[e.jsxs("span",{children:["@ Files ",o&&`· "${o}"`]}),e.jsx("span",{children:"↑/↓ select · ↵ insert · Esc dismiss"})]}),r.length===0?e.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground italic",children:o?`No files match "${o}"`:"Searching project…"}):r.map((x,p)=>e.jsxs("button",{type:"button",onClick:()=>t(x),onMouseEnter:()=>l(p),className:S("w-full text-left px-3 py-1.5 rounded transition-colors flex items-center gap-2 font-mono text-xs",p===c?"bg-accent text-accent-foreground":"hover:bg-accent/40"),children:[x.includes("/")?e.jsx($s,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}):e.jsx(Ts,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),e.jsx("span",{className:"truncate",children:x})]},x))]})}const Fn=Es("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),B=u.forwardRef(({className:o,variant:t,size:s,asChild:a=!1,...n},r)=>{const i=a?Ms:"button";return e.jsx(i,{className:S(Fn({variant:t,size:s,className:o})),ref:r,...n})});B.displayName="Button";const dt=[{name:"/help",category:"App",description:"Show every slash command and what it does"},{name:"/export",category:"Session",description:"Download the current chat as markdown"},{name:"/todos",category:"Inspect",description:"List current todos (try `/todos clear` to reset)"},{name:"/clear",category:"Session",description:"Wipe current context (keeps session id, disk record stays)"},{name:"/new",category:"Session",description:"Start a brand-new session (fresh on disk and in memory)"},{name:"/compact",category:"Session",description:"Shrink context — elide ancient tool output"},{name:"/repair",category:"Session",description:"Repair orphan tool_use/tool_result blocks in context"},{name:"/debug",category:"Inspect",aliases:["/context"],description:"Per-section context size breakdown"},{name:"/tools",category:"Inspect",description:"List every registered tool the model can call"},{name:"/memory",category:"Inspect",description:"Show all remembered notes (project + user scope)"},{name:"/skill",category:"Inspect",aliases:["/skills"],description:"List active skills"},{name:"/diag",category:"Inspect",description:"Runtime diagnostics (provider, tools, features, mode, usage)"},{name:"/stats",category:"Inspect",description:"Session stats: tokens, cache hit ratio, cost, elapsed"},{name:"/save",category:"Session",description:"Force-flush the session (auto-saved already)"},{name:"/abort",category:"Run",aliases:["/stop"],description:"Abort the current run"},{name:"/settings",category:"App",aliases:["/model"],description:"Open settings (provider/model/keys)"}],_n=["Run","Session","Inspect","App"];function Lt(o,t){let s=t-1;for(;s>=0;){const a=o[s];if(a==="@"){const n=s>0?o[s-1]:"";return s===0||/\s/.test(n??"")?{start:s,query:o.slice(s+1,t)}:null}if(/\s/.test(a))return null;s--}return null}function Kn(o){const t=o.toLowerCase();return t==="/"||t===""?dt:dt.filter(s=>{var a;return s.name.startsWith(t)||(((a=s.aliases)==null?void 0:a.some(n=>n.startsWith(t)))??!1)})}function Wn(){const{isLoading:o,setLoading:t,addMessage:s,clearMessages:a}=T(),n=T(y=>y.queue),r=T(y=>y.enqueue),i=T(y=>y.removeQueued),c=T(y=>y.clearQueue),{setCurrentView:l}=I(),d=I(y=>y.pushPrompt),m=I(y=>y.promptHistory),x=fe(),{sendMessage:p,sendAbort:f,client:v}=x,w=H(y=>y.lastInputTokens),C=H(y=>y.maxContext),[b,g]=u.useState(""),[L,Z]=u.useState(0),[K,W]=u.useState(-1),[G,q]=u.useState(null),[J,ee]=u.useState(null),[re,Y]=u.useState(!1),V=u.useRef(null),A=u.useCallback(y=>{var j,U,ae,X,me,ue;const $=y.trim(),R=$.indexOf(" "),h=(R===-1?$:$.slice(0,R)).toLowerCase(),M=R===-1?"":$.slice(R+1).trim(),E=h;switch(E){case"/help":{const oe=["📖 **Slash commands**","",...dt.map(D=>{var O;return`• \`${D.name}\`${(O=D.aliases)!=null&&O.length?` (${D.aliases.map(z=>`\`${z}\``).join(", ")})`:""} — ${D.description}`})];return s({role:"assistant",content:oe.join(`
|
|
68
68
|
`)}),!0}case"/clear":return a(),(j=v==null?void 0:v.clearContext)==null||j.call(v),!0;case"/new":return(U=v==null?void 0:v.newSession)==null||U.call(v),!0;case"/compact":case"/compact!":return(ae=v==null?void 0:v.compactContext)==null||ae.call(v,E==="/compact!"),!0;case"/repair":return(X=v==null?void 0:v.repairContext)==null||X.call(v),!0;case"/debug":case"/context":return(me=v==null?void 0:v.debugContext)==null||me.call(v),!0;case"/tools":return x.listTools(),!0;case"/memory":return x.listMemory(),!0;case"/skill":case"/skills":return x.listSkills(),!0;case"/diag":return x.getDiag(),!0;case"/stats":return x.getStats(),!0;case"/save":return x.saveSession(),!0;case"/todos":{if(M.toLowerCase()==="clear")return(ue=v==null?void 0:v.clearTodos)==null||ue.call(v),!0;const D=H.getState().todos;if(D.length===0)return s({role:"assistant",content:"✅ **Todos** — _empty. Ask the agent to plan something and they'll show up here._"}),!0;const O=[`✅ **Todos** (${D.filter(z=>z.status==="completed").length}/${D.length} done)`,""];for(const z of D){const ie=z.status==="completed"?"[x]":z.status==="in_progress"?"[~]":"[ ]",ge=z.status==="in_progress"&&z.activeForm?z.activeForm:z.content;O.push(`- ${ie} ${ge}`)}return O.push("","_Use `/todos clear` to wipe the list._"),s({role:"assistant",content:O.join(`
|
|
69
69
|
`)}),!0}case"/export":return Ct(),s({role:"assistant",content:"📥 Chat exported to your downloads folder."}),!0;case"/abort":case"/stop":return f(),t(!1),!0;case"/settings":case"/model":return l("settings"),!0;default:return!1}},[s,a,v,f,t,l,x]),F=b.startsWith("/")&&!b.includes(" ")?Kn(b):[];u.useEffect(()=>{L>=F.length&&Z(0)},[F.length,L]);const k=u.useCallback(async y=>{if(y.preventDefault(),!b.trim())return;const $=b.trim();if($.startsWith("/")&&A($)){d($),g(""),W(-1);return}if(g(""),W(-1),d($),o){r($);return}try{v!=null&&v.isConnected?(s({role:"user",content:$}),t(!0),p($)):console.error("WebSocket not connected")}catch(R){console.error("Failed to send:",R),t(!1)}},[b,o,r,v,p,t,s,A,d]),te=u.useCallback(()=>{f(),t(!1)},[f,t]),_=u.useCallback(()=>{f(),t(!1);const y=T.getState().messages;for(let $=y.length-1;$>=0;$--){const R=y[$];if(R.role==="user"&&R.content){g(R.content),requestAnimationFrame(()=>{const h=V.current;h&&(h.style.height="auto",h.style.height=`${Math.min(h.scrollHeight,200)}px`,h.focus(),h.setSelectionRange(R.content.length,R.content.length))});return}}},[f,t]),se=u.useCallback(y=>{if(F.length===0&&!G&&m.length>0){if(y.key==="ArrowUp"){const $=y.currentTarget,R=$.value.slice(0,$.selectionStart);if(K>=0||R.indexOf(`
|
|
70
|
-
`)===-1){y.preventDefault();const h=Math.min(m.length-1,K+1);W(h);const M=m[h]??"";g(M),requestAnimationFrame(()=>{const E=V.current;E&&(E.style.height="auto",E.style.height=`${Math.min(E.scrollHeight,200)}px`,E.setSelectionRange(M.length,M.length))});return}}if(y.key==="ArrowDown"&&K>=0){y.preventDefault();const $=K-1;if($<0)W(-1),g("");else{W($);const R=m[$]??"";g(R),requestAnimationFrame(()=>{const h=V.current;h&&(h.style.height="auto",h.style.height=`${Math.min(h.scrollHeight,200)}px`,h.setSelectionRange(R.length,R.length))})}return}}if(F.length>0){if(y.key==="ArrowDown"){y.preventDefault(),Z($=>($+1)%F.length);return}if(y.key==="ArrowUp"){y.preventDefault(),Z($=>($-1+F.length)%F.length);return}if(y.key==="Tab"){y.preventDefault();const $=F[L];$&&(g($.name+" "),Z(0));return}if(y.key==="Enter"&&!y.shiftKey){const $=F[L];if($&&$.name!==b.toLowerCase().trim()){y.preventDefault(),g(""),A($.name);return}}if(y.key==="Escape"){y.preventDefault(),g("");return}}y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),k(y))},[F,G,m,K,
|
|
70
|
+
`)===-1){y.preventDefault();const h=Math.min(m.length-1,K+1);W(h);const M=m[h]??"";g(M),requestAnimationFrame(()=>{const E=V.current;E&&(E.style.height="auto",E.style.height=`${Math.min(E.scrollHeight,200)}px`,E.setSelectionRange(M.length,M.length))});return}}if(y.key==="ArrowDown"&&K>=0){y.preventDefault();const $=K-1;if($<0)W(-1),g("");else{W($);const R=m[$]??"";g(R),requestAnimationFrame(()=>{const h=V.current;h&&(h.style.height="auto",h.style.height=`${Math.min(h.scrollHeight,200)}px`,h.setSelectionRange(R.length,R.length))})}return}}if(F.length>0){if(y.key==="ArrowDown"){y.preventDefault(),Z($=>($+1)%F.length);return}if(y.key==="ArrowUp"){y.preventDefault(),Z($=>($-1+F.length)%F.length);return}if(y.key==="Tab"){y.preventDefault();const $=F[L];$&&(g($.name+" "),Z(0));return}if(y.key==="Enter"&&!y.shiftKey){const $=F[L];if($&&$.name!==b.toLowerCase().trim()){y.preventDefault(),g(""),A($.name);return}}if(y.key==="Escape"){y.preventDefault(),g("");return}}y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),k(y))},[F,G,m,K,A,k]),ce=()=>{const y=V.current;y&&(y.style.height="auto",y.style.height=`${Math.min(y.scrollHeight,200)}px`)};return e.jsxs("div",{className:"flex flex-col gap-2",children:[J&&e.jsxs("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/5 text-amber-700 dark:text-amber-300 px-2.5 py-1.5 text-xs flex items-center justify-between gap-2 animate-message",children:[e.jsxs("span",{children:["Pasted"," ",e.jsx("span",{className:"font-mono tabular-nums",children:J.chars.toLocaleString()})," chars (",e.jsx("span",{className:"font-mono tabular-nums",children:J.lines})," lines) — fenced code blocks render best with ",e.jsx("span",{className:"font-mono",children:"```"}),"."]}),e.jsx("button",{type:"button",onClick:()=>ee(null),className:"text-amber-600/70 hover:text-amber-600 dark:text-amber-300/70 dark:hover:text-amber-300 shrink-0",title:"Dismiss",children:"×"})]}),n.length>0&&e.jsxs("div",{className:"rounded-lg border bg-muted/30 p-2 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsxs("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:["Queued (",n.length,")"]}),e.jsx("button",{type:"button",onClick:c,className:"text-muted-foreground hover:text-destructive text-xs",children:"Clear all"})]}),e.jsx("ul",{className:"space-y-1",children:n.map((y,$)=>e.jsxs("li",{className:"flex items-start justify-between gap-2 rounded bg-background/60 border px-2 py-1",children:[e.jsx("span",{className:"truncate flex-1 min-w-0",children:y}),e.jsx("button",{type:"button",onClick:()=>i($),className:"text-muted-foreground hover:text-destructive shrink-0",title:"Remove from queue",children:"×"})]},$))})]}),e.jsxs("form",{onSubmit:k,onDragEnter:y=>{!y.dataTransfer||!Array.from(y.dataTransfer.types).includes("Files")||(y.preventDefault(),Y(!0))},onDragOver:y=>{!y.dataTransfer||!Array.from(y.dataTransfer.types).includes("Files")||(y.preventDefault(),y.dataTransfer.dropEffect="copy")},onDragLeave:y=>{y.currentTarget.contains(y.relatedTarget)||Y(!1)},onDrop:y=>{if(!y.dataTransfer)return;const $=Array.from(y.dataTransfer.files??[]);if($.length===0){Y(!1);return}y.preventDefault(),Y(!1);const R=V.current,h=(R==null?void 0:R.selectionStart)??b.length,M=b.slice(0,h),E=b.slice(h),U=M.length>0&&!/\s$/.test(M)?" ":"",ae=$.map(ie=>`@${ie.name}`),X=ae.join(" "),ue=E.length===0||!/^\s/.test(E)?" ":"",oe=`${U}${X}${ue}`,D=M+oe+E;g(D);const O=M.length+U.length+ae.slice(0,-1).join(" ").length+(ae.length>1?1:0),z=$[$.length-1].name;requestAnimationFrame(()=>{if(R){const ie=M.length+oe.length-ue.length;R.focus(),R.setSelectionRange(ie,ie),R.style.height="auto",R.style.height=`${Math.min(R.scrollHeight,200)}px`}q({start:O,query:z})})},className:S("flex items-end gap-2 relative rounded-lg transition-colors",re&&"ring-2 ring-primary ring-offset-2 ring-offset-background bg-primary/5"),children:[re&&e.jsxs("div",{className:"absolute inset-0 z-20 flex items-center justify-center pointer-events-none rounded-lg bg-primary/10 text-primary text-sm font-medium",children:["Drop file","(s)"," to attach as @-mention"]}),e.jsxs("div",{className:"relative flex-1",children:[G&&e.jsx(Pn,{query:G.query,onClose:()=>q(null),onPick:y=>{const $=b.slice(0,G.start),R=b.slice(G.start+1+G.query.length),h=`@${y} `,M=$+h+R;g(M),q(null),requestAnimationFrame(()=>{const E=V.current;if(E){const j=$.length+h.length;E.focus(),E.setSelectionRange(j,j),E.style.height="auto",E.style.height=`${Math.min(E.scrollHeight,200)}px`}})}}),!G&&F.length>0&&(()=>{const y={};F.forEach((R,h)=>{y[R.category]||(y[R.category]=[]),y[R.category].push({cmd:R,idx:h})});const $=_n.filter(R=>{var h;return(h=y[R])==null?void 0:h.length});return e.jsxs("div",{className:"absolute bottom-full left-0 right-0 mb-2 rounded-lg border bg-popover shadow-md p-1 text-sm max-h-72 overflow-auto",children:[e.jsx("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-muted-foreground border-b mb-1",children:"↑/↓ select · Tab complete · Enter dispatch · Esc dismiss"}),$.map(R=>e.jsxs("div",{className:"mb-1",children:[e.jsx("div",{className:"px-3 pt-1 pb-0.5 text-[10px] uppercase tracking-wider text-muted-foreground/70 font-semibold",children:R}),y[R].map(({cmd:h,idx:M})=>{var E;return e.jsxs("button",{type:"button",onClick:()=>{g(""),A(h.name)},onMouseEnter:()=>Z(M),className:S("w-full text-left px-3 py-1.5 rounded transition-colors flex items-center gap-3",M===L?"bg-accent text-accent-foreground":"hover:bg-accent/40"),children:[e.jsx("span",{className:"font-mono shrink-0",children:h.name}),(E=h.aliases)!=null&&E.length?e.jsxs("span",{className:"text-xs text-muted-foreground/70 font-mono shrink-0",children:["(",h.aliases.join(", "),")"]}):null,e.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["— ",h.description]})]},h.name)})]},R))]})})(),e.jsx("textarea",{ref:V,value:b,onChange:y=>{const $=y.target.value;g($),ce(),K>=0&&W(-1);const R=y.target.selectionStart??$.length;q(Lt($,R))},onSelect:y=>{const $=y.currentTarget;q(Lt($.value,$.selectionStart))},onKeyDown:se,onPaste:y=>{var R;const $=((R=y.clipboardData)==null?void 0:R.getData("text"))??"";if($.length>800){const h=$.split(`
|
|
71
71
|
`).length;ee({chars:$.length,lines:h}),setTimeout(()=>ee(null),4e3)}},placeholder:v!=null&&v.isConnected?o?"Agent is running — type to queue a follow-up…":"Message WrongStack… (type / for commands, @ for files)":"Connect to server first…",className:S("flex min-h-[44px] w-full resize-none rounded-lg border border-input bg-background px-4 py-3 pr-12","text-sm ring-offset-background placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50","scrollbar-thin"),rows:1,disabled:!(v!=null&&v.isConnected)}),b.length>0&&(()=>{const y=b.length>=400,$=Math.ceil(b.length/4);let R="text-muted-foreground",h;if(C>0&&y){const E=(w+$+64)/C*100;E>=100?(R="text-red-600 dark:text-red-400 font-medium",h=`Projected ${Math.round(E)}% of ${C.toLocaleString()} ctx — will likely error or compact.`):E>=85?(R="text-amber-600 dark:text-amber-400 font-medium",h=`Projected ${Math.round(E)}% of ${C.toLocaleString()} ctx — getting tight.`):h=`≈ ${$.toLocaleString()} tokens · projected ${Math.round(E)}% of ${C.toLocaleString()} ctx.`}else y&&(h=`≈ ${$.toLocaleString()} tokens (4-char heuristic)`);return e.jsxs("span",{className:S("absolute bottom-1.5 right-12 text-xs tabular-nums",R),title:h,children:[b.length,y&&e.jsxs("span",{className:"ml-1 opacity-70",children:["· ≈",$>=1e3?`${($/1e3).toFixed(1)}k`:$,"t"]})]})})()]}),e.jsx("div",{className:"flex gap-1",children:o?e.jsxs(e.Fragment,{children:[e.jsx(B,{type:"button",size:"icon",variant:"outline",onClick:_,className:"h-[44px] w-[44px] rounded-lg",title:"Stop run and edit the last prompt (reuse + rewrite)",children:e.jsx(_t,{className:"h-4 w-4"})}),e.jsx(B,{type:"button",size:"icon",variant:"destructive",onClick:te,className:"h-[44px] w-[44px] rounded-lg",title:"Abort the current run",children:e.jsx(Ds,{className:"h-4 w-4 fill-current"})})]}):e.jsx(B,{type:"submit",size:"icon",disabled:!b.trim()||!(v!=null&&v.isConnected),className:"h-[44px] w-[44px] rounded-lg",children:e.jsx(Ls,{className:"h-4 w-4"})})})]})]})}function Un({wsStatus:o,wsConnected:t}){const s=Q(i=>i.wsUrl),[a,n]=u.useState(Date.now());u.useEffect(()=>{if(o.state!=="reconnecting")return;const i=setInterval(()=>n(Date.now()),500);return()=>clearInterval(i)},[o.state]);const r=()=>pe(s).retryNow();if(o.state==="open"&&t)return e.jsx("div",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[11px] font-medium shrink-0 bg-green-500/10 text-green-600 dark:text-green-400",title:"Backend connected",children:e.jsx(Kt,{className:"h-3 w-3"})});if(o.state==="connecting")return e.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[11px] font-medium shrink-0 bg-yellow-500/10 text-yellow-600 dark:text-yellow-400",title:"Connecting to backend",children:[e.jsx(we,{className:"h-3 w-3 animate-spin"}),e.jsx("span",{children:"connecting"})]});if(o.state==="reconnecting"){const i=Math.max(0,Math.ceil((o.nextRetryAt-a)/1e3));return e.jsxs("button",{type:"button",onClick:r,className:S("flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[11px] font-medium shrink-0","bg-orange-500/10 text-orange-600 dark:text-orange-400 hover:bg-orange-500/20","transition-colors"),title:o.lastError?`Reconnecting — last error: ${o.lastError}. Click to retry now.`:"Reconnecting — click to retry now.",children:[e.jsx(we,{className:"h-3 w-3 animate-spin"}),e.jsxs("span",{children:["retry #",o.attempt," in ",i,"s"]})]})}return e.jsxs("button",{type:"button",onClick:r,className:"flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[11px] font-medium shrink-0 bg-red-500/10 text-red-600 dark:text-red-400 hover:bg-red-500/20 transition-colors",title:o.state==="closed"&&o.error?`Disconnected: ${o.error}. Click to retry.`:"Disconnected. Click to retry.",children:[e.jsx(yt,{className:"h-3 w-3"}),e.jsxs("span",{className:"flex items-center gap-0.5",children:["offline",e.jsx(Ke,{className:"h-3 w-3 opacity-70"})]})]})}const zn=[{id:"balanced",name:"Balanced",description:"Default rolling compaction",thresholds:{warn:.6,soft:.75,hard:.9},preserveK:10,eliseThreshold:2e3}];function Hn(){const o=H(d=>d.contextMode),t=H(d=>d.contextModes),{listContextModes:s,switchContextMode:a}=fe(),[n,r]=u.useState(!1),i=u.useRef(null);u.useEffect(()=>{n&&s()},[n,s]),u.useEffect(()=>{if(!n)return;const d=x=>{var p;(p=i.current)!=null&&p.contains(x.target)||r(!1)},m=x=>{x.key==="Escape"&&r(!1)};return document.addEventListener("mousedown",d),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",m)}},[n]);const c=t.length>0?t:zn,l=c.find(d=>d.id===o)??c[0];return e.jsxs("div",{ref:i,className:"relative shrink-0",children:[e.jsxs("button",{type:"button",onClick:()=>r(d=>!d),className:S("flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium","bg-emerald-500/10 text-emerald-700 dark:text-emerald-300 hover:bg-emerald-500/15 transition-colors border border-transparent hover:border-emerald-500/30"),title:"Context-window mode",children:[e.jsx(Rs,{className:"h-3 w-3"}),"ctx: ",e.jsx("span",{className:"font-mono",children:o||l.id}),e.jsx(We,{className:"h-3 w-3 opacity-60"})]}),n&&e.jsxs("div",{className:"absolute top-full left-0 mt-1 w-80 rounded-md border bg-popover shadow-lg z-30 py-1",children:[e.jsx("div",{className:"px-3 py-1.5 text-[10px] uppercase tracking-wider text-muted-foreground border-b",children:"Context Window"}),c.map(d=>e.jsxs("button",{type:"button",onClick:()=>{a(d.id),r(!1)},className:S("w-full text-left px-3 py-2 hover:bg-accent/40 flex items-start gap-2",d.id===o&&"bg-accent/30"),children:[e.jsx(vt,{className:S("h-3.5 w-3.5 mt-0.5 shrink-0",d.id===o?"opacity-100 text-primary":"opacity-0")}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-xs font-mono",children:d.id}),d.thresholds&&e.jsxs("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:[Math.round(d.thresholds.warn*100),"/",Math.round(d.thresholds.soft*100),"/",Math.round(d.thresholds.hard*100),"%"]})]}),e.jsx("div",{className:"text-[11px] text-muted-foreground leading-snug",children:d.description}),(d.preserveK||d.eliseThreshold)&&e.jsxs("div",{className:"mt-1 text-[10px] text-muted-foreground/80",children:["keep ",d.preserveK??"-"," recent · elide ",d.eliseThreshold??"-","+ tokens"]})]})]},d.id))]})]})}function qn(){const o=H(x=>x.cost),t=H(x=>x.inputCost),s=H(x=>x.outputCost),a=H(x=>x.cacheReadCost),n=T(x=>x.messages),[r,i]=u.useState(!1),c=u.useRef(null);u.useEffect(()=>{if(!r)return;const x=f=>{var v;(v=c.current)!=null&&v.contains(f.target)||i(!1)},p=f=>{f.key==="Escape"&&i(!1)};return document.addEventListener("mousedown",x),document.addEventListener("keydown",p),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",p)}},[r]);const l=(()=>{const x=[];for(const p of n)p.role==="assistant"&&p.runSummary&&p.runSummary.costDelta>0&&x.push({id:p.id,preview:p.content.slice(0,80).replace(/\s+/g," ").trim()||"(empty)",cost:p.runSummary.costDelta,tools:p.runSummary.tools,ms:p.runSummary.durationMs,ts:p.timestamp});return x.sort((p,f)=>f.cost-p.cost),x.slice(0,5)})(),d=x=>x>=.01?`$${x.toFixed(4)}`:x>0?`$${x.toFixed(6).replace(/0+$/,"").replace(/\.$/,"")}`:"$0",m=t>0||s>0;return e.jsxs("div",{ref:c,className:"relative inline-block",children:[e.jsxs("button",{type:"button",onClick:()=>i(x=>!x),className:S("font-medium text-green-600 dark:text-green-400 hover:underline tabular-nums"),title:"Click for per-turn cost breakdown",children:["$",o.toFixed(4)]}),r&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-30 w-80 rounded-md border bg-popover shadow-lg p-3 text-foreground",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-xs uppercase tracking-wider text-muted-foreground font-medium",children:"Cost breakdown"}),e.jsx("span",{className:"font-mono tabular-nums text-sm font-semibold text-green-600 dark:text-green-400",children:d(o)})]}),m?e.jsxs("div",{className:"text-[11px] text-muted-foreground font-mono mb-3 border-b pb-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"input /1M"}),e.jsxs("span",{children:["$",t.toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"output /1M"}),e.jsxs("span",{children:["$",s.toFixed(2)]})]}),a>0&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"cache /1M"}),e.jsxs("span",{children:["$",a.toFixed(2)]})]})]}):e.jsx("div",{className:"text-[11px] text-muted-foreground italic mb-3 border-b pb-2",children:"No pricing for the current model — cost figures are zero."}),l.length===0?e.jsx("div",{className:"text-xs text-muted-foreground italic",children:"No completed turns yet. Run a prompt to see per-turn cost here."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/80 mb-1",children:["Top ",l.length," expensive turn",l.length===1?"":"s"]}),e.jsx("ul",{className:"space-y-1",children:l.map(x=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>{const p=document.querySelector(`[data-message-id="${x.id}"]`);p&&p.scrollIntoView({behavior:"smooth",block:"center"}),i(!1)},className:"w-full text-left rounded px-2 py-1.5 hover:bg-accent/40 transition-colors",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"text-xs truncate",children:x.preview}),e.jsx("span",{className:"text-xs font-mono tabular-nums text-green-600 dark:text-green-400 shrink-0",children:d(x.cost)})]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground font-mono mt-0.5",children:[x.tools," tool",x.tools===1?"":"s"," · ",(x.ms/1e3).toFixed(1),"s"]})]})},x.id))})]})]})]})}const Bn=["path","file_path","pattern","command","cmd","url","query","description","content"];function Vn(o,t){if(t==null)return"";if(typeof t!="object")return be(String(t),120);const s=t,a=(o??"").toLowerCase();if(/^todo(_?write)?$|^todos$/i.test(a)||Array.isArray(s.todos)){const r=s.todos??[];if(Array.isArray(r)){const i=r.filter(d=>d.status==="completed").length,c=r.filter(d=>d.status==="in_progress").length,l=[`${r.length} todo${r.length===1?"":"s"}`];return i>0&&l.push(`${i} done`),c>0&&l.push(`${c} in-progress`),l.join(" · ")}}if(/batch|parallel/.test(a)||Array.isArray(s.tool_uses)||Array.isArray(s.calls)){const r=s.tool_uses??s.calls??s.batch;if(Array.isArray(r)){const i=new Set;for(const d of r)d&&typeof d=="object"&&"name"in d&&i.add(String(d.name));const c=[...i].slice(0,3).join(", "),l=i.size>3?` +${i.size-3}`:"";return`${r.length} sub-tool${r.length===1?"":"s"}${c?` · ${c}${l}`:""}`}}if(/^(edit|str_replace|edit_file|patch)$/.test(a)){const r=nt(s),i=typeof s.old_string=="string"?s.old_string:"",c=typeof s.new_string=="string"?s.new_string:"",l=i?i.split(`
|
|
72
72
|
`).length:0,d=c?c.split(`
|
|
73
73
|
`).length:0;return`edit ${r||"(file)"}${l||d?` (${l} → ${d} lines)`:""}`}if(/^(write|write_file|create_file|new_file)$/.test(a)){const r=nt(s),i=typeof s.content=="string"?s.content:"",c=i?i.split(`
|
package/dist/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/wrongstack.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>WrongStack WebUI</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-B9lEIHt9.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/vendor-Dff2jyfM.js">
|
|
10
10
|
<link rel="stylesheet" crossorigin href="/assets/index-B-u6omip.css">
|
|
11
11
|
</head>
|
package/dist/index.js
CHANGED
|
@@ -2572,7 +2572,7 @@ function ChatInput() {
|
|
|
2572
2572
|
handleSubmit(e);
|
|
2573
2573
|
}
|
|
2574
2574
|
},
|
|
2575
|
-
[slashSuggestions, atMention, promptHistory, historyIdx,
|
|
2575
|
+
[slashSuggestions, atMention, promptHistory, historyIdx, runSlashCommand, handleSubmit]
|
|
2576
2576
|
);
|
|
2577
2577
|
const adjustTextareaHeight = () => {
|
|
2578
2578
|
const textarea = textareaRef.current;
|