forge-cw 0.1.26 → 0.1.28
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};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/banner.tsx
|
|
2
|
+
import { useState as useState2 } from "preact/hooks";
|
|
2
3
|
import { definePanel } from "@forge-dev/sdk";
|
|
3
4
|
|
|
4
5
|
// src/ops.ts
|
|
@@ -33,6 +34,20 @@ function groupProblems(problems) {
|
|
|
33
34
|
var groupLine = (g) => `${g.account} \xB7 ${g.label} did not respond`;
|
|
34
35
|
var problemsLabel = (n) => `\u26A0 ${n} account problem${n === 1 ? "" : "s"}`;
|
|
35
36
|
var accountsOf = (items) => [...new Set(items.flatMap((i) => i.account ? [i.account] : []))];
|
|
37
|
+
function titleFor(i) {
|
|
38
|
+
if (!i.issueKey) return i.title;
|
|
39
|
+
const key = i.issueKey.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
40
|
+
const rest = i.title.replace(new RegExp(`^\\s*\\[?${key}\\]?\\s*[:\\-\u2013\u2014]?\\s*`, "i"), "");
|
|
41
|
+
return rest.trim() ? rest : i.title;
|
|
42
|
+
}
|
|
43
|
+
var SOURCE_NAMES = { linear: "Linear", slack: "Slack", github: "GitHub" };
|
|
44
|
+
function whoOf(i) {
|
|
45
|
+
const who = i.who.trim();
|
|
46
|
+
return !who || who.toLowerCase() === SOURCE_NAMES[i.source].toLowerCase() ? null : who;
|
|
47
|
+
}
|
|
48
|
+
var pendingLabel = (p) => p.kind === "ci" ? "CI failing" : p.kind === "review" ? "Review requested" : p.source === "linear" ? p.started ? "In progress" : "To do" : "Assigned";
|
|
49
|
+
var pendingIn = (items, account) => account ? items.filter((p) => p.account === account) : items;
|
|
50
|
+
var FIRST_READING_NOTE = "First reading \u2014 what you have open is under Pending.";
|
|
36
51
|
|
|
37
52
|
// src/rows.tsx
|
|
38
53
|
import { useCallback, useEffect, useRef, useState } from "preact/hooks";
|
|
@@ -131,6 +146,12 @@ function useActing(forge, date, reload, hurry = () => {
|
|
|
131
146
|
const act = (item, op, project) => run(async () => {
|
|
132
147
|
if (date) await forge.action(op, { date, id: item.id, ...project ? { project } : {} });
|
|
133
148
|
});
|
|
149
|
+
const startPending = (item, project) => run(async () => {
|
|
150
|
+
await forge.action("pending-start", { id: item.id, ...project ? { project } : {} });
|
|
151
|
+
});
|
|
152
|
+
const hidePending = (item) => run(async () => {
|
|
153
|
+
await forge.action("pending-hide", { id: item.id });
|
|
154
|
+
});
|
|
134
155
|
const refresh = async () => {
|
|
135
156
|
if (reading.current) return;
|
|
136
157
|
reading.current = true;
|
|
@@ -155,7 +176,7 @@ function useActing(forge, date, reload, hurry = () => {
|
|
|
155
176
|
const s = await forge.action("reconnect", { account });
|
|
156
177
|
if (s) forge.openSession(s.project, s.sessionDir);
|
|
157
178
|
});
|
|
158
|
-
return { busy, refreshing, retrying, retry, reconnect, run, act, refresh };
|
|
179
|
+
return { busy, refreshing, retrying, retry, reconnect, run, act, refresh, startPending, hidePending };
|
|
159
180
|
}
|
|
160
181
|
function dayOf(date) {
|
|
161
182
|
const [y, m, d] = date.split("-").map(Number);
|
|
@@ -174,12 +195,14 @@ function foldedNow(folded, items) {
|
|
|
174
195
|
return folded || !items.some((i) => i.state === "proposed" || i.state === "failed");
|
|
175
196
|
}
|
|
176
197
|
var clock = (d) => d.toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit" });
|
|
198
|
+
function windowTime(at, read) {
|
|
199
|
+
if (at.toDateString() === read.toDateString()) return clock(at);
|
|
200
|
+
const yesterday = new Date(read.getTime() - 864e5).toDateString() === at.toDateString();
|
|
201
|
+
return `${yesterday ? "yesterday" : at.toLocaleDateString("en-US", { month: "short", day: "numeric" })} ${clock(at)}`;
|
|
202
|
+
}
|
|
177
203
|
function readLine(d) {
|
|
178
204
|
const read = new Date(d.readAt);
|
|
179
|
-
|
|
180
|
-
const same = read.toDateString() === since.toDateString();
|
|
181
|
-
const day = new Date(read.getTime() - 864e5).toDateString() === since.toDateString() ? "yesterday " : `${since.toLocaleDateString("en-US", { month: "short", day: "numeric" })} `;
|
|
182
|
-
return `Read at ${clock(read)} \xB7 Linear, Slack and GitHub since ${same ? "" : day}${clock(since)}`;
|
|
205
|
+
return `Read at ${clock(read)} \xB7 changes since ${windowTime(new Date(d.windowStart ?? d.since), read)}`;
|
|
183
206
|
}
|
|
184
207
|
function ago(iso, now = /* @__PURE__ */ new Date()) {
|
|
185
208
|
const t = new Date(iso);
|
|
@@ -255,17 +278,17 @@ var Row = ({ item, projects = EMPTY_PROJECTS, acting, forge }) => {
|
|
|
255
278
|
/* @__PURE__ */ jsxs("div", { style: { minWidth: 0 }, children: [
|
|
256
279
|
/* @__PURE__ */ jsxs("div", { style: { fontWeight: 560, fontSize: "13px", display: "flex", alignItems: "center", gap: "8px", minWidth: 0 }, children: [
|
|
257
280
|
item.issueKey && /* @__PURE__ */ jsx("span", { style: { fontFamily: "var(--mono, ui-monospace, monospace)", fontSize: "11.5px", color: "var(--ink-2)", fontWeight: 500 }, children: item.issueKey }),
|
|
258
|
-
/* @__PURE__ */ jsx("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: item
|
|
281
|
+
/* @__PURE__ */ jsx("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: titleFor(item) })
|
|
259
282
|
] }),
|
|
260
283
|
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "6px", marginTop: "3px", fontSize: "11.5px", color: "var(--ink-2)", flexWrap: "wrap" }, children: [
|
|
261
|
-
/* @__PURE__ */ jsx(Avatar, { who: item.who }),
|
|
262
|
-
/* @__PURE__ */
|
|
284
|
+
whoOf(item) && /* @__PURE__ */ jsx(Avatar, { who: item.who }),
|
|
285
|
+
/* @__PURE__ */ jsx("span", { children: whoOf(item) ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
263
286
|
item.who,
|
|
264
287
|
" ",
|
|
265
288
|
where,
|
|
266
289
|
" ",
|
|
267
290
|
strong(item.where)
|
|
268
|
-
] }),
|
|
291
|
+
] }) : strong(item.where) }),
|
|
269
292
|
/* @__PURE__ */ jsx(Sep, {}),
|
|
270
293
|
/* @__PURE__ */ jsx("span", { children: ago(item.when) }),
|
|
271
294
|
item.account && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -311,6 +334,55 @@ var Row = ({ item, projects = EMPTY_PROJECTS, acting, forge }) => {
|
|
|
311
334
|
] })
|
|
312
335
|
] });
|
|
313
336
|
};
|
|
337
|
+
var PENDING_TOKEN = { ci: "--red", review: "--blue", issue: "--green" };
|
|
338
|
+
var PendingRow = ({ item, projects = EMPTY_PROJECTS, acting, forge, compact }) => {
|
|
339
|
+
const [project, setProject] = useState(item.project ?? "");
|
|
340
|
+
const token = PENDING_TOKEN[item.kind];
|
|
341
|
+
const target = item.project ?? project;
|
|
342
|
+
return /* @__PURE__ */ jsxs("div", { style: { display: "grid", gridTemplateColumns: "30px 1fr auto", gap: "12px", alignItems: "center", padding: compact ? "7px 10px" : "10px 12px", borderRadius: "11px", background: soft("--ink", 3), border: "1px solid var(--hair)" }, children: [
|
|
343
|
+
/* @__PURE__ */ jsx(SourceIcon, { source: item.source }),
|
|
344
|
+
/* @__PURE__ */ jsxs("div", { style: { minWidth: 0 }, children: [
|
|
345
|
+
/* @__PURE__ */ jsxs("div", { style: { fontWeight: 560, fontSize: "13px", display: "flex", alignItems: "center", gap: "8px", minWidth: 0 }, children: [
|
|
346
|
+
item.issueKey && /* @__PURE__ */ jsx("span", { style: { fontFamily: "var(--mono, ui-monospace, monospace)", fontSize: "11.5px", color: "var(--ink-2)", fontWeight: 500 }, children: item.issueKey }),
|
|
347
|
+
/* @__PURE__ */ jsx("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: titleFor(item) })
|
|
348
|
+
] }),
|
|
349
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "6px", marginTop: "3px", fontSize: "11.5px", color: "var(--ink-2)", flexWrap: "wrap" }, children: [
|
|
350
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
351
|
+
item.repo ? strong(item.repo) : null,
|
|
352
|
+
item.repo && item.state ? " \xB7 " : "",
|
|
353
|
+
item.state
|
|
354
|
+
] }),
|
|
355
|
+
(item.repo || item.state) && /* @__PURE__ */ jsx(Sep, {}),
|
|
356
|
+
/* @__PURE__ */ jsx("span", { children: ago(item.when) }),
|
|
357
|
+
item.account && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
358
|
+
/* @__PURE__ */ jsx(Sep, {}),
|
|
359
|
+
/* @__PURE__ */ jsx(AccountChip, { account: item.account })
|
|
360
|
+
] }),
|
|
361
|
+
/* @__PURE__ */ jsx(Sep, {}),
|
|
362
|
+
/* @__PURE__ */ jsxs("a", { href: item.link, target: "_blank", rel: "noopener noreferrer", style: { color: "var(--ink-2)", textDecoration: "none", borderBottom: "1px dotted var(--ink-3)" }, children: [
|
|
363
|
+
"View in ",
|
|
364
|
+
SOURCE_LABEL[item.source],
|
|
365
|
+
" \u2197"
|
|
366
|
+
] }),
|
|
367
|
+
item.project && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
368
|
+
/* @__PURE__ */ jsx(Sep, {}),
|
|
369
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
370
|
+
"project ",
|
|
371
|
+
strong(item.project)
|
|
372
|
+
] })
|
|
373
|
+
] })
|
|
374
|
+
] })
|
|
375
|
+
] }),
|
|
376
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
|
|
377
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: "10.5px", fontWeight: 600, padding: "2px 7px", borderRadius: "6px", whiteSpace: "nowrap", color: `var(${token})`, background: soft(token, 15) }, children: pendingLabel(item) }),
|
|
378
|
+
item.targetSession ? /* @__PURE__ */ jsx(Btn, { label: "Open task", onClick: () => forge.openSession(item.targetSession.project, item.targetSession.sessionDir) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
379
|
+
!item.project && /* @__PURE__ */ jsx(ProjectPicker, { projects: projectsFor(projects, item.account), value: project, onChange: setProject }),
|
|
380
|
+
/* @__PURE__ */ jsx(Btn, { label: item.kind === "review" ? "Review" : "Start", disabled: acting.busy || !target, onClick: () => acting.startPending(item, item.project ? void 0 : project) })
|
|
381
|
+
] }),
|
|
382
|
+
/* @__PURE__ */ jsx(Btn, { label: "Hide", style: ghostStyle, disabled: acting.busy, onClick: () => acting.hidePending(item) })
|
|
383
|
+
] })
|
|
384
|
+
] });
|
|
385
|
+
};
|
|
314
386
|
var READING_CSS = `
|
|
315
387
|
@keyframes today-spin { to { transform: rotate(360deg) } }
|
|
316
388
|
@keyframes today-pulse { 0%, 100% { opacity: .55 } 50% { opacity: 1 } }
|
|
@@ -392,13 +464,32 @@ var done = (items, pick) => items.filter((i) => i.state === "done" && pick(i.kin
|
|
|
392
464
|
function shell(children) {
|
|
393
465
|
return /* @__PURE__ */ jsx2("div", { style: { position: "relative", borderRadius: "16px", padding: "1px", background: `linear-gradient(135deg, ${soft("--blue", 55)}, ${soft("--purple", 40)} 45%, var(--hair) 80%)`, boxShadow: `0 10px 40px ${soft("--blue", 10)}` }, children: /* @__PURE__ */ jsx2("div", { style: { borderRadius: "15px", background: "radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--blue) 14%, var(--card)) 0%, var(--card) 55%)" }, children }) });
|
|
394
466
|
}
|
|
395
|
-
|
|
467
|
+
var PENDING_SHOWN = 5;
|
|
468
|
+
function PendingFold({ pending, projects, acting, forge }) {
|
|
469
|
+
const [open, setOpen] = useState2(false);
|
|
470
|
+
if (pending.length === 0) return null;
|
|
471
|
+
return /* @__PURE__ */ jsxs2("div", { style: { marginTop: "10px" }, children: [
|
|
472
|
+
/* @__PURE__ */ jsxs2("button", { type: "button", "aria-expanded": open, onClick: () => setOpen(!open), style: { font: "inherit", fontSize: "12px", fontWeight: 600, padding: 0, border: 0, background: "none", cursor: "pointer", color: "var(--ink-2)" }, children: [
|
|
473
|
+
open ? "\u25BE" : "\u25B8",
|
|
474
|
+
" Pending \xB7 ",
|
|
475
|
+
pending.length
|
|
476
|
+
] }),
|
|
477
|
+
open && /* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexDirection: "column", gap: "6px", marginTop: "8px" }, children: [
|
|
478
|
+
pending.slice(0, PENDING_SHOWN).map((p) => /* @__PURE__ */ jsx2(PendingRow, { item: p, projects, acting, forge, compact: true }, p.id)),
|
|
479
|
+
/* @__PURE__ */ jsx2("div", { children: /* @__PURE__ */ jsx2(Btn, { label: "See all \u2192", style: ghostStyle, onClick: () => forge.openPage() }) })
|
|
480
|
+
] })
|
|
481
|
+
] });
|
|
482
|
+
}
|
|
483
|
+
function Strip({ title, children, actions, below }) {
|
|
396
484
|
return shell(
|
|
397
|
-
/* @__PURE__ */ jsxs2(
|
|
398
|
-
/* @__PURE__ */
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
485
|
+
/* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
486
|
+
/* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", gap: "10px", padding: "9px 16px", fontSize: "12.5px", color: "var(--ink-2)" }, children: [
|
|
487
|
+
/* @__PURE__ */ jsx2("span", { style: { color: "var(--orange)" }, children: "\u2600\uFE0E" }),
|
|
488
|
+
/* @__PURE__ */ jsx2("b", { style: { color: "var(--ink)", fontWeight: 600 }, children: title }),
|
|
489
|
+
children,
|
|
490
|
+
/* @__PURE__ */ jsx2("span", { style: { marginLeft: "auto", display: "flex", gap: "8px" }, children: actions })
|
|
491
|
+
] }),
|
|
492
|
+
below && /* @__PURE__ */ jsx2("div", { style: { padding: "0 16px 10px" }, children: below })
|
|
402
493
|
] })
|
|
403
494
|
);
|
|
404
495
|
}
|
|
@@ -407,6 +498,8 @@ function Banner({ forge }) {
|
|
|
407
498
|
const projects = useProjects(forge);
|
|
408
499
|
const [chosen, choose] = useAccountFilter();
|
|
409
500
|
const digest = reply?.digest;
|
|
501
|
+
const allPending = reply?.pending ?? [];
|
|
502
|
+
const pendingText = (list) => list.length ? ` \xB7 ${list.length} pending` : "";
|
|
410
503
|
const acting = useActing(forge, digest?.date, reload, hurry);
|
|
411
504
|
const reading = reply?.reading;
|
|
412
505
|
const isReading = acting.refreshing || !!reading;
|
|
@@ -444,10 +537,11 @@ function Banner({ forge }) {
|
|
|
444
537
|
);
|
|
445
538
|
}
|
|
446
539
|
if (!reply || !digest || digest.items.length === 0) {
|
|
447
|
-
return /* @__PURE__ */ jsxs2(Strip, { title: reply && !digest ? "Not read yet" : shortDay(/* @__PURE__ */ new Date(), digest?.date), actions: refreshBtn, children: [
|
|
540
|
+
return /* @__PURE__ */ jsxs2(Strip, { title: reply && !digest ? "Not read yet" : shortDay(/* @__PURE__ */ new Date(), digest?.date), actions: refreshBtn, below: reply && /* @__PURE__ */ jsx2(PendingFold, { pending: allPending, projects, acting, forge }), children: [
|
|
448
541
|
!reply ? failure(loadFailedLine(error)) : digest?.error ? failure(failedLine(digest.error)) : digest && /* @__PURE__ */ jsxs2("span", { children: [
|
|
449
|
-
"\xB7
|
|
450
|
-
clock(new Date(digest.readAt))
|
|
542
|
+
"\xB7 ",
|
|
543
|
+
reply.firstReading ? FIRST_READING_NOTE : `nothing new since ${clock(new Date(digest.readAt))}`,
|
|
544
|
+
pendingText(allPending)
|
|
451
545
|
] }),
|
|
452
546
|
problemsLink,
|
|
453
547
|
note
|
|
@@ -464,7 +558,7 @@ function Banner({ forge }) {
|
|
|
464
558
|
return /* @__PURE__ */ jsxs2(Strip, { title: shortDay(/* @__PURE__ */ new Date(), digest.date), actions: /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
465
559
|
refreshBtn,
|
|
466
560
|
/* @__PURE__ */ jsx2(Btn, { label: "See all \u2192", style: ghostStyle, onClick: () => forge.openPage() })
|
|
467
|
-
] }), children: [
|
|
561
|
+
] }), below: /* @__PURE__ */ jsx2(PendingFold, { pending: pendingIn(allPending, account), projects, acting, forge }), children: [
|
|
468
562
|
/* @__PURE__ */ jsxs2("span", { children: [
|
|
469
563
|
"\xB7 ",
|
|
470
564
|
done(items, startsTask),
|
|
@@ -472,7 +566,8 @@ function Banner({ forge }) {
|
|
|
472
566
|
done(items, (k) => k === "research"),
|
|
473
567
|
" researching \xB7 ",
|
|
474
568
|
done(items, (k) => k === "to-task"),
|
|
475
|
-
" sent"
|
|
569
|
+
" sent",
|
|
570
|
+
pendingText(pendingIn(allPending, account))
|
|
476
571
|
] }),
|
|
477
572
|
digest.error && failure(failedLine(digest.error)),
|
|
478
573
|
problemsLink,
|
|
@@ -516,6 +611,7 @@ function Banner({ forge }) {
|
|
|
516
611
|
notes && /* @__PURE__ */ jsx2("div", { style: { marginBottom: "8px", fontSize: "11.5px", color: "var(--ink-3)" }, children: notes }),
|
|
517
612
|
problemRows,
|
|
518
613
|
/* @__PURE__ */ jsx2("div", { style: { display: "flex", flexDirection: "column", gap: "6px" }, children: shown.map((i) => /* @__PURE__ */ jsx2(Row, { item: i, projects, acting, forge }, i.id)) }),
|
|
614
|
+
/* @__PURE__ */ jsx2(PendingFold, { pending: pendingIn(allPending, account), projects, acting, forge }),
|
|
519
615
|
/* @__PURE__ */ jsx2("div", { style: { marginTop: "10px", fontSize: "11.5px", color: "var(--ink-3)" }, children: "Research starts on its own (limited per day). The rest waits for your ok." })
|
|
520
616
|
] })
|
|
521
617
|
);
|
|
@@ -168,6 +168,62 @@ function shouldRead(now, time, lastReadAt) {
|
|
|
168
168
|
function pendingCount(d) {
|
|
169
169
|
return d.items.filter((i) => i.state === "proposed").length;
|
|
170
170
|
}
|
|
171
|
+
var PENDING_MAX_AGE = 30 * 24 * 60 * 60 * 1e3;
|
|
172
|
+
var isRecent = (when, now) => {
|
|
173
|
+
const t = Date.parse(when);
|
|
174
|
+
return !Number.isNaN(t) && now.getTime() - t <= PENDING_MAX_AGE;
|
|
175
|
+
};
|
|
176
|
+
function pendingId(source, kind, link, account) {
|
|
177
|
+
return createHash("sha1").update(`pending
|
|
178
|
+
${source}
|
|
179
|
+
${kind}
|
|
180
|
+
${link}
|
|
181
|
+
${account ?? ""}`).digest("hex").slice(0, 16);
|
|
182
|
+
}
|
|
183
|
+
var rank = (p) => p.kind === "ci" ? 0 : p.kind === "review" ? 1 : p.source === "linear" ? p.started ? 2 : 3 : 4;
|
|
184
|
+
var sortPending = (items) => [...items].sort((a, b) => rank(a) - rank(b) || Date.parse(b.when) - Date.parse(a.when));
|
|
185
|
+
function parseReaderPending(out, known, now) {
|
|
186
|
+
let root;
|
|
187
|
+
try {
|
|
188
|
+
root = extractJson(out);
|
|
189
|
+
} catch {
|
|
190
|
+
return void 0;
|
|
191
|
+
}
|
|
192
|
+
if (!isRecord(root) || !Array.isArray(root.pending)) return void 0;
|
|
193
|
+
const seen = /* @__PURE__ */ new Set();
|
|
194
|
+
const list = [];
|
|
195
|
+
for (const raw of root.pending) {
|
|
196
|
+
if (!isRecord(raw)) continue;
|
|
197
|
+
const str = (k) => typeof raw[k] === "string" && raw[k].trim() ? raw[k] : void 0;
|
|
198
|
+
const link = str("link");
|
|
199
|
+
const title = str("title");
|
|
200
|
+
const when = str("when");
|
|
201
|
+
if (!link || !title || !when || !isRecent(when, now)) continue;
|
|
202
|
+
let url;
|
|
203
|
+
try {
|
|
204
|
+
url = new URL(link);
|
|
205
|
+
} catch {
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
if (url.protocol !== "http:" && url.protocol !== "https:" || /(^|\.)github\.com$/i.test(url.hostname)) continue;
|
|
209
|
+
const id = pendingId("linear", "issue", link, known.account);
|
|
210
|
+
if (seen.has(id)) continue;
|
|
211
|
+
seen.add(id);
|
|
212
|
+
const item = { id, source: "linear", kind: "issue", title, link, when };
|
|
213
|
+
if (known.account) item.account = known.account;
|
|
214
|
+
const state = str("state");
|
|
215
|
+
if (state) item.state = state.slice(0, 40);
|
|
216
|
+
if (raw.started === true) item.started = true;
|
|
217
|
+
const key = str("issueKey");
|
|
218
|
+
if (key) item.issueKey = key;
|
|
219
|
+
const project = str("project");
|
|
220
|
+
if (project && known.projects.includes(project)) item.project = project;
|
|
221
|
+
const t = raw.targetSession;
|
|
222
|
+
if (isRecord(t) && typeof t.project === "string" && typeof t.sessionDir === "string" && known.sessions.includes(`${t.project}::${t.sessionDir}`)) item.targetSession = { project: t.project, sessionDir: t.sessionDir };
|
|
223
|
+
list.push(item);
|
|
224
|
+
}
|
|
225
|
+
return list;
|
|
226
|
+
}
|
|
171
227
|
|
|
172
228
|
// src/run.ts
|
|
173
229
|
import { homedir } from "node:os";
|
|
@@ -213,9 +269,11 @@ Item kinds (to-task | issue | request | research | review), exactly one per item
|
|
|
213
269
|
- review: a GitHub review-request event, a pull request someone asked me to review; link is the pull request url, set project when the repo clearly belongs to a known project.
|
|
214
270
|
- GitHub events with no matching session: a ci-failure becomes an issue (link is the pull request url, quote lists the failing checks); a mention or assigned event becomes a request or an issue; a comment or review on my pull request with no session becomes a request. Skip events that need nothing from me.
|
|
215
271
|
|
|
272
|
+
Pending (a snapshot of what is open now, whatever the date window): from Linear only, the issues assigned to me whose state is started or unstarted and that were updated in the last 30 days, following every page of list_issues. Never list Slack or GitHub there.
|
|
273
|
+
|
|
216
274
|
Answer with ONLY a JSON object, no prose and no code fence:
|
|
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 ] }
|
|
218
|
-
Every item needs a link. Use an empty items array when there is nothing new.
|
|
275
|
+
{ "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 } ], "pending": [ { "issueKey": string, "title": string (without the key), "state": string (the Linear state name), "started": boolean (true for a started state, false for unstarted), "link": string (issue URL), "when": ISO time of its last update, "project"?: string, "targetSession"?: { "project": string, "sessionDir": string } (an open session listed above that works on it) } ], "problems"?: [ string ] }
|
|
276
|
+
Every item needs a link. Use an empty items array when there is nothing new, and an empty pending array when nothing is open. If Linear could not be read, leave pending out.
|
|
219
277
|
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).`;
|
|
220
278
|
}
|
|
221
279
|
|
|
@@ -322,6 +380,45 @@ async function fetchGithub(ctx, since, deadlineMs = DEADLINE_MS) {
|
|
|
322
380
|
return { items: [], error: errorMessage(e) };
|
|
323
381
|
}
|
|
324
382
|
}
|
|
383
|
+
async function fetchPending(ctx, now, deadlineMs = DEADLINE_MS) {
|
|
384
|
+
try {
|
|
385
|
+
const search = (flag, kind = "prs") => gh(ctx, ["search", kind, flag, "--state=open", "--sort=updated", `--limit=${MAX_PRS}`, "--json", SEARCH_FIELDS]);
|
|
386
|
+
const [mine, asked, issues] = await Promise.all([search("--author=@me"), search("user-review-requested:@me"), search("--assignee=@me", "issues")]);
|
|
387
|
+
const items = [];
|
|
388
|
+
const add = (kind, f, state) => {
|
|
389
|
+
if (!isRecent(f.updatedAt, now)) return;
|
|
390
|
+
items.push({ id: pendingId("github", kind, f.url), source: "github", kind, title: f.title, link: f.url, when: f.updatedAt, repo: repoOf(f), ...state ? { state } : {} });
|
|
391
|
+
};
|
|
392
|
+
for (const pr of asked) add("review", pr);
|
|
393
|
+
for (const i of issues) add("issue", i);
|
|
394
|
+
const prs = mine.slice(0, MAX_PRS).filter((pr) => isRecent(pr.updatedAt, now));
|
|
395
|
+
const deadline = Date.now() + deadlineMs;
|
|
396
|
+
let next = 0;
|
|
397
|
+
let unread = 0;
|
|
398
|
+
const worker = async () => {
|
|
399
|
+
while (next < prs.length) {
|
|
400
|
+
const pr = prs[next++];
|
|
401
|
+
if (Date.now() >= deadline) {
|
|
402
|
+
unread++;
|
|
403
|
+
continue;
|
|
404
|
+
}
|
|
405
|
+
try {
|
|
406
|
+
const view = await gh(ctx, ["pr", "view", pr.url, "--json", "statusCheckRollup"]);
|
|
407
|
+
const failed = (view.statusCheckRollup ?? []).filter((c) => FAILED.has(c.conclusion ?? c.state ?? ""));
|
|
408
|
+
if (failed.length) add("ci", pr, `failing: ${[...new Set(failed.map((c) => c.name ?? c.context ?? "check"))].join(", ").slice(0, 80)}`);
|
|
409
|
+
} catch {
|
|
410
|
+
unread++;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
await Promise.all(Array.from({ length: Math.min(CONCURRENCY, prs.length) }, worker));
|
|
415
|
+
if (unread) return { items: [], error: `${unread} pull request${unread === 1 ? "" : "s"} could not be checked` };
|
|
416
|
+
const capped = mine.length >= MAX_PRS || asked.length >= MAX_PRS || issues.length >= MAX_PRS;
|
|
417
|
+
return { items, ...capped ? { capped: true } : {} };
|
|
418
|
+
} catch (e) {
|
|
419
|
+
return { items: [], error: errorMessage(e) };
|
|
420
|
+
}
|
|
421
|
+
}
|
|
325
422
|
|
|
326
423
|
// src/run.ts
|
|
327
424
|
var DAY = 24 * 60 * 60 * 1e3;
|
|
@@ -398,10 +495,12 @@ async function readAccount(ctx, account, o) {
|
|
|
398
495
|
const problems = parseReaderProblems(out.text).map((p) => toProblem(account, p));
|
|
399
496
|
const fetched = new Set(github.map((e) => e.pr));
|
|
400
497
|
const toReview = new Set(github.filter((e) => e.type === "review-request").map((e) => e.pr));
|
|
401
|
-
const
|
|
498
|
+
const known = { projects, sessions: sessions.map((s) => `${s.project}::${s.sessionDir}`), account };
|
|
499
|
+
const items = parseReaderOutput(out.text, known);
|
|
500
|
+
const pending = problems.some((p) => p.source === "linear") ? void 0 : parseReaderPending(out.text, known, o.now);
|
|
402
501
|
const placed = checkGithub(items, fetched, toReview).map((i) => i.source === "github" ? { ...i, account: o.owners[i.project ?? i.targetSession?.project ?? ""] } : i);
|
|
403
502
|
const fresh = dedupe(collapse(placed), o.handled);
|
|
404
|
-
return { items: github.length ? fresh.map((i) => ({ ...i, manual: true })) : fresh, problems };
|
|
503
|
+
return { items: github.length ? fresh.map((i) => ({ ...i, manual: true })) : fresh, problems, pending };
|
|
405
504
|
}
|
|
406
505
|
async function readOne(ctx, account, o) {
|
|
407
506
|
const finish = (r) => {
|
|
@@ -415,10 +514,17 @@ async function readOne(ctx, account, o) {
|
|
|
415
514
|
return finish({ account, items: [], problems: [{ account, source: "reader", reason: error.replace(/\s+/g, " ").trim().slice(0, 160) }], error });
|
|
416
515
|
}
|
|
417
516
|
}
|
|
517
|
+
function placeGithub(items, projects, owners) {
|
|
518
|
+
return items.map((i) => {
|
|
519
|
+
const name = projects.find((p) => p.name.toLowerCase() === i.repo?.split("/")[1]?.toLowerCase())?.name;
|
|
520
|
+
return name ? { ...i, project: name, ...owners[name] ? { account: owners[name] } : {} } : i;
|
|
521
|
+
});
|
|
522
|
+
}
|
|
418
523
|
async function reread(ctx, now, notes) {
|
|
419
524
|
const lastReadAt = await ctx.storage.get("lastReadAt");
|
|
420
525
|
const since = lastReadAt ?? new Date(now.getTime() - DAY).toISOString();
|
|
421
526
|
const github = fetchGithub(ctx, since);
|
|
527
|
+
const githubPending = fetchPending(ctx, now);
|
|
422
528
|
const [sessions, projects, handled, accounts] = await Promise.all([
|
|
423
529
|
ctx.sessions.list(),
|
|
424
530
|
ctx.projects.list(),
|
|
@@ -427,14 +533,18 @@ async function reread(ctx, now, notes) {
|
|
|
427
533
|
]);
|
|
428
534
|
const owners = ownersOf(projects);
|
|
429
535
|
if (progress) progress.accounts = Object.fromEntries(accounts.map((a) => [a, "reading"]));
|
|
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 ?? {} })));
|
|
536
|
+
const results = await Promise.all(accounts.map((account, n) => readOne(ctx, account, { since, sessions, projects, owners, github: n === 0 ? github : void 0, handled: handled ?? {}, now })));
|
|
431
537
|
const gh2 = await github;
|
|
538
|
+
const gp = await githubPending;
|
|
432
539
|
if (gh2.error) notes.push(`GitHub: ${gh2.error}`);
|
|
433
540
|
if (results[0].error && gh2.items.length) notes.push("GitHub: not read");
|
|
434
541
|
const failed = results.filter((r) => r.error);
|
|
435
542
|
if (failed.length === results.length) throw new Error(failed.length === 1 ? failed[0].error : failed.map((f) => `${f.account}: ${f.error}`).join("; "));
|
|
436
543
|
const requested = gh2.error ? void 0 : new Set(gh2.requested ?? gh2.items.filter((e) => e.type === "review-request").map((e) => e.pr));
|
|
437
|
-
|
|
544
|
+
const pending = Object.fromEntries(results.map((r) => [r.account, r.pending]));
|
|
545
|
+
pending.github = gp.error ? void 0 : placeGithub(gp.items, projects, owners);
|
|
546
|
+
if (gp.error) notes.push(`GitHub pending: ${gp.error}`);
|
|
547
|
+
return { items: collapse(results.flatMap((r) => r.items)), problems: results.flatMap((r) => r.problems), requested, accounts, pending, githubCapped: gp.error ? void 0 : !!gp.capped };
|
|
438
548
|
}
|
|
439
549
|
async function rememberHandled(ctx, items, now) {
|
|
440
550
|
const old = await ctx.storage.get("handled") ?? {};
|
|
@@ -443,6 +553,34 @@ async function rememberHandled(ctx, items, now) {
|
|
|
443
553
|
for (const i of items) next[i.id] = i.when;
|
|
444
554
|
await ctx.storage.set("handled", next);
|
|
445
555
|
}
|
|
556
|
+
var PENDING = "pending/";
|
|
557
|
+
async function savePending(ctx, pending, accounts) {
|
|
558
|
+
for (const [source, items] of Object.entries(pending)) if (items) await ctx.storage.set(PENDING + source, items);
|
|
559
|
+
if (!accounts) return;
|
|
560
|
+
for (const key of await ctx.storage.list(PENDING)) {
|
|
561
|
+
const source = key.slice(key.lastIndexOf(PENDING) + PENDING.length);
|
|
562
|
+
if (source !== "github" && !accounts.includes(source)) await ctx.storage.delete(key);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
var hiddenOf = async (ctx) => await ctx.storage.get("pendingHidden") ?? {};
|
|
566
|
+
async function allPending(ctx) {
|
|
567
|
+
const lists = await Promise.all((await ctx.storage.list(PENDING)).map((k) => ctx.storage.get(k)));
|
|
568
|
+
return lists.flatMap((l) => l ?? []);
|
|
569
|
+
}
|
|
570
|
+
async function pendingNow(ctx) {
|
|
571
|
+
const [all, hidden, started] = await Promise.all([allPending(ctx), hiddenOf(ctx), startedOf(ctx)]);
|
|
572
|
+
return sortPending(all.filter((p) => hidden[p.id] !== p.when).map((p) => started[p.id] && !p.targetSession ? { ...p, targetSession: started[p.id] } : p));
|
|
573
|
+
}
|
|
574
|
+
var startedOf = async (ctx) => await ctx.storage.get("pendingStarted") ?? {};
|
|
575
|
+
async function pruneHidden(ctx) {
|
|
576
|
+
const [all, hidden] = await Promise.all([allPending(ctx), hiddenOf(ctx)]);
|
|
577
|
+
const ids = new Set(all.map((p) => p.id));
|
|
578
|
+
const next = Object.fromEntries(Object.entries(hidden).filter(([id]) => ids.has(id)));
|
|
579
|
+
if (Object.keys(next).length !== Object.keys(hidden).length) await ctx.storage.set("pendingHidden", next);
|
|
580
|
+
const started = await startedOf(ctx);
|
|
581
|
+
const keep = Object.fromEntries(Object.entries(started).filter(([id]) => ids.has(id)));
|
|
582
|
+
if (Object.keys(keep).length !== Object.keys(started).length) await ctx.storage.set("pendingStarted", keep);
|
|
583
|
+
}
|
|
446
584
|
function dropStaleReviews(items, requested) {
|
|
447
585
|
if (!requested) return items;
|
|
448
586
|
return items.filter((i) => !(i.kind === "review" && i.state === "proposed" && !requested.has(githubPage(i.link) ?? i.link)));
|
|
@@ -478,7 +616,7 @@ async function doRead(ctx, now) {
|
|
|
478
616
|
const date = localDate(now);
|
|
479
617
|
const notes = [];
|
|
480
618
|
try {
|
|
481
|
-
const { items: fresh, problems, requested } = await reread(ctx, now, notes);
|
|
619
|
+
const { items: fresh, problems, requested, accounts, pending, githubCapped } = await reread(ctx, now, notes);
|
|
482
620
|
const lastReadAt = await ctx.storage.get("lastReadAt");
|
|
483
621
|
await locked(async () => {
|
|
484
622
|
const prev = await loadDigest(ctx, date);
|
|
@@ -489,11 +627,16 @@ async function doRead(ctx, now) {
|
|
|
489
627
|
date,
|
|
490
628
|
readAt: now.toISOString(),
|
|
491
629
|
since: prev?.since ?? lastReadAt ?? new Date(now.getTime() - DAY).toISOString(),
|
|
630
|
+
windowStart: lastReadAt ?? new Date(now.getTime() - DAY).toISOString(),
|
|
631
|
+
...prev?.firstReading ?? !lastReadAt ? { firstReading: true } : {},
|
|
492
632
|
items,
|
|
493
633
|
autoStarted: prev?.autoStarted ?? {},
|
|
494
634
|
...notes.length ? { notes } : {},
|
|
495
635
|
...problems.length ? { problems } : {}
|
|
496
636
|
});
|
|
637
|
+
await savePending(ctx, pending, accounts);
|
|
638
|
+
if (githubCapped !== void 0) await ctx.storage.set("pendingCapped", githubCapped);
|
|
639
|
+
await pruneHidden(ctx);
|
|
497
640
|
await rememberHandled(ctx, fresh, now);
|
|
498
641
|
await ctx.storage.set("lastReadAt", now.toISOString());
|
|
499
642
|
await ctx.storage.delete("lastFailedAt");
|
|
@@ -517,7 +660,7 @@ async function retryAccount(ctx, account, now) {
|
|
|
517
660
|
let result;
|
|
518
661
|
try {
|
|
519
662
|
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 ?? {} });
|
|
663
|
+
result = await readOne(ctx, account, { since: prev.since, sessions, projects, owners: ownersOf(projects), handled: handled ?? {}, now });
|
|
521
664
|
} finally {
|
|
522
665
|
if (progress === mine && !Object.values(mine.accounts).includes("reading")) progress = void 0;
|
|
523
666
|
}
|
|
@@ -531,6 +674,7 @@ async function retryAccount(ctx, account, now) {
|
|
|
531
674
|
if (problems.length) next.problems = problems;
|
|
532
675
|
else delete next.problems;
|
|
533
676
|
await saveDigest(ctx, next);
|
|
677
|
+
await savePending(ctx, { [account]: result.pending });
|
|
534
678
|
await rememberHandled(ctx, result.items, now);
|
|
535
679
|
});
|
|
536
680
|
await autoResearch(ctx, date);
|
|
@@ -717,6 +861,42 @@ async function acceptAll(ctx, date, id, project, account) {
|
|
|
717
861
|
}
|
|
718
862
|
return requireDigest(ctx, date);
|
|
719
863
|
}
|
|
864
|
+
async function requirePending(ctx, id) {
|
|
865
|
+
const item = (await pendingNow(ctx)).find((p) => p.id === id);
|
|
866
|
+
if (!item) throw new ModuleError("not_found", "no such pending item");
|
|
867
|
+
return item;
|
|
868
|
+
}
|
|
869
|
+
function hidePending(ctx, id) {
|
|
870
|
+
return locked(async () => {
|
|
871
|
+
const item = await requirePending(ctx, id);
|
|
872
|
+
await ctx.storage.set("pendingHidden", { ...await hiddenOf(ctx), [id]: item.when });
|
|
873
|
+
return pendingNow(ctx);
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
var pendingInFlight = /* @__PURE__ */ new Set();
|
|
877
|
+
async function startPending(ctx, id, project) {
|
|
878
|
+
if (!await isEnabled(ctx)) throw new ModuleError("bad_request", OFF_MESSAGE);
|
|
879
|
+
const item = await locked(async () => {
|
|
880
|
+
const found = await requirePending(ctx, id);
|
|
881
|
+
if (pendingInFlight.has(id)) throw new ModuleError("bad_request", "item is already being handled");
|
|
882
|
+
pendingInFlight.add(id);
|
|
883
|
+
return found;
|
|
884
|
+
});
|
|
885
|
+
try {
|
|
886
|
+
const target = project ?? item.project;
|
|
887
|
+
if (!target) throw new ModuleError("bad_request", "pick a project");
|
|
888
|
+
const owner = (await ownersOf(await ctx.projects.list()))[target];
|
|
889
|
+
if (item.account && owner && owner !== item.account) throw new ModuleError("bad_request", "project belongs to another account");
|
|
890
|
+
const account = item.account ?? owner;
|
|
891
|
+
const url = githubPage(item.link) ?? item.link;
|
|
892
|
+
const input = { type: item.kind === "review" ? "review" : "work", project: target, task: url, ...account ? { account } : {} };
|
|
893
|
+
const session = await ctx.cw.start(input);
|
|
894
|
+
await locked(async () => ctx.storage.set("pendingStarted", { ...await startedOf(ctx), [id]: session }));
|
|
895
|
+
return { session };
|
|
896
|
+
} finally {
|
|
897
|
+
pendingInFlight.delete(id);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
720
900
|
function setFolded(ctx, date, folded) {
|
|
721
901
|
return locked(async () => {
|
|
722
902
|
if (folded) await ctx.storage.set(`folded/${date}`, true);
|
|
@@ -754,7 +934,9 @@ async function digestFor(ctx, date) {
|
|
|
754
934
|
}
|
|
755
935
|
const enabled = await isEnabled(ctx);
|
|
756
936
|
const reading2 = readingNow();
|
|
757
|
-
|
|
937
|
+
const pending = await pendingNow(ctx);
|
|
938
|
+
const pendingCapped = await ctx.storage.get("pendingCapped") === true;
|
|
939
|
+
return { ...digest ? { digest, folded, enabled } : { digest: null, folded: false, enabled }, pending, pendingCapped, firstReading: digest?.firstReading === true, ...reading2 ? { reading: reading2 } : {} };
|
|
758
940
|
}
|
|
759
941
|
var server_default = defineModule({
|
|
760
942
|
routes: [
|
|
@@ -817,6 +999,20 @@ var server_default = defineModule({
|
|
|
817
999
|
return { enabled: false };
|
|
818
1000
|
}
|
|
819
1001
|
}),
|
|
1002
|
+
defineAction({
|
|
1003
|
+
id: "pending-start",
|
|
1004
|
+
label: "Start",
|
|
1005
|
+
effect: "local",
|
|
1006
|
+
input: { id: { type: "string", required: true }, project: { type: "string" } },
|
|
1007
|
+
run: (input, ctx) => startPending(ctx, input.id, input.project)
|
|
1008
|
+
}),
|
|
1009
|
+
defineAction({
|
|
1010
|
+
id: "pending-hide",
|
|
1011
|
+
label: "Hide",
|
|
1012
|
+
effect: "local",
|
|
1013
|
+
input: { id: { type: "string", required: true } },
|
|
1014
|
+
run: async (input, ctx) => ({ pending: await hidePending(ctx, input.id) })
|
|
1015
|
+
}),
|
|
820
1016
|
itemAction("send", "Send"),
|
|
821
1017
|
itemAction("start", "Start"),
|
|
822
1018
|
itemAction("research", "Research"),
|
|
@@ -52,6 +52,30 @@ function byAccount(items) {
|
|
|
52
52
|
const rest = items.filter((i) => !i.account);
|
|
53
53
|
return rest.length ? [...blocks, { sections: sections(rest) }] : blocks;
|
|
54
54
|
}
|
|
55
|
+
function titleFor(i) {
|
|
56
|
+
if (!i.issueKey) return i.title;
|
|
57
|
+
const key = i.issueKey.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
58
|
+
const rest = i.title.replace(new RegExp(`^\\s*\\[?${key}\\]?\\s*[:\\-\u2013\u2014]?\\s*`, "i"), "");
|
|
59
|
+
return rest.trim() ? rest : i.title;
|
|
60
|
+
}
|
|
61
|
+
var SOURCE_NAMES = { linear: "Linear", slack: "Slack", github: "GitHub" };
|
|
62
|
+
function whoOf(i) {
|
|
63
|
+
const who = i.who.trim();
|
|
64
|
+
return !who || who.toLowerCase() === SOURCE_NAMES[i.source].toLowerCase() ? null : who;
|
|
65
|
+
}
|
|
66
|
+
var pendingLabel = (p) => p.kind === "ci" ? "CI failing" : p.kind === "review" ? "Review requested" : p.source === "linear" ? p.started ? "In progress" : "To do" : "Assigned";
|
|
67
|
+
var pendingIn = (items, account) => account ? items.filter((p) => p.account === account) : items;
|
|
68
|
+
function pendingByAccount(items) {
|
|
69
|
+
const accounts = [...new Set(items.flatMap((p) => p.account ? [p.account] : []))];
|
|
70
|
+
if (accounts.length < 2) return items.length ? [{ items }] : [];
|
|
71
|
+
const blocks = accounts.map((account) => ({ account, items: pendingIn(items, account) }));
|
|
72
|
+
const rest = items.filter((p) => !p.account);
|
|
73
|
+
return rest.length ? [...blocks, { items: rest }] : blocks;
|
|
74
|
+
}
|
|
75
|
+
var CAPPED_NOTE = "showing the latest 20";
|
|
76
|
+
var GITHUB_SEARCH = "https://github.com/pulls/review-requested";
|
|
77
|
+
var PENDING_EMPTY = "Nothing open \u2014 nice.";
|
|
78
|
+
var FIRST_READING_NOTE = "First reading \u2014 what you have open is under Pending.";
|
|
55
79
|
|
|
56
80
|
// src/rows.tsx
|
|
57
81
|
import { useCallback, useEffect, useRef, useState } from "preact/hooks";
|
|
@@ -131,6 +155,12 @@ function useActing(forge, date, reload, hurry = () => {
|
|
|
131
155
|
const act = (item, op, project) => run(async () => {
|
|
132
156
|
if (date) await forge.action(op, { date, id: item.id, ...project ? { project } : {} });
|
|
133
157
|
});
|
|
158
|
+
const startPending = (item, project) => run(async () => {
|
|
159
|
+
await forge.action("pending-start", { id: item.id, ...project ? { project } : {} });
|
|
160
|
+
});
|
|
161
|
+
const hidePending = (item) => run(async () => {
|
|
162
|
+
await forge.action("pending-hide", { id: item.id });
|
|
163
|
+
});
|
|
134
164
|
const refresh = async () => {
|
|
135
165
|
if (reading.current) return;
|
|
136
166
|
reading.current = true;
|
|
@@ -155,7 +185,7 @@ function useActing(forge, date, reload, hurry = () => {
|
|
|
155
185
|
const s = await forge.action("reconnect", { account });
|
|
156
186
|
if (s) forge.openSession(s.project, s.sessionDir);
|
|
157
187
|
});
|
|
158
|
-
return { busy, refreshing, retrying, retry, reconnect, run, act, refresh };
|
|
188
|
+
return { busy, refreshing, retrying, retry, reconnect, run, act, refresh, startPending, hidePending };
|
|
159
189
|
}
|
|
160
190
|
function dayOf(date) {
|
|
161
191
|
const [y, m, d] = date.split("-").map(Number);
|
|
@@ -170,12 +200,18 @@ function dayLabel(now, date) {
|
|
|
170
200
|
return `${part} \xB7 your ${now.toLocaleDateString("en-US", { weekday: "long" })} ${now.getDate()}`;
|
|
171
201
|
}
|
|
172
202
|
var clock = (d) => d.toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit" });
|
|
203
|
+
function windowTime(at, read) {
|
|
204
|
+
if (at.toDateString() === read.toDateString()) return clock(at);
|
|
205
|
+
const yesterday = new Date(read.getTime() - 864e5).toDateString() === at.toDateString();
|
|
206
|
+
return `${yesterday ? "yesterday" : at.toLocaleDateString("en-US", { month: "short", day: "numeric" })} ${clock(at)}`;
|
|
207
|
+
}
|
|
173
208
|
function readLine(d) {
|
|
174
209
|
const read = new Date(d.readAt);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
210
|
+
return `Read at ${clock(read)} \xB7 changes since ${windowTime(new Date(d.windowStart ?? d.since), read)}`;
|
|
211
|
+
}
|
|
212
|
+
function dayName(date) {
|
|
213
|
+
const day = dayOf(date);
|
|
214
|
+
return `${day.toLocaleDateString("en-US", { weekday: "long" })} ${day.getDate()}`;
|
|
179
215
|
}
|
|
180
216
|
function ago(iso, now = /* @__PURE__ */ new Date()) {
|
|
181
217
|
const t = new Date(iso);
|
|
@@ -251,17 +287,17 @@ var Row = ({ item, projects = EMPTY_PROJECTS, acting, forge }) => {
|
|
|
251
287
|
/* @__PURE__ */ jsxs("div", { style: { minWidth: 0 }, children: [
|
|
252
288
|
/* @__PURE__ */ jsxs("div", { style: { fontWeight: 560, fontSize: "13px", display: "flex", alignItems: "center", gap: "8px", minWidth: 0 }, children: [
|
|
253
289
|
item.issueKey && /* @__PURE__ */ jsx("span", { style: { fontFamily: "var(--mono, ui-monospace, monospace)", fontSize: "11.5px", color: "var(--ink-2)", fontWeight: 500 }, children: item.issueKey }),
|
|
254
|
-
/* @__PURE__ */ jsx("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: item
|
|
290
|
+
/* @__PURE__ */ jsx("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: titleFor(item) })
|
|
255
291
|
] }),
|
|
256
292
|
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "6px", marginTop: "3px", fontSize: "11.5px", color: "var(--ink-2)", flexWrap: "wrap" }, children: [
|
|
257
|
-
/* @__PURE__ */ jsx(Avatar, { who: item.who }),
|
|
258
|
-
/* @__PURE__ */
|
|
293
|
+
whoOf(item) && /* @__PURE__ */ jsx(Avatar, { who: item.who }),
|
|
294
|
+
/* @__PURE__ */ jsx("span", { children: whoOf(item) ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
259
295
|
item.who,
|
|
260
296
|
" ",
|
|
261
297
|
where,
|
|
262
298
|
" ",
|
|
263
299
|
strong(item.where)
|
|
264
|
-
] }),
|
|
300
|
+
] }) : strong(item.where) }),
|
|
265
301
|
/* @__PURE__ */ jsx(Sep, {}),
|
|
266
302
|
/* @__PURE__ */ jsx("span", { children: ago(item.when) }),
|
|
267
303
|
item.account && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -307,6 +343,55 @@ var Row = ({ item, projects = EMPTY_PROJECTS, acting, forge }) => {
|
|
|
307
343
|
] })
|
|
308
344
|
] });
|
|
309
345
|
};
|
|
346
|
+
var PENDING_TOKEN = { ci: "--red", review: "--blue", issue: "--green" };
|
|
347
|
+
var PendingRow = ({ item, projects = EMPTY_PROJECTS, acting, forge, compact }) => {
|
|
348
|
+
const [project, setProject] = useState(item.project ?? "");
|
|
349
|
+
const token = PENDING_TOKEN[item.kind];
|
|
350
|
+
const target = item.project ?? project;
|
|
351
|
+
return /* @__PURE__ */ jsxs("div", { style: { display: "grid", gridTemplateColumns: "30px 1fr auto", gap: "12px", alignItems: "center", padding: compact ? "7px 10px" : "10px 12px", borderRadius: "11px", background: soft("--ink", 3), border: "1px solid var(--hair)" }, children: [
|
|
352
|
+
/* @__PURE__ */ jsx(SourceIcon, { source: item.source }),
|
|
353
|
+
/* @__PURE__ */ jsxs("div", { style: { minWidth: 0 }, children: [
|
|
354
|
+
/* @__PURE__ */ jsxs("div", { style: { fontWeight: 560, fontSize: "13px", display: "flex", alignItems: "center", gap: "8px", minWidth: 0 }, children: [
|
|
355
|
+
item.issueKey && /* @__PURE__ */ jsx("span", { style: { fontFamily: "var(--mono, ui-monospace, monospace)", fontSize: "11.5px", color: "var(--ink-2)", fontWeight: 500 }, children: item.issueKey }),
|
|
356
|
+
/* @__PURE__ */ jsx("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: titleFor(item) })
|
|
357
|
+
] }),
|
|
358
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "6px", marginTop: "3px", fontSize: "11.5px", color: "var(--ink-2)", flexWrap: "wrap" }, children: [
|
|
359
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
360
|
+
item.repo ? strong(item.repo) : null,
|
|
361
|
+
item.repo && item.state ? " \xB7 " : "",
|
|
362
|
+
item.state
|
|
363
|
+
] }),
|
|
364
|
+
(item.repo || item.state) && /* @__PURE__ */ jsx(Sep, {}),
|
|
365
|
+
/* @__PURE__ */ jsx("span", { children: ago(item.when) }),
|
|
366
|
+
item.account && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
367
|
+
/* @__PURE__ */ jsx(Sep, {}),
|
|
368
|
+
/* @__PURE__ */ jsx(AccountChip, { account: item.account })
|
|
369
|
+
] }),
|
|
370
|
+
/* @__PURE__ */ jsx(Sep, {}),
|
|
371
|
+
/* @__PURE__ */ jsxs("a", { href: item.link, target: "_blank", rel: "noopener noreferrer", style: { color: "var(--ink-2)", textDecoration: "none", borderBottom: "1px dotted var(--ink-3)" }, children: [
|
|
372
|
+
"View in ",
|
|
373
|
+
SOURCE_LABEL[item.source],
|
|
374
|
+
" \u2197"
|
|
375
|
+
] }),
|
|
376
|
+
item.project && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
377
|
+
/* @__PURE__ */ jsx(Sep, {}),
|
|
378
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
379
|
+
"project ",
|
|
380
|
+
strong(item.project)
|
|
381
|
+
] })
|
|
382
|
+
] })
|
|
383
|
+
] })
|
|
384
|
+
] }),
|
|
385
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
|
|
386
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: "10.5px", fontWeight: 600, padding: "2px 7px", borderRadius: "6px", whiteSpace: "nowrap", color: `var(${token})`, background: soft(token, 15) }, children: pendingLabel(item) }),
|
|
387
|
+
item.targetSession ? /* @__PURE__ */ jsx(Btn, { label: "Open task", onClick: () => forge.openSession(item.targetSession.project, item.targetSession.sessionDir) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
388
|
+
!item.project && /* @__PURE__ */ jsx(ProjectPicker, { projects: projectsFor(projects, item.account), value: project, onChange: setProject }),
|
|
389
|
+
/* @__PURE__ */ jsx(Btn, { label: item.kind === "review" ? "Review" : "Start", disabled: acting.busy || !target, onClick: () => acting.startPending(item, item.project ? void 0 : project) })
|
|
390
|
+
] }),
|
|
391
|
+
/* @__PURE__ */ jsx(Btn, { label: "Hide", style: ghostStyle, disabled: acting.busy, onClick: () => acting.hidePending(item) })
|
|
392
|
+
] })
|
|
393
|
+
] });
|
|
394
|
+
};
|
|
310
395
|
var READING_CSS = `
|
|
311
396
|
@keyframes today-spin { to { transform: rotate(360deg) } }
|
|
312
397
|
@keyframes today-pulse { 0%, 100% { opacity: .55 } 50% { opacity: 1 } }
|
|
@@ -363,7 +448,9 @@ function ProblemRow({ group, acting, details = false }) {
|
|
|
363
448
|
}
|
|
364
449
|
|
|
365
450
|
// src/view.tsx
|
|
366
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "preact/jsx-runtime";
|
|
451
|
+
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "preact/jsx-runtime";
|
|
452
|
+
var heading = { margin: "4px 0 0", fontSize: "13px", fontWeight: 650, letterSpacing: "-.01em" };
|
|
453
|
+
var subheading = { margin: "4px 0", fontSize: "11px", fontWeight: 600, letterSpacing: ".06em", textTransform: "uppercase", color: "var(--ink-3)" };
|
|
367
454
|
function View({ forge }) {
|
|
368
455
|
const [days, setDays] = useState2([]);
|
|
369
456
|
const [day, setDay] = useState2(null);
|
|
@@ -377,13 +464,15 @@ function View({ forge }) {
|
|
|
377
464
|
const problems = groupProblems(digest?.problems ?? []);
|
|
378
465
|
const notes = notesLine(digest?.notes);
|
|
379
466
|
const enabled = reply?.enabled === true;
|
|
467
|
+
const pending = reply?.pending ?? [];
|
|
468
|
+
const liveNews = (digest?.items ?? []).filter((i) => i.state !== "dismissed").length;
|
|
380
469
|
useEffect2(() => {
|
|
381
470
|
forge.route("/days").then((r) => setDays(r.days), () => {
|
|
382
471
|
});
|
|
383
472
|
}, [forge, digest?.readAt]);
|
|
384
473
|
return /* @__PURE__ */ jsxs2("div", { style: { padding: "22px", display: "flex", flexDirection: "column", gap: "16px", maxWidth: "1180px" }, children: [
|
|
385
474
|
/* @__PURE__ */ jsxs2("div", { style: { display: "flex", alignItems: "center", gap: "12px", flexWrap: "wrap" }, children: [
|
|
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)) }),
|
|
475
|
+
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: dayName(d) }, d)) }),
|
|
387
476
|
digest && /* @__PURE__ */ jsx2("b", { style: { fontSize: "13px", fontWeight: 600 }, children: dayLabel(/* @__PURE__ */ new Date(), digest.date) }),
|
|
388
477
|
isReading ? /* @__PURE__ */ jsx2(ReadingLine, { reading }) : /* @__PURE__ */ jsx2("span", { style: { fontSize: "12px", color: "var(--ink-2)" }, children: digest ? readLine(digest) : "Not read yet" }),
|
|
389
478
|
/* @__PURE__ */ jsxs2("span", { style: { marginLeft: "auto", display: "flex", gap: "8px" }, children: [
|
|
@@ -398,17 +487,43 @@ function View({ forge }) {
|
|
|
398
487
|
/* @__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
488
|
] }),
|
|
400
489
|
notes && /* @__PURE__ */ jsx2("div", { style: { fontSize: "12px", color: "var(--ink-3)" }, children: notes }),
|
|
401
|
-
!digest && isReading ? /* @__PURE__ */ jsx2(SkeletonRows, {}) : !digest
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
490
|
+
!digest && isReading ? /* @__PURE__ */ jsx2(SkeletonRows, {}) : !digest ? /* @__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." }) : /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
491
|
+
/* @__PURE__ */ jsxs2("section", { style: { display: "flex", flexDirection: "column", gap: "16px" }, children: [
|
|
492
|
+
/* @__PURE__ */ jsxs2("h3", { style: heading, children: [
|
|
493
|
+
"News \xB7 ",
|
|
494
|
+
liveNews
|
|
495
|
+
] }),
|
|
496
|
+
digest.items.length === 0 && /* @__PURE__ */ jsx2("div", { style: { fontSize: "12.5px", color: "var(--ink-2)" }, children: reply?.firstReading ? FIRST_READING_NOTE : "Nothing new." }),
|
|
497
|
+
byAccount(digest.items).map(({ account, sections: sections2 }) => /* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexDirection: "column", gap: "16px" }, children: [
|
|
498
|
+
account && /* @__PURE__ */ jsx2("div", { children: /* @__PURE__ */ jsx2(AccountChip, { account }) }),
|
|
499
|
+
sections2.map(({ title, items }) => /* @__PURE__ */ jsxs2("section", { style: { display: "flex", flexDirection: "column", gap: "6px" }, children: [
|
|
500
|
+
/* @__PURE__ */ jsxs2("h4", { style: subheading, children: [
|
|
501
|
+
title,
|
|
502
|
+
" \xB7 ",
|
|
503
|
+
items.length
|
|
504
|
+
] }),
|
|
505
|
+
items.map((i) => /* @__PURE__ */ jsx2(Row, { item: i, projects, acting, forge }, i.id))
|
|
506
|
+
] }, title))
|
|
507
|
+
] }, account ?? ""))
|
|
508
|
+
] }),
|
|
509
|
+
/* @__PURE__ */ jsxs2("section", { style: { display: "flex", flexDirection: "column", gap: "8px" }, children: [
|
|
510
|
+
/* @__PURE__ */ jsxs2("h3", { style: heading, children: [
|
|
511
|
+
"Pending \xB7 ",
|
|
512
|
+
pending.length,
|
|
513
|
+
reply?.pendingCapped && /* @__PURE__ */ jsxs2("span", { style: { fontWeight: 400, fontSize: "11.5px", color: "var(--ink-3)" }, children: [
|
|
514
|
+
" \xB7 ",
|
|
515
|
+
CAPPED_NOTE,
|
|
516
|
+
" \u2014 ",
|
|
517
|
+
/* @__PURE__ */ jsx2("a", { href: GITHUB_SEARCH, target: "_blank", rel: "noopener noreferrer", style: { color: "inherit" }, children: "see GitHub" })
|
|
518
|
+
] })
|
|
408
519
|
] }),
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
520
|
+
pending.length === 0 && /* @__PURE__ */ jsx2("div", { style: { fontSize: "12.5px", color: "var(--ink-2)" }, children: PENDING_EMPTY }),
|
|
521
|
+
pendingByAccount(pending).map(({ account, items }) => /* @__PURE__ */ jsxs2("div", { style: { display: "flex", flexDirection: "column", gap: "6px" }, children: [
|
|
522
|
+
account && /* @__PURE__ */ jsx2("div", { children: /* @__PURE__ */ jsx2(AccountChip, { account }) }),
|
|
523
|
+
items.map((p) => /* @__PURE__ */ jsx2(PendingRow, { item: p, projects, acting, forge }, p.id))
|
|
524
|
+
] }, account ?? ""))
|
|
525
|
+
] })
|
|
526
|
+
] })
|
|
412
527
|
] });
|
|
413
528
|
}
|
|
414
529
|
var view_default = definePanel({ id: "main", title: "Today", component: View });
|