forge-cw 0.1.25 → 0.1.27
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.
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import{jsx as e}from"./preact-jsx-runtime.js";import{useState as B,useRef as w,useEffect as O,useLayoutEffect as
|
|
1
|
+
import{jsx as e}from"./preact-jsx-runtime.js";import{useState as B,useRef as w,useEffect as O,useLayoutEffect as Z,useCallback as ee}from"./preact-hooks.js";import{signal as re}from"./preact-signals.js";import{createPortal as Q}from"./preact-compat.js";import"./preact.js";const te={good:"var(--green)",warn:"var(--orange)",bad:"var(--red)",neutral:"var(--ink-3)"},ye=({icon:r,label:n,value:o,trend:t,status:a})=>e("div",{class:"relative overflow-hidden",style:{padding:"10px 12px",borderRadius:"13px",background:"var(--card)",border:"1px solid var(--hair)",boxShadow:"var(--shadow-s)"},children:[e("div",{class:"flex items-center gap-2",style:{fontSize:"11.5px",color:"var(--ink-2)"},children:[e("span",{children:r}),e("span",{children:n})]}),e("div",{class:"mono",style:{fontSize:"19px",fontWeight:650,marginTop:"2px"},children:o}),t&&e("div",{class:"mono",style:{fontSize:"11.5px",marginTop:"2px",color:t.startsWith("-")?"var(--red)":"var(--green)"},children:t}),e("div",{class:"absolute bottom-0 left-0 right-0 h-0.5",style:{backgroundColor:te[a]}})]}),ne={sm:{pad:"6px 12px",primaryPad:"6px 14px",font:"12.5px",radius:"9px"},md:{pad:"7px 13px",primaryPad:"7px 15px",font:"13px",radius:"9px"},lg:{pad:"12px 16px",primaryPad:"12px 16px",font:"14.5px",radius:"12px"}},V={primary:{background:"linear-gradient(180deg, var(--blue-2), var(--blue))",color:"#fff",border:"0",boxShadow:"var(--shadow-m)",fontWeight:"600"},secondary:{background:"var(--card)",color:"var(--ink)",border:"1px solid var(--hair)",boxShadow:"var(--shadow-s)",fontWeight:"500"},danger:{background:"var(--card)",color:"var(--red)",border:"1px solid var(--hair)",boxShadow:"var(--shadow-s)",fontWeight:"500"},destructive:{background:"var(--red)",color:"#fff",border:"0",boxShadow:"var(--shadow-m)",fontWeight:"600"}},oe={background:"var(--elev)",color:"var(--ink-3)",border:"1px solid transparent",boxShadow:"none",opacity:".8"},se=({label:r,icon:n,variant:o="primary",size:t="md",block:a,title:h,disabled:s,loading:c,onClick:d})=>{const[i,f]=B(!1),p=c??i,l=!!(s||p),u=async()=>{if(!l){f(!0);try{await d()}finally{f(!1)}}},g=ne[t],S=o==="primary"||o==="destructive",z=s&&!p?{...V[o],...oe}:V[o];return e("button",{type:"button",class:`inline-flex items-center justify-center gap-1.5 whitespace-nowrap transition-all duration-180 ease-spring ${l?"cursor-not-allowed":`cursor-pointer hover:-translate-y-px hover:shadow-m${S?" hover:brightness-106":""}`}${a?" w-full":""}`,style:{...z,padding:S?g.primaryPad:g.pad,fontSize:g.font,borderRadius:g.radius},disabled:l,title:h,onClick:u,children:[p?e("span",{class:"i-lucide-loader-2 animate-spin"}):n?e("span",{class:n}):null,e("span",{children:r})]})},ae="modulepreload",ie=function(r){return"/"+r},q={},N=function(n,o,t){let a=Promise.resolve();if(o&&o.length>0){let s=function(i){return Promise.all(i.map(f=>Promise.resolve(f).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));a=s(o.map(i=>{if(i=ie(i),i in q)return;q[i]=!0;const f=i.endsWith(".css"),p=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${i}"]${p}`))return;const l=document.createElement("link");if(l.rel=f?"stylesheet":ae,f||(l.as="script"),l.crossOrigin="",l.href=i,d&&l.setAttribute("nonce",d),document.head.appendChild(l),f)return new Promise((u,g)=>{l.addEventListener("load",u),l.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${i}`)))})}))}function h(s){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=s,window.dispatchEvent(c),!c.defaultPrevented)throw s}return a.then(s=>{for(const c of s||[])c.status==="rejected"&&h(c.reason);return n().catch(h)})};function X(r){/^https?:\/\//i.test(r)&&window.open(r,"_blank","noopener")}const le='ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace',I=r=>({background:r==="dark"?"#0e0e10":"#1c1c1e",foreground:"#e3e3e8",cursor:"#e3e3e8",selectionBackground:"rgba(10,132,255,0.35)"}),we=({streamUrl:r,content:n,wsUrl:o,height:t=300,onExit:a,onGiveUp:h,onConnectionChange:s,onOutput:c,focused:d=!0,theme:i="dark"})=>{const f=w(null),p=!!o,l=w(a);l.current=a;const u=w(h);u.current=h;const g=w(s);g.current=s;const S=w(c);S.current=c;const z=w(i);z.current=i;const j=w(d);j.current=d;const T=w(null);O(()=>{T.current&&(T.current.options.theme=I(i))},[i]),O(()=>{var k;p&&d&&((k=T.current)==null||k.focus())},[d,p]),O(()=>{if(!f.current)return;let k=!1,b=null,C=null,$=0;const J=[];return(async()=>{const{Terminal:F}=await N(async()=>{const{Terminal:v}=await import("./chunk-DlVFs1Kw.js").then(x=>x.x);return{Terminal:v}},[]),{FitAddon:G}=await N(async()=>{const{FitAddon:v}=await import("./chunk-BlxrFPDK.js").then(x=>x.a);return{FitAddon:v}},[]),{WebLinksAddon:U}=await N(async()=>{const{WebLinksAddon:v}=await import("./chunk-BWjmmSgS.js");return{WebLinksAddon:v}},[]);if(k)return;const m=new F({theme:I(z.current),fontSize:13,fontFamily:le,convertEol:!p,disableStdin:!p,cursorBlink:p,scrollback:1e4,linkHandler:{activate:(v,x)=>X(x),allowNonHttpProtocols:!1}});T.current=m;const D=v=>{var x;m.write(v),(x=S.current)==null||x.call(S,v)},A=new G;m.loadAddon(A),m.loadAddon(new U((v,x)=>X(x))),m.open(f.current),setTimeout(()=>{A.fit(),p&&j.current&&m.focus()},50),n&&!p&&D(n);let E;if(r&&!p&&(E=new EventSource(r),E.addEventListener("output",v=>{const{chunk:x}=JSON.parse(v.data);D(x)}),E.addEventListener("done",v=>{const{exitCode:x}=JSON.parse(v.data);m.write(`\r
|
|
2
2
|
\x1B[${x===0?"32":"31"}m--- Exit code: ${x} ---\x1B[0m\r
|
|
3
|
-
`),E==null||E.close()})),o&&!k){const
|
|
3
|
+
`),E==null||E.close()})),o&&!k){const v=x=>{if(k)return;console.log("[ForgeTerminal] Connecting to:",x),b=new WebSocket(x);const M=[];b.onopen=()=>{var y;console.log("[ForgeTerminal] WebSocket OPEN"),$=0,(y=g.current)==null||y.call(g,!0),A.fit();const{cols:L,rows:W}=m;b.send(JSON.stringify({type:"resize",cols:L,rows:W})),M.push(m.onData(R=>{(b==null?void 0:b.readyState)===WebSocket.OPEN&&b.send(JSON.stringify({type:"input",data:R}))})),M.push(m.onResize(({cols:R,rows:P})=>{(b==null?void 0:b.readyState)===WebSocket.OPEN&&b.send(JSON.stringify({type:"resize",cols:R,rows:P}))}))},b.onmessage=L=>{var W;try{const y=JSON.parse(L.data);y.type==="output"||y.type==="scrollback"?D(y.data):y.type==="exit"?(m.write(`\r
|
|
4
4
|
\x1B[33m--- Session ended (code ${y.code}) ---\x1B[0m\r
|
|
5
|
-
`),(
|
|
5
|
+
`),(W=l.current)==null||W.call(l,y.code)):y.type==="error"&&m.write(`\r
|
|
6
6
|
\x1B[31m--- Error: ${y.message} ---\x1B[0m\r
|
|
7
|
-
`)}catch{}},
|
|
7
|
+
`)}catch{}},b.onclose=L=>{var W,y,R;if(console.log("[ForgeTerminal] WebSocket CLOSE:",L.code,L.reason),M.forEach(P=>P.dispose()),M.length=0,(W=g.current)==null||W.call(g,!1),!k)if(L.code===4404)m.write(`\r
|
|
8
8
|
\x1B[31m--- Click Restart to try again. ---\x1B[0m\r
|
|
9
|
-
`),(y=u.current)==null||y.call(u);else if($<5){const P=Math.min(2e3*Math.pow(2,$),16e3);$++,
|
|
9
|
+
`),(y=u.current)==null||y.call(u);else if($<5){const P=Math.min(2e3*Math.pow(2,$),16e3);$++,m.write(`\r
|
|
10
10
|
\x1B[90m--- Reconnecting (attempt ${$}/5)... ---\x1B[0m\r
|
|
11
|
-
`),C=setTimeout(()=>
|
|
11
|
+
`),C=setTimeout(()=>v(x),P)}else m.write(`\r
|
|
12
12
|
\x1B[31m--- Connection lost. Click Restart to try again. ---\x1B[0m\r
|
|
13
|
-
`),(R=u.current)==null||R.call(u)},g.onerror=W=>{console.error("[ForgeTerminal] WebSocket error:",W)}};m(o)}const V=new ResizeObserver(()=>{k||A.fit()});V.observe(f.current),J.push({dispose:()=>{E==null||E.close(),V.disconnect(),C&&clearTimeout(C),g&&(k=!0,g.close()),b.dispose(),T.current=null}})})(),()=>{k=!0,J.forEach(F=>F.dispose())}},[r,n,o,p]);const Y=p?{width:"100%",height:"100%"}:{width:"100%",height:`${t}px`};return e("div",{ref:f,class:"overflow-hidden",style:{...Y,background:I(i).background}})},_=ee([]);function we(r,n="info"){const o=Math.random().toString(36).slice(2);_.value=[..._.value,{id:o,message:r,type:n}],setTimeout(()=>{_.value=_.value.filter(t=>t.id!==o)},4e3)}const le={success:"var(--green)",error:"var(--red)",info:"var(--blue)"},ke=()=>e("div",{class:"fixed bottom-4 right-4 flex flex-col gap-2 z-[70]",style:{maxWidth:"calc(100vw - 32px)"},role:"status","aria-live":"polite",children:_.value.map(r=>e("div",{class:"flex items-center gap-2.5",style:{padding:"10px 14px",borderRadius:"12px",background:"var(--card)",border:"1px solid var(--hair)",boxShadow:"var(--shadow-l)",fontSize:"13px",color:"var(--ink)",animation:"riseIn .3s var(--ease) both"},children:[e("span",{class:"shrink-0",style:{width:"6px",height:"6px",borderRadius:"50%",background:le[r.type]}}),r.message]},r.id))}),ce=({label:r,color:n="var(--ink-2)",variant:o="tint",dot:t})=>{const a=o==="tint"?{background:`color-mix(in srgb, ${n} 18%, transparent)`,color:n}:{background:"var(--elev)",color:"var(--ink-2)",border:"1px solid var(--hair)"};return e("span",{class:"inline-flex items-center gap-1.5 whitespace-nowrap shrink-0",style:{...a,padding:"2px 8px",borderRadius:"99px",fontSize:"11px",fontWeight:600},children:[t&&e("span",{style:{width:"6px",height:"6px",borderRadius:"50%",background:n}}),r]})},Q=({onClick:r,label:n="Close"})=>e("button",{type:"button","aria-label":n,class:"grid place-items-center shrink-0 cursor-pointer transition-all duration-180 ease-spring hover:text-ink",style:{width:"26px",height:"26px",borderRadius:"50%",border:"1px solid var(--hair)",background:"var(--card)",color:"var(--ink-2)"},onClick:r,children:e("span",{class:"i-lucide-x",style:{width:"13px",height:"13px"}})}),Se=({open:r,title:n,onClose:o,footer:t,width:a=540,children:h})=>(H(()=>{if(!r)return;const s=c=>{c.key==="Escape"&&o()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[r,o]),r?Z(e("div",{class:"fixed inset-0 z-[55] flex items-start justify-center overflow-auto",style:{background:"rgba(0,0,0,.42)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",padding:"56px 16px 16px"},onClick:o,children:e("div",{role:"dialog","aria-modal":"true","aria-label":n,class:"flex flex-col overflow-hidden",style:{width:`min(${a}px, 100%)`,maxHeight:"calc(100vh - 72px)",borderRadius:"18px",background:"var(--bg-2)",border:"1px solid var(--hair-2)",boxShadow:"var(--shadow-l)",animation:"popIn .26s var(--ease) both"},onClick:s=>s.stopPropagation(),children:[e("div",{class:"flex items-center gap-2.5 shrink-0",style:{padding:"14px 18px",borderBottom:"1px solid var(--hair)"},children:[e("h2",{style:{fontSize:"17px",fontWeight:700,letterSpacing:"-0.02em"},children:n}),e("span",{class:"flex-1"}),e(Q,{onClick:o})]}),e("div",{class:"overflow-auto min-h-0",style:{padding:"16px 18px"},children:h}),t&&e("div",{class:"flex items-center gap-2.5 shrink-0",style:{padding:"13px 18px",borderTop:"1px solid var(--hair)"},children:t})]})}),document.body):null),Ee=({title:r,onClose:n,children:o})=>(H(()=>{const t=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[n]),Z(e("div",{class:"fixed inset-0 z-50 flex justify-end",style:{background:"rgba(0,0,0,.38)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)"},onClick:n,children:e("aside",{role:"dialog","aria-modal":"true","aria-label":r,class:"flex flex-col h-full overflow-auto",style:{width:"min(492px, 100%)",background:"var(--bg-2)",borderLeft:"1px solid var(--hair)",boxShadow:"var(--shadow-l)",animation:"slideIn .3s var(--ease) both"},onClick:t=>t.stopPropagation(),children:[e("div",{class:"glass flex items-center sticky top-0 z-1",style:{gap:"10px",padding:"14px 18px",borderBottom:"1px solid var(--hair)"},children:[e("h2",{style:{fontSize:"17px",fontWeight:700,letterSpacing:"-0.02em"},children:r}),e("span",{class:"flex-1"}),e(Q,{onClick:n})]}),e("div",{class:"flex flex-col",style:{padding:"16px 18px 24px",gap:"14px"},children:o})]})}),document.body)),We=({tabs:r,active:n,onChange:o,fill:t,size:a="md",label:h})=>{const s=a!=="md",c=a==="xs";return e("div",{role:"tablist","aria-label":h,class:`${t?"flex":"inline-flex"} max-w-full overflow-x-auto`,style:{padding:"3px",borderRadius:s?"10px":"11px",background:"var(--elev)",border:"1px solid var(--hair)"},children:r.map(d=>{const i=n===d.id;return e("button",{type:"button",role:"tab","aria-selected":i,disabled:d.disabled,class:`flex items-center justify-center gap-1.5 whitespace-nowrap transition-all duration-200 ease-spring ${t?"flex-1":""} ${d.disabled?"cursor-not-allowed opacity-50":"cursor-pointer"}`,style:{padding:c?"4px 0":t?s?"5px 6px":"7px 8px":s?"5px 11px":"6px 12px",border:0,borderRadius:s?"7px":"8px",fontSize:c?"11.5px":s?"12px":"12.5px",fontWeight:600,background:i?"var(--card)":"transparent",color:i?"var(--ink)":"var(--ink-3)",boxShadow:i?"var(--shadow-s)":"none"},onClick:()=>o(d.id),children:[d.label,d.count!==void 0&&e("span",{class:"mono",style:{fontSize:"11px",fontWeight:400,color:"var(--ink-3)"},children:d.count})]},d.id)})})},de=({item:r,onItemClick:n})=>{const[o,t]=B(!1);return e("div",{class:`flex items-center justify-between transition-all duration-180 ease-spring ${n?"cursor-pointer":""}`,style:{padding:"11px 15px",borderRadius:"12px",background:"var(--card)",border:`1px solid ${n&&o?"var(--hair-2)":"var(--hair)"}`,boxShadow:"var(--shadow-s)"},onMouseEnter:n?()=>t(!0):void 0,onMouseLeave:n?()=>t(!1):void 0,onClick:n?()=>n(r.id):void 0,children:[e("div",{class:"min-w-0 flex-1",children:[e("div",{class:"truncate",style:{fontSize:"14px",fontWeight:600},children:r.title}),r.subtitle&&e("div",{class:"truncate",style:{fontSize:"12px",color:"var(--ink-2)",marginTop:"2px"},children:r.subtitle})]}),e("div",{class:"flex items-center gap-2 ml-3",children:[r.badge&&e(ce,{label:r.badge.label,color:r.badge.color,variant:"tint"}),r.trailing]})]})},ze=({items:r,loading:n,onItemClick:o})=>n?e("div",{class:"space-y-2",children:[1,2,3].map(t=>e("div",{class:"h-16 animate-pulse",style:{borderRadius:"12px",background:"var(--card)"}},t))}):r.length===0?null:e("div",{class:"space-y-1",children:r.map(t=>e(de,{item:t,onItemClick:o},t.id))}),Le=({icon:r,title:n,description:o,action:t})=>e("div",{class:"flex flex-col items-center justify-center text-center mx-auto",style:{maxWidth:"520px",padding:"36px 28px",borderRadius:"16px",background:"var(--card)",border:"1px solid var(--hair)",boxShadow:"var(--shadow-m)",animation:"riseIn .34s var(--ease) both"},children:[r&&e("span",{class:r,style:{width:"28px",height:"28px",color:"var(--ink-3)",marginBottom:"14px"}}),e("h3",{style:{fontSize:"17px",fontWeight:700,letterSpacing:"-0.02em",marginBottom:"6px"},children:n}),o&&e("p",{style:{fontSize:"13px",color:"var(--ink-2)",maxWidth:"40ch",marginBottom:t?"16px":0},children:o}),t&&e(oe,{label:t.label,variant:"primary",onClick:t.onClick})]}),Re=({checked:r,onChange:n,label:o,disabled:t})=>e("button",{type:"button",role:"switch","aria-checked":r,"aria-label":o,disabled:t,class:`relative shrink-0 ${t?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,style:{width:"44px",height:"26px",borderRadius:"99px",border:0,background:r?"var(--green)":"var(--hair-2)",transition:"background .22s var(--ease)"},onClick:()=>!t&&n(!r),children:e("span",{class:"absolute pointer-events-none",style:{top:"3px",left:r?"21px":"3px",width:"20px",height:"20px",borderRadius:"50%",background:"#fff",boxShadow:"var(--shadow-s)",transition:"left .22s var(--ease)"}})}),Te=({left:r,right:n,defaultWidth:o=300,minWidth:t=200,maxWidth:a=600,storageKey:h="forge-split-width"})=>{const[s,c]=B(()=>{if(typeof localStorage<"u"&&h){const l=localStorage.getItem(h);if(l){const u=parseInt(l,10);if(!isNaN(u)&&u>=t&&u<=a)return u}}return o}),d=w(!1),i=w(0),f=w(0),p=U(l=>{l.preventDefault(),d.current=!0,i.current=l.clientX,f.current=s,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[s]);return O(()=>{const l=v=>{if(!d.current)return;const S=v.clientX-i.current,L=Math.min(a,Math.max(t,f.current+S));c(L)},u=()=>{d.current&&(d.current=!1,document.body.style.cursor="",document.body.style.userSelect="",typeof localStorage<"u"&&h&&localStorage.setItem(h,String(s)))};return document.addEventListener("mousemove",l),document.addEventListener("mouseup",u),()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",u)}},[s,t,a,h]),e("div",{class:"flex h-full w-full overflow-hidden",children:[e("div",{class:"shrink-0 overflow-y-auto overflow-x-hidden",style:{width:`${s}px`},children:r}),e("div",{class:"shrink-0 w-1 cursor-col-resize transition-colors hover:bg-blue",style:{backgroundColor:"var(--hair)"},onMouseDown:p}),e("div",{class:"flex-1 min-w-0 overflow-hidden",children:n})]})},$e=({title:r,defaultOpen:n=!1,children:o})=>{const[t,a]=B(n);return e("div",{style:{borderBottom:"1px solid var(--hair)"},children:[e("button",{class:"flex items-center justify-between w-full px-3 py-2.5 cursor-pointer transition-colors text-ink3 hover:text-ink",style:{fontSize:"11px",fontWeight:600,border:0,background:"none"},onClick:()=>a(!t),children:[e("span",{children:r}),e("span",{class:"transition-transform",style:{transform:t?"rotate(90deg)":"rotate(0deg)"},children:e("span",{class:"i-lucide-chevron-right"})})]}),t&&e("div",{class:"px-3 pb-3",children:o})]})},pe={normal:"--blue",warning:"--orange",critical:"--red"},ue=({bar:r,size:n})=>{const o=`var(${pe[r.severity]})`,t=n==="sm",a=Math.max(0,Math.min(100,r.percent));return e("span",{class:"flex items-center w-full",style:{gap:t?"6px":"9px"},children:[e("span",{class:"mono shrink-0 text-right",style:{width:t?"28px":"32px",fontSize:t?"10px":"11.5px",color:"var(--ink-3)"},children:r.label}),e("span",{class:"relative block flex-1 overflow-hidden",style:{height:t?"4px":"6px",borderRadius:"99px",background:"var(--elev)"},children:e("span",{class:"block h-full",style:{width:`${a}%`,borderRadius:"99px",background:o,transition:"width .6s var(--ease)"}})}),e("span",{class:"mono shrink-0 text-right",style:{width:t?"30px":"36px",fontSize:t?"10px":"11.5px",fontWeight:600,color:r.severity==="normal"?"var(--ink-2)":o},children:[Math.round(r.percent),"%"]}),!t&&r.reset&&e("span",{class:"shrink-0 whitespace-nowrap",style:{fontSize:"11px",color:"var(--ink-3)"},children:r.reset})]})},Pe=({bars:r,size:n="md"})=>e("span",{class:"flex flex-col w-full",style:{gap:n==="sm"?"4px":"6px"},children:r.map((o,t)=>e("span",{class:"flex flex-col w-full",style:{gap:"2px"},children:[e(ue,{bar:o,size:n}),o.scope&&n==="md"&&e("span",{style:{paddingLeft:"39px",fontSize:"10.5px",color:"var(--ink-3)"},children:o.scope})]},t))});export{$e as AccordionSection,oe as ActionButton,ce as Badge,Q as CloseButton,ze as DataList,Ee as Drawer,Le as EmptyState,ye as ForgeTerminal,Se as Modal,Te as SplitPane,me as StatusCard,We as Tabs,ke as ToastContainer,Re as ToggleSwitch,Pe as UsageMeter,we as showToast,_ as toasts};
|
|
13
|
+
`),(R=u.current)==null||R.call(u)},b.onerror=L=>{console.error("[ForgeTerminal] WebSocket error:",L)}};v(o)}const H=new ResizeObserver(()=>{k||A.fit()});H.observe(f.current),J.push({dispose:()=>{E==null||E.close(),H.disconnect(),C&&clearTimeout(C),b&&(k=!0,b.close()),m.dispose(),T.current=null}})})(),()=>{k=!0,J.forEach(F=>F.dispose())}},[r,n,o,p]);const K=p?{width:"100%",height:"100%"}:{width:"100%",height:`${t}px`};return e("div",{ref:f,class:"overflow-hidden",style:{...K,background:I(i).background}})},_=re([]);function ke(r,n="info"){const o=Math.random().toString(36).slice(2);_.value=[..._.value,{id:o,message:r,type:n}],setTimeout(()=>{_.value=_.value.filter(t=>t.id!==o)},4e3)}const ce={success:"var(--green)",error:"var(--red)",info:"var(--blue)"},Se=()=>e("div",{class:"fixed bottom-4 right-4 flex flex-col gap-2 z-[70]",style:{maxWidth:"calc(100vw - 32px)"},role:"status","aria-live":"polite",children:_.value.map(r=>e("div",{class:"flex items-center gap-2.5",style:{padding:"10px 14px",borderRadius:"12px",background:"var(--card)",border:"1px solid var(--hair)",boxShadow:"var(--shadow-l)",fontSize:"13px",color:"var(--ink)",animation:"riseIn .3s var(--ease) both"},children:[e("span",{class:"shrink-0",style:{width:"6px",height:"6px",borderRadius:"50%",background:ce[r.type]}}),r.message]},r.id))}),de=({label:r,color:n="var(--ink-2)",variant:o="tint",dot:t})=>{const a=o==="tint"?{background:`color-mix(in srgb, ${n} 18%, transparent)`,color:n}:{background:"var(--elev)",color:"var(--ink-2)",border:"1px solid var(--hair)"};return e("span",{class:"inline-flex items-center gap-1.5 whitespace-nowrap shrink-0",style:{...a,padding:"2px 8px",borderRadius:"99px",fontSize:"11px",fontWeight:600},children:[t&&e("span",{style:{width:"6px",height:"6px",borderRadius:"50%",background:n}}),r]})},Y=({onClick:r,label:n="Close"})=>e("button",{type:"button","aria-label":n,class:"grid place-items-center shrink-0 cursor-pointer transition-all duration-180 ease-spring hover:text-ink",style:{width:"26px",height:"26px",borderRadius:"50%",border:"1px solid var(--hair)",background:"var(--card)",color:"var(--ink-2)"},onClick:r,children:e("span",{class:"i-lucide-x",style:{width:"13px",height:"13px"}})}),Ee=({open:r,title:n,onClose:o,footer:t,width:a=540,children:h})=>(Z(()=>{if(!r)return;const s=c=>{c.key==="Escape"&&o()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[r,o]),r?Q(e("div",{class:"fixed inset-0 z-[55] flex items-start justify-center overflow-auto",style:{background:"rgba(0,0,0,.42)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",padding:"56px 16px 16px"},onClick:o,children:e("div",{role:"dialog","aria-modal":"true","aria-label":n,class:"flex flex-col overflow-hidden",style:{width:`min(${a}px, 100%)`,maxHeight:"calc(100vh - 72px)",borderRadius:"18px",background:"var(--bg-2)",border:"1px solid var(--hair-2)",boxShadow:"var(--shadow-l)",animation:"popIn .26s var(--ease) both"},onClick:s=>s.stopPropagation(),children:[e("div",{class:"flex items-center gap-2.5 shrink-0",style:{padding:"14px 18px",borderBottom:"1px solid var(--hair)"},children:[e("h2",{style:{fontSize:"17px",fontWeight:700,letterSpacing:"-0.02em"},children:n}),e("span",{class:"flex-1"}),e(Y,{onClick:o})]}),e("div",{class:"overflow-auto min-h-0",style:{padding:"16px 18px"},children:h}),t&&e("div",{class:"flex items-center gap-2.5 shrink-0",style:{padding:"13px 18px",borderTop:"1px solid var(--hair)"},children:t})]})}),document.body):null),Le=({title:r,onClose:n,children:o})=>(Z(()=>{const t=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[n]),Q(e("div",{class:"fixed inset-0 z-50 flex justify-end",style:{background:"rgba(0,0,0,.38)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)"},onClick:n,children:e("aside",{role:"dialog","aria-modal":"true","aria-label":r,class:"flex flex-col h-full overflow-auto",style:{width:"min(492px, 100%)",background:"var(--bg-2)",borderLeft:"1px solid var(--hair)",boxShadow:"var(--shadow-l)",animation:"slideIn .3s var(--ease) both"},onClick:t=>t.stopPropagation(),children:[e("div",{class:"glass flex items-center sticky top-0 z-1",style:{gap:"10px",padding:"14px 18px",borderBottom:"1px solid var(--hair)"},children:[e("h2",{style:{fontSize:"17px",fontWeight:700,letterSpacing:"-0.02em"},children:r}),e("span",{class:"flex-1"}),e(Y,{onClick:n})]}),e("div",{class:"flex flex-col",style:{padding:"16px 18px 24px",gap:"14px"},children:o})]})}),document.body)),We=({tabs:r,active:n,onChange:o,fill:t,size:a="md",label:h})=>{const s=a!=="md",c=a==="xs";return e("div",{role:"tablist","aria-label":h,class:`${t?"flex":"inline-flex"} max-w-full overflow-x-auto`,style:{padding:"3px",borderRadius:s?"10px":"11px",background:"var(--elev)",border:"1px solid var(--hair)"},children:r.map(d=>{const i=n===d.id;return e("button",{type:"button",role:"tab","aria-selected":i,disabled:d.disabled,class:`flex items-center justify-center gap-1.5 whitespace-nowrap transition-all duration-200 ease-spring ${t?"flex-1":""} ${d.disabled?"cursor-not-allowed opacity-50":"cursor-pointer"}`,style:{padding:c?"4px 0":t?s?"5px 6px":"7px 8px":s?"5px 11px":"6px 12px",border:0,borderRadius:s?"7px":"8px",fontSize:c?"11.5px":s?"12px":"12.5px",fontWeight:600,background:i?"var(--card)":"transparent",color:i?"var(--ink)":"var(--ink-3)",boxShadow:i?"var(--shadow-s)":"none"},onClick:()=>o(d.id),children:[d.label,d.count!==void 0&&e("span",{class:"mono",style:{fontSize:"11px",fontWeight:400,color:"var(--ink-3)"},children:d.count})]},d.id)})})},pe=({item:r,onItemClick:n})=>{const[o,t]=B(!1);return e("div",{class:`flex items-center justify-between transition-all duration-180 ease-spring ${n?"cursor-pointer":""}`,style:{padding:"11px 15px",borderRadius:"12px",background:"var(--card)",border:`1px solid ${n&&o?"var(--hair-2)":"var(--hair)"}`,boxShadow:"var(--shadow-s)"},onMouseEnter:n?()=>t(!0):void 0,onMouseLeave:n?()=>t(!1):void 0,onClick:n?()=>n(r.id):void 0,children:[e("div",{class:"min-w-0 flex-1",children:[e("div",{class:"truncate",style:{fontSize:"14px",fontWeight:600},children:r.title}),r.subtitle&&e("div",{class:"truncate",style:{fontSize:"12px",color:"var(--ink-2)",marginTop:"2px"},children:r.subtitle})]}),e("div",{class:"flex items-center gap-2 ml-3",children:[r.badge&&e(de,{label:r.badge.label,color:r.badge.color,variant:"tint"}),r.trailing]})]})},ze=({items:r,loading:n,onItemClick:o})=>n?e("div",{class:"space-y-2",children:[1,2,3].map(t=>e("div",{class:"h-16 animate-pulse",style:{borderRadius:"12px",background:"var(--card)"}},t))}):r.length===0?null:e("div",{class:"space-y-1",children:r.map(t=>e(pe,{item:t,onItemClick:o},t.id))}),Re=({icon:r,title:n,description:o,action:t})=>e("div",{class:"flex flex-col items-center justify-center text-center mx-auto",style:{maxWidth:"520px",padding:"36px 28px",borderRadius:"16px",background:"var(--card)",border:"1px solid var(--hair)",boxShadow:"var(--shadow-m)",animation:"riseIn .34s var(--ease) both"},children:[r&&e("span",{class:r,style:{width:"28px",height:"28px",color:"var(--ink-3)",marginBottom:"14px"}}),e("h3",{style:{fontSize:"17px",fontWeight:700,letterSpacing:"-0.02em",marginBottom:"6px"},children:n}),o&&e("p",{style:{fontSize:"13px",color:"var(--ink-2)",maxWidth:"40ch",marginBottom:t?"16px":0},children:o}),t&&e(se,{label:t.label,variant:"primary",onClick:t.onClick})]}),Te=({checked:r,onChange:n,label:o,disabled:t})=>e("button",{type:"button",role:"switch","aria-checked":r,"aria-label":o,disabled:t,class:`relative shrink-0 ${t?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,style:{width:"44px",height:"26px",borderRadius:"99px",border:0,background:r?"var(--green)":"var(--hair-2)",transition:"background .22s var(--ease)"},onClick:()=>!t&&n(!r),children:e("span",{class:"absolute pointer-events-none",style:{top:"3px",left:r?"21px":"3px",width:"20px",height:"20px",borderRadius:"50%",background:"#fff",boxShadow:"var(--shadow-s)",transition:"left .22s var(--ease)"}})}),$e=({left:r,right:n,defaultWidth:o=300,minWidth:t=200,maxWidth:a=600,storageKey:h="forge-split-width"})=>{const[s,c]=B(()=>{if(typeof localStorage<"u"&&h){const l=localStorage.getItem(h);if(l){const u=parseInt(l,10);if(!isNaN(u)&&u>=t&&u<=a)return u}}return o}),d=w(!1),i=w(0),f=w(0),p=ee(l=>{l.preventDefault(),d.current=!0,i.current=l.clientX,f.current=s,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[s]);return O(()=>{const l=g=>{if(!d.current)return;const S=g.clientX-i.current,z=Math.min(a,Math.max(t,f.current+S));c(z)},u=()=>{d.current&&(d.current=!1,document.body.style.cursor="",document.body.style.userSelect="",typeof localStorage<"u"&&h&&localStorage.setItem(h,String(s)))};return document.addEventListener("mousemove",l),document.addEventListener("mouseup",u),()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",u)}},[s,t,a,h]),e("div",{class:"flex h-full w-full overflow-hidden",children:[e("div",{class:"shrink-0 overflow-y-auto overflow-x-hidden",style:{width:`${s}px`},children:r}),e("div",{class:"shrink-0 w-1 cursor-col-resize transition-colors hover:bg-blue",style:{backgroundColor:"var(--hair)"},onMouseDown:p}),e("div",{class:"flex-1 min-w-0 overflow-hidden",children:n})]})},Pe=({title:r,defaultOpen:n=!1,children:o})=>{const[t,a]=B(n);return e("div",{style:{borderBottom:"1px solid var(--hair)"},children:[e("button",{class:"flex items-center justify-between w-full px-3 py-2.5 cursor-pointer transition-colors text-ink3 hover:text-ink",style:{fontSize:"11px",fontWeight:600,border:0,background:"none"},onClick:()=>a(!t),children:[e("span",{children:r}),e("span",{class:"transition-transform",style:{transform:t?"rotate(90deg)":"rotate(0deg)"},children:e("span",{class:"i-lucide-chevron-right"})})]}),t&&e("div",{class:"px-3 pb-3",children:o})]})},ue={normal:"--blue",warning:"--orange",critical:"--red"},xe=({bar:r,size:n})=>{const o=`var(${ue[r.severity]})`,t=n==="sm",a=Math.max(0,Math.min(100,r.percent));return e("span",{class:"flex items-center w-full",style:{gap:t?"6px":"9px"},children:[e("span",{class:"mono shrink-0 text-right",style:{width:t?"28px":"32px",fontSize:t?"10px":"11.5px",color:"var(--ink-3)"},children:r.label}),e("span",{class:"relative block flex-1 overflow-hidden",style:{height:t?"4px":"6px",borderRadius:"99px",background:"var(--elev)"},children:e("span",{class:"block h-full",style:{width:`${a}%`,borderRadius:"99px",background:o,transition:"width .6s var(--ease)"}})}),e("span",{class:"mono shrink-0 text-right",style:{width:t?"30px":"36px",fontSize:t?"10px":"11.5px",fontWeight:600,color:r.severity==="normal"?"var(--ink-2)":o},children:[Math.round(r.percent),"%"]}),!t&&r.reset&&e("span",{class:"shrink-0 whitespace-nowrap",style:{fontSize:"11px",color:"var(--ink-3)"},children:r.reset})]})},_e=({bars:r,size:n="md"})=>e("span",{class:"flex flex-col w-full",style:{gap:n==="sm"?"4px":"6px"},children:r.map((o,t)=>e("span",{class:"flex flex-col w-full",style:{gap:"2px"},children:[e(xe,{bar:o,size:n}),o.scope&&n==="md"&&e("span",{style:{paddingLeft:"39px",fontSize:"10.5px",color:"var(--ink-3)"},children:o.scope})]},t))});export{Pe as AccordionSection,se as ActionButton,de as Badge,Y as CloseButton,ze as DataList,Le as Drawer,Re as EmptyState,we as ForgeTerminal,Ee as Modal,$e as SplitPane,ye as StatusCard,We as Tabs,Se as ToastContainer,Te as ToggleSwitch,_e as UsageMeter,ke as showToast,_ as toasts};
|
package/dist/index.js
CHANGED
|
@@ -8656,7 +8656,7 @@ function runAgent(input, o) {
|
|
|
8656
8656
|
const cwd = mkdtempSync2(join19(tmpdir2(), "forge-agent-"));
|
|
8657
8657
|
const cleanup = () => rmSync4(cwd, { recursive: true, force: true });
|
|
8658
8658
|
return new Promise((resolve11, reject) => {
|
|
8659
|
-
const child = spawn9("claude", args, { cwd, env: { ...envWithoutHarness(), CLAUDE_CONFIG_DIR: configDir }, stdio: ["pipe", "pipe", "pipe"] });
|
|
8659
|
+
const child = spawn9("claude", args, { cwd, env: { ...envWithoutHarness(), CLAUDE_CONFIG_DIR: configDir, ...CONNECTOR_ENV }, stdio: ["pipe", "pipe", "pipe"] });
|
|
8660
8660
|
child.stdin?.on("error", () => {
|
|
8661
8661
|
});
|
|
8662
8662
|
child.stdin?.end(input.prompt);
|
|
@@ -8698,7 +8698,7 @@ function runAgent(input, o) {
|
|
|
8698
8698
|
}));
|
|
8699
8699
|
}).finally(cleanup);
|
|
8700
8700
|
}
|
|
8701
|
-
var DEFAULT_TIMEOUT_MS;
|
|
8701
|
+
var DEFAULT_TIMEOUT_MS, CONNECTOR_ENV;
|
|
8702
8702
|
var init_agent_runner = __esm({
|
|
8703
8703
|
"../core/dist/agent-runner.js"() {
|
|
8704
8704
|
"use strict";
|
|
@@ -8706,6 +8706,7 @@ var init_agent_runner = __esm({
|
|
|
8706
8706
|
init_cw_types();
|
|
8707
8707
|
init_cw_doctor();
|
|
8708
8708
|
DEFAULT_TIMEOUT_MS = 18e4;
|
|
8709
|
+
CONNECTOR_ENV = { MCP_CONNECTION_NONBLOCKING: "false", MCP_TIMEOUT: "60000" };
|
|
8709
8710
|
}
|
|
8710
8711
|
});
|
|
8711
8712
|
|
|
@@ -19,7 +19,18 @@ var failedLine = (error) => `Last reading failed: ${error}`;
|
|
|
19
19
|
var loadFailedLine = (error) => `Can't load Today: ${error}`;
|
|
20
20
|
var notesLine = (notes) => notes?.length ? notes.join(" \xB7 ") : null;
|
|
21
21
|
var SOURCE_NAME = { slack: "Slack", linear: "Linear", reader: "Reader" };
|
|
22
|
-
|
|
22
|
+
function sourcesLabel(sources) {
|
|
23
|
+
const names = ["slack", "linear", "reader"].filter((s) => sources.includes(s)).map((s) => SOURCE_NAME[s]);
|
|
24
|
+
return names.join(" and ");
|
|
25
|
+
}
|
|
26
|
+
function groupProblems(problems) {
|
|
27
|
+
const accounts = [...new Set(problems.map((p) => p.account))];
|
|
28
|
+
return accounts.map((account) => {
|
|
29
|
+
const mine = problems.filter((p) => p.account === account);
|
|
30
|
+
return { account, label: sourcesLabel(mine.map((p) => p.source)), reasons: mine.map((p) => `${SOURCE_NAME[p.source]}: ${p.reason}`) };
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
var groupLine = (g) => `${g.account} \xB7 ${g.label} did not respond`;
|
|
23
34
|
var problemsLabel = (n) => `\u26A0 ${n} account problem${n === 1 ? "" : "s"}`;
|
|
24
35
|
var accountsOf = (items) => [...new Set(items.flatMap((i) => i.account ? [i.account] : []))];
|
|
25
36
|
|
|
@@ -61,6 +72,7 @@ function useAccountFilter() {
|
|
|
61
72
|
function useDigest(forge, path = "/digest") {
|
|
62
73
|
const [reply, setReply] = useState(null);
|
|
63
74
|
const [error, setError] = useState(null);
|
|
75
|
+
const [hurried, hurry] = useState(false);
|
|
64
76
|
const latest = useRef(0);
|
|
65
77
|
const load = useCallback(async () => {
|
|
66
78
|
const mine = ++latest.current;
|
|
@@ -73,19 +85,20 @@ function useDigest(forge, path = "/digest") {
|
|
|
73
85
|
if (mine === latest.current) setError(errorMessage(e));
|
|
74
86
|
}
|
|
75
87
|
}, [forge, path]);
|
|
88
|
+
const fast = hurried || !!reply?.reading;
|
|
76
89
|
useEffect(() => {
|
|
77
90
|
void load();
|
|
78
91
|
const poll = () => {
|
|
79
92
|
if (!document.hidden) void load();
|
|
80
93
|
};
|
|
81
|
-
const t = setInterval(poll, 6e4);
|
|
94
|
+
const t = setInterval(poll, fast ? 3e3 : 6e4);
|
|
82
95
|
document.addEventListener("visibilitychange", poll);
|
|
83
96
|
return () => {
|
|
84
97
|
clearInterval(t);
|
|
85
98
|
document.removeEventListener("visibilitychange", poll);
|
|
86
99
|
};
|
|
87
|
-
}, [load]);
|
|
88
|
-
return { reply, error, reload: load };
|
|
100
|
+
}, [load, fast]);
|
|
101
|
+
return { reply, error, reload: load, hurry };
|
|
89
102
|
}
|
|
90
103
|
function useProjects(forge) {
|
|
91
104
|
const [projects, setProjects] = useState(EMPTY_PROJECTS);
|
|
@@ -95,7 +108,8 @@ function useProjects(forge) {
|
|
|
95
108
|
}, [forge]);
|
|
96
109
|
return projects;
|
|
97
110
|
}
|
|
98
|
-
function useActing(forge, date, reload) {
|
|
111
|
+
function useActing(forge, date, reload, hurry = () => {
|
|
112
|
+
}) {
|
|
99
113
|
const [busy, setBusy] = useState(false);
|
|
100
114
|
const [refreshing, setRefreshing] = useState(false);
|
|
101
115
|
const [retrying, setRetrying] = useState(null);
|
|
@@ -121,7 +135,9 @@ function useActing(forge, date, reload) {
|
|
|
121
135
|
if (reading.current) return;
|
|
122
136
|
reading.current = true;
|
|
123
137
|
setRefreshing(true);
|
|
138
|
+
hurry(true);
|
|
124
139
|
await guarded(() => forge.action("refresh"));
|
|
140
|
+
hurry(false);
|
|
125
141
|
reading.current = false;
|
|
126
142
|
setRefreshing(false);
|
|
127
143
|
};
|
|
@@ -129,7 +145,9 @@ function useActing(forge, date, reload) {
|
|
|
129
145
|
if (busy) return;
|
|
130
146
|
setBusy(true);
|
|
131
147
|
setRetrying(account);
|
|
148
|
+
hurry(true);
|
|
132
149
|
await guarded(() => forge.action("retry-account", { account }));
|
|
150
|
+
hurry(false);
|
|
133
151
|
setRetrying(null);
|
|
134
152
|
setBusy(false);
|
|
135
153
|
};
|
|
@@ -293,15 +311,58 @@ var Row = ({ item, projects = EMPTY_PROJECTS, acting, forge }) => {
|
|
|
293
311
|
] })
|
|
294
312
|
] });
|
|
295
313
|
};
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
314
|
+
var READING_CSS = `
|
|
315
|
+
@keyframes today-spin { to { transform: rotate(360deg) } }
|
|
316
|
+
@keyframes today-pulse { 0%, 100% { opacity: .55 } 50% { opacity: 1 } }
|
|
317
|
+
.today-spin { animation: today-spin .8s linear infinite }
|
|
318
|
+
.today-pulse { animation: today-pulse 1.4s ease-in-out infinite }
|
|
319
|
+
@media (prefers-reduced-motion: reduce) { .today-spin, .today-pulse { animation: none } }`;
|
|
320
|
+
function useReadingStyles() {
|
|
321
|
+
if (typeof document !== "undefined" && !document.getElementById("today-reading-css")) {
|
|
322
|
+
const el = document.createElement("style");
|
|
323
|
+
el.id = "today-reading-css";
|
|
324
|
+
el.textContent = READING_CSS;
|
|
325
|
+
document.head.appendChild(el);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
function Spinner() {
|
|
329
|
+
return /* @__PURE__ */ jsx("i", { class: "today-spin", style: { display: "inline-block", width: "10px", height: "10px", borderRadius: "50%", border: "2px solid var(--hair-2)", borderTopColor: "var(--blue)", boxSizing: "border-box" } });
|
|
330
|
+
}
|
|
331
|
+
function ReadingLine({ reading }) {
|
|
332
|
+
useReadingStyles();
|
|
333
|
+
const accounts = Object.entries(reading?.accounts ?? {});
|
|
334
|
+
return /* @__PURE__ */ jsxs("span", { role: "status", "aria-live": "polite", style: { display: "inline-flex", alignItems: "center", gap: "6px", fontSize: "12px", color: "var(--ink-2)", flexWrap: "wrap" }, children: [
|
|
335
|
+
/* @__PURE__ */ jsx("b", { class: "today-pulse", style: { fontWeight: 600, color: "var(--ink)" }, children: accounts.length ? "Reading" : "Reading\u2026" }),
|
|
336
|
+
accounts.map(([account, state], n) => /* @__PURE__ */ jsxs("span", { style: { display: "inline-flex", alignItems: "center", gap: "5px" }, children: [
|
|
337
|
+
n > 0 && /* @__PURE__ */ jsx("span", { style: { color: "var(--ink-3)" }, children: "\xB7" }),
|
|
338
|
+
state === "reading" ? /* @__PURE__ */ jsx(Spinner, {}) : state === "done" ? /* @__PURE__ */ jsx("span", { style: { color: "var(--green)" }, children: "\u2713" }) : /* @__PURE__ */ jsx("span", { style: { color: "var(--orange)" }, children: "\u26A0" }),
|
|
339
|
+
account
|
|
340
|
+
] }, account)),
|
|
341
|
+
accounts.length > 0 && /* @__PURE__ */ jsx("span", { children: "\u2026" })
|
|
342
|
+
] });
|
|
343
|
+
}
|
|
344
|
+
function SkeletonRows() {
|
|
345
|
+
useReadingStyles();
|
|
346
|
+
return /* @__PURE__ */ jsx("div", { "aria-hidden": "true", style: { display: "flex", flexDirection: "column", gap: "6px" }, children: [0, 1, 2].map((n) => /* @__PURE__ */ jsxs("div", { class: "today-pulse", style: { display: "flex", alignItems: "center", gap: "12px", padding: "10px 12px", borderRadius: "10px", background: "var(--elev)", border: "1px solid var(--hair)", animationDelay: `${n * 0.15}s` }, children: [
|
|
347
|
+
/* @__PURE__ */ jsx("div", { style: { width: "30px", height: "30px", borderRadius: "8px", background: "var(--hair)" } }),
|
|
348
|
+
/* @__PURE__ */ jsxs("div", { style: { flex: 1, display: "flex", flexDirection: "column", gap: "6px" }, children: [
|
|
349
|
+
/* @__PURE__ */ jsx("div", { style: { height: "9px", width: `${70 - n * 12}%`, borderRadius: "5px", background: "var(--hair)" } }),
|
|
350
|
+
/* @__PURE__ */ jsx("div", { style: { height: "8px", width: "35%", borderRadius: "5px", background: "var(--hair)" } })
|
|
304
351
|
] })
|
|
352
|
+
] }, n)) });
|
|
353
|
+
}
|
|
354
|
+
function ProblemRow({ group, acting, details = false }) {
|
|
355
|
+
const mine = acting.retrying === group.account;
|
|
356
|
+
return /* @__PURE__ */ jsxs("div", { role: "alert", title: group.reasons.join("\n"), style: { padding: "7px 10px", borderRadius: "10px", fontSize: "12px", color: "var(--ink-2)", background: soft("--orange", 10), border: `1px solid ${soft("--orange", 35)}` }, children: [
|
|
357
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "10px" }, children: [
|
|
358
|
+
/* @__PURE__ */ jsx("span", { style: { color: "var(--orange)" }, children: "\u26A0" }),
|
|
359
|
+
/* @__PURE__ */ jsx("span", { style: { minWidth: 0, overflowWrap: "anywhere" }, children: groupLine(group) }),
|
|
360
|
+
/* @__PURE__ */ jsxs("span", { style: { marginLeft: "auto", display: "flex", gap: "8px", flexShrink: 0 }, children: [
|
|
361
|
+
/* @__PURE__ */ jsx(Btn, { label: mine ? "Reading\u2026" : "Retry", disabled: acting.busy, onClick: () => acting.retry(group.account) }),
|
|
362
|
+
/* @__PURE__ */ jsx(Btn, { label: "Reconnect", style: ghostStyle, disabled: acting.busy, onClick: () => acting.reconnect(group.account) })
|
|
363
|
+
] })
|
|
364
|
+
] }),
|
|
365
|
+
details && /* @__PURE__ */ jsx("ul", { style: { margin: "6px 0 0 22px", padding: 0, color: "var(--ink-3)", fontSize: "11.5px" }, children: group.reasons.map((r) => /* @__PURE__ */ jsx("li", { children: r }, r)) })
|
|
305
366
|
] });
|
|
306
367
|
}
|
|
307
368
|
|
|
@@ -342,12 +403,14 @@ function Strip({ title, children, actions }) {
|
|
|
342
403
|
);
|
|
343
404
|
}
|
|
344
405
|
function Banner({ forge }) {
|
|
345
|
-
const { reply, error, reload } = useDigest(forge);
|
|
406
|
+
const { reply, error, reload, hurry } = useDigest(forge);
|
|
346
407
|
const projects = useProjects(forge);
|
|
347
408
|
const [chosen, choose] = useAccountFilter();
|
|
348
409
|
const digest = reply?.digest;
|
|
349
|
-
const acting = useActing(forge, digest?.date, reload);
|
|
350
|
-
const
|
|
410
|
+
const acting = useActing(forge, digest?.date, reload, hurry);
|
|
411
|
+
const reading = reply?.reading;
|
|
412
|
+
const isReading = acting.refreshing || !!reading;
|
|
413
|
+
const refreshBtn = /* @__PURE__ */ jsx2(Btn, { label: isReading ? "Reading\u2026" : "Refresh", style: ghostStyle, disabled: isReading, onClick: acting.refresh });
|
|
351
414
|
const failure = (text) => /* @__PURE__ */ jsxs2("span", { style: { color: "var(--red)" }, children: [
|
|
352
415
|
"\xB7 ",
|
|
353
416
|
text
|
|
@@ -357,8 +420,8 @@ function Banner({ forge }) {
|
|
|
357
420
|
"\xB7 ",
|
|
358
421
|
notes
|
|
359
422
|
] });
|
|
360
|
-
const problems = digest?.problems ?? [];
|
|
361
|
-
const problemRows = problems.length > 0 && /* @__PURE__ */ jsx2("div", { style: { display: "flex", flexDirection: "column", gap: "6px", marginBottom: "8px" }, children: problems.map((
|
|
423
|
+
const problems = groupProblems(digest?.problems ?? []);
|
|
424
|
+
const problemRows = problems.length > 0 && /* @__PURE__ */ jsx2("div", { style: { display: "flex", flexDirection: "column", gap: "6px", marginBottom: "8px" }, children: problems.map((g) => /* @__PURE__ */ jsx2(ProblemRow, { group: g, acting }, g.account)) });
|
|
362
425
|
const problemsLink = problems.length > 0 && /* @__PURE__ */ jsxs2("button", { type: "button", onClick: () => forge.openPage(), style: { font: "inherit", fontSize: "inherit", padding: 0, border: 0, background: "none", cursor: "pointer", color: "var(--orange)" }, children: [
|
|
363
426
|
"\xB7 ",
|
|
364
427
|
problemsLabel(problems.length)
|
|
@@ -367,6 +430,19 @@ function Banner({ forge }) {
|
|
|
367
430
|
if (reply && !reply.enabled) {
|
|
368
431
|
return /* @__PURE__ */ jsx2(Strip, { title: "Today", actions: /* @__PURE__ */ jsx2(Btn, { label: "Turn on", style: primaryStyle, disabled: acting.busy, onClick: () => acting.run(() => forge.action("enable")) }), children: /* @__PURE__ */ jsx2("span", { children: "\xB7 Linear, Slack and GitHub each morning" }) });
|
|
369
432
|
}
|
|
433
|
+
if (reply && isReading && (!digest || digest.items.length === 0)) {
|
|
434
|
+
return shell(
|
|
435
|
+
/* @__PURE__ */ jsxs2("div", { style: { padding: "14px 18px", display: "flex", flexDirection: "column", gap: "12px" }, children: [
|
|
436
|
+
/* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", gap: "10px" }, children: [
|
|
437
|
+
/* @__PURE__ */ jsx2("span", { style: { color: "var(--orange)" }, children: "\u2600\uFE0E" }),
|
|
438
|
+
/* @__PURE__ */ jsx2(ReadingLine, { reading }),
|
|
439
|
+
/* @__PURE__ */ jsx2("span", { style: { marginLeft: "auto" }, children: refreshBtn })
|
|
440
|
+
] }),
|
|
441
|
+
!digest && /* @__PURE__ */ jsx2(SkeletonRows, {}),
|
|
442
|
+
problemRows
|
|
443
|
+
] })
|
|
444
|
+
);
|
|
445
|
+
}
|
|
370
446
|
if (!reply || !digest || digest.items.length === 0) {
|
|
371
447
|
return /* @__PURE__ */ jsxs2(Strip, { title: reply && !digest ? "Not read yet" : shortDay(/* @__PURE__ */ new Date(), digest?.date), actions: refreshBtn, children: [
|
|
372
448
|
!reply ? failure(loadFailedLine(error)) : digest?.error ? failure(failedLine(digest.error)) : digest && /* @__PURE__ */ jsxs2("span", { children: [
|
|
@@ -412,7 +488,7 @@ function Banner({ forge }) {
|
|
|
412
488
|
/* @__PURE__ */ jsx2("div", { style: { width: "34px", height: "34px", borderRadius: "10px", display: "grid", placeItems: "center", background: "linear-gradient(160deg, #ffb340, #ff7a1a)", boxShadow: "0 4px 14px rgba(255, 140, 30, .35)", fontSize: "17px" }, children: "\u2600\uFE0E" }),
|
|
413
489
|
/* @__PURE__ */ jsxs2("div", { children: [
|
|
414
490
|
/* @__PURE__ */ jsx2("h3", { style: { margin: 0, fontSize: "15px", fontWeight: 650, letterSpacing: "-.01em" }, children: dayLabel(/* @__PURE__ */ new Date(), digest.date) }),
|
|
415
|
-
/* @__PURE__ */ jsx2("div", { style: { color: "var(--ink-2)", fontSize: "12px", marginTop: "1px" }, children: readLine(digest) })
|
|
491
|
+
/* @__PURE__ */ jsx2("div", { style: { color: "var(--ink-2)", fontSize: "12px", marginTop: "1px" }, children: isReading ? /* @__PURE__ */ jsx2(ReadingLine, { reading }) : readLine(digest) })
|
|
416
492
|
] }),
|
|
417
493
|
/* @__PURE__ */ jsxs2("div", { style: { marginLeft: "auto", display: "flex", gap: "8px" }, children: [
|
|
418
494
|
refreshBtn,
|
|
@@ -95,11 +95,13 @@ function parseReaderProblems(out) {
|
|
|
95
95
|
return [];
|
|
96
96
|
}
|
|
97
97
|
if (!isRecord(root) || !Array.isArray(root.problems)) return [];
|
|
98
|
-
return root.problems.filter((p) => typeof p === "string" &&
|
|
98
|
+
return root.problems.filter((p) => typeof p === "string" && /\b(slack|linear)\b/i.test(p) && !/^\s*github/i.test(p)).slice(0, 5).map((p) => p.replace(/\s+/g, " ").trim().slice(0, 160));
|
|
99
99
|
}
|
|
100
100
|
function toProblem(account, text2) {
|
|
101
101
|
const m = /^(slack|linear|reader)\s*:\s*(.+)$/i.exec(text2);
|
|
102
|
-
|
|
102
|
+
if (m) return { account, source: m[1].toLowerCase(), reason: m[2] };
|
|
103
|
+
const named = /\b(slack|linear)\b/i.exec(text2);
|
|
104
|
+
return { account, source: named ? named[1].toLowerCase() : "reader", reason: text2 };
|
|
103
105
|
}
|
|
104
106
|
function parseReaderOutput(out, known) {
|
|
105
107
|
const root = extractJson(out);
|
|
@@ -214,7 +216,7 @@ Item kinds (to-task | issue | request | research | review), exactly one per item
|
|
|
214
216
|
Answer with ONLY a JSON object, no prose and no code fence:
|
|
215
217
|
{ "items": [ { "source": "linear" | "slack" | "github", "kind": "to-task" | "issue" | "request" | "research" | "review", "title": string, "who": string, "where": string, "when": ISO time of the latest activity, "quote"?: string, "link": string (permalink, issue URL or pull request URL), "issueKey"?: string, "targetSession"?: { "project": string, "sessionDir": string }, "project"?: string } ], "problems"?: [ string ] }
|
|
216
218
|
Every item needs a link. Use an empty items array when there is nothing new.
|
|
217
|
-
|
|
219
|
+
Problems are only for the Slack and Linear tools: if one is missing, still connecting or fails, do not report "nothing new" for it, add "slack: <short reason>" or "linear: <short reason>" to problems. Never put anything else in problems (GitHub is given to you as data, not a tool).`;
|
|
218
220
|
}
|
|
219
221
|
|
|
220
222
|
// src/github.ts
|
|
@@ -314,7 +316,8 @@ async function fetchGithub(ctx, since, deadlineMs = DEADLINE_MS) {
|
|
|
314
316
|
items.push({ type: "mention", repo: n.repository.full_name, number: page.number, title: n.subject.title, url: page.url, pr: page.url, when: n.updated_at });
|
|
315
317
|
}
|
|
316
318
|
}
|
|
317
|
-
|
|
319
|
+
const requested = asked.length >= MAX_PRS ? void 0 : asked.map((pr) => pr.url);
|
|
320
|
+
return unread ? { items, requested, error: `${unread} pull request${unread === 1 ? "" : "s"} could not be read` } : { items, requested };
|
|
318
321
|
} catch (e) {
|
|
319
322
|
return { items: [], error: errorMessage(e) };
|
|
320
323
|
}
|
|
@@ -327,6 +330,9 @@ function localDate(d) {
|
|
|
327
330
|
const p = (n) => String(n).padStart(2, "0");
|
|
328
331
|
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())}`;
|
|
329
332
|
}
|
|
333
|
+
var timing = { retryMs: 15e3 };
|
|
334
|
+
var progress;
|
|
335
|
+
var readingNow = () => progress ? { startedAt: progress.startedAt, accounts: { ...progress.accounts } } : void 0;
|
|
330
336
|
var chain = Promise.resolve();
|
|
331
337
|
function locked(fn) {
|
|
332
338
|
const next = chain.then(fn, fn);
|
|
@@ -385,7 +391,10 @@ async function readAccount(ctx, account, o) {
|
|
|
385
391
|
const model = typeof ctx.settings.model === "string" && ctx.settings.model ? ctx.settings.model : void 0;
|
|
386
392
|
const ask = () => ctx.agent.run({ account, prompt, model, allowedTools: READER_TOOLS, timeoutMs: 10 * 60 * 1e3 });
|
|
387
393
|
let out = await ask();
|
|
388
|
-
if (parseReaderProblems(out.text).length)
|
|
394
|
+
if (parseReaderProblems(out.text).length) {
|
|
395
|
+
await new Promise((r) => setTimeout(r, timing.retryMs));
|
|
396
|
+
out = await ask();
|
|
397
|
+
}
|
|
389
398
|
const problems = parseReaderProblems(out.text).map((p) => toProblem(account, p));
|
|
390
399
|
const fetched = new Set(github.map((e) => e.pr));
|
|
391
400
|
const toReview = new Set(github.filter((e) => e.type === "review-request").map((e) => e.pr));
|
|
@@ -395,11 +404,15 @@ async function readAccount(ctx, account, o) {
|
|
|
395
404
|
return { items: github.length ? fresh.map((i) => ({ ...i, manual: true })) : fresh, problems };
|
|
396
405
|
}
|
|
397
406
|
async function readOne(ctx, account, o) {
|
|
407
|
+
const finish = (r) => {
|
|
408
|
+
if (progress) progress.accounts[account] = r.problems.length ? "problem" : "done";
|
|
409
|
+
return r;
|
|
410
|
+
};
|
|
398
411
|
try {
|
|
399
|
-
return { account, ...await readAccount(ctx, account, o) };
|
|
412
|
+
return finish({ account, ...await readAccount(ctx, account, o) });
|
|
400
413
|
} catch (e) {
|
|
401
414
|
const error = errorMessage(e);
|
|
402
|
-
return { account, items: [], problems: [{ account, source: "reader", reason: error.replace(/\s+/g, " ").trim().slice(0, 160) }], error };
|
|
415
|
+
return finish({ account, items: [], problems: [{ account, source: "reader", reason: error.replace(/\s+/g, " ").trim().slice(0, 160) }], error });
|
|
403
416
|
}
|
|
404
417
|
}
|
|
405
418
|
async function reread(ctx, now, notes) {
|
|
@@ -413,13 +426,15 @@ async function reread(ctx, now, notes) {
|
|
|
413
426
|
readAccounts(ctx)
|
|
414
427
|
]);
|
|
415
428
|
const owners = ownersOf(projects);
|
|
429
|
+
if (progress) progress.accounts = Object.fromEntries(accounts.map((a) => [a, "reading"]));
|
|
416
430
|
const results = await Promise.all(accounts.map((account, n) => readOne(ctx, account, { since, sessions, projects, owners, github: n === 0 ? github : void 0, handled: handled ?? {} })));
|
|
417
431
|
const gh2 = await github;
|
|
418
432
|
if (gh2.error) notes.push(`GitHub: ${gh2.error}`);
|
|
419
433
|
if (results[0].error && gh2.items.length) notes.push("GitHub: not read");
|
|
420
434
|
const failed = results.filter((r) => r.error);
|
|
421
435
|
if (failed.length === results.length) throw new Error(failed.length === 1 ? failed[0].error : failed.map((f) => `${f.account}: ${f.error}`).join("; "));
|
|
422
|
-
|
|
436
|
+
const requested = gh2.error ? void 0 : new Set(gh2.requested ?? gh2.items.filter((e) => e.type === "review-request").map((e) => e.pr));
|
|
437
|
+
return { items: collapse(results.flatMap((r) => r.items)), problems: results.flatMap((r) => r.problems), requested };
|
|
423
438
|
}
|
|
424
439
|
async function rememberHandled(ctx, items, now) {
|
|
425
440
|
const old = await ctx.storage.get("handled") ?? {};
|
|
@@ -428,6 +443,10 @@ async function rememberHandled(ctx, items, now) {
|
|
|
428
443
|
for (const i of items) next[i.id] = i.when;
|
|
429
444
|
await ctx.storage.set("handled", next);
|
|
430
445
|
}
|
|
446
|
+
function dropStaleReviews(items, requested) {
|
|
447
|
+
if (!requested) return items;
|
|
448
|
+
return items.filter((i) => !(i.kind === "review" && i.state === "proposed" && !requested.has(githubPage(i.link) ?? i.link)));
|
|
449
|
+
}
|
|
431
450
|
function merge(existing, fresh) {
|
|
432
451
|
const byId = new Map(existing.map((i) => [i.id, i]));
|
|
433
452
|
const out = [...existing];
|
|
@@ -446,20 +465,24 @@ var reading;
|
|
|
446
465
|
var OFF_MESSAGE = "Today is off";
|
|
447
466
|
async function readNow(ctx, now) {
|
|
448
467
|
if (!await isEnabled(ctx)) throw new ModuleError("bad_request", OFF_MESSAGE);
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
468
|
+
if (!reading) {
|
|
469
|
+
progress = { startedAt: (/* @__PURE__ */ new Date()).toISOString(), accounts: {} };
|
|
470
|
+
reading = doRead(ctx, now).finally(() => {
|
|
471
|
+
reading = void 0;
|
|
472
|
+
progress = void 0;
|
|
473
|
+
});
|
|
474
|
+
}
|
|
452
475
|
return reading;
|
|
453
476
|
}
|
|
454
477
|
async function doRead(ctx, now) {
|
|
455
478
|
const date = localDate(now);
|
|
456
479
|
const notes = [];
|
|
457
480
|
try {
|
|
458
|
-
const { items: fresh, problems } = await reread(ctx, now, notes);
|
|
481
|
+
const { items: fresh, problems, requested } = await reread(ctx, now, notes);
|
|
459
482
|
const lastReadAt = await ctx.storage.get("lastReadAt");
|
|
460
483
|
await locked(async () => {
|
|
461
484
|
const prev = await loadDigest(ctx, date);
|
|
462
|
-
const items = merge(prev?.items ?? [], fresh);
|
|
485
|
+
const items = dropStaleReviews(merge(prev?.items ?? [], fresh), requested);
|
|
463
486
|
const known = new Set((prev?.items ?? []).map((i) => i.id));
|
|
464
487
|
if (items.some((i) => i.state === "proposed" && !known.has(i.id))) await ctx.storage.delete(`folded/${date}`);
|
|
465
488
|
await saveDigest(ctx, {
|
|
@@ -484,13 +507,20 @@ async function doRead(ctx, now) {
|
|
|
484
507
|
async function retryAccount(ctx, account, now) {
|
|
485
508
|
if (!await isEnabled(ctx)) throw new ModuleError("bad_request", OFF_MESSAGE);
|
|
486
509
|
if (!(await readAccounts(ctx)).includes(account)) throw new ModuleError("bad_request", `${account} is not an account Today reads`);
|
|
487
|
-
|
|
488
|
-
});
|
|
510
|
+
if (reading) throw new ModuleError("bad_request", "a reading is running");
|
|
489
511
|
const date = localDate(now);
|
|
490
512
|
const prev = await loadDigest(ctx, date);
|
|
491
513
|
if (!prev) throw new ModuleError("not_found", `no digest for ${date}`);
|
|
492
|
-
|
|
493
|
-
|
|
514
|
+
progress ??= { startedAt: (/* @__PURE__ */ new Date()).toISOString(), accounts: {} };
|
|
515
|
+
progress.accounts[account] = "reading";
|
|
516
|
+
const mine = progress;
|
|
517
|
+
let result;
|
|
518
|
+
try {
|
|
519
|
+
const [sessions, projects, handled] = await Promise.all([ctx.sessions.list(), ctx.projects.list(), ctx.storage.get("handled")]);
|
|
520
|
+
result = await readOne(ctx, account, { since: prev.since, sessions, projects, owners: ownersOf(projects), handled: handled ?? {} });
|
|
521
|
+
} finally {
|
|
522
|
+
if (progress === mine && !Object.values(mine.accounts).includes("reading")) progress = void 0;
|
|
523
|
+
}
|
|
494
524
|
await locked(async () => {
|
|
495
525
|
const digest = await loadDigest(ctx, date) ?? prev;
|
|
496
526
|
const items = merge(digest.items, result.items);
|
|
@@ -723,7 +753,8 @@ async function digestFor(ctx, date) {
|
|
|
723
753
|
if (latest) [digest, folded] = await read(wanted = latest);
|
|
724
754
|
}
|
|
725
755
|
const enabled = await isEnabled(ctx);
|
|
726
|
-
|
|
756
|
+
const reading2 = readingNow();
|
|
757
|
+
return { ...digest ? { digest, folded, enabled } : { digest: null, folded: false, enabled }, ...reading2 ? { reading: reading2 } : {} };
|
|
727
758
|
}
|
|
728
759
|
var server_default = defineModule({
|
|
729
760
|
routes: [
|
|
@@ -21,7 +21,18 @@ var failedLine = (error) => `Last reading failed: ${error}`;
|
|
|
21
21
|
var loadFailedLine = (error) => `Can't load Today: ${error}`;
|
|
22
22
|
var notesLine = (notes) => notes?.length ? notes.join(" \xB7 ") : null;
|
|
23
23
|
var SOURCE_NAME = { slack: "Slack", linear: "Linear", reader: "Reader" };
|
|
24
|
-
|
|
24
|
+
function sourcesLabel(sources) {
|
|
25
|
+
const names = ["slack", "linear", "reader"].filter((s) => sources.includes(s)).map((s) => SOURCE_NAME[s]);
|
|
26
|
+
return names.join(" and ");
|
|
27
|
+
}
|
|
28
|
+
function groupProblems(problems) {
|
|
29
|
+
const accounts = [...new Set(problems.map((p) => p.account))];
|
|
30
|
+
return accounts.map((account) => {
|
|
31
|
+
const mine = problems.filter((p) => p.account === account);
|
|
32
|
+
return { account, label: sourcesLabel(mine.map((p) => p.source)), reasons: mine.map((p) => `${SOURCE_NAME[p.source]}: ${p.reason}`) };
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
var groupLine = (g) => `${g.account} \xB7 ${g.label} did not respond`;
|
|
25
36
|
var GROUPS = [
|
|
26
37
|
{ title: "In open tasks", pick: (i) => i.kind === "to-task" },
|
|
27
38
|
{ title: "New", pick: (i) => i.kind === "issue" || i.kind === "request" },
|
|
@@ -61,6 +72,7 @@ function AccountChip({ account }) {
|
|
|
61
72
|
function useDigest(forge, path = "/digest") {
|
|
62
73
|
const [reply, setReply] = useState(null);
|
|
63
74
|
const [error, setError] = useState(null);
|
|
75
|
+
const [hurried, hurry] = useState(false);
|
|
64
76
|
const latest = useRef(0);
|
|
65
77
|
const load = useCallback(async () => {
|
|
66
78
|
const mine = ++latest.current;
|
|
@@ -73,19 +85,20 @@ function useDigest(forge, path = "/digest") {
|
|
|
73
85
|
if (mine === latest.current) setError(errorMessage(e));
|
|
74
86
|
}
|
|
75
87
|
}, [forge, path]);
|
|
88
|
+
const fast = hurried || !!reply?.reading;
|
|
76
89
|
useEffect(() => {
|
|
77
90
|
void load();
|
|
78
91
|
const poll = () => {
|
|
79
92
|
if (!document.hidden) void load();
|
|
80
93
|
};
|
|
81
|
-
const t = setInterval(poll, 6e4);
|
|
94
|
+
const t = setInterval(poll, fast ? 3e3 : 6e4);
|
|
82
95
|
document.addEventListener("visibilitychange", poll);
|
|
83
96
|
return () => {
|
|
84
97
|
clearInterval(t);
|
|
85
98
|
document.removeEventListener("visibilitychange", poll);
|
|
86
99
|
};
|
|
87
|
-
}, [load]);
|
|
88
|
-
return { reply, error, reload: load };
|
|
100
|
+
}, [load, fast]);
|
|
101
|
+
return { reply, error, reload: load, hurry };
|
|
89
102
|
}
|
|
90
103
|
function useProjects(forge) {
|
|
91
104
|
const [projects, setProjects] = useState(EMPTY_PROJECTS);
|
|
@@ -95,7 +108,8 @@ function useProjects(forge) {
|
|
|
95
108
|
}, [forge]);
|
|
96
109
|
return projects;
|
|
97
110
|
}
|
|
98
|
-
function useActing(forge, date, reload) {
|
|
111
|
+
function useActing(forge, date, reload, hurry = () => {
|
|
112
|
+
}) {
|
|
99
113
|
const [busy, setBusy] = useState(false);
|
|
100
114
|
const [refreshing, setRefreshing] = useState(false);
|
|
101
115
|
const [retrying, setRetrying] = useState(null);
|
|
@@ -121,7 +135,9 @@ function useActing(forge, date, reload) {
|
|
|
121
135
|
if (reading.current) return;
|
|
122
136
|
reading.current = true;
|
|
123
137
|
setRefreshing(true);
|
|
138
|
+
hurry(true);
|
|
124
139
|
await guarded(() => forge.action("refresh"));
|
|
140
|
+
hurry(false);
|
|
125
141
|
reading.current = false;
|
|
126
142
|
setRefreshing(false);
|
|
127
143
|
};
|
|
@@ -129,7 +145,9 @@ function useActing(forge, date, reload) {
|
|
|
129
145
|
if (busy) return;
|
|
130
146
|
setBusy(true);
|
|
131
147
|
setRetrying(account);
|
|
148
|
+
hurry(true);
|
|
132
149
|
await guarded(() => forge.action("retry-account", { account }));
|
|
150
|
+
hurry(false);
|
|
133
151
|
setRetrying(null);
|
|
134
152
|
setBusy(false);
|
|
135
153
|
};
|
|
@@ -289,15 +307,58 @@ var Row = ({ item, projects = EMPTY_PROJECTS, acting, forge }) => {
|
|
|
289
307
|
] })
|
|
290
308
|
] });
|
|
291
309
|
};
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
310
|
+
var READING_CSS = `
|
|
311
|
+
@keyframes today-spin { to { transform: rotate(360deg) } }
|
|
312
|
+
@keyframes today-pulse { 0%, 100% { opacity: .55 } 50% { opacity: 1 } }
|
|
313
|
+
.today-spin { animation: today-spin .8s linear infinite }
|
|
314
|
+
.today-pulse { animation: today-pulse 1.4s ease-in-out infinite }
|
|
315
|
+
@media (prefers-reduced-motion: reduce) { .today-spin, .today-pulse { animation: none } }`;
|
|
316
|
+
function useReadingStyles() {
|
|
317
|
+
if (typeof document !== "undefined" && !document.getElementById("today-reading-css")) {
|
|
318
|
+
const el = document.createElement("style");
|
|
319
|
+
el.id = "today-reading-css";
|
|
320
|
+
el.textContent = READING_CSS;
|
|
321
|
+
document.head.appendChild(el);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
function Spinner() {
|
|
325
|
+
return /* @__PURE__ */ jsx("i", { class: "today-spin", style: { display: "inline-block", width: "10px", height: "10px", borderRadius: "50%", border: "2px solid var(--hair-2)", borderTopColor: "var(--blue)", boxSizing: "border-box" } });
|
|
326
|
+
}
|
|
327
|
+
function ReadingLine({ reading }) {
|
|
328
|
+
useReadingStyles();
|
|
329
|
+
const accounts = Object.entries(reading?.accounts ?? {});
|
|
330
|
+
return /* @__PURE__ */ jsxs("span", { role: "status", "aria-live": "polite", style: { display: "inline-flex", alignItems: "center", gap: "6px", fontSize: "12px", color: "var(--ink-2)", flexWrap: "wrap" }, children: [
|
|
331
|
+
/* @__PURE__ */ jsx("b", { class: "today-pulse", style: { fontWeight: 600, color: "var(--ink)" }, children: accounts.length ? "Reading" : "Reading\u2026" }),
|
|
332
|
+
accounts.map(([account, state], n) => /* @__PURE__ */ jsxs("span", { style: { display: "inline-flex", alignItems: "center", gap: "5px" }, children: [
|
|
333
|
+
n > 0 && /* @__PURE__ */ jsx("span", { style: { color: "var(--ink-3)" }, children: "\xB7" }),
|
|
334
|
+
state === "reading" ? /* @__PURE__ */ jsx(Spinner, {}) : state === "done" ? /* @__PURE__ */ jsx("span", { style: { color: "var(--green)" }, children: "\u2713" }) : /* @__PURE__ */ jsx("span", { style: { color: "var(--orange)" }, children: "\u26A0" }),
|
|
335
|
+
account
|
|
336
|
+
] }, account)),
|
|
337
|
+
accounts.length > 0 && /* @__PURE__ */ jsx("span", { children: "\u2026" })
|
|
338
|
+
] });
|
|
339
|
+
}
|
|
340
|
+
function SkeletonRows() {
|
|
341
|
+
useReadingStyles();
|
|
342
|
+
return /* @__PURE__ */ jsx("div", { "aria-hidden": "true", style: { display: "flex", flexDirection: "column", gap: "6px" }, children: [0, 1, 2].map((n) => /* @__PURE__ */ jsxs("div", { class: "today-pulse", style: { display: "flex", alignItems: "center", gap: "12px", padding: "10px 12px", borderRadius: "10px", background: "var(--elev)", border: "1px solid var(--hair)", animationDelay: `${n * 0.15}s` }, children: [
|
|
343
|
+
/* @__PURE__ */ jsx("div", { style: { width: "30px", height: "30px", borderRadius: "8px", background: "var(--hair)" } }),
|
|
344
|
+
/* @__PURE__ */ jsxs("div", { style: { flex: 1, display: "flex", flexDirection: "column", gap: "6px" }, children: [
|
|
345
|
+
/* @__PURE__ */ jsx("div", { style: { height: "9px", width: `${70 - n * 12}%`, borderRadius: "5px", background: "var(--hair)" } }),
|
|
346
|
+
/* @__PURE__ */ jsx("div", { style: { height: "8px", width: "35%", borderRadius: "5px", background: "var(--hair)" } })
|
|
300
347
|
] })
|
|
348
|
+
] }, n)) });
|
|
349
|
+
}
|
|
350
|
+
function ProblemRow({ group, acting, details = false }) {
|
|
351
|
+
const mine = acting.retrying === group.account;
|
|
352
|
+
return /* @__PURE__ */ jsxs("div", { role: "alert", title: group.reasons.join("\n"), style: { padding: "7px 10px", borderRadius: "10px", fontSize: "12px", color: "var(--ink-2)", background: soft("--orange", 10), border: `1px solid ${soft("--orange", 35)}` }, children: [
|
|
353
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "10px" }, children: [
|
|
354
|
+
/* @__PURE__ */ jsx("span", { style: { color: "var(--orange)" }, children: "\u26A0" }),
|
|
355
|
+
/* @__PURE__ */ jsx("span", { style: { minWidth: 0, overflowWrap: "anywhere" }, children: groupLine(group) }),
|
|
356
|
+
/* @__PURE__ */ jsxs("span", { style: { marginLeft: "auto", display: "flex", gap: "8px", flexShrink: 0 }, children: [
|
|
357
|
+
/* @__PURE__ */ jsx(Btn, { label: mine ? "Reading\u2026" : "Retry", disabled: acting.busy, onClick: () => acting.retry(group.account) }),
|
|
358
|
+
/* @__PURE__ */ jsx(Btn, { label: "Reconnect", style: ghostStyle, disabled: acting.busy, onClick: () => acting.reconnect(group.account) })
|
|
359
|
+
] })
|
|
360
|
+
] }),
|
|
361
|
+
details && /* @__PURE__ */ jsx("ul", { style: { margin: "6px 0 0 22px", padding: 0, color: "var(--ink-3)", fontSize: "11.5px" }, children: group.reasons.map((r) => /* @__PURE__ */ jsx("li", { children: r }, r)) })
|
|
301
362
|
] });
|
|
302
363
|
}
|
|
303
364
|
|
|
@@ -306,10 +367,14 @@ import { jsx as jsx2, jsxs as jsxs2 } from "preact/jsx-runtime";
|
|
|
306
367
|
function View({ forge }) {
|
|
307
368
|
const [days, setDays] = useState2([]);
|
|
308
369
|
const [day, setDay] = useState2(null);
|
|
309
|
-
const { reply, error, reload } = useDigest(forge, day ? `/digest/${day}` : "/digest");
|
|
370
|
+
const { reply, error, reload, hurry } = useDigest(forge, day ? `/digest/${day}` : "/digest");
|
|
310
371
|
const projects = useProjects(forge);
|
|
311
372
|
const digest = reply?.digest;
|
|
312
|
-
const acting = useActing(forge, digest?.date, reload);
|
|
373
|
+
const acting = useActing(forge, digest?.date, reload, hurry);
|
|
374
|
+
const reading = reply?.reading;
|
|
375
|
+
const isReading = acting.refreshing || !!reading;
|
|
376
|
+
const [details, setDetails] = useState2(false);
|
|
377
|
+
const problems = groupProblems(digest?.problems ?? []);
|
|
313
378
|
const notes = notesLine(digest?.notes);
|
|
314
379
|
const enabled = reply?.enabled === true;
|
|
315
380
|
useEffect2(() => {
|
|
@@ -320,17 +385,20 @@ function View({ forge }) {
|
|
|
320
385
|
/* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", gap: "12px", flexWrap: "wrap" }, children: [
|
|
321
386
|
days.length > 0 && /* @__PURE__ */ jsx2("select", { "aria-label": "Day", value: digest?.date ?? "", onChange: (e) => setDay(e.target.value), style: { font: "inherit", fontSize: "12.5px", padding: "5px 8px", borderRadius: "8px", border: "1px solid var(--hair-2)", background: "var(--card)", color: "var(--ink)" }, children: days.map((d) => /* @__PURE__ */ jsx2("option", { value: d, children: d }, d)) }),
|
|
322
387
|
digest && /* @__PURE__ */ jsx2("b", { style: { fontSize: "13px", fontWeight: 600 }, children: dayLabel(/* @__PURE__ */ new Date(), digest.date) }),
|
|
323
|
-
/* @__PURE__ */ jsx2("span", { style: { fontSize: "12px", color: "var(--ink-2)" }, children: digest ? readLine(digest) : "Not read yet" }),
|
|
388
|
+
isReading ? /* @__PURE__ */ jsx2(ReadingLine, { reading }) : /* @__PURE__ */ jsx2("span", { style: { fontSize: "12px", color: "var(--ink-2)" }, children: digest ? readLine(digest) : "Not read yet" }),
|
|
324
389
|
/* @__PURE__ */ jsxs2("span", { style: { marginLeft: "auto", display: "flex", gap: "8px" }, children: [
|
|
325
|
-
enabled && /* @__PURE__ */ jsx2(ActionButton, { label: "Read now", variant: "primary", size: "sm", loading:
|
|
390
|
+
enabled && /* @__PURE__ */ jsx2(ActionButton, { label: isReading ? "Reading\u2026" : "Read now", variant: "primary", size: "sm", disabled: isReading, loading: isReading, onClick: acting.refresh }),
|
|
326
391
|
reply && /* @__PURE__ */ jsx2(ActionButton, { label: enabled ? "Turn off" : "Turn on", variant: enabled ? "secondary" : "primary", size: "sm", disabled: acting.busy, onClick: () => acting.run(() => forge.action(enabled ? "disable" : "enable")) })
|
|
327
392
|
] })
|
|
328
393
|
] }),
|
|
329
394
|
reply && !enabled && /* @__PURE__ */ jsx2("div", { style: { padding: "12px 14px", borderRadius: "10px", fontSize: "12.5px", lineHeight: 1.5, color: "var(--ink-2)", background: "var(--card)", border: "1px solid var(--hair)", maxWidth: "640px" }, children: "Today is off. Turned on, it reads your Linear, Slack and GitHub each morning and whenever you press Read now. Each reading spends your account's usage. Research it proposes can start sessions on its own, a few a day." }),
|
|
330
395
|
(error || digest?.error) && /* @__PURE__ */ jsx2("div", { style: { padding: "10px 12px", borderRadius: "10px", fontSize: "12px", color: "var(--red)", background: "var(--card)", border: "1px solid color-mix(in srgb, var(--red) 45%, var(--hair))" }, children: error ? loadFailedLine(error) : failedLine(digest.error) }),
|
|
331
|
-
|
|
396
|
+
problems.length > 0 && /* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexDirection: "column", gap: "6px" }, children: [
|
|
397
|
+
problems.map((g) => /* @__PURE__ */ jsx2(ProblemRow, { group: g, acting, details }, g.account)),
|
|
398
|
+
/* @__PURE__ */ jsx2("button", { type: "button", "aria-expanded": details, onClick: () => setDetails(!details), style: { alignSelf: "flex-start", font: "inherit", fontSize: "11.5px", padding: 0, border: 0, background: "none", cursor: "pointer", color: "var(--ink-3)" }, children: details ? "Hide details" : "Details" })
|
|
399
|
+
] }),
|
|
332
400
|
notes && /* @__PURE__ */ jsx2("div", { style: { fontSize: "12px", color: "var(--ink-3)" }, children: notes }),
|
|
333
|
-
!digest || digest.items.length === 0 ? /* @__PURE__ */ jsx2(EmptyState, { title: "Nothing to show", description: enabled ? "Today reads your Linear, Slack and GitHub once a day. Use Read now to read them now." : "Turn Today on to read your Linear, Slack and GitHub." }) : byAccount(digest.items).map(({ account, sections: sections2 }) => /* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexDirection: "column", gap: "16px" }, children: [
|
|
401
|
+
!digest && isReading ? /* @__PURE__ */ jsx2(SkeletonRows, {}) : !digest || digest.items.length === 0 ? /* @__PURE__ */ jsx2(EmptyState, { title: "Nothing to show", description: enabled ? "Today reads your Linear, Slack and GitHub once a day. Use Read now to read them now." : "Turn Today on to read your Linear, Slack and GitHub." }) : byAccount(digest.items).map(({ account, sections: sections2 }) => /* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexDirection: "column", gap: "16px" }, children: [
|
|
334
402
|
account && /* @__PURE__ */ jsx2("div", { children: /* @__PURE__ */ jsx2(AccountChip, { account }) }),
|
|
335
403
|
sections2.map(({ title, items }) => /* @__PURE__ */ jsxs2("section", { style: { display: "flex", flexDirection: "column", gap: "6px" }, children: [
|
|
336
404
|
/* @__PURE__ */ jsxs2("h4", { style: { margin: "4px 0", fontSize: "11px", fontWeight: 600, letterSpacing: ".06em", textTransform: "uppercase", color: "var(--ink-3)" }, children: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "forge-cw",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.27",
|
|
4
4
|
"description": "A visual dashboard for your coding agents on Claude Code, Codex, Pi or OpenCode. Installs CW for you.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"@types/node": "^22.0.0",
|
|
41
41
|
"esbuild": "^0.25.0",
|
|
42
42
|
"typescript": "^5.8.0",
|
|
43
|
-
"@forge-dev/
|
|
44
|
-
"@forge-dev/
|
|
43
|
+
"@forge-dev/console": "0.1.0",
|
|
44
|
+
"@forge-dev/core": "0.1.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "tsc",
|