@sentry/junior-dashboard 0.280.0 → 0.281.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.js +23 -30
- package/dist/client-manifest.json +1 -1
- package/dist/index.js +23 -30
- package/dist/public/chunks/{AdminPage-YEKZOKH6.js → AdminPage-M5RBVZFN.js} +1 -1
- package/dist/public/chunks/{AutomationPage-5GS3IUAK.js → AutomationPage-WALCREDT.js} +1 -1
- package/dist/public/chunks/{AutomationRunsPage-IPYEZU4L.js → AutomationRunsPage-CV47E4UX.js} +1 -1
- package/dist/public/chunks/{AutomationsPage-HSAYPC3C.js → AutomationsPage-57L3AQVJ.js} +1 -1
- package/dist/public/chunks/{CodePage-IPFKXWFB.js → CodePage-XJUYMFJH.js} +1 -1
- package/dist/public/chunks/{ConnectionsPage-5XUEK6FS.js → ConnectionsPage-3QQAGYWF.js} +1 -1
- package/dist/public/chunks/{LocationDetailPage-27ETUGR6.js → LocationDetailPage-4IL5HQML.js} +1 -1
- package/dist/public/chunks/{LocationsPage-WOKMQAGM.js → LocationsPage-D2DUQAHJ.js} +1 -1
- package/dist/public/chunks/{PeoplePage-6YQLDOUL.js → PeoplePage-6F5GPQ7C.js} +1 -1
- package/dist/public/chunks/{PersonProfilePage-GYMAZFIK.js → PersonProfilePage-SPAYQPTD.js} +1 -1
- package/dist/public/chunks/{PersonalTokensPage-4BCR744B.js → PersonalTokensPage-SHAUJ74M.js} +1 -1
- package/dist/public/chunks/{PluginUserPage-IP6WL7MD.js → PluginUserPage-64FIWD7M.js} +1 -1
- package/dist/public/chunks/{RepositoryPage-TRD44LQ3.js → RepositoryPage-L7IHOXSN.js} +1 -1
- package/dist/public/chunks/{SettingsPage-4E3SLQ36.js → SettingsPage-U7WG4FHE.js} +1 -1
- package/dist/public/chunks/{SystemPage-C3XBKXKW.js → SystemPage-ZBC43OJH.js} +1 -1
- package/dist/public/chunks/{WorkspaceFormPage-2LS2X67Q.js → WorkspaceFormPage-3NVIIZ4P.js} +1 -1
- package/dist/public/chunks/{WorkspacesPage-5WB3CUTX.js → WorkspacesPage-G73HPBDD.js} +1 -1
- package/dist/public/chunks/{chunk-VFEBNOPX.js → chunk-2J3LGF5Q.js} +1 -1
- package/dist/public/chunks/chunk-2NNKHSZE.js +1 -0
- package/dist/public/chunks/chunk-4TQSTCIN.js +13 -0
- package/dist/public/chunks/chunk-64GPEGGE.js +1 -0
- package/dist/public/chunks/{chunk-WZVO3HG4.js → chunk-6FHY65EQ.js} +1 -1
- package/dist/public/chunks/{chunk-YYNMZ4WC.js → chunk-DEEO4D4N.js} +1 -1
- package/dist/public/chunks/{chunk-SDKV3OID.js → chunk-FSGVY7HB.js} +1 -1
- package/dist/public/chunks/chunk-GZBMHYYU.js +1 -0
- package/dist/public/chunks/{chunk-NQMDED2R.js → chunk-II4NXLSQ.js} +1 -1
- package/dist/public/chunks/{chunk-B6HGRBBX.js → chunk-ILH47V7O.js} +1 -1
- package/dist/public/chunks/{chunk-GRMX2HX6.js → chunk-JPL2NRWK.js} +1 -1
- package/dist/public/chunks/{chunk-NQOJAZFQ.js → chunk-JVJ5UWIK.js} +1 -1
- package/dist/public/chunks/{chunk-V5UDSIRA.js → chunk-K4TYMAA3.js} +1 -1
- package/dist/public/chunks/{chunk-EFEREKX4.js → chunk-KDUTK357.js} +1 -1
- package/dist/public/chunks/{chunk-RHIXHBS5.js → chunk-LZYAHJVQ.js} +1 -1
- package/dist/public/chunks/{chunk-5GZDBGAR.js → chunk-MKKFXRYO.js} +1 -1
- package/dist/public/chunks/{chunk-PEQNT5MO.js → chunk-NGQRNS3C.js} +1 -1
- package/dist/public/chunks/{chunk-IA6BJDKN.js → chunk-ONDKE72P.js} +1 -1
- package/dist/public/chunks/{chunk-WJ3OXMVX.js → chunk-PG7M7L24.js} +1 -1
- package/dist/public/chunks/{chunk-6GQL3EVJ.js → chunk-QQUFROWT.js} +1 -1
- package/dist/public/chunks/{chunk-UAH6DWNS.js → chunk-RB5FBDEY.js} +1 -1
- package/dist/public/chunks/{chunk-A2QWWA7O.js → chunk-RGXXD4DM.js} +1 -1
- package/dist/public/chunks/{chunk-AYXSBMWA.js → chunk-TC7TU4GK.js} +1 -1
- package/dist/public/chunks/chunk-WLIOZO3W.js +1 -0
- package/dist/public/chunks/{chunk-VXT3FIVL.js → chunk-XDUSY26N.js} +11 -11
- package/dist/public/client-4OAAOHF4.js +68 -0
- package/dist/tailwind.css +1 -1
- package/package.json +4 -4
- package/src/client/components/BottomSheet.tsx +1 -1
- package/src/client/components/DetailsPanel.tsx +2 -1
- package/src/client/conversations/ConversationBrief.tsx +129 -65
- package/src/client/conversations/ConversationDetails.tsx +13 -14
- package/src/client/conversations/ConversationEventLog.tsx +20 -97
- package/src/client/conversations/ConversationHeader.tsx +41 -26
- package/src/client/conversations/ConversationHeaderActions.tsx +3 -1
- package/src/client/conversations/ConversationLinkedWork.tsx +30 -10
- package/src/client/conversations/ConversationMeta.tsx +15 -15
- package/src/client/conversations/ConversationPage.tsx +31 -7
- package/src/client/conversations/ConversationTranscript.tsx +234 -186
- package/src/client/conversations/ConversationUsageBreakdown.tsx +142 -64
- package/src/client/conversations/DetailsList.tsx +7 -1
- package/src/client/conversations/PendingMailboxStack.tsx +88 -44
- package/src/client/conversations/TranscriptActivityGroup.tsx +7 -14
- package/src/client/conversations/TranscriptEventView.tsx +7 -3
- package/src/client/conversations/TranscriptReasoningView.tsx +4 -2
- package/src/client/conversations/TranscriptRows.tsx +37 -5
- package/src/client/conversations/TranscriptView.tsx +4 -0
- package/src/client/conversations/queries.ts +74 -43
- package/src/client/conversations/transcriptBottomPinning.ts +13 -5
- package/src/client/conversations/transcriptListRows.ts +215 -0
- package/src/client/conversations/virtualRows.ts +168 -0
- package/src/client/http.ts +6 -5
- package/src/client/sentry.ts +53 -3
- package/src/conversation-cache.ts +8 -10
- package/src/mock-reporting/fixtures.ts +0 -8
- package/dist/public/chunks/chunk-GO45RQDL.js +0 -1
- package/dist/public/chunks/chunk-N4AONKD3.js +0 -1
- package/dist/public/chunks/chunk-QNA7F7QB.js +0 -1
- package/dist/public/chunks/chunk-R4ORRE77.js +0 -1
- package/dist/public/chunks/chunk-Z2JPRGFT.js +0 -1
- package/dist/public/client-TYC7JKRE.js +0 -91
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as he,b as xe,c as ye}from"./chunk-PEQNT5MO.js";import{a as fe}from"./chunk-H2ZU34CP.js";import{a as A}from"./chunk-WJ3OXMVX.js";import"./chunk-SUX4QBVF.js";import{a as ie,c as re,f as se,j as ne,n as oe,o as le,p as de,q as me,r as ce,s as ge,t as ue,v as pe,w as be,x as ve}from"./chunk-V5UDSIRA.js";import{a as te,b as ae}from"./chunk-AYXSBMWA.js";import{a as T,b as Z,c as D,d as ee}from"./chunk-UT6HZPGL.js";import{a as C}from"./chunk-L2H3ZWZN.js";import"./chunk-TFJOEF3Q.js";import"./chunk-YYNMZ4WC.js";import"./chunk-EFEREKX4.js";import"./chunk-LKW7MULF.js";import"./chunk-6FSJ3W2W.js";import"./chunk-QOX5RMLM.js";import{e as X}from"./chunk-564V7YHG.js";import{f as F,r as f,s as V,z as k}from"./chunk-NQMDED2R.js";import"./chunk-GMZIELFU.js";import{Ja as p}from"./chunk-VXT3FIVL.js";import"./chunk-QPBLZSNX.js";import"./chunk-RHMZNAJX.js";import"./chunk-GOTQ4D6W.js";import{F as Y,G as J,H as Q,J as B,K as $,M as P,d as _,k as U,o as G,s as w,t as W}from"./chunk-6PHJZPWD.js";import"./chunk-JAZABOBA.js";import"./chunk-WRXMQB7X.js";import"./chunk-CQY6BYUB.js";import"./chunk-B5ZN3SWQ.js";import{Bc as N,Jc as j,Pb as E,Rc as M,Ya as H,a as Be,b,bc as I,cb as y,pb as q,qc as O,yc as K}from"./chunk-YPMUHXYT.js";import{c as u}from"./chunk-7SZRL6FY.js";var Ae=u(Be(),1);var g=u(b(),1);function ke(e){return(0,g.jsxs)("section",{"aria-labelledby":"plugin-details-heading",className:"grid gap-3",children:[(0,g.jsx)(C,{className:"px-1",id:"plugin-details-heading",title:"Details"}),(0,g.jsxs)(p,{children:[(0,g.jsxs)("div",{className:"grid grid-cols-1 gap-px bg-dashboard-fill-hover sm:grid-cols-3",children:[(0,g.jsx)(L,{icon:y,label:"Identifier",value:e.plugin.name}),(0,g.jsx)(L,{icon:N,label:"Skills",value:String(e.plugin.skills.length)}),(0,g.jsx)(L,{icon:E,label:"Configuration",value:String(e.plugin.configKeys.length)})]}),(0,g.jsxs)("div",{className:"grid gap-5 border-t border-dashboard-border-subtle p-4 sm:p-5 lg:grid-cols-2",children:[(0,g.jsx)(Ne,{emptyText:"No plugin-provided skills were discovered.",items:e.plugin.skills.map(t=>t.name),title:"Skills"}),e.plugin.configKeys.length?(0,g.jsx)("div",{className:"lg:col-span-2",children:(0,g.jsx)(Ne,{emptyText:"",items:e.plugin.configKeys,title:"Configuration keys"})}):null]})]})]})}function L(e){let t=e.icon;return(0,g.jsxs)("div",{className:"flex items-center gap-3 bg-dashboard-surface-panel px-4 py-3.5",children:[(0,g.jsx)(t,{"aria-hidden":"true",className:"text-dashboard-accent-text/60",size:15}),(0,g.jsxs)("div",{className:"min-w-0",children:[(0,g.jsx)("div",{className:"truncate font-display text-base font-medium text-dashboard-text",children:e.value}),(0,g.jsx)("div",{className:"mt-0.5 font-sans font-medium text-xs text-dashboard-text-muted",children:e.label})]})]})}function Ne(e){return(0,g.jsxs)("div",{children:[(0,g.jsx)("h3",{className:"m-0 font-sans text-xs font-medium text-dashboard-text-muted",children:e.title}),e.items.length?(0,g.jsx)("div",{className:"mt-2.5 flex flex-wrap gap-2",children:e.items.map(t=>(0,g.jsx)("span",{className:"rounded-md border border-dashboard-border bg-dashboard-overlay-soft px-2.5 py-1.5 font-mono text-xs text-dashboard-text-muted",children:t},t))}):(0,g.jsx)("p",{className:"mt-2 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted",children:e.emptyText})]})}var c=u(b(),1);function Ce(e){return(0,c.jsx)("section",{"aria-label":"Plugins",className:"grid gap-3",children:e.plugins.length?(0,c.jsx)("div",{className:"grid gap-3",children:e.plugins.map(t=>(0,c.jsx)($e,{plugin:t},t.name))}):(0,c.jsx)(p,{padding:"md",children:(0,c.jsx)("div",{className:"font-mono text-xs text-dashboard-text-muted",children:"No plugin inventory has been reported yet."})})})}function $e(e){let t=e.plugin.reports.flatMap(a=>a.metrics??[]);return(0,c.jsxs)(G,{className:"group grid min-w-0 gap-4 rounded-lg border border-dashboard-border bg-dashboard-surface-panel/85 p-4 no-underline transition-colors hover:border-dashboard-accent/20 hover:bg-dashboard-accent/[0.025] sm:p-5",to:D(e.plugin.name),children:[(0,c.jsxs)("div",{className:"flex min-w-0 items-start justify-between gap-4",children:[(0,c.jsxs)("div",{className:"flex min-w-0 items-start gap-3",children:[(0,c.jsx)("div",{className:"grid size-9 shrink-0 place-items-center rounded-md border border-dashboard-accent/15 bg-dashboard-accent/[0.075] text-dashboard-accent-text",children:(0,c.jsx)(y,{"aria-hidden":"true",size:16,strokeWidth:1.8})}),(0,c.jsxs)("div",{className:"min-w-0",children:[(0,c.jsx)("h3",{className:"m-0 truncate font-display text-lg font-medium text-dashboard-text",children:e.plugin.displayName}),(0,c.jsx)("p",{className:"mt-1 mb-0 line-clamp-2 font-sans text-xs leading-relaxed text-dashboard-text-muted",children:e.plugin.description})]})]}),(0,c.jsx)(H,{"aria-hidden":"true",className:"mt-1 shrink-0 text-dashboard-text-muted transition-transform group-hover:translate-x-0.5 group-hover:text-dashboard-accent-text/70",size:16})]}),t.length?(0,c.jsx)("div",{className:`grid ${t.length===1?"grid-cols-1":"grid-cols-2"} gap-px overflow-hidden rounded-md border border-dashboard-border-subtle bg-dashboard-fill-hover`,children:t.slice(0,2).map(a=>(0,c.jsxs)("div",{className:"min-w-0 bg-dashboard-surface-panel px-3 py-2.5",children:[(0,c.jsx)("div",{className:"truncate font-display text-lg font-light text-dashboard-text",children:a.value}),(0,c.jsx)("div",{className:"mt-1 truncate font-sans font-medium text-xs text-dashboard-text-muted",children:a.label})]},a.label))}):null,(0,c.jsx)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 border-t border-dashboard-border-subtle pt-3",children:(0,c.jsx)(Le,{icon:N,label:`${e.plugin.skills.length} skills`})})]})}function Le(e){let t=e.icon;return(0,c.jsxs)("span",{className:"inline-flex items-center gap-1.5 font-sans font-medium text-xs text-dashboard-text-muted",children:[(0,c.jsx)(t,{"aria-hidden":"true",size:11}),e.label]})}var l=u(b(),1);function Se(e){return e.reports.length===0&&!e.emptyText?null:e.reports.length===0?(0,l.jsx)(p,{padding:"md",children:(0,l.jsxs)("div",{className:"flex items-center gap-4",children:[(0,l.jsx)("div",{className:"grid size-10 shrink-0 place-items-center rounded-md border border-dashboard-border bg-dashboard-fill-soft text-dashboard-text-muted",children:(0,l.jsx)(O,{"aria-hidden":"true",size:17})}),(0,l.jsxs)("div",{children:[(0,l.jsx)("h2",{className:"m-0 font-display text-base font-medium text-dashboard-text-muted",children:"Operational reports"}),(0,l.jsx)("p",{className:"mt-1 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted",children:e.emptyText})]})]})}):(0,l.jsxs)("div",{className:"grid gap-3",children:[(0,l.jsx)(C,{className:"px-1",title:"Operational reports"}),e.reports.map(t=>(0,l.jsx)(ze,{fallbackTitle:e.fallbackTitle,range:e.range,report:t},t.pluginName))]})}function ze(e){let a=(e.report.title===e.report.pluginName?void 0:e.report.title)??e.fallbackTitle??e.report.pluginName,s=e.report.metrics??[];return(0,l.jsxs)(p,{children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-4 border-b border-dashboard-border-subtle px-5 py-4",children:[(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsx)("h3",{className:"m-0 truncate font-display text-lg font-medium text-dashboard-text",children:a}),(0,l.jsx)("div",{className:"mt-1 hidden font-mono text-xs text-dashboard-text-muted sm:block",children:e.report.pluginName})]}),e.report.generatedAt?(0,l.jsxs)("div",{className:"hidden shrink-0 font-mono text-xs text-dashboard-text-muted sm:block",children:["updated ",F(e.report.generatedAt)]}):null]}),s.length?(0,l.jsx)("div",{className:M("grid gap-px bg-dashboard-fill-hover",s.length===1?"grid-cols-1":"grid-cols-2",s.length===3?"lg:grid-cols-3":s.length===5?"lg:grid-cols-5":s.length>=4?"lg:grid-cols-4":void 0),children:s.map(d=>(0,l.jsxs)("div",{className:M("min-w-0 bg-dashboard-surface-panel px-4 py-4",s.length>1&&s.length%2===1&&"last:col-span-2 lg:last:col-span-1",_e(d.tone)),children:[(0,l.jsx)("div",{className:"truncate font-display text-2xl font-light leading-none text-dashboard-text",children:d.value}),(0,l.jsx)("div",{className:"mt-2 font-sans font-medium text-xs text-dashboard-text-muted",children:d.label})]},d.label))}):null,e.report.widgets?.length?(0,l.jsx)("div",{className:"grid gap-3 border-t border-dashboard-border-subtle bg-dashboard-overlay-soft p-3 lg:grid-cols-2",children:e.report.widgets.map(d=>(0,l.jsx)(xe,{range:e.range,widget:d},d.id))}):null,e.report.recordSets?.map(d=>(0,l.jsx)(ye,{embedded:!0,recordSet:d},`${e.report.pluginName}:${d.title}`))]})}function _e(e){return e==="danger"?"shadow-[inset_0_2px_0_rgba(251,113,133,0.65)]":e==="warning"?"shadow-[inset_0_2px_0_rgba(251,191,36,0.65)]":e==="good"?"shadow-[inset_0_2px_0_rgba(110,231,183,0.55)]":""}var o=u(b(),1);function Re(e){let t=He(e.skills),a=e.skills.filter(s=>s.pluginProvider).length;return(0,o.jsxs)(p,{children:[(0,o.jsxs)("div",{className:"flex items-start justify-between gap-4 border-b border-dashboard-border-subtle px-5 py-4 max-sm:flex-col",children:[(0,o.jsx)(C,{description:(0,o.jsxs)(o.Fragment,{children:["The task-specific instructions ",w()," ","discovered, grouped by their plugin provider when one is registered."]}),title:"Skills"}),(0,o.jsxs)("div",{className:"grid min-w-[12rem] grid-cols-2 overflow-hidden rounded-lg border border-dashboard-border bg-dashboard-overlay-soft max-sm:w-full max-sm:min-w-0",children:[(0,o.jsx)(we,{label:"discovered",value:e.skills.length}),(0,o.jsx)(we,{label:"from plugins",value:a})]})]}),(0,o.jsx)("div",{className:"grid gap-3 p-3 sm:p-4",children:t.length?t.map(s=>(0,o.jsx)(Ge,{group:s},s.pluginProvider??"standalone")):(0,o.jsx)("div",{className:"rounded-lg border border-dashed border-dashboard-border px-4 py-8 text-center font-sans text-xs text-dashboard-text-muted",children:"No skills have been discovered yet."})})]})}function Ge(e){let t=e.group.pluginProvider??"Standalone";return(0,o.jsxs)("article",{className:"rounded-lg border border-dashboard-border-subtle bg-dashboard-fill-soft p-4",children:[(0,o.jsxs)("div",{className:"mb-3 flex items-center justify-between gap-3",children:[(0,o.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5",children:[(0,o.jsx)("div",{className:"grid size-8 shrink-0 place-items-center rounded-md border border-dashboard-accent/15 bg-dashboard-accent/[0.075] text-dashboard-accent-text",children:e.group.pluginProvider?(0,o.jsx)(y,{"aria-hidden":"true",size:15,strokeWidth:1.8}):(0,o.jsx)(N,{"aria-hidden":"true",size:15,strokeWidth:1.8})}),(0,o.jsxs)("div",{children:[(0,o.jsx)("h3",{className:"m-0 truncate font-display text-base font-medium text-dashboard-text",children:t}),(0,o.jsx)("div",{className:"mt-0.5 font-sans font-medium text-xs text-dashboard-text-muted",children:e.group.pluginProvider?"plugin provider":"core or local"})]})]}),(0,o.jsxs)("span",{className:"font-mono text-xs text-dashboard-text-muted",children:[f(e.group.skills.length)," skill",e.group.skills.length===1?"":"s"]})]}),(0,o.jsx)("div",{className:"flex flex-wrap gap-2",children:e.group.skills.map(a=>(0,o.jsx)("span",{className:"rounded-md border border-dashboard-border bg-dashboard-overlay-soft px-2.5 py-1.5 font-mono text-xs text-dashboard-text-muted",children:a.name},a.name))})]})}function we(e){return(0,o.jsxs)("div",{className:"border-r border-dashboard-border-subtle px-3 py-2.5 text-center last:border-r-0",children:[(0,o.jsx)("div",{className:"font-display text-xl font-light leading-none text-dashboard-text",children:f(e.value)}),(0,o.jsx)("div",{className:"mt-1.5 font-sans font-medium text-xs text-dashboard-text-muted",children:e.label})]})}function He(e){let t=new Map;for(let a of e){let s=t.get(a.pluginProvider)??[];s.push(a),t.set(a.pluginProvider,s)}return[...t.entries()].map(([a,s])=>({pluginProvider:a,skills:[...s].sort((d,r)=>d.name.localeCompare(r.name))})).sort((a,s)=>a.pluginProvider?s.pluginProvider?a.pluginProvider.localeCompare(s.pluginProvider):-1:1)}var v=u(b(),1),qe={conversations:{color:"var(--color-cyan-400)",label:"Conversations"}};function Pe(e){let t=e.bucketUnit??"day",a=Math.max(1,...e.days.map(m=>m.conversations)),s=e.days.map(m=>m.conversations),d=s.reduce((m,x)=>m+x,0),r=ce(s);return(0,v.jsxs)(p,{children:[(0,v.jsx)(fe,{description:`Root conversations with recorded activity, per ${t==="6hour"?"6 hours":t}.`,title:"Conversation activity",total:f(d)}),(0,v.jsx)("div",{className:"px-2 py-2",children:(0,v.jsx)(be,{className:"aspect-auto h-38 w-full",config:qe,children:(0,v.jsxs)(se,{"aria-label":`Conversations per ${t==="6hour"?"6 hours":t}`,data:e.days,margin:le,role:"img",children:[(0,v.jsx)(ie,{strokeDasharray:"3 5",vertical:!1}),(0,v.jsx)(me,{maximum:a}),(0,v.jsx)(de,{keys:e.days.map(m=>m.date)}),(0,v.jsx)(ve,{content:(0,v.jsx)(ue,{rows:m=>[["conversations",m.conversations]]})}),(0,v.jsx)(re,{dataKey:"conversations",fill:"var(--color-conversations)",fillOpacity:.78,isAnimationActive:!1,maxBarSize:24,minPointSize:m=>m?2:0,radius:2}),(0,v.jsx)(ge,{average:r,format:V,stroke:"var(--color-cyan-400)",unit:Q(t)})]})})})]})}var i=u(b(),1);function Ee(e){return e.reduce((t,a)=>({allow:t.allow+a.allow,ask:t.ask+a.ask,costUsd:t.costUsd+(a.costUsd??0),deny:t.deny+a.deny,requests:t.requests+a.requests}),{allow:0,ask:0,costUsd:0,deny:0,requests:0})}function R(e){return(0,i.jsxs)("div",{className:"rounded-md border border-dashboard-border-subtle bg-dashboard-overlay-soft px-3 py-3",children:[(0,i.jsx)("div",{className:"font-display text-xl font-light text-dashboard-text",children:(0,i.jsx)("span",{className:e.valueClassName,children:e.value})}),(0,i.jsx)("div",{className:"mt-1 font-sans text-xs leading-relaxed text-dashboard-text-muted",children:e.label})]})}function Te(e){let t=e.bucketUnit??"day",a=Ee(e.days),s=Math.max(1,...e.days.map(r=>r.requests)),d=[0,Math.floor((e.days.length-1)/2),e.days.length-1].filter((r,m,x)=>r>=0&&x.indexOf(r)===m);return(0,i.jsxs)(p,{children:[(0,i.jsxs)("div",{className:"border-b border-dashboard-border-subtle px-4 py-4",children:[(0,i.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h3",{className:"m-0 font-sans text-xs font-medium text-dashboard-text-muted",children:"Guardian reviews"}),(0,i.jsxs)("p",{className:"mt-1 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted",children:[B(t)," decisions before reviewed actions execute."]})]}),(0,i.jsxs)("div",{className:"font-sans font-medium text-xs text-dashboard-text-muted",children:[(0,i.jsx)("span",{className:"mr-3 text-emerald-200/75",children:"Allow"}),(0,i.jsx)("span",{className:"mr-3 text-amber-200/75",children:"Ask"}),(0,i.jsx)("span",{className:"text-rose-200/75",children:"Deny"})]})]}),(0,i.jsxs)("div",{className:"mt-4 grid grid-cols-2 gap-2 sm:grid-cols-5",children:[(0,i.jsx)(R,{label:"Requests",value:f(a.requests)}),(0,i.jsx)(R,{label:"Allowed",value:f(a.allow),valueClassName:"text-emerald-100"}),(0,i.jsx)(R,{label:"Asked",value:f(a.ask),valueClassName:"text-amber-100"}),(0,i.jsx)(R,{label:"Denied",value:f(a.deny),valueClassName:"text-rose-100"}),(0,i.jsx)(R,{label:"Estimated cost",value:k({total:a.costUsd})})]})]}),(0,i.jsxs)("div",{className:"px-4 pt-5 pb-3",children:[(0,i.jsx)("div",{"aria-label":`${B(t)} Guardian review results`,className:"flex h-36 items-end gap-px",role:"img",children:e.days.map(r=>{let m=Math.max(2,r.requests/s*100);return(0,i.jsx)(pe,{content:(0,i.jsxs)("div",{className:"grid grid-cols-[auto_auto] gap-x-4",children:[(0,i.jsx)("span",{children:"Allow"}),(0,i.jsx)("span",{className:"text-right",children:r.allow}),(0,i.jsx)("span",{children:"Ask"}),(0,i.jsx)("span",{className:"text-right",children:r.ask}),(0,i.jsx)("span",{children:"Deny"}),(0,i.jsx)("span",{className:"text-right",children:r.deny}),(0,i.jsx)("span",{children:"Cost"}),(0,i.jsx)("span",{className:"text-right",children:k({total:r.costUsd??0})})]}),date:r.date,summary:`${r.allow} allowed, ${r.ask} asked, ${r.deny} denied, ${k({total:r.costUsd??0})}`,children:(0,i.jsxs)("button",{className:"flex min-w-0 flex-1 flex-col justify-end overflow-hidden rounded-t-sm bg-dashboard-fill-soft focus-visible:outline-1 focus-visible:outline-dashboard-focus",style:{height:`${m}%`},type:"button",children:[r.deny?(0,i.jsx)("span",{className:"block w-full bg-rose-400/75",style:{flex:r.deny}}):null,r.ask?(0,i.jsx)("span",{className:"block w-full bg-amber-300/75",style:{flex:r.ask}}):null,r.allow?(0,i.jsx)("span",{className:"block w-full bg-emerald-300/70",style:{flex:r.allow}}):null]})},r.date)})}),(0,i.jsx)("div",{className:"relative mt-2 h-4",children:d.map(r=>{let m=e.days[r];return m?(0,i.jsx)(oe,{className:"absolute -translate-x-1/2",style:{left:`${(r+.5)/e.days.length*100}%`},children:ne(m.date)},m.date):null})})]})]})}var h=u(b(),1);function Ie(e){return e.reduce((t,a)=>({conversations:t.conversations+a.conversations,costUsd:t.costUsd+(a.costUsd??0),tokens:t.tokens+(a.tokens??0)}),{conversations:0,costUsd:0,tokens:0})}function De(e){if(!e.stats)return(0,h.jsx)(p,{padding:"sm",children:(0,h.jsx)(X,{children:e.error?"Conversation metrics failed to load.":e.loading?"Loading conversation metrics.":"No conversation metrics have been reported yet."})});let t=$({days:e.stats.metricDays,hours:e.stats.metricHours,sixHours:e.stats.metricSixHours,range:e.range,emptySixHour:r=>({conversations:0,date:r,durationMs:0})}),a=$({days:e.stats.guardian.metricDays,hours:e.stats.guardian.metricHours,sixHours:e.stats.guardian.metricSixHours,range:e.range,emptySixHour:r=>({allow:0,ask:0,date:r,deny:0,requests:0})}),s=Ie(t),d=J(e.range);return(0,h.jsxs)("section",{"aria-label":"Runtime telemetry",className:"grid gap-4",children:[e.error?(0,h.jsx)("p",{className:"m-0 font-sans text-xs text-rose-200/65",children:"Metrics refresh failed. Showing cached data."}):null,(0,h.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[(0,h.jsx)(A,{detail:`Root conversations in the ${Y(e.range)}`,icon:I,label:"Conversations",value:f(s.conversations)}),(0,h.jsx)(A,{detail:"All recorded model tokens",icon:K,label:"Tokens",value:f(s.tokens)}),(0,h.jsx)(A,{detail:"Estimated model cost",icon:q,label:"Model spend",value:k({total:s.costUsd})})]}),(0,h.jsx)(he,{bucketUnit:d,cacheBreakdown:!0,days:t}),(0,h.jsx)(Pe,{bucketUnit:d,days:t}),(0,h.jsx)(Te,{bucketUnit:d,days:a})]})}var n=u(b(),1);function Yt(e){let[t,a]=(0,Ae.useState)(30),s=_(),d=e.data.pluginReports?.reports??[],r=Z({plugins:e.data.plugins,reports:d,skills:e.data.skills}),m=ee(s.pathname),x=m===T,S=r.find(Me=>D(Me.name)===m),z=m.startsWith(`${T}/`);return z&&!S&&e.data.pluginReportsLoading?(0,n.jsx)(ae,{description:"Loading plugin details and operational reports.",label:"Loading plugin",title:"Plugin"}):z&&!S?(0,n.jsx)(U,{replace:!0,to:T}):m!=="/system"&&!x&&!S?(0,n.jsx)(U,{replace:!0,to:"/system"}):(0,n.jsx)(te,{children:S?(0,n.jsx)(je,{data:e.data,onRangeChange:a,plugin:S,range:t}):x?(0,n.jsx)(Ke,{data:e.data,plugins:r}):(0,n.jsx)(Oe,{data:e.data,range:t,onRangeChange:a})})}function Oe(e){return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(P,{description:`A live read on ${W()} runtime and model usage.`,onRangeChange:e.onRangeChange,range:e.range,title:"System"}),(0,n.jsx)(De,{error:e.data.conversationStatsError,range:e.range,loading:e.data.conversationStatsLoading,stats:e.data.conversationStats})]})}function Ke(e){return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(P,{description:`Loaded capabilities and operational reports for ${w()}.`,title:"Plugins"}),e.data.pluginReportsError?(0,n.jsx)(Ue,{showingReports:e.plugins.some(t=>t.reports.length)}):null,(0,n.jsx)(Ce,{plugins:e.plugins}),e.data.skills.length?(0,n.jsx)(Re,{skills:e.data.skills}):null]})}function je(e){let t=e.plugin.reports,a=t.some(s=>s.widgets?.some(d=>d.timeRangeDays?.length));return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(P,{description:e.plugin.description,...a?{onRangeChange:e.onRangeChange,range:e.range}:{},title:e.plugin.displayName}),e.data.pluginReportsError?(0,n.jsx)(Ue,{showingReports:!!t.length}):null,(0,n.jsx)(ke,{plugin:e.plugin}),(0,n.jsx)(Se,{fallbackTitle:e.plugin.displayName,...!e.data.pluginReportsLoading&&!e.data.pluginReportsError?{emptyText:"This plugin does not expose operational activity yet."}:{},range:e.range,reports:t})]})}function Ue(e){return(0,n.jsx)(p,{className:"border-amber-300/10 bg-amber-300/[0.025]",padding:"sm",children:(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("div",{className:"grid size-9 shrink-0 place-items-center rounded-md border border-amber-300/15 bg-amber-300/[0.055] text-amber-200/70",children:(0,n.jsx)(j,{"aria-hidden":"true",size:15})}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"font-display text-sm font-medium text-dashboard-text-muted",children:"Plugin stats failed to load."}),(0,n.jsx)("div",{className:"mt-1 font-sans text-xs leading-relaxed text-dashboard-text-muted",children:e.showingReports?`Showing the last operational reports ${w()} received.`:"Plugin details and capabilities are still available."})]})]})})}export{Yt as SystemPage};
|
|
1
|
+
import{a as he,b as xe,c as ye}from"./chunk-NGQRNS3C.js";import{a as fe}from"./chunk-H2ZU34CP.js";import{a as A}from"./chunk-PG7M7L24.js";import"./chunk-SUX4QBVF.js";import{a as ie,c as re,f as se,j as ne,n as oe,o as le,p as de,q as me,r as ce,s as ge,t as ue,v as pe,w as be,x as ve}from"./chunk-K4TYMAA3.js";import{a as te,b as ae}from"./chunk-TC7TU4GK.js";import{a as T,b as Z,c as D,d as ee}from"./chunk-UT6HZPGL.js";import{a as C}from"./chunk-L2H3ZWZN.js";import"./chunk-TFJOEF3Q.js";import"./chunk-DEEO4D4N.js";import"./chunk-KDUTK357.js";import"./chunk-LKW7MULF.js";import"./chunk-6FSJ3W2W.js";import"./chunk-QOX5RMLM.js";import{e as X}from"./chunk-564V7YHG.js";import{f as F,r as f,s as V,z as k}from"./chunk-II4NXLSQ.js";import"./chunk-GMZIELFU.js";import{Ka as p}from"./chunk-XDUSY26N.js";import"./chunk-QPBLZSNX.js";import"./chunk-RHMZNAJX.js";import"./chunk-GOTQ4D6W.js";import{F as Y,G as J,H as Q,J as B,K as $,M as P,d as _,k as U,o as G,s as w,t as W}from"./chunk-6PHJZPWD.js";import"./chunk-JAZABOBA.js";import"./chunk-WRXMQB7X.js";import"./chunk-CQY6BYUB.js";import"./chunk-B5ZN3SWQ.js";import{Bc as N,Jc as j,Pb as E,Rc as M,Ya as H,a as Be,b,bc as I,cb as y,pb as q,qc as O,yc as K}from"./chunk-YPMUHXYT.js";import{c as u}from"./chunk-7SZRL6FY.js";var Ae=u(Be(),1);var g=u(b(),1);function ke(e){return(0,g.jsxs)("section",{"aria-labelledby":"plugin-details-heading",className:"grid gap-3",children:[(0,g.jsx)(C,{className:"px-1",id:"plugin-details-heading",title:"Details"}),(0,g.jsxs)(p,{children:[(0,g.jsxs)("div",{className:"grid grid-cols-1 gap-px bg-dashboard-fill-hover sm:grid-cols-3",children:[(0,g.jsx)(L,{icon:y,label:"Identifier",value:e.plugin.name}),(0,g.jsx)(L,{icon:N,label:"Skills",value:String(e.plugin.skills.length)}),(0,g.jsx)(L,{icon:E,label:"Configuration",value:String(e.plugin.configKeys.length)})]}),(0,g.jsxs)("div",{className:"grid gap-5 border-t border-dashboard-border-subtle p-4 sm:p-5 lg:grid-cols-2",children:[(0,g.jsx)(Ne,{emptyText:"No plugin-provided skills were discovered.",items:e.plugin.skills.map(t=>t.name),title:"Skills"}),e.plugin.configKeys.length?(0,g.jsx)("div",{className:"lg:col-span-2",children:(0,g.jsx)(Ne,{emptyText:"",items:e.plugin.configKeys,title:"Configuration keys"})}):null]})]})]})}function L(e){let t=e.icon;return(0,g.jsxs)("div",{className:"flex items-center gap-3 bg-dashboard-surface-panel px-4 py-3.5",children:[(0,g.jsx)(t,{"aria-hidden":"true",className:"text-dashboard-accent-text/60",size:15}),(0,g.jsxs)("div",{className:"min-w-0",children:[(0,g.jsx)("div",{className:"truncate font-display text-base font-medium text-dashboard-text",children:e.value}),(0,g.jsx)("div",{className:"mt-0.5 font-sans font-medium text-xs text-dashboard-text-muted",children:e.label})]})]})}function Ne(e){return(0,g.jsxs)("div",{children:[(0,g.jsx)("h3",{className:"m-0 font-sans text-xs font-medium text-dashboard-text-muted",children:e.title}),e.items.length?(0,g.jsx)("div",{className:"mt-2.5 flex flex-wrap gap-2",children:e.items.map(t=>(0,g.jsx)("span",{className:"rounded-md border border-dashboard-border bg-dashboard-overlay-soft px-2.5 py-1.5 font-mono text-xs text-dashboard-text-muted",children:t},t))}):(0,g.jsx)("p",{className:"mt-2 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted",children:e.emptyText})]})}var c=u(b(),1);function Ce(e){return(0,c.jsx)("section",{"aria-label":"Plugins",className:"grid gap-3",children:e.plugins.length?(0,c.jsx)("div",{className:"grid gap-3",children:e.plugins.map(t=>(0,c.jsx)($e,{plugin:t},t.name))}):(0,c.jsx)(p,{padding:"md",children:(0,c.jsx)("div",{className:"font-mono text-xs text-dashboard-text-muted",children:"No plugin inventory has been reported yet."})})})}function $e(e){let t=e.plugin.reports.flatMap(a=>a.metrics??[]);return(0,c.jsxs)(G,{className:"group grid min-w-0 gap-4 rounded-lg border border-dashboard-border bg-dashboard-surface-panel/85 p-4 no-underline transition-colors hover:border-dashboard-accent/20 hover:bg-dashboard-accent/[0.025] sm:p-5",to:D(e.plugin.name),children:[(0,c.jsxs)("div",{className:"flex min-w-0 items-start justify-between gap-4",children:[(0,c.jsxs)("div",{className:"flex min-w-0 items-start gap-3",children:[(0,c.jsx)("div",{className:"grid size-9 shrink-0 place-items-center rounded-md border border-dashboard-accent/15 bg-dashboard-accent/[0.075] text-dashboard-accent-text",children:(0,c.jsx)(y,{"aria-hidden":"true",size:16,strokeWidth:1.8})}),(0,c.jsxs)("div",{className:"min-w-0",children:[(0,c.jsx)("h3",{className:"m-0 truncate font-display text-lg font-medium text-dashboard-text",children:e.plugin.displayName}),(0,c.jsx)("p",{className:"mt-1 mb-0 line-clamp-2 font-sans text-xs leading-relaxed text-dashboard-text-muted",children:e.plugin.description})]})]}),(0,c.jsx)(H,{"aria-hidden":"true",className:"mt-1 shrink-0 text-dashboard-text-muted transition-transform group-hover:translate-x-0.5 group-hover:text-dashboard-accent-text/70",size:16})]}),t.length?(0,c.jsx)("div",{className:`grid ${t.length===1?"grid-cols-1":"grid-cols-2"} gap-px overflow-hidden rounded-md border border-dashboard-border-subtle bg-dashboard-fill-hover`,children:t.slice(0,2).map(a=>(0,c.jsxs)("div",{className:"min-w-0 bg-dashboard-surface-panel px-3 py-2.5",children:[(0,c.jsx)("div",{className:"truncate font-display text-lg font-light text-dashboard-text",children:a.value}),(0,c.jsx)("div",{className:"mt-1 truncate font-sans font-medium text-xs text-dashboard-text-muted",children:a.label})]},a.label))}):null,(0,c.jsx)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 border-t border-dashboard-border-subtle pt-3",children:(0,c.jsx)(Le,{icon:N,label:`${e.plugin.skills.length} skills`})})]})}function Le(e){let t=e.icon;return(0,c.jsxs)("span",{className:"inline-flex items-center gap-1.5 font-sans font-medium text-xs text-dashboard-text-muted",children:[(0,c.jsx)(t,{"aria-hidden":"true",size:11}),e.label]})}var l=u(b(),1);function Se(e){return e.reports.length===0&&!e.emptyText?null:e.reports.length===0?(0,l.jsx)(p,{padding:"md",children:(0,l.jsxs)("div",{className:"flex items-center gap-4",children:[(0,l.jsx)("div",{className:"grid size-10 shrink-0 place-items-center rounded-md border border-dashboard-border bg-dashboard-fill-soft text-dashboard-text-muted",children:(0,l.jsx)(O,{"aria-hidden":"true",size:17})}),(0,l.jsxs)("div",{children:[(0,l.jsx)("h2",{className:"m-0 font-display text-base font-medium text-dashboard-text-muted",children:"Operational reports"}),(0,l.jsx)("p",{className:"mt-1 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted",children:e.emptyText})]})]})}):(0,l.jsxs)("div",{className:"grid gap-3",children:[(0,l.jsx)(C,{className:"px-1",title:"Operational reports"}),e.reports.map(t=>(0,l.jsx)(ze,{fallbackTitle:e.fallbackTitle,range:e.range,report:t},t.pluginName))]})}function ze(e){let a=(e.report.title===e.report.pluginName?void 0:e.report.title)??e.fallbackTitle??e.report.pluginName,s=e.report.metrics??[];return(0,l.jsxs)(p,{children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-4 border-b border-dashboard-border-subtle px-5 py-4",children:[(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsx)("h3",{className:"m-0 truncate font-display text-lg font-medium text-dashboard-text",children:a}),(0,l.jsx)("div",{className:"mt-1 hidden font-mono text-xs text-dashboard-text-muted sm:block",children:e.report.pluginName})]}),e.report.generatedAt?(0,l.jsxs)("div",{className:"hidden shrink-0 font-mono text-xs text-dashboard-text-muted sm:block",children:["updated ",F(e.report.generatedAt)]}):null]}),s.length?(0,l.jsx)("div",{className:M("grid gap-px bg-dashboard-fill-hover",s.length===1?"grid-cols-1":"grid-cols-2",s.length===3?"lg:grid-cols-3":s.length===5?"lg:grid-cols-5":s.length>=4?"lg:grid-cols-4":void 0),children:s.map(d=>(0,l.jsxs)("div",{className:M("min-w-0 bg-dashboard-surface-panel px-4 py-4",s.length>1&&s.length%2===1&&"last:col-span-2 lg:last:col-span-1",_e(d.tone)),children:[(0,l.jsx)("div",{className:"truncate font-display text-2xl font-light leading-none text-dashboard-text",children:d.value}),(0,l.jsx)("div",{className:"mt-2 font-sans font-medium text-xs text-dashboard-text-muted",children:d.label})]},d.label))}):null,e.report.widgets?.length?(0,l.jsx)("div",{className:"grid gap-3 border-t border-dashboard-border-subtle bg-dashboard-overlay-soft p-3 lg:grid-cols-2",children:e.report.widgets.map(d=>(0,l.jsx)(xe,{range:e.range,widget:d},d.id))}):null,e.report.recordSets?.map(d=>(0,l.jsx)(ye,{embedded:!0,recordSet:d},`${e.report.pluginName}:${d.title}`))]})}function _e(e){return e==="danger"?"shadow-[inset_0_2px_0_rgba(251,113,133,0.65)]":e==="warning"?"shadow-[inset_0_2px_0_rgba(251,191,36,0.65)]":e==="good"?"shadow-[inset_0_2px_0_rgba(110,231,183,0.55)]":""}var o=u(b(),1);function Re(e){let t=He(e.skills),a=e.skills.filter(s=>s.pluginProvider).length;return(0,o.jsxs)(p,{children:[(0,o.jsxs)("div",{className:"flex items-start justify-between gap-4 border-b border-dashboard-border-subtle px-5 py-4 max-sm:flex-col",children:[(0,o.jsx)(C,{description:(0,o.jsxs)(o.Fragment,{children:["The task-specific instructions ",w()," ","discovered, grouped by their plugin provider when one is registered."]}),title:"Skills"}),(0,o.jsxs)("div",{className:"grid min-w-[12rem] grid-cols-2 overflow-hidden rounded-lg border border-dashboard-border bg-dashboard-overlay-soft max-sm:w-full max-sm:min-w-0",children:[(0,o.jsx)(we,{label:"discovered",value:e.skills.length}),(0,o.jsx)(we,{label:"from plugins",value:a})]})]}),(0,o.jsx)("div",{className:"grid gap-3 p-3 sm:p-4",children:t.length?t.map(s=>(0,o.jsx)(Ge,{group:s},s.pluginProvider??"standalone")):(0,o.jsx)("div",{className:"rounded-lg border border-dashed border-dashboard-border px-4 py-8 text-center font-sans text-xs text-dashboard-text-muted",children:"No skills have been discovered yet."})})]})}function Ge(e){let t=e.group.pluginProvider??"Standalone";return(0,o.jsxs)("article",{className:"rounded-lg border border-dashboard-border-subtle bg-dashboard-fill-soft p-4",children:[(0,o.jsxs)("div",{className:"mb-3 flex items-center justify-between gap-3",children:[(0,o.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5",children:[(0,o.jsx)("div",{className:"grid size-8 shrink-0 place-items-center rounded-md border border-dashboard-accent/15 bg-dashboard-accent/[0.075] text-dashboard-accent-text",children:e.group.pluginProvider?(0,o.jsx)(y,{"aria-hidden":"true",size:15,strokeWidth:1.8}):(0,o.jsx)(N,{"aria-hidden":"true",size:15,strokeWidth:1.8})}),(0,o.jsxs)("div",{children:[(0,o.jsx)("h3",{className:"m-0 truncate font-display text-base font-medium text-dashboard-text",children:t}),(0,o.jsx)("div",{className:"mt-0.5 font-sans font-medium text-xs text-dashboard-text-muted",children:e.group.pluginProvider?"plugin provider":"core or local"})]})]}),(0,o.jsxs)("span",{className:"font-mono text-xs text-dashboard-text-muted",children:[f(e.group.skills.length)," skill",e.group.skills.length===1?"":"s"]})]}),(0,o.jsx)("div",{className:"flex flex-wrap gap-2",children:e.group.skills.map(a=>(0,o.jsx)("span",{className:"rounded-md border border-dashboard-border bg-dashboard-overlay-soft px-2.5 py-1.5 font-mono text-xs text-dashboard-text-muted",children:a.name},a.name))})]})}function we(e){return(0,o.jsxs)("div",{className:"border-r border-dashboard-border-subtle px-3 py-2.5 text-center last:border-r-0",children:[(0,o.jsx)("div",{className:"font-display text-xl font-light leading-none text-dashboard-text",children:f(e.value)}),(0,o.jsx)("div",{className:"mt-1.5 font-sans font-medium text-xs text-dashboard-text-muted",children:e.label})]})}function He(e){let t=new Map;for(let a of e){let s=t.get(a.pluginProvider)??[];s.push(a),t.set(a.pluginProvider,s)}return[...t.entries()].map(([a,s])=>({pluginProvider:a,skills:[...s].sort((d,r)=>d.name.localeCompare(r.name))})).sort((a,s)=>a.pluginProvider?s.pluginProvider?a.pluginProvider.localeCompare(s.pluginProvider):-1:1)}var v=u(b(),1),qe={conversations:{color:"var(--color-cyan-400)",label:"Conversations"}};function Pe(e){let t=e.bucketUnit??"day",a=Math.max(1,...e.days.map(m=>m.conversations)),s=e.days.map(m=>m.conversations),d=s.reduce((m,x)=>m+x,0),r=ce(s);return(0,v.jsxs)(p,{children:[(0,v.jsx)(fe,{description:`Root conversations with recorded activity, per ${t==="6hour"?"6 hours":t}.`,title:"Conversation activity",total:f(d)}),(0,v.jsx)("div",{className:"px-2 py-2",children:(0,v.jsx)(be,{className:"aspect-auto h-38 w-full",config:qe,children:(0,v.jsxs)(se,{"aria-label":`Conversations per ${t==="6hour"?"6 hours":t}`,data:e.days,margin:le,role:"img",children:[(0,v.jsx)(ie,{strokeDasharray:"3 5",vertical:!1}),(0,v.jsx)(me,{maximum:a}),(0,v.jsx)(de,{keys:e.days.map(m=>m.date)}),(0,v.jsx)(ve,{content:(0,v.jsx)(ue,{rows:m=>[["conversations",m.conversations]]})}),(0,v.jsx)(re,{dataKey:"conversations",fill:"var(--color-conversations)",fillOpacity:.78,isAnimationActive:!1,maxBarSize:24,minPointSize:m=>m?2:0,radius:2}),(0,v.jsx)(ge,{average:r,format:V,stroke:"var(--color-cyan-400)",unit:Q(t)})]})})})]})}var i=u(b(),1);function Ee(e){return e.reduce((t,a)=>({allow:t.allow+a.allow,ask:t.ask+a.ask,costUsd:t.costUsd+(a.costUsd??0),deny:t.deny+a.deny,requests:t.requests+a.requests}),{allow:0,ask:0,costUsd:0,deny:0,requests:0})}function R(e){return(0,i.jsxs)("div",{className:"rounded-md border border-dashboard-border-subtle bg-dashboard-overlay-soft px-3 py-3",children:[(0,i.jsx)("div",{className:"font-display text-xl font-light text-dashboard-text",children:(0,i.jsx)("span",{className:e.valueClassName,children:e.value})}),(0,i.jsx)("div",{className:"mt-1 font-sans text-xs leading-relaxed text-dashboard-text-muted",children:e.label})]})}function Te(e){let t=e.bucketUnit??"day",a=Ee(e.days),s=Math.max(1,...e.days.map(r=>r.requests)),d=[0,Math.floor((e.days.length-1)/2),e.days.length-1].filter((r,m,x)=>r>=0&&x.indexOf(r)===m);return(0,i.jsxs)(p,{children:[(0,i.jsxs)("div",{className:"border-b border-dashboard-border-subtle px-4 py-4",children:[(0,i.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h3",{className:"m-0 font-sans text-xs font-medium text-dashboard-text-muted",children:"Guardian reviews"}),(0,i.jsxs)("p",{className:"mt-1 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted",children:[B(t)," decisions before reviewed actions execute."]})]}),(0,i.jsxs)("div",{className:"font-sans font-medium text-xs text-dashboard-text-muted",children:[(0,i.jsx)("span",{className:"mr-3 text-emerald-200/75",children:"Allow"}),(0,i.jsx)("span",{className:"mr-3 text-amber-200/75",children:"Ask"}),(0,i.jsx)("span",{className:"text-rose-200/75",children:"Deny"})]})]}),(0,i.jsxs)("div",{className:"mt-4 grid grid-cols-2 gap-2 sm:grid-cols-5",children:[(0,i.jsx)(R,{label:"Requests",value:f(a.requests)}),(0,i.jsx)(R,{label:"Allowed",value:f(a.allow),valueClassName:"text-emerald-100"}),(0,i.jsx)(R,{label:"Asked",value:f(a.ask),valueClassName:"text-amber-100"}),(0,i.jsx)(R,{label:"Denied",value:f(a.deny),valueClassName:"text-rose-100"}),(0,i.jsx)(R,{label:"Estimated cost",value:k({total:a.costUsd})})]})]}),(0,i.jsxs)("div",{className:"px-4 pt-5 pb-3",children:[(0,i.jsx)("div",{"aria-label":`${B(t)} Guardian review results`,className:"flex h-36 items-end gap-px",role:"img",children:e.days.map(r=>{let m=Math.max(2,r.requests/s*100);return(0,i.jsx)(pe,{content:(0,i.jsxs)("div",{className:"grid grid-cols-[auto_auto] gap-x-4",children:[(0,i.jsx)("span",{children:"Allow"}),(0,i.jsx)("span",{className:"text-right",children:r.allow}),(0,i.jsx)("span",{children:"Ask"}),(0,i.jsx)("span",{className:"text-right",children:r.ask}),(0,i.jsx)("span",{children:"Deny"}),(0,i.jsx)("span",{className:"text-right",children:r.deny}),(0,i.jsx)("span",{children:"Cost"}),(0,i.jsx)("span",{className:"text-right",children:k({total:r.costUsd??0})})]}),date:r.date,summary:`${r.allow} allowed, ${r.ask} asked, ${r.deny} denied, ${k({total:r.costUsd??0})}`,children:(0,i.jsxs)("button",{className:"flex min-w-0 flex-1 flex-col justify-end overflow-hidden rounded-t-sm bg-dashboard-fill-soft focus-visible:outline-1 focus-visible:outline-dashboard-focus",style:{height:`${m}%`},type:"button",children:[r.deny?(0,i.jsx)("span",{className:"block w-full bg-rose-400/75",style:{flex:r.deny}}):null,r.ask?(0,i.jsx)("span",{className:"block w-full bg-amber-300/75",style:{flex:r.ask}}):null,r.allow?(0,i.jsx)("span",{className:"block w-full bg-emerald-300/70",style:{flex:r.allow}}):null]})},r.date)})}),(0,i.jsx)("div",{className:"relative mt-2 h-4",children:d.map(r=>{let m=e.days[r];return m?(0,i.jsx)(oe,{className:"absolute -translate-x-1/2",style:{left:`${(r+.5)/e.days.length*100}%`},children:ne(m.date)},m.date):null})})]})]})}var h=u(b(),1);function Ie(e){return e.reduce((t,a)=>({conversations:t.conversations+a.conversations,costUsd:t.costUsd+(a.costUsd??0),tokens:t.tokens+(a.tokens??0)}),{conversations:0,costUsd:0,tokens:0})}function De(e){if(!e.stats)return(0,h.jsx)(p,{padding:"sm",children:(0,h.jsx)(X,{children:e.error?"Conversation metrics failed to load.":e.loading?"Loading conversation metrics.":"No conversation metrics have been reported yet."})});let t=$({days:e.stats.metricDays,hours:e.stats.metricHours,sixHours:e.stats.metricSixHours,range:e.range,emptySixHour:r=>({conversations:0,date:r,durationMs:0})}),a=$({days:e.stats.guardian.metricDays,hours:e.stats.guardian.metricHours,sixHours:e.stats.guardian.metricSixHours,range:e.range,emptySixHour:r=>({allow:0,ask:0,date:r,deny:0,requests:0})}),s=Ie(t),d=J(e.range);return(0,h.jsxs)("section",{"aria-label":"Runtime telemetry",className:"grid gap-4",children:[e.error?(0,h.jsx)("p",{className:"m-0 font-sans text-xs text-rose-200/65",children:"Metrics refresh failed. Showing cached data."}):null,(0,h.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[(0,h.jsx)(A,{detail:`Root conversations in the ${Y(e.range)}`,icon:I,label:"Conversations",value:f(s.conversations)}),(0,h.jsx)(A,{detail:"All recorded model tokens",icon:K,label:"Tokens",value:f(s.tokens)}),(0,h.jsx)(A,{detail:"Estimated model cost",icon:q,label:"Model spend",value:k({total:s.costUsd})})]}),(0,h.jsx)(he,{bucketUnit:d,cacheBreakdown:!0,days:t}),(0,h.jsx)(Pe,{bucketUnit:d,days:t}),(0,h.jsx)(Te,{bucketUnit:d,days:a})]})}var n=u(b(),1);function Yt(e){let[t,a]=(0,Ae.useState)(30),s=_(),d=e.data.pluginReports?.reports??[],r=Z({plugins:e.data.plugins,reports:d,skills:e.data.skills}),m=ee(s.pathname),x=m===T,S=r.find(Me=>D(Me.name)===m),z=m.startsWith(`${T}/`);return z&&!S&&e.data.pluginReportsLoading?(0,n.jsx)(ae,{description:"Loading plugin details and operational reports.",label:"Loading plugin",title:"Plugin"}):z&&!S?(0,n.jsx)(U,{replace:!0,to:T}):m!=="/system"&&!x&&!S?(0,n.jsx)(U,{replace:!0,to:"/system"}):(0,n.jsx)(te,{children:S?(0,n.jsx)(je,{data:e.data,onRangeChange:a,plugin:S,range:t}):x?(0,n.jsx)(Ke,{data:e.data,plugins:r}):(0,n.jsx)(Oe,{data:e.data,range:t,onRangeChange:a})})}function Oe(e){return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(P,{description:`A live read on ${W()} runtime and model usage.`,onRangeChange:e.onRangeChange,range:e.range,title:"System"}),(0,n.jsx)(De,{error:e.data.conversationStatsError,range:e.range,loading:e.data.conversationStatsLoading,stats:e.data.conversationStats})]})}function Ke(e){return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(P,{description:`Loaded capabilities and operational reports for ${w()}.`,title:"Plugins"}),e.data.pluginReportsError?(0,n.jsx)(Ue,{showingReports:e.plugins.some(t=>t.reports.length)}):null,(0,n.jsx)(Ce,{plugins:e.plugins}),e.data.skills.length?(0,n.jsx)(Re,{skills:e.data.skills}):null]})}function je(e){let t=e.plugin.reports,a=t.some(s=>s.widgets?.some(d=>d.timeRangeDays?.length));return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(P,{description:e.plugin.description,...a?{onRangeChange:e.onRangeChange,range:e.range}:{},title:e.plugin.displayName}),e.data.pluginReportsError?(0,n.jsx)(Ue,{showingReports:!!t.length}):null,(0,n.jsx)(ke,{plugin:e.plugin}),(0,n.jsx)(Se,{fallbackTitle:e.plugin.displayName,...!e.data.pluginReportsLoading&&!e.data.pluginReportsError?{emptyText:"This plugin does not expose operational activity yet."}:{},range:e.range,reports:t})]})}function Ue(e){return(0,n.jsx)(p,{className:"border-amber-300/10 bg-amber-300/[0.025]",padding:"sm",children:(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("div",{className:"grid size-9 shrink-0 place-items-center rounded-md border border-amber-300/15 bg-amber-300/[0.055] text-amber-200/70",children:(0,n.jsx)(j,{"aria-hidden":"true",size:15})}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"font-display text-sm font-medium text-dashboard-text-muted",children:"Plugin stats failed to load."}),(0,n.jsx)("div",{className:"mt-1 font-sans text-xs leading-relaxed text-dashboard-text-muted",children:e.showingReports?`Showing the last operational reports ${w()} received.`:"Plugin details and capabilities are still available."})]})]})})}export{Yt as SystemPage};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as M,b as R,c as q,d as F,e as G,f as H}from"./chunk-
|
|
1
|
+
import{a as M,b as R,c as q,d as F,e as G,f as H}from"./chunk-6FHY65EQ.js";import{a as m,b as l,c as W,e as A}from"./chunk-PQPAPPEI.js";import{a as C}from"./chunk-TC7TU4GK.js";import"./chunk-UT6HZPGL.js";import{b as J}from"./chunk-J37MXUED.js";import{a as V}from"./chunk-XNR4RZEC.js";import"./chunk-TFJOEF3Q.js";import"./chunk-DEEO4D4N.js";import"./chunk-KDUTK357.js";import{e as K}from"./chunk-564V7YHG.js";import{N}from"./chunk-II4NXLSQ.js";import{l as h}from"./chunk-MEHLQZDG.js";import"./chunk-MTBUV2GJ.js";import{d as E,i as L,r as Q,s as B}from"./chunk-4TQSTCIN.js";import{Ha as D,Ka as w}from"./chunk-XDUSY26N.js";import"./chunk-QPBLZSNX.js";import"./chunk-RHMZNAJX.js";import"./chunk-GOTQ4D6W.js";import{M as z,f as O,g as I,o as $}from"./chunk-6PHJZPWD.js";import"./chunk-VC6IS564.js";import"./chunk-B5ZN3SWQ.js";import{a as _,b as x}from"./chunk-CR2ICLSH.js";import{Hc as U,a as re,b,pc as T}from"./chunk-YPMUHXYT.js";import{c as v}from"./chunk-7SZRL6FY.js";var k=v(re(),1);function y(){return{key:crypto.randomUUID(),provider:"github",repo:""}}function Y(){return{name:"",setupScript:"",vcpus:"",repos:[y()]}}function X(e){return{name:e.name,setupScript:e.setupScript,vcpus:e.vcpus===null?"":String(e.vcpus),repos:e.repos.length>0?e.repos.map(r=>({key:`${r.provider}:${r.repo.toLowerCase()}`,provider:r.provider,repo:r.repo})):[y()]}}function Z(e){return{name:e.name.trim(),setupScript:e.setupScript,vcpus:e.vcpus.trim()?Number(e.vcpus.trim()):null,repos:e.repos.map(r=>({provider:r.provider.trim(),repo:r.repo.trim()}))}}function j(e,r){return!(r||!e.name.trim()||e.vcpus.trim()&&!/^[1-9]\d*$/.test(e.vcpus.trim())||e.repos.some(p=>!p.provider.trim()||!p.repo.trim()))}var a=v(b(),1);function ee(e){function r(t,s){e.onChange({...e.draft,repos:e.draft.repos.map(o=>o.key===t?{...o,...s}:o)})}function p(t){let s=e.draft.repos.filter(o=>o.key!==t);e.onChange({...e.draft,repos:s.length>0?s:[y()]})}function u(t){t.preventDefault(),e.canSave&&e.onSubmit()}return(0,a.jsx)(w,{className:"mb-0",padding:"md",variant:"section",children:(0,a.jsxs)("form",{className:"grid gap-6",onSubmit:u,children:[(0,a.jsxs)(m,{children:[(0,a.jsx)(l,{htmlFor:"workspace-name",children:"Name"}),(0,a.jsx)(h,{autoComplete:"off",id:"workspace-name",maxLength:64,onChange:t=>e.onChange({...e.draft,name:t.target.value}),placeholder:"sentry",value:e.draft.name}),(0,a.jsx)(W,{id:"workspace-name-help",children:"Lowercase name used when agents switch into this Workspace."})]}),(0,a.jsxs)("section",{className:"grid gap-3","aria-labelledby":"workspace-repos-title",children:[(0,a.jsxs)("div",{className:"grid gap-3 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-start sm:gap-4",children:[(0,a.jsxs)("div",{className:"min-w-0 grid gap-1",children:[(0,a.jsx)("h3",{className:"m-0 text-sm font-semibold text-dashboard-text",id:"workspace-repos-title",children:"Repositories"}),(0,a.jsxs)("p",{className:"m-0 text-xs leading-relaxed text-dashboard-text-muted sm:text-sm",children:["Each repository clones to a fixed"," ",(0,a.jsxs)("code",{className:"text-dashboard-text",children:["repos/","{name}"]})," ","path. Junior loads"," ",(0,a.jsx)("code",{className:"text-dashboard-text",children:"AGENTS.md"})," from each repository and labels those instructions with that directory."]})]}),(0,a.jsxs)(x,{className:"w-full sm:w-auto",disabled:e.busy,onClick:()=>e.onChange({...e.draft,repos:[...e.draft.repos,y()]}),type:"button",children:[(0,a.jsx)(T,{"aria-hidden":"true",size:14}),"Add repository"]})]}),(0,a.jsx)("div",{className:"grid gap-3",children:e.draft.repos.map((t,s)=>(0,a.jsx)("div",{className:"grid gap-3 rounded-lg border border-dashboard-border-strong bg-dashboard-overlay-soft p-3 sm:p-4",children:(0,a.jsxs)("div",{className:"grid gap-3 sm:grid-cols-[minmax(0,8.5rem)_minmax(0,1fr)_auto] sm:items-end",children:[(0,a.jsxs)(m,{className:"gap-1.5",children:[(0,a.jsx)(l,{htmlFor:`workspace-repo-provider-${t.key}`,className:"font-sans text-xs font-medium text-dashboard-text-muted",children:"Provider"}),(0,a.jsx)(h,{"aria-label":`Provider ${s+1}`,id:`workspace-repo-provider-${t.key}`,onChange:o=>r(t.key,{provider:o.target.value}),placeholder:"github",value:t.provider})]}),(0,a.jsxs)(m,{className:"gap-1.5",children:[(0,a.jsx)(l,{htmlFor:`workspace-repo-name-${t.key}`,className:"font-sans text-xs font-medium text-dashboard-text-muted",children:"Repository"}),(0,a.jsx)(h,{"aria-label":`Repository ${s+1}`,id:`workspace-repo-name-${t.key}`,onChange:o=>r(t.key,{repo:o.target.value}),placeholder:"getsentry/sentry",value:t.repo})]}),(0,a.jsxs)(x,{"aria-label":`Remove repository ${s+1}`,className:"w-full sm:w-auto",onClick:()=>p(t.key),variant:"danger",type:"button",children:[(0,a.jsx)(U,{"aria-hidden":"true",size:14}),"Remove"]})]})},t.key))})]}),(0,a.jsxs)(m,{children:[(0,a.jsx)(l,{htmlFor:"workspace-setup",children:"Setup script"}),(0,a.jsx)(A,{className:"font-mono",id:"workspace-setup",onChange:t=>e.onChange({...e.draft,setupScript:t.target.value}),placeholder:`pnpm install --dir "$JUNIOR_REPOS_ROOT/sentry"
|
|
2
2
|
# cwd is $JUNIOR_WORKSPACE_ROOT`,value:e.draft.setupScript}),(0,a.jsx)(W,{id:"workspace-setup-help",children:(0,a.jsxs)(a.Fragment,{children:["Runs once while Junior builds the reusable snapshot. Current working directory is"," ",(0,a.jsx)("code",{className:"text-dashboard-text",children:"$JUNIOR_WORKSPACE_ROOT"})," ","(the Sandbox root, usually"," ",(0,a.jsx)("code",{className:"text-dashboard-text",children:"/vercel/sandbox"}),"). Cloned repositories live under"," ",(0,a.jsx)("code",{className:"text-dashboard-text",children:"$JUNIOR_REPOS_ROOT"})," (",(0,a.jsx)("code",{className:"text-dashboard-text",children:"$JUNIOR_WORKSPACE_ROOT/repos"}),"). Use those variables instead of hard-coded absolute paths."]})})]}),(0,a.jsxs)(m,{children:[(0,a.jsx)(l,{htmlFor:"workspace-vcpus",children:"vCPUs"}),(0,a.jsx)(h,{autoComplete:"off",id:"workspace-vcpus",inputMode:"numeric",onChange:t=>e.onChange({...e.draft,vcpus:t.target.value}),placeholder:M(e.defaultVcpus),value:e.draft.vcpus}),(0,a.jsx)(W,{id:"workspace-vcpus-help",children:"Sandbox vCPUs for this Workspace. Each vCPU adds 2 GB of memory. Leave empty to use the app default."})]}),e.error?(0,a.jsx)(V,{children:e.error}):null,(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-3 border-t border-dashboard-border-subtle pt-5",children:[(0,a.jsx)(x,{disabled:!e.canSave,type:"submit",variant:"primary",children:e.busy?"Saving\u2026":e.editing?"Save changes":"Create Workspace"}),(0,a.jsx)($,{className:_(),to:e.cancelPath,children:"Cancel"}),(0,a.jsx)("p",{className:"m-0 text-xs text-dashboard-text-muted",children:e.editing?"Saved changes apply the next time this Workspace is prepared.":"You can edit repositories and setup after create."})]})]})})}var i=v(b(),1);function Pe(){let{workspaceId:e}=I(),r=e!==void 0,p=O(),u=E(),[t,s]=(0,k.useState)(Y),[o,P]=(0,k.useState)(),n=H(e),ae=G().data?.defaultVcpus??null;(0,k.useEffect)(()=>{!r||!e||!n.data||o?.workspaceId!==e&&P({draft:X(n.data),workspaceId:e})},[r,o?.workspaceId,e,n.data]);let f=r?o?.workspaceId===e?o.draft:void 0:t,g=L({mutationFn:async d=>{let c=Z(d);return r?B(D,`/api/workspaces/${encodeURIComponent(e)}`,c):Q(D,"/api/workspaces",c)},onSuccess:async d=>{await u.cancelQueries({queryKey:R}),u.setQueryData(R,c=>c&&{...c,workspaces:[d,...c.workspaces.filter(S=>S.id!==d.id)].sort((S,te)=>S.name.localeCompare(te.name))}),await u.invalidateQueries({queryKey:q(d.id)}),p(N(d.id))}});return r&&!n.error&&(!n.data||!f)?(0,i.jsx)(C,{children:(0,i.jsx)(J,{label:"Loading Workspace"})}):(0,i.jsx)(C,{children:(0,i.jsxs)("div",{className:"grid min-w-0 gap-4 sm:gap-5",children:[(0,i.jsx)(z,{description:r?"Change the repositories, setup script, or Sandbox size.":"Name the recipe, choose repositories, and optionally add a one-time setup script.",title:r?n.data?.name??"Workspace":"New Workspace"}),n.error?(0,i.jsx)(w,{padding:"sm",children:(0,i.jsx)(K,{children:F(n.error,"Workspace not found. It may have been deleted.")})}):f?(0,i.jsx)(ee,{busy:g.isPending,canSave:j(f,g.isPending),cancelPath:e?N(e):"/system/workspaces",defaultVcpus:ae,draft:f,editing:r,error:g.error?F(g.error,"Could not save the Workspace. Try again."):void 0,onChange:r?d=>P({draft:d,workspaceId:e}):s,onSubmit:()=>g.mutate(f)}):null]})})}export{Pe as WorkspaceFormPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as y,b as z,c as We,d as Te,e as Re,f as Ae}from"./chunk-WZVO3HG4.js";import{a as Le}from"./chunk-BKOACADP.js";import{a as Ee}from"./chunk-SIOW7OOW.js";import{a as Se}from"./chunk-H2ZU34CP.js";import{a as ge,c as he,f as be,o as ke,p as ye,q as xe,r as we,s as ve,t as De,w as Ne,x as Ce}from"./chunk-V5UDSIRA.js";import{a as de,b as w}from"./chunk-4AKUZW6R.js";import{b as j}from"./chunk-GYRM5ZIV.js";import{a as ae,b as oe,c as re,d as se,e as ne,f as ie,g as le}from"./chunk-5GZDBGAR.js";import{c as ce}from"./chunk-Z2JPRGFT.js";import"./chunk-NQOJAZFQ.js";import{e as fe}from"./chunk-UT6HZPGL.js";import"./chunk-FE522UEA.js";import"./chunk-G5NWYJTV.js";import"./chunk-TFJOEF3Q.js";import{a as V,b as C}from"./chunk-EFEREKX4.js";import{e as k}from"./chunk-564V7YHG.js";import{s as Y}from"./chunk-QNA7F7QB.js";import"./chunk-B6HGRBBX.js";import{N as R,f as S,g as W,h as T,r as ee,s as te}from"./chunk-NQMDED2R.js";import{i as E,j as P,l as U}from"./chunk-GMZIELFU.js";import"./chunk-MTBUV2GJ.js";import{d as M,i as $,p as X}from"./chunk-GO45RQDL.js";import{Ja as b}from"./chunk-VXT3FIVL.js";import"./chunk-QPBLZSNX.js";import"./chunk-RHMZNAJX.js";import{a as ue}from"./chunk-GOTQ4D6W.js";import{E as me,M as pe,f as I,g as H,o as D,s as Z}from"./chunk-6PHJZPWD.js";import"./chunk-IZWTFLCC.js";import"./chunk-JAZABOBA.js";import"./chunk-WRXMQB7X.js";import"./chunk-CQY6BYUB.js";import"./chunk-VC6IS564.js";import"./chunk-B5ZN3SWQ.js";import{a as N,b as Q}from"./chunk-CR2ICLSH.js";import{Fb as _,Hc as q,Rc as J,a as F,b as u,kb as O,lc as G,pc as K}from"./chunk-YPMUHXYT.js";import{c as m}from"./chunk-7SZRL6FY.js";var v=m(F(),1);var s=m(u(),1);function Pe(e){let t=e.snapshot;return(0,s.jsx)(b,{as:"section",className:"mb-0",padding:"md",variant:"section",children:(0,s.jsxs)("div",{"aria-labelledby":"base-sandbox-heading",className:"grid gap-4",children:[(0,s.jsxs)("div",{className:"min-w-0 grid gap-1",children:[(0,s.jsx)("h2",{className:"m-0 text-base font-semibold text-dashboard-text",id:"base-sandbox-heading",children:"Base Sandbox"}),(0,s.jsx)("p",{className:"m-0 text-sm leading-relaxed text-dashboard-text-muted",children:"The base snapshot is inherited by all Workspaces."})]}),(0,s.jsxs)("dl",{className:"m-0 grid grid-cols-[max-content_minmax(0,1fr)] gap-x-6 gap-y-2 text-sm",children:[(0,s.jsx)(x,{label:"Size",children:y(e.defaultVcpus)}),t?(0,s.jsxs)(s.Fragment,{children:[t.dependencyCount==null?null:(0,s.jsx)(x,{label:"Dependencies",children:t.dependencyCount}),(0,s.jsx)(x,{label:"Build time",children:T(t.buildDurationMs)}),(0,s.jsx)(x,{label:"Generated",children:(0,s.jsx)("span",{title:S(t.generatedAt),children:W(t.generatedAt)})}),(0,s.jsx)(x,{label:"Snapshot",children:(0,s.jsx)("span",{className:"break-all font-mono text-xs",children:t.id})})]}):(0,s.jsx)(x,{label:"Snapshot",children:(0,s.jsx)("span",{className:"text-dashboard-text-muted",children:"Not built yet. The first Sandbox without a Workspace builds it."})})]})]})})}function x(e){return(0,s.jsxs)("div",{className:"contents",children:[(0,s.jsx)("dt",{className:"text-dashboard-text-muted",children:e.label}),(0,s.jsx)("dd",{className:"m-0 min-w-0 tabular-nums text-dashboard-text",children:e.children})]})}var Ue=m(F(),1);var f=m(u(),1);function Ve(e){let[t,o]=(0,Ue.useState)(!0),n=M(),p=j(),c=$({mutationFn:()=>X(`/api/workspaces/${encodeURIComponent(e.workspace.id)}`),onSuccess:async()=>{await n.cancelQueries({queryKey:z}),n.setQueryData(z,r=>r&&{...r,workspaces:r.workspaces.filter(g=>g.id!==e.workspace.id)}),e.onDeleted(),n.removeQueries({queryKey:We(e.workspace.id)}),p.add({title:"Workspace deleted",description:e.workspace.name,type:"success"}),o(!1)}});return(0,f.jsx)(ae,{open:t,onOpenChange:(r,g)=>{c.isPending?g.cancel():o(r)},onOpenChangeComplete:r=>{r||e.onClose()},children:(0,f.jsxs)(oe,{finalFocus:e.returnFocus,children:[(0,f.jsx)(re,{children:"Delete Workspace?"}),(0,f.jsxs)(se,{children:["Delete"," ",(0,f.jsx)("strong",{className:"font-medium text-dashboard-text",children:e.workspace.name}),"? Active conversations keep their current Sandbox until the next switch."]}),c.error?(0,f.jsx)(Le,{tone:"error",title:Te(c.error,"Could not delete the Workspace. Try again.")}):null,(0,f.jsxs)(ne,{children:[(0,f.jsx)(le,{disabled:c.isPending,children:"Cancel"}),(0,f.jsx)(ie,{disabled:c.isPending,onClick:()=>c.mutate(),variant:"danger",children:c.isPending?"Deleting\u2026":"Delete Workspace"})]})]})})}var d=m(u(),1),ze="var(--color-violet-400)",Oe={count:{color:ze,label:"Usage"}};function Be(e){let t=e.days.map(r=>r.count),o=Math.max(1,...t),n=we(t),p=t.reduce((r,g)=>r+g,0),c=p>0;return(0,d.jsxs)(b,{children:[(0,d.jsx)(Se,{description:`Successful switches into \u201C${e.workspaceName}\u201D.`,title:"Usage",total:ee(p),totalLabel:`last ${e.range} days`}),(0,d.jsxs)("div",{className:"relative px-2 py-3 sm:px-4 sm:py-4",children:[(0,d.jsx)(Ne,{className:"aspect-auto h-50 w-full",config:Oe,children:(0,d.jsxs)(be,{"aria-label":`Usage for ${e.workspaceName} during the last ${e.range} days`,data:e.days,margin:ke,role:"img",children:[(0,d.jsx)(ge,{strokeDasharray:"3 5",vertical:!1}),(0,d.jsx)(xe,{maximum:o}),(0,d.jsx)(ye,{keys:e.days.map(r=>r.date)}),(0,d.jsx)(Ce,{content:(0,d.jsx)(De,{rows:r=>[["usage",r.count]]})}),(0,d.jsx)(he,{dataKey:"count",fill:"var(--color-count)",fillOpacity:.82,isAnimationActive:!1,maxBarSize:13,minPointSize:r=>r?2:0,radius:2}),(0,d.jsx)(ve,{average:n,format:te,stroke:ze})]})}),c?null:(0,d.jsx)("div",{className:"pointer-events-none absolute inset-0 grid place-items-center pt-12 font-sans text-xs text-dashboard-text-muted",children:"No usage in this period."})]})]})}function _e(e,t=Date.now()){let o=new Date(t);return o.setUTCHours(0,0,0,0),Array.from({length:e},(n,p)=>{let c=new Date(o);return c.setUTCDate(o.getUTCDate()-(e-1-p)),c.toISOString().slice(0,10)})}function Fe(e){let t=new Map;for(let o of e.stats)o.namespace!=="junior"||o.metric!=="workspace_switch"||o.name!==e.workspaceId||t.set(o.date,(t.get(o.date)??0)+o.count);return _e(e.range,e.nowMs).map(o=>({count:t.get(o)??0,date:o}))}var a=m(u(),1),Me=30;function $e(e){let t=Ae(e.workspaceId),o=Y(),n=t.data??e.workspace,p=!n&&(t.isError||e.listError);return(0,a.jsx)(ce,{actions:n?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(E,{children:[(0,a.jsx)(P,{render:(0,a.jsx)(D,{"aria-label":`Edit ${n.name}`,className:N({size:"icon"}),to:`${R(n.id)}/edit`,children:(0,a.jsx)(G,{"aria-hidden":"true",size:15})})}),(0,a.jsx)(U,{size:"compact",children:"Edit Workspace"})]}),(0,a.jsxs)(E,{children:[(0,a.jsx)(P,{render:(0,a.jsx)(Q,{"aria-label":`Delete ${n.name}`,onClick:c=>e.onDelete(n,c.currentTarget),size:"icon",children:(0,a.jsx)(q,{"aria-hidden":"true",size:15})})}),(0,a.jsx)(U,{size:"compact",children:"Delete Workspace"})]})]}):void 0,label:"Workspace details",onClose:e.onClose,sheetTitle:n?.name,title:(0,a.jsx)("h2",{className:"m-0 break-words font-display text-base font-medium text-dashboard-text",children:n?.name??"Workspace details"}),children:(0,a.jsx)("div",{className:"p-4 [overflow-wrap:anywhere]",children:n?(0,a.jsx)(Ge,{defaultVcpus:e.defaultVcpus,error:!!o.error,loading:o.isPending,snapshot:t.data?"ready":t.isError?"error":"loading",stats:o.data,workspace:n}):p?(0,a.jsx)(k,{children:"Workspace not found. It may have been deleted."}):(0,a.jsx)(C,{label:"Loading Workspace details",variant:"panel"})})})}function Ge(e){let{workspace:t}=e;return(0,a.jsxs)("div",{className:"grid min-w-0 gap-4",children:[(0,a.jsxs)(de,{children:[(0,a.jsx)(w,{label:"Repositories",children:t.repos.length===0?(0,a.jsx)("span",{className:"text-dashboard-text-muted",children:"None"}):(0,a.jsx)("ul",{className:"m-0 grid list-none gap-1.5 p-0",children:t.repos.map(o=>(0,a.jsxs)("li",{className:"min-w-0",children:[(0,a.jsxs)("span",{className:"block font-mono text-xs text-dashboard-text",children:[o.provider,":",o.repo]}),(0,a.jsx)("span",{className:"block font-mono text-xs text-dashboard-text-muted",children:o.checkoutPath})]},`${o.provider}:${o.repo}`))})}),(0,a.jsxs)(w,{label:"Sandbox size",children:[y(t.vcpus??e.defaultVcpus),t.vcpus===null?(0,a.jsx)("span",{className:"text-dashboard-text-muted",children:" \xB7 default"}):null]}),(0,a.jsx)(w,{label:"Snapshot",children:(0,a.jsx)(Ke,{state:e.snapshot,workspace:t})}),(0,a.jsx)(w,{label:"Setup script",children:t.setupScript.trim()?(0,a.jsx)("pre",{className:"m-0 max-h-48 overflow-auto whitespace-pre-wrap rounded-md bg-dashboard-fill-soft p-2 font-mono text-xs leading-relaxed text-dashboard-text",children:t.setupScript}):(0,a.jsx)("span",{className:"text-dashboard-text-muted",children:"None"})})]}),e.stats?(0,a.jsxs)("div",{className:"grid min-w-0 gap-3",children:[e.error?(0,a.jsx)("p",{className:"m-0 font-sans text-xs text-rose-200/65",children:"Workspace usage refresh failed. Showing cached data."}):null,(0,a.jsx)(Be,{days:Fe({workspaceId:t.id,range:Me,stats:e.stats.stats}),range:Me,workspaceName:t.name})]}):(0,a.jsx)(k,{children:e.error?"Workspace usage failed to load.":e.loading?"Loading Workspace usage.":"No usage in this period."})]})}function Ke(e){if(e.state==="loading")return(0,a.jsxs)("span",{className:"grid gap-1.5",role:"status",children:[(0,a.jsx)("span",{className:"sr-only",children:"Loading snapshot"}),(0,a.jsx)(V,{className:"h-4 w-36"}),(0,a.jsx)(V,{className:"h-3.5 w-48"})]});if(e.state==="error")return(0,a.jsx)("span",{className:"text-dashboard-text-muted",children:"Snapshot status could not be loaded."});let t=e.workspace.snapshot;return t?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("span",{className:"block tabular-nums",children:[(0,a.jsx)("span",{title:S(t.generatedAt),children:W(t.generatedAt)})," ","\xB7 built in ",T(t.buildDurationMs)]}),(0,a.jsx)("span",{className:"block break-all font-mono text-xs text-dashboard-text-muted",children:t.id})]}):(0,a.jsx)("span",{className:"text-dashboard-text-muted",children:"Not built yet. The first successful prepare builds it."})}var l=m(u(),1);function Ie(e){return(0,l.jsx)(b,{padding:"none",children:e.workspaces.length===0?(0,l.jsx)("div",{className:"p-5",children:(0,l.jsx)(k,{children:"No Workspaces yet. Create one so agents can switch into a prepared multi-repo Sandbox."})}):(0,l.jsx)("ul",{className:"m-0 list-none p-0",children:e.workspaces.map(t=>(0,l.jsx)(qe,{defaultVcpus:e.defaultVcpus,onSelect:()=>e.onSelect(t),selected:t.id===e.selectedId,workspace:t},t.id))})})}function qe(e){let{workspace:t}=e;return(0,l.jsx)("li",{className:"border-b border-dashboard-border-subtle last:border-b-0","data-workspace-id":t.id,children:(0,l.jsx)(Ee,{className:"px-4 py-3.5",onSelect:e.onSelect,selected:e.selected,children:(0,l.jsxs)("button",{"aria-expanded":e.selected,"aria-label":`View Workspace details: ${t.name}`,className:"flex w-full min-w-0 cursor-pointer items-center gap-3 rounded-md border-0 bg-transparent p-0 text-left focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus",onClick:e.onSelect,type:"button",children:[(0,l.jsx)("span",{className:"grid size-9 shrink-0 place-items-center rounded-md border border-dashboard-border-strong bg-dashboard-fill-soft text-dashboard-accent transition-colors group-hover:border-dashboard-accent/20 group-hover:bg-dashboard-accent/[0.06] group-hover:text-dashboard-accent-text",children:(0,l.jsx)(_,{"aria-hidden":"true",size:16})}),(0,l.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,l.jsxs)("span",{className:"flex flex-wrap items-center gap-2",children:[(0,l.jsx)("span",{className:"font-display text-base font-medium leading-tight text-dashboard-text",children:t.name}),(0,l.jsxs)("span",{className:"font-mono text-xs text-dashboard-text-muted",children:[t.repos.length," repo",t.repos.length===1?"":"s"," \xB7"," ",y(t.vcpus??e.defaultVcpus)]})]}),(0,l.jsx)("span",{className:"mt-1.5 block truncate font-mono text-xs text-dashboard-text-muted",children:t.repos.length?t.repos.map(o=>`${o.provider}:${o.repo}`).join(" \xB7 "):"No repositories"})]}),(0,l.jsx)(O,{"aria-hidden":"true",className:"shrink-0 text-dashboard-text-muted transition-transform group-hover:translate-x-0.5 group-hover:text-dashboard-text",size:16})]})})})}var i=m(u(),1),A="/system/workspaces";function ea(){let{workspaceId:e}=H(),t=I(),o=(0,v.useRef)(null),n=(0,v.useRef)(null),[p,c]=(0,v.useState)(),r=Re(),g=r.data?.workspaces??[],L=r.data?.defaultVcpus??null,B=g.find(h=>h.id===e);me(B?.name??"Workspaces");let He=()=>{let h=e?o.current?.querySelector(`[data-workspace-id="${CSS.escape(e)}"] button`):void 0;t(A),(h??o.current)?.focus()};return(0,i.jsxs)(fe,{className:"grid h-full min-h-0 grid-rows-[auto_minmax(0,1fr)] md:grid-rows-[minmax(0,1fr)]",children:[(0,i.jsxs)("div",{className:J("grid h-full min-h-0 min-w-0",e&&"xl:grid-cols-[minmax(0,1fr)_25rem]"),children:[(0,i.jsx)("div",{"aria-label":"Workspaces list",className:"min-h-0 overflow-y-auto overscroll-contain outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus",ref:o,role:"region",tabIndex:0,children:(0,i.jsxs)(ue,{children:[(0,i.jsx)(pe,{actions:(0,i.jsxs)(D,{className:N(),to:`${A}/new`,children:[(0,i.jsx)(K,{"aria-hidden":"true",size:14}),"New Workspace"]}),description:`Named repository recipes ${Z()} can switch into without cloning each turn.`,title:"Workspaces"}),r.error?(0,i.jsx)(b,{padding:"sm",children:(0,i.jsx)(k,{children:"Workspaces failed to load. Try refreshing the dashboard."})}):r.data?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(Pe,{defaultVcpus:L,snapshot:r.data.baselineSnapshot}),(0,i.jsx)(Ie,{defaultVcpus:L,onSelect:h=>t(h.id===e?A:R(h.id)),selectedId:e,workspaces:g})]}):(0,i.jsx)(C,{label:"Loading Workspaces",variant:"list"})]})}),e?(0,i.jsx)($e,{defaultVcpus:L,listError:!!r.error,onClose:He,onDelete:(h,Qe)=>{n.current=Qe,c(h)},workspace:B,workspaceId:e},e):null]}),p?(0,i.jsx)(Ve,{onClose:()=>c(void 0),onDeleted:()=>{e===p.id&&t(A)},returnFocus:()=>n.current?.isConnected?n.current:o.current??!1,workspace:p}):null]})}export{ea as WorkspacesPage};
|
|
1
|
+
import{a as y,b as z,c as We,d as Te,e as Re,f as Ae}from"./chunk-6FHY65EQ.js";import{a as Le}from"./chunk-BKOACADP.js";import{a as Ee}from"./chunk-SIOW7OOW.js";import{a as Se}from"./chunk-H2ZU34CP.js";import{a as ge,c as he,f as be,o as ke,p as ye,q as xe,r as we,s as ve,t as De,w as Ne,x as Ce}from"./chunk-K4TYMAA3.js";import{a as de,b as w}from"./chunk-4AKUZW6R.js";import{b as j}from"./chunk-GYRM5ZIV.js";import{a as ae,b as oe,c as re,d as se,e as ne,f as ie,g as le}from"./chunk-MKKFXRYO.js";import{c as ce}from"./chunk-WLIOZO3W.js";import"./chunk-JVJ5UWIK.js";import{e as fe}from"./chunk-UT6HZPGL.js";import"./chunk-FE522UEA.js";import"./chunk-G5NWYJTV.js";import"./chunk-TFJOEF3Q.js";import{a as V,b as C}from"./chunk-KDUTK357.js";import{e as k}from"./chunk-564V7YHG.js";import{s as Y}from"./chunk-64GPEGGE.js";import"./chunk-ILH47V7O.js";import{N as R,f as S,g as W,h as T,r as ee,s as te}from"./chunk-II4NXLSQ.js";import{i as E,j as P,l as U}from"./chunk-GMZIELFU.js";import"./chunk-MTBUV2GJ.js";import{d as M,i as $,t as X}from"./chunk-4TQSTCIN.js";import{Ka as b}from"./chunk-XDUSY26N.js";import"./chunk-QPBLZSNX.js";import"./chunk-RHMZNAJX.js";import{a as ue}from"./chunk-GOTQ4D6W.js";import{E as me,M as pe,f as I,g as H,o as D,s as Z}from"./chunk-6PHJZPWD.js";import"./chunk-IZWTFLCC.js";import"./chunk-JAZABOBA.js";import"./chunk-WRXMQB7X.js";import"./chunk-CQY6BYUB.js";import"./chunk-VC6IS564.js";import"./chunk-B5ZN3SWQ.js";import{a as N,b as Q}from"./chunk-CR2ICLSH.js";import{Fb as _,Hc as q,Rc as J,a as F,b as u,kb as O,lc as G,pc as K}from"./chunk-YPMUHXYT.js";import{c as m}from"./chunk-7SZRL6FY.js";var v=m(F(),1);var s=m(u(),1);function Pe(e){let t=e.snapshot;return(0,s.jsx)(b,{as:"section",className:"mb-0",padding:"md",variant:"section",children:(0,s.jsxs)("div",{"aria-labelledby":"base-sandbox-heading",className:"grid gap-4",children:[(0,s.jsxs)("div",{className:"min-w-0 grid gap-1",children:[(0,s.jsx)("h2",{className:"m-0 text-base font-semibold text-dashboard-text",id:"base-sandbox-heading",children:"Base Sandbox"}),(0,s.jsx)("p",{className:"m-0 text-sm leading-relaxed text-dashboard-text-muted",children:"The base snapshot is inherited by all Workspaces."})]}),(0,s.jsxs)("dl",{className:"m-0 grid grid-cols-[max-content_minmax(0,1fr)] gap-x-6 gap-y-2 text-sm",children:[(0,s.jsx)(x,{label:"Size",children:y(e.defaultVcpus)}),t?(0,s.jsxs)(s.Fragment,{children:[t.dependencyCount==null?null:(0,s.jsx)(x,{label:"Dependencies",children:t.dependencyCount}),(0,s.jsx)(x,{label:"Build time",children:T(t.buildDurationMs)}),(0,s.jsx)(x,{label:"Generated",children:(0,s.jsx)("span",{title:S(t.generatedAt),children:W(t.generatedAt)})}),(0,s.jsx)(x,{label:"Snapshot",children:(0,s.jsx)("span",{className:"break-all font-mono text-xs",children:t.id})})]}):(0,s.jsx)(x,{label:"Snapshot",children:(0,s.jsx)("span",{className:"text-dashboard-text-muted",children:"Not built yet. The first Sandbox without a Workspace builds it."})})]})]})})}function x(e){return(0,s.jsxs)("div",{className:"contents",children:[(0,s.jsx)("dt",{className:"text-dashboard-text-muted",children:e.label}),(0,s.jsx)("dd",{className:"m-0 min-w-0 tabular-nums text-dashboard-text",children:e.children})]})}var Ue=m(F(),1);var f=m(u(),1);function Ve(e){let[t,o]=(0,Ue.useState)(!0),n=M(),p=j(),c=$({mutationFn:()=>X(`/api/workspaces/${encodeURIComponent(e.workspace.id)}`),onSuccess:async()=>{await n.cancelQueries({queryKey:z}),n.setQueryData(z,r=>r&&{...r,workspaces:r.workspaces.filter(g=>g.id!==e.workspace.id)}),e.onDeleted(),n.removeQueries({queryKey:We(e.workspace.id)}),p.add({title:"Workspace deleted",description:e.workspace.name,type:"success"}),o(!1)}});return(0,f.jsx)(ae,{open:t,onOpenChange:(r,g)=>{c.isPending?g.cancel():o(r)},onOpenChangeComplete:r=>{r||e.onClose()},children:(0,f.jsxs)(oe,{finalFocus:e.returnFocus,children:[(0,f.jsx)(re,{children:"Delete Workspace?"}),(0,f.jsxs)(se,{children:["Delete"," ",(0,f.jsx)("strong",{className:"font-medium text-dashboard-text",children:e.workspace.name}),"? Active conversations keep their current Sandbox until the next switch."]}),c.error?(0,f.jsx)(Le,{tone:"error",title:Te(c.error,"Could not delete the Workspace. Try again.")}):null,(0,f.jsxs)(ne,{children:[(0,f.jsx)(le,{disabled:c.isPending,children:"Cancel"}),(0,f.jsx)(ie,{disabled:c.isPending,onClick:()=>c.mutate(),variant:"danger",children:c.isPending?"Deleting\u2026":"Delete Workspace"})]})]})})}var d=m(u(),1),ze="var(--color-violet-400)",Oe={count:{color:ze,label:"Usage"}};function Be(e){let t=e.days.map(r=>r.count),o=Math.max(1,...t),n=we(t),p=t.reduce((r,g)=>r+g,0),c=p>0;return(0,d.jsxs)(b,{children:[(0,d.jsx)(Se,{description:`Successful switches into \u201C${e.workspaceName}\u201D.`,title:"Usage",total:ee(p),totalLabel:`last ${e.range} days`}),(0,d.jsxs)("div",{className:"relative px-2 py-3 sm:px-4 sm:py-4",children:[(0,d.jsx)(Ne,{className:"aspect-auto h-50 w-full",config:Oe,children:(0,d.jsxs)(be,{"aria-label":`Usage for ${e.workspaceName} during the last ${e.range} days`,data:e.days,margin:ke,role:"img",children:[(0,d.jsx)(ge,{strokeDasharray:"3 5",vertical:!1}),(0,d.jsx)(xe,{maximum:o}),(0,d.jsx)(ye,{keys:e.days.map(r=>r.date)}),(0,d.jsx)(Ce,{content:(0,d.jsx)(De,{rows:r=>[["usage",r.count]]})}),(0,d.jsx)(he,{dataKey:"count",fill:"var(--color-count)",fillOpacity:.82,isAnimationActive:!1,maxBarSize:13,minPointSize:r=>r?2:0,radius:2}),(0,d.jsx)(ve,{average:n,format:te,stroke:ze})]})}),c?null:(0,d.jsx)("div",{className:"pointer-events-none absolute inset-0 grid place-items-center pt-12 font-sans text-xs text-dashboard-text-muted",children:"No usage in this period."})]})]})}function _e(e,t=Date.now()){let o=new Date(t);return o.setUTCHours(0,0,0,0),Array.from({length:e},(n,p)=>{let c=new Date(o);return c.setUTCDate(o.getUTCDate()-(e-1-p)),c.toISOString().slice(0,10)})}function Fe(e){let t=new Map;for(let o of e.stats)o.namespace!=="junior"||o.metric!=="workspace_switch"||o.name!==e.workspaceId||t.set(o.date,(t.get(o.date)??0)+o.count);return _e(e.range,e.nowMs).map(o=>({count:t.get(o)??0,date:o}))}var a=m(u(),1),Me=30;function $e(e){let t=Ae(e.workspaceId),o=Y(),n=t.data??e.workspace,p=!n&&(t.isError||e.listError);return(0,a.jsx)(ce,{actions:n?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(E,{children:[(0,a.jsx)(P,{render:(0,a.jsx)(D,{"aria-label":`Edit ${n.name}`,className:N({size:"icon"}),to:`${R(n.id)}/edit`,children:(0,a.jsx)(G,{"aria-hidden":"true",size:15})})}),(0,a.jsx)(U,{size:"compact",children:"Edit Workspace"})]}),(0,a.jsxs)(E,{children:[(0,a.jsx)(P,{render:(0,a.jsx)(Q,{"aria-label":`Delete ${n.name}`,onClick:c=>e.onDelete(n,c.currentTarget),size:"icon",children:(0,a.jsx)(q,{"aria-hidden":"true",size:15})})}),(0,a.jsx)(U,{size:"compact",children:"Delete Workspace"})]})]}):void 0,label:"Workspace details",onClose:e.onClose,sheetTitle:n?.name,title:(0,a.jsx)("h2",{className:"m-0 break-words font-display text-base font-medium text-dashboard-text",children:n?.name??"Workspace details"}),children:(0,a.jsx)("div",{className:"p-4 [overflow-wrap:anywhere]",children:n?(0,a.jsx)(Ge,{defaultVcpus:e.defaultVcpus,error:!!o.error,loading:o.isPending,snapshot:t.data?"ready":t.isError?"error":"loading",stats:o.data,workspace:n}):p?(0,a.jsx)(k,{children:"Workspace not found. It may have been deleted."}):(0,a.jsx)(C,{label:"Loading Workspace details",variant:"panel"})})})}function Ge(e){let{workspace:t}=e;return(0,a.jsxs)("div",{className:"grid min-w-0 gap-4",children:[(0,a.jsxs)(de,{children:[(0,a.jsx)(w,{label:"Repositories",children:t.repos.length===0?(0,a.jsx)("span",{className:"text-dashboard-text-muted",children:"None"}):(0,a.jsx)("ul",{className:"m-0 grid list-none gap-1.5 p-0",children:t.repos.map(o=>(0,a.jsxs)("li",{className:"min-w-0",children:[(0,a.jsxs)("span",{className:"block font-mono text-xs text-dashboard-text",children:[o.provider,":",o.repo]}),(0,a.jsx)("span",{className:"block font-mono text-xs text-dashboard-text-muted",children:o.checkoutPath})]},`${o.provider}:${o.repo}`))})}),(0,a.jsxs)(w,{label:"Sandbox size",children:[y(t.vcpus??e.defaultVcpus),t.vcpus===null?(0,a.jsx)("span",{className:"text-dashboard-text-muted",children:" \xB7 default"}):null]}),(0,a.jsx)(w,{label:"Snapshot",children:(0,a.jsx)(Ke,{state:e.snapshot,workspace:t})}),(0,a.jsx)(w,{label:"Setup script",children:t.setupScript.trim()?(0,a.jsx)("pre",{className:"m-0 max-h-48 overflow-auto whitespace-pre-wrap rounded-md bg-dashboard-fill-soft p-2 font-mono text-xs leading-relaxed text-dashboard-text",children:t.setupScript}):(0,a.jsx)("span",{className:"text-dashboard-text-muted",children:"None"})})]}),e.stats?(0,a.jsxs)("div",{className:"grid min-w-0 gap-3",children:[e.error?(0,a.jsx)("p",{className:"m-0 font-sans text-xs text-rose-200/65",children:"Workspace usage refresh failed. Showing cached data."}):null,(0,a.jsx)(Be,{days:Fe({workspaceId:t.id,range:Me,stats:e.stats.stats}),range:Me,workspaceName:t.name})]}):(0,a.jsx)(k,{children:e.error?"Workspace usage failed to load.":e.loading?"Loading Workspace usage.":"No usage in this period."})]})}function Ke(e){if(e.state==="loading")return(0,a.jsxs)("span",{className:"grid gap-1.5",role:"status",children:[(0,a.jsx)("span",{className:"sr-only",children:"Loading snapshot"}),(0,a.jsx)(V,{className:"h-4 w-36"}),(0,a.jsx)(V,{className:"h-3.5 w-48"})]});if(e.state==="error")return(0,a.jsx)("span",{className:"text-dashboard-text-muted",children:"Snapshot status could not be loaded."});let t=e.workspace.snapshot;return t?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("span",{className:"block tabular-nums",children:[(0,a.jsx)("span",{title:S(t.generatedAt),children:W(t.generatedAt)})," ","\xB7 built in ",T(t.buildDurationMs)]}),(0,a.jsx)("span",{className:"block break-all font-mono text-xs text-dashboard-text-muted",children:t.id})]}):(0,a.jsx)("span",{className:"text-dashboard-text-muted",children:"Not built yet. The first successful prepare builds it."})}var l=m(u(),1);function Ie(e){return(0,l.jsx)(b,{padding:"none",children:e.workspaces.length===0?(0,l.jsx)("div",{className:"p-5",children:(0,l.jsx)(k,{children:"No Workspaces yet. Create one so agents can switch into a prepared multi-repo Sandbox."})}):(0,l.jsx)("ul",{className:"m-0 list-none p-0",children:e.workspaces.map(t=>(0,l.jsx)(qe,{defaultVcpus:e.defaultVcpus,onSelect:()=>e.onSelect(t),selected:t.id===e.selectedId,workspace:t},t.id))})})}function qe(e){let{workspace:t}=e;return(0,l.jsx)("li",{className:"border-b border-dashboard-border-subtle last:border-b-0","data-workspace-id":t.id,children:(0,l.jsx)(Ee,{className:"px-4 py-3.5",onSelect:e.onSelect,selected:e.selected,children:(0,l.jsxs)("button",{"aria-expanded":e.selected,"aria-label":`View Workspace details: ${t.name}`,className:"flex w-full min-w-0 cursor-pointer items-center gap-3 rounded-md border-0 bg-transparent p-0 text-left focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus",onClick:e.onSelect,type:"button",children:[(0,l.jsx)("span",{className:"grid size-9 shrink-0 place-items-center rounded-md border border-dashboard-border-strong bg-dashboard-fill-soft text-dashboard-accent transition-colors group-hover:border-dashboard-accent/20 group-hover:bg-dashboard-accent/[0.06] group-hover:text-dashboard-accent-text",children:(0,l.jsx)(_,{"aria-hidden":"true",size:16})}),(0,l.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,l.jsxs)("span",{className:"flex flex-wrap items-center gap-2",children:[(0,l.jsx)("span",{className:"font-display text-base font-medium leading-tight text-dashboard-text",children:t.name}),(0,l.jsxs)("span",{className:"font-mono text-xs text-dashboard-text-muted",children:[t.repos.length," repo",t.repos.length===1?"":"s"," \xB7"," ",y(t.vcpus??e.defaultVcpus)]})]}),(0,l.jsx)("span",{className:"mt-1.5 block truncate font-mono text-xs text-dashboard-text-muted",children:t.repos.length?t.repos.map(o=>`${o.provider}:${o.repo}`).join(" \xB7 "):"No repositories"})]}),(0,l.jsx)(O,{"aria-hidden":"true",className:"shrink-0 text-dashboard-text-muted transition-transform group-hover:translate-x-0.5 group-hover:text-dashboard-text",size:16})]})})})}var i=m(u(),1),A="/system/workspaces";function ea(){let{workspaceId:e}=H(),t=I(),o=(0,v.useRef)(null),n=(0,v.useRef)(null),[p,c]=(0,v.useState)(),r=Re(),g=r.data?.workspaces??[],L=r.data?.defaultVcpus??null,B=g.find(h=>h.id===e);me(B?.name??"Workspaces");let He=()=>{let h=e?o.current?.querySelector(`[data-workspace-id="${CSS.escape(e)}"] button`):void 0;t(A),(h??o.current)?.focus()};return(0,i.jsxs)(fe,{className:"grid h-full min-h-0 grid-rows-[auto_minmax(0,1fr)] md:grid-rows-[minmax(0,1fr)]",children:[(0,i.jsxs)("div",{className:J("grid h-full min-h-0 min-w-0",e&&"xl:grid-cols-[minmax(0,1fr)_25rem]"),children:[(0,i.jsx)("div",{"aria-label":"Workspaces list",className:"min-h-0 overflow-y-auto overscroll-contain outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus",ref:o,role:"region",tabIndex:0,children:(0,i.jsxs)(ue,{children:[(0,i.jsx)(pe,{actions:(0,i.jsxs)(D,{className:N(),to:`${A}/new`,children:[(0,i.jsx)(K,{"aria-hidden":"true",size:14}),"New Workspace"]}),description:`Named repository recipes ${Z()} can switch into without cloning each turn.`,title:"Workspaces"}),r.error?(0,i.jsx)(b,{padding:"sm",children:(0,i.jsx)(k,{children:"Workspaces failed to load. Try refreshing the dashboard."})}):r.data?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(Pe,{defaultVcpus:L,snapshot:r.data.baselineSnapshot}),(0,i.jsx)(Ie,{defaultVcpus:L,onSelect:h=>t(h.id===e?A:R(h.id)),selectedId:e,workspaces:g})]}):(0,i.jsx)(C,{label:"Loading Workspaces",variant:"list"})]})}),e?(0,i.jsx)($e,{defaultVcpus:L,listError:!!r.error,onClose:He,onDelete:(h,Qe)=>{n.current=Qe,c(h)},workspace:B,workspaceId:e},e):null]}),p?(0,i.jsx)(Ve,{onClose:()=>c(void 0),onDeleted:()=>{e===p.id&&t(A)},returnFocus:()=>n.current?.isConnected?n.current:o.current??!1,workspace:p}):null]})}export{ea as WorkspacesPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as ne}from"./chunk-H76B43OQ.js";import{e as Pt}from"./chunk-GMZIELFU.js";import{Ja as qt}from"./chunk-VXT3FIVL.js";import{u as Qt,v as Zt,x as te,y as ee,z as ae}from"./chunk-6PHJZPWD.js";import{a as $t}from"./chunk-IZWTFLCC.js";import{a as Ve,k as jt}from"./chunk-WRXMQB7X.js";import{i as Wt,j as Gt}from"./chunk-B5ZN3SWQ.js";import{A as yt,D as Et,E as Ft,G as kt,H as zt,Ia as q,La as Yt,M as Lt,N as Ut,Na as Xt,Oa as ft,Pa as J,Qa as bt,Qc as pt,Rc as Nt,Sa as Kt,Xc as Jt,a as O,b as K,d as wt,g as z,h as dt,i as Ot,j as U,l as _t,p as Ht,x as Bt}from"./chunk-YPMUHXYT.js";import{b as Me,c as b}from"./chunk-7SZRL6FY.js";var lt={};Me(lt,{Indicator:()=>Ee,List:()=>Ie,Panel:()=>Ne,Root:()=>ie,Tab:()=>ce});var d=b(O(),1);var mt=b(O(),1),It=mt.createContext(void 0);function Q(){let t=mt.useContext(It);if(t===void 0)throw new Error(dt(64));return t}var oe="data-activation-direction";var _={tabActivationDirection:t=>({[oe]:t})};var St=b(K(),1),ie=d.forwardRef(function(e,r){let{className:l,defaultValue:a=0,onValueChange:T,orientation:n="horizontal",render:E,value:L,style:P,...N}=e,I=e.defaultValue!==void 0,p=d.useRef([]),[S,m]=d.useState(()=>new Map),[o,C]=Jt({controlled:L,default:a,name:"Tabs",state:"value"}),u=L!==void 0,[s,x]=d.useState(()=>new Map),R=d.useRef(void 0),f=d.useCallback(c=>Dt(s,c),[s]),[H,w]=d.useState(()=>({previousValue:o,tabActivationDirection:"none"})),{previousValue:i,tabActivationDirection:y}=H,g=y,W=!1;i!==o&&(g=se(i,o,n,s),W=i!=null&&o!=null&&f(o)==null);let D=W?i:o,et=i!==D||y!==g;z(()=>{et&&w({previousValue:D,tabActivationDirection:g})},[D,et,g]);let at=U((c,h)=>{let k=se(o,c,n,s);h.activationDirection=k,T?.(c,h),!h.isCanceled&&C(()=>c)}),$=U((c,h)=>{T?.(c,ft(h,void 0,void 0,{activationDirection:"none"}))}),Z=U((c,h)=>(m(k=>{let G=new Map(k);return G.set(c,h),G}),()=>{m(k=>{if(k.get(c)!==h)return k;let G=new Map(k);return G.delete(c),G})})),B=d.useCallback(c=>S.get(c),[S]),M=d.useCallback(c=>{for(let h of s.values())if(c===h.value)return h.id},[s]),nt=d.useMemo(()=>({getTabElementBySelectedValue:f,getTabIdByPanelValue:M,getTabPanelIdByValue:B,onValueChange:at,orientation:n,registerMountedTabPanel:Z,setTabMap:x,tabActivationDirection:g,value:o}),[f,M,B,at,n,Z,x,g,o]),Y=d.useMemo(()=>{for(let c of s.values())if(c.value===o)return c},[s,o]),tt=d.useMemo(()=>{for(let c of s.values())if(!c.disabled)return c.value},[s]),F=d.useRef(!I),ot=d.useRef(a),rt=d.useRef(I),v=d.useRef(!1);z(()=>{if(u)return;function c(it,ut){C(()=>it),w({previousValue:it,tabActivationDirection:"none"}),$(it,ut),F.current=!1}if(s.size===0){v.current&&o!==null&&!R.current?.isConnected&&c(null,J.missing);return}v.current=!0,R.current=s.keys().next().value;let h=Y?.disabled,k=Y==null&&o!==null;if(!h&&o===ot.current&&(rt.current=!1),rt.current&&h&&o===ot.current)return;let G=F.current;if(h||k){let it=tt??null;if(o===it){F.current=!1;return}let ut=J.missing;G?ut=J.initial:h&&(ut=J.disabled),c(it,ut);return}G&&Y!=null&&($(o,J.initial),F.current=!1)},[tt,u,$,Y,C,s,o]);let st=q("div",e,{state:{orientation:n,tabActivationDirection:g},ref:r,props:N,stateAttributesMapping:_});return(0,St.jsx)(It.Provider,{value:nt,children:(0,St.jsx)(te,{elementsRef:p,children:st})})});function Dt(t,e){for(let[r,l]of t.entries())if(e===l.value)return r;return null}function se(t,e,r,l){if(t==null||e==null)return"none";let[a,T,n]=r==="horizontal"?["left","left","right"]:["top","up","down"],E=Dt(l,t),L=Dt(l,e);if(E==null||L==null)return E!==L&&(typeof t=="number"||typeof t=="string")&&typeof t==typeof e?e>t?n:T:"none";let P=E.getBoundingClientRect()[a],N=L.getBoundingClientRect()[a];return N<P?T:N>P?n:"none"}var j=b(O(),1);var gt=b(O(),1),At=gt.createContext(void 0);function vt(){let t=gt.useContext(At);if(t===void 0)throw new Error(dt(65));return t}var ce=j.forwardRef(function(e,r){let{className:l,disabled:a=!1,render:T,value:n,id:E,nativeButton:L=!0,style:P,...N}=e,{value:I,getTabPanelIdByValue:p,onValueChange:S,orientation:m,tabActivationDirection:o}=Q(),{activateOnFocus:C,registerTabResizeObserverElement:u,tabsListElement:s}=vt(),{highlightedIndex:x,onHighlightedIndexChange:R}=Yt(),f=pt(E),H=j.useMemo(()=>({disabled:a,id:f,value:n}),[a,f,n]),{compositeProps:w,compositeRef:i,index:y}=Zt({metadata:H}),g=n===I,W=j.useRef(!1),D=j.useRef(null),et=U(v=>{D.current?.(),D.current=v?u(v):null});z(()=>{if(W.current){W.current=!1;return}if(!(g&&y>-1&&x!==y))return;let v=s;if(v!=null){let X=kt(Et(v));if(X&&zt(v,X))return}a||R(y)},[g,y,x,R,a,s]);let{getButtonProps:at,buttonRef:$}=Xt({disabled:a,native:L,focusableWhenDisabled:!0}),Z=p(n),B=j.useRef(!1),M=j.useRef(!1);function nt(v){S(n,ft(J.none,v.nativeEvent,void 0,{activationDirection:"none"}))}function Y(v){g||a||nt(v)}function tt(v){g||a||C&&(!B.current||M.current)&&nt(v)}function F(v){if(g||a)return;B.current=!0,M.current=v.button===0;let X=Et(v.currentTarget);function st(){B.current=!1,M.current=!1,X.removeEventListener("pointerup",st),X.removeEventListener("pointercancel",st)}X.addEventListener("pointerup",st),X.addEventListener("pointercancel",st)}return q("button",e,{state:{disabled:a,active:g,orientation:m,tabActivationDirection:o},ref:[r,$,i,et],props:[w,{role:"tab","aria-controls":Z,"aria-selected":g,id:f,onClick:Y,onFocus:tt,onPointerDown:F,[ee]:g?"":void 0,onKeyDownCapture(){W.current=!0}},N,at],stateAttributesMapping:_})});var ct=b(O(),1);var Da=b(O(),1);var Tt=b(O(),1),le=b(Ve(),1);var we=()=>()=>{},Oe=()=>!0,_e=()=>!1;function He(){return(0,le.useSyncExternalStore)(we,Oe,_e)}function Be(){let[t,e]=Tt.useState(!1);return Tt.useEffect(()=>{e(!0)},[]),t}var Fe=Ot(18)?He:Be;function Mt(){return!Fe()}var xt=b(O(),1),ke=xt.createContext(void 0),ze={disableStyleElements:!1};function ue(){return xt.useContext(ke)??ze}var de=b(K(),1);function fe(t){let{script:e}=t,{nonce:r}=ue();return Mt()?(0,de.jsx)("script",{nonce:r,dangerouslySetInnerHTML:{__html:e},suppressHydrationWarning:!0}):null}var be="--active-tab-left",pe="--active-tab-right",me="--active-tab-top",ge="--active-tab-bottom",ve="--active-tab-width",Te="--active-tab-height";var Rt=b(K(),1),Re,Ue={..._,activeTabPosition:()=>null,activeTabSize:()=>null},he=2,Ee=ct.forwardRef(function(e,r){let{className:l,render:a,renderBeforeHydration:T=!1,style:n,...E}=e,{getTabElementBySelectedValue:L,orientation:P,tabActivationDirection:N,value:I}=Q(),{tabsListElement:p,registerIndicatorUpdateListener:S}=vt(),m=Ft();ct.useEffect(()=>S(m),[S,m]);let o=0,C=0,u=0,s=0,x=0,R=0,f=!1;if(I!=null&&p!=null){let D=L(I);if(D!=null){f=!0;let{width:et,height:at}=Pt(D),{width:$,height:Z}=Pt(p),B=D.getBoundingClientRect(),M=p.getBoundingClientRect(),nt=$>0?M.width/$:1,Y=Z>0?M.height/Z:1,tt=je(D,p);o=tt.left,u=tt.top;let F=(B.left-M.left)/nt+p.scrollLeft-p.clientLeft,ot=(B.top-M.top)/Y+p.scrollTop-p.clientTop,rt=We(D);Math.abs(F-rt.x-o)<=he&&Math.abs(ot-rt.y-u)<=he&&(o=F,u=ot),x=et,R=at,C=p.scrollWidth-o-x,s=p.scrollHeight-u-R}}let H=f?{left:o,right:C,top:u,bottom:s}:null,w=f?{width:x,height:R}:null,i=f?{[be]:`${o}px`,[pe]:`${C}px`,[me]:`${u}px`,[ge]:`${s}px`,[ve]:`${x}px`,[Te]:`${R}px`}:void 0,y=f&&x>0&&R>0,W=q("span",e,{state:{orientation:P,activeTabPosition:H,activeTabSize:w,tabActivationDirection:N},ref:r,props:[{role:"presentation",style:i,hidden:!y},E,{suppressHydrationWarning:!0}],stateAttributesMapping:Ue});return I==null?null:(0,Rt.jsxs)(ct.Fragment,{children:[W,T&&(Re||(Re=(0,Rt.jsx)(fe,{script:""})))]})});function je(t,e){let r=Ce(t),l=Ce(e),a=r.left-l.left-e.clientLeft,T=r.top-l.top-e.clientTop,n=yt(t);for(;Ht(n)&&n!==e&&!Bt(n);)a-=n.scrollLeft,T-=n.scrollTop,n=yt(n);return{left:a,top:T}}function Ce(t){let e=0,r=0,l=t;for(;l!=null;){e+=l.offsetLeft,r+=l.offsetTop;let a=l.offsetParent;a!=null&&(e+=a.clientLeft,r+=a.clientTop),l=a}return{left:e,top:r}}function We(t){let e=_t(t).getComputedStyle(t),{x:r,y:l}=$t(t,e),a=r,T=l,{translate:n}=e;if(n&&n!=="none"){let E=n.split(" ");a+=ye(E[0],t.offsetWidth),T+=ye(E[1],t.offsetHeight)}return{x:a,y:T}}function ye(t,e){if(!t)return 0;let r=parseFloat(t);return Number.isFinite(r)?t.endsWith("%")?r/100*e:r:0}var ht=b(O(),1);var Le="data-index";var Xa=Lt.startingStyle,Ga=Lt.endingStyle;var $e={..._,...Ut},Ne=ht.forwardRef(function(e,r){let{className:l,value:a,render:T,keepMounted:n=!1,style:E,...L}=e,{value:P,getTabIdByPanelValue:N,orientation:I,tabActivationDirection:p,registerMountedTabPanel:S}=Q(),m=pt(),{ref:o,index:C}=Qt(),u=a===P,{mounted:s,transitionStatus:x,setMounted:R}=Gt(u),f=!s,H=N(a),w={hidden:f,orientation:I,tabActivationDirection:p,transitionStatus:x},i=ht.useRef(null),y=q("div",e,{state:w,ref:[r,o,i],props:[{"aria-labelledby":H,hidden:f,id:m,role:"tabpanel",tabIndex:u?0:-1,inert:jt(!u),[Le]:C},L],stateAttributesMapping:$e});return Wt({open:u,ref:i,onComplete(){u||R(!1)}}),z(()=>{if(!(m==null||f&&!n))return S(a,m)},[f,n,a,m,S]),n||s?y:null});var V=b(O(),1);var Vt=b(K(),1),Ie=V.forwardRef(function(e,r){let{activateOnFocus:l=!1,className:a,loopFocus:T=!0,render:n,style:E,...L}=e,{orientation:P,setTabMap:N,tabActivationDirection:I}=Q(),[p,S]=V.useState(0),[m,o]=V.useState(null),C=V.useRef(new Set),u=V.useRef(new Set),s=V.useRef(null);z(()=>{if(typeof ResizeObserver>"u")return;let i=new ResizeObserver(()=>{C.current.forEach(y=>{y()})});return s.current=i,m&&i.observe(m),u.current.forEach(y=>{i.observe(y)}),()=>{i.disconnect(),s.current=null}},[m]);let x=U(i=>(C.current.add(i),()=>{C.current.delete(i)})),R=U(i=>(u.current.add(i),s.current?.observe(i),()=>{u.current.delete(i),s.current?.unobserve(i)})),f={orientation:P,tabActivationDirection:I},H={"aria-orientation":P==="vertical"?"vertical":void 0,role:"tablist"},w=V.useMemo(()=>({activateOnFocus:l,registerIndicatorUpdateListener:x,registerTabResizeObserverElement:R,tabsListElement:m}),[l,x,R,m]);return(0,Vt.jsx)(At.Provider,{value:w,children:(0,Vt.jsx)(ae,{render:n,className:a,style:E,state:f,refs:[r,o],props:[H,L],stateAttributesMapping:_,highlightedIndex:p,enableHomeAndEndKeys:!0,loopFocus:T,orientation:P,onHighlightedIndexChange:S,onMapChange:N,disabledIndices:wt})})});var Ct=b(K(),1);function Se({className:t,...e}){return(0,Ct.jsx)(lt.Root,{"data-slot":"tabs",className:bt("grid min-w-0 gap-4",t),...e})}var Ye=Kt("group/tabs-list flex min-w-0",{variants:{variant:{default:"gap-1 rounded-lg border border-dashboard-border bg-dashboard-surface-panel p-1",line:"gap-1 border-b border-dashboard-border-subtle"}},defaultVariants:{variant:"default"}});function De({className:t,variant:e="default",...r}){return(0,Ct.jsx)(lt.List,{"data-slot":"tabs-list","data-variant":e,className:bt(Ye({variant:e}),t),...r})}function Ae({className:t,...e}){return(0,Ct.jsx)(lt.Tab,{"data-slot":"tabs-trigger",className:bt("inline-flex min-w-0 cursor-pointer items-center gap-1.5 border-0 bg-transparent font-sans text-xs font-medium text-dashboard-text-muted transition-colors hover:text-dashboard-text focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus","group-data-[variant=default]/tabs-list:min-h-9 group-data-[variant=default]/tabs-list:flex-auto group-data-[variant=default]/tabs-list:justify-center group-data-[variant=default]/tabs-list:rounded-md group-data-[variant=default]/tabs-list:px-1.5 group-data-[variant=default]/tabs-list:py-2 group-data-[variant=default]/tabs-list:hover:bg-dashboard-fill-faint group-data-[variant=default]/tabs-list:data-active:bg-dashboard-fill-strong group-data-[variant=default]/tabs-list:data-active:text-dashboard-text group-data-[variant=default]/tabs-list:sm:flex-1","group-data-[variant=line]/tabs-list:relative group-data-[variant=line]/tabs-list:gap-2 group-data-[variant=line]/tabs-list:px-3 group-data-[variant=line]/tabs-list:py-2.5 group-data-[variant=line]/tabs-list:after:absolute group-data-[variant=line]/tabs-list:after:inset-x-2 group-data-[variant=line]/tabs-list:after:bottom-0 group-data-[variant=line]/tabs-list:after:h-px group-data-[variant=line]/tabs-list:data-active:text-dashboard-accent-text group-data-[variant=line]/tabs-list:data-active:after:bg-dashboard-accent",t),...e})}var A=b(K(),1);function Mn(t){return(0,A.jsxs)(qt,{className:Nt("flex flex-wrap items-end gap-4 p-4",t.className),children:[t.children,t.search?(0,A.jsx)(Xe,{className:"min-w-[16rem] flex-1",label:"Search",children:(0,A.jsx)(ne,{className:"w-full max-w-md",label:t.search.label,onChange:t.search.onChange,placeholder:t.search.placeholder,value:t.search.value})}):null]})}function Xe(t){return(0,A.jsxs)("div",{className:Nt("min-w-0",t.className),children:[(0,A.jsx)("div",{className:"mb-2 font-sans font-medium text-xs text-dashboard-text-muted",children:t.label}),(0,A.jsx)("div",{"aria-label":t.label,className:"flex flex-wrap gap-2",role:"group",children:t.children})]})}function Vn(t){return(0,A.jsx)(Se,{onValueChange:t.onChange,value:t.value,children:(0,A.jsx)(De,{"aria-label":t.ariaLabel,className:"grid grid-cols-3 sm:flex sm:overflow-x-auto",variant:"line",children:t.items.map(e=>(0,A.jsxs)(Ae,{className:"group/tab justify-between sm:shrink-0 sm:justify-start",value:e.value,children:[e.label,e.count!==void 0?(0,A.jsx)("span",{className:"rounded-sm border border-dashboard-border bg-dashboard-fill-soft px-1.5 py-0.5 text-xs text-dashboard-text-muted group-data-active/tab:border-dashboard-accent/20 group-data-active/tab:bg-dashboard-accent/10 group-data-active/tab:text-dashboard-accent-text",children:e.count.toLocaleString("en-US")}):null]},e.value||"all"))})})}export{Mn as a,Xe as b,Vn as c};
|
|
1
|
+
import{a as ne}from"./chunk-H76B43OQ.js";import{e as Pt}from"./chunk-GMZIELFU.js";import{Ka as qt}from"./chunk-XDUSY26N.js";import{u as Qt,v as Zt,x as te,y as ee,z as ae}from"./chunk-6PHJZPWD.js";import{a as $t}from"./chunk-IZWTFLCC.js";import{a as Ve,k as jt}from"./chunk-WRXMQB7X.js";import{i as Wt,j as Gt}from"./chunk-B5ZN3SWQ.js";import{A as yt,D as Et,E as Ft,G as kt,H as zt,Ia as q,La as Yt,M as Lt,N as Ut,Na as Xt,Oa as ft,Pa as J,Qa as bt,Qc as pt,Rc as Nt,Sa as Kt,Xc as Jt,a as O,b as K,d as wt,g as z,h as dt,i as Ot,j as U,l as _t,p as Ht,x as Bt}from"./chunk-YPMUHXYT.js";import{b as Me,c as b}from"./chunk-7SZRL6FY.js";var lt={};Me(lt,{Indicator:()=>Ee,List:()=>Ie,Panel:()=>Ne,Root:()=>ie,Tab:()=>ce});var d=b(O(),1);var mt=b(O(),1),It=mt.createContext(void 0);function Q(){let t=mt.useContext(It);if(t===void 0)throw new Error(dt(64));return t}var oe="data-activation-direction";var _={tabActivationDirection:t=>({[oe]:t})};var St=b(K(),1),ie=d.forwardRef(function(e,r){let{className:l,defaultValue:a=0,onValueChange:T,orientation:n="horizontal",render:E,value:L,style:P,...N}=e,I=e.defaultValue!==void 0,p=d.useRef([]),[S,m]=d.useState(()=>new Map),[o,C]=Jt({controlled:L,default:a,name:"Tabs",state:"value"}),u=L!==void 0,[s,x]=d.useState(()=>new Map),R=d.useRef(void 0),f=d.useCallback(c=>Dt(s,c),[s]),[H,w]=d.useState(()=>({previousValue:o,tabActivationDirection:"none"})),{previousValue:i,tabActivationDirection:y}=H,g=y,W=!1;i!==o&&(g=se(i,o,n,s),W=i!=null&&o!=null&&f(o)==null);let D=W?i:o,et=i!==D||y!==g;z(()=>{et&&w({previousValue:D,tabActivationDirection:g})},[D,et,g]);let at=U((c,h)=>{let k=se(o,c,n,s);h.activationDirection=k,T?.(c,h),!h.isCanceled&&C(()=>c)}),$=U((c,h)=>{T?.(c,ft(h,void 0,void 0,{activationDirection:"none"}))}),Z=U((c,h)=>(m(k=>{let G=new Map(k);return G.set(c,h),G}),()=>{m(k=>{if(k.get(c)!==h)return k;let G=new Map(k);return G.delete(c),G})})),B=d.useCallback(c=>S.get(c),[S]),M=d.useCallback(c=>{for(let h of s.values())if(c===h.value)return h.id},[s]),nt=d.useMemo(()=>({getTabElementBySelectedValue:f,getTabIdByPanelValue:M,getTabPanelIdByValue:B,onValueChange:at,orientation:n,registerMountedTabPanel:Z,setTabMap:x,tabActivationDirection:g,value:o}),[f,M,B,at,n,Z,x,g,o]),Y=d.useMemo(()=>{for(let c of s.values())if(c.value===o)return c},[s,o]),tt=d.useMemo(()=>{for(let c of s.values())if(!c.disabled)return c.value},[s]),F=d.useRef(!I),ot=d.useRef(a),rt=d.useRef(I),v=d.useRef(!1);z(()=>{if(u)return;function c(it,ut){C(()=>it),w({previousValue:it,tabActivationDirection:"none"}),$(it,ut),F.current=!1}if(s.size===0){v.current&&o!==null&&!R.current?.isConnected&&c(null,J.missing);return}v.current=!0,R.current=s.keys().next().value;let h=Y?.disabled,k=Y==null&&o!==null;if(!h&&o===ot.current&&(rt.current=!1),rt.current&&h&&o===ot.current)return;let G=F.current;if(h||k){let it=tt??null;if(o===it){F.current=!1;return}let ut=J.missing;G?ut=J.initial:h&&(ut=J.disabled),c(it,ut);return}G&&Y!=null&&($(o,J.initial),F.current=!1)},[tt,u,$,Y,C,s,o]);let st=q("div",e,{state:{orientation:n,tabActivationDirection:g},ref:r,props:N,stateAttributesMapping:_});return(0,St.jsx)(It.Provider,{value:nt,children:(0,St.jsx)(te,{elementsRef:p,children:st})})});function Dt(t,e){for(let[r,l]of t.entries())if(e===l.value)return r;return null}function se(t,e,r,l){if(t==null||e==null)return"none";let[a,T,n]=r==="horizontal"?["left","left","right"]:["top","up","down"],E=Dt(l,t),L=Dt(l,e);if(E==null||L==null)return E!==L&&(typeof t=="number"||typeof t=="string")&&typeof t==typeof e?e>t?n:T:"none";let P=E.getBoundingClientRect()[a],N=L.getBoundingClientRect()[a];return N<P?T:N>P?n:"none"}var j=b(O(),1);var gt=b(O(),1),At=gt.createContext(void 0);function vt(){let t=gt.useContext(At);if(t===void 0)throw new Error(dt(65));return t}var ce=j.forwardRef(function(e,r){let{className:l,disabled:a=!1,render:T,value:n,id:E,nativeButton:L=!0,style:P,...N}=e,{value:I,getTabPanelIdByValue:p,onValueChange:S,orientation:m,tabActivationDirection:o}=Q(),{activateOnFocus:C,registerTabResizeObserverElement:u,tabsListElement:s}=vt(),{highlightedIndex:x,onHighlightedIndexChange:R}=Yt(),f=pt(E),H=j.useMemo(()=>({disabled:a,id:f,value:n}),[a,f,n]),{compositeProps:w,compositeRef:i,index:y}=Zt({metadata:H}),g=n===I,W=j.useRef(!1),D=j.useRef(null),et=U(v=>{D.current?.(),D.current=v?u(v):null});z(()=>{if(W.current){W.current=!1;return}if(!(g&&y>-1&&x!==y))return;let v=s;if(v!=null){let X=kt(Et(v));if(X&&zt(v,X))return}a||R(y)},[g,y,x,R,a,s]);let{getButtonProps:at,buttonRef:$}=Xt({disabled:a,native:L,focusableWhenDisabled:!0}),Z=p(n),B=j.useRef(!1),M=j.useRef(!1);function nt(v){S(n,ft(J.none,v.nativeEvent,void 0,{activationDirection:"none"}))}function Y(v){g||a||nt(v)}function tt(v){g||a||C&&(!B.current||M.current)&&nt(v)}function F(v){if(g||a)return;B.current=!0,M.current=v.button===0;let X=Et(v.currentTarget);function st(){B.current=!1,M.current=!1,X.removeEventListener("pointerup",st),X.removeEventListener("pointercancel",st)}X.addEventListener("pointerup",st),X.addEventListener("pointercancel",st)}return q("button",e,{state:{disabled:a,active:g,orientation:m,tabActivationDirection:o},ref:[r,$,i,et],props:[w,{role:"tab","aria-controls":Z,"aria-selected":g,id:f,onClick:Y,onFocus:tt,onPointerDown:F,[ee]:g?"":void 0,onKeyDownCapture(){W.current=!0}},N,at],stateAttributesMapping:_})});var ct=b(O(),1);var Da=b(O(),1);var Tt=b(O(),1),le=b(Ve(),1);var we=()=>()=>{},Oe=()=>!0,_e=()=>!1;function He(){return(0,le.useSyncExternalStore)(we,Oe,_e)}function Be(){let[t,e]=Tt.useState(!1);return Tt.useEffect(()=>{e(!0)},[]),t}var Fe=Ot(18)?He:Be;function Mt(){return!Fe()}var xt=b(O(),1),ke=xt.createContext(void 0),ze={disableStyleElements:!1};function ue(){return xt.useContext(ke)??ze}var de=b(K(),1);function fe(t){let{script:e}=t,{nonce:r}=ue();return Mt()?(0,de.jsx)("script",{nonce:r,dangerouslySetInnerHTML:{__html:e},suppressHydrationWarning:!0}):null}var be="--active-tab-left",pe="--active-tab-right",me="--active-tab-top",ge="--active-tab-bottom",ve="--active-tab-width",Te="--active-tab-height";var Rt=b(K(),1),Re,Ue={..._,activeTabPosition:()=>null,activeTabSize:()=>null},he=2,Ee=ct.forwardRef(function(e,r){let{className:l,render:a,renderBeforeHydration:T=!1,style:n,...E}=e,{getTabElementBySelectedValue:L,orientation:P,tabActivationDirection:N,value:I}=Q(),{tabsListElement:p,registerIndicatorUpdateListener:S}=vt(),m=Ft();ct.useEffect(()=>S(m),[S,m]);let o=0,C=0,u=0,s=0,x=0,R=0,f=!1;if(I!=null&&p!=null){let D=L(I);if(D!=null){f=!0;let{width:et,height:at}=Pt(D),{width:$,height:Z}=Pt(p),B=D.getBoundingClientRect(),M=p.getBoundingClientRect(),nt=$>0?M.width/$:1,Y=Z>0?M.height/Z:1,tt=je(D,p);o=tt.left,u=tt.top;let F=(B.left-M.left)/nt+p.scrollLeft-p.clientLeft,ot=(B.top-M.top)/Y+p.scrollTop-p.clientTop,rt=We(D);Math.abs(F-rt.x-o)<=he&&Math.abs(ot-rt.y-u)<=he&&(o=F,u=ot),x=et,R=at,C=p.scrollWidth-o-x,s=p.scrollHeight-u-R}}let H=f?{left:o,right:C,top:u,bottom:s}:null,w=f?{width:x,height:R}:null,i=f?{[be]:`${o}px`,[pe]:`${C}px`,[me]:`${u}px`,[ge]:`${s}px`,[ve]:`${x}px`,[Te]:`${R}px`}:void 0,y=f&&x>0&&R>0,W=q("span",e,{state:{orientation:P,activeTabPosition:H,activeTabSize:w,tabActivationDirection:N},ref:r,props:[{role:"presentation",style:i,hidden:!y},E,{suppressHydrationWarning:!0}],stateAttributesMapping:Ue});return I==null?null:(0,Rt.jsxs)(ct.Fragment,{children:[W,T&&(Re||(Re=(0,Rt.jsx)(fe,{script:""})))]})});function je(t,e){let r=Ce(t),l=Ce(e),a=r.left-l.left-e.clientLeft,T=r.top-l.top-e.clientTop,n=yt(t);for(;Ht(n)&&n!==e&&!Bt(n);)a-=n.scrollLeft,T-=n.scrollTop,n=yt(n);return{left:a,top:T}}function Ce(t){let e=0,r=0,l=t;for(;l!=null;){e+=l.offsetLeft,r+=l.offsetTop;let a=l.offsetParent;a!=null&&(e+=a.clientLeft,r+=a.clientTop),l=a}return{left:e,top:r}}function We(t){let e=_t(t).getComputedStyle(t),{x:r,y:l}=$t(t,e),a=r,T=l,{translate:n}=e;if(n&&n!=="none"){let E=n.split(" ");a+=ye(E[0],t.offsetWidth),T+=ye(E[1],t.offsetHeight)}return{x:a,y:T}}function ye(t,e){if(!t)return 0;let r=parseFloat(t);return Number.isFinite(r)?t.endsWith("%")?r/100*e:r:0}var ht=b(O(),1);var Le="data-index";var Xa=Lt.startingStyle,Ga=Lt.endingStyle;var $e={..._,...Ut},Ne=ht.forwardRef(function(e,r){let{className:l,value:a,render:T,keepMounted:n=!1,style:E,...L}=e,{value:P,getTabIdByPanelValue:N,orientation:I,tabActivationDirection:p,registerMountedTabPanel:S}=Q(),m=pt(),{ref:o,index:C}=Qt(),u=a===P,{mounted:s,transitionStatus:x,setMounted:R}=Gt(u),f=!s,H=N(a),w={hidden:f,orientation:I,tabActivationDirection:p,transitionStatus:x},i=ht.useRef(null),y=q("div",e,{state:w,ref:[r,o,i],props:[{"aria-labelledby":H,hidden:f,id:m,role:"tabpanel",tabIndex:u?0:-1,inert:jt(!u),[Le]:C},L],stateAttributesMapping:$e});return Wt({open:u,ref:i,onComplete(){u||R(!1)}}),z(()=>{if(!(m==null||f&&!n))return S(a,m)},[f,n,a,m,S]),n||s?y:null});var V=b(O(),1);var Vt=b(K(),1),Ie=V.forwardRef(function(e,r){let{activateOnFocus:l=!1,className:a,loopFocus:T=!0,render:n,style:E,...L}=e,{orientation:P,setTabMap:N,tabActivationDirection:I}=Q(),[p,S]=V.useState(0),[m,o]=V.useState(null),C=V.useRef(new Set),u=V.useRef(new Set),s=V.useRef(null);z(()=>{if(typeof ResizeObserver>"u")return;let i=new ResizeObserver(()=>{C.current.forEach(y=>{y()})});return s.current=i,m&&i.observe(m),u.current.forEach(y=>{i.observe(y)}),()=>{i.disconnect(),s.current=null}},[m]);let x=U(i=>(C.current.add(i),()=>{C.current.delete(i)})),R=U(i=>(u.current.add(i),s.current?.observe(i),()=>{u.current.delete(i),s.current?.unobserve(i)})),f={orientation:P,tabActivationDirection:I},H={"aria-orientation":P==="vertical"?"vertical":void 0,role:"tablist"},w=V.useMemo(()=>({activateOnFocus:l,registerIndicatorUpdateListener:x,registerTabResizeObserverElement:R,tabsListElement:m}),[l,x,R,m]);return(0,Vt.jsx)(At.Provider,{value:w,children:(0,Vt.jsx)(ae,{render:n,className:a,style:E,state:f,refs:[r,o],props:[H,L],stateAttributesMapping:_,highlightedIndex:p,enableHomeAndEndKeys:!0,loopFocus:T,orientation:P,onHighlightedIndexChange:S,onMapChange:N,disabledIndices:wt})})});var Ct=b(K(),1);function Se({className:t,...e}){return(0,Ct.jsx)(lt.Root,{"data-slot":"tabs",className:bt("grid min-w-0 gap-4",t),...e})}var Ye=Kt("group/tabs-list flex min-w-0",{variants:{variant:{default:"gap-1 rounded-lg border border-dashboard-border bg-dashboard-surface-panel p-1",line:"gap-1 border-b border-dashboard-border-subtle"}},defaultVariants:{variant:"default"}});function De({className:t,variant:e="default",...r}){return(0,Ct.jsx)(lt.List,{"data-slot":"tabs-list","data-variant":e,className:bt(Ye({variant:e}),t),...r})}function Ae({className:t,...e}){return(0,Ct.jsx)(lt.Tab,{"data-slot":"tabs-trigger",className:bt("inline-flex min-w-0 cursor-pointer items-center gap-1.5 border-0 bg-transparent font-sans text-xs font-medium text-dashboard-text-muted transition-colors hover:text-dashboard-text focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus","group-data-[variant=default]/tabs-list:min-h-9 group-data-[variant=default]/tabs-list:flex-auto group-data-[variant=default]/tabs-list:justify-center group-data-[variant=default]/tabs-list:rounded-md group-data-[variant=default]/tabs-list:px-1.5 group-data-[variant=default]/tabs-list:py-2 group-data-[variant=default]/tabs-list:hover:bg-dashboard-fill-faint group-data-[variant=default]/tabs-list:data-active:bg-dashboard-fill-strong group-data-[variant=default]/tabs-list:data-active:text-dashboard-text group-data-[variant=default]/tabs-list:sm:flex-1","group-data-[variant=line]/tabs-list:relative group-data-[variant=line]/tabs-list:gap-2 group-data-[variant=line]/tabs-list:px-3 group-data-[variant=line]/tabs-list:py-2.5 group-data-[variant=line]/tabs-list:after:absolute group-data-[variant=line]/tabs-list:after:inset-x-2 group-data-[variant=line]/tabs-list:after:bottom-0 group-data-[variant=line]/tabs-list:after:h-px group-data-[variant=line]/tabs-list:data-active:text-dashboard-accent-text group-data-[variant=line]/tabs-list:data-active:after:bg-dashboard-accent",t),...e})}var A=b(K(),1);function Mn(t){return(0,A.jsxs)(qt,{className:Nt("flex flex-wrap items-end gap-4 p-4",t.className),children:[t.children,t.search?(0,A.jsx)(Xe,{className:"min-w-[16rem] flex-1",label:"Search",children:(0,A.jsx)(ne,{className:"w-full max-w-md",label:t.search.label,onChange:t.search.onChange,placeholder:t.search.placeholder,value:t.search.value})}):null]})}function Xe(t){return(0,A.jsxs)("div",{className:Nt("min-w-0",t.className),children:[(0,A.jsx)("div",{className:"mb-2 font-sans font-medium text-xs text-dashboard-text-muted",children:t.label}),(0,A.jsx)("div",{"aria-label":t.label,className:"flex flex-wrap gap-2",role:"group",children:t.children})]})}function Vn(t){return(0,A.jsx)(Se,{onValueChange:t.onChange,value:t.value,children:(0,A.jsx)(De,{"aria-label":t.ariaLabel,className:"grid grid-cols-3 sm:flex sm:overflow-x-auto",variant:"line",children:t.items.map(e=>(0,A.jsxs)(Ae,{className:"group/tab justify-between sm:shrink-0 sm:justify-start",value:e.value,children:[e.label,e.count!==void 0?(0,A.jsx)("span",{className:"rounded-sm border border-dashboard-border bg-dashboard-fill-soft px-1.5 py-0.5 text-xs text-dashboard-text-muted group-data-active/tab:border-dashboard-accent/20 group-data-active/tab:bg-dashboard-accent/10 group-data-active/tab:text-dashboard-accent-text",children:e.count.toLocaleString("en-US")}):null]},e.value||"all"))})})}export{Mn as a,Xe as b,Vn as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{E as Ze}from"./chunk-II4NXLSQ.js";import{a as qe,d as H,f as De,g as $,i as U,j as fe,n as xe,p as Ye,r as z,s as Je,u as Xe,v as W,w as Ge}from"./chunk-4TQSTCIN.js";import{A as He,B as pe,C as Ne,D as Ue,Da as Me,E as Ee,Ea as $e,F as ge,Fa as ze,Ga as We,J as ke,Q as Be,aa as Ke,ba as Qe,ca as Fe,da as Ve,f as _e,ka as je}from"./chunk-XDUSY26N.js";import{a as ae}from"./chunk-YPMUHXYT.js";import{c as se}from"./chunk-7SZRL6FY.js";var k=se(ae(),1);function nt(e,t){window.dispatchEvent(new StorageEvent("storage",{key:e,newValue:t}))}var et=(e,t)=>{let n=JSON.stringify(t);window.localStorage.setItem(e,n),nt(e,n)},It=e=>{window.localStorage.removeItem(e),nt(e,null)},tt=e=>window.localStorage.getItem(e),At=e=>(window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)),Ot=()=>{throw Error("useLocalStorage is a client-only hook")};function ot(e,t){let o=k.useSyncExternalStore(At,()=>tt(e),Ot),r=k.useCallback(s=>{try{let a=typeof s=="function"?s(JSON.parse(o)):s;a==null?It(e):et(e,a)}catch(a){console.warn(a)}},[e,o]);return k.useEffect(()=>{tt(e)===null&&typeof t<"u"&&et(e,t)},[e,t]),[o?JSON.parse(o):t,r]}var B=se(ae(),1);var E=se(ae(),1);var me=se(ae(),1);var ee=["dashboard","review-items"],rt=6e4;function Cn(e){let t=new URLSearchParams;e.conversationId&&t.set("conversationId",e.conversationId),e.forViewer&&t.set("for","viewer"),e.q&&t.set("q",e.q);let n=t.toString(),o=fe({initialPageParam:void 0,queryKey:[...ee,"list",n],queryFn:({pageParam:a,signal:l})=>{let d=new URLSearchParams(n);return a&&d.set("cursor",a),W($e,`/api/review-items?${d.toString()}`,l)},getNextPageParam:a=>a.nextCursor,placeholderData:qe,retry:!1}),r=o.data?.pages;return{items:(0,me.useMemo)(()=>(r??[]).flatMap(a=>a.items),[r]),moreArchived:!!r?.[0]?.moreArchived,query:o}}function wn(e){return $({enabled:!!e,queryKey:[...ee,"detail",e],queryFn:({signal:t})=>W(Me,`/api/review-items/${encodeURIComponent(e)}`,t),retry:!1})}function Sn(e){return De({queries:e.map(t=>({queryKey:["dashboard","conversation-title",t],queryFn:async({signal:n})=>Ze(await W(ge,`/api/conversations/${encodeURIComponent(t)}?limit=1`,n))??null,retry:!1,staleTime:5*6e4}))}).map(t=>t.data??void 0)}function Rn(e){return $({enabled:e,queryKey:[...ee,"count"],queryFn:({signal:t})=>W(ze,"/api/review-items/count",t),refetchInterval:rt,retry:!1})}function En(e){return $({enabled:e,queryKey:["dashboard","automations","scope=mine&state=blocked"],queryFn:({signal:t})=>W(Be,"/api/automations?scope=mine&state=blocked&pageSize=100",t),retry:!1})}function Mn(){let e=H();return U({mutationFn:t=>z(Me,`/api/review-items/${encodeURIComponent(t.id)}/actions`,t.body),onSettled:()=>e.invalidateQueries({queryKey:ee})})}var qt=new Map;function Dt(){let t=$({queryKey:[...ee,"waiting-conversations"],queryFn:({signal:n})=>W(We,"/api/review-items/waiting-conversations",n),refetchInterval:rt,retry:!1}).data?.conversations;return(0,me.useMemo)(()=>t?new Map(t.map(({conversationId:n,count:o,title:r})=>[n,{count:o,title:r}])):qt,[t])}function xn(){let e=Dt();return(0,me.useMemo)(()=>new Set(e.keys()),[e])}function ve(e){let t=e.getQueryData(["dashboard","core"])?.me.user;if(t?.email)return{...t.avatarUrl?{avatarUrl:t.avatarUrl}:void 0,email:t.email,fullName:t.name||void 0}}function J(e){return["conversation",e,"outbox"]}function ye(e){let t=e.now??new Date().toISOString();return{actorIdentity:e.actorIdentity,createdAt:t,idempotencyKey:e.idempotencyKey,...e.inline?{inline:!0}:void 0,message:e.message,...e.images?.length?{images:e.images}:void 0,messageId:e.messageId,status:"sending"}}function st(e){return{actorIdentity:e.actorIdentity,clientStatus:e.status,createdAt:e.createdAt,delivery:"defer",idempotencyKey:e.idempotencyKey,inboundMessageId:e.messageId,messageId:e.messageId,receivedAt:e.createdAt,role:"user",source:"web",text:e.message,...e.images?.length?{images:e.images}:void 0}}function at(e,t,n){let o=e??[],r=t??[],s=o;if(r.length>0){let a=new Set(o.map(d=>d.messageId)),l=r.filter(d=>!a.has(d.messageId)).map(st);l.length>0&&(s=[...o,...l])}return he(n,s)}function he(e,t){if(!e)return t;if(e===t)return e;if(e.length!==t.length)return t;for(let n=0;n<e.length;n+=1)if(!_t(e[n],t[n]))return t;return e}function _t(e,t){return e.inboundMessageId===t.inboundMessageId&&e.messageId===t.messageId&&e.clientStatus===t.clientStatus&&e.delivery===t.delivery&&e.text===t.text&&e.images===t.images&&JSON.stringify(e.attachments)===JSON.stringify(t.attachments)&&e.redacted===t.redacted&&e.source===t.source&&e.role===t.role&&e.createdAt===t.createdAt&&e.receivedAt===t.receivedAt&&e.idempotencyKey===t.idempotencyKey&&it(e.actorIdentity,t.actorIdentity)&&Ht(e.mentions,t.mentions)}function Ht(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((n,o)=>it(n,t[o]))}function it(e,t){return e===t?!0:!e||!t?!1:e.avatarUrl===t.avatarUrl&&e.email===t.email&&e.fullName===t.fullName&&e.slackUserId===t.slackUserId&&e.slackUserName===t.slackUserName}function Te(e){return!!e.inline&&e.status!=="failed"}function ut(e,t,n){let o=n.filter(Te);if(o.length===0)return{inline:[],queued:e};let r=new Set(o.map(a=>a.messageId)),s=new Map((t??[]).map(a=>[a.messageId,a]));return{inline:o.map(a=>s.get(a.messageId)??st(a)),queued:e.filter(a=>!r.has(a.messageId))}}function be(e,t){let n=e??[],o=n.findIndex(s=>s.idempotencyKey===t.idempotencyKey);if(o<0)return[...n,t];let r=n.slice();return r[o]=t,r}function ct(e,t,n){return(e??[]).map(o=>o.idempotencyKey===t?{...o,messageId:n,status:"accepted"}:o)}function lt(e,t){return(e??[]).map(n=>n.idempotencyKey===t?{...n,status:"failed"}:n)}function Pe(e,t){let n=ht(e,t);return n||(t.length===0?e:{...e,events:yt([...t.flatMap(o=>o.events),...e.events]),previousCursor:Ce(e.previousCursor,t)??(t.length?Le(t):e.previousCursor)})}function Ln(e,t,n){let o=ht(e,t);return o||{...e,events:yt([...t.flatMap(r=>r.events),...n]),previousCursor:Le(t)}}async function ft(e){let t=new Map(e.historyPages.map(s=>[s.requestedBefore,s])),n=[],o=new Set,r=e.detail.previousCursor;for(;r;){if(o.has(r))throw new Error("Conversation history cursor did not advance");o.add(r);let s=t.get(r)??{...await e.readPage(r),requestedBefore:r};n.push(s),r=s.previousCursor}return Pe(e.detail,n)}function pt(e){let t=vt(e);return t===void 0?"empty":String(t)}function gt(e,t){return Ce(e,t)??Le(t)}function Ce(e,t){if(!e)return;let n=new Map(t.map(a=>[a.requestedBefore,a])),o=new Set,r=new Set,s=e;for(;s;){if(r.has(s))return;r.add(s);let a=n.get(s);if(!a)return o.size>0&&o.size===t.length?void 0:s;o.add(a);let l=vt(o),d=Nt(t.filter(S=>!o.has(S)));if(l!==void 0&&d!==void 0&&l<=d+1)return;s=a.previousCursor}}function mt(e,t){return t.some(n=>n.eventHistory.status!==e.eventHistory.status)}function vt(e){let t;for(let n of e){let o=n.events[0]?.seq;o!==void 0&&(t===void 0||o<t)&&(t=o)}return t}function Nt(e){let t;for(let n of e){let o=n.events.at(-1)?.seq;o!==void 0&&(t===void 0||o>t)&&(t=o)}return t}function Le(e){let t;for(let n of e){let o=n.events[0]?.seq,r=t?.events[0]?.seq;o!==void 0&&(r===void 0||o<r)&&(t=n)}return t?.previousCursor}function yt(e){return[...new Map(e.map(t=>[t.seq,t])).values()].sort((t,n)=>t.seq-n.seq)}function ht(e,t){if(e.eventHistory.status!=="available")return dt(e);let n=t.find(o=>o.eventHistory.status!=="available");if(n)return dt({...e,eventHistory:n.eventHistory,events:n.events,previousCursor:n.previousCursor})}function dt(e){let{modelUsage:t,...n}=e;return n}function bt(e,t){if(!e)return t;let n=Ut(e.events,t.events)?e.events:t.events,o=JSON.stringify(e.annotations)===JSON.stringify(t.annotations)?e.annotations:t.annotations,r=JSON.stringify(e.authors)===JSON.stringify(t.authors)?e.authors:t.authors;return n===t.events&&o===t.annotations&&r===t.authors?t:{...t,events:n,annotations:o,authors:r}}function Ut(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let o=e[n],r=t[n];if(o.seq!==r.seq||o.createdAt!==r.createdAt||o.data.type==="message"&&r.data.type==="message"&&JSON.stringify(o.data.attachments)!==JSON.stringify(r.data.attachments))return!1}return!0}function In(e){if(e?.status!=="active")return!1;for(let t=e.events.length-1;t>=0;t-=1){let n=e.events[t].data;if(n.type==="turn_lifecycle")return n.state==="started"}return!!e.previousCursor}function M(e){return["conversation",e,"detail"]}var kt=500,Bt=6e3,Kt=3e4;function Qt(e,t){let n=M(t),o=e.getQueryState(n);if(!o?.data?.prefetchedAtMs)return;let{prefetchedAtMs:r,...s}=o.data;e.setQueryData(n,s,{updatedAt:o.dataUpdatedAt})}function Ft(e){return!!(e?.prefetchedAtMs&&Date.now()-e.prefetchedAtMs<Kt)}var Vt=["agents","memories","watches"];function jt(e,t){return["conversation",e,t]}function $t(e,t,n,o){if(!(!n?.detailEtag||!o.detailEtag||n.detailEtag===o.detailEtag)){for(let r of Vt)e.invalidateQueries({queryKey:jt(t,r)});e.invalidateQueries({queryKey:ee})}}function zt(e,t){return{enabled:!!e,queryKey:M(e),queryFn:async({signal:n,client:o})=>{let r=o.getQueryData(M(e)),s=await Yt(e,n,r,{mailbox:!0,unreadPage:t?.unreadPage});return $t(o,e,r,s),s},structuralSharing:(n,o)=>!o||typeof o!="object"||!n||typeof n!="object"?o:Wt(n,bt(n,o)),refetchInterval:n=>t?.fastPollUntilMs&&Date.now()<t.fastPollUntilMs?kt:t?.awaitingMessage||n.state.data?.status==="active"||n.state.data?.mailbox?.messages.length||n.state.data?.mailbox?.authorization?2e3:1e4,retry:!1}}function Wt(e,t){let n=e.readPosition;if(!n||(t.readPosition?.lastReadSeq??-1)>=n.lastReadSeq)return t;let{unreadCursor:o,unreadPage:r,...s}=t;return{...s,readPosition:n,...e.unreadCursor?{unreadCursor:e.unreadCursor,unreadPage:e.unreadPage}:void 0}}function Kn(){let e=H();return U({mutationFn:t=>z(pe,"/api/conversations",t),onSuccess:(t,n)=>{e.setQueryData(J(t.conversationId),o=>be(o,{...ye({...n,actorIdentity:ve(e),inline:!0,messageId:t.messageId}),status:"accepted"})),e.invalidateQueries({queryKey:["dashboard","conversations"]}),e.invalidateQueries({exact:!0,queryKey:M(t.conversationId)})}})}function Qn(e){let t=H();return U({mutationFn:async n=>{let o=await z(Ne,`/api/conversations/${encodeURIComponent(e)}/forks`,{messageId:n.messageId,idempotencyKey:n.idempotencyKey});return z(pe,`/api/conversations/${encodeURIComponent(o.conversationId)}/messages`,{idempotencyKey:n.idempotencyKey,message:n.message})},onSuccess:(n,o)=>{t.setQueryData(J(n.conversationId),r=>be(r,{...ye({idempotencyKey:o.idempotencyKey,message:o.message,actorIdentity:ve(t),inline:!0,messageId:n.messageId}),status:"accepted"})),t.invalidateQueries({queryKey:["dashboard","conversations"]})}})}function Fn(e){let t=H(),n=J(e);return U({mutationFn:({inline:o,...r})=>z(pe,`/api/conversations/${encodeURIComponent(e)}/messages`,r),onMutate:async o=>{let r=await ke({conversationId:e,idempotencyKey:o.idempotencyKey}),s=ye({...o,actorIdentity:ve(t),messageId:r});t.setQueryData(n,a=>be(a,s))},onError:(o,r)=>{t.setQueryData(n,s=>lt(s,r.idempotencyKey))},onSuccess:(o,r)=>{t.setQueryData(n,s=>ct(s,r.idempotencyKey,o.messageId)),t.invalidateQueries({queryKey:["dashboard","conversations"]}),t.invalidateQueries({exact:!0,queryKey:M(e)})}})}function Vn(e){let t=H();return U({mutationFn:n=>Xe(Fe,`/api/conversations/${encodeURIComponent(e)}/pending-messages`,n),onMutate:async n=>{await t.cancelQueries({exact:!0,queryKey:M(e)});let o=t.getQueryData(M(e));return o?.mailbox&&t.setQueryData(M(e),{...o,mailbox:{...o.mailbox,messages:o.mailbox.messages.filter(r=>!n.inboundMessageIds.includes(r.inboundMessageId))}}),{previousPending:o}},onError:(n,o,r)=>{r?.previousPending&&t.setQueryData(M(e),s=>s&&{...s,mailbox:r.previousPending?.mailbox})},onSettled:async()=>{await Promise.all([t.invalidateQueries({queryKey:["dashboard","conversations"]}),t.invalidateQueries({exact:!0,queryKey:M(e)})])}})}function jn(e){let t=H();return U({mutationFn:n=>z(Ve,`/api/conversations/${encodeURIComponent(e)}/pending-messages/steer`,n),onSuccess:async n=>{let o=new Set(n.steeredInboundMessageIds);o.size!==0&&(await t.cancelQueries({exact:!0,queryKey:M(e)}),t.setQueryData(M(e),r=>r?.mailbox?{...r,mailbox:{...r.mailbox,messages:r.mailbox.messages.map(s=>o.has(s.inboundMessageId)?{...s,delivery:"interrupt"}:s)}}:r))},onSettled:async()=>{await t.invalidateQueries({exact:!0,queryKey:M(e)})}})}function Ie(e){return["conversation",e,"stopped-messages"]}function $n(e){let t=H();return U({mutationFn:()=>z(je,`/api/conversations/${encodeURIComponent(e)}/stop`,{}),onSuccess:n=>{let o=n.stoppedInboundMessageIds;o.length&&(t.setQueryData(Ie(e),r=>[...r??[],...o]),t.setQueryData(J(e),r=>r?.filter(s=>!o.includes(s.messageId))))},onSettled:async()=>{await t.invalidateQueries({exact:!0,queryKey:M(e)})}})}function zn(e,t){let n=H(),o=()=>{let g=Ft(n.getQueryData(M(e)));return{conversationId:e,fetched:g,prefetched:g}},[r,s]=(0,E.useState)(o);r.conversationId!==e&&s(o());let a=r.conversationId===e&&r.fetched,l=r.conversationId===e&&r.prefetched,d=$({enabled:!!e,queryFn:async()=>n.getQueryData(J(e))??[],queryKey:J(e),initialData:[],staleTime:1/0,gcTime:1/0}),S=$({enabled:!!e,queryFn:async()=>n.getQueryData(Ie(e))??[],queryKey:Ie(e),initialData:[],staleTime:1/0,gcTime:1/0}),K=d.data.filter(g=>g.status!=="failed"),Q=Math.max(0,...K.map(g=>Date.parse(g.createdAt))),C=$({...zt(e,{awaitingMessage:K.length>0,fastPollUntilMs:Q?Q+Bt:void 0,unreadPage:!!t?.unreadPageAtOpen&&!a})}),D=C.refetch;(0,E.useEffect)(()=>{if(e)return D({cancelRefetch:!1}),()=>Qt(n,e)},[e,n,D]),!a&&C.isFetchedAfterMount&&!C.isFetching&&s({conversationId:e,fetched:!0,prefetched:l});let F=(0,E.useDeferredValue)(C.data),v=F&&F.conversationId===e?F:C.data,x=v?.mailbox;(0,E.useEffect)(()=>{if(!x||!v)return;let g=new Set(x.messages.map(y=>y.messageId)),R=new Set;for(let y of v.events)y.data.type==="message"&&R.add(y.data.messageId);n.setQueryData(J(e),y=>{let j=y?.filter(P=>!R.has(P.messageId)&&(Te(P)||!g.has(P.messageId)));return j?.length===y?.length?y:j})},[e,v,x,d.data,n]);let V=C.data?.displayTitle,m=C.dataUpdatedAt;(0,E.useEffect)(()=>{if(!e||!V)return;let g=n.getQueryCache().findAll({queryKey:["dashboard","conversations"]});for(let R of g){let y=R.state.data;!y||R.state.dataUpdatedAt>m||!y.conversations.some(P=>P.conversationId===e&&P.displayTitle!==V)||n.setQueryData(R.queryKey,{...y,conversations:y.conversations.map(P=>P.conversationId===e?{...P,displayTitle:V}:P)})}},[e,m,V,n]);let h=v?.eventHistory.status,T=(0,E.useMemo)(()=>["conversation",e,"history",h],[e,h]),p=fe({enabled:!1,queryKey:T,queryFn:async({pageParam:g,signal:R})=>({...await St(e,g,R),requestedBefore:g}),initialPageParam:v?.previousCursor??"",getNextPageParam:(g,R)=>gt(v?.previousCursor,R),retry:!1}),X=p.data?.pages,ce=(0,E.useMemo)(()=>v?Pe(v,X??[]):void 0,[v,X]),I=(0,E.useRef)(void 0),le=(0,E.useRef)(void 0),{inlineMessages:de,pendingMessages:Y}=(0,E.useMemo)(()=>{let g=S.data,R=g.length?x?.messages.filter(i=>!g.includes(i.inboundMessageId)):x?.messages,y=g.length?d.data.filter(i=>!g.includes(i.messageId)):d.data,j=ut(at(R,y),R,y),P=he(I.current,j.queued),c=he(le.current,j.inline);return I.current=P,le.current=c,{inlineMessages:c,pendingMessages:P}},[d.data,x?.messages,S.data]),f=Jt(p.error),_=!!(v&&(mt(v,X??[])||f)),te=f?null:p.error,G=!!(v?.previousCursor&&p.data&&Ce(v.previousCursor,p.data.pages)&&!_&&!p.error&&!p.isFetchingNextPage),Z=p.isFetchingNextPage||G;(0,E.useEffect)(()=>{_&&D()},[D,_]),(0,E.useEffect)(()=>{f&&n.resetQueries({exact:!0,queryKey:T})},[T,f,n]);let N=p.fetchNextPage;return(0,E.useEffect)(()=>{G&&N({cancelRefetch:!1})},[N,G]),{data:ce,latest:C.data,error:C.error,historyError:te,historyVersion:pt(X??[]),hasPreviousPage:p.data?p.hasNextPage:!!v?.previousCursor,isPending:C.isPending,fetchedAtOpen:a,fetchedDetail:l||C.isFetchedAfterMount&&!C.isFetching?C.data:void 0,isLoadingPreviousPage:Z,pendingAuthorization:x?.authorization,pendingGeneratedAt:x?.generatedAt,inlineMessages:de,pendingMessages:Y,loadCompleteTranscript:()=>{if(!e||!v)throw new Error("Cannot load a conversation without an id");return ft({detail:v,historyPages:p.data?.pages??[],readPage:g=>St(e,g)})},loadPreviousPage:()=>{let g=p.data?p.hasNextPage:!!v?.previousCursor;e&&g&&p.fetchNextPage({cancelRefetch:!1})}}}async function Yt(e,t,n,o){let r=new URLSearchParams;o?.unreadPage&&r.set("unreadPage","true"),o?.mailbox&&r.set("mailbox","true");let s=o?.unreadPage?void 0:n?.appendCursor;s&&r.set("after",s);let a=r.size?`?${r}`:"",l=await Ge(`/api/conversations/${encodeURIComponent(e)}${a}`,t,n?.detailEtag?{[Ee]:n.detailEtag}:void 0);if(l.status===304&&n)return n;if(!o?.mailbox)return wt(Ct(await xe(l,ge),n),l);let d=await xe(l,_e([Qe,Ke]));if(!("unchanged"in d))return wt(Ct(d,n),l);if(!n)throw new Error("Unchanged detail without a cached copy");return{...n,mailbox:d.mailbox}}function Ct(e,t){if(!e.appended)return e;if(!t)throw new Error("Appended detail without a cached copy");let{appended:n,...o}=e,r=t.events.at(-1)?.seq??-1,s=t.events[0]?.seq,a=o.readPosition!==void 0&&s!==void 0&&o.readPosition.lastReadSeq+1<s;return{...o,events:[...t.events,...e.events.filter(l=>l.seq>r)],...t.previousCursor?{previousCursor:t.previousCursor}:void 0,...a&&t.unreadCursor?{unreadCursor:t.unreadCursor,unreadPage:t.unreadPage}:void 0}}function wt(e,t){return{...e,detailEtag:t.headers.get(Ee)??void 0}}function St(e,t,n){let o=new URLSearchParams({before:t});return W(Ue,`/api/conversations/${encodeURIComponent(e)}/events?${o}`,n).then(r=>{if(r.previousCursor===t)throw new Error("Conversation history cursor did not advance");return r})}function Jt(e){return e instanceof Ye&&e.status===400}var u=se(ae(),1);var we="data-scroll-anchor";function Xt(e,t,n){let o=0,r=e;for(;o<r;){let s=o+r>>1;t(s).bottom<=n.top?o=s+1:r=s}return o>=e?null:t(o).top>=n.top?o:o+1<e&&t(o+1).top<n.bottom?o+1:o}function Rt(e,t){let n=e.querySelectorAll(`[${we}]`),o=new Map,r=l=>{let d=o.get(l);return d||(d=n[l].getBoundingClientRect(),o.set(l,d)),d},s=Xt(n.length,r,t);if(s===null)return null;let a=n[s];return{element:a,key:a.getAttribute(we)??"",offset:r(s).top-t.top}}function Et(e,t,n){let o=n.element.isConnected?n.element:Gt(e,n.key);return o?o.getBoundingClientRect().top-t.top-n.offset:null}function Gt(e,t){for(let n of e.querySelectorAll(`[${we}]`))if(n.getAttribute(we)===t)return n;return null}var Zt=96,Mt=600,xt=2,en=48,Oe="data-transcript-pin-start",tn=16;function Xn(e){return{[Oe]:e}}var ie=typeof window>"u"?u.useEffect:u.useLayoutEffect;function ue(e,t=Zt){return e.scrollHeight-e.scrollTop-e.clientHeight<=t}function Gn(e){if(!e)return"empty";for(let t=e.events.length-1;t>=0;t-=1){let n=e.events[t],o=n.data;if(o.type==="message"&&o.role==="assistant")return[n.seq,n.createdAt,o.messageId,o.redacted?"redacted":o.text?.length??0].join(":");if(o.type==="assistant_message"&&o.parts.length>0){let r=o.parts.at(-1);return[n.seq,n.createdAt,o.parts.length,r?.redacted?"redacted":r?.text?.length??0].join(":")}}return"empty"}function Zn(e,t="rich"){if(!e)return"empty";let n;for(let o=e.events.length-1;o>=0;o-=1){let r=e.events[o];if(!(t==="rich"&&!nn(r))){n=r;break}}return[e.conversationId,e.status,n?.seq??"",n?.createdAt??"",on(n)].join("|")}function nn(e){let t=e.data;return t.type==="turn_lifecycle"?t.state==="failed":t.type==="message"||t.type==="assistant_message"&&t.parts.length>0||t.type==="tool_calls"||t.type==="subagent"||t.type==="structured_event"||t.type==="attachments_delivered"||t.type==="compaction"}function on(e){if(!e)return"";let t=e.data;switch(t.type){case"message":return[t.type,t.role,t.messageId,t.redacted?"redacted":t.text?.length??0,t.eventType??""].join(":");case"assistant_message":{let n=t.parts,o=n.at(-1);return[t.type,n.length,o?.redacted?"redacted":o?.text?.length??0].join(":")}case"tool_calls":{let n=t.calls.at(-1);return[t.type,t.calls.length,n?.toolCallId??"",n?.name??"",n?.status??"",n?.output===void 0?"":"output"].join(":")}case"subagent":return[t.type,t.childConversationId,t.status,t.subagentKind,t.parentToolCallId??""].join(":");case"turn_lifecycle":return[t.type,t.turnId,t.state,"failureCode"in t?t.failureCode:"","failureReason"in t?t.failureReason??"":""].join(":");case"structured_event":return[t.type,t.namespace,t.name,t.version,t.presentation.title,t.presentation.preview?.length??0].join(":");case"message_handled":return[t.type,t.messageId].join(":");case"attachments_delivered":return[t.type,t.attachments.length,...t.attachments.map(n=>`${n.id}:${n.filename}:${n.bytes}`)].join(":");case"compaction":return[t.type,t.summary?.length??0,e.createdAt].join(":");case"guardian_action_reviewed":return[t.type,t.turnId,t.toolCallId,t.decision].join(":");case"turn_context":return[t.type,t.turnId,t.pluginName,t.kind,t.version].join(":");default:return`${t.type??"unknown"}:${e.seq}`}}function rn(e){return e.enabled&&e.following}function sn(e){if(e.enabled)return{pending:!1,pin:!1};let t=e.pending||e.wasEnabled&&!e.enabled&&e.following;return t&&e.juniorMessageChanged?{pending:!1,pin:!0}:{pending:t,pin:!1}}function an(e){return!e.following&&(e.endsAtLatest===!1||!!e.openedAtUnread||e.enabled&&e.hasPendingUpdate)}function un(e){return e.source==="scroll"&&e.previousScrollTop!=null&&e.snapshot.scrollTop<e.previousScrollTop-xt?"pause":e.source==="scroll"&&ue(e.snapshot)?"follow":"preserve"}function cn(e){return e.intent==="pause"&&!ue(e.snapshot)?"pause":"ignore"}function eo(e){let t=(0,u.useRef)(null),n=(0,u.useRef)(null),o=(0,u.useRef)(e.enabled),r=(0,u.useRef)(!0);r.current=e.endsAtLatest??!0;let s=(0,u.useRef)(!1),a=(0,u.useRef)(!1),l=(0,u.useRef)(null),d=(0,u.useRef)(null),S=(0,u.useRef)(null),K=(0,u.useRef)(null),Q=(0,u.useRef)(e.pinRequestVersion??0),C=(0,u.useRef)(e.juniorMessageVersion),D=(0,u.useRef)(e.enabled),F=(0,u.useRef)(!1),v=(0,u.useRef)(e.versions),x=(0,u.useRef)(0),V=(0,u.useRef)(new Set),[m,h]=(0,u.useState)(!1),[T,p]=(0,u.useState)(!1),[X,ce]=(0,u.useState)(!1),[I,le]=(0,u.useState)(null),de=(0,u.useCallback)(c=>{n.current=c,le(c)},[]);(0,u.useEffect)(()=>{o.current=e.enabled,e.enabled||p(!1)},[e.enabled]);let Y=(0,u.useRef)(!1),f=(0,u.useCallback)(c=>{s.current=c,h(c),c?ce(!1):Y.current=!1},[]),_=(0,u.useCallback)(()=>{let c=n.current,i=q(c);!c||!i||(K.current=Rt(c,Ae(i)))},[]),te=(0,u.useCallback)(()=>{let c=n.current,i=q(c),w=K.current;if(!c||!i)return;let L=w?Et(c,Ae(i),w):null;if(L!==null&&Math.abs(L)>=1){let b=O(i).scrollTop+L;Se(i,b);let A=O(i).scrollTop;d.current=A,S.current=A}_()},[_]),G=(0,u.useCallback)(()=>{if(!s.current)return;let c=q(n.current);!c||O(c).scrollTop<=0||(x.current=0,f(!1))},[f]),Z=(0,u.useCallback)(c=>{let i=q(n.current);if(!i)return;let w=O(i),L=d.current;if(d.current=w.scrollTop,c==="scroll"){let A=S.current;if(S.current=null,A!==null&&Math.abs(w.scrollTop-A)<1)return;_()}let b=un({previousScrollTop:L,snapshot:w,source:c});if(c==="scroll"&&x.current>0){cn({intent:b,snapshot:w})==="pause"&&(x.current=0,f(!1));return}if(b==="follow"){if(!r.current)return;f(!0),p(!1);return}b==="pause"&&f(!1)},[_,f]),N=(0,u.useCallback)(c=>{let i=q(n.current);if(!i)return;let w=ln(i,n.current,V.current);w!==null&&f(!1);let L=w!==null||s.current,b=L?++x.current:0;Se(i,w??O(i).scrollHeight,c);let A=()=>{if(L&&x.current!==b)return;L&&(x.current=0);let oe=O(i);d.current=oe.scrollTop,o.current&&s.current&&ue(oe)&&(f(!0),p(!1))};if(c==="smooth"){window.setTimeout(A,400);return}requestAnimationFrame(()=>{requestAnimationFrame(A)})},[f]),g=(0,u.useCallback)(()=>{let c=n.current,i=q(c),w=c?.querySelector("[data-transcript-unread-marker]");if(!i||!w)return!1;Y.current=!1;let L=w.getBoundingClientRect().top-Ae(i).top;Se(i,Math.max(0,O(i).scrollTop+L-en));let b=O(i);d.current=b.scrollTop,S.current=b.scrollTop;let A=r.current&&ue(b);return f(A),ce(!A),_(),!0},[_,f]);ie(()=>{if(!I||!e.conversationId)return;let c=`${e.conversationId}:${e.startAtLink?"link":"start"}`;if(l.current===c)return;let i=q(I);if(i){if(l.current=c,p(!1),e.startAtLink){d.current=O(i).scrollTop,f(!1);return}e.startAtUnread&&g()||(Se(i,O(i).scrollHeight),d.current=O(i).scrollTop,f(!0),Y.current=!!e.startAtUnread)}},[I,e.conversationId,e.startAtLink,e.startAtUnread,g,f]);let R=(0,u.useCallback)(()=>{if(!(Y.current&&g())){if(!r.current){f(!1),te();return}N("auto")}},[g,te,N,f]),y=(0,u.useCallback)(()=>{if(s.current){R();return}te(),Z("measure")},[R,Z,te]);ie(()=>{y()},[e.historyVersion,y]),ie(()=>{let c=v.current[e.view]!==e.versions[e.view];v.current=e.versions;let i=o.current;if(a.current&&!c&&i===e.enabled)return;let w=e.enabled||i;if(o.current=e.enabled,!w)return;let L=a.current;if(a.current||(a.current=!0),e.enabled&&!i){let b=q(n.current);b&&f(ue(O(b)))}if(rn({enabled:e.enabled,following:s.current})){R(),p(!1);return}e.enabled&&L&&p(!0)},[e.enabled,e.view,e.versions.rich,e.versions.raw,R,f]),(0,u.useEffect)(()=>{if(typeof window>"u"||!I)return;let c=q(I);if(!c)return;let i=c,w=()=>Z("scroll"),L=re=>{re.deltaY<0&&G()},b=null,A=re=>{b=re.touches[0]?.clientY??null},oe=re=>{let Re=re.touches[0]?.clientY;Re===void 0||b===null||(Re>b+xt&&G(),b=Math.min(b,Re))};return Z("measure"),_(),i.addEventListener("scroll",w,{capture:!0,passive:!0}),i.addEventListener("wheel",L,{passive:!0}),i.addEventListener("touchstart",A,{passive:!0}),i.addEventListener("touchmove",oe,{passive:!0}),window.addEventListener("resize",y),()=>{i.removeEventListener("scroll",w,{capture:!0}),i.removeEventListener("wheel",L),i.removeEventListener("touchstart",A),i.removeEventListener("touchmove",oe),window.removeEventListener("resize",y)}},[I,G,Z,_,y]),(0,u.useEffect)(()=>{if(typeof ResizeObserver>"u"||!I)return;let c=new ResizeObserver(()=>{y()});c.observe(I);let i=q(I);return i&&!ne(i)&&c.observe(i),()=>c.disconnect()},[I,y]);let j=(0,u.useCallback)(()=>{Y.current=!1,f(!0),p(!1),N(dn())},[N,f]);ie(()=>{let c=C.current!==e.juniorMessageVersion;C.current=e.juniorMessageVersion;let i=sn({enabled:e.enabled,following:s.current,juniorMessageChanged:c,pending:F.current,wasEnabled:D.current});D.current=e.enabled,F.current=i.pending,i.pin&&(f(!0),p(!1),N("auto"))},[e.enabled,e.juniorMessageVersion,N,f]),ie(()=>{let c=e.pinRequestVersion??0;c!==Q.current&&(Q.current=c,Y.current=!1,f(!0),p(!1),N("auto"))},[e.pinRequestVersion,N,f]);let P=(0,u.useCallback)(()=>K.current?.key,[]);return(0,u.useMemo)(()=>({anchorRef:t,contentElement:I,contentRef:de,hasPendingUpdate:T,jumpToBottom:j,scrollAnchorKey:P,showJumpToLatest:an({enabled:e.enabled,endsAtLatest:e.endsAtLatest,following:m,hasPendingUpdate:T,openedAtUnread:X})}),[I,de,m,T,e.enabled,e.endsAtLatest,j,X,P])}var to=(0,u.createContext)(void 0);function no(e){let[t,n]=(0,u.useState)(null),o=(0,u.useRef)(e.onLoad);return o.current=e.onLoad,(0,u.useEffect)(()=>{if(!e.enabled||!t||typeof IntersectionObserver>"u")return;let r=q(t),s=new IntersectionObserver(a=>{a.some(l=>l.isIntersecting)&&(s.disconnect(),o.current())},{root:r&&!ne(r)?r:null,rootMargin:e.edge==="top"?`${Mt}px 0px 0px 0px`:`0px 0px ${Mt}px 0px`});return s.observe(t),()=>s.disconnect()},[e.edge,e.enabled,e.historyVersion,t]),n}function q(e){if(typeof window>"u")return null;if(!e)return window;let t=e.parentElement;for(;t&&t!==document.body;){let n=window.getComputedStyle(t);if(/(auto|scroll|overlay)/.test(n.overflowY))return t;t=t.parentElement}return window}function ln(e,t,n){let o=t?Array.from(t.querySelectorAll(`[${Oe}]`)).at(-1):void 0,r=o?.getAttribute(Oe);if(!o||!r||n.has(r))return null;let s=o.getBoundingClientRect();if(s.height===0)return null;n.add(r);let a=O(e),l=a.scrollTop-(ne(e)?0:e.getBoundingClientRect().top),d=s.top+l-tn,S=a.scrollHeight-a.clientHeight;return d>=S||s.bottom+l<=S?null:Math.max(0,d)}function O(e){if(ne(e)){let t=document.scrollingElement??document.documentElement;return{clientHeight:window.innerHeight,scrollHeight:t.scrollHeight,scrollTop:window.scrollY||t.scrollTop}}return{clientHeight:e.clientHeight,scrollHeight:e.scrollHeight,scrollTop:e.scrollTop}}function Se(e,t,n="auto"){if(ne(e)){window.scrollTo({behavior:n,top:t});return}e.scrollTo({behavior:n,top:t})}function Ae(e){if(ne(e))return{bottom:window.innerHeight,top:0};let t=e.getBoundingClientRect().top;return{bottom:t+e.clientHeight,top:t}}function ne(e){return e===window}function dn(){return typeof window>"u"||typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches?"auto":"smooth"}var fn=750,Pt="data-transcript-seq",Tt=`[${Pt}]`,Lt="junior:conversation:start-position";function lo(){return ot(Lt,"unread")}function fo(){if(typeof window>"u")return"unread";try{let e=window.localStorage.getItem(Lt);return e&&JSON.parse(e)==="latest"?"latest":"unread"}catch{return"unread"}}function po(e,t){let[n,o]=(0,B.useState)(),[r,s]=(0,B.useState)(),a=n??(e?{lastReadSeq:e.readPosition?.lastReadSeq}:void 0);!n&&a&&o(a);let l=r??(t?{throughSeq:t.events.at(-1)?.seq,unreadCursor:t.unreadCursor,unreadPage:t.unreadPage}:void 0);return!r&&l&&s(l),{...pn(a?.lastReadSeq,l?l.throughSeq:e?.events.at(-1)?.seq),...l?.unreadCursor?{unreadCursor:l.unreadCursor,unreadPage:l.unreadPage}:void 0}}function pn(e,t){return e===void 0?{}:t===void 0||t<=e?{lastReadSeq:e}:{lastReadSeq:e,unread:{afterSeq:e,throughSeq:t}}}function gn(e,t){let n=e.events[0]?.seq;if(!e.unreadCursor||n!==void 0&&t.lastReadSeq+1<n)return{...e,readPosition:t};let{unreadCursor:o,unreadPage:r,...s}=e;return{...s,readPosition:t}}function go(e){let t=H(),{mutate:n}=U({mutationFn:o=>Je(He,`/api/conversations/${encodeURIComponent(e)}/read-position`,{lastReadSeq:o}),onSuccess:o=>{t.setQueryData(M(e),r=>r&&gn(r,o))}});return(0,B.useCallback)(o=>{let r=t.getQueryData(M(e))?.readPosition?.lastReadSeq;r!==void 0&&o<=r||n(o)},[e,n,t])}function mo(e){let t=(0,B.useRef)(e.onRead);t.current=e.onRead;let n=(0,B.useRef)(e.paused);n.current=e.paused;let o=(0,B.useRef)(e.lastReadSeq??-1),r=!!e.onRead;(0,B.useEffect)(()=>{let s=e.content,a=q(s);if(!r||!s||!a||typeof IntersectionObserver>"u")return;let l=new Set,d,S=null,K=()=>{d!==void 0&&window.clearTimeout(d),d=void 0;let m=S;S=null,!(m===null||m<=o.current)&&(o.current=m,t.current?.(m))},Q=()=>{if(!(n.current||document.visibilityState!=="visible")){for(let m of l){let h=Number(m.dataset.transcriptSeq);Number.isSafeInteger(h)&&(S=Math.max(S??-1,h))}S!==null&&(d??=window.setTimeout(K,fn))}},C=()=>{document.visibilityState==="visible"?Q():K()},D=new IntersectionObserver(m=>{for(let h of m){let T=h.target;h.isIntersecting&&T.isConnected?l.add(T):l.delete(T)}Q()},{root:a===window?null:a}),F=m=>{if(!(m instanceof HTMLElement))return[];let h=[...m.querySelectorAll(Tt)];return m.matches(Tt)?[m,...h]:h},v=m=>{for(let h of F(m))D.observe(h)},x=m=>{for(let h of F(m))D.unobserve(h),l.delete(h)},V=new MutationObserver(m=>{let h=!1;for(let T of m)if(T.addedNodes.forEach(v),T.removedNodes.forEach(x),T.type==="attributes"){let p=T.target;D.observe(p),h||=l.has(p)}h&&Q()});return V.observe(s,{attributeFilter:[Pt],childList:!0,subtree:!0}),v(s),document.addEventListener("visibilitychange",C),()=>{K(),D.disconnect(),V.disconnect(),document.removeEventListener("visibilitychange",C)}},[r,e.content])}export{Cn as a,wn as b,Sn as c,Rn as d,En as e,Mn as f,Dt as g,xn as h,Ln as i,pt as j,In as k,M as l,jt as m,$t as n,zt as o,Kn as p,Qn as q,Fn as r,Vn as s,jn as t,$n as u,zn as v,Yt as w,St as x,ot as y,Xn as z,Gn as A,Zn as B,eo as C,to as D,no as E,q as F,lo as G,fo as H,po as I,go as J,mo as K};
|