@sentry/junior-dashboard 0.291.0 → 0.292.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 +3 -3
- package/dist/client-manifest.json +1 -1
- package/dist/index.js +3 -3
- package/dist/public/chunks/{AdminPage-nus5ycri.js → AdminPage-fdz3hucf.js} +1 -1
- package/dist/public/chunks/{Area-gt1sdk4c.js → Area-f1nin66q.js} +1 -1
- package/dist/public/chunks/{AutomationPage-gkkuw17m.js → AutomationPage-d5mdkrn9.js} +3 -3
- package/dist/public/chunks/{AutomationRunDetails-najm4x1j.js → AutomationRunDetails-hyjcewq8.js} +1 -1
- package/dist/public/chunks/AutomationRunsPage-fcez9yb2.js +1 -0
- package/dist/public/chunks/AutomationsPage-in07jyvb.js +15 -0
- package/dist/public/chunks/{BarChart-nm91dx0i.js → BarChart-hdlbq093.js} +1 -1
- package/dist/public/chunks/{BoardPage-bnp4bh2y.js → BoardPage-jmv26j4s.js} +1 -1
- package/dist/public/chunks/{CodeChangeRow-l7msz02v.js → CodeChangeRow-enn40527.js} +2 -2
- package/dist/public/chunks/CodePage-ous0utk0.js +1 -0
- package/dist/public/chunks/{CodeSummaryCards-ko46g18h.js → CodeSummaryCards-d2oxdoq1.js} +1 -1
- package/dist/public/chunks/{ConnectionsPage-bs0trwlu.js → ConnectionsPage-lilwyiau.js} +2 -2
- package/dist/public/chunks/{DrawerContent-clt2v4h5.js → DrawerContent-jg0soa2u.js} +1 -1
- package/dist/public/chunks/{FilterBar-k012tagh.js → FilterBar-lsllb7tj.js} +1 -1
- package/dist/public/chunks/{FormNotice-ndbxjxml.js → FormNotice-mmzuj60h.js} +1 -1
- package/dist/public/chunks/{LocationDetailPage-lmq3fzwb.js → LocationDetailPage-cf82jjul.js} +1 -1
- package/dist/public/chunks/{LocationsPage-iuycwgrk.js → LocationsPage-g9b4zhrs.js} +1 -1
- package/dist/public/chunks/{McpSettingsPage-jt621pk7.js → McpSettingsPage-gibci7qd.js} +1 -1
- package/dist/public/chunks/{PeoplePage-cq7tlf7s.js → PeoplePage-cphdlfgf.js} +1 -1
- package/dist/public/chunks/{PersonProfilePage-k6z8ayic.js → PersonProfilePage-mf6i9tif.js} +1 -1
- package/dist/public/chunks/{PersonalTokensPage-f3zhm3px.js → PersonalTokensPage-iodbv05e.js} +1 -1
- package/dist/public/chunks/PluginReportRecordSet-fossppyd.js +1 -0
- package/dist/public/chunks/{PluginUserPage-mjr7t9js.js → PluginUserPage-ismd883z.js} +2 -2
- package/dist/public/chunks/RepositoryPage-dwvax7uv.js +1 -0
- package/dist/public/chunks/SettingsPage-f9kssan6.js +1 -0
- package/dist/public/chunks/{SystemPage-f9sgyr71.js → SystemPage-a5t28k3w.js} +1 -1
- package/dist/public/chunks/{WorkspaceFormPage-ovra0hwr.js → WorkspaceFormPage-h21lnuo4.js} +2 -2
- package/dist/public/chunks/WorkspacesPage-h0lwq044.js +1 -0
- package/dist/public/chunks/{automationFormat-f3vjb9y9.js → automationFormat-nmiq4qj2.js} +1 -1
- package/dist/public/chunks/{chart-peynklgr.js → chart-dbzd0ka8.js} +1 -1
- package/dist/public/chunks/{code-highlighter-jcl4p6jg.js → code-highlighter-lmx9nqyd.js} +1 -1
- package/dist/public/chunks/{format-li35oiyp.js → format-c4b0iyrx.js} +1 -1
- package/dist/public/chunks/{junior-g9xga7oj.js → junior-gfsokzu9.js} +1 -1
- package/dist/public/chunks/{workspaceQueries-ocke5763.js → workspaceQueries-l3p6sri7.js} +1 -1
- package/dist/public/{client-h0cvcz8x.js → client-mgf2bxi7.js} +13 -13
- package/package.json +4 -4
- package/src/client/conversations/ConversationWorkspace.tsx +45 -30
- package/dist/public/chunks/AutomationRunsPage-bx3nhkyu.js +0 -1
- package/dist/public/chunks/AutomationsPage-o1gvds5a.js +0 -15
- package/dist/public/chunks/CodePage-eb9xfehg.js +0 -1
- package/dist/public/chunks/PluginReportRecordSet-ovmfoi5x.js +0 -1
- package/dist/public/chunks/RepositoryPage-miaqb63z.js +0 -1
- package/dist/public/chunks/SettingsPage-ocko5gzs.js +0 -1
- package/dist/public/chunks/WorkspacesPage-m9o335es.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{C as t,S as n,_ as r,r as i}from"./vendor-react-ggbyvons.js";import{B as a,at as o,bt as s,qt as c,u as l}from"./vendor-icons-mxz7yi04.js";import{t as u}from"./coins-bqkaxeba.js";import{n as ee,r as d,t as f}from"./CodeChangeRow-l7msz02v.js";import{a as p,i as m,n as h,t as te}from"./tooltip-c9bbl0em.js";import{t as g}from"./styles-j0007fov.js";import{t as _}from"./Card-hy4bfgq7.js";import{m as v,r as y,s as b,t as x}from"./PageHeader-kvp1fo95.js";import{K as S,l as C,p as w,q as T}from"./format-li35oiyp.js";import{t as E}from"./PageLayout-l6dhbimv.js";import{n as D}from"./AnchorHeading-cp3vx8qa.js";import{Bt as O,Ft as k,Rt as A,Vt as j,f as M,pt as N}from"../client-h0cvcz8x.js";import{t as P}from"./native-select-jfknh8t4.js";import{n as F}from"./FilterBar-k012tagh.js";import{c as I}from"./chart-peynklgr.js";import{n as L,r as R,t as z}from"./PluginReportRecordSet-ovmfoi5x.js";import{t as B}from"./StatCard-i2klkqqp.js";import{n as V,t as H}from"./SectionTitle-drw3mqtl.js";var U=/* @__PURE__ */ e(t(),1),W=n();function G(e){let t=Math.max(1,...e.days.map(e=>e.conversations)),n=[],r=e.days[0]?(/* @__PURE__ */ new Date(`${e.days[0].date}T00:00:00Z`)).getUTCDay():0,i=[...Array.from({length:r},()=>null),...e.days];for(;i.length>0&&i.length%7!=0;)i.push(null);for(let e=0;e<i.length;e+=7){let t=i.slice(e,e+7);for(;t.length<7;)t.push(null);n.push(t)}n.length===0&&n.push([null,null,null,null,null,null,null]);let a=n.map((e,t)=>{let r=e.find(Boolean);if(!r)return``;let i=t>0?n[t-1]:void 0,a=i?[...i].reverse().find(Boolean):void 0;return a&&a.date.slice(0,7)===r.date.slice(0,7)?``:(/* @__PURE__ */ new Date(`${r.date}T00:00:00Z`)).toLocaleString(void 0,{month:`short`,timeZone:`UTC`})});return/* @__PURE__ */ (0,W.jsx)(`div`,{className:`overflow-x-auto px-4 py-4`,children:/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`min-w-[36rem]`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{"aria-hidden":`true`,className:`mb-1 grid gap-1 text-xs font-semibold leading-none text-dashboard-text-muted`,style:{gridTemplateColumns:`repeat(${n.length}, minmax(0.75rem, 1fr))`},children:a.map((e,t)=>/* @__PURE__ */ (0,W.jsx)(`div`,{className:`h-3 overflow-visible`,children:e},`${e}-${t}`))}),/* @__PURE__ */ (0,W.jsx)(`div`,{"aria-label":`Daily ${v()} conversation activity`,className:`grid w-full grid-flow-col grid-rows-7 gap-1`,role:`list`,style:{gridTemplateColumns:`repeat(${n.length}, minmax(0.75rem, 1fr))`},children:n.flatMap((e,n)=>e.map((e,r)=>e?/* @__PURE__ */ (0,W.jsxs)(te,{children:[/* @__PURE__ */ (0,W.jsx)(p,{render:/* @__PURE__ */ (0,W.jsx)(`span`,{"aria-label":`${e.date}: ${e.conversations} conversations, ${q(e)}, ${w({total:e.costUsd??0})} spend, ${C(e.tokens??0)} tokens`,className:g(`size-3 border border-dashboard-overlay outline-none focus-visible:ring-2 focus-visible:ring-dashboard-focus`,J(e.conversations,t)),role:`listitem`,tabIndex:0})}),/* @__PURE__ */ (0,W.jsxs)(h,{children:[/* @__PURE__ */ (0,W.jsx)(m,{children:K(e.date)}),/* @__PURE__ */ (0,W.jsx)(I,{rows:[[`conversations`,e.conversations],[`runtime`,q(e)],[`spend`,w({total:e.costUsd??0})],[`tokens`,C(e.tokens??0)]]})]})]},e.date):/* @__PURE__ */ (0,W.jsx)(`span`,{"aria-hidden":`true`,className:`size-3 border border-dashboard-overlay bg-dashboard-surface-raised`},`empty-${n}-${r}`)))}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-3 flex items-center gap-1 text-xs font-semibold leading-none text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,W.jsx)(`span`,{children:`Less`}),[0,1,2,3,4].map(e=>/* @__PURE__ */ (0,W.jsx)(`span`,{"aria-hidden":`true`,className:g(`size-3 border border-dashboard-overlay`,e===0&&`bg-dashboard-surface-hover`,e===1&&`bg-[#133225] light:bg-[#9be9a8]`,e===2&&`bg-[#176a4a] light:bg-[#40c463]`,e===3&&`bg-[#22a06b] light:bg-[#30a14e]`,e===4&&`bg-[#8bdc97] light:bg-[#216e39]`)},e)),/* @__PURE__ */ (0,W.jsx)(`span`,{children:`More`})]})]})})}function K(e){return(/* @__PURE__ */ new Date(`${e}T00:00:00Z`)).toLocaleDateString(void 0,{day:`numeric`,month:`short`,timeZone:`UTC`,year:`numeric`})}function q(e){return e.durationMs<=0&&e.conversations>0?`unknown`:T(e.durationMs)}function J(e,t){if(e<=0)return`bg-dashboard-surface-hover`;let n=e/t;return n>=.75?`bg-[#8bdc97] light:bg-[#216e39]`:n>=.45?`bg-[#22a06b] light:bg-[#30a14e]`:n>=.2?`bg-[#176a4a] light:bg-[#40c463]`:`bg-[#133225] light:bg-[#9be9a8]`}const Y=[{label:`Open`,value:`open`},{label:`Merged`,value:`merged`},{label:`Closed`,value:`closed`},{label:`All`,value:``}],X=[{label:`Any time`,value:``},{label:`Last 24 hours`,value:`1`},{label:`Last 7 days`,value:`7`},{label:`Last 30 days`,value:`30`},{label:`Last 90 days`,value:`90`}];function Z(e){let[t,n]=(0,U.useState)(`open`),[r,i]=(0,U.useState)(``),a=r?Date.parse(e.generatedAt)-Number(r)*864e5:void 0,o=e.changes.filter(e=>a===void 0||Date.parse(e.openedAt)>=a),s=o.filter(e=>!t||e.state===t),c=e=>e?o.filter(t=>t.state===e).length:o.length;return/* @__PURE__ */ (0,W.jsxs)(_,{as:`section`,children:[/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-4 border-b border-dashboard-border-subtle px-4 py-3`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-display text-lg text-dashboard-text`,children:`Recent changes`}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(F,{className:`w-36`,label:`State`,children:/* @__PURE__ */ (0,W.jsx)(P,{"aria-label":`Filter changes by state`,onChange:e=>n(e.currentTarget.value),value:t,children:Y.map(e=>/* @__PURE__ */ (0,W.jsxs)(`option`,{value:e.value,children:[e.label,` (`,c(e.value),`)`]},e.value))})}),/* @__PURE__ */ (0,W.jsx)(F,{className:`w-36`,label:`Opened`,children:/* @__PURE__ */ (0,W.jsx)(P,{"aria-label":`Filter changes by opened date`,onChange:e=>i(e.currentTarget.value),value:r,children:X.map(e=>/* @__PURE__ */ (0,W.jsx)(`option`,{value:e.value,children:e.label},e.value))})})]})]}),s.length>0?/* @__PURE__ */ (0,W.jsx)(`div`,{children:s.map(e=>/* @__PURE__ */ (0,W.jsx)(f,{change:e},e.id))}):/* @__PURE__ */ (0,W.jsx)(`div`,{className:`p-4`,children:/* @__PURE__ */ (0,W.jsx)(N,{children:t&&o.length>0?`No ${t} changes. Set State to All to see ${o.length} more.`:`No changes match these filters.`})})]})}function Q(e){return e===void 0?`—`:`${Math.round(e*100)}%`}function ne(e){return T(e)||`—`}function re(e){return w(e===void 0?void 0:{total:e})||`—`}function ie(e){let t=e.summary;return e.changes.length>0||t.created+t.merged+t.closed>0||(t.costUsd??0)>0||e.activityDays.some(e=>e.created+e.merged+e.closed>0)}function ae(e){if(!ie(e.report))return null;let t=e.report.summary;return/* @__PURE__ */ (0,W.jsxs)(`section`,{"aria-labelledby":D(`code`),className:`grid gap-4`,children:[/* @__PURE__ */ (0,W.jsx)(M,{anchor:`code`,title:`Code`}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[/* @__PURE__ */ (0,W.jsx)(B,{detail:`In the last 30 days`,icon:o,label:`Created`,value:C(t.created)}),/* @__PURE__ */ (0,W.jsx)(B,{detail:`Share of completed changes that merged`,icon:d,label:`Merge rate`,value:Q(t.mergeRate)}),/* @__PURE__ */ (0,W.jsx)(B,{detail:`Median time from open to merge in the last 30 days`,icon:l,label:`Median merge time`,value:ne(t.medianMergeTimeMs)}),/* @__PURE__ */ (0,W.jsx)(B,{detail:`Conversation cost for changes opened in the last 30 days`,icon:u,label:`Cost`,value:re(t.costUsd)})]}),/* @__PURE__ */ (0,W.jsx)(ee,{bucketUnit:b(e.range),days:y({days:e.report.activityDays,hours:e.report.activityHours,sixHours:e.report.activitySixHours,range:e.range,emptySixHour:e=>({closed:0,created:0,date:e,merged:0})}),range:e.range}),e.report.changes.length>0?/* @__PURE__ */ (0,W.jsx)(Z,{changes:e.report.changes,generatedAt:e.report.generatedAt}):null]})}function oe(e){return e.reports.length===0?null:/* @__PURE__ */ (0,W.jsx)(W.Fragment,{children:e.reports.map(t=>/* @__PURE__ */ (0,W.jsx)($,{range:e.range,report:t},t.pluginName))})}function $(e){let t=e.report.title&&e.report.title!==e.report.pluginName?e.report.title:e.report.pluginName,n=e.report.metrics??[],r=e.report.widgets??[],i=e.report.recordSets??[];if(!n.length&&!r.length&&!i.length)return null;let a=`plugin-${e.report.pluginName}`;return/* @__PURE__ */ (0,W.jsxs)(`section`,{"aria-labelledby":D(a),className:`grid gap-4`,children:[/* @__PURE__ */ (0,W.jsx)(M,{anchor:a,title:t}),n.length?/* @__PURE__ */ (0,W.jsx)(`div`,{className:g(`grid gap-px overflow-hidden rounded-md border border-dashboard-border bg-dashboard-fill-hover`,n.length===1?`grid-cols-1`:`grid-cols-2`,n.length===3?`lg:grid-cols-3`:n.length===5?`lg:grid-cols-5`:n.length>=4?`lg:grid-cols-4`:void 0),children:n.map(e=>/* @__PURE__ */ (0,W.jsxs)(`div`,{className:g(`min-w-0 bg-dashboard-surface-panel px-4 py-4`,n.length>1&&n.length%2==1&&`last:col-span-2 lg:last:col-span-1`,se(e.tone)),children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`truncate font-display text-2xl font-light leading-none text-dashboard-text`,children:e.value}),/* @__PURE__ */ (0,W.jsx)(`div`,{className:`mt-2 font-sans font-medium text-xs text-dashboard-text-muted`,children:e.label})]},e.label))}):null,r.length?/* @__PURE__ */ (0,W.jsx)(`div`,{className:g(`grid gap-3`,r.length>1?`lg:grid-cols-2`:void 0),children:r.map(t=>/* @__PURE__ */ (0,W.jsx)(L,{range:e.range,widget:t},t.id))}):null,i.map(t=>/* @__PURE__ */ (0,W.jsx)(z,{recordSet:t},`${e.report.pluginName}:${t.title}`))]})}function se(e){if(e===`danger`)return`shadow-[inset_0_2px_0_rgba(251,113,133,0.65)]`;if(e===`warning`)return`shadow-[inset_0_2px_0_rgba(251,191,36,0.65)]`;if(e===`good`)return`shadow-[inset_0_2px_0_rgba(110,231,183,0.55)]`}function ce(e,t){return e<=0&&t>0?`unknown`:T(e)}function le(){let e=r(),t=e.email?decodeURIComponent(e.email):void 0,n=j(t),i=O(t),a=A(t);return!n.data&&!n.error?/* @__PURE__ */ (0,W.jsx)(k,{label:`Loading profile`}):/* @__PURE__ */ (0,W.jsx)(E,{children:n.data?/* @__PURE__ */ (0,W.jsx)(ue,{code:a.data,codeError:!!a.error,codeLoading:a.isPending,pluginReports:i.data?.reports??[],pluginReportsError:!!i.error,pluginReportsLoading:i.isPending,profile:n.data}):/* @__PURE__ */ (0,W.jsx)(_,{padding:`md`,children:/* @__PURE__ */ (0,W.jsx)(N,{children:`Profile failed to load.`})})})}function ue(e){let[t,n]=(0,U.useState)(30),r=e.profile,o=e.pluginReports??[],l=r.actor.fullName??r.actor.slackUserName??r.actor.email;return/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid min-w-0 gap-5`,children:[/* @__PURE__ */ (0,W.jsxs)(i,{className:`flex w-fit items-center gap-2 font-display text-sm font-medium text-dashboard-text-muted no-underline transition-colors hover:text-dashboard-text`,to:`/system/people`,children:[/* @__PURE__ */ (0,W.jsx)(c,{"aria-hidden":`true`,size:15,strokeWidth:1.8}),`Back to people`]}),/* @__PURE__ */ (0,W.jsx)(x,{description:/* @__PURE__ */ (0,W.jsxs)(W.Fragment,{children:[r.actor.email,r.actor.slackUserName?` / @${r.actor.slackUserName}`:``]}),onRangeChange:n,range:t,title:l}),/* @__PURE__ */ (0,W.jsxs)(`section`,{className:`grid gap-4`,"aria-labelledby":D(`usage`),children:[/* @__PURE__ */ (0,W.jsx)(M,{anchor:`usage`,title:`Usage over time`}),/* @__PURE__ */ (0,W.jsx)(R,{bucketUnit:b(t),days:y({days:r.activityDays,hours:r.activityHours,sixHours:r.activitySixHours,range:t,emptySixHour:e=>({active:0,conversations:0,date:e,durationMs:0,failed:0})})})]}),e.codeError?/* @__PURE__ */ (0,W.jsx)(_,{className:`border-amber-300/10 bg-amber-300/[0.025]`,padding:`sm`,children:/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-display text-sm font-medium text-dashboard-text-muted`,children:`Code activity failed to load.`})}):null,!e.codeLoading&&e.code?/* @__PURE__ */ (0,W.jsx)(ae,{range:t,report:e.code}):null,e.pluginReportsError?/* @__PURE__ */ (0,W.jsx)(_,{className:`border-amber-300/10 bg-amber-300/[0.025]`,padding:`sm`,children:/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-display text-sm font-medium text-dashboard-text-muted`,children:`Plugin activity failed to load.`})}):null,e.pluginReportsLoading?null:/* @__PURE__ */ (0,W.jsx)(oe,{range:t,reports:o}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid min-w-0 gap-5 lg:grid-cols-[minmax(0,1fr)_19rem] lg:items-start`,children:[/* @__PURE__ */ (0,W.jsx)(`aside`,{className:`grid min-w-0 gap-4 lg:order-2`,children:/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-3 lg:grid-cols-1`,children:[/* @__PURE__ */ (0,W.jsx)(B,{detail:`Across the complete conversation index`,icon:a,label:`Conversations`,value:C(r.totals.conversations)}),/* @__PURE__ */ (0,W.jsx)(B,{detail:`Cumulative persisted conversation runtime`,icon:s,label:`Runtime`,value:/* @__PURE__ */ (0,W.jsx)(S,{value:r.totals.durationMs})}),/* @__PURE__ */ (0,W.jsx)(B,{detail:`Persisted model token usage`,icon:u,label:`Tokens`,value:C(r.totals.tokens??0)})]})}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid min-w-0 gap-5 lg:order-1`,children:[/* @__PURE__ */ (0,W.jsxs)(_,{as:`section`,className:`mb-0`,variant:`section`,children:[/* @__PURE__ */ (0,W.jsx)(V,{actions:/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:`52 weeks`}),children:/* @__PURE__ */ (0,W.jsx)(H,{children:`Activity`})}),/* @__PURE__ */ (0,W.jsx)(G,{days:r.activityDays})]}),/* @__PURE__ */ (0,W.jsx)(de,{items:r.surfaces,title:`Surfaces`})]})]})]})}function de(e){return e.items.length<=1?null:/* @__PURE__ */ (0,W.jsxs)(_,{as:`section`,className:`mb-0`,variant:`section`,children:[/* @__PURE__ */ (0,W.jsx)(V,{children:/* @__PURE__ */ (0,W.jsx)(H,{children:e.title})}),/* @__PURE__ */ (0,W.jsx)(`ol`,{className:`m-0 list-none p-0`,children:e.items.slice(0,6).map((e,t)=>/* @__PURE__ */ (0,W.jsxs)(`li`,{className:`grid min-w-0 grid-cols-[2rem_minmax(0,1fr)_auto] items-center gap-3 border-b border-dashboard-border-subtle px-4 py-3 last:border-b-0`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-mono text-xs leading-none text-dashboard-text-muted`,children:t+1}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`truncate font-display text-base font-medium leading-tight text-dashboard-text`,children:e.label}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-1 truncate font-mono text-xs leading-tight text-dashboard-text-muted`,children:[ce(e.durationMs,e.conversations),e.tokens?` / ${C(e.tokens)} tokens`:``,e.failed?` / ${C(e.failed)} errors`:``]})]}),/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-display text-xl font-light leading-none text-dashboard-text`,children:C(e.conversations)})]},e.label))})]})}export{le as PersonProfilePage};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{C as t,S as n,_ as r,r as i}from"./vendor-react-ggbyvons.js";import{B as a,at as o,bt as s,qt as c,u as l}from"./vendor-icons-mxz7yi04.js";import{t as u}from"./coins-bqkaxeba.js";import{n as ee,r as d,t as f}from"./CodeChangeRow-enn40527.js";import{a as p,i as m,n as h,t as te}from"./tooltip-c9bbl0em.js";import{t as g}from"./styles-j0007fov.js";import{t as _}from"./Card-hy4bfgq7.js";import{m as v,r as y,s as b,t as x}from"./PageHeader-kvp1fo95.js";import{K as S,l as C,p as w,q as T}from"./format-c4b0iyrx.js";import{t as E}from"./PageLayout-l6dhbimv.js";import{n as D}from"./AnchorHeading-cp3vx8qa.js";import{Bt as O,Ft as k,Rt as A,Vt as j,f as M,pt as N}from"../client-mgf2bxi7.js";import{t as P}from"./native-select-jfknh8t4.js";import{n as F}from"./FilterBar-lsllb7tj.js";import{c as I}from"./chart-dbzd0ka8.js";import{n as L,r as R,t as z}from"./PluginReportRecordSet-fossppyd.js";import{t as B}from"./StatCard-i2klkqqp.js";import{n as V,t as H}from"./SectionTitle-drw3mqtl.js";var U=/* @__PURE__ */ e(t(),1),W=n();function G(e){let t=Math.max(1,...e.days.map(e=>e.conversations)),n=[],r=e.days[0]?(/* @__PURE__ */ new Date(`${e.days[0].date}T00:00:00Z`)).getUTCDay():0,i=[...Array.from({length:r},()=>null),...e.days];for(;i.length>0&&i.length%7!=0;)i.push(null);for(let e=0;e<i.length;e+=7){let t=i.slice(e,e+7);for(;t.length<7;)t.push(null);n.push(t)}n.length===0&&n.push([null,null,null,null,null,null,null]);let a=n.map((e,t)=>{let r=e.find(Boolean);if(!r)return``;let i=t>0?n[t-1]:void 0,a=i?[...i].reverse().find(Boolean):void 0;return a&&a.date.slice(0,7)===r.date.slice(0,7)?``:(/* @__PURE__ */ new Date(`${r.date}T00:00:00Z`)).toLocaleString(void 0,{month:`short`,timeZone:`UTC`})});return/* @__PURE__ */ (0,W.jsx)(`div`,{className:`overflow-x-auto px-4 py-4`,children:/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`min-w-[36rem]`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{"aria-hidden":`true`,className:`mb-1 grid gap-1 text-xs font-semibold leading-none text-dashboard-text-muted`,style:{gridTemplateColumns:`repeat(${n.length}, minmax(0.75rem, 1fr))`},children:a.map((e,t)=>/* @__PURE__ */ (0,W.jsx)(`div`,{className:`h-3 overflow-visible`,children:e},`${e}-${t}`))}),/* @__PURE__ */ (0,W.jsx)(`div`,{"aria-label":`Daily ${v()} conversation activity`,className:`grid w-full grid-flow-col grid-rows-7 gap-1`,role:`list`,style:{gridTemplateColumns:`repeat(${n.length}, minmax(0.75rem, 1fr))`},children:n.flatMap((e,n)=>e.map((e,r)=>e?/* @__PURE__ */ (0,W.jsxs)(te,{children:[/* @__PURE__ */ (0,W.jsx)(p,{render:/* @__PURE__ */ (0,W.jsx)(`span`,{"aria-label":`${e.date}: ${e.conversations} conversations, ${q(e)}, ${w({total:e.costUsd??0})} spend, ${C(e.tokens??0)} tokens`,className:g(`size-3 border border-dashboard-overlay outline-none focus-visible:ring-2 focus-visible:ring-dashboard-focus`,J(e.conversations,t)),role:`listitem`,tabIndex:0})}),/* @__PURE__ */ (0,W.jsxs)(h,{children:[/* @__PURE__ */ (0,W.jsx)(m,{children:K(e.date)}),/* @__PURE__ */ (0,W.jsx)(I,{rows:[[`conversations`,e.conversations],[`runtime`,q(e)],[`spend`,w({total:e.costUsd??0})],[`tokens`,C(e.tokens??0)]]})]})]},e.date):/* @__PURE__ */ (0,W.jsx)(`span`,{"aria-hidden":`true`,className:`size-3 border border-dashboard-overlay bg-dashboard-surface-raised`},`empty-${n}-${r}`)))}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-3 flex items-center gap-1 text-xs font-semibold leading-none text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,W.jsx)(`span`,{children:`Less`}),[0,1,2,3,4].map(e=>/* @__PURE__ */ (0,W.jsx)(`span`,{"aria-hidden":`true`,className:g(`size-3 border border-dashboard-overlay`,e===0&&`bg-dashboard-surface-hover`,e===1&&`bg-[#133225] light:bg-[#9be9a8]`,e===2&&`bg-[#176a4a] light:bg-[#40c463]`,e===3&&`bg-[#22a06b] light:bg-[#30a14e]`,e===4&&`bg-[#8bdc97] light:bg-[#216e39]`)},e)),/* @__PURE__ */ (0,W.jsx)(`span`,{children:`More`})]})]})})}function K(e){return(/* @__PURE__ */ new Date(`${e}T00:00:00Z`)).toLocaleDateString(void 0,{day:`numeric`,month:`short`,timeZone:`UTC`,year:`numeric`})}function q(e){return e.durationMs<=0&&e.conversations>0?`unknown`:T(e.durationMs)}function J(e,t){if(e<=0)return`bg-dashboard-surface-hover`;let n=e/t;return n>=.75?`bg-[#8bdc97] light:bg-[#216e39]`:n>=.45?`bg-[#22a06b] light:bg-[#30a14e]`:n>=.2?`bg-[#176a4a] light:bg-[#40c463]`:`bg-[#133225] light:bg-[#9be9a8]`}const Y=[{label:`Open`,value:`open`},{label:`Merged`,value:`merged`},{label:`Closed`,value:`closed`},{label:`All`,value:``}],X=[{label:`Any time`,value:``},{label:`Last 24 hours`,value:`1`},{label:`Last 7 days`,value:`7`},{label:`Last 30 days`,value:`30`},{label:`Last 90 days`,value:`90`}];function Z(e){let[t,n]=(0,U.useState)(`open`),[r,i]=(0,U.useState)(``),a=r?Date.parse(e.generatedAt)-Number(r)*864e5:void 0,o=e.changes.filter(e=>a===void 0||Date.parse(e.openedAt)>=a),s=o.filter(e=>!t||e.state===t),c=e=>e?o.filter(t=>t.state===e).length:o.length;return/* @__PURE__ */ (0,W.jsxs)(_,{as:`section`,children:[/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-4 border-b border-dashboard-border-subtle px-4 py-3`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-display text-lg text-dashboard-text`,children:`Recent changes`}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(F,{className:`w-36`,label:`State`,children:/* @__PURE__ */ (0,W.jsx)(P,{"aria-label":`Filter changes by state`,onChange:e=>n(e.currentTarget.value),value:t,children:Y.map(e=>/* @__PURE__ */ (0,W.jsxs)(`option`,{value:e.value,children:[e.label,` (`,c(e.value),`)`]},e.value))})}),/* @__PURE__ */ (0,W.jsx)(F,{className:`w-36`,label:`Opened`,children:/* @__PURE__ */ (0,W.jsx)(P,{"aria-label":`Filter changes by opened date`,onChange:e=>i(e.currentTarget.value),value:r,children:X.map(e=>/* @__PURE__ */ (0,W.jsx)(`option`,{value:e.value,children:e.label},e.value))})})]})]}),s.length>0?/* @__PURE__ */ (0,W.jsx)(`div`,{children:s.map(e=>/* @__PURE__ */ (0,W.jsx)(f,{change:e},e.id))}):/* @__PURE__ */ (0,W.jsx)(`div`,{className:`p-4`,children:/* @__PURE__ */ (0,W.jsx)(N,{children:t&&o.length>0?`No ${t} changes. Set State to All to see ${o.length} more.`:`No changes match these filters.`})})]})}function Q(e){return e===void 0?`—`:`${Math.round(e*100)}%`}function ne(e){return T(e)||`—`}function re(e){return w(e===void 0?void 0:{total:e})||`—`}function ie(e){let t=e.summary;return e.changes.length>0||t.created+t.merged+t.closed>0||(t.costUsd??0)>0||e.activityDays.some(e=>e.created+e.merged+e.closed>0)}function ae(e){if(!ie(e.report))return null;let t=e.report.summary;return/* @__PURE__ */ (0,W.jsxs)(`section`,{"aria-labelledby":D(`code`),className:`grid gap-4`,children:[/* @__PURE__ */ (0,W.jsx)(M,{anchor:`code`,title:`Code`}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[/* @__PURE__ */ (0,W.jsx)(B,{detail:`In the last 30 days`,icon:o,label:`Created`,value:C(t.created)}),/* @__PURE__ */ (0,W.jsx)(B,{detail:`Share of completed changes that merged`,icon:d,label:`Merge rate`,value:Q(t.mergeRate)}),/* @__PURE__ */ (0,W.jsx)(B,{detail:`Median time from open to merge in the last 30 days`,icon:l,label:`Median merge time`,value:ne(t.medianMergeTimeMs)}),/* @__PURE__ */ (0,W.jsx)(B,{detail:`Conversation cost for changes opened in the last 30 days`,icon:u,label:`Cost`,value:re(t.costUsd)})]}),/* @__PURE__ */ (0,W.jsx)(ee,{bucketUnit:b(e.range),days:y({days:e.report.activityDays,hours:e.report.activityHours,sixHours:e.report.activitySixHours,range:e.range,emptySixHour:e=>({closed:0,created:0,date:e,merged:0})}),range:e.range}),e.report.changes.length>0?/* @__PURE__ */ (0,W.jsx)(Z,{changes:e.report.changes,generatedAt:e.report.generatedAt}):null]})}function oe(e){return e.reports.length===0?null:/* @__PURE__ */ (0,W.jsx)(W.Fragment,{children:e.reports.map(t=>/* @__PURE__ */ (0,W.jsx)($,{range:e.range,report:t},t.pluginName))})}function $(e){let t=e.report.title&&e.report.title!==e.report.pluginName?e.report.title:e.report.pluginName,n=e.report.metrics??[],r=e.report.widgets??[],i=e.report.recordSets??[];if(!n.length&&!r.length&&!i.length)return null;let a=`plugin-${e.report.pluginName}`;return/* @__PURE__ */ (0,W.jsxs)(`section`,{"aria-labelledby":D(a),className:`grid gap-4`,children:[/* @__PURE__ */ (0,W.jsx)(M,{anchor:a,title:t}),n.length?/* @__PURE__ */ (0,W.jsx)(`div`,{className:g(`grid gap-px overflow-hidden rounded-md border border-dashboard-border bg-dashboard-fill-hover`,n.length===1?`grid-cols-1`:`grid-cols-2`,n.length===3?`lg:grid-cols-3`:n.length===5?`lg:grid-cols-5`:n.length>=4?`lg:grid-cols-4`:void 0),children:n.map(e=>/* @__PURE__ */ (0,W.jsxs)(`div`,{className:g(`min-w-0 bg-dashboard-surface-panel px-4 py-4`,n.length>1&&n.length%2==1&&`last:col-span-2 lg:last:col-span-1`,se(e.tone)),children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`truncate font-display text-2xl font-light leading-none text-dashboard-text`,children:e.value}),/* @__PURE__ */ (0,W.jsx)(`div`,{className:`mt-2 font-sans font-medium text-xs text-dashboard-text-muted`,children:e.label})]},e.label))}):null,r.length?/* @__PURE__ */ (0,W.jsx)(`div`,{className:g(`grid gap-3`,r.length>1?`lg:grid-cols-2`:void 0),children:r.map(t=>/* @__PURE__ */ (0,W.jsx)(L,{range:e.range,widget:t},t.id))}):null,i.map(t=>/* @__PURE__ */ (0,W.jsx)(z,{recordSet:t},`${e.report.pluginName}:${t.title}`))]})}function se(e){if(e===`danger`)return`shadow-[inset_0_2px_0_rgba(251,113,133,0.65)]`;if(e===`warning`)return`shadow-[inset_0_2px_0_rgba(251,191,36,0.65)]`;if(e===`good`)return`shadow-[inset_0_2px_0_rgba(110,231,183,0.55)]`}function ce(e,t){return e<=0&&t>0?`unknown`:T(e)}function le(){let e=r(),t=e.email?decodeURIComponent(e.email):void 0,n=j(t),i=O(t),a=A(t);return!n.data&&!n.error?/* @__PURE__ */ (0,W.jsx)(k,{label:`Loading profile`}):/* @__PURE__ */ (0,W.jsx)(E,{children:n.data?/* @__PURE__ */ (0,W.jsx)(ue,{code:a.data,codeError:!!a.error,codeLoading:a.isPending,pluginReports:i.data?.reports??[],pluginReportsError:!!i.error,pluginReportsLoading:i.isPending,profile:n.data}):/* @__PURE__ */ (0,W.jsx)(_,{padding:`md`,children:/* @__PURE__ */ (0,W.jsx)(N,{children:`Profile failed to load.`})})})}function ue(e){let[t,n]=(0,U.useState)(30),r=e.profile,o=e.pluginReports??[],l=r.actor.fullName??r.actor.slackUserName??r.actor.email;return/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid min-w-0 gap-5`,children:[/* @__PURE__ */ (0,W.jsxs)(i,{className:`flex w-fit items-center gap-2 font-display text-sm font-medium text-dashboard-text-muted no-underline transition-colors hover:text-dashboard-text`,to:`/system/people`,children:[/* @__PURE__ */ (0,W.jsx)(c,{"aria-hidden":`true`,size:15,strokeWidth:1.8}),`Back to people`]}),/* @__PURE__ */ (0,W.jsx)(x,{description:/* @__PURE__ */ (0,W.jsxs)(W.Fragment,{children:[r.actor.email,r.actor.slackUserName?` / @${r.actor.slackUserName}`:``]}),onRangeChange:n,range:t,title:l}),/* @__PURE__ */ (0,W.jsxs)(`section`,{className:`grid gap-4`,"aria-labelledby":D(`usage`),children:[/* @__PURE__ */ (0,W.jsx)(M,{anchor:`usage`,title:`Usage over time`}),/* @__PURE__ */ (0,W.jsx)(R,{bucketUnit:b(t),days:y({days:r.activityDays,hours:r.activityHours,sixHours:r.activitySixHours,range:t,emptySixHour:e=>({active:0,conversations:0,date:e,durationMs:0,failed:0})})})]}),e.codeError?/* @__PURE__ */ (0,W.jsx)(_,{className:`border-amber-300/10 bg-amber-300/[0.025]`,padding:`sm`,children:/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-display text-sm font-medium text-dashboard-text-muted`,children:`Code activity failed to load.`})}):null,!e.codeLoading&&e.code?/* @__PURE__ */ (0,W.jsx)(ae,{range:t,report:e.code}):null,e.pluginReportsError?/* @__PURE__ */ (0,W.jsx)(_,{className:`border-amber-300/10 bg-amber-300/[0.025]`,padding:`sm`,children:/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-display text-sm font-medium text-dashboard-text-muted`,children:`Plugin activity failed to load.`})}):null,e.pluginReportsLoading?null:/* @__PURE__ */ (0,W.jsx)(oe,{range:t,reports:o}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid min-w-0 gap-5 lg:grid-cols-[minmax(0,1fr)_19rem] lg:items-start`,children:[/* @__PURE__ */ (0,W.jsx)(`aside`,{className:`grid min-w-0 gap-4 lg:order-2`,children:/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-3 lg:grid-cols-1`,children:[/* @__PURE__ */ (0,W.jsx)(B,{detail:`Across the complete conversation index`,icon:a,label:`Conversations`,value:C(r.totals.conversations)}),/* @__PURE__ */ (0,W.jsx)(B,{detail:`Cumulative persisted conversation runtime`,icon:s,label:`Runtime`,value:/* @__PURE__ */ (0,W.jsx)(S,{value:r.totals.durationMs})}),/* @__PURE__ */ (0,W.jsx)(B,{detail:`Persisted model token usage`,icon:u,label:`Tokens`,value:C(r.totals.tokens??0)})]})}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`grid min-w-0 gap-5 lg:order-1`,children:[/* @__PURE__ */ (0,W.jsxs)(_,{as:`section`,className:`mb-0`,variant:`section`,children:[/* @__PURE__ */ (0,W.jsx)(V,{actions:/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:`52 weeks`}),children:/* @__PURE__ */ (0,W.jsx)(H,{children:`Activity`})}),/* @__PURE__ */ (0,W.jsx)(G,{days:r.activityDays})]}),/* @__PURE__ */ (0,W.jsx)(de,{items:r.surfaces,title:`Surfaces`})]})]})]})}function de(e){return e.items.length<=1?null:/* @__PURE__ */ (0,W.jsxs)(_,{as:`section`,className:`mb-0`,variant:`section`,children:[/* @__PURE__ */ (0,W.jsx)(V,{children:/* @__PURE__ */ (0,W.jsx)(H,{children:e.title})}),/* @__PURE__ */ (0,W.jsx)(`ol`,{className:`m-0 list-none p-0`,children:e.items.slice(0,6).map((e,t)=>/* @__PURE__ */ (0,W.jsxs)(`li`,{className:`grid min-w-0 grid-cols-[2rem_minmax(0,1fr)_auto] items-center gap-3 border-b border-dashboard-border-subtle px-4 py-3 last:border-b-0`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-mono text-xs leading-none text-dashboard-text-muted`,children:t+1}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`truncate font-display text-base font-medium leading-tight text-dashboard-text`,children:e.label}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-1 truncate font-mono text-xs leading-tight text-dashboard-text-muted`,children:[ce(e.durationMs,e.conversations),e.tokens?` / ${C(e.tokens)} tokens`:``,e.failed?` / ${C(e.failed)} errors`:``]})]}),/* @__PURE__ */ (0,W.jsx)(`div`,{className:`font-display text-xl font-light leading-none text-dashboard-text`,children:C(e.conversations)})]},e.label))})]})}export{le as PersonProfilePage};
|
package/dist/public/chunks/{PersonalTokensPage-f3zhm3px.js → PersonalTokensPage-iodbv05e.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{ot as t,pt as n,ut as r}from"./vendor-lthmb2su.js";import{C as i,S as a}from"./vendor-react-ggbyvons.js";import{t as o}from"./button-loz3etho.js";import{$ as s,l as c}from"./vendor-icons-mxz7yi04.js";import{O as l,x as u}from"./junior-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{ot as t,pt as n,ut as r}from"./vendor-lthmb2su.js";import{C as i,S as a}from"./vendor-react-ggbyvons.js";import{t as o}from"./button-loz3etho.js";import{$ as s,l as c}from"./vendor-icons-mxz7yi04.js";import{O as l,x as u}from"./junior-gfsokzu9.js";import{i as d,o as f,r as p}from"./http-cdq677qt.js";import{t as m}from"./Card-hy4bfgq7.js";import{m as h}from"./PageHeader-kvp1fo95.js";import{bt as g,d as _,q as v}from"../client-mgf2bxi7.js";var y=/* @__PURE__ */ e(i(),1),b=a();const x=[`dashboard`,`personal-tokens`];function S(){let e=n(),i=(0,y.useRef)(!1),[a,S]=(0,y.useState)(`Local agent`),C=()=>e.cancelQueries({exact:!0,queryKey:x}),w=r({queryKey:x,queryFn:({signal:e})=>d(l,`/api/personal-tokens`,e),retry:!1}),T=t({gcTime:0,mutationFn:e=>f(u,`/api/personal-tokens`,{name:e}),onMutate:()=>C(),onSuccess:async t=>{let{token:n,...r}=t;await C(),e.setQueryData(x,e=>({tokens:[r,...(e?.tokens??[]).filter(e=>e.id!==r.id)]}))},onSettled:()=>{i.current=!1}}),E=t({mutationFn:e=>p(`/api/personal-tokens/${encodeURIComponent(e.id)}`),onMutate:()=>C(),onSuccess:async(t,n)=>{await C(),e.setQueryData(x,e=>({tokens:(e?.tokens??[]).filter(e=>e.id!==n.id)})),T.data?.id===n.id&&T.reset()}}),D=T.data,O=w.data?.tokens??[],k=w.isPending,A=T.isPending||E.isPending,j=!k&&!A&&!!a.trim(),M=(T.isError?`Could not create the API token. Try again.`:E.isError?`Could not revoke the API token. Try again.`:void 0)??(!w.data&&w.isError?`Could not load API tokens. Try again.`:void 0);return/* @__PURE__ */ (0,b.jsxs)(_,{description:/* @__PURE__ */ (0,b.jsxs)(b.Fragment,{children:[`Use a token to read `,h(),` APIs from a local agent or script. Tokens expire after 90 days.`]}),title:`API Tokens`,children:[D?/* @__PURE__ */ (0,b.jsxs)(`div`,{className:`rounded-md border border-emerald-400/40 bg-emerald-400/5 p-3`,children:[/* @__PURE__ */ (0,b.jsx)(`p`,{className:`mt-0 mb-2 text-sm font-semibold`,children:`Copy this token now. It won't be shown again.`}),/* @__PURE__ */ (0,b.jsx)(`code`,{className:`block overflow-x-auto rounded-md bg-dashboard-ink p-2 text-xs text-emerald-300`,children:D.token}),/* @__PURE__ */ (0,b.jsx)(o,{className:`mt-3`,onClick:()=>{T.reset(),S(`Local agent`)},children:`Create another token`})]}):/* @__PURE__ */ (0,b.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),j&&!i.current&&(E.reset(),i.current=!0,T.mutate(a))},children:[/* @__PURE__ */ (0,b.jsx)(g,{"aria-label":`Token name`,className:`min-w-0 flex-1`,maxLength:80,onChange:e=>S(e.target.value),value:a}),/* @__PURE__ */ (0,b.jsx)(o,{disabled:!j,type:`submit`,children:`Create token`})]}),M?/* @__PURE__ */ (0,b.jsx)(v,{children:M}):null,/* @__PURE__ */ (0,b.jsx)(m,{className:`mb-0`,variant:`raised`,children:k?/* @__PURE__ */ (0,b.jsx)(`p`,{className:`m-0 p-5 text-sm text-dashboard-text-muted`,children:`Loading API tokens…`}):O.length===0?/* @__PURE__ */ (0,b.jsx)(`p`,{className:`m-0 p-5 text-sm text-dashboard-text-muted`,children:`No active API tokens.`}):/* @__PURE__ */ (0,b.jsx)(`ul`,{className:`m-0 list-none divide-y divide-dashboard-border-subtle p-0`,children:O.map(e=>/* @__PURE__ */ (0,b.jsxs)(`li`,{className:`flex items-center gap-3 px-5 py-4`,children:[/* @__PURE__ */ (0,b.jsx)(s,{className:`text-dashboard-accent`,size:16}),/* @__PURE__ */ (0,b.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[/* @__PURE__ */ (0,b.jsx)(`p`,{className:`m-0 truncate text-sm font-semibold`,children:e.name}),/* @__PURE__ */ (0,b.jsxs)(`p`,{className:`mt-1 mb-0 text-xs text-dashboard-text-muted`,children:[`Ends in `,e.tokenSuffix,` · Expires`,` `,new Date(e.expiresAt).toLocaleDateString()]})]}),/* @__PURE__ */ (0,b.jsx)(o,{"aria-label":`Revoke ${e.name}`,disabled:A,onClick:()=>{T.isError&&T.reset(),E.mutate(e)},size:`icon`,variant:`danger`,type:`button`,children:/* @__PURE__ */ (0,b.jsx)(c,{size:16})})]},e.id))})})]})}export{S as PersonalTokensPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{nt as t}from"./vendor-lthmb2su.js";import{C as n,S as r}from"./vendor-react-ggbyvons.js";import{Pt as i}from"./vendor-icons-mxz7yi04.js";import{i as a,t as o}from"./styles-j0007fov.js";import{t as s}from"./Card-hy4bfgq7.js";import{a as c,d as l,o as u,u as d}from"./PageHeader-kvp1fo95.js";import{c as f,l as p,p as m,q as h}from"./format-c4b0iyrx.js";import{$ as g,Q as _,ct as v,et as y,nt as b,ot as x,rt as S,st as C,tt as w}from"../client-mgf2bxi7.js";import{$t as ee,A as te,At as T,C as E,Ct as D,D as ne,E as re,Et as O,F as ie,Ft as ae,H as oe,It as se,J as ce,K as le,Lt as ue,M as de,Mt as fe,N as pe,Nt as me,O as he,P as ge,Qt as _e,R as ve,S as ye,Tt as k,U as A,Vt as j,Yt as M,Z as N,_ as be,a as P,ct as xe,d as F,dt as Se,f as Ce,g as we,gt as Te,h as Ee,ht as De,it as Oe,k as ke,n as I,o as L,p as Ae,q as je,r as Me,s as R,st as Ne,t as z,u as Pe,ut as Fe,v as Ie,x as Le,yt as Re,zt as B}from"./chart-dbzd0ka8.js";import{a as ze,c as Be,i as Ve,l as He,n as V,o as Ue,r as We,s as Ge,t as H}from"./BarChart-hdlbq093.js";import{t as Ke}from"./Area-f1nin66q.js";import{t as qe}from"./ChartLegend-c3e9l1vl.js";import{t as Je}from"./ChartHeader-c1zg4xt5.js";var U=/* @__PURE__ */ e(n()),Ye=[`option`,`isActive`];function W(){return W=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},W.apply(null,arguments)}function Xe(e,t){if(e==null)return{};var n,r,i=Ze(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Ze(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Qe(e){var{option:t,isActive:n}=e,r=Xe(e,Ye);return typeof t==`string`?/*#__PURE__*/ U.createElement(Ge,W({option:/*#__PURE__*/ U.createElement(He,W({type:t},r)),isActive:n,shapeType:`symbols`},r)):/*#__PURE__*/ U.createElement(Ge,W({option:t,isActive:n,shapeType:`symbols`},r))}var $e=(e,t,n,r,i,a,o)=>A(e,`xAxis`,t,o),et=(e,t,n,r,i,a,o)=>le(e,`xAxis`,t,o),tt=(e,t,n,r,i,a,o)=>A(e,`yAxis`,n,o),nt=(e,t,n,r,i,a,o)=>le(e,`yAxis`,n,o),rt=(e,t,n,r)=>ce(e,`zAxis`,r,!1),it=(e,t,n,r,i)=>i,at=(e,t,n,r,i,a)=>a,ot=(e,t,n,r,i,a,o)=>Oe(e,void 0,void 0,o),st=T([je,it],(e,t)=>e.filter(e=>e.type===`scatter`).find(e=>e.id===t)),ct=T([ot,$e,et,tt,nt,rt,st,at],(e,t,n,r,i,a,o,s)=>{var{chartData:c,dataStartIndex:l,dataEndIndex:u}=e;if(o!=null){var d=o?.data!=null&&o.data.length>0?o.data:c?.slice(l,u+1);if(d!=null&&t!=null&&r!=null&&n!=null&&i!=null&&n?.length!==0&&i?.length!==0)return Ct({displayedData:d,xAxis:t,yAxis:r,zAxis:a,scatterSettings:o,xAxisTicks:n,yAxisTicks:i,cells:s})}}),lt=[`id`],ut=[`onMouseEnter`,`onClick`,`onMouseLeave`],dt=[`animationBegin`,`animationDuration`,`animationEasing`,`hide`,`isAnimationActive`,`legendType`,`lineJointType`,`lineType`,`shape`,`xAxisId`,`yAxisId`,`zAxisId`];function G(e,t){if(e==null)return{};var n,r,i=ft(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function ft(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function K(){return K=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},K.apply(null,arguments)}function pt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?pt(Object(n),!0).forEach(function(t){mt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):pt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function mt(e,t,n){return(t=ht(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ht(e){var t=gt(e,`string`);return typeof t==`symbol`?t:t+``}function gt(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var _t=e=>{var{dataKey:t,name:n,fill:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:k(n,t),payload:e}]},vt=/*#__PURE__*/ U.memo(e=>{var{dataKey:t,points:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,tooltipType:c,id:l}=e,u={dataDefinedOnItem:n?.map(e=>e.tooltipPayload),getPosition:e=>{var t;return n==null||(t=n[Number(e)])==null?void 0:t.tooltipPosition},settings:{stroke:r,strokeWidth:i,fill:a,nameKey:void 0,dataKey:t,name:k(o,t),hide:s,type:c,color:a,unit:``,graphicalItemId:l}};return/*#__PURE__*/ U.createElement(ke,{tooltipEntrySettings:u})});function yt(e){var{points:t,props:n}=e,{line:r,lineType:i,lineJointType:a}=n;if(!r)return null;var o=_e(n),s=ee(r),c,l;if(i===`joint`)c=t.map(e=>({x:e.cx??null,y:e.cy??null}));else if(i===`fitting`){var{xmin:u,xmax:d,a:f,b:p}=ue(t),m=e=>f*e+p;c=[{x:u,y:m(u)},{x:d,y:m(d)}]}var h=q(q(q({},o),{},{fill:`none`,stroke:o&&o.fill},s),{},{points:c});return l=/*#__PURE__*/ U.isValidElement(r)?/*#__PURE__*/ U.cloneElement(r,h):typeof r==`function`?r(h):/*#__PURE__*/ U.createElement(Fe,K({},h,{type:a})),/*#__PURE__*/ U.createElement(M,{className:`recharts-scatter-line`,key:`recharts-scatter-line`},l)}function bt(e){var{showLabels:t,points:n,children:r}=e,i=De(),a=(0,U.useMemo)(()=>n?.map(e=>{var t={x:e.x??0,y:e.y??0,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width};return q(q({},t),{},{value:void 0,payload:e.payload,viewBox:t,parentViewBox:i,fill:void 0})}),[i,n]);return/*#__PURE__*/ U.createElement(de,{value:t?a:void 0},r)}function xt(e){var{points:t,allOtherScatterProps:n}=e,{shape:r,activeShape:i,dataKey:a}=n,{id:o}=n,s=G(n,lt),c=fe(ve),{onMouseEnter:l,onClick:u,onMouseLeave:d}=n,f=G(n,ut),p=ze(l,a,o),m=Ue(d),h=Ve(u,a,o);if(!se(t))return null;var g=_e(s);return/*#__PURE__*/ U.createElement(U.Fragment,null,/*#__PURE__*/ U.createElement(yt,{points:t,props:s}),t.map((e,t)=>{var n=i!=null&&i!==!1,a=n&&c===String(t),s=n&&a?i:r,l=q(q(q({},g),e),{},{index:t,[Re]:String(o)});return/*#__PURE__*/ U.createElement(ie,{key:`symbol-${e?.cx}-${e?.cy}-${e?.size}-${t}`,zIndex:a?N.activeDot:void 0},/*#__PURE__*/ U.createElement(M,K({className:`recharts-scatter-symbol`},ae(f,e,t),{onMouseEnter:p(e,t),onMouseLeave:m(e,t),onClick:h(e,t)}),/*#__PURE__*/ U.createElement(Qe,K({option:s,isActive:a},l))))}))}function St(e){var{previousPointsRef:t,props:n}=e,{points:r,isAnimationActive:i,animationBegin:a,animationDuration:o,animationEasing:s}=n,c=t.current,l=Ne(n,`recharts-scatter-`),[u,d]=(0,U.useState)(!1),f=(0,U.useCallback)(()=>{d(!1)},[]),p=(0,U.useCallback)(()=>{d(!0)},[]),m=!u;return/*#__PURE__*/ U.createElement(bt,{showLabels:m,points:r},n.children,/*#__PURE__*/ U.createElement(xe,{animationId:l,begin:a,duration:o,isActive:i,easing:s,onAnimationEnd:f,onAnimationStart:p,key:l},e=>{var i=e===1?r:r?.map((t,n)=>{var r=c&&c[n];return r?q(q({},t),{},{cx:t.cx==null?void 0:B(r.cx,t.cx,e),cy:t.cy==null?void 0:B(r.cy,t.cy,e),size:B(r.size,t.size,e)}):q(q({},t),{},{size:B(0,t.size,e)})});return e>0&&(t.current=i),/*#__PURE__*/ U.createElement(M,null,/*#__PURE__*/ U.createElement(xt,{points:i,allOtherScatterProps:n,showLabels:m}))}),/*#__PURE__*/ U.createElement(pe,{label:n.label}))}function Ct(e){var{displayedData:t,xAxis:n,yAxis:r,zAxis:i,scatterSettings:a,xAxisTicks:o,yAxisTicks:s,cells:c}=e,l=j(n.dataKey)?a.dataKey:n.dataKey,u=j(r.dataKey)?a.dataKey:r.dataKey,d=i&&i.dataKey,f=i?i.range:oe.range,p=f&&f[0],m=n.scale.bandwidth?n.scale.bandwidth():0,h=r.scale.bandwidth?r.scale.bandwidth():0;return t.map((e,t)=>{var f=O(e,l),g=O(e,u),_=!j(d)&&O(e,d)||`-`,v=[{name:j(n.dataKey)?a.name:n.name||String(n.dataKey),unit:n.unit||``,value:f,payload:e,dataKey:l,type:a.tooltipType,graphicalItemId:a.id},{name:j(r.dataKey)?a.name:r.name||String(r.dataKey),unit:r.unit||``,value:g,payload:e,dataKey:u,type:a.tooltipType,graphicalItemId:a.id}];_!==`-`&&i!=null&&v.push({name:i.name||i.dataKey,unit:i.unit||``,value:_,payload:e,dataKey:d,type:a.tooltipType,graphicalItemId:a.id});var y=D({axis:n,ticks:o,bandSize:m,entry:e,index:t,dataKey:l}),b=D({axis:r,ticks:s,bandSize:h,entry:e,index:t,dataKey:u}),x=_!==`-`&&i!=null?i.scale.map(_):p,S=x==null?0:Math.sqrt(Math.max(x,0)/Math.PI);return q(q({},e),{},{cx:y,cy:b,x:y==null?void 0:y-S,y:b==null?void 0:b-S,width:2*S,height:2*S,size:x,node:{x:f,y:g,z:_},tooltipPayload:v,tooltipPosition:{x:y,y:b},payload:e},c&&c[t]&&c[t].props)})}var wt=(e,t,n)=>({x:e.cx,y:e.cy,value:Number(n===`x`?e.node.x:e.node.y),errorVal:O(e,t)});function Tt(e){var{hide:n,points:r,className:i,needClip:a,xAxisId:o,yAxisId:s,id:c}=e,l=(0,U.useRef)(null);if(n)return null;var u=t(`recharts-scatter`,i),d=c;return/*#__PURE__*/ U.createElement(ie,{zIndex:e.zIndex},/*#__PURE__*/ U.createElement(M,{className:u,clipPath:a?`url(#clipPath-${d})`:void 0,id:c},a&&/*#__PURE__*/ U.createElement(`defs`,null,/*#__PURE__*/ U.createElement(Le,{clipPathId:d,xAxisId:o,yAxisId:s})),/*#__PURE__*/ U.createElement(We,{xAxisId:o,yAxisId:s,data:r,dataPointFormatter:wt,errorBarOffset:0},/*#__PURE__*/ U.createElement(M,{key:`recharts-scatter-symbols`},/*#__PURE__*/ U.createElement(St,{props:e,previousPointsRef:l})))))}var Et={xAxisId:0,yAxisId:0,zAxisId:0,label:!1,line:!1,legendType:`circle`,lineType:`joint`,lineJointType:`linear`,shape:`circle`,hide:!1,isAnimationActive:`auto`,animationBegin:0,animationDuration:400,animationEasing:`linear`,zIndex:N.scatter};function Dt(e){var t=me(e,Et),{animationBegin:n,animationDuration:r,animationEasing:i,hide:a,isAnimationActive:o,legendType:s,lineJointType:c,lineType:l,shape:u,xAxisId:d,yAxisId:f,zAxisId:p}=t,m=G(t,dt),{needClip:h}=ye(d,f),g=(0,U.useMemo)(()=>te(e.children,Be),[e.children]),_=Te(),v=fe(t=>ct(t,d,f,p,e.id,g,_));return h==null||v==null?null:/*#__PURE__*/ U.createElement(U.Fragment,null,/*#__PURE__*/ U.createElement(vt,{dataKey:e.dataKey,points:v,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,tooltipType:e.tooltipType,id:e.id}),/*#__PURE__*/ U.createElement(Tt,K({},m,{xAxisId:d,yAxisId:f,zAxisId:p,lineType:l,lineJointType:c,legendType:s,shape:u,hide:a,isAnimationActive:o,animationBegin:n,animationDuration:r,animationEasing:i,points:v,needClip:h})))}function Ot(e){var t=me(e,Et),n=Te();return/*#__PURE__*/ U.createElement(ne,{id:t.id,type:`scatter`},e=>/*#__PURE__*/ U.createElement(U.Fragment,null,/*#__PURE__*/ U.createElement(he,{legendPayload:_t(t)}),/*#__PURE__*/ U.createElement(re,{type:`scatter`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:t.zAxisId,dataKey:t.dataKey,hide:t.hide,name:t.name,tooltipType:t.tooltipType,isPanorama:n}),/*#__PURE__*/ U.createElement(Dt,K({},t,{id:e}))))}var kt=/*#__PURE__*/ U.memo(Ot,Se);kt.displayName=`Scatter`;var At=[`axis`],jt=/*#__PURE__*/ (0,U.forwardRef)((e,t)=>/*#__PURE__*/ U.createElement(be,{chartName:`ComposedChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:At,tooltipPayloadSearcher:ge,categoricalChartProps:e,ref:t}));const J=[{key:`cachedInputTokens`,label:`From cache`,color:`var(--color-cyan-400)`},{key:`cacheCreationTokens`,label:`Written to cache`,color:`var(--color-amber-400)`},{key:`inputTokens`,label:`Uncached`,color:`var(--color-violet-400)`}];function Y(e){if(!J.some(({key:t})=>e[t]===void 0))return J.reduce((t,{key:n})=>t+e[n],0)}function X(e,t){if(e===void 0||t===void 0||t===0)return`—`;let n=e/t*100;return n<100&&n>=99.95?`<100%`:n>0&&n<.05?`<0.1%`:`${n.toFixed(1)}%`}function Mt(e){return J.some(({key:t})=>e[t]!==void 0)||(e.tokens??0)>0||e.durationMs>0||e.conversations>0}function Nt(e){let t=e.filter(Mt),n={};for(let{key:e}of J)t.length&&t.every(t=>t[e]!==void 0)&&(n[e]=t.reduce((t,n)=>t+n[e],0));return{input:n,total:Y(n),activePeriods:t.length,incompletePeriods:t.filter(e=>Y(e)===void 0).length}}var Z=r();function Pt(e){let t=e.days.filter(e=>(e.cacheCreationTokens??0)>0).sort((e,t)=>t.cacheCreationTokens-e.cacheCreationTokens||t.date.localeCompare(e.date)).slice(0,3);if(!t.length)return null;let n=e.bucketUnit===`6hour`?`6 hours`:e.bucketUnit;return/* @__PURE__ */ (0,Z.jsxs)(x,{className:`border-t border-dashboard-border-subtle px-4 py-3 sm:px-5`,children:[/* @__PURE__ */ (0,Z.jsxs)(v,{className:`group flex cursor-pointer items-center gap-1 font-sans tabular-nums text-xs text-dashboard-text focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-dashboard-focus`,children:[/* @__PURE__ */ (0,Z.jsx)(i,{"aria-hidden":`true`,className:a}),`Largest cache writes`]}),/* @__PURE__ */ (0,Z.jsxs)(C,{hiddenUntilFound:!0,children:[/* @__PURE__ */ (0,Z.jsxs)(`p`,{className:`mb-2 mt-3 font-sans tabular-nums text-xs leading-relaxed text-dashboard-text-muted`,children:[`Top three by tokens written per `,n,`, within the selected time window. Large writes alone do not mean a cache problem.`]}),/* @__PURE__ */ (0,Z.jsxs)(_,{"aria-label":`Largest cache writes`,className:`min-w-80 table-fixed font-sans text-xs tabular-nums`,children:[/* @__PURE__ */ (0,Z.jsx)(b,{children:/* @__PURE__ */ (0,Z.jsxs)(S,{children:[/* @__PURE__ */ (0,Z.jsx)(w,{scope:`col`,className:`px-0 py-2 font-normal`,children:e.bucketUnit===`day`?`Day`:`Starting at`}),/* @__PURE__ */ (0,Z.jsx)(w,{scope:`col`,className:`w-24 px-0 py-2 text-right font-normal`,children:`Written`}),/* @__PURE__ */ (0,Z.jsx)(w,{scope:`col`,className:`w-24 px-0 py-2 text-right font-normal`,children:`From cache`})]})}),/* @__PURE__ */ (0,Z.jsx)(g,{children:t.map(e=>/* @__PURE__ */ (0,Z.jsxs)(S,{children:[/* @__PURE__ */ (0,Z.jsx)(w,{scope:`row`,className:`px-0 py-2 font-normal whitespace-normal`,children:Ee(e.date)}),/* @__PURE__ */ (0,Z.jsx)(y,{className:`px-0 py-2 text-right whitespace-normal`,children:p(e.cacheCreationTokens)}),/* @__PURE__ */ (0,Z.jsx)(y,{className:`px-0 py-2 text-right whitespace-normal`,children:X(e.cachedInputTokens,Y(e))})]},e.date))})]})]})]})}const Ft={...Object.fromEntries(J.map(({color:e,key:t,label:n})=>[t,{color:e,label:n}])),missing:{color:`var(--color-slate-400)`,label:`Missing data`}};function It(e){let[t,n]=(0,U.useState)(`share`),r=Nt(e.days),o=e.days.map(e=>{let n=Y(e);return{...Object.fromEntries(J.map(({key:r})=>{let i=e[r]??0;return[r,t===`share`?n?i/n*100:0:i]})),date:e.date,day:e,missing:n===void 0&&Mt(e)?0:void 0}}),c=t===`share`?100:Math.max(1,...e.days.map(e=>J.reduce((t,{key:n})=>t+(e[n]??0),0)));return/* @__PURE__ */ (0,Z.jsxs)(s,{children:[/* @__PURE__ */ (0,Z.jsx)(Je,{title:`Input cache`,trailing:/* @__PURE__ */ (0,Z.jsxs)(d,{"aria-label":`Cache chart display`,onValueChange:([e])=>{e&&n(e)},value:[t],children:[/* @__PURE__ */ (0,Z.jsx)(l,{value:`share`,children:`Percent`}),/* @__PURE__ */ (0,Z.jsx)(l,{value:`tokens`,children:`Tokens`})]})}),/* @__PURE__ */ (0,Z.jsx)(`dl`,{className:`m-0 flex flex-wrap gap-x-5 gap-y-2 px-4 py-3 font-sans tabular-nums text-xs sm:px-5`,children:J.map(({key:e,label:t,color:n})=>/* @__PURE__ */ (0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[/* @__PURE__ */ (0,Z.jsxs)(`dt`,{className:`flex items-center gap-1.5 text-dashboard-text-muted`,children:[/* @__PURE__ */ (0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 rounded-full`,style:{backgroundColor:n}}),t]}),/* @__PURE__ */ (0,Z.jsx)(`dd`,{className:`m-0 tabular-nums text-dashboard-text`,children:X(r.input[e],r.total)})]},e))}),r.activePeriods===0?/* @__PURE__ */ (0,Z.jsx)(`p`,{className:`m-0 px-4 pb-2 font-sans tabular-nums text-xs text-dashboard-text-muted sm:px-5`,children:`No input data in this time window.`}):r.incompletePeriods>0?/* @__PURE__ */ (0,Z.jsxs)(`p`,{className:`m-0 px-4 pb-2 font-sans tabular-nums text-xs text-dashboard-text-muted sm:px-5`,children:[`Missing data in `,r.incompletePeriods,` of `,r.activePeriods,` `,`active time intervals. Percentages are unavailable; Tokens shows the reported values.`]}):null,/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`px-2 pb-2`,children:/* @__PURE__ */ (0,Z.jsx)(z,{className:`aspect-auto h-40 w-full`,config:Ft,children:/* @__PURE__ */ (0,Z.jsxs)(H,{"aria-label":`Input cache ${t} per ${u(e.bucketUnit)}`,data:o,margin:F,role:`img`,children:[/* @__PURE__ */ (0,Z.jsx)(E,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,Z.jsx)(R,{format:t===`share`?e=>`${e}%`:p,maximum:c}),/* @__PURE__ */ (0,Z.jsx)(L,{keys:o.map(e=>e.date)}),/* @__PURE__ */ (0,Z.jsx)(Ie,{dataKey:`date`,hide:!0,xAxisId:`missing`}),/* @__PURE__ */ (0,Z.jsx)(I,{content:/* @__PURE__ */ (0,Z.jsx)(P,{rows:({day:e})=>{let t=Y(e);return J.map(({key:n,label:r})=>[r,e[n]===void 0?`Not reported`:`${p(e[n])} · ${X(e[n],t)}`])}})}),J.map(({key:e})=>/* @__PURE__ */ (0,Z.jsx)(V,{dataKey:e,fill:`var(--color-${e})`,fillOpacity:.85,isAnimationActive:!1,maxBarSize:32,stackId:`input`},e)),/* @__PURE__ */ (0,Z.jsx)(V,{dataKey:`missing`,fill:`var(--color-missing)`,isAnimationActive:!1,maxBarSize:32,minPointSize:3,xAxisId:`missing`})]})})}),/* @__PURE__ */ (0,Z.jsx)(Pt,{days:e.days,bucketUnit:e.bucketUnit}),/* @__PURE__ */ (0,Z.jsxs)(x,{className:`border-t border-dashboard-border-subtle px-4 py-3 font-sans tabular-nums text-xs text-dashboard-text-muted sm:px-5`,children:[/* @__PURE__ */ (0,Z.jsxs)(v,{className:`group flex cursor-pointer items-center gap-1 text-dashboard-text focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-dashboard-focus`,children:[/* @__PURE__ */ (0,Z.jsx)(i,{"aria-hidden":`true`,className:a}),`How to read this`]}),/* @__PURE__ */ (0,Z.jsx)(C,{hiddenUntilFound:!0,children:/* @__PURE__ */ (0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2 leading-relaxed`,children:[/* @__PURE__ */ (0,Z.jsx)(`p`,{className:`m-0`,children:`From cache is input reused. Written to cache is input saved for reuse. Uncached is the remaining input.`}),/* @__PURE__ */ (0,Z.jsx)(`p`,{className:`m-0`,children:`Percentages use total input tokens, not call counts. Gray marks and — mean missing data; zero means a reported zero. The latest interval may be incomplete.`}),/* @__PURE__ */ (0,Z.jsx)(`p`,{className:`m-0`,children:`These totals can show when reuse changes, but not why. They do not show individual calls or prove that every call reported cache use.`})]})})]})]})}function Lt(e){return e<1?`$${e.toFixed(2)}`:`$${p(e)}`}function Rt(e){let t=e/36e5;return t>=24?`${p(t/24)}d`:t>=1?`${p(t)}h`:h(e)}function zt(){return{axisFormat:p,color:`var(--color-cyan-400)`,format:p,metric:`tokens`,title:`Token usage`,type:`bar`}}function Bt(){return[{axisFormat:Lt,color:`var(--color-amber-400)`,format:e=>m({total:e}),metric:`costUsd`,title:`Model spend`,type:`area`},{axisFormat:Rt,color:`var(--color-violet-400)`,format:h,metric:`durationMs`,title:`Runtime`,type:`scatter`}]}function Vt(e,t){return e[t]??0}function Ht(e){let t=e.bucketUnit??`day`,n=e.cacheBreakdown?Bt():[zt(),...Bt()];return/* @__PURE__ */ (0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[e.cacheBreakdown?/* @__PURE__ */ (0,Z.jsx)(It,{bucketUnit:t,days:e.days}):null,/* @__PURE__ */ (0,Z.jsx)(`div`,{className:e.cacheBreakdown?`grid gap-4 lg:grid-cols-2`:`grid gap-4 lg:grid-cols-3`,children:n.map(n=>/* @__PURE__ */ (0,Z.jsx)(Ut,{bucketUnit:t,chart:n,days:e.days},n.metric))})]})}function Ut(e){let{chart:t,days:n}=e,r=n.map(e=>Vt(e,t.metric)),i=n.map((e,t)=>({date:e.date,value:r[t]})),a=Math.max(2**-52,...r),o=r.reduce((e,t)=>e+t,0),l=Pe(r),u={dataKey:`value`,fill:`var(--color-value)`,isAnimationActive:!1};return/* @__PURE__ */ (0,Z.jsxs)(s,{children:[/* @__PURE__ */ (0,Z.jsx)(Je,{title:t.title,total:t.format(o)}),/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`px-2 py-2`,children:/* @__PURE__ */ (0,Z.jsx)(z,{className:`aspect-auto h-38 w-full`,config:{value:{color:t.color,label:t.title}},children:/* @__PURE__ */ (0,Z.jsxs)(jt,{"aria-label":`${t.title} per ${e.bucketUnit===`6hour`?`6 hours`:e.bucketUnit}`,data:i,margin:F,role:`img`,children:[/* @__PURE__ */ (0,Z.jsx)(E,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,Z.jsx)(R,{format:t.axisFormat,maximum:a}),/* @__PURE__ */ (0,Z.jsx)(L,{keys:i.map(e=>e.date)}),/* @__PURE__ */ (0,Z.jsx)(I,{content:/* @__PURE__ */ (0,Z.jsx)(P,{rows:e=>[[t.title,t.format(e.value)]]})}),t.type===`bar`?/* @__PURE__ */ (0,Z.jsx)(V,{...u,fillOpacity:.8,maxBarSize:8,minPointSize:e=>e?2:0,radius:1.5}):t.type===`area`?/* @__PURE__ */ (0,Z.jsx)(Ke,{...u,dot:{fillOpacity:.45,r:2.5,stroke:`none`},fillOpacity:.08,stroke:`var(--color-value)`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,type:`linear`}):/* @__PURE__ */ (0,Z.jsx)(kt,{...u,fillOpacity:.75}),/* @__PURE__ */ (0,Z.jsx)(Me,{average:l,format:t.metric===`tokens`?f:t.format,stroke:t.color,unit:c(e.bucketUnit)})]})})})]})}const Q=[`var(--color-cyan-300)`,`var(--color-emerald-300)`,`var(--color-amber-400)`,`var(--color-rose-400)`,`var(--color-violet-400)`],Wt={danger:`var(--color-rose-400)`,good:`var(--color-emerald-300)`,neutral:`var(--color-cyan-300)`,warning:`var(--color-amber-400)`};function Gt(e,t){return e.tone?Wt[e.tone]:Q[t%Q.length]??Q[0]}function Kt(e,t){let n=e.timeRangeDays?e.categories.slice(-Jt(e,t)):e.categories,r=n.flatMap(t=>e.series.map(e=>t.values[e.key]??0)),i=Math.min(0,...r),a=Math.max(0,...r);return{categories:n,maximum:a===i?i+1:a,minimum:i}}function qt(e){let{widget:t}=e,{categories:n,maximum:r,minimum:i}=Kt(t,e.range),a=Xt(t),o=n.map(e=>({category:e,id:e.id,...Object.fromEntries(t.series.map((t,n)=>[`series-${n}`,e.values[t.key]??0]))})),s=new Map(n.map(e=>[e.id,e.label])),c=Object.fromEntries(t.series.map((e,t)=>[`series-${t}`,{color:Gt(e,t),label:e.label}]));return/* @__PURE__ */ (0,Z.jsxs)(`div`,{className:`overflow-hidden rounded-md border border-dashboard-border bg-dashboard-surface-panel`,children:[/* @__PURE__ */ (0,Z.jsxs)(`div`,{className:`border-b border-dashboard-border-subtle px-4 py-3`,children:[/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:/* @__PURE__ */ (0,Z.jsx)(`h4`,{className:`m-0 font-sans text-xs font-medium text-dashboard-text-muted`,children:t.title})}),t.description?/* @__PURE__ */ (0,Z.jsx)(`p`,{className:`mt-1 mb-0 font-mono text-xs text-dashboard-text-muted`,children:t.description}):null,t.series.length>1?/* @__PURE__ */ (0,Z.jsx)(qe,{ariaLabel:`Chart legend`,items:t.series.map((e,t)=>({color:Gt(e,t),key:e.key,label:e.label}))}):null]}),n.length===0?/* @__PURE__ */ (0,Z.jsx)(`p`,{className:`m-0 p-4 font-sans text-xs text-dashboard-text-muted`,children:t.emptyText??`No chart data.`}):/* @__PURE__ */ (0,Z.jsx)(z,{className:`aspect-auto h-60 w-full`,config:c,children:/* @__PURE__ */ (0,Z.jsxs)(H,{"aria-label":t.title,data:o,margin:F,role:`img`,children:[/* @__PURE__ */ (0,Z.jsx)(E,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,Z.jsx)(R,{format:e=>Zt(e,a),maximum:r,minimum:i}),/* @__PURE__ */ (0,Z.jsx)(L,{centered:!0,dataKey:`id`,formatLabel:e=>Ce(s.get(e)??e),keys:n.map(e=>e.id)}),/* @__PURE__ */ (0,Z.jsx)(I,{content:/* @__PURE__ */ (0,Z.jsx)(P,{formatLabel:e=>Ae(s.get(e)??e),rows:({category:e})=>t.series.map(t=>[t.label,Zt(e.values[t.key]??0,t.format)])})}),t.series.map((e,n)=>/* @__PURE__ */ (0,Z.jsx)(V,{dataKey:`series-${n}`,fill:`var(--color-series-${n})`,fillOpacity:.82,isAnimationActive:!1,maxBarSize:54/t.series.length,minPointSize:e=>e?2:0,radius:1.5},e.key))]})})]})}function Jt(e,t){let n=e.timeRangeDays??[],r=e.categories[0],i=r?.id||r?.label||``,a=we(i);return t===1?a&&n.includes(1)?24:n.includes(7)?7:n.includes(30)?30:n[0]??30:t&&n.includes(t)?t:n.includes(30)?30:n[0]??30}function Yt(e){return String(Number(e.toPrecision(12)))}function Xt(e){return new Set(e.series.map(e=>e.format)).size===1?e.series[0]?.format:void 0}function Zt(e,t){return t===`usd`?m({total:e}):Yt(e)}function Qt(e){let t=e.recordSet.fields??[],n=e.recordSet.records??[],r=e.embedded===!0;return/* @__PURE__ */ (0,Z.jsxs)(`div`,{className:o(r?`border-t border-dashboard-border-subtle`:`overflow-hidden rounded-md border border-dashboard-border bg-dashboard-surface-panel`),children:[/* @__PURE__ */ (0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4 px-5 py-3`,children:[/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:e.recordSet.title}),/* @__PURE__ */ (0,Z.jsxs)(`div`,{className:`hidden font-mono text-xs text-dashboard-text-muted sm:block`,children:[n.length,` records`]})]}),n.length===0?/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`px-5 pb-5 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:e.recordSet.emptyText??`No records.`}):t.length===0?/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`px-5 pb-5 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:`Report records are unavailable because no fields were declared.`}):/* @__PURE__ */ (0,Z.jsxs)(Z.Fragment,{children:[/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`grid gap-2 border-t border-dashboard-border-subtle p-3 sm:hidden`,children:n.map(e=>/* @__PURE__ */ (0,Z.jsx)(`div`,{className:o(`grid gap-3 rounded-md border border-dashboard-border-subtle bg-dashboard-overlay-soft p-3`,$(e.tone)),children:t.map(t=>/* @__PURE__ */ (0,Z.jsxs)(`div`,{children:[/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:t.label}),/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`mt-1 break-words font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:e.values[t.key]??``})]},t.key))},e.id))}),/* @__PURE__ */ (0,Z.jsx)(`div`,{className:`hidden border-t border-dashboard-border-subtle sm:block`,children:/* @__PURE__ */ (0,Z.jsxs)(_,{className:`min-w-[36rem]`,children:[/* @__PURE__ */ (0,Z.jsx)(b,{className:`bg-dashboard-overlay-soft`,children:/* @__PURE__ */ (0,Z.jsx)(S,{children:t.map(e=>/* @__PURE__ */ (0,Z.jsx)(w,{className:`px-5`,scope:`col`,children:e.label},e.key))})}),/* @__PURE__ */ (0,Z.jsx)(g,{children:n.map(e=>/* @__PURE__ */ (0,Z.jsx)(S,{className:$(e.tone),children:t.map(t=>/* @__PURE__ */ (0,Z.jsx)(y,{className:`max-w-72 truncate px-5 py-3 font-mono text-xs text-dashboard-text-muted`,children:e.values[t.key]??``},t.key))},e.id))})]})})]})]})}function $(e){return e===`danger`?`bg-rose-500/[0.07]`:e===`warning`?`bg-amber-300/[0.045]`:e===`good`?`bg-emerald-400/[0.055]`:``}export{qt as n,Ht as r,Qt as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{G as t,I as n,K as r,P as i,R as a,X as o,it as s,ot as c,pt as l,ut as u}from"./vendor-lthmb2su.js";import{C as d,S as f,_ as p,a as m,h as ee,p as h,y as g}from"./vendor-react-ggbyvons.js";import{t as _}from"./button-loz3etho.js";import{Bt as te,Qt as v,_ as ne,gt as re,kt as ie,l as ae,o as oe}from"./vendor-icons-mxz7yi04.js";import{a as se,n as ce,t as le}from"./tooltip-c9bbl0em.js";import{Ht as ue}from"./junior-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{G as t,I as n,K as r,P as i,R as a,X as o,it as s,ot as c,pt as l,ut as u}from"./vendor-lthmb2su.js";import{C as d,S as f,_ as p,a as m,h as ee,p as h,y as g}from"./vendor-react-ggbyvons.js";import{t as _}from"./button-loz3etho.js";import{Bt as te,Qt as v,_ as ne,gt as re,kt as ie,l as ae,o as oe}from"./vendor-icons-mxz7yi04.js";import{a as se,n as ce,t as le}from"./tooltip-c9bbl0em.js";import{Ht as ue}from"./junior-gfsokzu9.js";import{i as y,r as de}from"./http-cdq677qt.js";import{r as fe,t as b}from"./styles-j0007fov.js";import{t as x}from"./Card-hy4bfgq7.js";import{t as S}from"./PageContentSkeleton-b7dkba0l.js";import{a as pe,r as C,s as me,t as w}from"./PageHeader-kvp1fo95.js";import{p as T}from"./format-c4b0iyrx.js";import{t as he}from"./PageLayout-l6dhbimv.js";import{t as E}from"./AnchorHeading-cp3vx8qa.js";import{n as ge,t as D}from"./searchParams-moqjgi65.js";import{A as O,F as k,Ft as _e,H as ve,M as A,N as j,P as M,X as N,ft as P,j as F,k as I,m as L,n as ye,q as R}from"../client-mgf2bxi7.js";import{t as be}from"./SelectableRow-j8fwjsjz.js";import{C as z,a as B,d as V,n as xe,o as Se,r as Ce,s as we,t as Te,u as Ee}from"./chart-dbzd0ka8.js";import{n as H,t as De}from"./BarChart-hdlbq093.js";import{t as Oe}from"./ChartLegend-c3e9l1vl.js"
|
|
2
2
|
/**
|
|
3
3
|
* @license lucide-react v1.17.0 - ISC
|
|
4
4
|
*
|
|
@@ -12,4 +12,4 @@ import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{G as t,I as n,K as r,P
|
|
|
12
12
|
* This source code is licensed under the ISC license.
|
|
13
13
|
* See the LICENSE file in the root directory of this source tree.
|
|
14
14
|
*/
|
|
15
|
-
;var U=/* @__PURE__ */ e(d(),1);function je(e){let[t,n]=g(),r=l(),i=(0,U.useRef)(!1),a=t.get(`filter`)?.trim()??``,[o,u,d]=ge(),f=s({initialPageParam:void 0,queryKey:[`dashboard`,`plugin-user-page`,e.pluginName,e.id,a,d],queryFn:({pageParam:t,signal:n})=>{let r=new URLSearchParams;a&&r.set(`filter`,a),d&&r.set(`q`,d),t&&r.set(`cursor`,t);let i=r.toString();return y(ue,`/api/user-pages/${encodeURIComponent(e.pluginName)}/${encodeURIComponent(e.id)}${i?`?${i}`:``}`,n)},getNextPageParam:e=>e.nextCursor,placeholderData:e=>e,retry:!1}),p=(0,U.useMemo)(()=>[...new Map((f.data?.pages??[]).flatMap(e=>e.records).map(e=>[e.id,e])).values()],[f.data?.pages]),m=c({mutationFn:e=>de(e.href),onMutate:()=>({pluginName:e.pluginName}),onSuccess:async(e,t,n)=>{r.removeQueries({queryKey:[`dashboard`,`plugin-user-page`,n.pluginName,`record`]}),await r.invalidateQueries({queryKey:[`dashboard`,`plugin-user-page`,n.pluginName]})},onSettled:()=>{i.current=!1}});function ee(e){i.current||(i.current=!0,m.mutate(e))}function h(e){let r=new URLSearchParams(t);e?r.set(`filter`,e):r.delete(`filter`),n(r,{replace:!0})}return{action:m,content:f.data?.pages[0],filter:a,query:f,records:p,runAction:ee,searchQuery:d,searchText:o,setFilter:h,setSearchText:u}}const Me=o().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),Ne=r({count:t().int().min(0),date:Me}).strict(),W=r({costUsd:t().finite().min(0),date:Me,events:t().int().min(0)}).strict(),Pe=r({days:a(Ne).length(90),extractionDays:a(W).length(90),extractionHours:a(W).min(24).optional(),generatedAt:i(),hours:a(Ne).min(24).optional(),recallDays:a(W).length(90),recallHours:a(W).min(24).optional(),stats:r({active:t().int().min(0),automatic:t().int().min(0),createdThirtyDays:t().int().min(0),embedded:t().int().min(0),explicit:t().int().min(0),knowledge:t().int().min(0),preference:t().int().min(0),procedure:t().int().min(0)}).strict()}).strict();function Fe(){return u({queryFn:({signal:e})=>y(Pe,`/api/plugins/memory/dashboard`,e),queryKey:[`dashboard`,`plugin-user-page`,`memory`,`summary`],retry:!1})}var G=f();const Ie=/* @__PURE__ */ new Set([`Learned`,`Memory ID`,`Source`,`Type`]);function Le(e){let{record:t}=e,[n,r]=(0,U.useState)(!1),i=t?Be(t):`Memory details`,a=t?.actions?.find(e=>e.tone===`danger`);return/* @__PURE__ */ (0,G.jsxs)(ve,{label:`Memory details`,onClose:e.onClose,sheetTitle:i,title:/* @__PURE__ */ (0,G.jsx)(`h2`,{className:`m-0 flex items-center gap-2 font-display text-base font-medium text-dashboard-text`,children:/* @__PURE__ */ (0,G.jsx)(`span`,{className:`truncate`,children:i})}),children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`grid h-full min-h-0 grid-rows-[minmax(0,1fr)_auto]`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{"aria-label":`Memory content`,role:`region`,tabIndex:0,className:`grid min-h-0 min-w-0 content-start gap-4 overflow-y-auto overscroll-contain p-4 outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus [overflow-wrap:anywhere]`,children:t?/* @__PURE__ */ (0,G.jsxs)(G.Fragment,{children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`grid gap-3 text-sm leading-relaxed`,children:[/* @__PURE__ */ (0,G.jsx)(j,{text:t.title}),t.description?/* @__PURE__ */ (0,G.jsx)(j,{text:t.description}):null]}),/* @__PURE__ */ (0,G.jsx)(Re,{record:t})]}):/* @__PURE__ */ (0,G.jsx)(S,{label:`Loading memory`,variant:`panel`})}),t&&a?/* @__PURE__ */ (0,G.jsx)(`footer`,{"aria-label":`Memory actions`,className:`flex items-center gap-2 border-t border-dashboard-border bg-dashboard-bg-elevated p-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:/* @__PURE__ */ (0,G.jsxs)(le,{children:[/* @__PURE__ */ (0,G.jsx)(se,{render:/* @__PURE__ */ (0,G.jsx)(_,{"aria-label":`Forget this memory`,className:`min-h-11 min-w-11`,disabled:e.forgetPending,onClick:()=>{a.confirmation?r(!0):e.onForget(a)},size:`icon`,variant:`danger`,children:/* @__PURE__ */ (0,G.jsx)(ae,{"aria-hidden":`true`,size:16})})}),/* @__PURE__ */ (0,G.jsx)(ce,{size:`compact`,children:`Forget this memory`})]})}):null]}),a?.confirmation&&t?/* @__PURE__ */ (0,G.jsx)(N,{onOpenChange:r,open:n,children:/* @__PURE__ */ (0,G.jsxs)(M,{children:[/* @__PURE__ */ (0,G.jsx)(L,{children:a.confirmation}),/* @__PURE__ */ (0,G.jsx)(R,{children:t.title}),/* @__PURE__ */ (0,G.jsxs)(O,{children:[/* @__PURE__ */ (0,G.jsx)(k,{children:`Cancel`}),/* @__PURE__ */ (0,G.jsx)(A,{onClick:()=>{r(!1),e.onForget(a)},variant:`danger`,children:a.label})]})]})}):null]})}function Re(e){let{record:t}=e,n=K(t,`Learned`),r=K(t,`Source`),i=n===`Automatic`?`From a ${r??`past`} conversation`:n===`Explicit`?`Someone asked Junior`:n?`Before origin tracking`:void 0,a=K(t,`Remembered`),o=(t.metadata??[]).filter(e=>!Ie.has(e.label)&&(e.label!==`Observed`||e.value!==a));return/* @__PURE__ */ (0,G.jsxs)(`dl`,{className:`m-0 grid min-w-0 gap-2 rounded-lg border border-dashboard-border-subtle bg-dashboard-surface-panel p-3 text-xs leading-snug`,children:[i?/* @__PURE__ */ (0,G.jsx)(ze,{label:`Learned`,children:i}):null,o.map(e=>/* @__PURE__ */ (0,G.jsx)(ze,{label:e.label,children:e.value},e.label))]})}function ze(e){return/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-4`,children:[/* @__PURE__ */ (0,G.jsx)(`dt`,{className:`shrink-0 text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,G.jsx)(`dd`,{className:`m-0 min-w-0 break-words text-right tabular-nums text-dashboard-text`,children:e.children})]})}function Be(e){return K(e,`Type`)??`Memory`}function K(e,t){return e.metadata?.find(e=>e.label===t)?.value}function Ve(e){return[...new Set(e.toLowerCase().split(/[^a-z0-9_'-]+/).filter(e=>e.length>=2))]}function He(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Ue(e){let t=Ve(e.query);if(t.length===0)return/* @__PURE__ */ (0,G.jsx)(G.Fragment,{children:e.text});let n=RegExp(`(${t.sort((e,t)=>t.length-e.length).map(He).join(`|`)})`,`gi`);return/* @__PURE__ */ (0,G.jsx)(G.Fragment,{children:e.text.split(n).map((e,t)=>t%2==1?/* @__PURE__ */ (0,G.jsx)(`mark`,{className:`rounded-sm bg-amber-300/25 text-dashboard-text`,children:e},t):e)})}const We={count:{color:`var(--color-emerald-300)`,label:`Memories`}};function Ge(e){let t=e.bucketUnit??`day`,n=e.days,r=n.map(e=>e.count),i=Math.max(1,...r),a=r.some(e=>e>0);return/* @__PURE__ */ (0,G.jsxs)(x,{className:`min-h-[17rem] p-4 sm:p-5`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{children:[/* @__PURE__ */ (0,G.jsx)(E,{anchor:`activity`,className:`m-0 font-display text-xl font-medium text-dashboard-text`,title:`Activity over time`}),/* @__PURE__ */ (0,G.jsx)(`p`,{className:`mt-1 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:t===`hour`?`Memories created each hour.`:t===`6hour`?`Memories created each 6 hours.`:`Memories created each day.`})]}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`relative mt-3 overflow-hidden`,children:[/* @__PURE__ */ (0,G.jsx)(Te,{className:`aspect-auto h-50 w-full`,config:We,children:/* @__PURE__ */ (0,G.jsxs)(De,{"aria-label":`Memories learned during the last ${e.range===1?`24 hours`:`${e.range} days`}`,data:n,margin:V,role:`img`,children:[/* @__PURE__ */ (0,G.jsx)(z,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,G.jsx)(we,{maximum:i}),/* @__PURE__ */ (0,G.jsx)(Se,{keys:n.map(e=>e.date)}),/* @__PURE__ */ (0,G.jsx)(xe,{content:/* @__PURE__ */ (0,G.jsx)(B,{rows:e=>[[`memories`,e.count]]})}),/* @__PURE__ */ (0,G.jsx)(H,{dataKey:`count`,fill:`var(--color-count)`,fillOpacity:.82,isAnimationActive:!1,maxBarSize:13})]})}),a?null:/* @__PURE__ */ (0,G.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 memories were learned in this period.`})]})]})}const Ke={extraction:{color:`var(--color-cyan-300)`,label:`Extraction`},recall:{color:`var(--color-fuchsia-400)`,label:`Recall`}};function q(e){return T({total:e})}function qe(e){let t=e.bucketUnit??`day`,n=new Map(e.recallDays.map(e=>[e.date,e])),r=e.extractionDays.map(e=>{let t=n.get(e.date)??{costUsd:0,date:e.date,events:0};return{date:e.date,extraction:e,extractionCost:e.costUsd,recall:t,recallCost:t.costUsd}}),i=r.reduce((e,t)=>e+t.extraction.costUsd,0),a=r.reduce((e,t)=>e+t.recall.costUsd,0),o=i+a,s=r.reduce((e,t)=>e+t.extraction.events+t.recall.events,0),c=r.map(e=>e.extraction.costUsd+e.recall.costUsd),l=Math.max(.01,...c),u=Ee(c);return/* @__PURE__ */ (0,G.jsxs)(x,{className:`min-h-[17rem] p-4 sm:p-5`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{children:[/* @__PURE__ */ (0,G.jsx)(E,{anchor:`cost`,label:`cost`,className:`m-0 font-display text-xl font-medium text-dashboard-text`,title:T({total:o})}),/* @__PURE__ */ (0,G.jsxs)(`p`,{className:`mt-1 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:[`System-wide estimate across `,J(s),` spanning extraction and recall.`]}),/* @__PURE__ */ (0,G.jsx)(Oe,{ariaLabel:`Memory cost legend`,items:[{color:`var(--color-cyan-300)`,key:`extraction`,label:`Extraction`,value:T({total:i})},{color:`var(--color-fuchsia-400)`,key:`recall`,label:`Recall`,value:T({total:a})}]})]}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`relative mt-4 overflow-hidden`,children:[/* @__PURE__ */ (0,G.jsx)(Te,{className:`aspect-auto h-50 w-full`,config:Ke,children:/* @__PURE__ */ (0,G.jsxs)(De,{"aria-label":`Memory extraction and recall cost during the last ${e.range===1?`24 hours`:`${e.range} days`}`,data:r,margin:V,role:`img`,children:[/* @__PURE__ */ (0,G.jsx)(z,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,G.jsx)(we,{format:q,maximum:l}),/* @__PURE__ */ (0,G.jsx)(Se,{keys:r.map(e=>e.date)}),/* @__PURE__ */ (0,G.jsx)(xe,{content:/* @__PURE__ */ (0,G.jsx)(B,{rows:e=>[[`extraction`,`${q(e.extractionCost)} · ${J(e.extraction.events)}`],[`recall`,`${q(e.recallCost)} · ${J(e.recall.events)}`],[`total`,q(e.extractionCost+e.recallCost)]]})}),/* @__PURE__ */ (0,G.jsx)(H,{dataKey:`extractionCost`,fill:`var(--color-extraction)`,fillOpacity:.82,isAnimationActive:!1,maxBarSize:13,stackId:`cost`}),/* @__PURE__ */ (0,G.jsx)(H,{dataKey:`recallCost`,fill:`var(--color-recall)`,fillOpacity:.82,isAnimationActive:!1,maxBarSize:13,stackId:`cost`}),/* @__PURE__ */ (0,G.jsx)(Ce,{unit:pe(t),average:u,format:q,stroke:`var(--color-slate-200)`})]})}),s===0?/* @__PURE__ */ (0,G.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 memory extraction or recall ran in this period.`}):null]})]})}function J(e){return`${e.toLocaleString()} ${e===1?`run`:`runs`}`}const Je=r({content:o().min(1),createdAt:i(),expiresAt:i().optional(),id:o().min(1),kind:n([`preference`,`procedure`,`knowledge`]),observedAt:i(),origin:n([`automatic`,`explicit`,`other`]),sourcePlatform:n([`local`,`slack`,`web`])}).strict();function Y(e){return e.charAt(0).toUpperCase()+e.slice(1)}function X(e){return new Intl.DateTimeFormat(`en-US`,{dateStyle:`medium`,timeStyle:`short`,timeZone:`UTC`}).format(new Date(e))}function Ye(e){let t=e.origin===`automatic`?`Automatic`:e.origin===`explicit`?`Explicit`:`Other`;return{actions:[{confirmation:`Forget this memory for everyone?`,href:`/api/plugins/memory/memories/${encodeURIComponent(e.id)}`,label:`Forget`,method:`DELETE`,tone:`danger`}],id:e.id,metadata:[{label:`Type`,value:Y(e.kind)},{label:`Learned`,value:t},{label:`Source`,value:Y(e.sourcePlatform)},{label:`Remembered`,value:X(e.createdAt)},{label:`Observed`,value:X(e.observedAt)},{label:`Expires`,value:e.expiresAt?X(e.expiresAt):`Never`}],title:e.content}}function Xe(e){return u({enabled:!!e,queryFn:async({signal:t})=>Ye(await y(Je,`/api/plugins/memory/memories/${encodeURIComponent(e)}`,t)),queryKey:[`dashboard`,`plugin-user-page`,`memory`,`record`,e],retry:!1})}const Ze=`grid-cols-1 sm:grid-cols-[minmax(0,1fr)_7rem_9rem]`;function Qe(e){let[t,n]=(0,U.useState)(30),r=h(),{memoryId:i}=p(),a=`/memories`,o=`${a}/library`,s=r.pathname===a,c=r.pathname===o||!!i;return!s&&!c?/* @__PURE__ */ (0,G.jsx)(m,{replace:!0,to:a}):/* @__PURE__ */ (0,G.jsx)(ye,{children:s?/* @__PURE__ */ (0,G.jsxs)(G.Fragment,{children:[/* @__PURE__ */ (0,G.jsx)(w,{description:e.page.description,onRangeChange:n,range:t,title:e.page.label}),/* @__PURE__ */ (0,G.jsx)($e,{range:t})]}):/* @__PURE__ */ (0,G.jsx)(et,{libraryPath:o,page:e.page})})}function $e(e){let t=Fe();return t.error?/* @__PURE__ */ (0,G.jsxs)(x,{className:`flex items-center gap-3 border-rose-300/20 p-5 text-sm text-rose-200`,children:[/* @__PURE__ */ (0,G.jsx)(ie,{"aria-hidden":`true`,size:18}),`Memory history is temporarily unavailable.`]}):t.data?/* @__PURE__ */ (0,G.jsxs)(G.Fragment,{children:[/* @__PURE__ */ (0,G.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-2`,children:[/* @__PURE__ */ (0,G.jsx)(Ge,{bucketUnit:me(e.range),days:C({days:t.data.days,hours:t.data.hours,range:e.range,emptySixHour:e=>({count:0,date:e})}),range:e.range}),/* @__PURE__ */ (0,G.jsx)(qe,{bucketUnit:me(e.range),extractionDays:C({days:t.data.extractionDays,hours:t.data.extractionHours,range:e.range,emptySixHour:e=>({costUsd:0,date:e,events:0})}),range:e.range,recallDays:C({days:t.data.recallDays,hours:t.data.recallHours,range:e.range,emptySixHour:e=>({costUsd:0,date:e,events:0})})})]}),/* @__PURE__ */ (0,G.jsx)(nt,{data:t.data}),/* @__PURE__ */ (0,G.jsxs)(`section`,{className:`grid gap-4 md:grid-cols-2`,children:[/* @__PURE__ */ (0,G.jsx)(rt,{data:t.data}),/* @__PURE__ */ (0,G.jsx)(it,{data:t.data})]})]}):/* @__PURE__ */ (0,G.jsx)(S,{className:`gap-6 sm:gap-8`,label:`Loading memory history`,variant:`overview`})}function et(e){let{action:t,content:n,query:r,records:i,runAction:a,searchQuery:o,searchText:s,setSearchText:c}=je(e.page),l=ee(),u=h(),{memoryId:d}=p(),f=(0,U.useRef)(null),m=Xe(d),g=m.data??i.find(e=>e.id===d),_=e=>D(e,u.search),te=()=>{let t=d?f.current?.querySelector(`button[data-memory-id="${CSS.escape(d)}"]`):void 0;l(_(e.libraryPath)),(t??f.current)?.focus()},v=t=>{l(_(e.libraryPath)),f.current?.focus(),a(t)};(0,U.useEffect)(()=>{d&&t.reset()},[d]),(0,U.useEffect)(()=>{!d||g||m.isFetching||m.isPending||(m.isError||m.isFetched)&&l(D(e.libraryPath,u.search),{replace:!0})},[u.search,d,m.isError,m.isFetched,m.isFetching,m.isPending,l,e.libraryPath,g]);let ne=!r.data&&!r.error;return/* @__PURE__ */ (0,G.jsxs)(`div`,{className:b(`grid h-full min-h-0 min-w-0`,d&&`xl:grid-cols-[minmax(0,1fr)_25rem]`),children:[/* @__PURE__ */ (0,G.jsx)(`div`,{"aria-label":`Memories 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:f,role:`region`,tabIndex:0,children:/* @__PURE__ */ (0,G.jsxs)(he,{className:`gap-6 sm:gap-8`,children:[/* @__PURE__ */ (0,G.jsx)(w,{description:e.page.description,title:e.page.label}),/* @__PURE__ */ (0,G.jsxs)(`section`,{className:`grid gap-4`,"aria-labelledby":`memory-library-title`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-4`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{children:/* @__PURE__ */ (0,G.jsx)(`h2`,{className:`m-0 font-display text-xl font-medium tracking-[-0.02em] text-dashboard-text`,id:`memory-library-title`,children:o?`Search results`:`What Junior remembers`})}),n?.searchPlaceholder?/* @__PURE__ */ (0,G.jsx)(I,{className:`w-full max-w-md sm:w-auto`,label:n.searchPlaceholder,onChange:c,placeholder:n.searchPlaceholder,size:`default`,value:s}):null]}),ne?/* @__PURE__ */ (0,G.jsx)(S,{label:`Loading memories`,variant:`panel`}):r.error?/* @__PURE__ */ (0,G.jsxs)(x,{className:`flex items-center gap-3 border-rose-300/20 p-5 text-sm text-rose-200`,children:[/* @__PURE__ */ (0,G.jsx)(ie,{"aria-hidden":`true`,size:18}),r.error.message]}):i.length===0?/* @__PURE__ */ (0,G.jsx)(x,{className:`grid min-h-56 place-items-center p-8 text-center`,children:/* @__PURE__ */ (0,G.jsxs)(`div`,{children:[/* @__PURE__ */ (0,G.jsx)(re,{"aria-hidden":`true`,className:`mx-auto text-dashboard-text-muted`,size:26}),/* @__PURE__ */ (0,G.jsx)(`p`,{className:`mt-4 mb-0 text-sm text-dashboard-text-muted`,children:n?.emptyText??`No memories yet.`})]})}):/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`grid gap-3`,children:[/* @__PURE__ */ (0,G.jsxs)(x,{padding:`none`,children:[/* @__PURE__ */ (0,G.jsx)(tt,{}),i.map((t,n)=>/* @__PURE__ */ (0,G.jsx)(at,{first:n===0,onSelect:()=>l(_(d===t.id?e.libraryPath:`/memories/${encodeURIComponent(t.id)}`)),record:t,searchQuery:o,selected:t.id===d},t.id))]}),/* @__PURE__ */ (0,G.jsx)(F,{className:`mt-2`,hasMore:!r.isPlaceholderData&&!!r.hasNextPage,loading:r.isFetchingNextPage,onLoadMore:()=>void r.fetchNextPage()}),t.error?/* @__PURE__ */ (0,G.jsx)(P,{className:`text-center`,children:`Could not complete this action. Try again.`}):null]})]})]})}),d?/* @__PURE__ */ (0,G.jsx)(Le,{forgetPending:t.isPending,onClose:te,onForget:v,record:g},d):null]})}function tt(){return/* @__PURE__ */ (0,G.jsxs)(`div`,{className:b(`hidden items-center gap-3 border-b border-dashboard-border px-4 py-2.5 text-left font-sans font-medium text-xs text-dashboard-text-muted sm:grid`,Ze),role:`row`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{children:`Memory`}),/* @__PURE__ */ (0,G.jsx)(`div`,{children:`Type`}),/* @__PURE__ */ (0,G.jsx)(`div`,{children:`Learned`})]})}function nt(e){let{stats:t}=e.data,n=[{detail:`shared across the workspace`,label:`Total active`,tone:`text-dashboard-accent-text`,value:t.active.toLocaleString(`en-US`)},{detail:`in the last 30 days`,label:`Added · 30d`,value:`+${t.createdThirtyDays.toLocaleString(`en-US`)}`}];return/* @__PURE__ */ (0,G.jsx)(`section`,{"aria-label":`Memory summary`,className:`grid grid-cols-2 gap-px border-y border-dashboard-border-subtle bg-dashboard-fill-hover`,children:n.map(e=>/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`bg-dashboard-bg px-4 py-4 sm:px-5`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:b(`mt-2 font-display text-3xl font-light tracking-[-0.04em] text-dashboard-text`,e.tone),children:e.value}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`mt-1 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:e.detail})]},e.label))})}function rt(e){let{stats:t}=e.data;return/* @__PURE__ */ (0,G.jsxs)(x,{className:`p-5 sm:p-6`,children:[/* @__PURE__ */ (0,G.jsx)(E,{anchor:`memory-types`,className:`m-0 font-display text-xl font-medium text-dashboard-text`,title:`What Junior remembers`}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`mt-5 grid gap-px overflow-hidden rounded-md border border-dashboard-border-subtle bg-dashboard-fill-hover`,children:[/* @__PURE__ */ (0,G.jsx)(Z,{detail:`How people like to work`,icon:oe,label:`Preferences`,value:t.preference}),/* @__PURE__ */ (0,G.jsx)(Z,{detail:`How work should get done`,icon:re,label:`Procedures`,value:t.procedure}),/* @__PURE__ */ (0,G.jsx)(Z,{detail:`Facts and durable context`,icon:Ae,label:`Knowledge`,value:t.knowledge})]})]})}function it(e){let{stats:t}=e.data,n=Math.max(0,t.active-t.automatic-t.explicit);return/* @__PURE__ */ (0,G.jsxs)(x,{className:`p-5 sm:p-6`,children:[/* @__PURE__ */ (0,G.jsx)(E,{anchor:`memory-sources`,className:`m-0 font-display text-xl font-medium text-dashboard-text`,title:`How they got here`}),/* @__PURE__ */ (0,G.jsx)(`p`,{className:`mt-1 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:`Same totals, split by how they were written.`}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`mt-5 grid gap-px overflow-hidden rounded-md border border-dashboard-border-subtle bg-dashboard-fill-hover`,children:[/* @__PURE__ */ (0,G.jsx)(Z,{detail:`Passive extraction after runs`,icon:ne,label:`Learned by Junior`,value:t.automatic}),/* @__PURE__ */ (0,G.jsx)(Z,{detail:`Someone asked to remember it`,icon:ke,label:`Saved explicitly`,value:t.explicit}),/* @__PURE__ */ (0,G.jsx)(Z,{detail:`Before origin tracking`,icon:Ae,label:`Older records`,value:n})]})]})}function Z(e){let t=e.icon;return/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex items-center gap-3 bg-dashboard-bg-elevated px-3 py-3`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`grid size-9 shrink-0 place-items-center rounded-md border border-dashboard-border bg-dashboard-fill-soft text-dashboard-text-muted`,children:/* @__PURE__ */ (0,G.jsx)(t,{"aria-hidden":`true`,size:15})}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`font-display text-base font-medium text-dashboard-text`,children:e.label}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`mt-0.5 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:e.detail})]}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`font-display text-2xl font-light text-dashboard-text`,children:e.value.toLocaleString(`en-US`)})]})}function at(e){let t=Q(e.record,`Type`),n=Q(e.record,`Remembered`),r=Q(e.record,`Source`);return/* @__PURE__ */ (0,G.jsx)(be,{className:b(`flex items-stretch`,!e.first&&`border-t border-dashboard-border-subtle`),onSelect:e.onSelect,selected:e.selected,children:/* @__PURE__ */ (0,G.jsxs)(`button`,{"aria-expanded":e.selected,"aria-label":`View memory details: ${e.record.title}`,"data-memory-id":e.record.id,className:b(`grid min-w-0 flex-1 cursor-pointer items-center gap-3 border-0 bg-transparent px-4 py-3 text-left`,Ze),onClick:e.onSelect,type:`button`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`min-w-0 overflow-hidden`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`flex min-w-0 items-center gap-2 overflow-hidden`,children:/* @__PURE__ */ (0,G.jsx)(`h3`,{className:`m-0 truncate font-display text-base font-medium leading-snug text-dashboard-text`,children:/* @__PURE__ */ (0,G.jsx)(Ue,{query:e.searchQuery,text:e.record.title})})}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`mt-1.5 truncate font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:[`Source: `,r,/* @__PURE__ */ (0,G.jsxs)(`span`,{className:`sm:hidden`,children:[` `,`· `,t,` · `,$(n)]})]})]}),/* @__PURE__ */ (0,G.jsx)(`span`,{className:`hidden truncate font-mono text-xs text-dashboard-text-muted sm:block`,children:t}),/* @__PURE__ */ (0,G.jsx)(`span`,{className:`hidden truncate font-mono text-xs text-dashboard-text sm:block`,children:$(n)})]})})}function Q(e,t){return e.metadata?.find(e=>e.label===t)?.value??`—`}function $(e){return e.split(`,`).slice(0,2).join(`,`)}function ot(e){let t=e.pages.find(e=>e.pluginName===`memory`&&e.id===`memories`);return t?/* @__PURE__ */ (0,G.jsx)(Qe,{page:t}):/* @__PURE__ */ (0,G.jsx)(m,{replace:!0,to:`/`})}function st(e){let t=h(),{"*":n,pageId:r,pluginName:i}=p(),a=e.pages.find(e=>e.pluginName===i&&e.id===r);if(!a)return/* @__PURE__ */ (0,G.jsx)(m,{replace:!0,to:`/`});if(a.pluginName===`memory`&&a.id===`memories`){let e=n?`/${n}`:``;return/* @__PURE__ */ (0,G.jsx)(m,{replace:!0,to:D(`/memories${e}`,t.search)})}return/* @__PURE__ */ (0,G.jsx)(ct,{page:a})}function ct(e){let{action:t,content:n,query:r,records:i,runAction:a,searchText:o,setSearchText:s}=je(e.page),[c,l]=(0,U.useState)(),[u,d]=(0,U.useState)(!1);return!r.data&&!r.error?/* @__PURE__ */ (0,G.jsx)(_e,{label:`Loading ${e.page.label}`}):/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`${fe} px-4 py-8 md:px-8`,children:[/* @__PURE__ */ (0,G.jsxs)(`section`,{className:`mx-auto grid w-full max-w-3xl gap-6`,children:[/* @__PURE__ */ (0,G.jsx)(w,{description:e.page.description,title:e.page.label}),n?.metrics?.length?/* @__PURE__ */ (0,G.jsx)(`section`,{"aria-label":`${e.page.label} overview`,className:`grid gap-3 sm:grid-cols-2`,children:n.metrics.map(e=>/* @__PURE__ */ (0,G.jsxs)(x,{className:`p-4`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`mt-3 font-display text-2xl font-light text-dashboard-text`,children:e.value}),e.detail?/* @__PURE__ */ (0,G.jsx)(`div`,{className:`mt-1 font-mono text-xs text-dashboard-text-muted`,children:e.detail}):null]},e.label))}):null,n?.searchPlaceholder?/* @__PURE__ */ (0,G.jsx)(I,{className:`w-full`,label:n.searchPlaceholder,onChange:s,placeholder:n.searchPlaceholder,size:`default`,value:o}):null,r.error?/* @__PURE__ */ (0,G.jsx)(x,{padding:`md`,children:/* @__PURE__ */ (0,G.jsxs)(P,{children:[`Could not load `,e.page.label.toLowerCase(),`. Try again.`]})}):i.length===0?/* @__PURE__ */ (0,G.jsx)(x,{padding:`md`,children:/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex items-center gap-4`,children:[/* @__PURE__ */ (0,G.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:/* @__PURE__ */ (0,G.jsx)(te,{"aria-hidden":`true`,size:17})}),/* @__PURE__ */ (0,G.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:n?.emptyText??`No ${e.page.label.toLowerCase()}.`})]})}):/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`grid gap-3`,children:[i.map(e=>/* @__PURE__ */ (0,G.jsxs)(x,{padding:`md`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[/* @__PURE__ */ (0,G.jsx)(`h2`,{className:`m-0 min-w-0 flex-1 font-display text-base font-medium text-dashboard-text`,children:e.title}),e.actions?.map(n=>n.method===`GET`?/* @__PURE__ */ (0,G.jsx)(`a`,{className:`shrink-0 rounded-md border border-dashboard-border-strong px-3 py-1.5 text-sm font-semibold text-dashboard-text no-underline transition-colors hover:bg-dashboard-fill-strong`,href:n.href,children:n.label},`${n.method}:${n.href}`):/* @__PURE__ */ (0,G.jsx)(`button`,{"aria-label":`${n.label}: ${e.title}`,className:`cursor-pointer border-0 bg-transparent p-1 text-dashboard-text-muted transition-colors ${n.tone===`danger`?`hover:text-rose-300`:`hover:text-dashboard-text`}`,disabled:t.isPending,onClick:()=>{n.confirmation?(l({action:n,record:e}),d(!0)):a(n)},title:n.label,type:`button`,children:n.tone===`danger`?/* @__PURE__ */ (0,G.jsx)(ae,{"aria-hidden":`true`,size:16}):n.label},`${n.method}:${n.href}`))]}),e.description?/* @__PURE__ */ (0,G.jsx)(`p`,{className:`mt-2 mb-0 text-sm text-dashboard-text-muted`,children:e.description}):null,e.metadata?.length?/* @__PURE__ */ (0,G.jsx)(`dl`,{className:`mt-4 flex flex-wrap gap-x-6 gap-y-2`,children:e.metadata.map(e=>/* @__PURE__ */ (0,G.jsxs)(`div`,{children:[/* @__PURE__ */ (0,G.jsx)(`dt`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,G.jsx)(`dd`,{className:`mt-1 ml-0 font-mono text-xs text-dashboard-text-muted`,children:e.value})]},e.label))}):null]},e.id)),/* @__PURE__ */ (0,G.jsx)(F,{hasMore:!r.isPlaceholderData&&!!r.hasNextPage,loading:r.isFetchingNextPage,onLoadMore:()=>void r.fetchNextPage()}),t.error?/* @__PURE__ */ (0,G.jsx)(P,{className:`text-center`,children:`Could not complete this action. Try again.`}):null]})]}),/* @__PURE__ */ (0,G.jsx)(N,{onOpenChange:d,open:u,children:/* @__PURE__ */ (0,G.jsxs)(M,{children:[/* @__PURE__ */ (0,G.jsx)(L,{children:c?.action.confirmation}),/* @__PURE__ */ (0,G.jsx)(R,{children:c?.record.title}),/* @__PURE__ */ (0,G.jsxs)(O,{children:[/* @__PURE__ */ (0,G.jsx)(k,{children:`Cancel`}),/* @__PURE__ */ (0,G.jsx)(A,{onClick:()=>{c&&a(c.action),d(!1)},variant:c?.action.tone===`danger`?`danger`:`primary`,children:c?.action.label})]})]})})]})}export{ot as MemoryPermalinkRoute,st as PluginUserPageRoute};
|
|
15
|
+
;var U=/* @__PURE__ */ e(d(),1);function je(e){let[t,n]=g(),r=l(),i=(0,U.useRef)(!1),a=t.get(`filter`)?.trim()??``,[o,u,d]=ge(),f=s({initialPageParam:void 0,queryKey:[`dashboard`,`plugin-user-page`,e.pluginName,e.id,a,d],queryFn:({pageParam:t,signal:n})=>{let r=new URLSearchParams;a&&r.set(`filter`,a),d&&r.set(`q`,d),t&&r.set(`cursor`,t);let i=r.toString();return y(ue,`/api/user-pages/${encodeURIComponent(e.pluginName)}/${encodeURIComponent(e.id)}${i?`?${i}`:``}`,n)},getNextPageParam:e=>e.nextCursor,placeholderData:e=>e,retry:!1}),p=(0,U.useMemo)(()=>[...new Map((f.data?.pages??[]).flatMap(e=>e.records).map(e=>[e.id,e])).values()],[f.data?.pages]),m=c({mutationFn:e=>de(e.href),onMutate:()=>({pluginName:e.pluginName}),onSuccess:async(e,t,n)=>{r.removeQueries({queryKey:[`dashboard`,`plugin-user-page`,n.pluginName,`record`]}),await r.invalidateQueries({queryKey:[`dashboard`,`plugin-user-page`,n.pluginName]})},onSettled:()=>{i.current=!1}});function ee(e){i.current||(i.current=!0,m.mutate(e))}function h(e){let r=new URLSearchParams(t);e?r.set(`filter`,e):r.delete(`filter`),n(r,{replace:!0})}return{action:m,content:f.data?.pages[0],filter:a,query:f,records:p,runAction:ee,searchQuery:d,searchText:o,setFilter:h,setSearchText:u}}const Me=o().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/),Ne=r({count:t().int().min(0),date:Me}).strict(),W=r({costUsd:t().finite().min(0),date:Me,events:t().int().min(0)}).strict(),Pe=r({days:a(Ne).length(90),extractionDays:a(W).length(90),extractionHours:a(W).min(24).optional(),generatedAt:i(),hours:a(Ne).min(24).optional(),recallDays:a(W).length(90),recallHours:a(W).min(24).optional(),stats:r({active:t().int().min(0),automatic:t().int().min(0),createdThirtyDays:t().int().min(0),embedded:t().int().min(0),explicit:t().int().min(0),knowledge:t().int().min(0),preference:t().int().min(0),procedure:t().int().min(0)}).strict()}).strict();function Fe(){return u({queryFn:({signal:e})=>y(Pe,`/api/plugins/memory/dashboard`,e),queryKey:[`dashboard`,`plugin-user-page`,`memory`,`summary`],retry:!1})}var G=f();const Ie=/* @__PURE__ */ new Set([`Learned`,`Memory ID`,`Source`,`Type`]);function Le(e){let{record:t}=e,[n,r]=(0,U.useState)(!1),i=t?Be(t):`Memory details`,a=t?.actions?.find(e=>e.tone===`danger`);return/* @__PURE__ */ (0,G.jsxs)(ve,{label:`Memory details`,onClose:e.onClose,sheetTitle:i,title:/* @__PURE__ */ (0,G.jsx)(`h2`,{className:`m-0 flex items-center gap-2 font-display text-base font-medium text-dashboard-text`,children:/* @__PURE__ */ (0,G.jsx)(`span`,{className:`truncate`,children:i})}),children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`grid h-full min-h-0 grid-rows-[minmax(0,1fr)_auto]`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{"aria-label":`Memory content`,role:`region`,tabIndex:0,className:`grid min-h-0 min-w-0 content-start gap-4 overflow-y-auto overscroll-contain p-4 outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-dashboard-focus [overflow-wrap:anywhere]`,children:t?/* @__PURE__ */ (0,G.jsxs)(G.Fragment,{children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`grid gap-3 text-sm leading-relaxed`,children:[/* @__PURE__ */ (0,G.jsx)(N,{text:t.title}),t.description?/* @__PURE__ */ (0,G.jsx)(N,{text:t.description}):null]}),/* @__PURE__ */ (0,G.jsx)(Re,{record:t})]}):/* @__PURE__ */ (0,G.jsx)(S,{label:`Loading memory`,variant:`panel`})}),t&&a?/* @__PURE__ */ (0,G.jsx)(`footer`,{"aria-label":`Memory actions`,className:`flex items-center gap-2 border-t border-dashboard-border bg-dashboard-bg-elevated p-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:/* @__PURE__ */ (0,G.jsxs)(le,{children:[/* @__PURE__ */ (0,G.jsx)(se,{render:/* @__PURE__ */ (0,G.jsx)(_,{"aria-label":`Forget this memory`,className:`min-h-11 min-w-11`,disabled:e.forgetPending,onClick:()=>{a.confirmation?r(!0):e.onForget(a)},size:`icon`,variant:`danger`,children:/* @__PURE__ */ (0,G.jsx)(ae,{"aria-hidden":`true`,size:16})})}),/* @__PURE__ */ (0,G.jsx)(ce,{size:`compact`,children:`Forget this memory`})]})}):null]}),a?.confirmation&&t?/* @__PURE__ */ (0,G.jsx)(I,{onOpenChange:r,open:n,children:/* @__PURE__ */ (0,G.jsxs)(A,{children:[/* @__PURE__ */ (0,G.jsx)(k,{children:a.confirmation}),/* @__PURE__ */ (0,G.jsx)(j,{children:t.title}),/* @__PURE__ */ (0,G.jsxs)(M,{children:[/* @__PURE__ */ (0,G.jsx)(F,{children:`Cancel`}),/* @__PURE__ */ (0,G.jsx)(O,{onClick:()=>{r(!1),e.onForget(a)},variant:`danger`,children:a.label})]})]})}):null]})}function Re(e){let{record:t}=e,n=K(t,`Learned`),r=K(t,`Source`),i=n===`Automatic`?`From a ${r??`past`} conversation`:n===`Explicit`?`Someone asked Junior`:n?`Before origin tracking`:void 0,a=K(t,`Remembered`),o=(t.metadata??[]).filter(e=>!Ie.has(e.label)&&(e.label!==`Observed`||e.value!==a));return/* @__PURE__ */ (0,G.jsxs)(`dl`,{className:`m-0 grid min-w-0 gap-2 rounded-lg border border-dashboard-border-subtle bg-dashboard-surface-panel p-3 text-xs leading-snug`,children:[i?/* @__PURE__ */ (0,G.jsx)(ze,{label:`Learned`,children:i}):null,o.map(e=>/* @__PURE__ */ (0,G.jsx)(ze,{label:e.label,children:e.value},e.label))]})}function ze(e){return/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-4`,children:[/* @__PURE__ */ (0,G.jsx)(`dt`,{className:`shrink-0 text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,G.jsx)(`dd`,{className:`m-0 min-w-0 break-words text-right tabular-nums text-dashboard-text`,children:e.children})]})}function Be(e){return K(e,`Type`)??`Memory`}function K(e,t){return e.metadata?.find(e=>e.label===t)?.value}function Ve(e){return[...new Set(e.toLowerCase().split(/[^a-z0-9_'-]+/).filter(e=>e.length>=2))]}function He(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Ue(e){let t=Ve(e.query);if(t.length===0)return/* @__PURE__ */ (0,G.jsx)(G.Fragment,{children:e.text});let n=RegExp(`(${t.sort((e,t)=>t.length-e.length).map(He).join(`|`)})`,`gi`);return/* @__PURE__ */ (0,G.jsx)(G.Fragment,{children:e.text.split(n).map((e,t)=>t%2==1?/* @__PURE__ */ (0,G.jsx)(`mark`,{className:`rounded-sm bg-amber-300/25 text-dashboard-text`,children:e},t):e)})}const We={count:{color:`var(--color-emerald-300)`,label:`Memories`}};function Ge(e){let t=e.bucketUnit??`day`,n=e.days,r=n.map(e=>e.count),i=Math.max(1,...r),a=r.some(e=>e>0);return/* @__PURE__ */ (0,G.jsxs)(x,{className:`min-h-[17rem] p-4 sm:p-5`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{children:[/* @__PURE__ */ (0,G.jsx)(E,{anchor:`activity`,className:`m-0 font-display text-xl font-medium text-dashboard-text`,title:`Activity over time`}),/* @__PURE__ */ (0,G.jsx)(`p`,{className:`mt-1 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:t===`hour`?`Memories created each hour.`:t===`6hour`?`Memories created each 6 hours.`:`Memories created each day.`})]}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`relative mt-3 overflow-hidden`,children:[/* @__PURE__ */ (0,G.jsx)(Te,{className:`aspect-auto h-50 w-full`,config:We,children:/* @__PURE__ */ (0,G.jsxs)(De,{"aria-label":`Memories learned during the last ${e.range===1?`24 hours`:`${e.range} days`}`,data:n,margin:V,role:`img`,children:[/* @__PURE__ */ (0,G.jsx)(z,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,G.jsx)(we,{maximum:i}),/* @__PURE__ */ (0,G.jsx)(Se,{keys:n.map(e=>e.date)}),/* @__PURE__ */ (0,G.jsx)(xe,{content:/* @__PURE__ */ (0,G.jsx)(B,{rows:e=>[[`memories`,e.count]]})}),/* @__PURE__ */ (0,G.jsx)(H,{dataKey:`count`,fill:`var(--color-count)`,fillOpacity:.82,isAnimationActive:!1,maxBarSize:13})]})}),a?null:/* @__PURE__ */ (0,G.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 memories were learned in this period.`})]})]})}const Ke={extraction:{color:`var(--color-cyan-300)`,label:`Extraction`},recall:{color:`var(--color-fuchsia-400)`,label:`Recall`}};function q(e){return T({total:e})}function qe(e){let t=e.bucketUnit??`day`,n=new Map(e.recallDays.map(e=>[e.date,e])),r=e.extractionDays.map(e=>{let t=n.get(e.date)??{costUsd:0,date:e.date,events:0};return{date:e.date,extraction:e,extractionCost:e.costUsd,recall:t,recallCost:t.costUsd}}),i=r.reduce((e,t)=>e+t.extraction.costUsd,0),a=r.reduce((e,t)=>e+t.recall.costUsd,0),o=i+a,s=r.reduce((e,t)=>e+t.extraction.events+t.recall.events,0),c=r.map(e=>e.extraction.costUsd+e.recall.costUsd),l=Math.max(.01,...c),u=Ee(c);return/* @__PURE__ */ (0,G.jsxs)(x,{className:`min-h-[17rem] p-4 sm:p-5`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{children:[/* @__PURE__ */ (0,G.jsx)(E,{anchor:`cost`,label:`cost`,className:`m-0 font-display text-xl font-medium text-dashboard-text`,title:T({total:o})}),/* @__PURE__ */ (0,G.jsxs)(`p`,{className:`mt-1 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:[`System-wide estimate across `,J(s),` spanning extraction and recall.`]}),/* @__PURE__ */ (0,G.jsx)(Oe,{ariaLabel:`Memory cost legend`,items:[{color:`var(--color-cyan-300)`,key:`extraction`,label:`Extraction`,value:T({total:i})},{color:`var(--color-fuchsia-400)`,key:`recall`,label:`Recall`,value:T({total:a})}]})]}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`relative mt-4 overflow-hidden`,children:[/* @__PURE__ */ (0,G.jsx)(Te,{className:`aspect-auto h-50 w-full`,config:Ke,children:/* @__PURE__ */ (0,G.jsxs)(De,{"aria-label":`Memory extraction and recall cost during the last ${e.range===1?`24 hours`:`${e.range} days`}`,data:r,margin:V,role:`img`,children:[/* @__PURE__ */ (0,G.jsx)(z,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,G.jsx)(we,{format:q,maximum:l}),/* @__PURE__ */ (0,G.jsx)(Se,{keys:r.map(e=>e.date)}),/* @__PURE__ */ (0,G.jsx)(xe,{content:/* @__PURE__ */ (0,G.jsx)(B,{rows:e=>[[`extraction`,`${q(e.extractionCost)} · ${J(e.extraction.events)}`],[`recall`,`${q(e.recallCost)} · ${J(e.recall.events)}`],[`total`,q(e.extractionCost+e.recallCost)]]})}),/* @__PURE__ */ (0,G.jsx)(H,{dataKey:`extractionCost`,fill:`var(--color-extraction)`,fillOpacity:.82,isAnimationActive:!1,maxBarSize:13,stackId:`cost`}),/* @__PURE__ */ (0,G.jsx)(H,{dataKey:`recallCost`,fill:`var(--color-recall)`,fillOpacity:.82,isAnimationActive:!1,maxBarSize:13,stackId:`cost`}),/* @__PURE__ */ (0,G.jsx)(Ce,{unit:pe(t),average:u,format:q,stroke:`var(--color-slate-200)`})]})}),s===0?/* @__PURE__ */ (0,G.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 memory extraction or recall ran in this period.`}):null]})]})}function J(e){return`${e.toLocaleString()} ${e===1?`run`:`runs`}`}const Je=r({content:o().min(1),createdAt:i(),expiresAt:i().optional(),id:o().min(1),kind:n([`preference`,`procedure`,`knowledge`]),observedAt:i(),origin:n([`automatic`,`explicit`,`other`]),sourcePlatform:n([`local`,`slack`,`web`])}).strict();function Y(e){return e.charAt(0).toUpperCase()+e.slice(1)}function X(e){return new Intl.DateTimeFormat(`en-US`,{dateStyle:`medium`,timeStyle:`short`,timeZone:`UTC`}).format(new Date(e))}function Ye(e){let t=e.origin===`automatic`?`Automatic`:e.origin===`explicit`?`Explicit`:`Other`;return{actions:[{confirmation:`Forget this memory for everyone?`,href:`/api/plugins/memory/memories/${encodeURIComponent(e.id)}`,label:`Forget`,method:`DELETE`,tone:`danger`}],id:e.id,metadata:[{label:`Type`,value:Y(e.kind)},{label:`Learned`,value:t},{label:`Source`,value:Y(e.sourcePlatform)},{label:`Remembered`,value:X(e.createdAt)},{label:`Observed`,value:X(e.observedAt)},{label:`Expires`,value:e.expiresAt?X(e.expiresAt):`Never`}],title:e.content}}function Xe(e){return u({enabled:!!e,queryFn:async({signal:t})=>Ye(await y(Je,`/api/plugins/memory/memories/${encodeURIComponent(e)}`,t)),queryKey:[`dashboard`,`plugin-user-page`,`memory`,`record`,e],retry:!1})}const Ze=`grid-cols-1 sm:grid-cols-[minmax(0,1fr)_7rem_9rem]`;function Qe(e){let[t,n]=(0,U.useState)(30),r=h(),{memoryId:i}=p(),a=`/memories`,o=`${a}/library`,s=r.pathname===a,c=r.pathname===o||!!i;return!s&&!c?/* @__PURE__ */ (0,G.jsx)(m,{replace:!0,to:a}):/* @__PURE__ */ (0,G.jsx)(ye,{children:s?/* @__PURE__ */ (0,G.jsxs)(G.Fragment,{children:[/* @__PURE__ */ (0,G.jsx)(w,{description:e.page.description,onRangeChange:n,range:t,title:e.page.label}),/* @__PURE__ */ (0,G.jsx)($e,{range:t})]}):/* @__PURE__ */ (0,G.jsx)(et,{libraryPath:o,page:e.page})})}function $e(e){let t=Fe();return t.error?/* @__PURE__ */ (0,G.jsxs)(x,{className:`flex items-center gap-3 border-rose-300/20 p-5 text-sm text-rose-200`,children:[/* @__PURE__ */ (0,G.jsx)(ie,{"aria-hidden":`true`,size:18}),`Memory history is temporarily unavailable.`]}):t.data?/* @__PURE__ */ (0,G.jsxs)(G.Fragment,{children:[/* @__PURE__ */ (0,G.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-2`,children:[/* @__PURE__ */ (0,G.jsx)(Ge,{bucketUnit:me(e.range),days:C({days:t.data.days,hours:t.data.hours,range:e.range,emptySixHour:e=>({count:0,date:e})}),range:e.range}),/* @__PURE__ */ (0,G.jsx)(qe,{bucketUnit:me(e.range),extractionDays:C({days:t.data.extractionDays,hours:t.data.extractionHours,range:e.range,emptySixHour:e=>({costUsd:0,date:e,events:0})}),range:e.range,recallDays:C({days:t.data.recallDays,hours:t.data.recallHours,range:e.range,emptySixHour:e=>({costUsd:0,date:e,events:0})})})]}),/* @__PURE__ */ (0,G.jsx)(nt,{data:t.data}),/* @__PURE__ */ (0,G.jsxs)(`section`,{className:`grid gap-4 md:grid-cols-2`,children:[/* @__PURE__ */ (0,G.jsx)(rt,{data:t.data}),/* @__PURE__ */ (0,G.jsx)(it,{data:t.data})]})]}):/* @__PURE__ */ (0,G.jsx)(S,{className:`gap-6 sm:gap-8`,label:`Loading memory history`,variant:`overview`})}function et(e){let{action:t,content:n,query:r,records:i,runAction:a,searchQuery:o,searchText:s,setSearchText:c}=je(e.page),l=ee(),u=h(),{memoryId:d}=p(),f=(0,U.useRef)(null),m=Xe(d),g=m.data??i.find(e=>e.id===d),_=e=>D(e,u.search),te=()=>{let t=d?f.current?.querySelector(`button[data-memory-id="${CSS.escape(d)}"]`):void 0;l(_(e.libraryPath)),(t??f.current)?.focus()},v=t=>{l(_(e.libraryPath)),f.current?.focus(),a(t)};(0,U.useEffect)(()=>{d&&t.reset()},[d]),(0,U.useEffect)(()=>{!d||g||m.isFetching||m.isPending||(m.isError||m.isFetched)&&l(D(e.libraryPath,u.search),{replace:!0})},[u.search,d,m.isError,m.isFetched,m.isFetching,m.isPending,l,e.libraryPath,g]);let ne=!r.data&&!r.error;return/* @__PURE__ */ (0,G.jsxs)(`div`,{className:b(`grid h-full min-h-0 min-w-0`,d&&`xl:grid-cols-[minmax(0,1fr)_25rem]`),children:[/* @__PURE__ */ (0,G.jsx)(`div`,{"aria-label":`Memories 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:f,role:`region`,tabIndex:0,children:/* @__PURE__ */ (0,G.jsxs)(he,{className:`gap-6 sm:gap-8`,children:[/* @__PURE__ */ (0,G.jsx)(w,{description:e.page.description,title:e.page.label}),/* @__PURE__ */ (0,G.jsxs)(`section`,{className:`grid gap-4`,"aria-labelledby":`memory-library-title`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-4`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{children:/* @__PURE__ */ (0,G.jsx)(`h2`,{className:`m-0 font-display text-xl font-medium tracking-[-0.02em] text-dashboard-text`,id:`memory-library-title`,children:o?`Search results`:`What Junior remembers`})}),n?.searchPlaceholder?/* @__PURE__ */ (0,G.jsx)(P,{className:`w-full max-w-md sm:w-auto`,label:n.searchPlaceholder,onChange:c,placeholder:n.searchPlaceholder,size:`default`,value:s}):null]}),ne?/* @__PURE__ */ (0,G.jsx)(S,{label:`Loading memories`,variant:`panel`}):r.error?/* @__PURE__ */ (0,G.jsxs)(x,{className:`flex items-center gap-3 border-rose-300/20 p-5 text-sm text-rose-200`,children:[/* @__PURE__ */ (0,G.jsx)(ie,{"aria-hidden":`true`,size:18}),r.error.message]}):i.length===0?/* @__PURE__ */ (0,G.jsx)(x,{className:`grid min-h-56 place-items-center p-8 text-center`,children:/* @__PURE__ */ (0,G.jsxs)(`div`,{children:[/* @__PURE__ */ (0,G.jsx)(re,{"aria-hidden":`true`,className:`mx-auto text-dashboard-text-muted`,size:26}),/* @__PURE__ */ (0,G.jsx)(`p`,{className:`mt-4 mb-0 text-sm text-dashboard-text-muted`,children:n?.emptyText??`No memories yet.`})]})}):/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`grid gap-3`,children:[/* @__PURE__ */ (0,G.jsxs)(x,{padding:`none`,children:[/* @__PURE__ */ (0,G.jsx)(tt,{}),i.map((t,n)=>/* @__PURE__ */ (0,G.jsx)(at,{first:n===0,onSelect:()=>l(_(d===t.id?e.libraryPath:`/memories/${encodeURIComponent(t.id)}`)),record:t,searchQuery:o,selected:t.id===d},t.id))]}),/* @__PURE__ */ (0,G.jsx)(L,{className:`mt-2`,hasMore:!r.isPlaceholderData&&!!r.hasNextPage,loading:r.isFetchingNextPage,onLoadMore:()=>void r.fetchNextPage()}),t.error?/* @__PURE__ */ (0,G.jsx)(R,{className:`text-center`,children:`Could not complete this action. Try again.`}):null]})]})]})}),d?/* @__PURE__ */ (0,G.jsx)(Le,{forgetPending:t.isPending,onClose:te,onForget:v,record:g},d):null]})}function tt(){return/* @__PURE__ */ (0,G.jsxs)(`div`,{className:b(`hidden items-center gap-3 border-b border-dashboard-border px-4 py-2.5 text-left font-sans font-medium text-xs text-dashboard-text-muted sm:grid`,Ze),role:`row`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{children:`Memory`}),/* @__PURE__ */ (0,G.jsx)(`div`,{children:`Type`}),/* @__PURE__ */ (0,G.jsx)(`div`,{children:`Learned`})]})}function nt(e){let{stats:t}=e.data,n=[{detail:`shared across the workspace`,label:`Total active`,tone:`text-dashboard-accent-text`,value:t.active.toLocaleString(`en-US`)},{detail:`in the last 30 days`,label:`Added · 30d`,value:`+${t.createdThirtyDays.toLocaleString(`en-US`)}`}];return/* @__PURE__ */ (0,G.jsx)(`section`,{"aria-label":`Memory summary`,className:`grid grid-cols-2 gap-px border-y border-dashboard-border-subtle bg-dashboard-fill-hover`,children:n.map(e=>/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`bg-dashboard-bg px-4 py-4 sm:px-5`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:b(`mt-2 font-display text-3xl font-light tracking-[-0.04em] text-dashboard-text`,e.tone),children:e.value}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`mt-1 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:e.detail})]},e.label))})}function rt(e){let{stats:t}=e.data;return/* @__PURE__ */ (0,G.jsxs)(x,{className:`p-5 sm:p-6`,children:[/* @__PURE__ */ (0,G.jsx)(E,{anchor:`memory-types`,className:`m-0 font-display text-xl font-medium text-dashboard-text`,title:`What Junior remembers`}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`mt-5 grid gap-px overflow-hidden rounded-md border border-dashboard-border-subtle bg-dashboard-fill-hover`,children:[/* @__PURE__ */ (0,G.jsx)(Z,{detail:`How people like to work`,icon:oe,label:`Preferences`,value:t.preference}),/* @__PURE__ */ (0,G.jsx)(Z,{detail:`How work should get done`,icon:re,label:`Procedures`,value:t.procedure}),/* @__PURE__ */ (0,G.jsx)(Z,{detail:`Facts and durable context`,icon:Ae,label:`Knowledge`,value:t.knowledge})]})]})}function it(e){let{stats:t}=e.data,n=Math.max(0,t.active-t.automatic-t.explicit);return/* @__PURE__ */ (0,G.jsxs)(x,{className:`p-5 sm:p-6`,children:[/* @__PURE__ */ (0,G.jsx)(E,{anchor:`memory-sources`,className:`m-0 font-display text-xl font-medium text-dashboard-text`,title:`How they got here`}),/* @__PURE__ */ (0,G.jsx)(`p`,{className:`mt-1 mb-0 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:`Same totals, split by how they were written.`}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`mt-5 grid gap-px overflow-hidden rounded-md border border-dashboard-border-subtle bg-dashboard-fill-hover`,children:[/* @__PURE__ */ (0,G.jsx)(Z,{detail:`Passive extraction after runs`,icon:ne,label:`Learned by Junior`,value:t.automatic}),/* @__PURE__ */ (0,G.jsx)(Z,{detail:`Someone asked to remember it`,icon:ke,label:`Saved explicitly`,value:t.explicit}),/* @__PURE__ */ (0,G.jsx)(Z,{detail:`Before origin tracking`,icon:Ae,label:`Older records`,value:n})]})]})}function Z(e){let t=e.icon;return/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex items-center gap-3 bg-dashboard-bg-elevated px-3 py-3`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`grid size-9 shrink-0 place-items-center rounded-md border border-dashboard-border bg-dashboard-fill-soft text-dashboard-text-muted`,children:/* @__PURE__ */ (0,G.jsx)(t,{"aria-hidden":`true`,size:15})}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`font-display text-base font-medium text-dashboard-text`,children:e.label}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`mt-0.5 font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:e.detail})]}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`font-display text-2xl font-light text-dashboard-text`,children:e.value.toLocaleString(`en-US`)})]})}function at(e){let t=Q(e.record,`Type`),n=Q(e.record,`Remembered`),r=Q(e.record,`Source`);return/* @__PURE__ */ (0,G.jsx)(be,{className:b(`flex items-stretch`,!e.first&&`border-t border-dashboard-border-subtle`),onSelect:e.onSelect,selected:e.selected,children:/* @__PURE__ */ (0,G.jsxs)(`button`,{"aria-expanded":e.selected,"aria-label":`View memory details: ${e.record.title}`,"data-memory-id":e.record.id,className:b(`grid min-w-0 flex-1 cursor-pointer items-center gap-3 border-0 bg-transparent px-4 py-3 text-left`,Ze),onClick:e.onSelect,type:`button`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`min-w-0 overflow-hidden`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`flex min-w-0 items-center gap-2 overflow-hidden`,children:/* @__PURE__ */ (0,G.jsx)(`h3`,{className:`m-0 truncate font-display text-base font-medium leading-snug text-dashboard-text`,children:/* @__PURE__ */ (0,G.jsx)(Ue,{query:e.searchQuery,text:e.record.title})})}),/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`mt-1.5 truncate font-sans text-xs leading-relaxed text-dashboard-text-muted`,children:[`Source: `,r,/* @__PURE__ */ (0,G.jsxs)(`span`,{className:`sm:hidden`,children:[` `,`· `,t,` · `,$(n)]})]})]}),/* @__PURE__ */ (0,G.jsx)(`span`,{className:`hidden truncate font-mono text-xs text-dashboard-text-muted sm:block`,children:t}),/* @__PURE__ */ (0,G.jsx)(`span`,{className:`hidden truncate font-mono text-xs text-dashboard-text sm:block`,children:$(n)})]})})}function Q(e,t){return e.metadata?.find(e=>e.label===t)?.value??`—`}function $(e){return e.split(`,`).slice(0,2).join(`,`)}function ot(e){let t=e.pages.find(e=>e.pluginName===`memory`&&e.id===`memories`);return t?/* @__PURE__ */ (0,G.jsx)(Qe,{page:t}):/* @__PURE__ */ (0,G.jsx)(m,{replace:!0,to:`/`})}function st(e){let t=h(),{"*":n,pageId:r,pluginName:i}=p(),a=e.pages.find(e=>e.pluginName===i&&e.id===r);if(!a)return/* @__PURE__ */ (0,G.jsx)(m,{replace:!0,to:`/`});if(a.pluginName===`memory`&&a.id===`memories`){let e=n?`/${n}`:``;return/* @__PURE__ */ (0,G.jsx)(m,{replace:!0,to:D(`/memories${e}`,t.search)})}return/* @__PURE__ */ (0,G.jsx)(ct,{page:a})}function ct(e){let{action:t,content:n,query:r,records:i,runAction:a,searchText:o,setSearchText:s}=je(e.page),[c,l]=(0,U.useState)(),[u,d]=(0,U.useState)(!1);return!r.data&&!r.error?/* @__PURE__ */ (0,G.jsx)(_e,{label:`Loading ${e.page.label}`}):/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`${fe} px-4 py-8 md:px-8`,children:[/* @__PURE__ */ (0,G.jsxs)(`section`,{className:`mx-auto grid w-full max-w-3xl gap-6`,children:[/* @__PURE__ */ (0,G.jsx)(w,{description:e.page.description,title:e.page.label}),n?.metrics?.length?/* @__PURE__ */ (0,G.jsx)(`section`,{"aria-label":`${e.page.label} overview`,className:`grid gap-3 sm:grid-cols-2`,children:n.metrics.map(e=>/* @__PURE__ */ (0,G.jsxs)(x,{className:`p-4`,children:[/* @__PURE__ */ (0,G.jsx)(`div`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,G.jsx)(`div`,{className:`mt-3 font-display text-2xl font-light text-dashboard-text`,children:e.value}),e.detail?/* @__PURE__ */ (0,G.jsx)(`div`,{className:`mt-1 font-mono text-xs text-dashboard-text-muted`,children:e.detail}):null]},e.label))}):null,n?.searchPlaceholder?/* @__PURE__ */ (0,G.jsx)(P,{className:`w-full`,label:n.searchPlaceholder,onChange:s,placeholder:n.searchPlaceholder,size:`default`,value:o}):null,r.error?/* @__PURE__ */ (0,G.jsx)(x,{padding:`md`,children:/* @__PURE__ */ (0,G.jsxs)(R,{children:[`Could not load `,e.page.label.toLowerCase(),`. Try again.`]})}):i.length===0?/* @__PURE__ */ (0,G.jsx)(x,{padding:`md`,children:/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex items-center gap-4`,children:[/* @__PURE__ */ (0,G.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:/* @__PURE__ */ (0,G.jsx)(te,{"aria-hidden":`true`,size:17})}),/* @__PURE__ */ (0,G.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,children:n?.emptyText??`No ${e.page.label.toLowerCase()}.`})]})}):/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`grid gap-3`,children:[i.map(e=>/* @__PURE__ */ (0,G.jsxs)(x,{padding:`md`,children:[/* @__PURE__ */ (0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[/* @__PURE__ */ (0,G.jsx)(`h2`,{className:`m-0 min-w-0 flex-1 font-display text-base font-medium text-dashboard-text`,children:e.title}),e.actions?.map(n=>n.method===`GET`?/* @__PURE__ */ (0,G.jsx)(`a`,{className:`shrink-0 rounded-md border border-dashboard-border-strong px-3 py-1.5 text-sm font-semibold text-dashboard-text no-underline transition-colors hover:bg-dashboard-fill-strong`,href:n.href,children:n.label},`${n.method}:${n.href}`):/* @__PURE__ */ (0,G.jsx)(`button`,{"aria-label":`${n.label}: ${e.title}`,className:`cursor-pointer border-0 bg-transparent p-1 text-dashboard-text-muted transition-colors ${n.tone===`danger`?`hover:text-rose-300`:`hover:text-dashboard-text`}`,disabled:t.isPending,onClick:()=>{n.confirmation?(l({action:n,record:e}),d(!0)):a(n)},title:n.label,type:`button`,children:n.tone===`danger`?/* @__PURE__ */ (0,G.jsx)(ae,{"aria-hidden":`true`,size:16}):n.label},`${n.method}:${n.href}`))]}),e.description?/* @__PURE__ */ (0,G.jsx)(`p`,{className:`mt-2 mb-0 text-sm text-dashboard-text-muted`,children:e.description}):null,e.metadata?.length?/* @__PURE__ */ (0,G.jsx)(`dl`,{className:`mt-4 flex flex-wrap gap-x-6 gap-y-2`,children:e.metadata.map(e=>/* @__PURE__ */ (0,G.jsxs)(`div`,{children:[/* @__PURE__ */ (0,G.jsx)(`dt`,{className:`font-sans font-medium text-xs text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,G.jsx)(`dd`,{className:`mt-1 ml-0 font-mono text-xs text-dashboard-text-muted`,children:e.value})]},e.label))}):null]},e.id)),/* @__PURE__ */ (0,G.jsx)(L,{hasMore:!r.isPlaceholderData&&!!r.hasNextPage,loading:r.isFetchingNextPage,onLoadMore:()=>void r.fetchNextPage()}),t.error?/* @__PURE__ */ (0,G.jsx)(R,{className:`text-center`,children:`Could not complete this action. Try again.`}):null]})]}),/* @__PURE__ */ (0,G.jsx)(I,{onOpenChange:d,open:u,children:/* @__PURE__ */ (0,G.jsxs)(A,{children:[/* @__PURE__ */ (0,G.jsx)(k,{children:c?.action.confirmation}),/* @__PURE__ */ (0,G.jsx)(j,{children:c?.record.title}),/* @__PURE__ */ (0,G.jsxs)(M,{children:[/* @__PURE__ */ (0,G.jsx)(F,{children:`Cancel`}),/* @__PURE__ */ (0,G.jsx)(O,{onClick:()=>{c&&a(c.action),d(!1)},variant:c?.action.tone===`danger`?`danger`:`primary`,children:c?.action.label})]})]})})]})}export{ot as MemoryPermalinkRoute,st as PluginUserPageRoute};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{C as t,S as n,_ as r,r as i}from"./vendor-react-ggbyvons.js";import{n as a}from"./button-loz3etho.js";import{qt as o}from"./vendor-icons-mxz7yi04.js";import{n as s,t as c}from"./CodeChangeRow-enn40527.js";import{a as l,t as u}from"./styles-j0007fov.js";import{t as d}from"./Card-hy4bfgq7.js";import{n as f,r as p,s as m,t as h}from"./PageHeader-kvp1fo95.js";import{H as g,T as _,U as v,a as ee,j as y,r as b,y as x}from"./format-c4b0iyrx.js";import{t as S}from"./SecondaryNavigation-m358iuko.js";import{t as C}from"./PageLayout-l6dhbimv.js";import{Dt as w,Et as T,J as E,Tt as D,W as O,Xt as k,Y as te,Yt as A,Z as j,_ as M,ft as N,g as P,h as F,p as I,pt as L,u as R,wt as z,xt as B}from"../client-mgf2bxi7.js";import{r as V}from"./FilterBar-lsllb7tj.js";import{t as H}from"./CodeSummaryCards-d2oxdoq1.js";import{n as U,t as W}from"./SectionTitle-drw3mqtl.js";var G=/* @__PURE__ */ e(t(),1),K=n();function q(e){return/* @__PURE__ */ (0,K.jsxs)(d,{as:`section`,className:`mb-0`,variant:`section`,children:[/* @__PURE__ */ (0,K.jsx)(U,{actions:e.viewAllTo?/* @__PURE__ */ (0,K.jsx)(i,{className:`text-sm text-dashboard-text underline underline-offset-2`,to:e.viewAllTo,children:`View all`}):void 0,children:/* @__PURE__ */ (0,K.jsx)(W,{children:e.title})}),e.children]})}function J(e){let t=e.conversation,n=ee(t),r=y(t,{includeId:!1}),a=!!t.sidebarAnnotations?.length;return/* @__PURE__ */ (0,K.jsxs)(`div`,{className:`relative min-w-0 border-b border-dashboard-border-subtle px-4 py-3 transition-colors last:border-b-0 hover:bg-dashboard-fill-soft`,children:[/* @__PURE__ */ (0,K.jsx)(i,{"aria-label":`Open ${n}`,className:`absolute inset-0 z-0 focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-dashboard-focus`,to:D(t.id)}),/* @__PURE__ */ (0,K.jsxs)(`div`,{className:`pointer-events-none relative z-[1] grid min-w-0 grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-x-2`,children:[/* @__PURE__ */ (0,K.jsx)(`span`,{className:`mt-1.5 grid size-3 shrink-0 place-items-center`,children:/* @__PURE__ */ (0,K.jsx)(te,{unread:!1,isPrivate:t.visibility===`private`,status:g(t),waitingOnViewer:!1})}),/* @__PURE__ */ (0,K.jsx)(`div`,{className:`min-w-0 truncate font-display text-sm text-dashboard-text`,children:n}),/* @__PURE__ */ (0,K.jsx)(`span`,{className:`whitespace-nowrap font-mono text-xs text-dashboard-text-muted`,children:x(t.lastSeenAt)}),/* @__PURE__ */ (0,K.jsx)(`div`,{className:`col-start-2 col-end-4 mt-1 flex h-4 min-w-0 items-center gap-1.5 font-mono text-xs text-dashboard-text-muted`,children:a?/* @__PURE__ */ (0,K.jsx)(O,{annotations:t.sidebarAnnotations}):r?/* @__PURE__ */ (0,K.jsx)(`span`,{className:`truncate`,children:r}):null})]})]})}function Y(e,t){return p({days:e.activityDays,hours:e.activityHours,sixHours:e.activitySixHours,range:t,emptySixHour:e=>({closed:0,created:0,date:e,merged:0})})}function X(e){let[t,n]=(0,G.useState)(``),[r,i]=(0,G.useState)(1),a=z(t.trim()),o=A(e.repositoryId,a),s=b(o.data?.conversations??[]),c=B();return(0,G.useEffect)(()=>{i(1)},[a]),/* @__PURE__ */ (0,K.jsxs)(`section`,{"aria-label":`Conversations`,className:`grid gap-3`,children:[/* @__PURE__ */ (0,K.jsx)(N,{className:`w-full sm:ml-auto sm:w-72`,label:`Search conversations in this repository`,onChange:n,placeholder:`Search conversations…`,value:t}),o.error?/* @__PURE__ */ (0,K.jsx)(L,{children:`Conversations are unavailable. Try refreshing the dashboard.`}):/* @__PURE__ */ (0,K.jsx)(E,{conversations:M(w(s,T(s,c)),r,25),emptyLabel:a?`No conversations match this search.`:`No conversations are linked to this repository yet.`,loading:!o.data,timeZone:_(),waitingConversationIds:c}),/* @__PURE__ */ (0,K.jsx)(F,{className:`pt-1`,onPageChange:i,page:r,pageCount:P(s.length,25),pageSize:25,total:s.length})]})}function Z(e){let[t,n]=(0,G.useState)(``),[r,i]=(0,G.useState)(``),[a,o]=(0,G.useState)(1),l=e.data.changes,u=r.trim().toLowerCase(),f=l.filter(e=>(!t||e.state===t)&&(!u||e.title?.toLowerCase().includes(u)||`#${e.number}`.includes(u))),p=e=>l.filter(t=>t.state===e).length;return(0,G.useEffect)(()=>{o(1)},[t,u]),/* @__PURE__ */ (0,K.jsxs)(K.Fragment,{children:[/* @__PURE__ */ (0,K.jsx)(s,{bucketUnit:m(e.range),days:Y(e.data,e.range),range:e.range}),/* @__PURE__ */ (0,K.jsxs)(`section`,{"aria-label":`Changes`,className:`grid gap-4`,children:[/* @__PURE__ */ (0,K.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-4`,children:[/* @__PURE__ */ (0,K.jsx)(V,{ariaLabel:`Change state`,items:[{count:l.length,label:`All`,value:``},{count:p(`open`),label:`Open`,value:`open`},{count:p(`merged`),label:`Merged`,value:`merged`},{count:p(`closed`),label:`Closed`,value:`closed`}],onChange:n,value:t}),/* @__PURE__ */ (0,K.jsx)(N,{className:`w-full max-w-md sm:w-auto`,label:`Search changes`,onChange:i,placeholder:`Title or number`,value:r})]}),/* @__PURE__ */ (0,K.jsx)(d,{children:f.length===0?/* @__PURE__ */ (0,K.jsx)(`div`,{className:`p-4`,children:/* @__PURE__ */ (0,K.jsx)(L,{children:`No changes match these filters.`})}):M(f,a,25).map(e=>/* @__PURE__ */ (0,K.jsx)(c,{change:e},e.id))}),/* @__PURE__ */ (0,K.jsx)(F,{onPageChange:o,page:a,pageCount:P(f.length,25),pageSize:25,total:f.length})]})]})}const Q=`Conversations and code changes from Junior.`,ne=u(`font-semibold`,l);function re(e){let t=r().repositoryId,[n,i]=(0,G.useState)(30),o=k(t);if(!o.data&&!o.error)return/* @__PURE__ */ (0,K.jsx)(R,{description:Q,label:`Loading repository`,title:`Repository`,variant:`stats`});let s=o.data;if(!s)return/* @__PURE__ */ (0,K.jsxs)(C,{children:[/* @__PURE__ */ (0,K.jsx)($,{}),/* @__PURE__ */ (0,K.jsx)(L,{children:`This repository is unavailable. It may not have any code changes from Junior.`})]});let c=s.repository;return/* @__PURE__ */ (0,K.jsx)(S,{ariaLabel:`Repository navigation`,items:[{end:!0,label:`Overview`,to:I(c.id)},{label:`Conversations`,to:I(c.id,`conversations`)},{label:`Changes`,to:I(c.id,`changes`)}],children:/* @__PURE__ */ (0,K.jsxs)(C,{children:[/* @__PURE__ */ (0,K.jsx)($,{}),/* @__PURE__ */ (0,K.jsx)(h,{actions:/* @__PURE__ */ (0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[/* @__PURE__ */ (0,K.jsx)(f,{onChange:i,value:n}),c.url?/* @__PURE__ */ (0,K.jsx)(j,{className:a(),href:c.url,children:`Open repository`}):null]}),description:/* @__PURE__ */ (0,K.jsx)(ie,{data:s}),documentTitle:e.tab===`overview`?c.name:`${c.name} · ${e.tab===`changes`?`Changes`:`Conversations`}`,title:c.name}),e.tab===`overview`?/* @__PURE__ */ (0,K.jsx)(ae,{data:s,range:n}):null,e.tab===`conversations`?/* @__PURE__ */ (0,K.jsx)(X,{repositoryId:c.id}):null,e.tab===`changes`?/* @__PURE__ */ (0,K.jsx)(Z,{data:s,range:n}):null]})})}function $(){return/* @__PURE__ */ (0,K.jsxs)(i,{className:`flex w-fit items-center gap-2 font-display text-sm font-medium text-dashboard-text-muted no-underline transition-colors hover:text-dashboard-text`,to:`/code`,children:[/* @__PURE__ */ (0,K.jsx)(o,{"aria-hidden":`true`,size:15,strokeWidth:1.8}),`Back to code`]})}function ie(e){let t=e.data.workspaces;return t.length===0?Q:/* @__PURE__ */ (0,K.jsxs)(K.Fragment,{children:[Q,` / Workspaces`,` `,t.map((e,t)=>/* @__PURE__ */ (0,K.jsxs)(`span`,{children:[t>0?`, `:null,/* @__PURE__ */ (0,K.jsx)(i,{className:ne,to:v(e.id),children:e.name})]},e.id))]})}function ae(e){let t=e.data,n=A(t.repository.id),r=b(n.data?.conversations??[]).slice(0,5),i=t.changes.slice(0,5);return/* @__PURE__ */ (0,K.jsxs)(K.Fragment,{children:[/* @__PURE__ */ (0,K.jsx)(H,{summary:t.summary}),/* @__PURE__ */ (0,K.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[/* @__PURE__ */ (0,K.jsx)(q,{title:`Recent conversations`,viewAllTo:I(t.repository.id,`conversations`),children:r.length>0?r.map(e=>/* @__PURE__ */ (0,K.jsx)(J,{conversation:e},e.id)):/* @__PURE__ */ (0,K.jsx)(`div`,{className:`p-4`,children:/* @__PURE__ */ (0,K.jsx)(L,{children:n.error?`Conversations are unavailable. Try refreshing the dashboard.`:n.data?`No conversations are linked to this repository yet.`:`Loading conversations…`})})}),/* @__PURE__ */ (0,K.jsx)(q,{title:`Recent changes`,viewAllTo:I(t.repository.id,`changes`),children:i.length>0?i.map(e=>/* @__PURE__ */ (0,K.jsx)(c,{change:e},e.id)):/* @__PURE__ */ (0,K.jsx)(`div`,{className:`p-4`,children:/* @__PURE__ */ (0,K.jsx)(L,{children:`No code changes are recorded yet.`})})})]}),/* @__PURE__ */ (0,K.jsx)(s,{bucketUnit:m(e.range),days:Y(t,e.range),range:e.range})]})}export{re as RepositoryPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{ot as t,pt as n,ut as r}from"./vendor-lthmb2su.js";import{C as i,S as a}from"./vendor-react-ggbyvons.js";import{t as o}from"./button-loz3etho.js";import{E as s,Ot as c,lt as l,mt as u}from"./junior-gfsokzu9.js";import{r as d}from"./schema-m4v0mjyv.js";import{a as f,i as p,n as m,s as h,t as g}from"./http-cdq677qt.js";import{t as _}from"./Card-hy4bfgq7.js";import{t as v}from"./skeleton-h6p83ux1.js";import{d as y,u as ee}from"./PageHeader-kvp1fo95.js";import{t as b}from"./AnchorHeading-cp3vx8qa.js";import{C as x,D as S,E as te,G as ne,I as C,K as w,L as T,Nt as E,O as D,Pt as O,R as k,S as A,T as j,_t as M,b as re,bt as N,d as ie,gt as P,mt as F,q as I,v as L,w as R,x as z,y as B,yt as V}from"../client-mgf2bxi7.js";import{t as H}from"./native-select-jfknh8t4.js";var U=/* @__PURE__ */ e(i(),1),W=a();const G=z.queryKey,K=[[1,`Mon`],[2,`Tue`],[3,`Wed`],[4,`Thu`],[5,`Fri`],[6,`Sat`],[0,`Sun`]],q={default:`Junior default`,saved:`from your profile`,slack:`from Slack`};function J(){try{return Intl.supportedValuesOf(`timeZone`)}catch{return[]}}function Y(){let e=r(z);return/* @__PURE__ */ (0,W.jsxs)(_,{className:`mt-6 mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(b,{anchor:re,className:`m-0 text-lg font-bold`,title:`Push notifications`}),/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-2 mb-0 text-sm text-dashboard-text-muted`,children:`Get a notification when Junior replies to a conversation you started here. Slack threads keep using Slack notifications.`}),e.isPending?/* @__PURE__ */ (0,W.jsx)(ae,{}):e.isError?/* @__PURE__ */ (0,W.jsx)(I,{className:`mt-5`,children:`Could not load notification settings. Reload the page to try again.`}):/* @__PURE__ */ (0,W.jsxs)(W.Fragment,{children:[/* @__PURE__ */ (0,W.jsx)(oe,{settings:e.data}),/* @__PURE__ */ (0,W.jsx)(se,{settings:e.data})]})]})}function ae(){return/* @__PURE__ */ (0,W.jsxs)(`div`,{"aria-label":`Loading notification settings`,className:`mt-5 grid gap-3`,role:`status`,children:[/* @__PURE__ */ (0,W.jsx)(v,{className:`h-10 w-48`}),/* @__PURE__ */ (0,W.jsx)(v,{className:`h-24 w-full`})]})}function oe({settings:e}){let i=n(),a=(0,U.useMemo)(()=>te(),[]),c=r({enabled:a===`supported`,queryKey:A,queryFn:async()=>(await j())?.endpoint??null}),l=a===`supported`&&!!e.publicKey;(0,U.useEffect)(()=>{l&&S()?.catch(()=>void 0)},[l]);let u=e=>i.setQueryData(G,e),d=t({mutationFn:e=>R(i,e)}),f=t({mutationFn:async()=>{let e=await D();return e?await m(s,`${B}/subscriptions`,{endpoint:e}):void 0},onSuccess:e=>{e&&u(e),i.invalidateQueries({queryKey:A})}}),p=t({mutationFn:x});if(!e.publicKey)return/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-5 mb-0 text-sm text-dashboard-text-muted`,children:`Push notifications are not set up for this Junior install. Ask a Junior admin to add Web Push keys.`});if(a===`needs-install`)return/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-5 mb-0 text-sm text-dashboard-text-muted`,children:`On iPhone and iPad, add Junior to your Home Screen first. Tap Share, then Add to Home Screen. Open Junior from the Home Screen and come back to this page.`});if(a===`unsupported`)return/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-5 mb-0 text-sm text-dashboard-text-muted`,children:`This browser cannot receive notifications.`});let h=typeof Notification<`u`&&Notification.permission===`denied`,g=!!c.data,_=e.publicKey;return/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-5`,children:[/* @__PURE__ */ (0,W.jsx)(`div`,{className:`flex flex-wrap items-center gap-3`,children:g?/* @__PURE__ */ (0,W.jsxs)(W.Fragment,{children:[/* @__PURE__ */ (0,W.jsx)(o,{disabled:f.isPending,onClick:()=>f.mutate(),type:`button`,children:f.isPending?`Turning off…`:`Turn off on this device`}),/* @__PURE__ */ (0,W.jsx)(o,{disabled:p.isPending,onClick:()=>p.mutate(),type:`button`,children:p.isPending?`Sending…`:`Send a test`})]}):/* @__PURE__ */ (0,W.jsx)(o,{disabled:d.isPending||c.isPending||h,onClick:()=>d.mutate(_),type:`button`,variant:`primary`,children:d.isPending?`Turning on…`:`Turn on for this device`})}),/* @__PURE__ */ (0,W.jsxs)(`p`,{className:`mt-3 mb-0 text-sm text-dashboard-text-muted`,children:[e.deviceCount===1?`1 device gets your notifications.`:`${e.deviceCount} devices get your notifications.`,h?` This browser blocks notifications from Junior. Allow them in the browser settings.`:``]}),p.isSuccess?/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-2 mb-0 text-sm text-emerald-300`,children:p.data.delivered>0?`Test sent.`:`No device got the test. Turn notifications off and on again.`}):null,d.isError||f.isError||p.isError?/* @__PURE__ */ (0,W.jsx)(I,{className:`mt-2`,children:`Could not change notifications on this device. Try again.`}):null]})}function se({settings:e}){let r=n(),[i,a]=(0,U.useState)(e.schedule);(0,U.useEffect)(()=>a(e.schedule),[e.schedule]);let l=(0,U.useMemo)(()=>J(),[]),u=t({mutationFn:e=>h(s,`${B}/schedule`,e),onSuccess:e=>r.setQueryData(G,e)}),d=e=>{a(t=>({...t,...e})),(u.isSuccess||u.isError)&&u.reset()},f=JSON.stringify(i)!==JSON.stringify(e.schedule),p=i.start!==i.end&&(!i.workingHoursOnly||i.days.length>0),m=i.timezone??e.timezone,g=i.followSlack!==!1,_=g&&e.slackPausedNow!==void 0?!e.slackPausedNow:c(i,m,Date.now());function v(e){e.preventDefault(),f&&p&&u.mutate(i)}return/* @__PURE__ */ (0,W.jsxs)(`form`,{className:`mt-6 border-t border-dashboard-border pt-5`,onSubmit:v,children:[/* @__PURE__ */ (0,W.jsx)(`h3`,{className:`m-0 text-base font-bold`,children:`Working hours`}),/* @__PURE__ */ (0,W.jsxs)(`label`,{className:`mt-4 flex items-center gap-3 text-sm`,children:[/* @__PURE__ */ (0,W.jsx)(k,{checked:g,onCheckedChange:e=>d({followSlack:e===!0})}),`Follow my Slack notification schedule`]}),g?/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-2 mb-0 text-sm text-dashboard-text-muted`,children:e.slackPausedNow===void 0?`Junior cannot read your Slack notification schedule, so it uses the hours below.`:`Junior pauses notifications when Slack does. It uses the hours below only when it cannot read Slack.`}):null,/* @__PURE__ */ (0,W.jsxs)(`label`,{className:`mt-4 flex items-center gap-3 text-sm`,children:[/* @__PURE__ */ (0,W.jsx)(k,{checked:i.workingHoursOnly,onCheckedChange:e=>d({workingHoursOnly:e===!0})}),`Only notify me during working hours`]}),/* @__PURE__ */ (0,W.jsxs)(`fieldset`,{className:`m-0 mt-4 border-0 p-0 disabled:opacity-60`,disabled:!i.workingHoursOnly,children:[/* @__PURE__ */ (0,W.jsx)(`legend`,{className:`mb-2 p-0 text-sm font-medium`,children:`Days`}),/* @__PURE__ */ (0,W.jsx)(ee,{"aria-label":`Working days`,className:`flex-wrap gap-2`,multiple:!0,onValueChange:e=>d({days:e.map(Number).sort((e,t)=>e-t)}),value:i.days.map(String),children:K.map(([e,t])=>/* @__PURE__ */ (0,W.jsx)(y,{className:`min-h-11 min-w-12 lg:min-h-9`,value:String(e),variant:`pill`,children:t},e))}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-3 sm:max-w-sm`,children:[/* @__PURE__ */ (0,W.jsxs)(P,{children:[/* @__PURE__ */ (0,W.jsx)(V,{htmlFor:`notification-start`,children:`Start`}),/* @__PURE__ */ (0,W.jsx)(N,{id:`notification-start`,onChange:e=>d({start:e.target.value}),required:!0,step:900,type:`time`,value:i.start})]}),/* @__PURE__ */ (0,W.jsxs)(P,{children:[/* @__PURE__ */ (0,W.jsx)(V,{htmlFor:`notification-end`,children:`End`}),/* @__PURE__ */ (0,W.jsx)(N,{id:`notification-end`,onChange:e=>d({end:e.target.value}),required:!0,step:900,type:`time`,value:i.end})]})]})]}),/* @__PURE__ */ (0,W.jsxs)(P,{className:`mt-4 sm:max-w-sm`,children:[/* @__PURE__ */ (0,W.jsx)(V,{htmlFor:`notification-timezone`,children:`Timezone`}),/* @__PURE__ */ (0,W.jsxs)(H,{id:`notification-timezone`,onChange:e=>d({timezone:e.target.value||void 0}),value:i.timezone??``,children:[/* @__PURE__ */ (0,W.jsx)(`option`,{value:``,children:e.timezoneSource===`manual`?`Automatic`:`Automatic: ${e.timezone} (${q[e.timezoneSource]})`}),l.map(e=>/* @__PURE__ */ (0,W.jsx)(`option`,{value:e,children:e},e))]}),/* @__PURE__ */ (0,W.jsx)(M,{children:`Automatic uses your Slack timezone when Junior can read it.`})]}),/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-4 mb-0 text-sm text-dashboard-text-muted`,children:_?`Notifications are on right now.`:`Notifications are paused right now. Replies still show here.`}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-5 flex items-center gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(o,{disabled:!f||!p||u.isPending,type:`submit`,children:u.isPending?`Saving…`:`Save hours`}),u.isSuccess?/* @__PURE__ */ (0,W.jsx)(`p`,{className:`m-0 text-sm text-emerald-300`,children:`Hours saved.`}):null,u.isError?/* @__PURE__ */ (0,W.jsx)(I,{children:`Could not save your hours. Try again.`}):null]})]})}const ce=[`dashboard`,`core`],X=[1,6,24,72,168];function le(e){return e===0?`No done conversations to archive.`:e===1?`Archived 1 conversation.`:`Archived ${e} conversations.`}function ue(e){if(e%24!=0)return e===1?`1 hour`:`${e} hours`;let t=e/24;return t===7?`1 week`:t===1?`1 day`:`${t} days`}function de({identity:e}){let r=n(),i=t({mutationFn:e=>f(d,`/api/me`,e),onSuccess:e=>{r.setQueryData(ce,t=>t&&{...t,me:e})}}),a=L(),s=e.autoArchiveDefault??!1,c=e.autoArchiveGraceHours??24,l=X.includes(c)?X:[...X,c].sort((e,t)=>e-t);return/* @__PURE__ */ (0,W.jsxs)(_,{className:`mt-6 mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(b,{anchor:`conversations`,className:`m-0 text-lg font-bold`,title:`Conversations`}),/* @__PURE__ */ (0,W.jsxs)(`label`,{className:`mt-4 flex cursor-pointer items-start gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(k,{checked:s,className:`mt-0.5`,disabled:i.isPending,onCheckedChange:e=>i.mutate({autoArchiveDefault:e})}),/* @__PURE__ */ (0,W.jsxs)(`span`,{className:`grid gap-0.5`,children:[/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-sm font-medium`,children:`Auto-archive conversations when done`}),/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-xs text-dashboard-text-muted`,children:`Archive a conversation for everyone when all of its linked work, such as pull requests, is merged or closed and nobody replies during the wait time. You can change this for each conversation in its details.`})]})]}),/* @__PURE__ */ (0,W.jsxs)(P,{className:`mt-5 max-w-xs`,children:[/* @__PURE__ */ (0,W.jsx)(V,{htmlFor:`auto-archive-grace`,children:`Wait time`}),/* @__PURE__ */ (0,W.jsx)(H,{"aria-describedby":`auto-archive-grace-help`,disabled:i.isPending,id:`auto-archive-grace`,onChange:e=>i.mutate({autoArchiveGraceHours:Number(e.target.value)}),value:c,children:l.map(e=>/* @__PURE__ */ (0,W.jsx)(`option`,{value:e,children:ue(e)},e))}),/* @__PURE__ */ (0,W.jsx)(M,{id:`auto-archive-grace-help`,children:`How long finished work and the conversation stay quiet before archive.`})]}),i.isError?/* @__PURE__ */ (0,W.jsx)(I,{className:`mt-3`,children:`Could not save this setting. Try again.`}):null,/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-5 grid gap-1.5`,children:[/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(o,{disabled:a.isPending,onClick:()=>a.mutate(),type:`button`,children:a.isPending?`Archiving…`:`Archive done now`}),a.isSuccess?/* @__PURE__ */ (0,W.jsx)(`p`,{className:`m-0 text-sm text-dashboard-text-muted`,role:`status`,children:le(a.data.archived)}):null,a.isError?/* @__PURE__ */ (0,W.jsx)(I,{children:`Could not archive conversations. Try again.`}):null]}),/* @__PURE__ */ (0,W.jsx)(`p`,{className:`m-0 text-xs text-dashboard-text-muted`,children:`Archive every done conversation once, after the same wait time. Skips conversations where you turned auto-archive off.`})]})]})}const fe=[`dashboard`,`core`],Z=[`dashboard`,`user-customization`],Q=`/api/user-customization`;function pe({identity:e}){let r=n(),[i,a]=(0,U.useState)(e.user.name??``);(0,U.useEffect)(()=>{a(e.user.name??``)},[e.user.name]);let s=t({mutationFn:e=>f(d,`/api/me`,{displayName:e}),onSuccess:e=>{r.setQueryData(fe,t=>t&&{...t,me:e}),a(e.user.name??``)}}),c=e.user.name?.trim()??``,l=i.trim(),u=l.length>0&&l.length<=80&&l!==c&&!s.isPending;function p(e){e.preventDefault(),u&&s.mutate(l)}return/* @__PURE__ */ (0,W.jsxs)(ie,{description:`Manage your profile and preferences.`,title:`General`,children:[/* @__PURE__ */ (0,W.jsx)(`form`,{onSubmit:p,children:/* @__PURE__ */ (0,W.jsxs)(_,{className:`mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(b,{anchor:`profile`,className:`m-0 text-lg font-bold`,title:`Profile`}),/* @__PURE__ */ (0,W.jsxs)(P,{className:`mt-5`,children:[/* @__PURE__ */ (0,W.jsx)(V,{htmlFor:`display-name`,children:`Display name`}),/* @__PURE__ */ (0,W.jsx)(N,{autoComplete:`name`,id:`display-name`,maxLength:80,onChange:e=>{a(e.target.value),(s.isError||s.isSuccess)&&s.reset()},value:i}),/* @__PURE__ */ (0,W.jsx)(M,{id:`display-name-help`,children:`Your display name is shown with your conversations and activity.`})]}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-5 flex items-center gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(o,{disabled:!u,type:`submit`,children:s.isPending?`Saving…`:`Save changes`}),s.isSuccess?/* @__PURE__ */ (0,W.jsx)(`p`,{className:`m-0 text-sm text-emerald-300`,children:`Changes saved.`}):null,s.isError?/* @__PURE__ */ (0,W.jsx)(I,{children:`Could not save your display name. Try again.`}):null]})]})}),/* @__PURE__ */ (0,W.jsx)($,{}),/* @__PURE__ */ (0,W.jsx)(he,{}),/* @__PURE__ */ (0,W.jsx)(ge,{}),/* @__PURE__ */ (0,W.jsx)(de,{identity:e}),/* @__PURE__ */ (0,W.jsx)(Y,{}),/* @__PURE__ */ (0,W.jsx)(_e,{})]})}function $(){let[e,t]=O();return/* @__PURE__ */ (0,W.jsxs)(_,{className:`mt-6 mb-0 hidden md:block`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(b,{anchor:`navigation`,className:`m-0 text-lg font-bold`,title:`Navigation`}),/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-1 mb-4 text-sm text-dashboard-text-muted`,children:`This choice applies to this browser.`}),/* @__PURE__ */ (0,W.jsx)(C,{"aria-label":`Navigation`,className:`grid gap-3`,onValueChange:t,value:e,children:E.map(e=>/* @__PURE__ */ (0,W.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(T,{className:`mt-0.5`,value:e.value}),/* @__PURE__ */ (0,W.jsxs)(`span`,{className:`grid gap-0.5`,children:[/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-sm font-medium`,children:e.label}),/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-xs text-dashboard-text-muted`,children:e.description})]})]},e.value))})]})}const me=[{description:`Open at the first new message, below a “New” line.`,label:`Where I left off`,value:`unread`},{description:`Always open at the newest message.`,label:`Latest message`,value:`latest`}];function he(){let[e,t]=F();return/* @__PURE__ */ (0,W.jsxs)(_,{className:`mt-6 mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(b,{anchor:`open-conversations-at`,className:`m-0 text-lg font-bold`,title:`Open conversations at`}),/* @__PURE__ */ (0,W.jsx)(`p`,{className:`mt-1 mb-4 text-sm text-dashboard-text-muted`,children:`Junior keeps your place in each conversation on all your devices. This choice applies to this browser.`}),/* @__PURE__ */ (0,W.jsx)(C,{"aria-label":`Open conversations at`,className:`grid gap-3`,onValueChange:t,value:e,children:me.map(e=>/* @__PURE__ */ (0,W.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(T,{className:`mt-0.5`,value:e.value}),/* @__PURE__ */ (0,W.jsxs)(`span`,{className:`grid gap-0.5`,children:[/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-sm font-medium`,children:e.label}),/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-xs text-dashboard-text-muted`,children:e.description})]})]},e.value))})]})}function ge(){let[e,t]=ne();return/* @__PURE__ */ (0,W.jsxs)(_,{className:`mt-6 mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(b,{anchor:`message-box`,className:`m-0 text-lg font-bold`,title:`Message box`}),/* @__PURE__ */ (0,W.jsxs)(`label`,{className:`mt-4 flex cursor-pointer items-start gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(k,{checked:e,className:`mt-0.5`,onCheckedChange:t}),/* @__PURE__ */ (0,W.jsxs)(`span`,{className:`grid gap-0.5`,children:[/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-sm font-medium`,children:`Autocorrect`}),/* @__PURE__ */ (0,W.jsx)(`span`,{className:`text-xs text-dashboard-text-muted`,children:`Let your keyboard correct spelling and capitalize sentences as you type. This can change ids, paths, and code. This choice applies to this browser.`})]})]})]})}function _e(){let e=n(),[i,a]=(0,U.useState)(``),s=r({queryKey:Z,queryFn:({signal:e})=>p(u,Q,e),retry:!1}),c=s.data?.customization;(0,U.useEffect)(()=>{c!==void 0&&a(c)},[c]);let d=t({mutationFn:e=>h(u,Q,{customization:e}),onSuccess:t=>{e.setQueryData(Z,t)}});if(s.error instanceof g&&s.error.status===404)return null;if(c===void 0)return s.isError?/* @__PURE__ */ (0,W.jsx)(I,{children:`Could not load your customization.`}):null;let f=i.trim()!==c&&i.trim().length<=1e3&&!d.isPending;function m(e){e.preventDefault(),f&&d.mutate(i.trim())}return/* @__PURE__ */ (0,W.jsx)(`form`,{onSubmit:m,children:/* @__PURE__ */ (0,W.jsxs)(_,{className:`mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(b,{anchor:`customization`,className:`m-0 text-lg font-bold`,title:`Customization`}),/* @__PURE__ */ (0,W.jsxs)(P,{className:`mt-5`,children:[/* @__PURE__ */ (0,W.jsx)(V,{htmlFor:`user-customization`,children:`How should replies to you change?`}),/* @__PURE__ */ (0,W.jsx)(w,{id:`user-customization`,maxLength:l,onChange:e=>{a(e.target.value),(d.isError||d.isSuccess)&&d.reset()},placeholder:`Keep replies short and simple.`,value:i}),/* @__PURE__ */ (0,W.jsxs)(M,{children:[`Added to each message you send. Do not put secrets here. (`,i.trim().length,`/`,l,`)`]})]}),/* @__PURE__ */ (0,W.jsxs)(`div`,{className:`mt-5 flex items-center gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(o,{disabled:!f,type:`submit`,children:d.isPending?`Saving…`:`Save customization`}),d.isSuccess?/* @__PURE__ */ (0,W.jsx)(`p`,{className:`m-0 text-sm text-emerald-300`,children:`Changes saved.`}):null,d.isError?/* @__PURE__ */ (0,W.jsx)(I,{children:`Could not save your customization. Try again.`}):null]})]})})}export{pe as SettingsPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{C as t,S as n,a as r,p as i,r as a}from"./vendor-react-ggbyvons.js";import{$ as o,B as s,Bt as c,Kt as l,Qt as u,_ as d,c as ee}from"./vendor-icons-mxz7yi04.js";import{t as te}from"./circle-dollar-sign-fpl4dmok.js";import{t as f}from"./styles-j0007fov.js";import{t as p}from"./Card-hy4bfgq7.js";import{a as ne,c as m,i as h,m as g,p as re,r as _,s as v,t as y}from"./PageHeader-kvp1fo95.js";import{c as ie,l as b,p as x,x as ae}from"./format-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{C as t,S as n,a as r,p as i,r as a}from"./vendor-react-ggbyvons.js";import{$ as o,B as s,Bt as c,Kt as l,Qt as u,_ as d,c as ee}from"./vendor-icons-mxz7yi04.js";import{t as te}from"./circle-dollar-sign-fpl4dmok.js";import{t as f}from"./styles-j0007fov.js";import{t as p}from"./Card-hy4bfgq7.js";import{a as ne,c as m,i as h,m as g,p as re,r as _,s as v,t as y}from"./PageHeader-kvp1fo95.js";import{c as ie,l as b,p as x,x as ae}from"./format-c4b0iyrx.js";import{n as oe}from"./AnchorHeading-cp3vx8qa.js";import{c as S,f as C,i as se,l as w,o as T,pt as E,r as D,s as O}from"../client-mgf2bxi7.js";import{C as k,a as A,d as j,i as M,l as N,m as P,n as F,o as I,r as L,s as R,t as z,u as B}from"./chart-dbzd0ka8.js";import{n as V,t as H}from"./BarChart-hdlbq093.js";import{n as U,r as W,t as G}from"./PluginReportRecordSet-fossppyd.js";import{t as K}from"./StatCard-i2klkqqp.js";import{t as ce}from"./ChartHeader-c1zg4xt5.js"
|
|
2
2
|
/**
|
|
3
3
|
* @license lucide-react v1.17.0 - ISC
|
|
4
4
|
*
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{ot as t,pt as n}from"./vendor-lthmb2su.js";import{C as r,S as i,_ as a,h as o,r as s}from"./vendor-react-ggbyvons.js";import{n as c,t as l}from"./button-loz3etho.js";import{l as u}from"./vendor-icons-mxz7yi04.js";import{t as d}from"./plus-gndielka.js";import{U as f}from"./junior-
|
|
2
|
-
# cwd is $JUNIOR_WORKSPACE_ROOT`,value:e.draft.setupScript}),/* @__PURE__ */ (0,z.jsx)(
|
|
1
|
+
import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{ot as t,pt as n}from"./vendor-lthmb2su.js";import{C as r,S as i,_ as a,h as o,r as s}from"./vendor-react-ggbyvons.js";import{n as c,t as l}from"./button-loz3etho.js";import{l as u}from"./vendor-icons-mxz7yi04.js";import{t as d}from"./plus-gndielka.js";import{U as f}from"./junior-gfsokzu9.js";import{o as p,s as m}from"./http-cdq677qt.js";import{t as h}from"./Card-hy4bfgq7.js";import{t as g}from"./PageHeader-kvp1fo95.js";import{U as _}from"./format-c4b0iyrx.js";import{Ft as v,K as y,_t as b,bt as x,gt as S,pt as C,q as w,r as T,yt as E}from"../client-mgf2bxi7.js";import{a as D,i as O,n as k,o as A,r as j,t as M}from"./workspaceQueries-l3p6sri7.js";var N=/* @__PURE__ */ e(r(),1);function P(){return{key:crypto.randomUUID(),provider:`github`,repo:``}}function F(){return{name:``,setupScript:``,vcpus:``,repos:[P()]}}function I(e){return{name:e.name,setupScript:e.setupScript,vcpus:e.vcpus===null?``:String(e.vcpus),repos:e.repos.length>0?e.repos.map(e=>({key:`${e.provider}:${e.repo.toLowerCase()}`,provider:e.provider,repo:e.repo})):[P()]}}function L(e){return{name:e.name.trim(),setupScript:e.setupScript,vcpus:e.vcpus.trim()?Number(e.vcpus.trim()):null,repos:e.repos.map(e=>({provider:e.provider.trim(),repo:e.repo.trim()}))}}function R(e,t){return!(t||!e.name.trim()||e.vcpus.trim()&&!/^[1-9]\d*$/.test(e.vcpus.trim())||e.repos.some(e=>!e.provider.trim()||!e.repo.trim()))}var z=i();function B(e){function t(t,n){e.onChange({...e.draft,repos:e.draft.repos.map(e=>e.key===t?{...e,...n}:e)})}function n(t){let n=e.draft.repos.filter(e=>e.key!==t);e.onChange({...e.draft,repos:n.length>0?n:[P()]})}function r(t){t.preventDefault(),e.canSave&&e.onSubmit()}return/* @__PURE__ */ (0,z.jsx)(h,{className:`mb-0`,padding:`md`,variant:`section`,children:/* @__PURE__ */ (0,z.jsxs)(`form`,{className:`grid gap-6`,onSubmit:r,children:[/* @__PURE__ */ (0,z.jsxs)(S,{children:[/* @__PURE__ */ (0,z.jsx)(E,{htmlFor:`workspace-name`,children:`Name`}),/* @__PURE__ */ (0,z.jsx)(x,{autoComplete:`off`,id:`workspace-name`,maxLength:64,onChange:t=>e.onChange({...e.draft,name:t.target.value}),placeholder:`sentry`,value:e.draft.name}),/* @__PURE__ */ (0,z.jsx)(b,{id:`workspace-name-help`,children:`Lowercase name used when agents switch into this Workspace.`})]}),/* @__PURE__ */ (0,z.jsxs)(`section`,{className:`grid gap-3`,"aria-labelledby":`workspace-repos-title`,children:[/* @__PURE__ */ (0,z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-start sm:gap-4`,children:[/* @__PURE__ */ (0,z.jsxs)(`div`,{className:`min-w-0 grid gap-1`,children:[/* @__PURE__ */ (0,z.jsx)(`h3`,{className:`m-0 text-sm font-semibold text-dashboard-text`,id:`workspace-repos-title`,children:`Repositories`}),/* @__PURE__ */ (0,z.jsxs)(`p`,{className:`m-0 text-xs leading-relaxed text-dashboard-text-muted sm:text-sm`,children:[`Each repository clones to a fixed`,` `,/* @__PURE__ */ (0,z.jsxs)(`code`,{className:`text-dashboard-text`,children:[`repos/`,`{name}`]}),` `,`path. Junior loads`,` `,/* @__PURE__ */ (0,z.jsx)(`code`,{className:`text-dashboard-text`,children:`AGENTS.md`}),` from each repository and labels those instructions with that directory.`]})]}),/* @__PURE__ */ (0,z.jsxs)(l,{className:`w-full sm:w-auto`,disabled:e.busy,onClick:()=>e.onChange({...e.draft,repos:[...e.draft.repos,P()]}),type:`button`,children:[/* @__PURE__ */ (0,z.jsx)(d,{"aria-hidden":`true`,size:14}),`Add repository`]})]}),/* @__PURE__ */ (0,z.jsx)(`div`,{className:`grid gap-3`,children:e.draft.repos.map((e,r)=>/* @__PURE__ */ (0,z.jsx)(`div`,{className:`grid gap-3 rounded-lg border border-dashboard-border-strong bg-dashboard-overlay-soft p-3 sm:p-4`,children:/* @__PURE__ */ (0,z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,8.5rem)_minmax(0,1fr)_auto] sm:items-end`,children:[/* @__PURE__ */ (0,z.jsxs)(S,{className:`gap-1.5`,children:[/* @__PURE__ */ (0,z.jsx)(E,{htmlFor:`workspace-repo-provider-${e.key}`,className:`font-sans text-xs font-medium text-dashboard-text-muted`,children:`Provider`}),/* @__PURE__ */ (0,z.jsx)(x,{"aria-label":`Provider ${r+1}`,id:`workspace-repo-provider-${e.key}`,onChange:n=>t(e.key,{provider:n.target.value}),placeholder:`github`,value:e.provider})]}),/* @__PURE__ */ (0,z.jsxs)(S,{className:`gap-1.5`,children:[/* @__PURE__ */ (0,z.jsx)(E,{htmlFor:`workspace-repo-name-${e.key}`,className:`font-sans text-xs font-medium text-dashboard-text-muted`,children:`Repository`}),/* @__PURE__ */ (0,z.jsx)(x,{"aria-label":`Repository ${r+1}`,id:`workspace-repo-name-${e.key}`,onChange:n=>t(e.key,{repo:n.target.value}),placeholder:`getsentry/sentry`,value:e.repo})]}),/* @__PURE__ */ (0,z.jsxs)(l,{"aria-label":`Remove repository ${r+1}`,className:`w-full sm:w-auto`,onClick:()=>n(e.key),variant:`danger`,type:`button`,children:[/* @__PURE__ */ (0,z.jsx)(u,{"aria-hidden":`true`,size:14}),`Remove`]})]})},e.key))})]}),/* @__PURE__ */ (0,z.jsxs)(S,{children:[/* @__PURE__ */ (0,z.jsx)(E,{htmlFor:`workspace-setup`,children:`Setup script`}),/* @__PURE__ */ (0,z.jsx)(y,{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
|
+
# cwd is $JUNIOR_WORKSPACE_ROOT`,value:e.draft.setupScript}),/* @__PURE__ */ (0,z.jsx)(b,{id:`workspace-setup-help`,children:/* @__PURE__ */ (0,z.jsxs)(z.Fragment,{children:[`Runs once while Junior builds the reusable snapshot. Current working directory is`,` `,/* @__PURE__ */ (0,z.jsx)(`code`,{className:`text-dashboard-text`,children:`$JUNIOR_WORKSPACE_ROOT`}),` `,`(the Sandbox root, usually`,` `,/* @__PURE__ */ (0,z.jsx)(`code`,{className:`text-dashboard-text`,children:`/vercel/sandbox`}),`). Cloned repositories live under`,` `,/* @__PURE__ */ (0,z.jsx)(`code`,{className:`text-dashboard-text`,children:`$JUNIOR_REPOS_ROOT`}),` (`,/* @__PURE__ */ (0,z.jsx)(`code`,{className:`text-dashboard-text`,children:`$JUNIOR_WORKSPACE_ROOT/repos`}),`). Use those variables instead of hard-coded absolute paths.`]})})]}),/* @__PURE__ */ (0,z.jsxs)(S,{children:[/* @__PURE__ */ (0,z.jsx)(E,{htmlFor:`workspace-vcpus`,children:`vCPUs`}),/* @__PURE__ */ (0,z.jsx)(x,{autoComplete:`off`,id:`workspace-vcpus`,inputMode:`numeric`,onChange:t=>e.onChange({...e.draft,vcpus:t.target.value}),placeholder:A(e.defaultVcpus),value:e.draft.vcpus}),/* @__PURE__ */ (0,z.jsx)(b,{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?/* @__PURE__ */ (0,z.jsx)(w,{children:e.error}):null,/* @__PURE__ */ (0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 border-t border-dashboard-border-subtle pt-5`,children:[/* @__PURE__ */ (0,z.jsx)(l,{disabled:!e.canSave,type:`submit`,variant:`primary`,children:e.busy?`Saving…`:e.editing?`Save changes`:`Create Workspace`}),/* @__PURE__ */ (0,z.jsx)(s,{className:c(),to:e.cancelPath,children:`Cancel`}),/* @__PURE__ */ (0,z.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.`})]})]})})}function V(){let{workspaceId:e}=a(),r=e!==void 0,i=o(),s=n(),[c,l]=(0,N.useState)(F),[u,d]=(0,N.useState)(),y=k(e),b=j().data?.defaultVcpus??null;(0,N.useEffect)(()=>{r&&e&&y.data&&u?.workspaceId!==e&&d({draft:I(y.data),workspaceId:e})},[r,u?.workspaceId,e,y.data]);let x=r?u?.workspaceId===e?u.draft:void 0:c,S=t({mutationFn:async t=>{let n=L(t);return r?m(f,`/api/workspaces/${encodeURIComponent(e)}`,n):p(f,`/api/workspaces`,n)},onSuccess:async e=>{await s.cancelQueries({queryKey:D}),s.setQueryData(D,t=>t&&{...t,workspaces:[e,...t.workspaces.filter(t=>t.id!==e.id)].sort((e,t)=>e.name.localeCompare(t.name))}),await s.invalidateQueries({queryKey:O(e.id)}),i(_(e.id))}});return r&&!y.error&&(!y.data||!x)?/* @__PURE__ */ (0,z.jsx)(T,{children:/* @__PURE__ */ (0,z.jsx)(v,{label:`Loading Workspace`})}):/* @__PURE__ */ (0,z.jsx)(T,{children:/* @__PURE__ */ (0,z.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:gap-5`,children:[/* @__PURE__ */ (0,z.jsx)(g,{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?y.data?.name??`Workspace`:`New Workspace`}),y.error?/* @__PURE__ */ (0,z.jsx)(h,{padding:`sm`,children:/* @__PURE__ */ (0,z.jsx)(C,{children:M(y.error,`Workspace not found. It may have been deleted.`)})}):x?/* @__PURE__ */ (0,z.jsx)(B,{busy:S.isPending,canSave:R(x,S.isPending),cancelPath:e?_(e):`/system/workspaces`,defaultVcpus:b,draft:x,editing:r,error:S.error?M(S.error,`Could not save the Workspace. Try again.`):void 0,onChange:r?t=>d({draft:t,workspaceId:e}):l,onSubmit:()=>S.mutate(x)}):null]})})}export{V as WorkspaceFormPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-bnnw9q4a.js";import{ot as t,pt as n}from"./vendor-lthmb2su.js";import{C as r,S as i,_ as a,h as o,r as s}from"./vendor-react-ggbyvons.js";import{n as c,t as l}from"./button-loz3etho.js";import{O as u,Pt as d,l as f,lt as p}from"./vendor-icons-mxz7yi04.js";import{t as ee}from"./plus-gndielka.js";import{a as m,n as h,t as g}from"./tooltip-c9bbl0em.js";import{r as te}from"./http-cdq677qt.js";import{t as ne}from"./styles-j0007fov.js";import{t as _}from"./Card-hy4bfgq7.js";import{t as v}from"./skeleton-h6p83ux1.js";import{t as y}from"./PageContentSkeleton-b7dkba0l.js";import{l as re,m as b,t as x}from"./PageHeader-kvp1fo95.js";import{U as S,c as ie,g as C,l as ae,x as w,y as T}from"./format-c4b0iyrx.js";import{t as oe}from"./PageLayout-l6dhbimv.js";import{t as se}from"./AnchorHeading-cp3vx8qa.js";import{$t as ce,A as E,B as D,F as O,H as k,M as A,N as j,P as M,V as N,a as P,en as F,j as I,k as L,pt as R}from"../client-mgf2bxi7.js";import{t as z}from"./FormNotice-mmzuj60h.js";import{t as B}from"./SelectableRow-j8fwjsjz.js";import{C as V,a as H,d as U,n as W,o as G,r as le,s as ue,t as de,u as fe}from"./chart-dbzd0ka8.js";import{n as pe,t as me}from"./BarChart-hdlbq093.js";import{t as he}from"./ChartHeader-c1zg4xt5.js";import{a as K,i as ge,n as _e,o as q,r as ve,t as ye}from"./workspaceQueries-l3p6sri7.js";var J=/* @__PURE__ */ e(r(),1),Y=i();function be(e){let t=e.snapshot;return/* @__PURE__ */ (0,Y.jsx)(_,{as:`section`,className:`mb-0`,padding:`md`,variant:`section`,children:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid gap-4`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`min-w-0 grid gap-1`,children:[/* @__PURE__ */ (0,Y.jsx)(se,{anchor:`base-sandbox`,className:`m-0 text-base font-semibold text-dashboard-text`,title:`Base Sandbox`}),/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 text-sm leading-relaxed text-dashboard-text-muted`,children:`The base snapshot is inherited by all Workspaces.`})]}),/* @__PURE__ */ (0,Y.jsxs)(`dl`,{className:`m-0 grid grid-cols-[max-content_minmax(0,1fr)] gap-x-6 gap-y-2 text-sm`,children:[/* @__PURE__ */ (0,Y.jsx)(X,{label:`Size`,children:q(e.defaultVcpus)}),t?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[t.dependencyCount==null?null:/* @__PURE__ */ (0,Y.jsx)(X,{label:`Dependencies`,children:t.dependencyCount}),/* @__PURE__ */ (0,Y.jsx)(X,{label:`Build time`,children:C(t.buildDurationMs)}),/* @__PURE__ */ (0,Y.jsx)(X,{label:`Generated`,children:/* @__PURE__ */ (0,Y.jsx)(`span`,{title:w(t.generatedAt),children:T(t.generatedAt)})}),/* @__PURE__ */ (0,Y.jsx)(X,{label:`Snapshot`,children:/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`break-all font-mono text-xs`,children:t.id})})]}):/* @__PURE__ */ (0,Y.jsx)(X,{label:`Snapshot`,children:/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-dashboard-text-muted`,children:`Not built yet. The first Sandbox without a Workspace builds it.`})})]})]})})}function X(e){return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`contents`,children:[/* @__PURE__ */ (0,Y.jsx)(`dt`,{className:`text-dashboard-text-muted`,children:e.label}),/* @__PURE__ */ (0,Y.jsx)(`dd`,{className:`m-0 min-w-0 tabular-nums text-dashboard-text`,children:e.children})]})}function xe(e){let[r,i]=(0,J.useState)(!0),a=n(),o=F(),s=t({mutationFn:()=>te(`/api/workspaces/${encodeURIComponent(e.workspace.id)}`),onSuccess:async()=>{await a.cancelQueries({queryKey:K}),a.setQueryData(K,t=>t&&{...t,workspaces:t.workspaces.filter(t=>t.id!==e.workspace.id)}),e.onDeleted(),a.removeQueries({queryKey:ge(e.workspace.id)}),o.add({title:`Workspace deleted`,description:e.workspace.name,type:`success`}),i(!1)}});return/* @__PURE__ */ (0,Y.jsx)(L,{open:r,onOpenChange:(e,t)=>{s.isPending?t.cancel():i(e)},onOpenChangeComplete:t=>{t||e.onClose()},children:/* @__PURE__ */ (0,Y.jsxs)(A,{finalFocus:e.returnFocus,children:[/* @__PURE__ */ (0,Y.jsx)(O,{children:`Delete Workspace?`}),/* @__PURE__ */ (0,Y.jsxs)(j,{children:[`Delete`,` `,/* @__PURE__ */ (0,Y.jsx)(`strong`,{className:`font-medium text-dashboard-text`,children:e.workspace.name}),`? Active conversations keep their current Sandbox until the next switch.`]}),s.error?/* @__PURE__ */ (0,Y.jsx)(z,{tone:`error`,title:ye(s.error,`Could not delete the Workspace. Try again.`)}):null,/* @__PURE__ */ (0,Y.jsxs)(M,{children:[/* @__PURE__ */ (0,Y.jsx)(I,{disabled:s.isPending,children:`Cancel`}),/* @__PURE__ */ (0,Y.jsx)(E,{disabled:s.isPending,onClick:()=>s.mutate(),variant:`danger`,children:s.isPending?`Deleting…`:`Delete Workspace`})]})]})})}const Z=`var(--color-violet-400)`,Q={count:{color:Z,label:`Usage`}};function Se(e){let t=e.days.map(e=>e.count),n=Math.max(1,...t),r=fe(t),i=t.reduce((e,t)=>e+t,0),a=i>0;return/* @__PURE__ */ (0,Y.jsxs)(_,{children:[/* @__PURE__ */ (0,Y.jsx)(he,{description:`Successful switches into “${e.workspaceName}”.`,title:`Usage`,total:ae(i),totalLabel:`last ${e.range} days`}),/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`relative px-2 py-3 sm:px-4 sm:py-4`,children:[/* @__PURE__ */ (0,Y.jsx)(de,{className:`aspect-auto h-50 w-full`,config:Q,children:/* @__PURE__ */ (0,Y.jsxs)(me,{"aria-label":`Usage for ${e.workspaceName} during the last ${e.range} days`,data:e.days,margin:U,role:`img`,children:[/* @__PURE__ */ (0,Y.jsx)(V,{strokeDasharray:`3 5`,vertical:!1}),/* @__PURE__ */ (0,Y.jsx)(ue,{maximum:n}),/* @__PURE__ */ (0,Y.jsx)(G,{keys:e.days.map(e=>e.date)}),/* @__PURE__ */ (0,Y.jsx)(W,{content:/* @__PURE__ */ (0,Y.jsx)(H,{rows:e=>[[`usage`,e.count]]})}),/* @__PURE__ */ (0,Y.jsx)(pe,{dataKey:`count`,fill:`var(--color-count)`,fillOpacity:.82,isAnimationActive:!1,maxBarSize:13,minPointSize:e=>e?2:0,radius:2}),/* @__PURE__ */ (0,Y.jsx)(le,{average:r,format:ie,stroke:Z})]})}),a?null:/* @__PURE__ */ (0,Y.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 Ce(e,t=Date.now()){let n=new Date(t);return n.setUTCHours(0,0,0,0),Array.from({length:e},(t,r)=>{let i=new Date(n);return i.setUTCDate(n.getUTCDate()-(e-1-r)),i.toISOString().slice(0,10)})}function we(e){let t=/* @__PURE__ */ new Map;for(let n of e.stats)n.namespace===`junior`&&n.metric===`workspace_switch`&&n.name===e.workspaceId&&t.set(n.date,(t.get(n.date)??0)+n.count);return Ce(e.range,e.nowMs).map(e=>({count:t.get(e)??0,date:e}))}function Te(e){let t=_e(e.workspaceId),n=ce(),r=t.data??e.workspace,i=!r&&(t.isError||e.listError);return/* @__PURE__ */ (0,Y.jsx)(k,{actions:r?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsxs)(g,{children:[/* @__PURE__ */ (0,Y.jsx)(m,{render:/* @__PURE__ */ (0,Y.jsx)(s,{"aria-label":`Edit ${r.name}`,className:c({size:`icon`}),to:`${S(r.id)}/edit`,children:/* @__PURE__ */ (0,Y.jsx)(u,{"aria-hidden":`true`,size:15})})}),/* @__PURE__ */ (0,Y.jsx)(h,{size:`compact`,children:`Edit Workspace`})]}),/* @__PURE__ */ (0,Y.jsxs)(g,{children:[/* @__PURE__ */ (0,Y.jsx)(m,{render:/* @__PURE__ */ (0,Y.jsx)(l,{"aria-label":`Delete ${r.name}`,onClick:t=>e.onDelete(r,t.currentTarget),size:`icon`,children:/* @__PURE__ */ (0,Y.jsx)(f,{"aria-hidden":`true`,size:15})})}),/* @__PURE__ */ (0,Y.jsx)(h,{size:`compact`,children:`Delete Workspace`})]})]}):void 0,label:`Workspace details`,onClose:e.onClose,sheetTitle:r?.name,title:/* @__PURE__ */ (0,Y.jsx)(`h2`,{className:`m-0 break-words font-display text-base font-medium text-dashboard-text`,children:r?.name??`Workspace details`}),children:/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`p-4 [overflow-wrap:anywhere]`,children:r?/* @__PURE__ */ (0,Y.jsx)(Ee,{defaultVcpus:e.defaultVcpus,error:!!n.error,loading:n.isPending,snapshot:t.data?`ready`:t.isError?`error`:`loading`,stats:n.data,workspace:r}):i?/* @__PURE__ */ (0,Y.jsx)(R,{children:`Workspace not found. It may have been deleted.`}):/* @__PURE__ */ (0,Y.jsx)(y,{label:`Loading Workspace details`,variant:`panel`})})})}function Ee(e){let{workspace:t}=e;return/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-4`,children:[/* @__PURE__ */ (0,Y.jsxs)(N,{children:[/* @__PURE__ */ (0,Y.jsx)(D,{label:`Repositories`,children:t.repos.length===0?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-dashboard-text-muted`,children:`None`}):/* @__PURE__ */ (0,Y.jsx)(`ul`,{className:`m-0 grid list-none gap-1.5 p-0`,children:t.repos.map(e=>/* @__PURE__ */ (0,Y.jsxs)(`li`,{className:`min-w-0`,children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`block font-mono text-xs text-dashboard-text`,children:[e.provider,`:`,e.repo]}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`block font-mono text-xs text-dashboard-text-muted`,children:e.checkoutPath})]},`${e.provider}:${e.repo}`))})}),/* @__PURE__ */ (0,Y.jsxs)(D,{label:`Sandbox size`,children:[q(t.vcpus??e.defaultVcpus),t.vcpus===null?/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-dashboard-text-muted`,children:` · default`}):null]}),/* @__PURE__ */ (0,Y.jsx)(D,{label:`Snapshot`,children:/* @__PURE__ */ (0,Y.jsx)(De,{state:e.snapshot,workspace:t})}),/* @__PURE__ */ (0,Y.jsx)(D,{label:`Setup script`,children:t.setupScript.trim()?/* @__PURE__ */ (0,Y.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}):/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-dashboard-text-muted`,children:`None`})})]}),e.stats?/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-3`,children:[e.error?/* @__PURE__ */ (0,Y.jsx)(`p`,{className:`m-0 font-sans text-xs text-rose-200/65`,children:`Workspace usage refresh failed. Showing cached data.`}):null,/* @__PURE__ */ (0,Y.jsx)(Se,{days:we({workspaceId:t.id,range:30,stats:e.stats.stats}),range:30,workspaceName:t.name})]}):/* @__PURE__ */ (0,Y.jsx)(R,{children:e.error?`Workspace usage failed to load.`:e.loading?`Loading Workspace usage.`:`No usage in this period.`})]})}function De(e){if(e.state===`loading`)return/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`grid gap-1.5`,role:`status`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`sr-only`,children:`Loading snapshot`}),/* @__PURE__ */ (0,Y.jsx)(v,{className:`h-4 w-36`}),/* @__PURE__ */ (0,Y.jsx)(v,{className:`h-3.5 w-48`})]});if(e.state===`error`)return/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-dashboard-text-muted`,children:`Snapshot status could not be loaded.`});let t=e.workspace.snapshot;return t?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`block tabular-nums`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{title:w(t.generatedAt),children:T(t.generatedAt)}),` `,`· built in `,C(t.buildDurationMs)]}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`block break-all font-mono text-xs text-dashboard-text-muted`,children:t.id})]}):/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`text-dashboard-text-muted`,children:`Not built yet. The first successful prepare builds it.`})}function Oe(e){return/* @__PURE__ */ (0,Y.jsx)(_,{padding:`none`,children:e.workspaces.length===0?/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`p-5`,children:/* @__PURE__ */ (0,Y.jsx)(R,{children:`No Workspaces yet. Create one so agents can switch into a prepared multi-repo Sandbox.`})}):/* @__PURE__ */ (0,Y.jsx)(`ul`,{className:`m-0 list-none p-0`,children:e.workspaces.map(t=>/* @__PURE__ */ (0,Y.jsx)(ke,{defaultVcpus:e.defaultVcpus,onSelect:()=>e.onSelect(t),selected:t.id===e.selectedId,workspace:t},t.id))})})}function ke(e){let{workspace:t}=e;return/* @__PURE__ */ (0,Y.jsx)(`li`,{className:`border-b border-dashboard-border-subtle last:border-b-0`,"data-workspace-id":t.id,children:/* @__PURE__ */ (0,Y.jsx)(B,{className:`px-4 py-3.5`,onSelect:e.onSelect,selected:e.selected,children:/* @__PURE__ */ (0,Y.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:[/* @__PURE__ */ (0,Y.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:/* @__PURE__ */ (0,Y.jsx)(p,{"aria-hidden":`true`,size:16})}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`font-display text-base font-medium leading-tight text-dashboard-text`,children:t.name}),/* @__PURE__ */ (0,Y.jsxs)(`span`,{className:`font-mono text-xs text-dashboard-text-muted`,children:[t.repos.length,` repo`,t.repos.length===1?``:`s`,` ·`,` `,q(t.vcpus??e.defaultVcpus)]})]}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`mt-1.5 block truncate font-mono text-xs text-dashboard-text-muted`,children:t.repos.length?t.repos.map(e=>`${e.provider}:${e.repo}`).join(` · `):`No repositories`})]}),/* @__PURE__ */ (0,Y.jsx)(d,{"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})]})})})}const $=`/system/workspaces`;function Ae(){let{workspaceId:e}=a(),t=o(),n=(0,J.useRef)(null),r=(0,J.useRef)(null),[i,l]=(0,J.useState)(),u=ve(),d=u.data?.workspaces??[],f=u.data?.defaultVcpus??null,p=d.find(t=>t.id===e);return re(p?.name??`Workspaces`),/* @__PURE__ */ (0,Y.jsxs)(P,{className:`grid h-full min-h-0 grid-rows-[auto_minmax(0,1fr)] md:grid-rows-[minmax(0,1fr)]`,children:[/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:ne(`grid h-full min-h-0 min-w-0`,e&&`xl:grid-cols-[minmax(0,1fr)_25rem]`),children:[/* @__PURE__ */ (0,Y.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:n,role:`region`,tabIndex:0,children:/* @__PURE__ */ (0,Y.jsxs)(oe,{children:[/* @__PURE__ */ (0,Y.jsx)(x,{actions:/* @__PURE__ */ (0,Y.jsxs)(s,{className:c(),to:`${$}/new`,children:[/* @__PURE__ */ (0,Y.jsx)(ee,{"aria-hidden":`true`,size:14}),`New Workspace`]}),description:`Named repository recipes ${b()} can switch into without cloning each turn.`,title:`Workspaces`}),u.error?/* @__PURE__ */ (0,Y.jsx)(_,{padding:`sm`,children:/* @__PURE__ */ (0,Y.jsx)(R,{children:`Workspaces failed to load. Try refreshing the dashboard.`})}):u.data?/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(be,{defaultVcpus:f,snapshot:u.data.baselineSnapshot}),/* @__PURE__ */ (0,Y.jsx)(Oe,{defaultVcpus:f,onSelect:n=>t(n.id===e?$:S(n.id)),selectedId:e,workspaces:d})]}):/* @__PURE__ */ (0,Y.jsx)(y,{label:`Loading Workspaces`,variant:`list`})]})}),e?/* @__PURE__ */ (0,Y.jsx)(Te,{defaultVcpus:f,listError:!!u.error,onClose:()=>{let r=e?n.current?.querySelector(`[data-workspace-id="${CSS.escape(e)}"] button`):void 0;t($),(r??n.current)?.focus()},onDelete:(e,t)=>{r.current=t,l(e)},workspace:p,workspaceId:e},e):null]}),i?/* @__PURE__ */ (0,Y.jsx)(xe,{onClose:()=>l(void 0),onDeleted:()=>{e===i.id&&t($)},returnFocus:()=>r.current?.isConnected?r.current:n.current??!1,workspace:i}):null]})}export{Ae as WorkspacesPage};
|