@sentry/junior-dashboard 0.289.0 → 0.291.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-dxpv4if7.js → AdminPage-nus5ycri.js} +1 -1
- package/dist/public/chunks/{Area-mifkw91r.js → Area-gt1sdk4c.js} +1 -1
- package/dist/public/chunks/{AutomationPage-b78qwjyj.js → AutomationPage-gkkuw17m.js} +1 -1
- package/dist/public/chunks/{AutomationRunDetails-eo5kytjz.js → AutomationRunDetails-najm4x1j.js} +1 -1
- package/dist/public/chunks/{AutomationRunsPage-lb6iq0e3.js → AutomationRunsPage-bx3nhkyu.js} +1 -1
- package/dist/public/chunks/{AutomationsPage-e1qwd0a3.js → AutomationsPage-o1gvds5a.js} +1 -1
- package/dist/public/chunks/{BarChart-mp8slgpi.js → BarChart-nm91dx0i.js} +1 -1
- package/dist/public/chunks/{BoardPage-l7fnq6fe.js → BoardPage-bnp4bh2y.js} +1 -1
- package/dist/public/chunks/{CodeChangeRow-ogz1mmmw.js → CodeChangeRow-l7msz02v.js} +1 -1
- package/dist/public/chunks/{CodePage-irv5asb6.js → CodePage-eb9xfehg.js} +1 -1
- package/dist/public/chunks/{CodeSummaryCards-jevt14n2.js → CodeSummaryCards-ko46g18h.js} +1 -1
- package/dist/public/chunks/{ConnectionsPage-getje22v.js → ConnectionsPage-bs0trwlu.js} +1 -1
- package/dist/public/chunks/{DrawerContent-mtjkrvnq.js → DrawerContent-clt2v4h5.js} +1 -1
- package/dist/public/chunks/{FilterBar-muavn9t5.js → FilterBar-k012tagh.js} +1 -1
- package/dist/public/chunks/{FormNotice-gpdzyqhs.js → FormNotice-ndbxjxml.js} +1 -1
- package/dist/public/chunks/{LocationDetailPage-d6osml7e.js → LocationDetailPage-lmq3fzwb.js} +1 -1
- package/dist/public/chunks/{LocationsPage-d7susa66.js → LocationsPage-iuycwgrk.js} +1 -1
- package/dist/public/chunks/{McpSettingsPage-ol9fpgsb.js → McpSettingsPage-jt621pk7.js} +1 -1
- package/dist/public/chunks/{PeoplePage-o4sfbnsg.js → PeoplePage-cq7tlf7s.js} +1 -1
- package/dist/public/chunks/{PersonProfilePage-fq0n3422.js → PersonProfilePage-k6z8ayic.js} +1 -1
- package/dist/public/chunks/{PersonalTokensPage-oykp5rk4.js → PersonalTokensPage-f3zhm3px.js} +1 -1
- package/dist/public/chunks/{PluginReportRecordSet-hm9gxrmi.js → PluginReportRecordSet-ovmfoi5x.js} +1 -1
- package/dist/public/chunks/{PluginUserPage-gf1so6gp.js → PluginUserPage-mjr7t9js.js} +1 -1
- package/dist/public/chunks/{RepositoryPage-5w57olft.js → RepositoryPage-miaqb63z.js} +1 -1
- package/dist/public/chunks/{SettingsPage-nk0okgmo.js → SettingsPage-ocko5gzs.js} +1 -1
- package/dist/public/chunks/{SystemPage-hgt606uy.js → SystemPage-f9sgyr71.js} +1 -1
- package/dist/public/chunks/{WorkspaceFormPage-jner7t6s.js → WorkspaceFormPage-ovra0hwr.js} +1 -1
- package/dist/public/chunks/{WorkspacesPage-bxry50gx.js → WorkspacesPage-m9o335es.js} +1 -1
- package/dist/public/chunks/{automationFormat-cgszhp4j.js → automationFormat-f3vjb9y9.js} +1 -1
- package/dist/public/chunks/{chart-mq6l636p.js → chart-peynklgr.js} +1 -1
- package/dist/public/chunks/{code-highlighter-mr5fgyiw.js → code-highlighter-jcl4p6jg.js} +1 -1
- package/dist/public/chunks/{format-gp7jvaw4.js → format-li35oiyp.js} +2 -2
- package/dist/public/chunks/{junior-n0x19hyd.js → junior-g9xga7oj.js} +2 -2
- package/dist/public/chunks/{workspaceQueries-cshqmgh0.js → workspaceQueries-ocke5763.js} +1 -1
- package/dist/public/{client-l5kt7yfz.js → client-h0cvcz8x.js} +17 -17
- package/dist/public/styles-6XAAC7O5.css +2 -0
- package/dist/tailwind.css +1 -1
- package/package.json +4 -4
- package/src/client/conversations/ConversationMeta.tsx +127 -34
- package/src/client/conversations/conversationSections.ts +3 -2
- package/src/client/format.ts +1 -0
- package/src/client/types.ts +2 -0
- package/dist/public/styles-GFFU7LPU.css +0 -2
|
@@ -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{E as s,Ot as c,lt as l,mt as u}from"./junior-n0x19hyd.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 b}from"./PageHeader-kvp1fo95.js";import{t as x}from"./AnchorHeading-cp3vx8qa.js";import{C as ee,H as S,M as C,N as w,Nt as te,P as T,Pt as ne,S as E,U as D,V as O,_ as k,_t as A,b as j,bt as M,d as re,g as ie,gt as N,h as P,m as F,mt as I,v as L,w as R,x as z,y as B,yt as V}from"../client-l5kt7yfz.js";import{t as H}from"./native-select-jfknh8t4.js";var U=/* @__PURE__ */ e(i(),1),W=a();const G=k.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(k);return/* @__PURE__ */ (0,W.jsxs)(_,{className:`mt-6 mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(x,{anchor:ie,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)(D,{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)(()=>E(),[]),c=r({enabled:a===`supported`,queryKey:L,queryFn:async()=>(await z())?.endpoint??null}),l=a===`supported`&&!!e.publicKey;(0,U.useEffect)(()=>{l&&ee()?.catch(()=>void 0)},[l]);let u=e=>i.setQueryData(G,e),d=t({mutationFn:e=>j(i,e)}),f=t({mutationFn:async()=>{let e=await R();return e?await m(s,`${P}/subscriptions`,{endpoint:e}):void 0},onSuccess:e=>{e&&u(e),i.invalidateQueries({queryKey:L})}}),p=t({mutationFn:B});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)(D,{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,`${P}/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)(T,{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)(T,{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)(b,{"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)(N,{children:[/* @__PURE__ */ (0,W.jsx)(V,{htmlFor:`notification-start`,children:`Start`}),/* @__PURE__ */ (0,W.jsx)(M,{id:`notification-start`,onChange:e=>d({start:e.target.value}),required:!0,step:900,type:`time`,value:i.start})]}),/* @__PURE__ */ (0,W.jsxs)(N,{children:[/* @__PURE__ */ (0,W.jsx)(V,{htmlFor:`notification-end`,children:`End`}),/* @__PURE__ */ (0,W.jsx)(M,{id:`notification-end`,onChange:e=>d({end:e.target.value}),required:!0,step:900,type:`time`,value:i.end})]})]})]}),/* @__PURE__ */ (0,W.jsxs)(N,{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)(A,{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)(D,{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=F(),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)(x,{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)(T,{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)(N,{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)(A,{id:`auto-archive-grace-help`,children:`How long finished work and the conversation stay quiet before archive.`})]}),i.isError?/* @__PURE__ */ (0,W.jsx)(D,{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)(D,{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)(re,{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)(x,{anchor:`profile`,className:`m-0 text-lg font-bold`,title:`Profile`}),/* @__PURE__ */ (0,W.jsxs)(N,{className:`mt-5`,children:[/* @__PURE__ */ (0,W.jsx)(V,{htmlFor:`display-name`,children:`Display name`}),/* @__PURE__ */ (0,W.jsx)(M,{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)(A,{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)(D,{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]=ne();return/* @__PURE__ */ (0,W.jsxs)(_,{className:`mt-6 mb-0 hidden md:block`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(x,{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:te.map(e=>/* @__PURE__ */ (0,W.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(w,{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]=I();return/* @__PURE__ */ (0,W.jsxs)(_,{className:`mt-6 mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(x,{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)(w,{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]=O();return/* @__PURE__ */ (0,W.jsxs)(_,{className:`mt-6 mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(x,{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)(T,{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)(D,{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)(x,{anchor:`customization`,className:`m-0 text-lg font-bold`,title:`Customization`}),/* @__PURE__ */ (0,W.jsxs)(N,{className:`mt-5`,children:[/* @__PURE__ */ (0,W.jsx)(V,{htmlFor:`user-customization`,children:`How should replies to you change?`}),/* @__PURE__ */ (0,W.jsx)(S,{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)(A,{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)(D,{children:`Could not save your customization. Try again.`}):null]})]})})}export{pe as SettingsPage};
|
|
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-g9xga7oj.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 b}from"./PageHeader-kvp1fo95.js";import{t as x}from"./AnchorHeading-cp3vx8qa.js";import{C as ee,H as S,M as C,N as w,Nt as te,P as T,Pt as ne,S as E,U as D,V as O,_ as k,_t as A,b as j,bt as M,d as re,g as ie,gt as N,h as P,m as F,mt as I,v as L,w as R,x as z,y as B,yt as V}from"../client-h0cvcz8x.js";import{t as H}from"./native-select-jfknh8t4.js";var U=/* @__PURE__ */ e(i(),1),W=a();const G=k.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(k);return/* @__PURE__ */ (0,W.jsxs)(_,{className:`mt-6 mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(x,{anchor:ie,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)(D,{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)(()=>E(),[]),c=r({enabled:a===`supported`,queryKey:L,queryFn:async()=>(await z())?.endpoint??null}),l=a===`supported`&&!!e.publicKey;(0,U.useEffect)(()=>{l&&ee()?.catch(()=>void 0)},[l]);let u=e=>i.setQueryData(G,e),d=t({mutationFn:e=>j(i,e)}),f=t({mutationFn:async()=>{let e=await R();return e?await m(s,`${P}/subscriptions`,{endpoint:e}):void 0},onSuccess:e=>{e&&u(e),i.invalidateQueries({queryKey:L})}}),p=t({mutationFn:B});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)(D,{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,`${P}/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)(T,{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)(T,{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)(b,{"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)(N,{children:[/* @__PURE__ */ (0,W.jsx)(V,{htmlFor:`notification-start`,children:`Start`}),/* @__PURE__ */ (0,W.jsx)(M,{id:`notification-start`,onChange:e=>d({start:e.target.value}),required:!0,step:900,type:`time`,value:i.start})]}),/* @__PURE__ */ (0,W.jsxs)(N,{children:[/* @__PURE__ */ (0,W.jsx)(V,{htmlFor:`notification-end`,children:`End`}),/* @__PURE__ */ (0,W.jsx)(M,{id:`notification-end`,onChange:e=>d({end:e.target.value}),required:!0,step:900,type:`time`,value:i.end})]})]})]}),/* @__PURE__ */ (0,W.jsxs)(N,{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)(A,{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)(D,{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=F(),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)(x,{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)(T,{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)(N,{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)(A,{id:`auto-archive-grace-help`,children:`How long finished work and the conversation stay quiet before archive.`})]}),i.isError?/* @__PURE__ */ (0,W.jsx)(D,{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)(D,{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)(re,{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)(x,{anchor:`profile`,className:`m-0 text-lg font-bold`,title:`Profile`}),/* @__PURE__ */ (0,W.jsxs)(N,{className:`mt-5`,children:[/* @__PURE__ */ (0,W.jsx)(V,{htmlFor:`display-name`,children:`Display name`}),/* @__PURE__ */ (0,W.jsx)(M,{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)(A,{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)(D,{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]=ne();return/* @__PURE__ */ (0,W.jsxs)(_,{className:`mt-6 mb-0 hidden md:block`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(x,{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:te.map(e=>/* @__PURE__ */ (0,W.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3`,children:[/* @__PURE__ */ (0,W.jsx)(w,{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]=I();return/* @__PURE__ */ (0,W.jsxs)(_,{className:`mt-6 mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(x,{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)(w,{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]=O();return/* @__PURE__ */ (0,W.jsxs)(_,{className:`mt-6 mb-0`,padding:`md`,variant:`raised`,children:[/* @__PURE__ */ (0,W.jsx)(x,{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)(T,{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)(D,{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)(x,{anchor:`customization`,className:`m-0 text-lg font-bold`,title:`Customization`}),/* @__PURE__ */ (0,W.jsxs)(N,{className:`mt-5`,children:[/* @__PURE__ */ (0,W.jsx)(V,{htmlFor:`user-customization`,children:`How should replies to you change?`}),/* @__PURE__ */ (0,W.jsx)(S,{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)(A,{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)(D,{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-li35oiyp.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-h0cvcz8x.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-peynklgr.js";import{n as V,t as H}from"./BarChart-nm91dx0i.js";import{n as U,r as W,t as G}from"./PluginReportRecordSet-ovmfoi5x.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-
|
|
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-g9xga7oj.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-li35oiyp.js";import{Ft as v,H as y,U as b,_t as x,bt as S,gt as C,pt as w,r as T,yt as E}from"../client-h0cvcz8x.js";import{a as D,i as O,n as k,o as A,r as j,t as M}from"./workspaceQueries-ocke5763.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)(C,{children:[/* @__PURE__ */ (0,z.jsx)(E,{htmlFor:`workspace-name`,children:`Name`}),/* @__PURE__ */ (0,z.jsx)(S,{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)(x,{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)(C,{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)(S,{"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)(C,{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)(S,{"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)(C,{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
2
|
# cwd is $JUNIOR_WORKSPACE_ROOT`,value:e.draft.setupScript}),/* @__PURE__ */ (0,z.jsx)(x,{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)(C,{children:[/* @__PURE__ */ (0,z.jsx)(E,{htmlFor:`workspace-vcpus`,children:`vCPUs`}),/* @__PURE__ */ (0,z.jsx)(S,{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)(x,{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)(b,{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)(w,{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};
|
|
@@ -1 +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-gp7jvaw4.js";import{t as oe}from"./PageLayout-l6dhbimv.js";import{t as se}from"./AnchorHeading-cp3vx8qa.js";import{$t as ce,A as E,D,E as O,I as k,L as A,O as j,R as M,T as N,a as P,en as F,j as I,k as L,pt as R}from"../client-l5kt7yfz.js";import{t as z}from"./FormNotice-gpdzyqhs.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-mq6l636p.js";import{n as pe,t as me}from"./BarChart-mp8slgpi.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-cshqmgh0.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)(N,{open:r,onOpenChange:(e,t)=>{s.isPending?t.cancel():i(e)},onOpenChangeComplete:t=>{t||e.onClose()},children:/* @__PURE__ */ (0,Y.jsxs)(j,{finalFocus:e.returnFocus,children:[/* @__PURE__ */ (0,Y.jsx)(I,{children:`Delete Workspace?`}),/* @__PURE__ */ (0,Y.jsxs)(L,{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)(E,{children:[/* @__PURE__ */ (0,Y.jsx)(D,{disabled:s.isPending,children:`Cancel`}),/* @__PURE__ */ (0,Y.jsx)(O,{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)(M,{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)(A,{children:[/* @__PURE__ */ (0,Y.jsx)(k,{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)(k,{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)(k,{label:`Snapshot`,children:/* @__PURE__ */ (0,Y.jsx)(De,{state:e.snapshot,workspace:t})}),/* @__PURE__ */ (0,Y.jsx)(k,{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};
|
|
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-li35oiyp.js";import{t as oe}from"./PageLayout-l6dhbimv.js";import{t as se}from"./AnchorHeading-cp3vx8qa.js";import{$t as ce,A as E,D,E as O,I as k,L as A,O as j,R as M,T as N,a as P,en as F,j as I,k as L,pt as R}from"../client-h0cvcz8x.js";import{t as z}from"./FormNotice-ndbxjxml.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-peynklgr.js";import{n as pe,t as me}from"./BarChart-nm91dx0i.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-ocke5763.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)(N,{open:r,onOpenChange:(e,t)=>{s.isPending?t.cancel():i(e)},onOpenChangeComplete:t=>{t||e.onClose()},children:/* @__PURE__ */ (0,Y.jsxs)(j,{finalFocus:e.returnFocus,children:[/* @__PURE__ */ (0,Y.jsx)(I,{children:`Delete Workspace?`}),/* @__PURE__ */ (0,Y.jsxs)(L,{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)(E,{children:[/* @__PURE__ */ (0,Y.jsx)(D,{disabled:s.isPending,children:`Cancel`}),/* @__PURE__ */ (0,Y.jsx)(O,{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)(M,{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)(A,{children:[/* @__PURE__ */ (0,Y.jsx)(k,{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)(k,{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)(k,{label:`Snapshot`,children:/* @__PURE__ */ (0,Y.jsx)(De,{state:e.snapshot,workspace:t})}),/* @__PURE__ */ (0,Y.jsx)(k,{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};
|