@wjarka/cezarion 0.14.9-dev.959 → 0.14.9-dev.991
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/delegation/routes.d.ts +50 -50
- package/dist/server/server.d.ts +1195 -1195
- package/package.json +3 -3
- package/web/dist/assets/{commit-list-D_WtLlWH.js → commit-list-ihwhOiFP.js} +1 -1
- package/web/dist/assets/{compare-variants-DJIej8bU.js → compare-variants-CmAaF9cg.js} +1 -1
- package/web/dist/assets/{github-DDkmhvRx.js → github-CY_FpDVo.js} +1 -1
- package/web/dist/assets/{index-BZB0C-In.js → index-GcasY1jB.js} +2 -2
- package/web/dist/assets/{repo-git-CTY51Xpo.js → repo-git-0_ca69eW.js} +1 -1
- package/web/dist/assets/{skills-fRAJjWDi.js → skills-BqWbc75M.js} +1 -1
- package/web/dist/assets/{task-changes-IX116bgy.js → task-changes-qYtGOIA6.js} +1 -1
- package/web/dist/assets/{task-commits-BaE7naEC.js → task-commits-CW10ZH8j.js} +1 -1
- package/web/dist/assets/{task-files-B17PDPqY.js → task-files-C-IhNjVf.js} +1 -1
- package/web/dist/assets/task-thread-DV71Q0au.js +9 -0
- package/web/dist/assets/{workflows-CV_4lCHh.js → workflows-DjoTJlOV.js} +1 -1
- package/web/dist/index.html +1 -1
- package/web/dist/assets/task-thread-D1dWARw-.js +0 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$n as r,Ba as i,Dn as a,Ga as o,It as s,Qn as c,Ra as l,Rt as u,Ti as d,U as f,Va as p,Vi as m,Yt as h,_t as g,a as _,c as v,d as y,er as b,gt as x,i as S,in as C,l as w,lt as T,o as ee,r as E,ra as D,s as O,t as k,ta as A,u as j,ui as M,xn as N,xt as P,ya as F}from"./centered-state-kOb8j_BL.js";import{n as I,t as L}from"./utils-BW1-Ibnd.js";import{t as R}from"./createLucideIcon-BHp8sXmF.js";import{n as z}from"./diff-controls-D_kgpdoa.js";import{i as B,r as V,t as H}from"./git-toolbar-DFC6bS8a.js";import{t as U,u as W}from"./project-router-CS_oeLqi.js";import{t as G}from"./search-x-I9Q8pgUa.js";import{t as K}from"./diff-stat-C3Id3W_C.js";import{a as q,h as J}from"./index-BZB0C-In.js";import{t as Y}from"./diff-Jd8igxRb2.js";import{t as X}from"./tab-link-D6eAdJez.js";import{t as Z}from"./use-desktop-BaYgO7YW.js";import{t as te}from"./commit-list-D_WtLlWH.js";var ne=R(`git-pull-request-arrow`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M5 9v12`,key:`ih889a`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}]]),Q=e(t(),1),$=n();function re({repo:e,info:t}){let n=a(),r=o(),c=e=>F(e.message,{tone:`danger`}),l=i({mutationFn:e=>d({name:e}),onSuccess:async e=>{F(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([r.invalidateQueries({queryKey:C.repo}),r.invalidateQueries({queryKey:C.health})]),r.setQueryData(C.repo,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),r.setQueryData(C.health,n=>n?.repo?.root===t.root?{...n,repo:{...n.repo,branch:e.branch}}:n)},onError:c}),f=i({mutationFn:e=>D({baseBranch:e}),onSuccess:e=>{F(e.baseBranch?`Agents now branch from ${e.baseBranch}`:`Agents now fork from the checked-out branch`),r.invalidateQueries({queryKey:C.repo})},onError:c}),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(``),_=h.trim().toLowerCase(),v=_?e.branches.filter(e=>e.toLowerCase().includes(_)):e.branches;return(0,$.jsxs)(`section`,{"data-slot":`repo-branches`,className:`grid min-w-0 grid-cols-1 gap-5 px-[18px] py-[22px] md:grid-cols-[minmax(0,1fr)_290px] md:px-9`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,$.jsx)(`h2`,{className:`sr-only`,children:`Branches`}),(0,$.jsxs)(`label`,{className:`relative block`,children:[(0,$.jsx)(u,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,$.jsx)(J,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:h,onChange:e=>g(e.target.value),className:`h-11 pl-10`})]}),(0,$.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-4 flex min-w-0 flex-col divide-y divide-border border-t border-border md:max-h-[40rem] md:overflow-y-auto md:overscroll-contain`,children:[v.map(e=>{let n=e===t.branch;return(0,$.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,className:`flex min-h-20 flex-col items-start justify-center gap-2 py-3 md:flex-row md:items-center md:justify-start md:py-2.5`,children:[(0,$.jsx)(`span`,{className:L(`min-w-0 truncate text-[13px]`,n&&`font-normal`),children:e}),n?(0,$.jsx)(`span`,{"data-slot":`branch-current`,className:`md:ml-auto flex shrink-0 items-center rounded-md bg-accent-strong/10 px-2 py-1.5 text-[12px] font-medium text-accent-text`,children:`Current`}):(0,$.jsxs)(y,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`md:ml-auto h-11`,disabled:l.isPending,onClick:()=>l.mutate(e),children:[(0,$.jsx)(x,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),v.length===0?(0,$.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-soft-foreground`,children:[`No branches match “`,h.trim(),`”.`]}):null]})]}),(0,$.jsxs)(`div`,{className:`min-w-0 self-start rounded-xl border border-border bg-card p-5`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold`,children:`Create a branch`}),(0,$.jsxs)(`form`,{"data-slot":`branch-create`,className:`mt-7 flex flex-col items-stretch gap-3`,onSubmit:e=>{e.preventDefault();let t=p.trim();t&&l.mutate(t,{onSuccess:()=>m(``)})},children:[(0,$.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,$.jsx)(`p`,{className:`-mt-1 text-xs text-muted-foreground`,children:`Create from the selected base.`}),(0,$.jsx)(J,{id:`new-branch-name`,"aria-label":`New branch name`,placeholder:`new-branch-name`,className:`h-11 bg-background`,value:p,onChange:e=>m(e.target.value)}),(0,$.jsxs)(y,{type:`submit`,variant:`primary`,size:`sm`,className:`min-h-11 self-start`,"data-action":`create-branch`,disabled:!p.trim()||l.isPending,children:[(0,$.jsx)(s,{size:16,"aria-hidden":`true`}),`Create branch`]})]}),(0,$.jsxs)(`div`,{className:`mt-5`,children:[(0,$.jsx)(`label`,{htmlFor:`base-branch-picker`,className:`text-sm font-medium`,children:`Agents’ base branch`}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`New task worktrees branch from this.`}),(0,$.jsxs)(`select`,{id:`base-branch-picker`,"data-slot":`base-branch-picker`,value:e.baseBranch??``,disabled:f.isPending,onChange:e=>f.mutate(e.target.value===``?null:e.target.value),className:`mt-1.5 block min-h-11 w-full rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[(0,$.jsx)(`option`,{value:``,children:`follow checked-out branch (default)`}),e.branches.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))]})]}),(0,$.jsx)(`p`,{className:`mt-3 border-t border-border pt-4 text-xs leading-relaxed text-muted-foreground`,children:`Switching branches changes your working tree. Review uncommitted changes first.`})]}),n.data?.forge?.available?(0,$.jsx)(ie,{}):null]})}function ie(){let e=N({limit:20});return(0,$.jsxs)(`div`,{"data-slot":`repo-prs`,className:`max-w-xl`,children:[(0,$.jsx)(`h2`,{className:`text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Open pull requests`}),e.isPending?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Loading pull requests…`}):e.isError?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:e.error.message}):e.data.available?e.data.prs.length===0?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`No open pull requests.`}):(0,$.jsx)(`ul`,{className:`mt-2 flex flex-col divide-y divide-border`,children:e.data.prs.map(e=>(0,$.jsx)(ae,{pr:e},e.number))}):(0,$.jsx)(`p`,{"data-slot":`repo-prs-unavailable`,className:`mt-2 text-xs text-soft-foreground`,children:e.data.reason??`The forge is unreachable right now.`})]})}function ae({pr:e}){let t=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(P,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:[`#`,e.number]}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.title}),e.checks?(0,$.jsx)(oe,{checks:e.checks}):null]}),n=`flex min-w-0 items-center gap-2 rounded-sm px-1.5 py-2`;return(0,$.jsx)(`li`,{"data-slot":`pr-row`,"data-number":e.number,children:I(e.url)?(0,$.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:L(n,`hover:bg-muted`),children:t}):(0,$.jsx)(`span`,{className:n,children:t})})}function oe({checks:e}){return(0,$.jsx)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:L(`shrink-0 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:e})}function se(){let e=r(),t=Z(),[n,i]=(0,Q.useState)(`unified`),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),l=(0,Q.useRef)(null),u=e.isError&&e.error instanceof M&&e.error.status===409,d=e.data?.files??[],f=(0,Q.useMemo)(()=>V(d),[d]),p=t?n:`unified`,m=!t||a;return(0,$.jsxs)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 px-[18px] py-[22px] md:px-9`,children:[(0,$.jsx)(`span`,{className:`text-sm`,children:e.data?`${e.data.stat.files} files changed ·`:`Uncommitted changes`}),e.data?(0,$.jsx)(H,{stat:e.data.stat}):null,(0,$.jsx)(`span`,{className:`ml-auto hidden items-center gap-1 md:flex`,children:(0,$.jsx)(z,{mode:n,wrap:a,onModeChange:i,onWrapChange:o})})]}),e.isPending?(0,$.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading changes…`}):e.isError?(0,$.jsx)(k,{icon:u?(0,$.jsx)(T,{size:16}):(0,$.jsx)(h,{size:16}),tone:u?`neutral`:`danger`,heading:`h2`,title:u?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):d.length===0?(0,$.jsx)(k,{icon:(0,$.jsx)(T,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 md:flex-row md:items-start px-[18px] pb-9 pt-0 [--diff-sticky-top:1rem] md:px-9`,children:[(0,$.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] w-full md:w-60 shrink-0 overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 lg:w-[250px]`,children:[(0,$.jsx)(`h2`,{className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,$.jsx)(B,{root:f,selected:s,onSelect:e=>{c(e),l.current?.scrollToPath(e)}})]}),(0,$.jsx)(Y,{files:d,viewRef:l,mode:p,wrap:m,className:`min-w-0 flex-1`})]})]})}function ce({log:e}){let{sha:t}=l();return t?(0,$.jsx)(le,{sha:t}):e.length===0?(0,$.jsx)(k,{icon:(0,$.jsx)(g,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`}):(0,$.jsx)(`div`,{className:`px-[18px] py-[22px] md:px-9`,children:(0,$.jsx)(te,{slot:`repo-commits`,commits:e.map(e=>({sha:e.hash,shaLabel:e.hash,subject:e.subject,author:e.author,when:e.when,href:`/git/commits/${e.hash}`}))})})}function le({sha:e}){let t=b(e),n=Z(),[r,i]=(0,Q.useState)(`unified`),[a,o]=(0,Q.useState)(!1),s=t.isError&&t.error instanceof M&&t.error.status===409,c=n?r:`unified`,l=!n||a;return(0,$.jsxs)(`section`,{"data-slot":`repo-commit`,"data-sha":e,className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 border-b border-border px-4 py-2 md:px-6`,children:[(0,$.jsx)(y,{asChild:!0,variant:`ghost`,size:`sm`,"data-slot":`commit-back`,children:(0,$.jsxs)(U,{to:`/git/commits`,children:[(0,$.jsx)(f,{size:16,"aria-hidden":`true`}),`All commits`]})}),t.data?(0,$.jsx)(K,{stat:t.data.stat}):null,(0,$.jsx)(`span`,{className:`ml-auto hidden items-center gap-1 md:flex`,children:(0,$.jsx)(z,{mode:r,wrap:a,onModeChange:i,onWrapChange:o})})]}),t.isPending?(0,$.jsx)(`p`,{"data-slot":`commit-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading commit…`}):t.isError?(0,$.jsx)(k,{icon:s?(0,$.jsx)(G,{}):(0,$.jsx)(h,{size:16}),tone:s?`neutral`:`danger`,heading:`h2`,title:s?`Commit not found`:`Could not load the commit`,subtitle:t.error.message}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{"data-slot":`commit-meta`,className:`border-b border-border px-4 py-3 md:px-6`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold`,children:t.data.subject}),(0,$.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-soft-foreground`,children:[t.data.author,` · `,t.data.when,` ·`,` `,(0,$.jsx)(`span`,{className:`font-mono select-all`,children:t.data.sha})]})]}),t.data.files.length===0?(0,$.jsx)(k,{icon:(0,$.jsx)(g,{size:16}),tone:`neutral`,heading:`h2`,title:`No file changes`,subtitle:`This commit carries no diff of its own — a merge commit's changes live on the commits it merged.`}):(0,$.jsx)(`div`,{className:`px-4 py-4 [--diff-sticky-top:1rem] md:px-6`,children:(0,$.jsx)(Y,{files:t.data.files,mode:c,wrap:l,className:`min-w-0`})})]})]})}function ue({repo:e,info:t}){let n=o(),[r,a]=(0,Q.useState)(e.baseBranch??t.branch),[s,c]=(0,Q.useState)(null),l=(0,Q.useRef)(null),u=C.repo,d=C.health,f=[...u,`pull`],h=!!t.remote,g=p({queryKey:f,queryFn:({signal:e})=>m({signal:e}),enabled:h}),b=i({mutationFn:A}),T=()=>Promise.all([n.invalidateQueries({queryKey:u}),n.invalidateQueries({queryKey:d})]),D=async(e,t=!1)=>{try{let n=await b.mutateAsync(t?{branch:e,confirm:!0}:{branch:e});if(`risks`in n){c(n);return}c(null),F(n.summary),await T()}catch(e){c(null),F(e instanceof Error?e.message:String(e),{tone:`danger`}),await T()}},k=g.data?.branches??e.branches,M=g.data===void 0||k.includes(r),N=M?k:[r,...k],P=h&&g.isPending,I=h?g.isError?`Could not load local branches: ${g.error.message}`:M?null:`${r} is not a local branch. Choose a local branch to pull.`:`No remote configured. Add a Git remote before pulling.`,L=b.isPending||P||!h||g.isError,R=L||!M,z=r!==t.branch;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{"data-slot":`repo-pull`,className:`max-w-full md:w-auto`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`label`,{htmlFor:`repo-pull-branch`,className:`sr-only`,children:`Branch to pull`}),(0,$.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,$.jsx)(x,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,$.jsx)(`select`,{id:`repo-pull-branch`,value:r,disabled:L,onChange:e=>a(e.target.value),className:`h-11 max-w-full min-w-[88px] appearance-none rounded-lg border border-input bg-card pr-3 pl-9 text-[13px] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,style:{width:`${Math.max(88,r.length*8+56)}px`},children:N.map(e=>(0,$.jsx)(`option`,{value:e,disabled:!M&&e===r,children:e},e))})]}),(0,$.jsxs)(y,{ref:l,type:`button`,"data-action":`repo-pull`,className:`h-11 px-4`,disabled:R,title:I??void 0,onClick:()=>void D(r),children:[b.isPending?(0,$.jsx)(W,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,$.jsx)(ne,{"aria-hidden":`true`}),z?`Switch & pull`:`Pull`]})]}),I||z?(0,$.jsx)(`p`,{"data-slot":`repo-pull-note`,className:`mt-1 break-all text-[11px] text-soft-foreground md:text-left`,children:I??`${r} stays checked out after the pull.`}):null]}),(0,$.jsx)(E,{open:s!==null,onOpenChange:e=>{!e&&!b.isPending&&c(null)},children:(0,$.jsxs)(ee,{onCloseAutoFocus:e=>{e.preventDefault(),l.current?.focus()},children:[(0,$.jsxs)(w,{children:[(0,$.jsxs)(j,{children:[`Pull `,s?.branch,` anyway?`]}),(0,$.jsx)(O,{asChild:!0,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[s?.risks.includes(`active_runs`)?(0,$.jsx)(`p`,{children:`An active session is using this repository. Pulling can change files while it works.`}):null,s?.risks.includes(`dirty_tree`)?(0,$.jsx)(`p`,{children:`The checkout has dirty files. Git may refuse the switch or pull to protect them.`}):null,(0,$.jsxs)(`p`,{children:[s?.branch,` will stay checked out after this attempt.`]})]})})]}),(0,$.jsxs)(v,{children:[(0,$.jsx)(_,{className:`h-11`,disabled:b.isPending,children:`Cancel`}),(0,$.jsx)(S,{className:`h-11`,disabled:b.isPending||s===null,onClick:e=>{e.preventDefault(),s&&D(s.branch,!0)},children:b.isPending?`Pulling…`:`Pull anyway`})]})]})})]})}function de({tab:e}){let t=c();if(t.isPending)return(0,$.jsx)(q,{});if(t.isError)return(0,$.jsx)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:(0,$.jsx)(k,{icon:(0,$.jsx)(h,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:t.error.message})});let n=t.data.info;return n?(0,$.jsx)(fe,{repo:t.data,info:n,tab:e}):(0,$.jsx)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:(0,$.jsx)(k,{icon:(0,$.jsx)(x,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`cezar is running outside a git repository — start it inside one to browse changes, commits and branches.`})})}function fe({repo:e,info:t,tab:n}){return(0,$.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,$.jsxs)(`header`,{"data-slot":`repo-header`,className:`px-[18px] pt-[18px] md:px-9 md:pt-9`,children:[(0,$.jsxs)(`h1`,{className:`text-2xl font-semibold tracking-tight md:text-[30px]`,children:[`Git · `,n===`changes`?`Changes`:n===`commits`?`Commits`:`Branches`]}),(0,$.jsxs)(`p`,{"data-slot":`repo-remote`,className:`mt-2 break-all text-[13px] text-muted-foreground`,children:[t.root.split(`/`).filter(Boolean).at(-1),t.remote?` · ${t.remote}`:``,` · `,(0,$.jsx)(`span`,{"data-slot":`branch-chip`,children:t.branch})]}),(0,$.jsx)(`div`,{className:`my-[22px] flex min-w-0 items-start gap-2.5`,children:(0,$.jsx)(ue,{repo:e,info:t})}),(0,$.jsxs)(`div`,{"data-slot":`repo-tabs`,className:`flex items-end gap-6 border-b border-border [&>a]:min-h-11`,children:[(0,$.jsx)(X,{to:`/git`,active:n===`changes`,children:`Changes`}),(0,$.jsx)(X,{to:`/git/commits`,active:n===`commits`,children:`Commits`}),(0,$.jsx)(X,{to:`/git/branches`,active:n===`branches`,children:`Branches`})]})]}),n===`changes`?(0,$.jsx)(se,{}):n===`commits`?(0,$.jsx)(ce,{log:e.log}):(0,$.jsx)(re,{repo:e,info:t})]})}export{de as RepoGitRoute};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$n as r,Ba as i,Dn as a,Ga as o,It as s,Qn as c,Ra as l,Rt as u,Ti as d,U as f,Va as p,Vi as m,Yt as h,_t as g,a as _,c as v,d as y,er as b,gt as x,i as S,in as C,l as w,lt as T,o as ee,r as E,ra as D,s as O,t as k,ta as A,u as j,ui as M,xn as N,xt as P,ya as F}from"./centered-state-kOb8j_BL.js";import{n as I,t as L}from"./utils-BW1-Ibnd.js";import{t as R}from"./createLucideIcon-BHp8sXmF.js";import{n as z}from"./diff-controls-D_kgpdoa.js";import{i as B,r as V,t as H}from"./git-toolbar-DFC6bS8a.js";import{t as U,u as W}from"./project-router-CS_oeLqi.js";import{t as G}from"./search-x-I9Q8pgUa.js";import{t as K}from"./diff-stat-C3Id3W_C.js";import{a as q,h as J}from"./index-GcasY1jB.js";import{t as Y}from"./diff-Jd8igxRb2.js";import{t as X}from"./tab-link-D6eAdJez.js";import{t as Z}from"./use-desktop-BaYgO7YW.js";import{t as te}from"./commit-list-ihwhOiFP.js";var ne=R(`git-pull-request-arrow`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M5 9v12`,key:`ih889a`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}]]),Q=e(t(),1),$=n();function re({repo:e,info:t}){let n=a(),r=o(),c=e=>F(e.message,{tone:`danger`}),l=i({mutationFn:e=>d({name:e}),onSuccess:async e=>{F(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([r.invalidateQueries({queryKey:C.repo}),r.invalidateQueries({queryKey:C.health})]),r.setQueryData(C.repo,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),r.setQueryData(C.health,n=>n?.repo?.root===t.root?{...n,repo:{...n.repo,branch:e.branch}}:n)},onError:c}),f=i({mutationFn:e=>D({baseBranch:e}),onSuccess:e=>{F(e.baseBranch?`Agents now branch from ${e.baseBranch}`:`Agents now fork from the checked-out branch`),r.invalidateQueries({queryKey:C.repo})},onError:c}),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(``),_=h.trim().toLowerCase(),v=_?e.branches.filter(e=>e.toLowerCase().includes(_)):e.branches;return(0,$.jsxs)(`section`,{"data-slot":`repo-branches`,className:`grid min-w-0 grid-cols-1 gap-5 px-[18px] py-[22px] md:grid-cols-[minmax(0,1fr)_290px] md:px-9`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,$.jsx)(`h2`,{className:`sr-only`,children:`Branches`}),(0,$.jsxs)(`label`,{className:`relative block`,children:[(0,$.jsx)(u,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,$.jsx)(J,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:h,onChange:e=>g(e.target.value),className:`h-11 pl-10`})]}),(0,$.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-4 flex min-w-0 flex-col divide-y divide-border border-t border-border md:max-h-[40rem] md:overflow-y-auto md:overscroll-contain`,children:[v.map(e=>{let n=e===t.branch;return(0,$.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,className:`flex min-h-20 flex-col items-start justify-center gap-2 py-3 md:flex-row md:items-center md:justify-start md:py-2.5`,children:[(0,$.jsx)(`span`,{className:L(`min-w-0 truncate text-[13px]`,n&&`font-normal`),children:e}),n?(0,$.jsx)(`span`,{"data-slot":`branch-current`,className:`md:ml-auto flex shrink-0 items-center rounded-md bg-accent-strong/10 px-2 py-1.5 text-[12px] font-medium text-accent-text`,children:`Current`}):(0,$.jsxs)(y,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`md:ml-auto h-11`,disabled:l.isPending,onClick:()=>l.mutate(e),children:[(0,$.jsx)(x,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),v.length===0?(0,$.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-soft-foreground`,children:[`No branches match “`,h.trim(),`”.`]}):null]})]}),(0,$.jsxs)(`div`,{className:`min-w-0 self-start rounded-xl border border-border bg-card p-5`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold`,children:`Create a branch`}),(0,$.jsxs)(`form`,{"data-slot":`branch-create`,className:`mt-7 flex flex-col items-stretch gap-3`,onSubmit:e=>{e.preventDefault();let t=p.trim();t&&l.mutate(t,{onSuccess:()=>m(``)})},children:[(0,$.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,$.jsx)(`p`,{className:`-mt-1 text-xs text-muted-foreground`,children:`Create from the selected base.`}),(0,$.jsx)(J,{id:`new-branch-name`,"aria-label":`New branch name`,placeholder:`new-branch-name`,className:`h-11 bg-background`,value:p,onChange:e=>m(e.target.value)}),(0,$.jsxs)(y,{type:`submit`,variant:`primary`,size:`sm`,className:`min-h-11 self-start`,"data-action":`create-branch`,disabled:!p.trim()||l.isPending,children:[(0,$.jsx)(s,{size:16,"aria-hidden":`true`}),`Create branch`]})]}),(0,$.jsxs)(`div`,{className:`mt-5`,children:[(0,$.jsx)(`label`,{htmlFor:`base-branch-picker`,className:`text-sm font-medium`,children:`Agents’ base branch`}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`New task worktrees branch from this.`}),(0,$.jsxs)(`select`,{id:`base-branch-picker`,"data-slot":`base-branch-picker`,value:e.baseBranch??``,disabled:f.isPending,onChange:e=>f.mutate(e.target.value===``?null:e.target.value),className:`mt-1.5 block min-h-11 w-full rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[(0,$.jsx)(`option`,{value:``,children:`follow checked-out branch (default)`}),e.branches.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))]})]}),(0,$.jsx)(`p`,{className:`mt-3 border-t border-border pt-4 text-xs leading-relaxed text-muted-foreground`,children:`Switching branches changes your working tree. Review uncommitted changes first.`})]}),n.data?.forge?.available?(0,$.jsx)(ie,{}):null]})}function ie(){let e=N({limit:20});return(0,$.jsxs)(`div`,{"data-slot":`repo-prs`,className:`max-w-xl`,children:[(0,$.jsx)(`h2`,{className:`text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Open pull requests`}),e.isPending?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Loading pull requests…`}):e.isError?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:e.error.message}):e.data.available?e.data.prs.length===0?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`No open pull requests.`}):(0,$.jsx)(`ul`,{className:`mt-2 flex flex-col divide-y divide-border`,children:e.data.prs.map(e=>(0,$.jsx)(ae,{pr:e},e.number))}):(0,$.jsx)(`p`,{"data-slot":`repo-prs-unavailable`,className:`mt-2 text-xs text-soft-foreground`,children:e.data.reason??`The forge is unreachable right now.`})]})}function ae({pr:e}){let t=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(P,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:[`#`,e.number]}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.title}),e.checks?(0,$.jsx)(oe,{checks:e.checks}):null]}),n=`flex min-w-0 items-center gap-2 rounded-sm px-1.5 py-2`;return(0,$.jsx)(`li`,{"data-slot":`pr-row`,"data-number":e.number,children:I(e.url)?(0,$.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:L(n,`hover:bg-muted`),children:t}):(0,$.jsx)(`span`,{className:n,children:t})})}function oe({checks:e}){return(0,$.jsx)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:L(`shrink-0 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:e})}function se(){let e=r(),t=Z(),[n,i]=(0,Q.useState)(`unified`),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),l=(0,Q.useRef)(null),u=e.isError&&e.error instanceof M&&e.error.status===409,d=e.data?.files??[],f=(0,Q.useMemo)(()=>V(d),[d]),p=t?n:`unified`,m=!t||a;return(0,$.jsxs)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 px-[18px] py-[22px] md:px-9`,children:[(0,$.jsx)(`span`,{className:`text-sm`,children:e.data?`${e.data.stat.files} files changed ·`:`Uncommitted changes`}),e.data?(0,$.jsx)(H,{stat:e.data.stat}):null,(0,$.jsx)(`span`,{className:`ml-auto hidden items-center gap-1 md:flex`,children:(0,$.jsx)(z,{mode:n,wrap:a,onModeChange:i,onWrapChange:o})})]}),e.isPending?(0,$.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading changes…`}):e.isError?(0,$.jsx)(k,{icon:u?(0,$.jsx)(T,{size:16}):(0,$.jsx)(h,{size:16}),tone:u?`neutral`:`danger`,heading:`h2`,title:u?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):d.length===0?(0,$.jsx)(k,{icon:(0,$.jsx)(T,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 md:flex-row md:items-start px-[18px] pb-9 pt-0 [--diff-sticky-top:1rem] md:px-9`,children:[(0,$.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] w-full md:w-60 shrink-0 overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 lg:w-[250px]`,children:[(0,$.jsx)(`h2`,{className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,$.jsx)(B,{root:f,selected:s,onSelect:e=>{c(e),l.current?.scrollToPath(e)}})]}),(0,$.jsx)(Y,{files:d,viewRef:l,mode:p,wrap:m,className:`min-w-0 flex-1`})]})]})}function ce({log:e}){let{sha:t}=l();return t?(0,$.jsx)(le,{sha:t}):e.length===0?(0,$.jsx)(k,{icon:(0,$.jsx)(g,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`}):(0,$.jsx)(`div`,{className:`px-[18px] py-[22px] md:px-9`,children:(0,$.jsx)(te,{slot:`repo-commits`,commits:e.map(e=>({sha:e.hash,shaLabel:e.hash,subject:e.subject,author:e.author,when:e.when,href:`/git/commits/${e.hash}`}))})})}function le({sha:e}){let t=b(e),n=Z(),[r,i]=(0,Q.useState)(`unified`),[a,o]=(0,Q.useState)(!1),s=t.isError&&t.error instanceof M&&t.error.status===409,c=n?r:`unified`,l=!n||a;return(0,$.jsxs)(`section`,{"data-slot":`repo-commit`,"data-sha":e,className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 border-b border-border px-4 py-2 md:px-6`,children:[(0,$.jsx)(y,{asChild:!0,variant:`ghost`,size:`sm`,"data-slot":`commit-back`,children:(0,$.jsxs)(U,{to:`/git/commits`,children:[(0,$.jsx)(f,{size:16,"aria-hidden":`true`}),`All commits`]})}),t.data?(0,$.jsx)(K,{stat:t.data.stat}):null,(0,$.jsx)(`span`,{className:`ml-auto hidden items-center gap-1 md:flex`,children:(0,$.jsx)(z,{mode:r,wrap:a,onModeChange:i,onWrapChange:o})})]}),t.isPending?(0,$.jsx)(`p`,{"data-slot":`commit-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading commit…`}):t.isError?(0,$.jsx)(k,{icon:s?(0,$.jsx)(G,{}):(0,$.jsx)(h,{size:16}),tone:s?`neutral`:`danger`,heading:`h2`,title:s?`Commit not found`:`Could not load the commit`,subtitle:t.error.message}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{"data-slot":`commit-meta`,className:`border-b border-border px-4 py-3 md:px-6`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold`,children:t.data.subject}),(0,$.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-soft-foreground`,children:[t.data.author,` · `,t.data.when,` ·`,` `,(0,$.jsx)(`span`,{className:`font-mono select-all`,children:t.data.sha})]})]}),t.data.files.length===0?(0,$.jsx)(k,{icon:(0,$.jsx)(g,{size:16}),tone:`neutral`,heading:`h2`,title:`No file changes`,subtitle:`This commit carries no diff of its own — a merge commit's changes live on the commits it merged.`}):(0,$.jsx)(`div`,{className:`px-4 py-4 [--diff-sticky-top:1rem] md:px-6`,children:(0,$.jsx)(Y,{files:t.data.files,mode:c,wrap:l,className:`min-w-0`})})]})]})}function ue({repo:e,info:t}){let n=o(),[r,a]=(0,Q.useState)(e.baseBranch??t.branch),[s,c]=(0,Q.useState)(null),l=(0,Q.useRef)(null),u=C.repo,d=C.health,f=[...u,`pull`],h=!!t.remote,g=p({queryKey:f,queryFn:({signal:e})=>m({signal:e}),enabled:h}),b=i({mutationFn:A}),T=()=>Promise.all([n.invalidateQueries({queryKey:u}),n.invalidateQueries({queryKey:d})]),D=async(e,t=!1)=>{try{let n=await b.mutateAsync(t?{branch:e,confirm:!0}:{branch:e});if(`risks`in n){c(n);return}c(null),F(n.summary),await T()}catch(e){c(null),F(e instanceof Error?e.message:String(e),{tone:`danger`}),await T()}},k=g.data?.branches??e.branches,M=g.data===void 0||k.includes(r),N=M?k:[r,...k],P=h&&g.isPending,I=h?g.isError?`Could not load local branches: ${g.error.message}`:M?null:`${r} is not a local branch. Choose a local branch to pull.`:`No remote configured. Add a Git remote before pulling.`,L=b.isPending||P||!h||g.isError,R=L||!M,z=r!==t.branch;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{"data-slot":`repo-pull`,className:`max-w-full md:w-auto`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`label`,{htmlFor:`repo-pull-branch`,className:`sr-only`,children:`Branch to pull`}),(0,$.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,$.jsx)(x,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,$.jsx)(`select`,{id:`repo-pull-branch`,value:r,disabled:L,onChange:e=>a(e.target.value),className:`h-11 max-w-full min-w-[88px] appearance-none rounded-lg border border-input bg-card pr-3 pl-9 text-[13px] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,style:{width:`${Math.max(88,r.length*8+56)}px`},children:N.map(e=>(0,$.jsx)(`option`,{value:e,disabled:!M&&e===r,children:e},e))})]}),(0,$.jsxs)(y,{ref:l,type:`button`,"data-action":`repo-pull`,className:`h-11 px-4`,disabled:R,title:I??void 0,onClick:()=>void D(r),children:[b.isPending?(0,$.jsx)(W,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,$.jsx)(ne,{"aria-hidden":`true`}),z?`Switch & pull`:`Pull`]})]}),I||z?(0,$.jsx)(`p`,{"data-slot":`repo-pull-note`,className:`mt-1 break-all text-[11px] text-soft-foreground md:text-left`,children:I??`${r} stays checked out after the pull.`}):null]}),(0,$.jsx)(E,{open:s!==null,onOpenChange:e=>{!e&&!b.isPending&&c(null)},children:(0,$.jsxs)(ee,{onCloseAutoFocus:e=>{e.preventDefault(),l.current?.focus()},children:[(0,$.jsxs)(w,{children:[(0,$.jsxs)(j,{children:[`Pull `,s?.branch,` anyway?`]}),(0,$.jsx)(O,{asChild:!0,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[s?.risks.includes(`active_runs`)?(0,$.jsx)(`p`,{children:`An active session is using this repository. Pulling can change files while it works.`}):null,s?.risks.includes(`dirty_tree`)?(0,$.jsx)(`p`,{children:`The checkout has dirty files. Git may refuse the switch or pull to protect them.`}):null,(0,$.jsxs)(`p`,{children:[s?.branch,` will stay checked out after this attempt.`]})]})})]}),(0,$.jsxs)(v,{children:[(0,$.jsx)(_,{className:`h-11`,disabled:b.isPending,children:`Cancel`}),(0,$.jsx)(S,{className:`h-11`,disabled:b.isPending||s===null,onClick:e=>{e.preventDefault(),s&&D(s.branch,!0)},children:b.isPending?`Pulling…`:`Pull anyway`})]})]})})]})}function de({tab:e}){let t=c();if(t.isPending)return(0,$.jsx)(q,{});if(t.isError)return(0,$.jsx)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:(0,$.jsx)(k,{icon:(0,$.jsx)(h,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:t.error.message})});let n=t.data.info;return n?(0,$.jsx)(fe,{repo:t.data,info:n,tab:e}):(0,$.jsx)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:(0,$.jsx)(k,{icon:(0,$.jsx)(x,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`cezar is running outside a git repository — start it inside one to browse changes, commits and branches.`})})}function fe({repo:e,info:t,tab:n}){return(0,$.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,$.jsxs)(`header`,{"data-slot":`repo-header`,className:`px-[18px] pt-[18px] md:px-9 md:pt-9`,children:[(0,$.jsxs)(`h1`,{className:`text-2xl font-semibold tracking-tight md:text-[30px]`,children:[`Git · `,n===`changes`?`Changes`:n===`commits`?`Commits`:`Branches`]}),(0,$.jsxs)(`p`,{"data-slot":`repo-remote`,className:`mt-2 break-all text-[13px] text-muted-foreground`,children:[t.root.split(`/`).filter(Boolean).at(-1),t.remote?` · ${t.remote}`:``,` · `,(0,$.jsx)(`span`,{"data-slot":`branch-chip`,children:t.branch})]}),(0,$.jsx)(`div`,{className:`my-[22px] flex min-w-0 items-start gap-2.5`,children:(0,$.jsx)(ue,{repo:e,info:t})}),(0,$.jsxs)(`div`,{"data-slot":`repo-tabs`,className:`flex items-end gap-6 border-b border-border [&>a]:min-h-11`,children:[(0,$.jsx)(X,{to:`/git`,active:n===`changes`,children:`Changes`}),(0,$.jsx)(X,{to:`/git/commits`,active:n===`commits`,children:`Commits`}),(0,$.jsx)(X,{to:`/git/branches`,active:n===`branches`,children:`Branches`})]})]}),n===`changes`?(0,$.jsx)(se,{}):n===`commits`?(0,$.jsx)(ce,{log:e.log}):(0,$.jsx)(re,{repo:e,info:t})]})}export{de as RepoGitRoute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ba as r,Cr as i,Dr as a,Ei as o,Ga as s,Gt as c,It as l,Lt as u,Q as d,Rt as f,Tr as p,U as m,Ut as h,Vn as g,Wt as _,Yt as v,_r as y,bi as b,ca as x,d as S,fi as C,gr as w,in as T,jt as E,kn as D,li as O,nn as k,oa as A,ot as j,t as M,ya as N,za as P}from"./centered-state-kOb8j_BL.js";import{t as F}from"./utils-BW1-Ibnd.js";import{a as ee,i as te,n as ne,o as re,r as ie,s as ae}from"./textarea-D2Gx4GDI.js";import{T as oe}from"./prompt-templates-BgXzCOlY.js";import{c as I,t as L}from"./project-router-CS_oeLqi.js";import{i as R,l as z,n as B,o as V,p as H}from"./skills-DFBiAuJG.js";import{c as U,h as W,o as G,t as K}from"./index-BZB0C-In.js";import{t as se}from"./skill-empty-hint-oOtzR3v0.js";var q=e(t(),1),J=n(),Y=`https://github.com/open-mercato/skills`;function ce(e){let t=e?.importedSkills;if(Array.isArray(t))return t.filter(e=>typeof e==`string`&&!!e)}function X(e,t){return ce(e)??[...t]}function le({projectId:e}){let t=s(),n=p(),r=D(),[i,o]=(0,q.useState)(``),u=y(e,!!e),d=r.data??[],m=(0,q.useMemo)(()=>d.map(e=>e.name),[d]),h=(0,q.useRef)([]);h.current=m;let g=(0,q.useMemo)(()=>new Set(X(n.data,m)),[n.data,m]),b=(0,q.useRef)(Promise.resolve()),x=(0,q.useRef)(0),S=(0,q.useCallback)(e=>{let n=a.uiState,r=t.getQueryData(n),i=e(X(r,h.current));t.setQueryData(n,{...r,importedSkills:i});let o=++x.current;b.current=b.current.then(async()=>{try{let e=await A({importedSkills:i});o===x.current&&(t.setQueryData(n,e),t.invalidateQueries({queryKey:T.skills}))}catch(e){N(e instanceof Error?e.message:String(e),{tone:`danger`}),o===x.current&&t.invalidateQueries({queryKey:n})}})},[t]),C=(0,q.useCallback)(e=>{S(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[S]),w=m.length>0&&m.every(e=>g.has(e)),O=(0,q.useCallback)(()=>{if(w){let e=new Set(h.current);S(t=>t.filter(t=>!e.has(t)))}else S(e=>[...new Set([...e,...h.current])])},[w,S]);if(r.isError)return(0,J.jsx)(M,{icon:(0,J.jsx)(v,{}),tone:`danger`,heading:`h2`,title:`Could not load importable skills`,subtitle:r.error.message});let k=z(d,i);return(0,J.jsxs)(`div`,{"data-slot":`skills-import-panel`,className:`w-full min-w-0 [&_button]:min-h-11`,children:[(0,J.jsx)(`p`,{className:`mb-4 text-[12px] font-medium tracking-wide text-link-foreground`,children:`OPEN-MERCATO / SKILLS`}),(0,J.jsx)(`h2`,{className:`text-2xl font-medium`,children:`Manage skills`}),(0,J.jsxs)(`p`,{className:`mt-2 text-[13px] leading-relaxed text-muted-foreground`,children:[`Choose which `,(0,J.jsx)(`a`,{href:Y,target:`_blank`,rel:`noreferrer`,children:`open-mercato`}),` skills appear in your catalog and composer picker. All are enabled by default; uncheck any you don’t want.`]}),(0,J.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Applies across projects · saved automatically`}),(0,J.jsx)(ue,{projectId:e,state:u.data,loadError:u.error}),(0,J.jsx)(`p`,{className:`mt-4 text-xs text-soft-foreground`,children:`Checkboxes control visibility. Updating refreshes installed skill files; it does not change your selection.`}),(0,J.jsxs)(`div`,{className:`sw-import-controls mt-4 flex flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`div`,{className:`sw-search relative min-w-0 flex-1`,children:[(0,J.jsx)(f,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,J.jsx)(W,{"data-slot":`import-filter`,placeholder:`Filter skills…`,"aria-label":`Filter skills`,value:i,onChange:e=>o(e.target.value),className:`h-11 min-w-0 pl-9 text-xs`})]}),(0,J.jsxs)(`button`,{type:`button`,"data-slot":`import-all`,disabled:m.length===0||n.isPending,onClick:O,className:`h-11 shrink-0 rounded-md border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-55`,children:[w?(0,J.jsx)(E,{"aria-hidden":`true`,className:`size-4`}):(0,J.jsx)(l,{"aria-hidden":`true`,className:`size-4`}),w?`Remove all`:`Enable all`]})]}),(0,J.jsx)(`div`,{"data-slot":`import-list`,className:`mt-3 flex flex-col gap-1.5`,children:r.isPending?(0,J.jsx)(`p`,{className:`px-1 py-2 text-[13px] text-soft-foreground`,children:`Loading…`}):k.length>0?k.map(e=>{let t=g.has(e.name);return(0,J.jsxs)(`label`,{"data-slot":`import-row`,"data-skill":e.name,"data-imported":t?`true`:void 0,className:F(`flex min-h-16 cursor-pointer items-start gap-3 rounded-lg border border-border p-4 transition-colors hover:bg-muted`,t&&`bg-background`),children:[(0,J.jsxs)(`span`,{className:`relative size-5 shrink-0`,children:[(0,J.jsx)(`input`,{type:`checkbox`,"data-slot":`import-toggle`,checked:t,onChange:()=>C(e.name),className:`peer absolute inset-0 m-0 size-5 opacity-0`}),t?(0,J.jsx)(_,{"aria-hidden":`true`,className:`pointer-events-none size-5 text-link-foreground peer-focus-visible:outline-2 peer-focus-visible:outline-ring`}):(0,J.jsx)(c,{"aria-hidden":`true`,className:`pointer-events-none size-5 text-link-foreground peer-focus-visible:outline-2 peer-focus-visible:outline-ring`})]}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`span`,{className:`flex min-w-0 items-center gap-2`,children:(0,J.jsx)(`span`,{className:`min-w-0 break-words text-[13px] font-medium text-foreground`,children:e.name})}),e.description?(0,J.jsx)(`span`,{className:`mt-2 block text-xs leading-relaxed text-soft-foreground`,children:e.description}):null]})]},e.name)}):(0,J.jsx)(`p`,{className:`px-1 py-2 text-xs text-soft-foreground`,children:d.length>0?`(no skills match)`:`(no skills available — the repo may still be cloning)`})})]})}function Z(e){return e===`project`?`Project installation`:`Global installation`}function ue({projectId:e,state:t,loadError:n}){let i=s(),c=I(),l=(0,q.useRef)(0),[f,p]=(0,q.useState)(!1),m=r({mutationFn:()=>o({task:`Apply the upgrade notes after updating the installed Open Mercato skills.`,steps:[{id:`apply-upgrade-notes`,name:`Apply upgrade notes`,skill:`om-apply-upgrade-notes`,prompt:`{{task}}`}]}),onSuccess:e=>{p(!1),c(oe(e))},onError:e=>N(e.message,{tone:`danger`})}),h=(t,n)=>{n.seq===l.current&&(i.setQueryData(a.skillsUpdate(e),t),n.action===`apply`&&t.updatedAt&&t.updatedAt!==n.previousUpdatedAt&&(i.invalidateQueries({queryKey:T.skills}),N(t.status===`error`?`Some skill updates failed.`:`Open Mercato skills updated.`),p(!0)))},g=(e,t)=>{t.seq===l.current&&N(e.message,{tone:`danger`})},_=r({mutationFn:t=>b(e).then(e=>({result:e,request:t})),onSuccess:({result:e,request:t})=>h(e,t),onError:(e,t)=>g(e,t)}),v=r({mutationFn:t=>C(e).then(e=>({result:e,request:t})),onSuccess:({result:e,request:t})=>h(e,t),onError:(e,t)=>g(e,t)}),y=e=>{let n=++l.current;e===`apply`?v.mutate({action:e,seq:n,previousUpdatedAt:t?.updatedAt??null}):_.mutate({action:e,seq:n})},x=t?.scopes.some(e=>e.skills.length>0)??!1,w=t?.status===`error`,E=x&&(t?.available||w),D=v.isPending||t?.status===`updating`,O=t?.scopes.filter(e=>e.status===`error`||e.status===`unavailable`)??[],k=t?.scopes.filter(e=>e.updatedAt&&!O.includes(e))??[],A=`Checking installed Open Mercato skills…`;return n?A=`Update status is unavailable right now.`:t?.status===`available`?A=`An update is available for your installed Open Mercato skills.`:t?.status===`updating`?A=`Updating installed Open Mercato skills…`:t?.status===`current`?A=`Installed Open Mercato skills are up to date.`:t?.status===`unavailable`?A=t.scopes.find(e=>e.reason)?.reason??`Automatic updates are unavailable.`:t?.status===`error`&&(A=`The update did not finish for every installation.`),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`section`,{"data-slot":`skills-update-card`,"aria-live":`polite`,className:`mt-4 rounded-lg border border-border bg-background p-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col items-start gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`p`,{className:`text-[13px] font-medium text-foreground`,children:A}),(0,J.jsx)(`p`,{className:`mt-4 text-xs text-soft-foreground`,children:`Project and global installations are checked separately.`}),t?.checkedAt?(0,J.jsxs)(`p`,{className:`mt-1 text-xs text-soft-foreground`,children:[`Last checked `,new Date(t.checkedAt).toLocaleString(),`.`]}):null,t?.scopes.some(e=>e.skills.length>0)?(0,J.jsx)(`ul`,{className:`mt-1 text-xs text-soft-foreground`,children:t.scopes.filter(e=>e.skills.length>0).map(e=>(0,J.jsxs)(`li`,{children:[Z(e.scope),` · `,e.skills.length,` tracked`]},e.scope))}):null,O.length>0?(0,J.jsxs)(`p`,{className:`mt-1 text-xs text-destructive`,children:[`Failed: `,O.map(e=>Z(e.scope)).join(`, `),k.length?`; updated: ${k.map(e=>Z(e.scope)).join(`, `)}`:``,`.`]}):null]}),E?(0,J.jsxs)(S,{"data-action":`skills-update-apply`,size:`sm`,disabled:D,onClick:()=>y(`apply`),children:[(0,J.jsx)(u,{"aria-hidden":`true`,className:F(`size-3.5`,D&&`motion-safe:animate-spin`)}),D?`Updating…`:w?`Retry`:`Update now`]}):t?.status===`current`?(0,J.jsxs)(S,{"data-action":`skills-update-check`,variant:`outline`,size:`sm`,disabled:_.isPending,onClick:()=>y(`check`),children:[(0,J.jsx)(u,{"aria-hidden":`true`,className:`size-4`}),`Check again`]}):t?.status===`unavailable`||n?(0,J.jsx)(S,{"data-action":`skills-update-check`,variant:`outline`,size:`sm`,disabled:_.isPending,onClick:()=>y(`check`),children:`Retry check`}):null]}),t?.status===`unavailable`||n?(0,J.jsxs)(`div`,{className:`mt-2 text-xs text-soft-foreground`,children:[`Manual examples: `,(0,J.jsx)(`code`,{children:`npx skills update -p`}),` · `,(0,J.jsx)(`code`,{children:`npx skills update -g`}),`. These broad commands may update other tracked sources.`]}):null,t?.needsUpgradeNotes?(0,J.jsxs)(`div`,{"data-slot":`skills-upgrade-notes`,className:`mt-3 flex gap-2 rounded-md border border-accent-strong/30 bg-background p-2.5 text-xs text-foreground`,children:[(0,J.jsx)(d,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-link-foreground`}),(0,J.jsxs)(`span`,{children:[`Skill files were updated. Run `,(0,J.jsx)(`code`,{children:`/om-apply-upgrade-notes`}),` in each configured repository to apply descriptor migrations while preserving local edits.`]})]}):null]}),(0,J.jsx)(ne,{open:f,onOpenChange:e=>m.isPending?void 0:p(e),children:(0,J.jsxs)(ie,{"data-slot":`skills-upgrade-notes-dialog`,showCloseButton:!1,children:[(0,J.jsxs)(re,{children:[(0,J.jsx)(ae,{children:`Apply the upgrade notes now?`}),(0,J.jsxs)(te,{children:[`The skill files were updated successfully. Start a new session with`,` `,(0,J.jsx)(`code`,{children:`/om-apply-upgrade-notes`}),` to sync repository descriptors while preserving local edits?`]})]}),(0,J.jsxs)(ee,{children:[(0,J.jsx)(S,{type:`button`,variant:`outline`,disabled:m.isPending,onClick:()=>p(!1),children:`No`}),(0,J.jsx)(S,{type:`button`,disabled:m.isPending,onClick:()=>m.mutate(),children:m.isPending?`Starting…`:`Yes, start session`})]})]})})]})}var Q=`__bm`,$=`__import`;function de(){return(0,J.jsx)(`div`,{"data-route":`skills`,className:`mx-auto min-h-full w-full px-[18px] py-6 md:p-9`,children:(0,J.jsx)(fe,{})})}function fe(){let e=w(),t=i(),n=D(),[a]=P(),[o,c]=(0,q.useState)(``),l=s(),d=g(),p=O().projectId??d.data?.bootProject??``,_=r({mutationFn:()=>x(),onSuccess:e=>{l.setQueryData(T.skills,e),N(`Team skills refreshed.`)},onError:e=>N(e.message,{tone:`danger`})});if(e.isError)return(0,J.jsx)(M,{icon:(0,J.jsx)(v,{}),tone:`danger`,heading:`h2`,title:`Could not load skills`,subtitle:e.error.message});let y=V(e.data??[]),b=(n.data?.length??0)>0,S=a.get(`skill`),C=S===Q||S===$||S!==null&&y.some(e=>e.name===S)?S:y[0]?.name??(b?$:Q),E=y.find(e=>e.name===C)??null,A=B(y,o);return(0,J.jsxs)(`div`,{"data-slot":`skills-section`,className:`@container flex min-w-0 flex-col gap-[22px]`,children:[(0,J.jsxs)(`header`,{className:`flex flex-col gap-4 @min-[700px]:flex-row @min-[700px]:items-center @min-[700px]:justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h1`,{className:`text-[25px] font-semibold md:text-[30px]`,children:`Skills`}),(0,J.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground md:text-[13px]`,children:`Markdown playbooks your agents can follow.`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[b?(0,J.jsxs)(L,{to:`/skills?skill=${$}`,"data-slot":`import-skills-row`,"aria-current":C===$?`page`:void 0,className:`inline-flex min-h-11 items-center gap-2 rounded-lg border border-border bg-card px-3 text-xs font-medium aria-[current=page]:bg-accent-strong/10 hover:bg-muted focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,J.jsx)(j,{"aria-hidden":`true`,className:`size-4 text-link-foreground`}),`Manage skills`]}):null,(0,J.jsxs)(L,{to:`/skills?skill=${Q}`,"data-slot":`bookmarklets-row`,"aria-current":C===Q?`page`:void 0,className:`inline-flex min-h-11 items-center gap-2 rounded-lg border border-border bg-card px-3 text-xs font-medium aria-[current=page]:bg-accent-strong/10 hover:bg-muted focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,J.jsx)(k,{"aria-hidden":`true`,className:`size-4 text-link-foreground`}),`Run from GitHub`]})]})]}),(0,J.jsxs)(`div`,{className:F(`flex-col items-start gap-2 sm:flex-row sm:items-center md:flex`,S===null?`flex`:`hidden`),children:[(0,J.jsxs)(`div`,{className:`sw-search relative w-full min-w-0 flex-1`,children:[(0,J.jsx)(f,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,J.jsx)(W,{"data-slot":`skills-filter`,placeholder:`Filter skills…`,"aria-label":`Filter skills`,value:o,onChange:e=>c(e.target.value),className:`h-11 min-w-0 bg-card pl-9 text-xs`})]}),(0,J.jsxs)(`button`,{type:`button`,"data-slot":`skills-refresh`,title:`git fetch the team skills repos`,disabled:_.isPending,onClick:()=>_.mutate(),className:`flex h-11 shrink-0 items-center gap-1.5 rounded-md border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-55`,children:[(0,J.jsx)(u,{"aria-hidden":`true`,className:F(`size-3`,_.isPending&&`motion-safe:animate-spin`)}),`Refresh`]})]}),(0,J.jsxs)(`div`,{className:`grid min-w-0 items-start gap-[22px] md:grid-cols-[minmax(220px,310px)_minmax(0,1fr)]`,children:[(0,J.jsx)(`section`,{"data-slot":`skills-list`,className:F(`min-w-0 flex-col rounded-xl border border-border bg-card p-3 md:flex`,S===null?`flex`:`hidden`),children:(0,J.jsx)(`ul`,{"data-slot":`skill-rows`,className:`flex min-h-0 flex-col gap-1 overflow-y-auto md:max-h-[calc(100dvh-280px)]`,children:e.isPending?(0,J.jsx)(`li`,{role:`status`,"aria-busy":`true`,className:`min-h-72 p-3 text-[13px] text-soft-foreground`,children:`Loading skills…`}):A.length>0?A.map(e=>(0,J.jsx)(pe,{skill:e,active:C===e.name,highlighted:C===$&&e===y[0]},e.path)):(0,J.jsx)(`li`,{className:`px-2.5 py-2 text-xs leading-relaxed text-soft-foreground`,children:y.length>0?`(no skills match)`:(0,J.jsx)(se,{})})})}),(0,J.jsx)(`section`,{"data-slot":`skills-detail`,className:F(`min-w-0 flex-col rounded-xl border border-border bg-card md:flex`,S===null?`hidden`:`flex`),children:(0,J.jsxs)(`div`,{className:`min-w-0 p-5`,children:[(0,J.jsxs)(L,{to:`/skills`,"data-slot":`skills-back`,className:`mb-4 inline-flex min-h-11 items-center gap-2 rounded-lg border border-border px-3 text-xs font-medium hover:bg-muted md:hidden`,children:[(0,J.jsx)(m,{"aria-hidden":`true`,className:`size-3.5`}),`Back to skills`]}),C===$?(0,J.jsx)(le,{projectId:p}):C===Q?(0,J.jsx)(K,{skills:y}):E?(0,J.jsx)(G,{skill:E,usedBy:H(t.data?.workflows??[],E.name)}):e.isPending?(0,J.jsx)(`div`,{role:`status`,"aria-busy":`true`,className:`min-h-72 text-xs text-muted-foreground`,children:`Loading skill…`}):(0,J.jsx)(M,{icon:(0,J.jsx)(h,{}),tone:`neutral`,heading:`h2`,title:`No skill selected`,subtitle:`Pick a skill from the catalog.`})]})})]})]})}function pe({skill:e,active:t,highlighted:n}){let r=R(e);return(0,J.jsx)(`li`,{children:(0,J.jsxs)(L,{to:`/skills?skill=${encodeURIComponent(e.name)}`,"data-slot":`skill-row`,"data-skill":e.name,"data-highlighted":n||void 0,"data-project":r?`true`:void 0,"aria-current":t?`page`:void 0,className:F(`selection-row flex min-h-24 flex-col gap-2 rounded-lg border-b border-border p-3 transition-colors hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,(t||n)&&`border-transparent bg-accent-strong/10`),children:[(0,J.jsx)(`span`,{className:`flex min-w-0 items-center gap-2`,children:(0,J.jsx)(`span`,{className:F(`min-w-0 break-words text-[13px]`,r?`font-semibold text-foreground`:`font-normal text-muted-foreground`),children:e.name})}),e.description?(0,J.jsx)(`span`,{className:`line-clamp-2 text-xs leading-relaxed text-supporting-foreground`,children:e.description}):null,(0,J.jsx)(U,{source:e.source,className:`self-start border-0 bg-transparent p-0 text-link-foreground`})]})})}export{de as SkillsRoute};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ba as r,Cr as i,Dr as a,Ei as o,Ga as s,Gt as c,It as l,Lt as u,Q as d,Rt as f,Tr as p,U as m,Ut as h,Vn as g,Wt as _,Yt as v,_r as y,bi as b,ca as x,d as S,fi as C,gr as w,in as T,jt as E,kn as D,li as O,nn as k,oa as A,ot as j,t as M,ya as N,za as P}from"./centered-state-kOb8j_BL.js";import{t as F}from"./utils-BW1-Ibnd.js";import{a as ee,i as te,n as ne,o as re,r as ie,s as ae}from"./textarea-D2Gx4GDI.js";import{T as oe}from"./prompt-templates-BgXzCOlY.js";import{c as I,t as L}from"./project-router-CS_oeLqi.js";import{i as R,l as z,n as B,o as V,p as H}from"./skills-DFBiAuJG.js";import{c as U,h as W,o as G,t as K}from"./index-GcasY1jB.js";import{t as se}from"./skill-empty-hint-oOtzR3v0.js";var q=e(t(),1),J=n(),Y=`https://github.com/open-mercato/skills`;function ce(e){let t=e?.importedSkills;if(Array.isArray(t))return t.filter(e=>typeof e==`string`&&!!e)}function X(e,t){return ce(e)??[...t]}function le({projectId:e}){let t=s(),n=p(),r=D(),[i,o]=(0,q.useState)(``),u=y(e,!!e),d=r.data??[],m=(0,q.useMemo)(()=>d.map(e=>e.name),[d]),h=(0,q.useRef)([]);h.current=m;let g=(0,q.useMemo)(()=>new Set(X(n.data,m)),[n.data,m]),b=(0,q.useRef)(Promise.resolve()),x=(0,q.useRef)(0),S=(0,q.useCallback)(e=>{let n=a.uiState,r=t.getQueryData(n),i=e(X(r,h.current));t.setQueryData(n,{...r,importedSkills:i});let o=++x.current;b.current=b.current.then(async()=>{try{let e=await A({importedSkills:i});o===x.current&&(t.setQueryData(n,e),t.invalidateQueries({queryKey:T.skills}))}catch(e){N(e instanceof Error?e.message:String(e),{tone:`danger`}),o===x.current&&t.invalidateQueries({queryKey:n})}})},[t]),C=(0,q.useCallback)(e=>{S(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[S]),w=m.length>0&&m.every(e=>g.has(e)),O=(0,q.useCallback)(()=>{if(w){let e=new Set(h.current);S(t=>t.filter(t=>!e.has(t)))}else S(e=>[...new Set([...e,...h.current])])},[w,S]);if(r.isError)return(0,J.jsx)(M,{icon:(0,J.jsx)(v,{}),tone:`danger`,heading:`h2`,title:`Could not load importable skills`,subtitle:r.error.message});let k=z(d,i);return(0,J.jsxs)(`div`,{"data-slot":`skills-import-panel`,className:`w-full min-w-0 [&_button]:min-h-11`,children:[(0,J.jsx)(`p`,{className:`mb-4 text-[12px] font-medium tracking-wide text-link-foreground`,children:`OPEN-MERCATO / SKILLS`}),(0,J.jsx)(`h2`,{className:`text-2xl font-medium`,children:`Manage skills`}),(0,J.jsxs)(`p`,{className:`mt-2 text-[13px] leading-relaxed text-muted-foreground`,children:[`Choose which `,(0,J.jsx)(`a`,{href:Y,target:`_blank`,rel:`noreferrer`,children:`open-mercato`}),` skills appear in your catalog and composer picker. All are enabled by default; uncheck any you don’t want.`]}),(0,J.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Applies across projects · saved automatically`}),(0,J.jsx)(ue,{projectId:e,state:u.data,loadError:u.error}),(0,J.jsx)(`p`,{className:`mt-4 text-xs text-soft-foreground`,children:`Checkboxes control visibility. Updating refreshes installed skill files; it does not change your selection.`}),(0,J.jsxs)(`div`,{className:`sw-import-controls mt-4 flex flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`div`,{className:`sw-search relative min-w-0 flex-1`,children:[(0,J.jsx)(f,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,J.jsx)(W,{"data-slot":`import-filter`,placeholder:`Filter skills…`,"aria-label":`Filter skills`,value:i,onChange:e=>o(e.target.value),className:`h-11 min-w-0 pl-9 text-xs`})]}),(0,J.jsxs)(`button`,{type:`button`,"data-slot":`import-all`,disabled:m.length===0||n.isPending,onClick:O,className:`h-11 shrink-0 rounded-md border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-55`,children:[w?(0,J.jsx)(E,{"aria-hidden":`true`,className:`size-4`}):(0,J.jsx)(l,{"aria-hidden":`true`,className:`size-4`}),w?`Remove all`:`Enable all`]})]}),(0,J.jsx)(`div`,{"data-slot":`import-list`,className:`mt-3 flex flex-col gap-1.5`,children:r.isPending?(0,J.jsx)(`p`,{className:`px-1 py-2 text-[13px] text-soft-foreground`,children:`Loading…`}):k.length>0?k.map(e=>{let t=g.has(e.name);return(0,J.jsxs)(`label`,{"data-slot":`import-row`,"data-skill":e.name,"data-imported":t?`true`:void 0,className:F(`flex min-h-16 cursor-pointer items-start gap-3 rounded-lg border border-border p-4 transition-colors hover:bg-muted`,t&&`bg-background`),children:[(0,J.jsxs)(`span`,{className:`relative size-5 shrink-0`,children:[(0,J.jsx)(`input`,{type:`checkbox`,"data-slot":`import-toggle`,checked:t,onChange:()=>C(e.name),className:`peer absolute inset-0 m-0 size-5 opacity-0`}),t?(0,J.jsx)(_,{"aria-hidden":`true`,className:`pointer-events-none size-5 text-link-foreground peer-focus-visible:outline-2 peer-focus-visible:outline-ring`}):(0,J.jsx)(c,{"aria-hidden":`true`,className:`pointer-events-none size-5 text-link-foreground peer-focus-visible:outline-2 peer-focus-visible:outline-ring`})]}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`span`,{className:`flex min-w-0 items-center gap-2`,children:(0,J.jsx)(`span`,{className:`min-w-0 break-words text-[13px] font-medium text-foreground`,children:e.name})}),e.description?(0,J.jsx)(`span`,{className:`mt-2 block text-xs leading-relaxed text-soft-foreground`,children:e.description}):null]})]},e.name)}):(0,J.jsx)(`p`,{className:`px-1 py-2 text-xs text-soft-foreground`,children:d.length>0?`(no skills match)`:`(no skills available — the repo may still be cloning)`})})]})}function Z(e){return e===`project`?`Project installation`:`Global installation`}function ue({projectId:e,state:t,loadError:n}){let i=s(),c=I(),l=(0,q.useRef)(0),[f,p]=(0,q.useState)(!1),m=r({mutationFn:()=>o({task:`Apply the upgrade notes after updating the installed Open Mercato skills.`,steps:[{id:`apply-upgrade-notes`,name:`Apply upgrade notes`,skill:`om-apply-upgrade-notes`,prompt:`{{task}}`}]}),onSuccess:e=>{p(!1),c(oe(e))},onError:e=>N(e.message,{tone:`danger`})}),h=(t,n)=>{n.seq===l.current&&(i.setQueryData(a.skillsUpdate(e),t),n.action===`apply`&&t.updatedAt&&t.updatedAt!==n.previousUpdatedAt&&(i.invalidateQueries({queryKey:T.skills}),N(t.status===`error`?`Some skill updates failed.`:`Open Mercato skills updated.`),p(!0)))},g=(e,t)=>{t.seq===l.current&&N(e.message,{tone:`danger`})},_=r({mutationFn:t=>b(e).then(e=>({result:e,request:t})),onSuccess:({result:e,request:t})=>h(e,t),onError:(e,t)=>g(e,t)}),v=r({mutationFn:t=>C(e).then(e=>({result:e,request:t})),onSuccess:({result:e,request:t})=>h(e,t),onError:(e,t)=>g(e,t)}),y=e=>{let n=++l.current;e===`apply`?v.mutate({action:e,seq:n,previousUpdatedAt:t?.updatedAt??null}):_.mutate({action:e,seq:n})},x=t?.scopes.some(e=>e.skills.length>0)??!1,w=t?.status===`error`,E=x&&(t?.available||w),D=v.isPending||t?.status===`updating`,O=t?.scopes.filter(e=>e.status===`error`||e.status===`unavailable`)??[],k=t?.scopes.filter(e=>e.updatedAt&&!O.includes(e))??[],A=`Checking installed Open Mercato skills…`;return n?A=`Update status is unavailable right now.`:t?.status===`available`?A=`An update is available for your installed Open Mercato skills.`:t?.status===`updating`?A=`Updating installed Open Mercato skills…`:t?.status===`current`?A=`Installed Open Mercato skills are up to date.`:t?.status===`unavailable`?A=t.scopes.find(e=>e.reason)?.reason??`Automatic updates are unavailable.`:t?.status===`error`&&(A=`The update did not finish for every installation.`),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`section`,{"data-slot":`skills-update-card`,"aria-live":`polite`,className:`mt-4 rounded-lg border border-border bg-background p-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col items-start gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`p`,{className:`text-[13px] font-medium text-foreground`,children:A}),(0,J.jsx)(`p`,{className:`mt-4 text-xs text-soft-foreground`,children:`Project and global installations are checked separately.`}),t?.checkedAt?(0,J.jsxs)(`p`,{className:`mt-1 text-xs text-soft-foreground`,children:[`Last checked `,new Date(t.checkedAt).toLocaleString(),`.`]}):null,t?.scopes.some(e=>e.skills.length>0)?(0,J.jsx)(`ul`,{className:`mt-1 text-xs text-soft-foreground`,children:t.scopes.filter(e=>e.skills.length>0).map(e=>(0,J.jsxs)(`li`,{children:[Z(e.scope),` · `,e.skills.length,` tracked`]},e.scope))}):null,O.length>0?(0,J.jsxs)(`p`,{className:`mt-1 text-xs text-destructive`,children:[`Failed: `,O.map(e=>Z(e.scope)).join(`, `),k.length?`; updated: ${k.map(e=>Z(e.scope)).join(`, `)}`:``,`.`]}):null]}),E?(0,J.jsxs)(S,{"data-action":`skills-update-apply`,size:`sm`,disabled:D,onClick:()=>y(`apply`),children:[(0,J.jsx)(u,{"aria-hidden":`true`,className:F(`size-3.5`,D&&`motion-safe:animate-spin`)}),D?`Updating…`:w?`Retry`:`Update now`]}):t?.status===`current`?(0,J.jsxs)(S,{"data-action":`skills-update-check`,variant:`outline`,size:`sm`,disabled:_.isPending,onClick:()=>y(`check`),children:[(0,J.jsx)(u,{"aria-hidden":`true`,className:`size-4`}),`Check again`]}):t?.status===`unavailable`||n?(0,J.jsx)(S,{"data-action":`skills-update-check`,variant:`outline`,size:`sm`,disabled:_.isPending,onClick:()=>y(`check`),children:`Retry check`}):null]}),t?.status===`unavailable`||n?(0,J.jsxs)(`div`,{className:`mt-2 text-xs text-soft-foreground`,children:[`Manual examples: `,(0,J.jsx)(`code`,{children:`npx skills update -p`}),` · `,(0,J.jsx)(`code`,{children:`npx skills update -g`}),`. These broad commands may update other tracked sources.`]}):null,t?.needsUpgradeNotes?(0,J.jsxs)(`div`,{"data-slot":`skills-upgrade-notes`,className:`mt-3 flex gap-2 rounded-md border border-accent-strong/30 bg-background p-2.5 text-xs text-foreground`,children:[(0,J.jsx)(d,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0 text-link-foreground`}),(0,J.jsxs)(`span`,{children:[`Skill files were updated. Run `,(0,J.jsx)(`code`,{children:`/om-apply-upgrade-notes`}),` in each configured repository to apply descriptor migrations while preserving local edits.`]})]}):null]}),(0,J.jsx)(ne,{open:f,onOpenChange:e=>m.isPending?void 0:p(e),children:(0,J.jsxs)(ie,{"data-slot":`skills-upgrade-notes-dialog`,showCloseButton:!1,children:[(0,J.jsxs)(re,{children:[(0,J.jsx)(ae,{children:`Apply the upgrade notes now?`}),(0,J.jsxs)(te,{children:[`The skill files were updated successfully. Start a new session with`,` `,(0,J.jsx)(`code`,{children:`/om-apply-upgrade-notes`}),` to sync repository descriptors while preserving local edits?`]})]}),(0,J.jsxs)(ee,{children:[(0,J.jsx)(S,{type:`button`,variant:`outline`,disabled:m.isPending,onClick:()=>p(!1),children:`No`}),(0,J.jsx)(S,{type:`button`,disabled:m.isPending,onClick:()=>m.mutate(),children:m.isPending?`Starting…`:`Yes, start session`})]})]})})]})}var Q=`__bm`,$=`__import`;function de(){return(0,J.jsx)(`div`,{"data-route":`skills`,className:`mx-auto min-h-full w-full px-[18px] py-6 md:p-9`,children:(0,J.jsx)(fe,{})})}function fe(){let e=w(),t=i(),n=D(),[a]=P(),[o,c]=(0,q.useState)(``),l=s(),d=g(),p=O().projectId??d.data?.bootProject??``,_=r({mutationFn:()=>x(),onSuccess:e=>{l.setQueryData(T.skills,e),N(`Team skills refreshed.`)},onError:e=>N(e.message,{tone:`danger`})});if(e.isError)return(0,J.jsx)(M,{icon:(0,J.jsx)(v,{}),tone:`danger`,heading:`h2`,title:`Could not load skills`,subtitle:e.error.message});let y=V(e.data??[]),b=(n.data?.length??0)>0,S=a.get(`skill`),C=S===Q||S===$||S!==null&&y.some(e=>e.name===S)?S:y[0]?.name??(b?$:Q),E=y.find(e=>e.name===C)??null,A=B(y,o);return(0,J.jsxs)(`div`,{"data-slot":`skills-section`,className:`@container flex min-w-0 flex-col gap-[22px]`,children:[(0,J.jsxs)(`header`,{className:`flex flex-col gap-4 @min-[700px]:flex-row @min-[700px]:items-center @min-[700px]:justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h1`,{className:`text-[25px] font-semibold md:text-[30px]`,children:`Skills`}),(0,J.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground md:text-[13px]`,children:`Markdown playbooks your agents can follow.`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[b?(0,J.jsxs)(L,{to:`/skills?skill=${$}`,"data-slot":`import-skills-row`,"aria-current":C===$?`page`:void 0,className:`inline-flex min-h-11 items-center gap-2 rounded-lg border border-border bg-card px-3 text-xs font-medium aria-[current=page]:bg-accent-strong/10 hover:bg-muted focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,J.jsx)(j,{"aria-hidden":`true`,className:`size-4 text-link-foreground`}),`Manage skills`]}):null,(0,J.jsxs)(L,{to:`/skills?skill=${Q}`,"data-slot":`bookmarklets-row`,"aria-current":C===Q?`page`:void 0,className:`inline-flex min-h-11 items-center gap-2 rounded-lg border border-border bg-card px-3 text-xs font-medium aria-[current=page]:bg-accent-strong/10 hover:bg-muted focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,J.jsx)(k,{"aria-hidden":`true`,className:`size-4 text-link-foreground`}),`Run from GitHub`]})]})]}),(0,J.jsxs)(`div`,{className:F(`flex-col items-start gap-2 sm:flex-row sm:items-center md:flex`,S===null?`flex`:`hidden`),children:[(0,J.jsxs)(`div`,{className:`sw-search relative w-full min-w-0 flex-1`,children:[(0,J.jsx)(f,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,J.jsx)(W,{"data-slot":`skills-filter`,placeholder:`Filter skills…`,"aria-label":`Filter skills`,value:o,onChange:e=>c(e.target.value),className:`h-11 min-w-0 bg-card pl-9 text-xs`})]}),(0,J.jsxs)(`button`,{type:`button`,"data-slot":`skills-refresh`,title:`git fetch the team skills repos`,disabled:_.isPending,onClick:()=>_.mutate(),className:`flex h-11 shrink-0 items-center gap-1.5 rounded-md border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-55`,children:[(0,J.jsx)(u,{"aria-hidden":`true`,className:F(`size-3`,_.isPending&&`motion-safe:animate-spin`)}),`Refresh`]})]}),(0,J.jsxs)(`div`,{className:`grid min-w-0 items-start gap-[22px] md:grid-cols-[minmax(220px,310px)_minmax(0,1fr)]`,children:[(0,J.jsx)(`section`,{"data-slot":`skills-list`,className:F(`min-w-0 flex-col rounded-xl border border-border bg-card p-3 md:flex`,S===null?`flex`:`hidden`),children:(0,J.jsx)(`ul`,{"data-slot":`skill-rows`,className:`flex min-h-0 flex-col gap-1 overflow-y-auto md:max-h-[calc(100dvh-280px)]`,children:e.isPending?(0,J.jsx)(`li`,{role:`status`,"aria-busy":`true`,className:`min-h-72 p-3 text-[13px] text-soft-foreground`,children:`Loading skills…`}):A.length>0?A.map(e=>(0,J.jsx)(pe,{skill:e,active:C===e.name,highlighted:C===$&&e===y[0]},e.path)):(0,J.jsx)(`li`,{className:`px-2.5 py-2 text-xs leading-relaxed text-soft-foreground`,children:y.length>0?`(no skills match)`:(0,J.jsx)(se,{})})})}),(0,J.jsx)(`section`,{"data-slot":`skills-detail`,className:F(`min-w-0 flex-col rounded-xl border border-border bg-card md:flex`,S===null?`hidden`:`flex`),children:(0,J.jsxs)(`div`,{className:`min-w-0 p-5`,children:[(0,J.jsxs)(L,{to:`/skills`,"data-slot":`skills-back`,className:`mb-4 inline-flex min-h-11 items-center gap-2 rounded-lg border border-border px-3 text-xs font-medium hover:bg-muted md:hidden`,children:[(0,J.jsx)(m,{"aria-hidden":`true`,className:`size-3.5`}),`Back to skills`]}),C===$?(0,J.jsx)(le,{projectId:p}):C===Q?(0,J.jsx)(K,{skills:y}):E?(0,J.jsx)(G,{skill:E,usedBy:H(t.data?.workflows??[],E.name)}):e.isPending?(0,J.jsx)(`div`,{role:`status`,"aria-busy":`true`,className:`min-h-72 text-xs text-muted-foreground`,children:`Loading skill…`}):(0,J.jsx)(M,{icon:(0,J.jsx)(h,{}),tone:`neutral`,heading:`h2`,title:`No skill selected`,subtitle:`Pick a skill from the catalog.`})]})})]})]})}function pe({skill:e,active:t,highlighted:n}){let r=R(e);return(0,J.jsx)(`li`,{children:(0,J.jsxs)(L,{to:`/skills?skill=${encodeURIComponent(e.name)}`,"data-slot":`skill-row`,"data-skill":e.name,"data-highlighted":n||void 0,"data-project":r?`true`:void 0,"aria-current":t?`page`:void 0,className:F(`selection-row flex min-h-24 flex-col gap-2 rounded-lg border-b border-border p-3 transition-colors hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,(t||n)&&`border-transparent bg-accent-strong/10`),children:[(0,J.jsx)(`span`,{className:`flex min-w-0 items-center gap-2`,children:(0,J.jsx)(`span`,{className:F(`min-w-0 break-words text-[13px]`,r?`font-semibold text-foreground`:`font-normal text-muted-foreground`),children:e.name})}),e.description?(0,J.jsx)(`span`,{className:`line-clamp-2 text-xs leading-relaxed text-supporting-foreground`,children:e.description}):null,(0,J.jsx)(U,{source:e.source,className:`self-start border-0 bg-transparent p-0 text-link-foreground`})]})})}export{de as SkillsRoute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$r as r,Ba as i,Di as a,Dn as o,Ga as s,Hi as c,Ji as l,Qn as u,Ra as d,Xi as f,_t as p,d as m,fa as h,in as g,lt as _,na as v,nr as y,rr as b,t as x,ui as S,xi as C,ya as w}from"./centered-state-kOb8j_BL.js";import{a as T,i as E,n as D,o as O,r as k,s as A,t as j}from"./textarea-D2Gx4GDI.js";import{d as M,m as N}from"./pill-0JHCf1v8.js";import{t as P}from"./run-header-BBQOWhJ7.js";import{i as F,n as I,r as L}from"./git-toolbar-DFC6bS8a.js";import{t as R}from"./use-submit-shortcut-KWJsC906.js";import{n as z,r as B}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$r as r,Ba as i,Di as a,Dn as o,Ga as s,Hi as c,Ji as l,Qn as u,Ra as d,Xi as f,_t as p,d as m,fa as h,in as g,lt as _,na as v,nr as y,rr as b,t as x,ui as S,xi as C,ya as w}from"./centered-state-kOb8j_BL.js";import{a as T,i as E,n as D,o as O,r as k,s as A,t as j}from"./textarea-D2Gx4GDI.js";import{d as M,m as N}from"./pill-0JHCf1v8.js";import{t as P}from"./run-header-BBQOWhJ7.js";import{i as F,n as I,r as L}from"./git-toolbar-DFC6bS8a.js";import{t as R}from"./use-submit-shortcut-KWJsC906.js";import{n as z,r as B}from"./index-GcasY1jB.js";import{t as ee}from"./diff-Jd8igxRb2.js";import{t as te}from"./use-desktop-BaYgO7YW.js";var V=e(t(),1),H=e=>e===`running`||e===`queued`||e===`waiting`,U=`no worktree — this task ran directly in the repo working tree`;function W(e){let t=e=>({id:`commit`,label:`Commit`,enabled:!1,reason:e});return e.hasWorktree?e.status===`running`?t(`Commit unavailable — the agent is still working in this worktree`):e.changedFiles===void 0?t(`Commit unavailable — changes are still loading`):e.changedFiles===0?t(`Commit unavailable — no changes to commit`):{id:`commit`,label:`Commit`,enabled:!0}:t(`Commit unavailable — ${U}`)}function G(e){let t=e=>({id:`push`,label:`Push`,enabled:!1,reason:e});return e.hasWorktree?e.remote===void 0?t(`Push unavailable — no remote configured`):e.branch===void 0?t(`Push unavailable — the run has no branch to push`):e.status===`running`?t(`Push unavailable — the agent is still working in this worktree`):{id:`push`,label:`Push`,enabled:!0}:t(`Push unavailable — ${U}`)}function K(e){let t=e=>({id:`create-pr`,label:`Create PR`,enabled:!1,reason:e});return!e.hasWorktree||e.branch===void 0?t(`Create PR unavailable — ${U}`):e.forge===null?t(`Create PR unavailable — no supported forge remote (GitHub) detected`):e.forge.available?H(e.status)?t(`Create PR unavailable — the run is still active; wait for the review gate`):{id:`create-pr`,label:`Create PR`,enabled:!0}:t(`Create PR unavailable — ${e.forge.reason??`the forge is unreachable`}`)}function q(e){let t=e.prUrl?{id:`view-pr`,label:`View PR`,enabled:!0,href:e.prUrl}:W(e),n=e.prUrl?[W(e),G(e)]:[G(e),K(e)],r=[];if(e.localHandoff){let t=e.hasSession?H(e.status)?{id:`open-terminal`,label:`Open in terminal`,enabled:!1,reason:`Terminal unavailable — the session is still active in the engine`}:{id:`open-terminal`,label:`Open in terminal`,enabled:!0}:{id:`open-terminal`,label:`Open in terminal`,enabled:!1,reason:`Terminal unavailable — no agent session to resume`};r.push(t)}return{primary:t,secondary:n,menu:r}}var J=n();function Y({run:e,open:t,onOpenChange:n}){let a=s(),[o,c]=(0,V.useState)(``),l=r(e),u=(0,V.useRef)(l);u.current=l,(0,V.useEffect)(()=>{t&&c(u.current)},[t]);let d=i({mutationFn:t=>C(e.id,t),onSuccess:t=>{w(`Committed ${t.sha.slice(0,7)}`),n(!1),a.invalidateQueries({queryKey:g.runs.changes(e.id)}),a.invalidateQueries({queryKey:g.runs.all})},onError:e=>w(e.message,{tone:`danger`})}),f=()=>{let e=o.trim();e.length===0||d.isPending||d.mutate(e)};return(0,J.jsx)(D,{open:t,onOpenChange:n,children:(0,J.jsxs)(k,{"data-slot":`commit-dialog`,children:[(0,J.jsxs)(O,{children:[(0,J.jsx)(A,{children:`Commit changes`}),(0,J.jsxs)(E,{children:[`Stages everything in the task's worktree (git add -A) and commits to`,` `,e.branch?(0,J.jsx)(`span`,{className:`font-mono`,children:e.branch}):`its branch`,`.`]})]}),(0,J.jsx)(j,{"data-slot":`commit-message`,"aria-label":`Commit message`,rows:3,value:o,onChange:e=>c(e.target.value),onKeyDown:e=>{R({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),f())}}),(0,J.jsxs)(T,{children:[(0,J.jsx)(m,{variant:`outline`,onClick:()=>n(!1),children:`Cancel`}),(0,J.jsx)(m,{"data-slot":`commit-confirm`,disabled:o.trim().length===0||d.isPending,onClick:f,children:d.isPending?`Committing…`:`Commit`})]})]})})}function X(){let{id:e}=d(),t=y(e);return t.isPending?(0,J.jsx)(B,{tab:`changes`}):t.isError?(0,J.jsx)(z,{tab:`changes`,error:t.error}):(0,J.jsx)(Z,{run:t.data})}function Z({run:e}){let t=o(),n=u(),r=b(e.id,M(e.status)),c=te(),[d,m]=(0,V.useState)(`unified`),[y,C]=(0,V.useState)(!1),[T,E]=(0,V.useState)(null),[D,O]=(0,V.useState)(!1),k=(0,V.useRef)(null),A=s(),j=()=>A.invalidateQueries({queryKey:g.runs.all}),R=e=>w(e.message,{tone:`danger`}),z=i({mutationFn:()=>v(e.id),onSuccess:e=>w(e.upstreamSet?`Pushed ${e.branch} to ${e.remote} (upstream set)`:`Pushed ${e.branch} to ${e.remote}`),onError:R}),B=i({mutationFn:()=>a(e.id),onSuccess:e=>{w(`Draft PR created — ${e.url}`),j()},onError:R}),H=i({mutationFn:()=>f(e.id),onError:e=>{if(e instanceof S&&e.command){navigator.clipboard.writeText(e.command).then(()=>w(`No terminal found — command copied to clipboard.`)).catch(()=>w(`Run manually: ${e.command}`));return}R(e)}}),U=i({mutationFn:t=>l(e.id,t),onError:R}),W=r.isError&&r.error instanceof S&&r.error.status===409,G=q({status:e.status,hasWorktree:!!e.worktreePath&&!W,branch:e.branch,changedFiles:r.data?.stat.files,remote:n.data?.info?.remote,forge:t.data?.forge??null,localHandoff:t.data?.capabilities.localHandoff??!1,hasSession:N(e)!==void 0,prUrl:e.pullRequestUrl}),K=e=>{switch(e){case`commit`:O(!0);break;case`push`:z.mutate();break;case`create-pr`:B.mutate();break;case`open-terminal`:H.mutate();break;case`view-pr`:break}},X=r.data?.files??[],Z=(0,V.useMemo)(()=>L(X),[X]),Q=c?d:`unified`,$=!c||y;return(0,J.jsxs)(`div`,{"data-route":`task-changes`,className:`flex min-h-full flex-col`,children:[(0,J.jsx)(P,{run:e,tab:`changes`}),(0,J.jsx)(I,{bar:G,branch:e.branch,stat:r.data?.stat,mode:Q,wrap:$,onModeChange:m,onWrapChange:C,onAction:K}),r.data?.repointedHead?(0,J.jsxs)(`p`,{"data-slot":`repointed-head-note`,className:`border-b px-4 py-2 text-xs text-soft-foreground md:px-9`,children:[`HEAD is on `,(0,J.jsx)(`code`,{children:r.data.repointedHead.headBranch}),`, not this task's branch`,` `,(0,J.jsx)(`code`,{children:r.data.repointedHead.taskBranch}),` — showing only what this task changed there.`]}):null,r.isPending?(0,J.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-9`,children:`Loading changes…`}):r.isError?(0,J.jsx)(x,{icon:W?(0,J.jsx)(_,{size:16}):(0,J.jsx)(p,{size:16}),tone:W?`neutral`:`danger`,heading:`h2`,title:W?`No changes to show`:`Could not load the changes`,subtitle:r.error.message}):X.length===0?(0,J.jsx)(x,{icon:(0,J.jsx)(_,{size:16}),tone:`neutral`,heading:`h2`,title:`No changes yet`,subtitle:`The worktree matches its base branch. Changes appear here as the agent works.`}):(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 md:flex-row md:items-start px-[18px] pb-9 pt-0 [--diff-sticky-top:0px] md:[--diff-sticky-top:1rem] md:px-9`,children:[(0,J.jsxs)(`aside`,{"data-slot":`changes-tree-pane`,className:`md:sticky md:top-4 max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] w-full md:w-60 shrink-0 overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 md:block lg:w-[250px]`,children:[(0,J.jsx)(`h2`,{className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,J.jsx)(F,{root:Z,selected:T,onSelect:e=>{E(e),k.current?.scrollToPath(e)}})]}),(0,J.jsx)(ee,{files:X,viewRef:k,mode:Q,wrap:$,loadFileText:t=>ne(e.id,t),imageSrc:t=>h(e.id,t),onOpenInApp:t.data?.capabilities.localHandoff?e=>U.mutate(e):void 0,className:`min-w-0 flex-1`})]}),(0,J.jsx)(Y,{run:e,open:D,onOpenChange:O})]})}async function ne(e,t){try{let n=await c(e,t);return n.type!==`file`||n.binary||n.tooLarge?null:n.content??null}catch{return null}}export{X as TaskChangesRoute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ra as r,U as i,Yt as a,_t as o,ar as s,ct as c,d as l,ir as u,nr as d,rr as f,t as p,ui as m}from"./centered-state-kOb8j_BL.js";import{d as h}from"./pill-0JHCf1v8.js";import{t as g}from"./run-header-BBQOWhJ7.js";import{n as _}from"./diff-controls-D_kgpdoa.js";import{t as v}from"./project-router-CS_oeLqi.js";import{t as y}from"./search-x-I9Q8pgUa.js";import{t as b}from"./diff-stat-C3Id3W_C.js";import{n as x,r as S}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ra as r,U as i,Yt as a,_t as o,ar as s,ct as c,d as l,ir as u,nr as d,rr as f,t as p,ui as m}from"./centered-state-kOb8j_BL.js";import{d as h}from"./pill-0JHCf1v8.js";import{t as g}from"./run-header-BBQOWhJ7.js";import{n as _}from"./diff-controls-D_kgpdoa.js";import{t as v}from"./project-router-CS_oeLqi.js";import{t as y}from"./search-x-I9Q8pgUa.js";import{t as b}from"./diff-stat-C3Id3W_C.js";import{n as x,r as S}from"./index-GcasY1jB.js";import{t as C}from"./diff-Jd8igxRb2.js";import{t as w}from"./use-desktop-BaYgO7YW.js";import{t as T}from"./commit-list-ihwhOiFP.js";var E=e(t(),1),D=n();function O(){let{id:e}=r(),t=d(e);return t.isPending?(0,D.jsx)(S,{tab:`changes`}):t.isError?(0,D.jsx)(x,{tab:`changes`,error:t.error}):(0,D.jsx)(k,{run:t.data})}function k({run:e}){let{sha:t}=r(),n=s(e.id,h(e.status));return(0,D.jsxs)(`div`,{"data-route":`task-commits`,className:`flex min-h-full flex-col`,children:[(0,D.jsx)(g,{run:e,tab:`commits`}),t?(0,D.jsx)(A,{runId:e.id,sha:t}):n.isPending?(0,D.jsx)(`p`,{"data-slot":`commits-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading commits…`}):n.isError?(0,D.jsx)(p,{icon:(0,D.jsx)(o,{size:16}),tone:n.error instanceof m&&n.error.status===409?`neutral`:`danger`,heading:`h2`,title:n.error instanceof m&&n.error.status===409?`No commits to show`:`Could not load the commits`,subtitle:n.error.message}):n.data.commits.length===0?(0,D.jsx)(p,{icon:(0,D.jsx)(o,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`This task hasn't committed anything on its branch. Autosave commits and any the agent makes appear here.`}):(0,D.jsxs)(`div`,{className:`px-[18px] py-[22px] md:px-9`,children:[(0,D.jsx)(T,{slot:`task-commits`,heading:(0,D.jsxs)(`h2`,{className:`text-base font-semibold`,children:[n.data.commits.length,` `,n.data.commits.length===1?`commit`:`commits`,` in this task`]}),className:`w-full`,commits:n.data.commits.map(t=>({...t,shaLabel:t.sha.slice(0,8),href:`/tasks/${e.id}/commits/${t.sha}`}))}),(0,D.jsx)(j,{run:e})]})]})}function A({runId:e,sha:t}){let n=u(e,t),r=w(),[s,c]=(0,E.useState)(`unified`),[d,f]=(0,E.useState)(!1),h=n.isError&&n.error instanceof m&&n.error.status===409,g=r?s:`unified`,x=!r||d;return(0,D.jsxs)(`section`,{"data-slot":`task-commit`,"data-sha":t,className:`mx-auto flex min-h-0 w-full max-w-[var(--measure)] flex-1 flex-col`,children:[(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-1.5 border-b border-border px-4 py-2 md:px-6`,children:[(0,D.jsx)(l,{asChild:!0,variant:`ghost`,size:`sm`,"data-slot":`commit-back`,children:(0,D.jsxs)(v,{to:`/tasks/${e}/commits`,children:[(0,D.jsx)(i,{size:16,"aria-hidden":`true`}),`All commits`]})}),n.data?(0,D.jsx)(b,{stat:n.data.stat}):null,(0,D.jsx)(`span`,{className:`ml-auto hidden items-center gap-1 md:flex`,children:(0,D.jsx)(_,{mode:s,wrap:d,onModeChange:c,onWrapChange:f})})]}),n.isPending?(0,D.jsx)(`p`,{"data-slot":`commit-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading commit…`}):n.isError?(0,D.jsx)(p,{icon:h?(0,D.jsx)(y,{}):(0,D.jsx)(a,{size:16}),tone:h?`neutral`:`danger`,heading:`h2`,title:h?`Commit not found`:`Could not load the commit`,subtitle:n.error.message}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{"data-slot":`commit-meta`,className:`border-b border-border px-4 py-3 md:px-6`,children:[(0,D.jsx)(`h2`,{className:`text-sm font-semibold`,children:n.data.subject}),(0,D.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-soft-foreground`,children:[n.data.author,` · `,n.data.when,` ·`,` `,(0,D.jsx)(`span`,{className:`font-mono select-all`,children:n.data.sha})]})]}),n.data.files.length===0?(0,D.jsx)(p,{icon:(0,D.jsx)(o,{size:16}),tone:`neutral`,heading:`h2`,title:`No file changes`,subtitle:`This commit carries no diff of its own — a merge commit's changes live on the commits it merged.`}):(0,D.jsx)(`div`,{className:`px-4 py-4 [--diff-sticky-top:0px] md:[--diff-sticky-top:1rem] md:px-6`,children:(0,D.jsx)(C,{files:n.data.files,mode:g,wrap:x,className:`min-w-0`})})]})]})}function j({run:e}){let t=f(e.id,h(e.status));return t.isPending?(0,D.jsx)(`p`,{className:`mt-[22px] text-xs text-muted-foreground`,children:`Loading changed files…`}):t.isError?(0,D.jsxs)(`p`,{role:`status`,className:`mt-[22px] text-xs text-danger`,children:[`Could not load changed files: `,t.error.message]}):t.data.files.length===0?null:(0,D.jsxs)(`section`,{"data-slot":`task-commit-files`,className:`mt-[22px] rounded-[10px] border border-border bg-card p-5`,children:[(0,D.jsxs)(`h2`,{className:`mb-4 text-[16px] font-semibold`,children:[t.data.files.length,` changed files`]}),(0,D.jsx)(`ul`,{className:`space-y-4`,children:t.data.files.map(t=>(0,D.jsx)(`li`,{children:(0,D.jsxs)(v,{to:`/tasks/${e.id}/changes`,className:`flex min-h-11 items-center gap-2 text-xs text-muted-foreground hover:text-foreground`,children:[(0,D.jsx)(c,{size:16,"aria-hidden":`true`,className:`size-[15px] shrink-0`}),(0,D.jsx)(`span`,{className:`break-all`,children:t.path})]})},t.path))})]})}export{O as TaskCommitsRoute};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ra as r,Rt as i,Yt as a,Z as o,ct as s,d as c,dn as l,dt as u,fa as d,fn as f,gi as p,ji as m,nr as h,sr as g,t as _,ui as v,ut as y,yn as b,za as x}from"./centered-state-kOb8j_BL.js";import{t as S}from"./utils-BW1-Ibnd.js";import{t as C}from"./createLucideIcon-BHp8sXmF.js";import{l as w,t as T}from"./run-header-BBQOWhJ7.js";import{n as E,t as D}from"./markdown-DlvW2wEx.js";import{a as O,i as k,r as A}from"./highlighter-CdHqIwFr.js";import{h as j,n as M,r as N}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ra as r,Rt as i,Yt as a,Z as o,ct as s,d as c,dn as l,dt as u,fa as d,fn as f,gi as p,ji as m,nr as h,sr as g,t as _,ui as v,ut as y,yn as b,za as x}from"./centered-state-kOb8j_BL.js";import{t as S}from"./utils-BW1-Ibnd.js";import{t as C}from"./createLucideIcon-BHp8sXmF.js";import{l as w,t as T}from"./run-header-BBQOWhJ7.js";import{n as E,t as D}from"./markdown-DlvW2wEx.js";import{a as O,i as k,r as A}from"./highlighter-CdHqIwFr.js";import{h as j,n as M,r as N}from"./index-GcasY1jB.js";var P=C(`file-exclamation-point`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),F=C(`file-question-mark`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}]]),I=C(`file-x`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m14.5 12.5-5 5`,key:`b62r18`}],[`path`,{d:`m9.5 12.5 5 5`,key:`1rk7el`}]]),L=C(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),R=C(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),z=e(t(),1),B=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`bmp`,`ico`,`avif`]);function V(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n<=0?!1:B.has(t.slice(n+1).toLowerCase())}function H(e){return e.tooLarge?`too-large`:V(e.path)?`image`:e.binary?`binary`:`text`}function U(e){return e>=1024**2?`${(e/1024**2).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} kB`:`${e} B`}var W=n();function G({runId:e,path:t,className:n}){let r=g(e,t??void 0);if(t===null)return(0,W.jsx)(q,{className:n,children:(0,W.jsx)(_,{icon:(0,W.jsx)(y,{size:16}),tone:`neutral`,heading:`h2`,title:`Select a file`,subtitle:`Pick a file from this task’s worktree to inspect its contents.`,className:`[&_[data-slot=centered-state-tile]]:size-10 [&_[data-slot=centered-state-tile]]:border-0 [&_[data-slot=centered-state-tile]]:bg-transparent [&_[data-slot=centered-state-tile]]:text-accent-text [&_[data-slot=centered-state-tile]]:shadow-none [&_h2]:text-xl`})});if(r.isPending)return(0,W.jsx)(q,{className:n,children:(0,W.jsxs)(`p`,{"data-slot":`file-preview-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground`,children:[`Loading `,t,`…`]})});if(r.isError){let e=r.error instanceof v&&r.error.status===409;return(0,W.jsx)(q,{className:n,children:(0,W.jsx)(_,{icon:e?(0,W.jsx)(I,{}):(0,W.jsx)(a,{size:16}),tone:e?`neutral`:`danger`,heading:`h2`,title:e?`Cannot preview this file`:`Could not load this file`,subtitle:r.error.message})})}return r.data.type===`file`?(0,W.jsx)(K,{runId:e,entry:r.data,className:n}):(0,W.jsx)(q,{className:n,children:(0,W.jsx)(_,{icon:(0,W.jsx)(F,{}),tone:`neutral`,heading:`h2`,title:`Choose a file inside this directory`,subtitle:`Expand the folder in the tree, or enter the full path to a file.`})})}function K({runId:e,entry:t,className:n,imageUrl:r,downloadUrl:i,snapshot:a,documentPreview:o=!1}){let[s,c]=(0,z.useState)(!1),l=o&&/\.(?:md|markdown)$/i.test(t.path),u=/\.(?:png|jpe?g|gif|webp|bmp|ico|avif)$/i.test(t.path),f=o&&u&&t.size<=10*1024*1024?`image`:H(t);return(0,W.jsxs)(q,{className:n,children:[(0,W.jsxs)(`header`,{"data-slot":`file-preview-head`,className:`flex items-center gap-2 border-b border-border bg-muted/40 px-4 py-2 text-xs`,children:[(0,W.jsx)(`span`,{className:`min-w-0 truncate font-mono font-medium`,children:t.path}),(0,W.jsx)(`span`,{className:`ml-auto shrink-0 tabular-nums text-soft-foreground`,children:U(t.size)})]}),a||i||l?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 border-b border-border px-4 py-2 text-xs`,children:[a?(0,W.jsxs)(`span`,{children:[`Published snapshot · `,a]}):null,i?(0,W.jsx)(`a`,{className:`inline-flex min-h-11 items-center text-accent-text underline`,href:i,children:`Download`}):null,l?(0,W.jsx)(`button`,{className:`min-h-11 rounded px-2 text-accent-text underline focus-visible:ring-2`,onClick:()=>c(e=>!e),children:s?`Preview`:`View source`}):null]}):null,f===`image`&&(!o||u)?(0,W.jsx)(`div`,{className:`flex justify-center p-4`,children:(0,W.jsx)(`img`,{"data-slot":`file-preview-image`,src:r??d(e,t.path),alt:t.path,className:`max-h-[70vh] max-w-full rounded-sm`})}):f===`too-large`?(0,W.jsx)(_,{icon:(0,W.jsx)(P,{}),tone:`neutral`,heading:`h2`,title:`Too large to preview`,subtitle:`${U(t.size)} — past the preview cap. Open it in your editor instead.`}):f===`binary`?(0,W.jsx)(_,{icon:(0,W.jsx)(F,{}),tone:`neutral`,heading:`h2`,title:`Binary file`,subtitle:`${U(t.size)} of binary data — no text preview.`}):l&&!s?(0,W.jsx)(`div`,{className:`p-4`,children:(0,W.jsx)(D,{document:!0,children:t.content??``})}):(0,W.jsx)(X,{path:t.path,text:t.content??``})]})}function q({className:e,children:t}){return(0,W.jsx)(`section`,{"data-slot":`file-preview`,className:S(`flex flex-col overflow-hidden rounded-lg border border-border bg-card`,e),children:t})}var J=1500;function Y(e,t){let n=(0,z.useMemo)(()=>t.split(`
|
|
2
2
|
`).map(e=>[{content:e}]),[t]),r=(0,z.useMemo)(()=>O(e),[e]),i=n.length>J,[a,o]=(0,z.useState)(null);return(0,z.useEffect)(()=>{if(r===null||i)return;let n=!1;return A(t,r).then(r=>{n||o({key:`${e}\0${t}`,tokens:r.tokens})}),()=>{n=!0}},[e,t,r,i]),r===null||i?n:a?.key===`${e}\0${t}`?a.tokens:k(t,r)?.tokens??n}function X({path:e,text:t}){let n=Y(e,t);return(0,W.jsx)(`div`,{"data-slot":`file-preview-code`,"data-lang":O(e)??`plaintext`,className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7]`,children:n.map((e,t)=>(0,W.jsxs)(`div`,{className:`flex px-4`,children:[(0,W.jsx)(`span`,{className:`w-10 shrink-0 select-none pr-3 text-right tabular-nums text-soft-foreground`,children:t+1}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-pre pr-4`,children:e.map((e,t)=>(0,W.jsx)(`span`,{style:e.color===void 0?void 0:{color:e.color},children:e.content},t))})]},t))})}function Z({runId:e,path:t,artifactId:n}){let r=b(e,n?null:t),i=l(e,n),a=n?i:r,o=(0,z.useContext)(E),s=a.data,u=(0,z.useMemo)(()=>s?.type===`file`&&s.source!==`artifact`?{runId:e,...o,basePath:s.path}:null,[s,o,e]);if(!t&&!n)return(0,W.jsx)(G,{runId:e,path:null,className:`min-w-0 flex-1`});if(a.isPending)return(0,W.jsx)(`p`,{role:`status`,className:`p-4`,children:`Loading file…`});if(a.isError)return(0,W.jsxs)(`section`,{"data-slot":`file-preview`,className:`min-w-0 flex-1 rounded-lg border p-4`,children:[(0,W.jsx)(`h2`,{children:`Could not load this file`}),(0,W.jsx)(`p`,{className:`wrap-anywhere text-sm`,children:a.error.message}),(0,W.jsx)(c,{variant:`outline`,onClick:()=>void a.refetch(),children:`Retry`})]});if(!s)return(0,W.jsx)(`p`,{role:`alert`,className:`p-4`,children:`No file data was returned.`});if(s.type!==`file`)return(0,W.jsxs)(`section`,{"data-slot":`file-preview`,className:`min-w-0 flex-1 rounded-lg border p-4`,children:[(0,W.jsx)(`h2`,{children:s.type===`unpublished`?`File not published`:`Cannot preview this file`}),(0,W.jsx)(`p`,{className:`wrap-anywhere py-2 font-mono text-xs`,children:s.path}),(0,W.jsx)(`p`,{className:`text-sm`,children:s.reason}),(0,W.jsx)(c,{variant:`outline`,onClick:()=>void a.refetch(),children:`Retry`})]});let d=s.artifact;return(0,W.jsx)(E.Provider,{value:u,children:(0,W.jsx)(K,{runId:e,entry:s,documentPreview:!0,className:`min-w-0 flex-1`,imageUrl:d?p(e,d.id,`image`):m(e,t),...d?{downloadUrl:p(e,d.id,`download`),snapshot:new Date(d.createdAt).toLocaleString()}:{}},d?.id??s.path)})}function Q({runId:e,selected:t,onSelect:n}){return(0,W.jsx)(`nav`,{"data-slot":`files-tree`,"aria-label":`Worktree files`,className:`min-w-0 text-[13px]`,children:(0,W.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,W.jsx)($,{runId:e,path:``,depth:0,selected:t,onSelect:n})})})}function $({runId:e,path:t,depth:n,selected:r,onSelect:i}){let a=g(e,t);return a.isPending?(0,W.jsx)(`li`,{"data-slot":`files-tree-loading`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${6+n*14}px`},children:`Loading…`}):a.isError?(0,W.jsx)(`li`,{"data-slot":`files-tree-error`,className:`px-1.5 py-1 text-xs text-danger`,style:{paddingLeft:`${6+n*14}px`},children:a.error.message}):a.data.type===`dir`?a.data.entries.length===0?(0,W.jsx)(`li`,{"data-slot":`files-tree-empty`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${6+n*14}px`},children:`Empty directory`}):(0,W.jsx)(W.Fragment,{children:a.data.entries.map(a=>a.type===`dir`?(0,W.jsx)(ee,{runId:e,name:a.name,path:t===``?a.name:`${t}/${a.name}`,depth:n,selected:r,onSelect:i},a.name):(0,W.jsx)(te,{name:a.name,path:t===``?a.name:`${t}/${a.name}`,size:a.size,depth:n,selected:r,onSelect:i},a.name))}):null}function ee({runId:e,name:t,path:n,depth:r,selected:i,onSelect:a}){let[s,c]=(0,z.useState)(!1);return(0,W.jsxs)(`li`,{children:[(0,W.jsxs)(`button`,{type:`button`,"data-slot":`files-dir`,"data-path":n,"data-state":s?`open`:`closed`,"aria-expanded":s,onClick:()=>c(e=>!e),className:`flex min-h-11 md:min-h-8 w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left text-muted-foreground hover:bg-muted hover:text-foreground`,style:{paddingLeft:`${6+r*14}px`},children:[(0,W.jsx)(o,{size:16,"aria-hidden":`true`,className:S(`order-last ml-auto size-3.5 shrink-0 transition-transform motion-reduce:transition-none`,s&&`rotate-90`)}),(0,W.jsx)(u,{size:16,"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,W.jsx)(`span`,{className:`min-w-0 truncate font-normal`,children:t})]}),s?(0,W.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,W.jsx)($,{runId:e,path:n,depth:r+1,selected:i,onSelect:a})}):null]})}function te({name:e,path:t,size:n,depth:r,selected:i,onSelect:a}){let o=i===t,c=V(t)?R:s;return(0,W.jsx)(`li`,{children:(0,W.jsxs)(`button`,{type:`button`,"data-slot":`files-file`,"data-path":t,"aria-current":o?`true`:void 0,onClick:()=>a(t),className:S(`flex min-h-11 md:min-h-8 w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left hover:bg-muted`,o?`bg-muted font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${6+r*14}px`},children:[(0,W.jsx)(c,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,W.jsx)(`span`,{className:`min-w-0 truncate`,children:e}),n===void 0?null:(0,W.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-[11px] tabular-nums text-soft-foreground`,children:U(n)})]})})}function ne(){let{id:e}=r(),t=h(e);return t.isPending?(0,W.jsx)(N,{tab:`files`}):t.isError?(0,W.jsx)(M,{tab:`files`,error:t.error}):(0,W.jsx)(w,{runId:t.data.id,children:(0,W.jsx)(re,{run:t.data},t.data.id)})}function re({run:e}){let t=g(e.id,``),n=f(e.id),[r,o]=x(),s=r.get(`path`),l=r.get(`artifact`),u=r.getAll(`path`).length>1||r.getAll(`artifact`).length>1||s!==null&&l!==null,[d,p]=(0,z.useState)(s??``);(0,z.useEffect)(()=>p(s??``),[s]);let m=(e,t)=>{let n=new URLSearchParams(r);n.delete(`path`),n.delete(`artifact`),n.set(e,t),o(n)},h=t.isError&&t.error instanceof v&&t.error.status===409;return(0,W.jsxs)(`div`,{"data-route":`task-files`,className:`flex min-h-full flex-col`,children:[(0,W.jsx)(T,{run:e,tab:`files`}),(0,W.jsxs)(`form`,{className:`flex min-w-0 gap-2 px-[18px] pt-[22px] md:px-9`,onSubmit:e=>{e.preventDefault(),d.trim()&&m(`path`,d.trim())},children:[(0,W.jsxs)(`label`,{className:`relative min-w-0 flex-1`,children:[(0,W.jsx)(i,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,W.jsx)(j,{"aria-label":`File path in the worktree`,placeholder:`Open a file by path…`,value:d,onChange:e=>p(e.target.value),className:`h-11 min-w-0 bg-card pl-10`})]}),(0,W.jsx)(c,{type:`submit`,variant:`outline`,className:`h-11 shrink-0`,disabled:!d.trim(),children:`Open file`})]}),(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-col items-stretch gap-5 px-[18px] py-[22px] [--diff-sticky-top:1rem] md:flex-row md:items-start md:px-9`,children:[(0,W.jsxs)(`aside`,{"data-slot":`files-tree-pane`,className:`w-full shrink-0 rounded-xl border border-border bg-card p-3.5 md:sticky md:top-[var(--diff-sticky-top)] md:max-h-[calc(100dvh_-_64px_-_var(--diff-sticky-top)_-_1rem)] md:w-60 md:overflow-y-auto md:overscroll-contain lg:w-72`,children:[(0,W.jsx)(`h2`,{className:`sr-only`,children:`Worktree files`}),t.isPending?(0,W.jsx)(`p`,{"data-slot":`files-loading`,className:`py-4 text-xs`,children:`Loading files…`}):t.isError?(0,W.jsx)(_,{icon:h?(0,W.jsx)(L,{}):(0,W.jsx)(a,{size:16}),tone:h?`neutral`:`danger`,heading:`h2`,title:h?`No files to browse`:`Could not load the files`,subtitle:t.error.message}):(0,W.jsx)(Q,{runId:e.id,selected:s,onSelect:e=>m(`path`,e)}),(0,W.jsxs)(`section`,{className:`mt-4 border-t border-border pt-3`,"aria-label":`Published artifacts`,children:[(0,W.jsx)(`h2`,{className:`text-sm font-medium`,children:`Published artifacts`}),n.isPending?(0,W.jsx)(`p`,{className:`py-2 text-xs`,children:`Loading published files…`}):n.isError?(0,W.jsx)(`p`,{role:`alert`,className:`py-2 text-xs`,children:`Could not load published files.`}):n.data.artifacts.length===0?(0,W.jsx)(`p`,{className:`py-2 text-xs text-muted-foreground`,children:`No published files yet.`}):(0,W.jsx)(`ul`,{children:n.data.artifacts.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsx)(`button`,{type:`button`,"aria-current":e.id===l?`true`:void 0,className:`min-h-11 w-full rounded px-2 py-2 text-left text-xs wrap-anywhere hover:bg-muted focus-visible:ring-2`,onClick:()=>m(`artifact`,e.id),children:e.name})},e.id))}),(0,W.jsx)(c,{variant:`ghost`,className:`min-h-11`,onClick:()=>void n.refetch(),children:`Refresh published files`})]})]}),u?(0,W.jsx)(`p`,{role:`alert`,className:`p-4`,children:`Invalid file link: choose either a path or a published artifact.`}):s!==null||l!==null||t.isSuccess?(0,W.jsx)(Z,{runId:e.id,path:s,artifactId:l}):null]}),(0,W.jsx)(`p`,{className:`px-[18px] pb-6 text-xs text-muted-foreground md:px-9`,children:`Browsing files is read-only. Worktree contents may differ from your main checkout. Published files are snapshots.`})]})}export{ne as TaskFilesRoute};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$r as r,Ba as i,Br as a,Ci as o,Di as s,Dt as c,Et as l,Ga as u,H as d,Ha as f,Hn as p,Ia as m,In as h,J as g,Jt as _,Mi as v,Oa as y,Or as b,Pt as x,Q as S,Ra as C,Rn as w,Rt as T,Ui as E,Va as D,Vr as O,Wi as k,X as A,Xa as j,Y as M,Ya as N,Z as P,Zn as F,_i as ee,at as te,d as I,dr as ne,en as L,et as R,fr as re,hr as ie,ht as ae,ii as oe,in as z,it as se,jn as ce,mn as le,n as ue,nr as de,nt as fe,qa as B,qt as pe,t as me,ui as he,vi as ge,vn as _e,wa as ve,xt as ye,ya as V}from"./centered-state-kOb8j_BL.js";import{C as be,S as xe,T as Se,c as Ce,i as we,n as Te,s as Ee,t as H,w as De,x as Oe,y as ke}from"./utils-BW1-Ibnd.js";import{n as U,r as Ae,t as je}from"./collapsible-KSKVv9J9.js";import{n as Me,s as Ne,t as Pe}from"./agent-accounts-Bh1l3ZSb.js";import{t as Fe}from"./textarea-D2Gx4GDI.js";import{t as Ie}from"./createLucideIcon-BHp8sXmF.js";import{A as Le,M as Re,O as ze,S as Be,c as Ve,d as He,f as Ue,g as We,h as Ge,u as Ke,v as qe}from"./pill-0JHCf1v8.js";import{a as Je,c as Ye,d as Xe,f as Ze,i as Qe,l as $e,n as et,o as tt,r as nt,s as rt,t as it,u as at}from"./run-header-BBQOWhJ7.js";import{t as ot}from"./external-link-BE6y205O.js";import{L as st,S as ct,_ as lt,b as ut,c as dt,g as ft,l as pt,v as mt,x as ht}from"./prompt-templates-BgXzCOlY.js";import{s as gt,t as W,u as _t}from"./project-router-CS_oeLqi.js";import{t as vt}from"./message-square-B-MD-8rD.js";import{t as yt}from"./search-x-I9Q8pgUa.js";import{t as bt}from"./square-terminal-B6RYYieR.js";import{t as xt}from"./markdown-DlvW2wEx.js";import{c as St,i as Ct,l as wt,n as Tt,o as Et,s as Dt,t as Ot}from"./thread-loading-hVlcCLdm.js";import{t as kt}from"./use-submit-shortcut-KWJsC906.js";import{t as At}from"./lib-BQXq3kEf.js";import{t as jt}from"./zoomable-image-DVvXID3t.js";import{t as Mt}from"./run-diff-xym-7QHm.js";import{t as Nt}from"./use-desktop-BaYgO7YW.js";var Pt=120;function Ft(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function It(e){let t=e.replace(/\s+/g,` `).trim();return t.length>Pt?`${t.slice(0,Pt-1)}…`:t}function G(e,...t){if(Ft(e))for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim()!==``)return It(t)}}function Lt(e){if(!Ft(e))return;let t=e.command;if(typeof t==`string`&&t.trim()!==``)return It(t);if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return It(e.join(` `))}}function Rt(e){if(!Ft(e)||!Array.isArray(e.changes))return[];let t=[];for(let n of e.changes)Ft(n)&&typeof n.path==`string`&&n.path.trim()!==``&&t.push(n.path);return t}function zt(e){return G(e,`description`,`query`,`url`,`filePath`,`file_path`,`path`,`pattern`,`name`)}function K(e,t){return t?`${e} ${t}`:e}function Bt(e,t){let n=typeof e==`string`?e.toLowerCase():``;switch(n){case`bash`:case`commandexecution`:return{toolKind:`execute`,title:K(`Ran`,Lt(t)),subtitle:G(t,`description`)};case`edit`:case`multiedit`:return{toolKind:`edit`,title:K(`Edit`,G(t,`file_path`,`filePath`,`path`))};case`write`:return{toolKind:`edit`,title:K(`Write`,G(t,`file_path`,`filePath`,`path`))};case`notebookedit`:return{toolKind:`edit`,title:K(`Edit`,G(t,`notebook_path`,`notebookPath`,`file_path`,`filePath`,`path`))};case`filechange`:{let e=Rt(t);return{toolKind:`edit`,title:K(`Edit`,e.length===1?e[0]:e.length>1?`${e.length} files`:void 0)}}case`read`:return{toolKind:`read`,title:K(`Read`,G(t,`file_path`,`filePath`,`path`))};case`imageview`:return{toolKind:`read`,title:K(`View image`,G(t,`path`))};case`glob`:case`grep`:return{toolKind:`search`,title:K(`Search`,G(t,`pattern`,`query`)),subtitle:G(t,`path`)};case`webfetch`:return{toolKind:`fetch`,title:K(`Fetch`,G(t,`url`))};case`websearch`:return{toolKind:`fetch`,title:K(`Web search`,G(t,`query`))};case`task`:case`agent`:{let e=n===`agent`?`Agent`:`Task`,r=G(t,`subagent_type`,`subagentType`),i=G(t,`description`,`prompt`)??r;return{toolKind:`task`,title:i?`${e}: ${i}`:e,subtitle:i===r?void 0:r}}case`skill`:{let e=G(t,`skill`,`name`,`command`);return{toolKind:`task`,title:e?`Skill: ${e}`:`Skill`,subtitle:G(t,`args`,`description`)}}case`todowrite`:case`todolist`:case`plan`:case`taskcreate`:case`taskupdate`:case`tasklist`:return{toolKind:`plan`,title:`Update plan`};case`contextcompaction`:return{toolKind:`other`,title:`Compacted context`};case`mcptoolcall`:{let e=G(t,`server`),n=G(t,`tool`);return e&&n?{toolKind:`other`,title:`${e}.${n}`}:{toolKind:`other`,title:`MCP tool`,subtitle:zt(t)}}}if(n.startsWith(`mcp__`)){let t=e.split(`__`).filter(e=>e!==``);if(t.length>=3)return{toolKind:`other`,title:`${t[1]}.${t.slice(2).join(`__`)}`}}return{toolKind:`other`,title:typeof e==`string`&&e.trim()!==``?It(e):`Tool`,subtitle:zt(t)}}var Vt=class extends B{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:N(t,n.data),hasPreviousPage:j(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}};function Ht(e,t){return f(e,Vt,t)}var Ut=Ie(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),Wt=Ie(`corner-up-left`,[[`path`,{d:`M20 20v-7a4 4 0 0 0-4-4H4`,key:`1nkjon`}],[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}]]),Gt=Ie(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),Kt=Ie(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),qt=Ie(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),q=e(t(),1),Jt=[`run-event`,`ui-event`];function Yt(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t||Array.isArray(t))return null;let{seq:n,type:r}=t;return typeof n!=`number`||typeof r!=`string`||r===``?null:t}function Xt(e,t={}){let[n,r]=(0,q.useState)([]),{cursor:i,afterSeq:a=0,maxEvents:o,compactAt:s,onCompact:c}=t;return(0,q.useEffect)(()=>{if(r([]),!e)return;let t=globalThis.EventSource;if(typeof t!=`function`)return;let n=a,l=null,u,d=!1,f=!1,p=Date.now(),m,h=e=>{p=Date.now();let t=Yt(e.data);!t||!(t.seq>n)||(n=t.seq,r(e=>{let n=[...e,t];return!f&&s!==void 0&&n.length>=s&&(f=!0,queueMicrotask(()=>{d||c?.()})),o===void 0||n.length<=o?n:n.slice(-o)}))},g=()=>{p=Date.now()},_=()=>{d||u!==void 0||(u=setTimeout(()=>{u=void 0,d||v()},1500))},v=()=>{l?.close(),p=Date.now();let r=new URLSearchParams;i!==void 0&&r.set(`cursor`,i),(i!==void 0||a>0)&&r.set(`afterSeq`,String(n));let o=r.size>0?`?${r.toString()}`:``;l=new t(we(`/runs/${encodeURIComponent(e)}/events${o}`),{withCredentials:!0});for(let e of Jt)l.addEventListener(e,h);l.addEventListener(`ping`,g),l.addEventListener(`error`,()=>{l?.readyState===2&&_()})},y=()=>{document.visibilityState===`visible`&&(!l||l.readyState===2)&&(clearTimeout(u),u=void 0,v())},b=()=>{clearTimeout(u),u=void 0,l?.close()},x=e=>{e.persisted&&v()};return m=setInterval(()=>{d||document.visibilityState!==`visible`||Date.now()-p<=4e4||(clearTimeout(u),u=void 0,v())},1e4),document.addEventListener(`visibilitychange`,y),window.addEventListener(`pagehide`,b),window.addEventListener(`pageshow`,x),v(),()=>{d=!0,clearTimeout(u),clearInterval(m),document.removeEventListener(`visibilitychange`,y),window.removeEventListener(`pagehide`,b),window.removeEventListener(`pageshow`,x),l?.close()}},[e,i,a,o,s,c]),n}var Zt=5,Qt=200,$t=5e3;function en(...e){let t=new Map;for(let n of e)for(let e of n)t.set(e.seq,e);return[...t.values()].sort((e,t)=>e.seq-t.seq)}function tn(e){let t=Ee(),n=u(),r=[`run-history`,t,e],i=[`run-history-context`,t,e],a=Ht({queryKey:r,enabled:e!==void 0,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>E(e,t,{signal:n}),getPreviousPageParam:e=>e.olderCursor,getNextPageParam:e=>e.newerCursor,maxPages:Zt,retry:1}),o=D({queryKey:i,enabled:e!==void 0,queryFn:({signal:t})=>k(e,{signal:t}),retry:1}),s=a.isError||o.isError,c=Xt(s?e:void 0),l=a.data?.pages??[],d=l.reduce((e,t)=>t.newerCursor===void 0?t:e??t,void 0),f=(0,q.useRef)(!1),p=(0,q.useCallback)(()=>{e===void 0||f.current||(f.current=!0,E(e,void 0).then(r=>{n.setQueryData([`run-history`,t,e],e=>{if(!e)return{pages:[r],pageParams:[void 0]};let t=[...e.pages],n=[...e.pageParams],i=-1;for(let e=0;e<t.length;e+=1)(i===-1||t[e].asOfSeq>t[i].asOfSeq)&&(i=e);for(i>=0&&t[i].newerCursor===void 0?(t[i]=r,n[i]=void 0):(t.push(r),n.push(void 0));t.length>Zt;)t.shift(),n.shift();return{pages:t,pageParams:n}})}).catch(()=>{}).finally(()=>{f.current=!1}))},[n,e,t]),m=Xt(!s&&d?e:void 0,{cursor:d?.liveCursor,afterSeq:d?.asOfSeq,maxEvents:$t,compactAt:Qt,onCompact:p}),h=(0,q.useMemo)(()=>en(...l.map(e=>e.events)),[l]),g=(0,q.useMemo)(()=>s?c:en(h,m),[s,c,h,m]),_=(0,q.useMemo)(()=>{if(s)return c;let e=o.data?.contextEvents??[],t=o.data?.asOfSeq??0;return en(e,g.filter(({seq:e})=>e>t))},[o.data,s,c,g]),v=(0,q.useCallback)(async()=>{await a.fetchPreviousPage()},[a.fetchPreviousPage]),y=(0,q.useCallback)(async()=>{s||await n.resetQueries({queryKey:r,exact:!0})},[s,r,n]);return{visibleEvents:g,currentEvents:_,isPending:!s&&a.isPending,contextPending:!s&&o.isPending,fallback:s,hasOlder:!s&&!!a.hasPreviousPage,isFetchingOlder:a.isFetchingPreviousPage,olderError:a.isFetchPreviousPageError?a.error instanceof Error?a.error.message:`Could not load earlier items`:void 0,loadOlder:v,jumpToLatest:y,retainedPages:l.length}}var J=n();function nn({run:e}){let t=u(),n=i({mutationFn:()=>ee(e.id),onSuccess:()=>{t.invalidateQueries({queryKey:z.runs.detail(e.id)}),t.invalidateQueries({queryKey:z.runs.list()}),V(`This task will not resume itself`)},onError:e=>V(e.message,{tone:`danger`})});if(e.status!==`failed`||!e.autoResumeAt)return null;let r=new Date(e.autoResumeAt);if(!Number.isFinite(r.getTime()))return null;let a=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(r);return(0,J.jsxs)(`div`,{"data-slot":`auto-resume-hint`,role:`status`,className:`flex flex-wrap items-center gap-x-2 gap-y-1 px-1 text-xs text-muted-foreground`,children:[(0,J.jsx)(Le,{tone:`pending`,pulse:!0}),(0,J.jsxs)(`span`,{children:[`Usage limit reached — this task resumes automatically at`,` `,(0,J.jsx)(`time`,{dateTime:e.autoResumeAt,className:`font-medium text-foreground`,children:a})]}),(0,J.jsx)(`button`,{type:`button`,"data-action":`auto-resume-cancel`,disabled:n.isPending,onClick:()=>n.mutate(),className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground disabled:opacity-50`,children:`Don’t resume`}),(0,J.jsx)(y,{to:`/settings/global/resources`,"data-slot":`auto-resume-settings-link`,className:`font-medium text-foreground underline decoration-border underline-offset-2 hover:decoration-foreground`,children:`Auto-resume settings`})]})}var rn=e=>e.kind===`tool`,an=e=>e.kind===`conversation`,on=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,sn=(e,t,n)=>`${e} ${e===1?t:n}`;function cn(e,t){let n=[];return e>0&&n.push(sn(e,`file`,`files`)),t>0&&n.push(sn(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function ln(e){return`${e} earlier tool call${e===1?``:`s`}`}var un=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function dn(e){for(let t of un)if(e.startsWith(`${t} `)&&e.length>t.length+1)return{verb:t===`Task:`?`Task`:t,detail:e.slice(t.length+1)};return{verb:e}}function fn(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!(e.kind===`reasoning`&&e.text.trim()===``)),n=new Set(t.filter(rn).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=(e.kind===`message`||e.kind===`reasoning`||e.kind===`tool`)&&e.parentItemId!==void 0&&e.parentItemId!==e.id&&n.has(e.parentItemId)?e.parentItemId:void 0;if(t===void 0)i.push(e);else{let n=r.get(t);n?n.push(e):r.set(t,[e])}}let a=[],o=[],s=()=>{if(o.length>=2){let e=o.filter(e=>e.toolKind===`read`).length;a.push({kind:`context-group`,id:`group:${o[0].id}`,tools:o,files:e,searches:o.length-e,label:cn(e,o.length-e)})}else for(let e of o)a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]});o=[]},c=[],l=()=>{if(c.length!==0){for(let e of pn(c).batches)a.push({kind:`worker-conversation`,id:`worker:${e.messages[0].id}`,batches:[e]});c=[]}};for(let e of i){if(an(e)){s(),c.push(e);continue}l(),rn(e)&&on(e)&&!r.has(e.id)?o.push(e):(s(),rn(e)?a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]}):a.push({kind:`entry`,id:e.id,entry:e}))}s(),l();let u=e=>e.kind===`context-group`||e.kind===`tool-card`&&e.item.status===`completed`,d=e=>e.kind===`context-group`?e.tools.length:1,f=[],p=[],m=()=>{if(p.length>3){let e=p.slice(0,p.length-3);f.push({kind:`streak`,id:`streak:${e[0].id}`,count:e.reduce((e,t)=>e+d(t),0),blocks:e}),f.push(...p.slice(p.length-3))}else f.push(...p);p=[]};for(let e of a)u(e)?p.push(e):(m(),f.push(e));return m(),f}function pn(e){let t=[];for(let n of e){let e=t.at(-1);n.messageKind===`request`&&e?.kind===`request`&&e.senderRunId===n.senderRunId&&e.text===n.text&&!e.messages.some(e=>e.recipientRunId===n.recipientRunId)?e.messages.push(n):t.push({id:`worker-batch:${n.messageId}`,kind:n.messageKind,text:n.text,senderRunId:n.senderRunId,messages:[n]})}return{kind:`worker-conversation`,id:`worker:${e[0].id}`,batches:t}}var mn=new Map,hn=(0,q.createContext)(null);function gn(){return(0,q.useContext)(hn)}function _n({runId:e,children:t}){let n=(0,q.useMemo)(()=>({get:t=>mn.get(e)?.get(t),set:(t,n)=>{let r=mn.get(e)??new Map;r.set(t,n),mn.set(e,r)}}),[e]);return(0,J.jsx)(hn.Provider,{value:n,children:t})}var vn=(0,q.createContext)({targets:new Map,replies:new Map,navigate:()=>{}});function yn(e){return e.scrollTop<Math.max(600,e.clientHeight)}function bn(e,t){let n=t.find(({bottom:t})=>t>e);return n===void 0?void 0:{key:n.key,offset:n.top-e}}function xn(e,t,n,r,i){if(n===void 0)return i;let a=r.find(({key:e})=>e===n.key);return a===void 0?i:e+(a.top-t-n.offset)}function Sn(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function Cn(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var wn=new Map;function Tn(e,t){wn.set(e,t)}function En(e){return wn.get(e)}var Dn=new Map;function On(e,t){Dn.set(e,t)}function kn(e,t){let n=Dn.get(e);return n!==void 0&&n.rows===t?n.cache:void 0}var An=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}),jn=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}),Mn=new Intl.DateTimeFormat(void 0,{weekday:`short`,month:`short`,day:`numeric`}),Nn=new Intl.DateTimeFormat(void 0,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`}),Pn=new Intl.DateTimeFormat(void 0,{dateStyle:`full`});function Y(e){if(typeof e!=`string`||e===``)return;let t=new Date(e);return Number.isFinite(t.getTime())?t:void 0}function Fn(e){let t=Y(e);return t===void 0?void 0:An.format(t)}function In(e){let t=Y(e);return t===void 0?void 0:jn.format(t)}var Ln=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;function Rn(e){let t=Y(e);return t===void 0?void 0:Ln(t)}function zn(e,t=new Date){let n=Y(e);if(n===void 0)return;let r=Ln(n);return r===Ln(t)?`Today`:r===Ln(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1))?`Yesterday`:(n.getFullYear()===t.getFullYear()?Mn:Nn).format(n)}function Bn(e,t){let n=Y(e),r=Y(t);if(n===void 0||r===void 0)return;let i=Math.round((r.getTime()-n.getTime())/1e3);if(i<0)return;if(i<60)return`${i}s`;let a=Math.floor(i/60);return a<60?`${a}m ${String(i%60).padStart(2,`0`)}s`:`${Math.floor(a/60)}h ${String(a%60).padStart(2,`0`)}m`}function Vn({ts:e}){let t=Fn(e);return t===void 0?null:(0,J.jsx)(`time`,{"data-slot":`message-time`,dateTime:e,title:In(e),className:`text-[11px] leading-none text-soft-foreground`,children:t})}function Hn({startedAt:e,completedAt:t}){let n=Fn(t);if(n===void 0)return null;let r=Bn(e,t);return(0,J.jsxs)(`div`,{"data-slot":`turn-time`,className:`flex items-center gap-1.5 px-0.5 text-[11px] leading-none text-soft-foreground`,children:[(0,J.jsx)(`time`,{dateTime:t,title:In(t),children:n}),r===void 0?null:(0,J.jsxs)(`span`,{title:`Replied in ${r}`,children:[`· `,r]})]})}function Un({ts:e}){let t=zn(e),n=Y(e);if(t===void 0||n===void 0)return null;let r=Pn.format(n);return(0,J.jsxs)(`div`,{"data-slot":`day-separator`,role:`separator`,"aria-label":t===`Today`||t===`Yesterday`?`${t}, ${r}`:r,className:`flex items-center gap-3 py-1 text-[11px] font-medium text-soft-foreground`,children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),(0,J.jsx)(`time`,{dateTime:Rn(e),title:r,children:t}),(0,J.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]})}function Wn(e,t){let n={};for(let r of[...t??[],e])n[r.id]=r.steps.find(e=>e.id===r.currentStepId)?.backend??r.runner;return n}function Gn(e,t){let n={[e.id]:r(e)};for(let e of t??[])n[e.id]=r(e);return n}function X(e,t){return t?.[e]??`Task`}function Kn(e,t){return e.senderRunId===t?`outbound`:`inbound`}function qn(e){switch(e){case`request`:return`Request`;case`progress`:return`Progress`;case`follow-up`:return`Follow-up`;case`reply`:return`Reply`;default:return e}}function Jn(e){switch(e){case`pending`:return`Pending`;case`replied`:return`Replied`;case`timed-out`:return`Timed out`;case`cancelled`:return`Cancelled`;case`completed-without-reply`:return`Completed without reply`;case`failed`:return`Failed`;case`destroyed`:return`Destroyed`;case`sender-closed`:return`Sender closed`;case`human-fallback`:return`Sent to a human`;default:return e}}function Yn(e){if(e.outcome)return Jn(e.outcome.status);if(e.delivery===`not-delivered`)return Xn(`not-delivered`)}function Xn(e){switch(e){case`queued`:return`Queued`;case`delivered`:return`Delivered`;case`consumed`:return`Read`;case`not-delivered`:return`Not delivered`;default:return e}}var Zn={user:{label:`YOUR MESSAGE`,speaker:`Your message`,classes:`border-message-user-border bg-message-user-bg`,accent:`text-message-user-accent`,body:`max-md:text-[12px]`},agent:{label:`AGENT RESPONSE`,speaker:`Agent response`,classes:`border-message-agent-border bg-message-agent-bg`,accent:`text-message-agent-accent`,body:`max-w-[65ch] text-[15px] md:text-[14px]`}};function Qn({role:e,children:t,className:n,ts:r,...i}){let a=Zn[e];return(0,J.jsxs)(`article`,{...i,"data-role":e,"aria-label":a.speaker,className:H(`flex w-full min-w-0 flex-col gap-2 self-stretch rounded-[8px] border p-3 md:px-4 md:py-[14px]`,a.classes,n),children:[(0,J.jsxs)(`p`,{className:H(`m-0 flex w-full min-w-0 items-start justify-between gap-2 text-[11px] leading-[1.2] font-semibold tracking-[0.6px] uppercase`,a.accent),children:[(0,J.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(vt,{"aria-hidden":`true`,className:`size-4 shrink-0`}),a.label]}),r!==void 0&&Fn(r)!==void 0?(0,J.jsx)(`span`,{className:`shrink-0 font-normal tracking-normal normal-case`,children:(0,J.jsx)(Vn,{ts:r})}):null]}),(0,J.jsx)(`div`,{className:H(`min-w-0 break-words text-[14px] text-foreground select-text [overflow-wrap:anywhere]`,a.body,`leading-[1.6]`),children:t})]})}function $n({text:e,imageCount:t=0,images:n=[],ts:r,onEdit:i,onRemove:a,editLabel:o=`Edit message`,removeLabel:s=`Remove message`}){let c=t-n.length,[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(e),[p,m]=(0,q.useState)(!1),[h,g]=(0,q.useState)(),v=()=>{f(e),g(void 0),u(!0)},y=async()=>{let t=d.trim();if(!t||t===e){u(!1);return}m(!0),g(void 0);try{await i?.(t),u(!1)}catch(e){g(e instanceof Error?e.message:`Could not save the message`)}finally{m(!1)}},b=async()=>{m(!0),g(void 0);try{await a?.()}catch(e){g(e instanceof Error?e.message:`Could not remove the message`)}finally{m(!1)}};return l?(0,J.jsxs)(Qn,{role:`user`,ts:r,"data-slot":`user-bubble`,"data-editing":`true`,children:[(0,J.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Edit the message`,value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),u(!1)):e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),y())},className:`block max-h-[220px] min-h-[60px] w-full resize-none rounded-md bg-background px-2 py-1.5 text-[14px] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}),(0,J.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>u(!1),disabled:p,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm px-2 text-xs font-medium text-muted-foreground hover:bg-background hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:`Cancel`}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>void y(),disabled:p,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm bg-action px-2 text-xs font-semibold text-action-foreground hover:brightness-[0.96] focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:p?(0,J.jsx)(_t,{className:`size-3.5 animate-spin`}):`Save`})]}),h?(0,J.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:h}):null]}):(0,J.jsxs)(Qn,{role:`user`,ts:r,"data-slot":`user-bubble`,className:`group`,children:[i||a?(0,J.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`mb-1 flex justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[i?(0,J.jsx)(`button`,{type:`button`,"aria-label":o,onClick:v,disabled:p,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,J.jsx)(qt,{className:`size-3.5`})}):null,a?(0,J.jsx)(`button`,{type:`button`,"aria-label":s,onClick:()=>void b(),disabled:p,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-danger focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,J.jsx)(_,{className:`size-3.5`})}):null]}):null,h?(0,J.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:h}):null,(0,J.jsx)(xt,{breaks:!0,children:e}),n.length>0?(0,J.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap items-center justify-end gap-1.5`,children:n.map(e=>ke(e.split(`/`).pop()??``)?(0,J.jsx)(jt,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e):(0,J.jsxs)(`a`,{href:Ce(e),download:!0,"data-slot":`user-file`,className:`inline-flex min-h-11 min-w-11 max-w-[220px] items-center gap-1.5 rounded-md border border-border bg-background/60 px-2 py-1 text-xs text-muted-foreground hover:text-foreground`,children:[(0,J.jsx)(x,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,J.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()})]},e))}):null,c>0?(0,J.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[c,` image`,c>1?`s`:``,` attached`]}):null]})}function er({text:e,ts:t}){return(0,J.jsx)(Qn,{role:`agent`,ts:t,"data-slot":`assistant-message`,children:(0,J.jsx)(xt,{children:e})})}var tr={outbound:{classes:`border-message-outbound-border bg-message-outbound-bg`,accent:`text-message-outbound-accent`},inbound:{classes:`border-message-inbound-border bg-message-inbound-bg`,accent:`text-message-inbound-accent`}},nr=`inline-flex min-h-11 max-w-full items-center break-words underline underline-offset-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`;function rr({block:e,runId:t,taskTitles:n,recipientBackends:r}){return(0,J.jsx)(`div`,{"data-slot":`worker-conversation`,className:`flex min-w-0 flex-col gap-2`,children:e.batches.map(e=>(0,J.jsx)(ir,{batch:e,runId:t,taskTitles:n,recipientBackends:r},e.id))})}function ir({batch:e,runId:t,taskTitles:n,recipientBackends:r}){let i=Kn(e.messages[0]??{senderRunId:e.senderRunId},t),a=tr[i],o=cr(e.messages.map(e=>i===`outbound`?e.recipientRunId:e.senderRunId)),s=i===`outbound`?`SENT to`:`RECEIVED from`,c=`${s} ${o.map(e=>X(e,n)).join(`, `)}`,l=e.messages[0],u=l?.createdAt??l?.recordedAt,d=l?Yn(l):void 0;return(0,J.jsxs)(`article`,{"data-slot":`worker-conversation-card`,"data-direction":i,"data-kind":e.kind,className:H(`flex w-full min-w-0 flex-col gap-2 rounded-[8px] border p-3 md:px-4 md:py-[14px]`,a.classes),children:[(0,J.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-start gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`p`,{className:H(`m-0 flex min-w-0 flex-wrap items-center gap-x-2 text-[11px] leading-[1.2] font-semibold tracking-[0.6px] uppercase`,a.accent),children:[(0,J.jsx)(`span`,{children:s}),o.map((e,t)=>(0,J.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-x-2 normal-case tracking-normal`,children:[t>0?(0,J.jsx)(`span`,{"aria-hidden":!0,children:`,`}):null,(0,J.jsx)(W,{className:nr,to:`/tasks/${e}`,"aria-label":`${s} ${X(e,n)}`,children:X(e,n)})]},e))]}),(0,J.jsx)(`span`,{"data-slot":`conversation-kind`,className:`rounded-full bg-background/60 px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-foreground uppercase`,children:qn(e.kind)}),e.messages.length===1&&d?(0,J.jsx)(`span`,{"data-slot":`conversation-outcome`,className:`text-xs font-medium text-muted-foreground`,children:d}):null]}),u!==void 0&&Fn(u)!==void 0?(0,J.jsxs)(`span`,{className:`flex shrink-0 items-center justify-self-end gap-1 whitespace-nowrap text-[11px] text-soft-foreground`,children:[e.messages.length>1?`First sent`:null,(0,J.jsx)(Vn,{ts:u})]}):null]}),(0,J.jsx)(`div`,{className:`min-w-0 break-words text-[14px] leading-[1.6] text-foreground select-text [overflow-wrap:anywhere]`,children:(0,J.jsx)(xt,{breaks:!0,children:e.text})}),[...new Set(e.messages.map(e=>e.instruction??(e.delivery===`queued`?`${r?.[e.recipientRunId]===`cursor`?`Queued for delivery. If Cursor is in a turn, delivery waits for that turn to end.`:r?.[e.recipientRunId]?`Queued for delivery. This agent can receive messages during its current turn.`:`Queued for delivery. Timing depends on the recipient agent.`} Pending messages are batched within the size limit; human questions and scheduler capacity can delay delivery.`:e.state===`continuation-required`?`Not delivered. The recipient needs a new instruction to resume. A parent can resume its owned worker with --resume; workers cannot resume parents.`:e.state===`destroyed`?`Not delivered. This worker was destroyed.`:void 0)))].map(e=>e?(0,J.jsx)(`p`,{"data-slot":`conversation-delivery-explanation`,className:`min-w-0 text-xs leading-relaxed text-muted-foreground [overflow-wrap:anywhere]`,children:e},e):null),e.kind===`request`&&e.messages.length>1?(0,J.jsx)(`ul`,{className:`grid min-w-0 gap-1 text-xs text-muted-foreground`,children:e.messages.map(e=>{let r=Yn(e),i=e.createdAt??e.recordedAt;return(0,J.jsxs)(`li`,{className:`flex min-h-11 min-w-0 flex-wrap items-center gap-2`,children:[(0,J.jsx)(W,{className:nr,to:`/tasks/${e.recipientRunId}`,"aria-label":`${X(e.recipientRunId,n)}${r?` — ${r}`:``}`,children:X(e.recipientRunId,n)}),r?(0,J.jsx)(`span`,{"data-slot":`conversation-outcome`,children:r}):null,(0,J.jsx)(ar,{message:e,runId:t,taskTitles:n}),i!==void 0&&Fn(i)!==void 0?(0,J.jsx)(`span`,{className:`ml-auto whitespace-nowrap`,children:(0,J.jsx)(Vn,{ts:i})}):null]},e.id)})}):null,e.messages.length===1&&l?(0,J.jsx)(ar,{message:l,runId:t,taskTitles:n}):null,(0,J.jsx)(or,{batch:e,heading:c})]})}function ar({message:e,runId:t,taskTitles:n}){let{targets:r,replies:i,navigate:a}=(0,q.useContext)(vn),o=e.requestId?r.get(e.requestId):void 0,s=e.requestId?o?[o]:[]:i.get(e.messageId)??[],c=e.requestId?`request`:`reply`;return s.length===0?e.requestId||e.outcome?.replyId?(0,J.jsxs)(`p`,{"data-slot":`conversation-connector`,className:`text-xs text-muted-foreground`,children:[`Linked `,c,` is outside loaded history.`]}):null:s.map(e=>{let r=Kn(e.message,t)===`outbound`,i=r?e.message.recipientRunId:e.message.senderRunId;return(0,J.jsxs)(`button`,{type:`button`,"data-slot":`conversation-connector`,className:H(nr,`w-fit gap-1.5 text-xs text-muted-foreground`),onClick:()=>a(e),children:[(0,J.jsx)(`span`,{"aria-hidden":!0,children:`↗`}),`View `,c,` `,r?`to`:`from`,` `,X(i,n)]},e.message.messageId)})}function or({batch:e,heading:t}){return(0,J.jsxs)(je,{"data-slot":`conversation-details`,className:`group/details`,children:[(0,J.jsxs)(Ae,{type:`button`,className:`inline-flex min-h-11 min-w-11 items-center gap-1.5 rounded-md px-2 text-left text-xs font-medium text-muted-foreground hover:bg-background/40 hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:[(0,J.jsx)(P,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/details:rotate-90`}),`Details`]}),(0,J.jsx)(U,{children:(0,J.jsxs)(`dl`,{className:`grid min-w-0 gap-1 break-all px-2 pb-1 font-mono text-[11px] text-muted-foreground`,children:[(0,J.jsx)(`div`,{className:`sr-only`,children:t}),e.messages.flatMap(e=>sr(e)).map((e,t)=>(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`dt`,{className:`inline font-sans font-medium text-soft-foreground`,children:[e.label,`: `]}),(0,J.jsx)(`dd`,{className:`inline`,children:e.value})]},`${e.label}:${e.value}:${t}`))]})})]})}function sr(e){let t=[{label:`Message`,value:e.messageId},{label:`Sender`,value:e.senderRunId},{label:`Recipient`,value:e.recipientRunId},{label:`Delivery`,value:Xn(e.delivery)}];return e.requestId&&t.push({label:`Request`,value:e.requestId}),e.outcome?.replyId&&t.push({label:`Reply`,value:e.outcome.replyId}),e.state&&t.push({label:`State`,value:e.state}),e.createdAt&&t.push({label:`Created`,value:e.createdAt}),e.deliveredAt&&t.push({label:e.resumed?`Opening turn completed`:`Delivery acknowledged`,value:e.deliveredAt}),e.recordedAt&&t.push({label:`Event recorded`,value:e.recordedAt}),e.resumed&&t.push({label:`Continuation`,value:`Requested by parent with this instruction`}),e.deadline&&t.push({label:`Deadline`,value:e.deadline}),e.requestHash&&t.push({label:`Hash`,value:e.requestHash}),t}function cr(e){let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n}function lr({note:e}){return e.icon===`handoff`?(0,J.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,"data-icon":`handoff`,className:`flex items-start gap-2 px-0.5 text-xs text-muted-foreground`,children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,className:`mt-[-1px] flex size-5 shrink-0 items-center justify-center rounded-full border border-border text-success`,children:(0,J.jsx)(Xe,{className:`size-3`})}),(0,J.jsx)(`span`,{className:`min-w-0 break-words`,children:e.text})]}):(0,J.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:H(`px-0.5 text-xs`,e.tone===`danger`?`text-danger [.light_&]:text-red-700`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:`· `,e.text]})}var ur={claude:`Claude Code`,codex:`Codex`,opencode:`OpenCode`,pi:`pi`,cursor:`Cursor`};function dr({incident:e}){let t=ur[e.provider];return(0,J.jsxs)(`div`,{role:`alert`,"data-slot":`provider-auth-required`,className:`rounded-md border border-danger/30 bg-danger/5 px-3.5 py-3`,children:[(0,J.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:[`This run needed `,t,` authorization`]}),(0,J.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Review `,t,` settings before retrying.`]}),(0,J.jsx)(W,{to:`/settings/agents#providers`,className:`mt-2 inline-flex text-xs font-medium text-foreground underline-offset-2 hover:underline`,children:`Open provider settings`})]})}function fr({text:e}){let t=(0,q.useId)();if(e.trim()===``)return null;let n=e.split(`
|
|
2
|
+
`,1)[0]??``,r=n.length<e.length;return(0,J.jsxs)(je,{"data-slot":`reasoning`,className:`group/reasoning min-w-0`,children:[(0,J.jsxs)(`div`,{id:t,className:`relative flex w-full items-center gap-1.5 rounded-md p-0.5 text-left text-[13px] text-soft-foreground hover:text-muted-foreground`,children:[(0,J.jsx)(P,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/reasoning:rotate-90`}),(0,J.jsx)(`span`,{className:`shrink-0`,children:`Thinking — `}),(0,J.jsx)(`div`,{className:`min-w-0 truncate text-muted-foreground`,children:(0,J.jsx)(xt,{inline:!0,children:n})}),r?(0,J.jsx)(`span`,{"aria-hidden":!0,children:`…`}):null,(0,J.jsx)(Ae,{"aria-labelledby":t,className:`absolute inset-0 rounded-md focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`})]}),(0,J.jsx)(U,{children:(0,J.jsx)(`div`,{className:`px-6 py-1.5 text-[13px] leading-[1.6] text-soft-foreground`,children:(0,J.jsx)(xt,{children:e})})})]})}function pr(){return(0,J.jsxs)(`div`,{"data-slot":`working-indicator`,className:`flex items-center gap-2 py-1 text-[13px] text-soft-foreground`,children:[(0,J.jsx)(_t,{role:`status`,"aria-label":`Working`,className:`size-3.5 shrink-0 animate-spin`}),(0,J.jsx)(`span`,{className:`shimmer font-medium`,children:`Working…`})]})}var mr={read:Ze,edit:qt,delete:_,move:Gt,search:T,execute:bt,think:Ut,fetch:Re,task:g,plan:c,other:L},hr=e=>e.split(`
|
|
3
|
+
`).length;function gr({text:e,streaming:t}){let[n,r]=(0,q.useState)(!1),i=(0,q.useRef)(null),a=(0,q.useRef)(!0);(0,q.useEffect)(()=>{let e=i.current;t&&e&&a.current&&(e.scrollTop=e.scrollHeight)},[e,t]);let o=hr(e),s=!t&&!n&&o>12;return(0,J.jsxs)(`div`,{"data-slot":`tool-output`,"data-clamped":s?`true`:void 0,children:[(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(`div`,{ref:i,onScroll:t?e=>{a.current=Sn(e.currentTarget)}:void 0,className:H(`overflow-x-auto`,t&&`max-h-[216px] overflow-y-auto`,s&&`max-h-[216px] overflow-y-hidden`),children:(0,J.jsx)(`pre`,{className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre text-muted-foreground`,children:e})}),s?(0,J.jsx)(`div`,{"data-slot":`tool-output-fade`,"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 h-14 bg-gradient-to-b from-transparent to-card-2`}):null]}),!t&&o>12?(0,J.jsx)(`button`,{type:`button`,"data-slot":`tool-output-toggle`,onClick:()=>r(e=>!e),className:`block w-full border-t border-border/50 px-4 py-1.5 text-left text-[11px] font-medium text-soft-foreground hover:text-foreground`,children:n?`Show less`:`Show all ${o} lines`}):null]})}function _r({diffs:e}){return(0,J.jsx)(J.Fragment,{children:e.map((e,t)=>(0,J.jsxs)(`div`,{"data-slot":`diff-preview`,className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`border-b border-border/50 px-4 py-1.5 font-mono text-[11px] text-soft-foreground`,children:e.path}),(0,J.jsx)(`pre`,{className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:e.unified===void 0?[...vr(e.oldText).map((e,t)=>(0,J.jsxs)(`span`,{className:`block bg-diff-del px-4 text-muted-foreground`,children:[`- `,e]},`old-${t}`)),...vr(e.newText).map((e,t)=>(0,J.jsxs)(`span`,{className:`block bg-diff-add px-4`,children:[`+ `,e]},`new-${t}`))]:e.unified.split(`
|
|
4
|
+
`).map((e,t)=>(0,J.jsx)(yr,{text:e},t))})]},`${e.path}:${t}`))})}function vr(e){return e==null||e===``?[]:e.replace(/\n$/,``).split(`
|
|
5
|
+
`)}function yr({text:e}){return(0,J.jsx)(`span`,{className:H(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del text-muted-foreground`,e.startsWith(`@@`)&&`text-soft-foreground`),children:e})}function br(e){return e.toolKind===`execute`&&e.status===`running`&&e.output!==void 0}function xr({item:e,nested:t=[],cacheKey:n,renderNested:r}){let i=gn(),[a,o]=(0,q.useState)(()=>n===void 0?null:i?.get(n)??null),s=e=>{n!==void 0&&i?.set(n,e),o(e)},c=e.status===`running`||e.status===`pending`,l=dn(e.title),{verb:u,detail:d}=e.toolKind===`execute`&&l.detail===void 0?{verb:`Ran`,detail:e.title}:l,f=e.output!==void 0&&e.output!==``||e.error!==void 0&&e.error!==``||e.diffs!==void 0&&e.diffs.length>0||t.length>0,p=d!==void 0||f,m=p&&(a??(f&&br(e))),h=mr[e.toolKind]??L;return(0,J.jsxs)(je,{"data-slot":`tool-card`,"data-status":e.status,"data-kind":e.toolKind,open:m,onOpenChange:s,className:H(`min-w-0 overflow-hidden rounded-md border bg-card`,e.status===`failed`?`border-danger/25`:`border-border`),children:[(0,J.jsxs)(Ae,{disabled:!p,className:`group flex min-h-[28px] w-full items-center gap-1.5 px-2.5 py-0.5 text-left text-[13px] enabled:hover:bg-muted`,children:[(0,J.jsx)(P,{"aria-hidden":!0,className:H(`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`,!p&&`invisible`)}),(0,J.jsx)(h,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,J.jsx)(`span`,{className:H(`shrink-0 font-semibold`,c&&`shimmer`,e.status===`declined`&&`text-muted-foreground`),children:u}),d===void 0?null:(0,J.jsx)(`code`,{title:d,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:d}),(0,J.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[c?(0,J.jsx)(_t,{role:`status`,"aria-label":`Running`,className:`size-3.5 animate-spin text-soft-foreground`}):null,e.status===`failed`?(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`failed`}):null,e.status===`declined`?(0,J.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`declined`}):null,e.toolKind===`execute`&&typeof e.exitCode==`number`?(0,J.jsx)(`span`,{"data-slot":`tool-exit`,className:H(`rounded-full px-2 py-px font-mono text-[11px] font-semibold`,e.exitCode===0?`bg-success/10 text-success`:`bg-danger/10 text-danger`),children:e.exitCode}):null]})]}),(0,J.jsx)(U,{children:(0,J.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[d===void 0?null:(0,J.jsx)(`pre`,{"data-slot":`tool-command`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:d}),e.error!==void 0&&e.error!==``?(0,J.jsx)(`div`,{"data-slot":`tool-error`,className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre-wrap text-danger`,children:e.error}):null,e.diffs!==void 0&&e.diffs.length>0?(0,J.jsx)(_r,{diffs:e.diffs}):null,e.output!==void 0&&e.output!==``?(0,J.jsx)(gr,{text:e.output,streaming:c}):null,t.length>0?(0,J.jsx)(`div`,{"data-slot":`tool-nested`,className:`flex flex-col gap-2 border-l-2 border-border py-2.5 pr-3 pl-3 ml-4 my-2`,children:r?.(t,n??e.id)}):null]})})]})}function Sr({group:e,scope:t}){return(0,J.jsxs)(je,{"data-slot":`ctx-group`,className:`min-w-0`,children:[(0,J.jsxs)(Ae,{className:`group flex h-[34px] tabular-nums w-full items-center gap-2 rounded-md px-2 -mx-2 text-left text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,J.jsx)(P,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),e.label]}),(0,J.jsx)(U,{children:(0,J.jsx)(`div`,{className:`flex flex-col gap-1.5 pt-1.5 pl-4`,children:e.tools.map(e=>(0,J.jsx)(xr,{item:e,cacheKey:t===void 0?void 0:`${t}:${e.id}`},e.id))})})]})}function Cr({count:e,children:t}){return(0,J.jsxs)(je,{"data-slot":`tool-streak`,className:`min-w-0`,children:[(0,J.jsxs)(Ae,{className:`group flex items-center gap-1.5 rounded-md p-0.5 tabular-nums text-left text-xs text-soft-foreground hover:text-muted-foreground`,children:[(0,J.jsx)(P,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),ln(e)]}),(0,J.jsx)(U,{children:(0,J.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t})})]})}function wr({image:e}){return(0,J.jsx)(jt,{"data-slot":`thread-image`,src:e.url,alt:e.name??`image from the agent session`,className:`max-h-72 max-w-full self-start rounded-lg border border-border`})}function Tr(e,t=null){let n=p(),r=le(),i=Ue(e),a=i&&!e.runner,o=ve(n.data),s=e.runner??(i?r.data?.defaultRunner:void 0)??`claude`,c=ct(t,o,s),l=o.includes(s),u=(i?Oe(e.workflowDef,c):[c]).filter(e=>!o.includes(e)),d=n.isSuccess&&(!a||r.isSuccess)&&u.length===0,f=a&&r.isPending?`Checking task settings…`:a&&r.isError?`Task settings could not be loaded.`:n.isPending?`Checking agent providers…`:n.isError?`Provider authentication could not be verified.`:d?void 0:i?`Connect the required workflow providers (${u.join(`, `)}) to continue.`:`Connect an agent provider to continue.`;return{runners:o,currentRunner:s,runner:c,currentRunnerConnected:l,canContinue:d,providerPending:n.isPending||a&&r.isPending,providerError:n.isError,reason:f,runnerOverride:t!==null||!l?c:void 0}}function Er(e){let t=u(),n=qe(e).continueRun,r=le(),[a,s]=(0,q.useState)(null),[c,l]=(0,q.useState)(null),[d,f]=(0,q.useState)(null),[p,m]=(0,q.useState)(null),[h,g]=(0,q.useState)(e.id);h!==e.id&&(g(e.id),s(null),l(null),f(null),m(null));let _=Tr(e,a),{runners:v,canContinue:y,currentRunner:b,runner:x}=_,S=ne(x,n),C=r.data?.modelsLocked===!0,w=x!==b,T=!C&&!w&&e.model?{...r.data?.defaultModels,[x]:e.model}:r.data?.defaultModels,E=C?null:c,D=mt(x,S.data,[E,T?.[x]]),O=ht(E,x,T,S.data),k=ft(x,O,S.data),A=C?``:d??e.effort??``,j=ut(A,k),M=!C&&d===null&&A!==``&&j===``,{accounts:N,repoAccount:P}=Me(),F=[...e.steps].reverse().find(e=>e.sessionId),ee=F?.profileId??e.agentProfile??`default`,I=w?P:{...P,[b]:ee},L=N.some(e=>e.provider===x&&e.id===p)?p:null,R=i({mutationFn:({text:t,images:n})=>y?o(e.id,{text:t.trim()?t:void 0,images:n.length?n:void 0,runner:_.runnerOverride,model:!C&&(c!==null||w)?O:void 0,effort:!C&&(d!==null||w)?j:M?``:void 0,agentProfile:L??void 0}):Promise.reject(Error(_.reason??`Connect an agent provider to continue.`)),onSuccess:()=>t.invalidateQueries({queryKey:z.runs.all}),onError:e=>{e instanceof he&&e.status===409&&t.invalidateQueries({queryKey:z.runs.all})}});return{available:n,canContinue:y,startsNewConversation:!!F&&(x!==(F.backend??b)||(L??e.agentProfile??F.profileId??`default`)!==(F.profileId??`default`)),reason:_.reason,providerPending:_.providerPending,pills:(0,J.jsxs)(`div`,{"data-slot":`follow-up-engine`,className:`session-engine-controls`,children:[v.length>1||v.some(e=>Pe(N,e))?(0,J.jsx)(pt,{icon:(0,J.jsx)(pe,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:v,value:x,accounts:N,account:L,repoAccount:I,onPick:(e,t)=>{m(t),e!==x&&(s(e),l(null))}}):(0,J.jsx)(dt,{icon:(0,J.jsx)(pe,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,readOnly:!0,slot:`session-runner-value`,ariaLabel:`Runner`,label:x,value:x,onPick:()=>{},options:[{value:x,label:x}]}),(0,J.jsx)(dt,{icon:(0,J.jsx)(te,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-model-pill`,ariaLabel:`Model`,label:D.find(e=>e.id===O)?.label??`auto`,value:O,readOnly:C,disabledHint:`Model selection is locked to native coding-agent settings.`,onPick:e=>{l(e);let t=ft(x,e,S.data);j!==``&&ut(j,t)===``&&f(``)},options:D.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:lt(x,S.data,S.isError,S.isFetching)}),(0,J.jsx)(dt,{icon:(0,J.jsx)(ae,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`follow-up-effort-pill`,ariaLabel:`Effort`,label:k.find(e=>e.value===j)?.label??`auto`,value:j,readOnly:C,disabledHint:`Effort selection is locked to native coding-agent settings.`,onPick:e=>f(e),options:k.map(e=>({value:e.value,label:e.label,desc:e.desc}))})]}),continueWith:(e,t)=>R.mutateAsync({text:e,images:t})}}var Dr=120,Or=e=>e!==`pending`&&e!==`running`,kr=e=>e.kind===`tool`&&e.toolKind===`task`,Z=e=>kr(e)&&e.parentItemId===void 0,Ar=e=>(e.kind===`message`||e.kind===`reasoning`||e.kind===`tool`)&&!(e.kind===`tool`&&e.toolKind===`plan`);function jr(e,t){for(let n=0;n<e.length;n+=1)if(e[n].items.some(e=>Z(e)&&t.has(e.id)))return n;return 0}function Mr(e){let t=e.input;if(typeof t!=`object`||!t)return;let n=t;for(let e of[`subagent_type`,`subagentType`,`agent`]){let t=n[e];if(typeof t==`string`&&t.trim()!==``)return t.trim()}}function Nr(e){if(e.kind===`tool`)return Pr(e.title);if(e.kind===`message`||e.kind===`reasoning`){let t=e.text.split(`
|
|
6
|
+
`);for(let e=t.length-1;e>=0;--e){let n=t[e].trim();if(n!==``)return Pr(n)}}}function Pr(e){return e.length>Dr?`${e.slice(0,Dr-1).trimEnd()}…`:e}function Fr(e,t=!1){let n=zr(e,e=>e.items.some(Z));if(n===-1)return[];let r=e=>!t&&!Or(e.status),i=[];for(let t=n-1;t>=0;--t){let n=e[t].items.filter(Z);if(n.length!==0){if(!n.some(r))break;i.unshift(...n)}}let a=[...i,...e[n].items.filter(Z)];if(n!==e.length-1&&!a.some(r))return[];let o=new Set(a.map(e=>e.id)),s=i.length>0?jr(e,o):n,c=new Map;for(let t=s;t<e.length;t+=1)for(let n of e[t].items){if(!Ar(n))continue;let e=n.parentItemId;if(e===void 0||!o.has(e))continue;let t=c.get(e);t?t.push(n):c.set(e,[n])}return a.map(e=>Ir(e,c.get(e.id)??[],t))}function Ir(e,t,n){let r={id:e.id,title:dn(e.title).detail??e.title,status:e.status,toolCalls:t.filter(e=>e.kind===`tool`).length},i=Mr(e);i!==void 0&&(r.agentType=i),n&&!Or(e.status)&&(r.stalled=!0);for(let e=t.length-1;e>=0;--e){let n=Nr(t[e]);if(n!==void 0){r.activity=n;break}}return r}function Lr(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.length}}function Rr(e){return e.activity??(e.stalled===!0?`never finished`:`starting…`)}function zr(e,t){for(let n=e.length-1;n>=0;--n)if(t(e[n]))return n;return-1}function Br(e,t,n=!1){for(let r=e.length-1;r>=0;--r){let i=e[r].items.find(e=>e.id===t&&Z(e));if(i!==void 0)return Ir(i,Vr(e,t),n)}}function Vr(e,t){let n=e.findIndex(e=>e.items.some(e=>e.id===t&&Z(e)));if(n===-1)return[];let r=[];for(let i=n;i<e.length;i+=1)for(let n of e[i].items)Ar(n)&&n.parentItemId===t&&n.id!==t&&r.push(n);return r}function Hr(e,t={}){let{surface:n=`document`,onLoadOlder:r,onJumpToLatest:i,rowKeys:a=[]}=t,o=(0,q.useRef)(e);o.current=e;let s=(0,q.useRef)(null),[c,l]=(0,q.useState)(null),[u,d]=(0,q.useState)(!1),f=(0,q.useRef)(!0),p=(0,q.useRef)(0),m=(0,q.useRef)(null),h=(0,q.useRef)(null),g=(0,q.useRef)(null),_=(0,q.useCallback)(e=>{let t=s.current;if(!t)return;let n=g.current;n?n.scrollTo(e):t.scrollTop=e},[]),v=(0,q.useCallback)(()=>{let e=s.current;e&&_(e.scrollHeight-e.clientHeight)},[_]),y=(0,q.useCallback)(()=>{if(s.current){if(h.current!==e){h.current=e;let t=En(e);t&&!t.atBottom?(f.current=!1,m.current=t.top):(f.current=!0,m.current=null)}m.current===null?f.current&&v():_(m.current)}},[e,_,v]),x=(0,q.useCallback)(e=>{l(e),e&&(s.current=e.closest(n===`panel`?`[data-slot="transcript-viewport"]`:`[data-slot="main"]`),y())},[n,y]),S=(0,q.useCallback)(()=>{f.current&&v()},[v]),C=(0,q.useRef)(!1),w=(0,q.useRef)(0),T=(0,q.useRef)(!1),E=(0,q.useRef)(void 0),D=(0,q.useRef)(!1),O=(0,q.useRef)(!1),k=(0,q.useRef)(a);k.current=a;let A=(0,q.useCallback)(e=>[...e.querySelectorAll(`[data-slot="thread-row"][data-row-key]`)].map(e=>{let t=e.getBoundingClientRect();return{key:e.dataset.rowKey,top:t.top,bottom:t.bottom}}),[]),j=(0,q.useRef)(null),M=(0,q.useRef)(0);(0,q.useEffect)(()=>{if(!b())return;let e=e=>{m.current=null,M.current+=1,j.current=null,f.current=!1,_(e)};return window.__cezThreadScrollTo=e,()=>{window.__cezThreadScrollTo===e&&delete window.__cezThreadScrollTo}},[_]);let N=(0,q.useCallback)(()=>{let e=j.current,t=s.current;if(!e||!t)return;j.current=null;let n=e.beforeTop+Math.max(0,t.scrollHeight-e.beforeHeight),r=t.getBoundingClientRect().top,i=e.anchor===void 0?-1:k.current.indexOf(e.anchor.key),a=g.current;a&&i>=0?a.scrollToIndex(i,{align:`start`,offset:-e.anchor.offset}):_(xn(t.scrollTop,r,e.anchor,A(t),n))},[A,_]),P=(0,q.useCallback)(()=>{let e=s.current;if(!e||!r||C.current)return;m.current=null,f.current=!1,C.current=!0;let t=w.current+1;w.current=t;let n=e.scrollHeight,i=e.scrollTop,a=e.getBoundingClientRect().top,c=bn(a,A(e)),l=c===void 0?-1:k.current.indexOf(c.key),u=o.current,d=M.current;r().then(()=>{o.current===u&&M.current===d&&(j.current={beforeHeight:n,beforeTop:i,anchor:c,anchorIndex:l})},()=>{}).finally(()=>{w.current===t&&(C.current=!1)})},[A,r]);(0,q.useEffect)(()=>()=>clearTimeout(E.current),[]);let F=(0,q.useRef)(null);(0,q.useEffect)(()=>()=>F.current?.disconnect(),[e,c]);let ee=(0,q.useCallback)((t,n)=>{let r=s.current;if(!r||!c)return;m.current=null,M.current+=1,j.current=null,f.current=!1,p.current=0,d(!0),F.current?.disconnect();let i=()=>[...c.querySelectorAll(`[data-row-key]`)].find(e=>e.dataset.rowKey===t),a=()=>{let e=i();return!e||getComputedStyle(e).visibility===`hidden`||(e.tabIndex=-1,e.focus({preventScroll:!0}),document.activeElement!==e)?!1:(F.current?.disconnect(),!0)},o=r.querySelector(`[data-slot="run-header"]`),l=o&&getComputedStyle(o).position===`sticky`?o.getBoundingClientRect().height:0,u=g.current;if(u)u.scrollToIndex(n,{align:`start`,...l>0?{offset:-l}:{}});else{let e=i();e&&_(r.scrollTop+e.getBoundingClientRect().top-r.getBoundingClientRect().top-l)}a()||(F.current=new MutationObserver(()=>{a()}),F.current.observe(c,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`,`class`]})),Tn(e,{top:r.scrollTop,atBottom:!1})},[c,_,e]),te=(0,q.useCallback)(()=>{F.current?.disconnect();let t=s.current;if(!t)return;m.current=null,M.current+=1,j.current=null,f.current=!0,Tn(e,{top:t.scrollHeight-t.clientHeight,atBottom:!0});let n=()=>{f.current&&v()};(i?.()??Promise.resolve()).finally(()=>{requestAnimationFrame(()=>{n(),requestAnimationFrame(n)})})},[i,e,v]),I=a.at(-1),ne=a.length;return(0,q.useLayoutEffect)(()=>{M.current+=1,j.current=null,C.current=!1},[e]),(0,q.useLayoutEffect)(()=>{let e=j.current;e?(e.anchor===void 0?-1:k.current.indexOf(e.anchor.key))>e.anchorIndex?N():j.current=null:f.current&&v()},[I,ne,N,v]),(0,q.useLayoutEffect)(()=>{!s.current||!c||y()},[c,y]),(0,q.useEffect)(()=>{let t=s.current,n=c;if(!t||!n)return;p.current=0;let r=null,i=!1,a=t.scrollTop,o=()=>{F.current?.disconnect(),m.current=null,M.current+=1,j.current=null,f.current=!1,p.current=0},l=()=>{M.current+=1,j.current=null,p.current=Date.now()},u=e=>{if(e.deltaY<0){o();let e=!T.current;T.current=!0,clearTimeout(E.current),E.current=setTimeout(()=>{T.current=!1},180),e&&yn(t)&&P()}else l()},h=e=>{[`ArrowUp`,`PageUp`,`Home`].includes(e.key)?(o(),!e.repeat&&yn(t)&&P()):[`ArrowDown`,`PageDown`,`End`].includes(e.key)&&l()},g=()=>{i=!0,O.current=!1,a=t.scrollTop,Sn(t,80)||(o(),l())},y=()=>{i=!1},b=e=>{D.current=!1,r=e.touches[0]?.clientY??null},x=e=>{let n=e.touches[0]?.clientY;n!==void 0&&(r!==null&&n>r+1?(o(),!D.current&&yn(t)&&(D.current=!0,P())):r!==null&&n<r-1&&l(),r=n)},S=()=>{i&&!O.current&&t.scrollTop<a&&yn(t)&&(O.current=!0,P()),a=t.scrollTop;let n=Sn(t,80);n&&m.current===null&&(f.current||Date.now()-p.current<2e3)&&(f.current=!0),d(!n),m.current===null&&Tn(e,{top:t.scrollTop,atBottom:n})};t.addEventListener(`scroll`,S,{passive:!0}),t.addEventListener(`wheel`,u,{passive:!0}),t.addEventListener(`touchstart`,b,{passive:!0}),t.addEventListener(`touchmove`,x,{passive:!0}),t.addEventListener(`pointerdown`,g,{passive:!0}),window.addEventListener(`pointerup`,y,{passive:!0}),t.addEventListener(`keydown`,h);let C;if(typeof ResizeObserver<`u`){C=new ResizeObserver(()=>{let e=m.current;if(e!==null){let n=t.scrollHeight-t.clientHeight;_(Math.min(e,n)),n>=e&&(m.current=null)}else f.current&&v()}),C.observe(n);let e=n.closest(`[data-route="task-thread"]`),r=e?.querySelector(`[data-slot="run-header"]`),i=e?.querySelector(`[data-slot="thread-dock"]`);r&&C.observe(r),i&&C.observe(i)}return()=>{t.removeEventListener(`scroll`,S),t.removeEventListener(`wheel`,u),t.removeEventListener(`touchstart`,b),t.removeEventListener(`touchmove`,x),t.removeEventListener(`pointerdown`,g),window.removeEventListener(`pointerup`,y),t.removeEventListener(`keydown`,h),C?.disconnect()}},[e,c,P,_,v]),{attachContent:x,scrollElRef:s,virtualizerRef:g,pillVisible:u,jumpToLatest:te,jumpToRow:ee,loadOlder:P,restickIfStuck:S}}function Ur({runId:e,rows:t,mode:n,controls:r}){return n===`virtual`?(0,J.jsx)(Wr,{runId:e,rows:t,controls:r}):(0,J.jsx)(`div`,{ref:r.attachContent,"data-slot":`thread-rows`,"data-virtualized":`false`,className:`[overflow-anchor:none]`,children:t.map(e=>(0,J.jsx)(`div`,{"data-slot":`thread-row`,"data-row-key":e.key,className:`flex w-full flex-col pb-2.5 [contain-intrinsic-block-size:auto_3rem] [content-visibility:auto]`,children:e.node},e.key))})}function Wr({runId:e,rows:t,controls:n}){return(0,J.jsx)(Gr,{runId:e,rows:t,controls:n},e)}function Gr({runId:e,rows:t,controls:n}){let r=(0,q.useRef)(null),i=(0,q.useRef)(t),a=t[0]?.key,o=i.current[0]?.key,s=a!==o&&(t.some(e=>e.key===o)||i.current.some(e=>e.key===a));(0,q.useLayoutEffect)(()=>{i.current=t},[t]);let[c]=(0,q.useState)(()=>kn(e,t.length)),l=(0,q.useRef)(t.length);l.current=t.length;let u=(0,q.useRef)(null),d=(0,q.useCallback)(t=>{n.virtualizerRef.current=t,t?u.current=t:u.current&&=(On(e,{rows:l.current,cache:u.current.cache}),null)},[e,n.virtualizerRef]),[f,p]=(0,q.useState)(0);return(0,q.useLayoutEffect)(()=>{let e=()=>{let e=r.current,t=n.scrollElRef.current;!e||!t||p(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[n.scrollElRef]),(0,J.jsx)(`div`,{ref:e=>{r.current=e,n.attachContent(e)},"data-slot":`thread-rows`,"data-virtualized":`true`,className:`[overflow-anchor:none]`,children:(0,J.jsx)(At,{ref:d,scrollRef:n.scrollElRef,startMargin:f,shift:s,...c===void 0?{}:{cache:c},children:t.map(e=>(0,J.jsx)(`div`,{"data-slot":`thread-row`,"data-row-key":e.key,className:`flex w-full flex-col pb-2.5`,children:e.node},e.key))})})}function Kr({onJump:e}){return(0,J.jsxs)(`button`,{type:`button`,"data-slot":`jump-to-latest`,onClick:e,className:`pointer-events-auto inline-flex min-h-11 min-w-11 items-center gap-1.5 rounded-full border border-border bg-background px-3.5 text-xs font-medium text-muted-foreground shadow-modal hover:text-foreground`,children:[(0,J.jsx)(d,{"aria-hidden":!0,className:`size-3.5`}),`Jump to latest`]})}function qr(e,t){let n=[];e.task&&n.push({id:`task`,userMessageKey:`task`,userMessage:{text:e.task,images:e.taskImages??[],ts:e.createdAt},entries:[]});for(let t of e.queuedMessages??[])n.push({id:`queued:${t.id}`,userMessageKey:`queued:${t.id}`,userMessage:{text:t.text,images:t.images??[],ts:t.createdAt},inDaySequence:!1,entries:[]});for(let e of t.turns)n.push({id:e.id,userMessageKey:`${e.id}:user`,...e.userMessage===void 0?{}:{userMessage:{text:e.userMessage.text,imageCount:e.userMessage.imageCount,images:e.userMessage.images,...e.userMessage.ts===void 0?{}:{ts:e.userMessage.ts}}},...e.startedAt===void 0?{}:{startedAt:e.startedAt},...e.completed?.ts===void 0?{}:{completedAt:e.completed.ts},entries:e.items});return n}function Jr(e,t){return[{id:`agent:${e}`,entries:t}]}function Yr(e){if(e.inDaySequence!==!1)return e.userMessage?.ts??e.startedAt??e.completedAt}function Xr(e,t){let n=[],r;for(let t of e){let e=Yr(t),i=Rn(e);i!==void 0&&e!==void 0&&(r===void 0||i>r)&&(r!==void 0&&n.push({key:`${t.id}:day-separator`,scope:t.id,content:{kind:`day-separator`,ts:e}}),r=i),t.userMessage!==void 0&&n.push({key:t.userMessageKey??`${t.id}:user`,scope:t.id,content:{kind:`user-message`,message:t.userMessage}});for(let e of fn([...t.entries]))n.push({key:`${t.id}:${e.id}`,scope:t.id,content:{kind:`block`,block:e}});t.completedAt!==void 0&&n.push({key:`${t.id}:turn-time`,scope:t.id,content:{kind:`turn-time`,completedAt:t.completedAt,...t.startedAt===void 0?{}:{startedAt:t.startedAt}}})}return n}function Zr({runId:e,viewId:t,sections:n,mode:r,empty:i,renderAsk:a,messageActions:o,scrollControls:s,renderMode:c,taskTitles:l,recipientBackends:u}){let d=(0,q.useMemo)(()=>Xr(n,e),[n,e]),f=Hr(`${e}:${t}`,{surface:r}),p=s??f,m=(0,q.useMemo)(()=>{let e=new Map;d.forEach((t,n)=>{if(!(t.content.kind!==`block`||t.content.block.kind!==`worker-conversation`))for(let r of t.content.block.batches)for(let i of r.messages)e.set(i.messageId,{message:i,rowKey:t.key,rowIndex:n})});let t=new Map;for(let n of e.values()){let{message:e}=n;if(e.messageKind!==`reply`||!e.requestId)continue;let r=t.get(e.requestId)??[];r.push(n),t.set(e.requestId,r)}return{targets:e,replies:t,navigate:e=>p.jumpToRow(e.rowKey,e.rowIndex)}},[d,p.jumpToRow]),h=(0,q.useMemo)(()=>d.map(t=>({key:t.key,node:Qr(t,o?.[t.key],a,e,l,u)})),[o,a,d,e,l,u]),g=c??Cn(``,h.length),_=h.length===0?i??null:(0,J.jsx)(Ur,{runId:`${e}:${t}`,rows:h,mode:g,controls:p});return(0,J.jsx)($e,{runId:e,children:(0,J.jsx)(_n,{runId:e,children:(0,J.jsx)(vn.Provider,{value:m,children:r===`panel`?(0,J.jsxs)(`div`,{"data-slot":`transcript-viewport`,"aria-label":`Agent transcript`,role:`region`,tabIndex:0,className:`relative flex min-h-0 flex-1 flex-col overflow-y-auto [scrollbar-gutter:stable]`,children:[(0,J.jsx)(`div`,{"data-slot":`subagent-stream`,className:`flex flex-col px-5 py-4`,children:_}),p.pillVisible?(0,J.jsx)(`div`,{className:`pointer-events-none sticky inset-x-0 bottom-4 flex justify-center`,children:(0,J.jsx)(Kr,{onJump:p.jumpToLatest})}):null]}):_})})})}function Qr(e,t,n,r,i,a){switch(e.content.kind){case`user-message`:return(0,J.jsx)($r,{message:e.content.message,actions:t});case`day-separator`:return(0,J.jsx)(Un,{ts:e.content.ts});case`turn-time`:return(0,J.jsx)(Hn,{completedAt:e.content.completedAt,...e.content.startedAt===void 0?{}:{startedAt:e.content.startedAt}});case`block`:return(0,J.jsx)(ei,{block:e.content.block,scope:e.scope,renderAsk:n,runId:r,taskTitles:i,recipientBackends:a});default:return ri(e.content)}}function $r({message:e,actions:t}){return(0,J.jsx)($n,{text:e.text,imageCount:e.imageCount,images:e.images,...e.ts===void 0?{}:{ts:e.ts},onEdit:t?.onEdit,onRemove:t?.onRemove,editLabel:t?.editLabel,removeLabel:t?.removeLabel})}function ei({block:e,scope:t,renderAsk:n,runId:r,taskTitles:i,recipientBackends:a}){switch(e.kind){case`entry`:return(0,J.jsx)(ni,{entry:e.entry,scope:t,renderAsk:n,runId:r,taskTitles:i,recipientBackends:a});case`tool-card`:return(0,J.jsx)(xr,{item:e.item,nested:e.children,cacheKey:`${t}:${e.id}`,renderNested:(e,t)=>(0,J.jsx)(ti,{entries:e,scope:t,renderAsk:n,runId:r,taskTitles:i,recipientBackends:a})});case`context-group`:return(0,J.jsx)(Sr,{group:e,scope:t});case`streak`:return(0,J.jsx)(Cr,{count:e.count,children:e.blocks.map(e=>(0,J.jsx)(ei,{block:e,scope:t,renderAsk:n,runId:r,taskTitles:i,recipientBackends:a},e.id))});case`worker-conversation`:return(0,J.jsx)(rr,{block:e,runId:r,taskTitles:i,recipientBackends:a});default:return ri(e)}}function ti({entries:e,scope:t,renderAsk:n,runId:r,taskTitles:i,recipientBackends:a}){return fn([...e]).map(e=>(0,J.jsx)(ei,{block:e,scope:t,renderAsk:n,runId:r,taskTitles:i,recipientBackends:a},e.id))}function ni({entry:e,scope:t,renderAsk:n,runId:r,taskTitles:i,recipientBackends:a}){switch(e.kind){case`message`:return e.role===`assistant`?(0,J.jsx)(er,{text:e.text,ts:e.ts}):(0,J.jsx)($n,{text:e.text,ts:e.ts});case`reasoning`:return(0,J.jsx)(fr,{text:e.text});case`tool`:return(0,J.jsx)(xr,{item:e,cacheKey:`${t}:${e.id}`});case`note`:return e.attribution?(0,J.jsxs)(`div`,{className:`min-w-0 rounded-md border border-border px-4 py-3 text-sm`,children:[(0,J.jsx)(`p`,{className:`mb-2 break-all text-xs text-muted-foreground`,children:e.attribution.source===`agent`?`Agent input from parent ${e.attribution.parentRunId}`:`Worker lifecycle context for parent ${e.attribution.parentRunId}`}),(0,J.jsx)(lr,{note:e})]}):(0,J.jsx)(lr,{note:e});case`conversation`:return(0,J.jsx)(rr,{runId:r,taskTitles:i,recipientBackends:a,block:{kind:`worker-conversation`,id:e.id,batches:[{id:e.id,kind:e.messageKind,text:e.text,senderRunId:e.senderRunId,messages:[e]}]}});case`image`:return(0,J.jsx)(wr,{image:e});case`ask`:return n===void 0?(0,J.jsx)(`div`,{"data-slot":`ask-card`,className:`rounded-lg border border-border bg-card px-4 py-3 text-sm`,children:`The agent asked a question. Open the main session to answer it.`}):n(e);case`provider-auth-required`:return(0,J.jsx)(dr,{incident:e});default:return ri(e)}}function ri(e){throw Error(`Unhandled transcript variant: ${JSON.stringify(e)}`)}function ii({runId:e,renderAsk:t,agent:n,entries:r,onClose:i,taskTitles:a,recipientBackends:o}){return(0,J.jsx)(Ct,{open:n!==void 0,onOpenChange:e=>{e||i()},children:(0,J.jsx)(Et,{"data-slot":`subagent-sheet`,side:`right`,className:`flex min-h-0 w-full gap-0 p-0 sm:max-w-xl`,children:n===void 0?null:(0,J.jsx)(ai,{runId:e,renderAsk:t,agent:n,entries:r,taskTitles:a,recipientBackends:o})})})}function ai({runId:e,renderAsk:t,agent:n,entries:r,taskTitles:i,recipientBackends:a}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(St,{className:`gap-1.5 border-b border-border px-5 py-4`,children:[(0,J.jsxs)(wt,{className:`flex min-w-0 items-center gap-2 pr-8 text-[16px]`,children:[(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:n.title}),n.agentType===void 0?null:(0,J.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:n.agentType})]}),(0,J.jsxs)(Dt,{"data-slot":`subagent-meta`,className:`flex items-center gap-2 text-xs`,children:[(0,J.jsx)(oi,{status:n.status}),(0,J.jsxs)(`span`,{className:`tabular-nums`,children:[n.toolCalls,` `,n.toolCalls===1?`tool call`:`tool calls`]})]})]}),(0,J.jsx)(Zr,{runId:e,viewId:`agent:${n.id}`,sections:Jr(n.id,r),mode:`panel`,renderAsk:t,taskTitles:i,recipientBackends:a,empty:(0,J.jsx)(`div`,{"data-slot":`subagent-empty`,className:`py-2 text-[13px] text-muted-foreground`,children:`No attributed output — see the thread card for this agent's result.`})})]})}function oi({status:e}){let t=e===`completed`?`Completed`:e===`failed`?`Failed`:e===`declined`?`Declined`:e===`pending`?`Pending`:`Running`;return(0,J.jsx)(`span`,{"data-slot":`subagent-status`,"data-status":e,className:H(`rounded-full px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] uppercase`,e===`completed`&&`bg-success/15 text-success`,(e===`failed`||e===`declined`)&&`bg-danger/15 text-danger`,(e===`running`||e===`pending`)&&`bg-muted text-muted-foreground`),children:t})}function si(e){let t=u();return i({mutationFn:()=>v(e),onSuccess:()=>t.invalidateQueries({queryKey:z.runs.all}),onError:e=>V(e.message,{tone:`danger`})})}function ci({run:e}){return(0,J.jsxs)(`section`,{"data-slot":`review-panel`,"aria-label":`Review the changes`,className:`flex flex-col gap-3`,children:[(0,J.jsxs)(`div`,{"data-slot":`review-banner`,className:`flex items-center gap-2.5 rounded-md border border-accent-strong/30 bg-accent-strong/10 px-3.5 py-2.5`,children:[(0,J.jsx)(st,{className:`size-4 shrink-0 text-accent-icon`,"aria-hidden":`true`}),(0,J.jsxs)(`p`,{className:`min-w-0 text-[13px]`,children:[(0,J.jsx)(`span`,{className:`font-semibold`,children:`Review the changes before anything lands.`}),` `,(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Read the diff, send notes back, draft a PR — or accept. Nothing merges on its own.`})]})]}),(0,J.jsx)(Mt,{runId:e.id}),(0,J.jsx)(li,{run:e})]})}function li({run:e}){let t=u(),n=(0,q.useRef)(null),[r,a]=(0,q.useState)(``),[c,l]=(0,q.useState)(null),d=si(e.id),f=Tr(e),p=()=>t.invalidateQueries({queryKey:z.runs.all}),m=i({mutationFn:async t=>f.canContinue?o(e.id,{text:`Review feedback:\n${t}`,runner:f.runnerOverride}):null,onSuccess:e=>{e!==null&&(a(``),p())},onError:e=>V(e.message,{tone:`danger`})}),h=i({mutationFn:()=>s(e.id),onSuccess:e=>{V(`Draft PR created — ${e.url}`),p()},onError:e=>{e instanceof he&&e.manual!==void 0&&l(e.manual),V(e.message,{tone:`danger`})}}),g=()=>{let e=r.trim();if(e.length===0){V(`Write what to change first.`),n.current?.focus();return}m.mutate(e)};return(0,J.jsxs)(`div`,{"data-slot":`review-actions`,className:`flex flex-col gap-2`,children:[(0,J.jsx)(Fe,{ref:n,"data-slot":`review-notes`,"aria-label":`Notes for the agent`,placeholder:`Notes for the agent — what should change?`,rows:2,value:r,onChange:e=>a(e.target.value),onKeyDown:e=>{kt({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),g())},className:`min-h-[52px] text-[13px]`}),f.canContinue?null:(0,J.jsxs)(`p`,{id:`review-provider-guidance`,className:`flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,J.jsx)(`span`,{children:f.reason}),f.providerPending?null:(0,J.jsx)(W,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsxs)(I,{"data-slot":`review-send-back`,variant:`outline`,size:`sm`,title:f.reason??`Send the notes back into the agent's session`,"aria-describedby":f.canContinue?void 0:`review-provider-guidance`,disabled:m.isPending||!f.canContinue,onClick:g,children:[(0,J.jsx)(Wt,{"aria-hidden":`true`}),`Send back`]}),Te(e.pullRequestUrl)?(0,J.jsx)(I,{asChild:!0,variant:`outline`,size:`sm`,children:(0,J.jsxs)(`a`,{"data-slot":`pr-link`,href:e.pullRequestUrl,target:`_blank`,rel:`noopener noreferrer`,title:`The PR for this task is already open`,children:[(0,J.jsx)(ot,{"aria-hidden":`true`}),`PR ↗`]})}):(0,J.jsxs)(I,{"data-slot":`review-draft-pr`,variant:`outline`,size:`sm`,title:`Push the branch and open a draft PR`,disabled:h.isPending,onClick:()=>h.mutate(),children:[(0,J.jsx)(ye,{"aria-hidden":`true`}),`Draft PR`]}),e.finishBlocked===null?(0,J.jsxs)(I,{"data-slot":`review-accept`,variant:`primary`,size:`sm`,className:`ml-auto`,title:Ke(`review`),disabled:d.isPending,onClick:()=>d.mutate(),children:[(0,J.jsx)(M,{"aria-hidden":`true`}),`Accept`]}):null]}),c===null?null:(0,J.jsx)(ui,{command:c})]})}function ui({command:e}){return(0,J.jsxs)(`button`,{type:`button`,"data-slot":`review-manual`,title:`Copy the command`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>V(`Command copied to clipboard.`)).catch(()=>V(`Run manually: ${e}`))},className:`flex w-full min-w-0 items-center gap-1.5 rounded-sm px-1 py-0.5 text-left font-mono text-[11px] text-soft-foreground hover:bg-muted hover:text-foreground`,children:[(0,J.jsx)(se,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,J.jsxs)(`span`,{className:`truncate`,children:[`manual path: `,e]})]})}function di(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var fi=1500;function pi({status:e}){let t=(0,q.useRef)(e),[n,r]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{let n=t.current;if(t.current=e,n!==`review`||e!==`done`||di())return;r(!0);let i=setTimeout(()=>r(!1),fi);return()=>clearTimeout(i)},[e]),n?(0,J.jsxs)(`div`,{"data-slot":`accept-celebration`,"aria-hidden":`true`,className:`pointer-events-none fixed inset-0 isolate z-40`,children:[(0,J.jsx)(ue,{}),(0,J.jsx)(`div`,{className:`flex justify-center pt-24`,children:(0,J.jsx)(`span`,{className:`rounded-full border border-accent-strong/30 bg-accent-strong/15 px-4 py-1.5 text-[13px] font-medium text-accent-text shadow-modal`,children:`✓ Changes accepted`})})]}):null}function mi(e){let t=u(),[n,r]=(0,q.useState)(),a=He(e.status);(0,q.useEffect)(()=>{(!a||n&&n!==e.id)&&r(void 0)},[a,e.id,n]);let o=i({mutationFn:async()=>{r(e.id);try{if(!(await ge(e.id)).cancelled)throw Error(`The task changed before Stop was accepted. Check its status and retry.`)}catch(e){throw r(void 0),e}},onSettled:()=>t.invalidateQueries({queryKey:z.runs.all})});return{stopping:!!e.stopping||o.isPending||a&&n===e.id,stop:()=>o.mutateAsync()}}function hi({agents:e,onSelect:t}){return e.length===0?null:(0,J.jsx)(`ul`,{"data-slot":`agents-list`,className:`flex min-w-0 flex-col gap-[7px]`,children:e.map(e=>(0,J.jsx)(gi,{agent:e,onSelect:t},e.id))})}function gi({agent:e,onSelect:t}){let n=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(_i,{status:e.status,stalled:e.stalled===!0}),(0,J.jsx)(`span`,{className:`min-w-0 shrink truncate font-medium`,children:e.title}),e.agentType===void 0?null:(0,J.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:e.agentType}),(0,J.jsx)(`span`,{"data-slot":`agent-activity`,className:`min-w-0 flex-1 truncate text-muted-foreground`,children:Rr(e)}),(0,J.jsxs)(`span`,{"data-slot":`agent-tools`,className:`shrink-0 text-muted-foreground tabular-nums`,children:[e.toolCalls,` `,e.toolCalls===1?`tool`:`tools`]})]});return(0,J.jsx)(`li`,{"data-slot":`agent-item`,"data-status":e.status,className:`min-w-0 text-[13px]`,children:t?(0,J.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),"aria-haspopup":`dialog`,className:`flex min-h-5 w-full min-w-0 items-center gap-2.5 rounded-sm text-left hover:bg-muted/50`,children:n}):(0,J.jsx)(`div`,{className:`flex min-h-5 min-w-0 items-center gap-2.5`,children:n})})}function _i({status:e,stalled:t=!1}){return t?(0,J.jsx)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,"data-stalled":`true`,className:`size-[15px] shrink-0 text-soft-foreground`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeDasharray:`3 2.5`,children:(0,J.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})}):e===`completed`?(0,J.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 text-success`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,J.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,J.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`failed`||e===`declined`?(0,J.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 text-danger`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,J.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,J.jsx)(`path`,{d:`m9 9 6 6M15 9l-6 6`})]}):(0,J.jsxs)(`svg`,{"aria-hidden":!0,"data-slot":`agent-glyph`,className:`size-[15px] shrink-0 animate-pulse motion-reduce:animate-none`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,J.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,J.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]})}function vi(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.filter(e=>e.status!==`cancelled`).length}}function yi({entries:e}){return e.length===0?null:(0,J.jsx)(`ul`,{"data-slot":`plan-list`,className:`flex min-w-0 flex-col gap-[7px]`,children:e.map((e,t)=>(0,J.jsx)(bi,{entry:e},`${t}:${e.content}`))})}function bi({entry:e}){return(0,J.jsxs)(`li`,{"data-slot":`plan-item`,"data-status":e.status,className:H(`flex min-h-5 min-w-0 items-center gap-2.5 text-[13px]`,e.status===`completed`&&`text-soft-foreground line-through`,e.status===`in_progress`&&`font-medium`,e.status===`pending`&&`text-muted-foreground`,e.status===`cancelled`&&`text-soft-foreground/70 line-through`),children:[(0,J.jsx)(xi,{status:e.status}),(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:e.content}),e.status===`in_progress`?(0,J.jsx)(`span`,{"data-slot":`plan-tag`,className:`ml-auto shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:`in progress`}):null]})}function xi({status:e}){return e===`cancelled`?(0,J.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-soft-foreground/70`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[(0,J.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`,opacity:`.5`}),(0,J.jsx)(`path`,{d:`m8.5 15.5 7-7`})]}):e===`completed`?(0,J.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-success`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,J.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,J.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`in_progress`?(0,J.jsxs)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 animate-pulse motion-reduce:animate-none`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,J.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,J.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]}):(0,J.jsx)(`svg`,{"aria-hidden":!0,className:`size-[15px] shrink-0 text-soft-foreground`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,J.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})})}var Si={"not-delivered":0,queued:1,delivered:2,consumed:3};function Ci(e){for(let t=e.turns.length-1;t>=0;--t){let n=e.turns[t].planEntries;if(n!==void 0)return n}}function wi(e){let t=[];for(let n of e.turns)for(let e of n.items)if(e.kind===`tool`){for(let n of e.locations??[])t.push(n.path);for(let n of e.diffs??[])t.push(n.path)}let n=[];for(let e=t.length-1;e>=0;--e)n.includes(t[e])||n.push(t[e]);return n}function Ti(e,t){switch(e){case`waiting`:return{state:`waiting`};case`failed`:return{state:`closed`,tone:`danger`,label:t?`Session failed — ${t}`:`Session failed`};case`review`:return{state:`closed`,tone:`dim`,label:`Session closed — waiting for your review`};case`done`:case`cancelled`:return{state:`closed`,tone:`dim`,label:`Session closed`};default:return null}}function Ei(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Di(e){let t=typeof e==`string`?new Date(e):void 0;return!t||Number.isNaN(t.getTime())?``:` · ${t.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}`}function Q(e){return typeof e==`string`?e:void 0}function $(e){if(!(typeof e!=`string`||e===``))return Number.isFinite(new Date(e).getTime())?e:void 0}function Oi(e){return e===`claude`||e===`codex`||e===`opencode`||e===`pi`||e===`cursor`?e:void 0}function ki(e,t){let n=e.replace(/\s*CEZ:DONE\s*$/,``).replace(/\s*CEZ:MONITORING\s*$/,``);return t&&(n=n.replace(/\s*CEZ:ASK[ \t]+[\s\S]*$/,``)),n.includes(`CEZ:`)?n.split(`
|
|
7
|
+
`).filter(e=>!/^CEZ:(?:PR=\d+|ISSUE=\d+|TITLE=.+)\s*$/.test(e)).join(`
|
|
8
|
+
`):n}function Ai(e){let t=e=>ki(e,!0).replace(/\s+/g,``),n=new Set,r=[];for(let{origin:i,entry:a}of e.entries)if(i===`v2`&&a.kind===`message`){let e=t(a.text);n.add(e),r.push(e)}if(r.length===0)return;n.add(r.join(``));let i=[],a={entries:[],texts:[]},o=()=>{if(a.entries.length>=2&&n.has(t(a.texts.join(``)))){a={entries:[],texts:[]};return}i.push(...a.entries),a={entries:[],texts:[]}};for(let t of e.entries)t.origin===`v1`&&t.entry.kind===`message`?(a.entries.push(t),a.texts.push(t.entry.text)):(o(),i.push(t));o(),e.entries=i}function ji(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e)}catch{return String(e)}}var Mi=e=>e.kind===`message`||e.kind===`reasoning`||e.kind===`tool`,Ni=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function Pi(e){if(!Ei(e)||!Array.isArray(e.todos))return;let t=[];for(let n of e.todos){if(!Ei(n)||typeof n.content!=`string`)return;t.push({content:n.content,status:Ni.has(n.status)?n.status:`pending`,...typeof n.activeForm==`string`?{activeForm:n.activeForm}:{}})}return t}function Fi(e,t={}){let n=[],r=new Map,i,a=0,o,s=e=>{a+=1;let t={id:e===void 0?`turn-fallback-${a}`:`turn-seq-${e}`,entries:[],v2Items:!1};return n.push(t),t},c=()=>n.at(-1)??s(),l=(e,t)=>{let n=Q(e.stepId);return n===void 0?t:`${n}:${t}`},u=(e,t,n,i)=>{let a=t.kind===`message`&&i!==void 0?{...t,ts:i}:{...t};if(!e.v2Items){e.v2Items=!0;for(let t of e.entries)t.origin===`v1`&&t.entry.kind===`tool`&&r.delete(t.entry.id);e.entries=e.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`tool`))}let o=r.get(n);if(o&&o.turn===e){o.entry.entry=a,r.set(n,o);return}let s={origin:`v2`,entry:a};e.entries.push(s),r.set(n,{turn:e,entry:s})},d=new Map,f=new Map,p=new Set,m=e=>{if(e.messageKind!==`request`)return;let t=f.get(e.messageId);t&&(e.outcome={status:t.status,...t.replyId===void 0?{}:{replyId:t.replyId},observedAt:t.observedAt})},h=(e,t,n)=>{let r=d.get(e.id);if(r)return(Si[r.delivery]<Si.delivered||Si[t]>Si[r.delivery])&&(r.delivery=t),e.text!==``&&(r.text=e.text),e.state!==void 0&&(r.state=e.state),e.createdAt!==void 0&&(r.createdAt=e.createdAt),e.requestHash!==void 0&&(r.requestHash=e.requestHash),e.deadline!==void 0&&(r.deadline=e.deadline),e.requestId!==void 0&&(r.requestId=e.requestId),e.instruction!==void 0&&(r.instruction=e.instruction),e.resumed!==void 0&&(r.resumed=e.resumed),n?.deliveredAt!==void 0&&(r.deliveredAt=n.deliveredAt),n?.consumedAt!==void 0&&(r.consumedAt=n.consumedAt),n?.recordedAt!==void 0&&(t===`delivered`||r.delivery!==`delivered`)&&(r.recordedAt=n.recordedAt),m(r),r;let i={kind:`conversation`,id:`conversation-message:${e.id}`,messageId:e.id,text:e.text,senderRunId:e.senderRunId,recipientRunId:e.recipientRunId,messageKind:e.kind,delivery:t,...n,...e.instruction===void 0?{}:{instruction:e.instruction},...e.resumed===void 0?{}:{resumed:e.resumed},...e.requestId===void 0?{}:{requestId:e.requestId},...e.state===void 0?{}:{state:e.state},...e.createdAt===void 0?{}:{createdAt:e.createdAt},...e.requestHash===void 0?{}:{requestHash:e.requestHash},...e.deadline===void 0?{}:{deadline:e.deadline}};return m(i),d.set(e.id,i),c().entries.push({origin:`meta`,entry:i}),i},g=!1;for(let t of e)switch(t.type){case`handoff`:{let e=Di(t.ts),n=Q(t.message),r=t.notify===!1?`Stopped notifying the webhook${e}`:`${g?`Note sent to webhook`:`Handed off to webhook`}${e}${n?` — ${n}`:``}`;g=t.notify!==!1,c().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${t.seq}`,text:r,tone:`dim`,icon:`handoff`}});break}case`webhook.failed`:{let e=typeof t.attempts==`number`?t.attempts:void 0,n=`Webhook delivery failed${Q(t.event)?` (${Q(t.event)})`:``}${e?` after ${e} attempt${e===1?``:`s`}`:``}: ${Q(t.error)??`unknown error`}`;c().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${t.seq}`,text:n,tone:`danger`}});break}case`webhook.dry-run`:{let e=t.payload??{},n=`Webhook (dry run, nothing sent): ${Q(t.event)??`delivery`}${Q(e.status)?` · ${Q(e.status)}`:``}`;c().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${t.seq}`,text:n,tone:`dim`}});break}case`conversation-message`:{let e=De.safeParse(t);if(!e.success)break;h(e.data.message,e.data.delivery,{deliveredAt:e.data.deliveredAt,consumedAt:e.data.consumedAt,recordedAt:e.data.ts});break}case`request-outcome`:{let e=Se.safeParse(t);if(!e.success||f.has(e.data.outcome.requestId))break;let{outcome:n}=e.data;f.set(n.requestId,n);let r=d.get(n.requestId);r&&m(r);break}case`agent-input`:{let e=be.safeParse(t);if(!e.success)break;let{input:n}=e.data;if(p.has(n.id))break;if(p.add(n.id),n.conversation){h({id:n.id,text:n.text,createdAt:n.createdAt,...n.conversation},`delivered`,{deliveredAt:n.deliveredAt,recordedAt:e.data.ts});break}c().entries.push({origin:`meta`,entry:{kind:`note`,id:`agent-input:${n.id}`,text:n.text,tone:`dim`,attribution:{source:n.source,parentRunId:n.parentRunId}}});break}case`user-message`:{let e=Q(t.text)??``;o&&!o.resolved&&(o.resolved=!0,o.answeredBy=`human`,e!==``&&(o.answer=e),o=void 0);let n=s(t.seq),r=$(t.ts);n.userMessage={text:e,imageCount:typeof t.imageCount==`number`?t.imageCount:0,images:Array.isArray(t.images)?t.images.filter(e=>typeof e==`string`):[],...r===void 0?{}:{ts:r}},r!==void 0&&(n.startedAt=r);break}case`turn.started`:{let e=Q(t.turnId),r=n.at(-1),i=r&&r.turnId===void 0&&!r.v2Items?r:s(t.seq);i.turnId=e;let a=$(t.ts);i.startedAt===void 0&&a!==void 0&&(i.startedAt=a);break}case`turn.completed`:{let e=Q(t.turnId),r;for(let t=n.length-1;t>=0&&!r;--t)n[t].turnId===e&&(r=n[t]);let i=r??n.at(-1);if(i){let e=$(t.ts);i.completed={stopReason:Q(t.stopReason)??`end_turn`,...typeof t.costUsd==`number`?{costUsd:t.costUsd}:{},...e===void 0?{}:{ts:e}}}break}case`item.started`:case`item.updated`:case`item.completed`:{if(!Ei(t.item))break;let e=t.item.kind,n=t.item.id;if(e!==`message`&&e!==`reasoning`&&e!==`tool`||typeof n!=`string`||n===``)break;let i=t.item,a=l(t,i.id);u(r.get(a)?.turn??c(),i,a,t.type===`item.completed`?$(t.ts):void 0);break}case`item.delta`:{let e=Q(t.itemId)??``,n=r.get(l(t,e)),i=Q(t.delta)??``;if(!n||i===``||!Mi(n.entry.entry))break;let a=n.entry.entry;t.field===`output`&&a.kind===`tool`?a.output=(a.output??``)+i:t.field!==`output`&&a.kind!==`tool`&&(a.text+=i);break}case`text`:{let e=c(),n=Q(t.text)??``;if(n===``)break;let r=$(t.ts);e.entries.push({origin:`v1`,entry:{kind:`message`,id:`v1:${t.seq}`,role:`assistant`,text:n,...r===void 0?{}:{ts:r}}});break}case`tool-call`:{let e=c();if(e.v2Items)break;let n=Q(t.tool)??`Tool`;if(Ii.has(n))break;let i=Bt(n,t.input);if(i.toolKind===`plan`){let n=Pi(t.input);n!==void 0&&(e.planEntries=n)}let a={kind:`tool`,id:Q(t.id)??`v1:${t.seq}`,name:n,toolKind:i.toolKind,title:i.title,status:`running`,input:t.input},o={origin:`v1`,entry:a};e.entries.push(o),r.set(a.id,{turn:e,entry:o});break}case`tool-result`:{let e=r.get(Q(t.toolCallId)??``);if(!e||e.turn.v2Items||e.entry.origin!==`v1`)break;let n=e.entry.entry;if(n.kind!==`tool`)break;n.status=`completed`,n.output=ji(t.result);break}case`note`:case`lifecycle`:{let e=Q(t.message)??``;if(e===``)break;let n=t.tone===`danger`?`danger`:`dim`;c().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${t.seq}`,text:e,tone:n}});break}case`error`:{let e=Q(t.message)??``;if(e===``)break;c().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${t.seq}`,text:e,tone:`danger`}});break}case`session.error`:{let e=Q(t.message)??``;if(e===``)break;c().entries.push({origin:`meta`,entry:{kind:`note`,id:`v2:${t.seq}`,text:e,tone:`danger`}});break}case`step-end`:{if(t.status!==`failed`)break;let e=Q(t.error)?` — ${Q(t.error)}`:``;c().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${t.seq}`,text:`step ${Q(t.stepId)??`?`} failed${e}`,tone:`danger`}});break}case`check-output`:{let e=Q(t.command)??`check`,n=typeof t.exitCode==`number`?t.exitCode:-1,r={kind:`tool`,id:`v1:${t.seq}`,name:`check`,toolKind:`execute`,title:`Ran ${e}`,status:n===0?`completed`:`failed`,output:Q(t.text)??``,exitCode:n};c().entries.push({origin:`meta`,entry:r});break}case`provider-auth-required`:{let e=Oi(t.provider),n=Q(t.authFailureId);if(e===void 0||n===void 0||n.length<1||n.length>128)break;c().entries.push({origin:`meta`,entry:{kind:`provider-auth-required`,id:`v1:${t.seq}`,provider:e,authFailureId:n}});break}case`image`:{let e=Q(t.url);if(e===void 0)break;let n={kind:`image`,id:`v1:${t.seq}`,url:e},r=Q(t.name);r!==void 0&&(n.name=r),c().entries.push({origin:`meta`,entry:n});break}case`plan.updated`:Array.isArray(t.entries)&&(c().planEntries=t.entries);break;case`session.ended`:i={reason:Q(t.reason)??`end_turn`,...Q(t.message)===void 0?{}:{message:Q(t.message)}};break;case`ask.requested`:{let e=Q(t.requestId);if(e===void 0||!Array.isArray(t.questions))break;let n=t.questions.filter(e=>Ei(e)&&typeof e.header==`string`&&Array.isArray(e.options));if(n.length===0)break;let r={kind:`ask`,id:e,questions:n,resolved:!1,askSeq:t.seq};c().entries.push({origin:`meta`,entry:r}),o=r;break}case`worker-question-routed`:if(o&&!o.resolved&&o.askSeq===t.askSeq){o.routedToParent=!0;let e=Q(t.parentRunId);e!==void 0&&(o.parentRunId=e)}break;case`worker-question-fallback`:o&&!o.resolved&&o.askSeq===t.askSeq&&(o.routedToParent=!1);break;case`human-input-delivered`:t.source===`parent`&&o&&!o.resolved&&o.askSeq===t.askSeq&&(o.resolved=!0,o.answeredBy=`parent`,o=void 0);break;case`step-start`:case`token-usage`:case`cost`:case`turn-end`:case`done`:case`session`:break;default:break}for(let e of n){if(!e.v2Items)continue;let t=new Set;for(let{origin:n,entry:r}of e.entries)n===`v2`&&r.kind===`message`&&t.add(ki(r.text,!0).trim());t.size!==0&&(e.entries=e.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`message`&&t.has(ki(e.entry.text,!0).trim()))),Ai(e))}for(let e of d.values())e.messageKind!==`request`||e.outcome!==void 0||e.delivery!==`not-delivered`&&(e.state!==void 0&&e.state!==`accepted`||(e.outcome={status:`pending`}));return{turns:n.map((e,r)=>{let i=e.entries.some(({entry:e})=>e.kind===`ask`),a=t.activeTurn===!0&&r===n.length-1;return{id:e.id,...e.turnId===void 0?{}:{turnId:e.turnId},...e.userMessage===void 0?{}:{userMessage:e.userMessage},...e.startedAt===void 0?{}:{startedAt:e.startedAt},...e.planEntries===void 0?{}:{planEntries:e.planEntries},...e.completed===void 0?{}:{completed:e.completed},items:e.entries.map(({entry:e})=>e.kind===`message`&&e.role===`assistant`?{...e,text:ki(e.text,i||a)}:e)}}),...i===void 0?{}:{sessionEnded:i}}}var Ii=new Set([`subAgentActivity`,`collabAgentToolCall`,`collabToolCall`]),Li=new Map,Ri=new Map;function zi({run:e,currentThread:t,onOpenWorker:n}){let r=Nt(),[i,a]=(0,q.useState)(()=>Li.get(e.id)??r),[o,s]=(0,q.useState)({}),u=!(e.status===`running`||e.status===`waiting`)&&e.status!==`queued`,d=e.steps,f=(0,q.useMemo)(()=>Fr(t.turns,u),[t.turns,u]),p=Ci(t)??[],m=e.delegation!==void 0&&e.delegation.role!==`invalid`,h=tt(e),_=d.length===0||d.every(e=>e.status===`done`||e.status===`skipped`),v=Lr(f),y=vi(p),b=[d.length>0?`workflow`:void 0,f.length>0?`subagents`:void 0,m?`workers`:void 0,p.length>0?`plan`:void 0].filter(e=>e!==void 0);if(b.length===0)return null;let x=t=>o[t]??Ri.get(`${e.id}:${t}`)??t===`workers`,C=t=>{let n=!x(t);Ri.set(`${e.id}:${t}`,n),s(e=>({...e,[t]:n}))},w=e.status===`done`&&_&&h===`complete`&&v.done===v.total&&y.done===y.total,T=h===`pending`,E=w?`All complete`:e.status===`failed`?`Failed`:e.status===`cancelled`?`Cancelled`:e.status===`running`?`Working`:e.status===`done`?h===`unknown`?`Workers unavailable`:T?`In progress`:`Incomplete`:`In progress`,D=e.status===`failed`||e.status===`cancelled`;return(0,J.jsxs)(`section`,{"data-slot":`run-activity-dock`,"data-state":i?`open`:`collapsed`,className:`min-w-0 overflow-hidden rounded-xl border border-border bg-card shadow-xs`,children:[(0,J.jsxs)(`button`,{type:`button`,"aria-expanded":i,onClick:()=>{Li.set(e.id,!i),a(!i)},className:`flex min-h-11 w-full min-w-0 items-center gap-2.5 px-3.5 py-2 text-left text-[14px] hover:bg-muted/40`,children:[(0,J.jsx)(l,{"aria-hidden":!0,className:`size-4 shrink-0 text-accent-text`}),(0,J.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Run activity`}),(0,J.jsxs)(`span`,{"data-slot":`run-activity-count`,className:`shrink-0 text-[13px] text-muted-foreground tabular-nums`,children:[`· `,b.length,` `,b.length===1?`section`:`sections`]}),(0,J.jsxs)(`span`,{"data-slot":`run-activity-status`,className:H(`ml-auto flex min-w-0 shrink items-center gap-1.5 truncate text-[13px]`,w?`text-success`:D?`text-danger`:`text-muted-foreground`),children:[w?(0,J.jsx)(S,{"aria-hidden":!0,className:`size-3.5 shrink-0`}):null,(0,J.jsx)(`span`,{className:`truncate`,children:E})]}),(0,J.jsx)(A,{"aria-hidden":!0,className:H(`size-4 shrink-0 text-soft-foreground transition-transform`,i&&`rotate-180`)})]}),i?(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[d.length>0?(0,J.jsx)(rt,{slot:`workflow`,icon:(0,J.jsx)(Bi,{steps:d}),title:d[nt(d)].name,meta:Ye(nt(d)+1,d.length,r,`step`),open:x(`workflow`),onToggle:()=>C(`workflow`),children:(0,J.jsx)(et,{steps:d})}):null,f.length>0?(0,J.jsx)(rt,{slot:`subagents`,icon:(0,J.jsx)(g,{className:`size-4`}),title:`Subagents`,meta:Ye(v.done,v.total,r),open:x(`subagents`),onToggle:()=>C(`subagents`),children:(0,J.jsx)(hi,{agents:f,onSelect:n})}):null,m?(0,J.jsx)(Je,{run:e,open:x(`workers`),onToggle:()=>C(`workers`)}):null,p.length>0?(0,J.jsx)(rt,{slot:`plan`,icon:(0,J.jsx)(c,{className:`size-4`}),title:`Plan`,meta:Ye(y.done,y.total,r),open:x(`plan`),onToggle:()=>C(`plan`),children:(0,J.jsx)(yi,{entries:p})}):null]}):null]})}function Bi({steps:e}){let t=Qe(e[nt(e)].status),n=`size-4 shrink-0`;switch(t){case`active`:return(0,J.jsx)(_t,{role:`status`,"aria-label":`Step running`,"data-slot":`workflow-glyph`,"data-visual":t,className:H(n,`animate-spin stroke-pending motion-reduce:animate-none`)});case`failed`:return(0,J.jsx)(fe,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":t,className:H(n,`text-danger`)});case`pending`:return(0,J.jsx)(R,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":t,className:H(n,`text-soft-foreground`)});case`done`:return(0,J.jsx)(S,{"aria-hidden":!0,"data-slot":`workflow-glyph`,"data-visual":t,className:H(n,`text-success`)})}}function Vi(e,t,n){return`${e.header}: ${n?.trim()||t.join(`, `)}`}function Hi({ask:e,run:t}){return e.resolved?(0,J.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`true`,className:`rounded-lg border border-border bg-card px-3.5 py-2.5 text-xs text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`text-soft-foreground`,children:e.answeredBy===`parent`?`Answered by parent`:`Answered`}),e.answer?(0,J.jsx)(`span`,{className:`ml-1.5 break-words whitespace-pre-line text-foreground`,children:e.answer}):null]}):e.routedToParent?(0,J.jsx)(Ui,{ask:e}):(0,J.jsx)(Wi,{ask:e,run:t})}function Ui({ask:e}){return(0,J.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-routed":`parent`,className:`rounded-lg border border-border bg-card px-4 pt-3.5 pb-3.5`,children:[(0,J.jsx)(`div`,{className:`mb-2.5 flex items-center gap-2`,children:(0,J.jsx)(`span`,{className:`text-xs font-medium text-link-foreground`,children:`The agent is asking its parent`})}),(0,J.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.questions.map((e,t)=>(0,J.jsxs)(`div`,{role:`group`,"aria-label":e.question,children:[(0,J.jsx)(`div`,{className:`mb-0.5 flex items-center gap-2`,children:(0,J.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e.header})}),(0,J.jsx)(`p`,{className:`mb-1.5 break-words text-sm font-semibold text-foreground`,children:e.question}),(0,J.jsx)(`ul`,{className:`flex list-disc flex-col gap-0.5 pl-5 text-[13px] text-muted-foreground`,children:e.options.map(e=>(0,J.jsxs)(`li`,{className:`break-words`,children:[(0,J.jsx)(`span`,{className:`text-foreground`,children:e.label}),e.description?(0,J.jsxs)(`span`,{children:[`: `,e.description]}):null]},e.label))})]},e.id??t))}),(0,J.jsxs)(`p`,{"data-slot":`ask-routed-hint`,className:`mt-3 text-xs text-muted-foreground`,children:[`Routed to parent: answer it in the`,` `,e.parentRunId?(0,J.jsx)(W,{to:`/tasks/${e.parentRunId}`,className:`font-medium text-foreground underline underline-offset-4`,children:`parent task`}):`parent task`,`.`]})]})}function Wi({ask:e,run:t}){let n=Ve(t),r=n.blockedBy!==void 0,i=e.questions,a=i.length===1&&i[0]?.multiSelect!==!0,[o,s]=(0,q.useState)({}),[c,l]=(0,q.useState)({}),u=(e,t)=>s(n=>({...n,[e]:t})),d=e=>l(t=>{if(t[e]===void 0)return t;let n={...t};return delete n[e],n}),f=e=>{u(e,[]),l(t=>({...t,[e]:t[e]??``}))},p=i.some((e,t)=>c[t]!==void 0),m=i.every((e,t)=>(o[t]?.length??0)>0||!!c[t]?.trim()),h=()=>void n.send(i.map((e,t)=>Vi(e,o[t]??[],c[t])).join(`
|
|
9
|
+
`)),g=n.mode===`resume`;return(0,J.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-delivery":n.mode,className:`rounded-lg border border-accent-strong/25 bg-accent-strong/[0.04] px-4 pt-3.5 pb-3.5`,children:[(0,J.jsx)(`div`,{className:`mb-2.5 flex items-center gap-2`,children:(0,J.jsx)(`span`,{className:`text-xs font-medium text-link-foreground`,children:`The agent is asking`})}),(0,J.jsx)(`div`,{className:`flex flex-col gap-4`,children:i.map((e,t)=>(0,J.jsx)(Gi,{question:e,disabled:n.isPending||r,selected:o[t]??[],isOther:c[t]!==void 0,otherAnswer:c[t]??``,onSelect:i=>{r||(d(t),a?n.send(Vi(e,i)):u(t,i))},onOtherToggle:()=>{r||(c[t]===void 0?f(t):d(t))},onOtherChange:e=>l(n=>({...n,[t]:e}))},e.id??t))}),a&&!p?g?(0,J.jsx)(`p`,{"data-slot":`ask-resume-hint`,className:`mt-3 text-[11px] text-soft-foreground`,children:`The session has ended — your answer reopens it and goes to the agent.`}):null:(0,J.jsxs)(`div`,{className:`mt-3 flex items-center gap-2.5`,children:[(0,J.jsx)(I,{size:`sm`,className:`min-h-11`,disabled:n.isPending||r||!m,onClick:h,children:g?`Send answer & reopen`:`Send answer`}),(0,J.jsx)(`span`,{"data-slot":g?`ask-resume-hint`:`ask-hint`,className:`text-[11px] text-soft-foreground`,children:g?`the session has ended — sending reopens it`:p?`${i.length>1?`answer each question above`:`enter your answer above`} — or type a reply below`:`${i.length>1?`answer each question`:`pick one or more`} — or type a reply below`})]}),n.blockedBy===`provider`?(0,J.jsxs)(`div`,{"data-slot":`ask-provider-gate`,className:`mt-3 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,J.jsx)(`span`,{children:n.reason}),(0,J.jsx)(W,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}):null,n.blockedBy===`no-session`?(0,J.jsx)(`p`,{"data-slot":`ask-no-session`,className:`mt-3 text-xs text-muted-foreground`,children:n.reason}):null,n.error?(0,J.jsx)(`p`,{"data-slot":`ask-error`,role:`alert`,className:`mt-3 text-xs text-danger`,children:n.error}):null]})}function Gi({question:e,disabled:t,selected:n,isOther:r,otherAnswer:i,onSelect:a,onOtherToggle:o,onOtherChange:s}){let c=(0,q.useId)(),l=e.multiSelect===!0,u=e=>{if(!l){a([e]);return}a(n.includes(e)?n.filter(t=>t!==e):[...n,e])};return(0,J.jsxs)(`div`,{role:`group`,"aria-label":e.question,children:[(0,J.jsxs)(`div`,{className:`mb-0.5 flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`rounded-md bg-accent-strong px-1.5 py-0.5 text-[12px] font-semibold uppercase tracking-wide text-accent-strong-foreground`,children:e.header}),l?(0,J.jsx)(`span`,{className:`ml-auto text-[11px] text-soft-foreground`,children:`select all that apply`}):null]}),(0,J.jsx)(`p`,{className:`mb-2.5 break-words text-sm font-semibold text-foreground`,children:e.question}),(0,J.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.options.map(e=>{let r=n.includes(e.label);return(0,J.jsxs)(`button`,{type:`button`,disabled:t,"aria-pressed":r,onClick:()=>u(e.label),className:H(`flex min-h-11 w-full flex-col gap-0.5 rounded-md border px-3.5 py-2.5 text-left transition-colors`,`hover:border-accent-strong/50 hover:bg-accent-strong/[0.06] disabled:pointer-events-none disabled:opacity-50`,r?`border-accent-strong/60 bg-accent-strong/[0.06]`:`border-border bg-card`),children:[(0,J.jsxs)(`span`,{className:`flex min-w-0 items-start gap-2 text-[14px] font-semibold text-foreground`,children:[l?(0,J.jsx)(`span`,{"aria-hidden":!0,className:H(`flex size-4 shrink-0 items-center justify-center rounded border text-[12px]`,r?`border-accent-strong bg-accent-strong text-accent-strong-foreground`:`border-soft-foreground`),children:r?`✓`:``}):null,(0,J.jsx)(`span`,{className:`min-w-0 break-words`,children:e.label})]}),e.description?(0,J.jsx)(`span`,{className:`min-w-0 break-words text-xs text-muted-foreground`,children:e.description}):null]},e.label)})}),(0,J.jsxs)(`div`,{className:`mt-2`,children:[(0,J.jsx)(I,{type:`button`,variant:`outline`,"aria-pressed":r,"aria-expanded":r,"aria-controls":r?c:void 0,disabled:t,onClick:o,className:H(`w-full justify-start text-left`,r&&`border-accent-strong/60 bg-accent-strong/[0.06]`),children:`Other`}),r?(0,J.jsxs)(`div`,{className:`mt-2.5`,children:[(0,J.jsx)(`label`,{htmlFor:c,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,J.jsx)(Fe,{id:c,rows:2,value:i,disabled:t,onChange:e=>s(e.target.value),className:`bg-card`})]}):null]})]})}var Ki=2e3;function qi(e){let t=0,n=0;for(let r of e)typeof r.seq==`number`&&(r.type===`session.ended`&&r.seq>t&&(t=r.seq),(r.type===`session.started`||r.type===`step-start`&&r.kind===`agent`)&&r.seq>n&&(n=r.seq));return t>n?t:0}function Ji(e){let t=0,n=0;for(let r of e)typeof r.seq==`number`&&(r.type===`turn-end`&&r.seq>t&&(t=r.seq),(r.type===`turn.started`||r.type===`session.started`||r.type===`user-message`||r.type===`step-start`&&r.kind===`agent`)&&r.seq>n&&(n=r.seq));return t>n?t:0}function Yi(e,t){let n=u(),r=(0,q.useMemo)(()=>qi(t),[t]),i=(0,q.useMemo)(()=>Ji(t),[t]),a=e?.id,o=e?.status,s=e?.activity;(0,q.useEffect)(()=>{if(!(r!==0&&(o===`running`||o===`waiting`))&&!(i!==0&&o===`running`&&s!==`monitoring`)||a===void 0)return;let e=setTimeout(()=>{n.invalidateQueries({queryKey:z.runs.detail(a)}),n.invalidateQueries({queryKey:z.runs.list()})},Ki);return()=>clearTimeout(e)},[r,i,a,o,s,n])}function Xi(){let{id:e}=C(),t=de(e),n=tn(e),r=t.data?.status,i=(0,q.useMemo)(()=>Fi(n.visibleEvents,{activeTurn:r===`running`}),[n.visibleEvents,r]),a=(0,q.useMemo)(()=>Fi(n.currentEvents,{activeTurn:r===`running`}),[n.currentEvents,r]),o=(0,q.useRef)(void 0),s=(0,q.useCallback)(e=>{o.current=e},[]),{mutate:c}=ce();if((0,q.useEffect)(()=>{t.data&&o.current!==t.data.id&&ze(t.data)&&c(t.data.id)},[c,t.data?.id,t.data?.status,t.data?.finishedAt,t.data?.seenAt,t.data?.archived]),Yi(t.data,n.visibleEvents),t.isPending)return(0,J.jsx)(Ot,{});if(t.isError){let e=t.error instanceof he&&t.error.status===404;return(0,J.jsx)(`div`,{"data-route":`task-thread`,className:`flex min-h-full flex-col`,children:(0,J.jsx)(me,{icon:e?(0,J.jsx)(yt,{}):(0,J.jsx)(Kt,{}),tone:e?`neutral`:`danger`,title:e?`Task not found`:`Could not load this task`,subtitle:e?`No run has this id. It may have been deleted, or the link is from another machine.`:t.error.message,actions:(0,J.jsx)(I,{asChild:!0,variant:`outline`,children:(0,J.jsx)(W,{to:`/`,children:`Back to tasks`})})})})}return n.isPending?(0,J.jsx)(Ot,{}):(0,J.jsx)(Zi,{run:t.data,thread:i,currentThread:a,history:n,onMarkedUnread:s})}function Zi({run:e,thread:t,currentThread:n=t,history:r,onMarkedUnread:i}){gt();let o=re(),s=r?xe(r.currentEvents)!==void 0:n.turns.some(e=>e.items.some(e=>e.kind===`ask`&&!e.resolved)),c=oe(e,s),l=Ti(e.status,e.error),u=e.status===`running`||e.status===`waiting`,d=!u&&e.status!==`queued`,f=e.status===`queued`,p=Er(e),g=mi(e),_=si(e.id),v=s||e.hasPendingHumanAsk===!0,y=!u&&!f&&p.available,b=y&&p.canContinue,[x,S]=(0,q.useState)(void 0),[C,T]=(0,q.useState)(e.id);C!==e.id&&(T(e.id),S(void 0));let E=(0,q.useMemo)(()=>x===void 0?void 0:Br(n.turns,x,d),[n.turns,x,d]),D=(0,q.useMemo)(()=>x===void 0?[]:Vr(n.turns,x),[n.turns,x]),k=ie(e.id),A=Ve(e),j=Be(e),M=u&&!j.usable,N=y&&!p.canContinue,P=M||N,ee=M?j.reason:p.reason,{mutateAsync:te}=h(e.id),{mutateAsync:I}=_e(e.id),{mutateAsync:ne}=F(e.id),L=(0,q.useMemo)(()=>f?{onEditTask:async e=>{await te({task:e})},onEditMessage:(e,t)=>I({msgId:e,message:{text:t}}).then(()=>void 0),onRemoveMessage:e=>ne(e).then(()=>void 0)}:void 0,[f,te,I,ne]),R=(0,q.useMemo)(()=>qr(e,t),[e,t]),ae=(0,q.useMemo)(()=>Xr(R,e.id),[R,e.id]),z=(0,q.useMemo)(()=>Gn(e,o.data),[e,o.data]),se=(0,q.useMemo)(()=>Wn(e,o.data),[e,o.data]),ce=(0,q.useCallback)(t=>(0,J.jsx)(Hi,{ask:t,run:e}),[e]),le=(0,q.useMemo)(()=>{if(L===void 0)return;let t={task:{onEdit:L.onEditTask,editLabel:`Edit the prompt`}};for(let n of e.queuedMessages??[])t[`queued:${n.id}`]={onEdit:e=>L.onEditMessage(n.id,e),onRemove:()=>L.onRemoveMessage(n.id)};return t},[L,e.queuedMessages]),ue=a(e,w()),{search:de}=m(),fe=Cn(de,ae.length),B=Hr(`${e.id}:main`,{onLoadOlder:r?.hasOlder?r.loadOlder:void 0,onJumpToLatest:r?.jumpToLatest,rowKeys:ae.map(({key:e})=>e)});return Ne(B.restickIfStuck),(0,J.jsxs)(`div`,{"data-route":`task-thread`,"data-run-id":e.id,className:`flex min-h-full flex-col`,children:[(0,J.jsx)(it,{run:e,hasPendingHumanAsk:s,onMarkedUnread:()=>i?.(e.id)}),(0,J.jsxs)(`div`,{"data-slot":`session-conversation`,className:`mx-auto flex w-full max-w-[var(--measure)] flex-1 flex-col gap-2.5 px-[18px] py-3 md:gap-3.5 md:px-16 md:py-5`,children:[r?(0,J.jsx)(Qi,{hasOlder:r.hasOlder,loading:r.isFetchingOlder,error:r.olderError,fallback:r.fallback,retainedPages:r.retainedPages,onLoad:B.loadOlder}):null,(0,J.jsx)(Zr,{runId:e.id,viewId:`main`,sections:R,mode:`document`,renderAsk:ce,messageActions:le,scrollControls:B,renderMode:fe,taskTitles:z,recipientBackends:se}),t.turns.length===0?e.status===`queued`?(0,J.jsx)($i,{run:e}):(0,J.jsx)(`p`,{"data-slot":`thread-empty`,className:`py-6 text-center text-xs text-soft-foreground`,children:`No session events yet.`}):null,e.status===`running`&&e.activity!==`monitoring`?(0,J.jsx)(pr,{}):null,l&&l.state===`closed`?(0,J.jsxs)(`div`,{"data-slot":`thread-footer`,"data-state":l.state,className:H(`mt-auto flex items-center gap-2 border-t border-border pt-3 text-xs`,l.tone===`danger`?`text-danger`:`text-soft-foreground`),children:[l.label,Te(O(e))?(0,J.jsx)(`a`,{"data-slot":`pr-link`,href:O(e),target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`PR ↗`}):null,Te(ue)?(0,J.jsx)(`a`,{"data-slot":`issue-link`,href:ue,target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`Issue ↗`}):null]}):null,e.status===`review`?(0,J.jsx)(ci,{run:e}):null]}),(0,J.jsx)(pi,{status:e.status}),(0,J.jsx)(ii,{runId:e.id,renderAsk:ce,agent:E,entries:D,taskTitles:z,recipientBackends:se,onClose:()=>S(void 0)}),(0,J.jsxs)(`div`,{"data-slot":`thread-dock`,className:`relative z-10 bg-background pt-1 pb-2 md:pt-1.5 md:pb-4`,children:[B.pillVisible?(0,J.jsx)(`div`,{className:`pointer-events-none fixed right-6 bottom-[calc(24px+env(safe-area-inset-bottom))] z-30 flex justify-center`,children:(0,J.jsx)(Kr,{onJump:B.jumpToLatest})}):null,(0,J.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[var(--measure)] flex-col gap-1.5 px-[14px] md:gap-2.5 md:px-16`,children:[(0,J.jsx)(zi,{run:e,currentThread:n,onOpenWorker:S},e.id),(0,J.jsx)(nn,{run:e}),e.status===`waiting`?(0,J.jsxs)(`div`,{"data-slot":`paused-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,J.jsx)(Le,{tone:c.tone,pulse:c.pulse}),c.bucket===`waiting`?`The agent is paused, waiting for your reply`:`${c.label.charAt(0).toUpperCase()}${c.label.slice(1)} — you can send a message to resume`]}):null,f?(0,J.jsxs)(`div`,{"data-slot":`queued-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,J.jsx)(Le,{tone:`pending`}),`Messages you add now are folded into the prompt before the run starts.`]}):null,b&&p.startsNewConversation?(0,J.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,role:`status`,children:`Starts a new agent conversation.`}):null,(0,J.jsx)(Tt,{onStop:qe(e).cancel?g.stop:void 0,onFinish:Ge(e,s)?()=>_.mutateAsync().catch(()=>void 0):void 0,finishing:_.isPending,secondaryAction:qe(e).archive?(0,J.jsx)(at,{run:e,compactOnMobile:!0}):void 0,stopOnEmpty:e.status===`queued`||e.status===`running`||e.status===`waiting`&&c.bucket===`none`&&!v,stopping:g.stopping,retainDraftUntilSuccess:!0,compactFeedback:!0,pendingLabel:b?`Continuing…`:`Sending…`,failureHint:`Your draft is kept. Check the task status and connection, then retry.`,sessionControls:b?p.pills:void 0,onSubmit:b?(e,t)=>p.continueWith(e,t):f?(e,t)=>k.mutateAsync({text:e,images:t}):async(e,t)=>{let n=await A.send(e,t);if(n!==void 0)throw Error(n)},disabled:P||!u&&!f&&!b,disabledReason:P?ee:`Session closed — no session to resume.`,footerEnd:P&&!p.providerPending?(0,J.jsx)(W,{to:`/settings/agents#providers`,className:`text-xs font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):void 0,allowEmptySubmit:b&&!v,emptySubmitLabel:b&&!v?`Continue`:void 0,placeholder:f?`Add to the prompt — sent when the run starts…`:b?`Continue — add a prompt, or send to just reopen the session…`:e.status===`waiting`?`Reply — / for skills, @ for files…`:`Message the agent — / for skills, @ for files…`,autocompleteSkills:!0,quickReplies:!0,getMentionCandidates:()=>wi(t)})]})]}),(0,J.jsx)(`div`,{"data-slot":`thread-tail-anchor`,"aria-hidden":`true`,className:`h-px shrink-0 md:hidden`})]})}function Qi({hasOlder:e,loading:t,error:n,fallback:r,retainedPages:i,onLoad:a}){return r?(0,J.jsx)(`p`,{"data-slot":`history-fallback`,className:`text-center text-xs text-soft-foreground`,role:`status`,children:`Progressive history is unavailable; showing the complete session.`}):!e&&!n?(0,J.jsxs)(`div`,{"data-slot":`history-start`,className:`flex items-center gap-3 text-[11px] text-soft-foreground`,children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),`Start of session`,(0,J.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]}):(0,J.jsxs)(`div`,{"data-slot":`history-boundary`,"data-retained-pages":i,"aria-busy":t,className:`flex min-h-8 items-center justify-center text-xs text-muted-foreground`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:a,disabled:t,className:`rounded-md px-3 py-1.5 font-medium hover:bg-muted disabled:cursor-wait`,children:t?`Loading 100 earlier items…`:n?`Couldn’t load earlier items · Retry`:`Load 100 earlier items`}),(0,J.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:t?`Loading earlier session history`:n||``})]})}function $i({run:e}){let t=We(re().data??[],e.id);return(0,J.jsxs)(`div`,{"data-slot":`queued-state`,className:`flex flex-col items-center gap-1.5 py-10 text-center`,children:[(0,J.jsx)(Le,{tone:`pending`,pulse:!0}),(0,J.jsxs)(`p`,{className:`text-[13px] font-medium`,children:[`Waiting for a free agent slot`,t===void 0?``:` — #${t} in queue`]}),(0,J.jsxs)(`p`,{className:`text-xs text-soft-foreground`,children:[e.workflow,` · starts automatically when a slot frees up`]})]})}export{Xi as TaskThreadRoute};
|