@open-mercato/cezar 0.9.0-pr646.708 → 0.9.0-pr647.716

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.
Files changed (28) hide show
  1. package/dist/runs/store.d.ts +6 -0
  2. package/dist/runs/store.js +14 -4
  3. package/dist/runs/store.js.map +1 -1
  4. package/dist/server/server.js +3 -2
  5. package/dist/server/server.js.map +1 -1
  6. package/dist/workflows/run.d.ts +2 -14
  7. package/dist/workflows/run.js +7 -23
  8. package/dist/workflows/run.js.map +1 -1
  9. package/package.json +1 -1
  10. package/web/dist/assets/{compare-variants-B5BlnpUb.js → compare-variants-BR6ZhIbj.js} +1 -1
  11. package/web/dist/assets/{diff-view-CYKPGL2w.js → diff-view-CNqm5bjB.js} +3 -3
  12. package/web/dist/assets/{git-toolbar-CDII-3Uv.js → git-toolbar-A1hGl9ke.js} +1 -1
  13. package/web/dist/assets/github-CNdzanog.js +1 -0
  14. package/web/dist/assets/{index-CcfkF2Ey.js → index-MN3Lxn3t.js} +9 -9
  15. package/web/dist/assets/{repo-git-4l-2tm7d.js → repo-git-BVbeQnIX.js} +1 -1
  16. package/web/dist/assets/{run-diff-Cksr4Dk5.js → run-diff-BGNJAOm7.js} +1 -1
  17. package/web/dist/assets/run-header-fLV2ZvNw.js +1 -0
  18. package/web/dist/assets/{skills-D7hPgl4y.js → skills-DbXoq215.js} +1 -1
  19. package/web/dist/assets/{task-changes-DvIUGL9a.js → task-changes-CVIoIFuR.js} +1 -1
  20. package/web/dist/assets/{task-commits-QD2JI3zj.js → task-commits-DwIx0CP-.js} +1 -1
  21. package/web/dist/assets/{task-files-BE7JDEwK.js → task-files-tHtq2G2M.js} +2 -2
  22. package/web/dist/assets/{task-thread-CRjuPhsl.js → task-thread-D5physox.js} +5 -5
  23. package/web/dist/assets/{use-desktop-4e8LLqMG.js → use-desktop-DDySz-Hn.js} +2 -2
  24. package/web/dist/assets/workflows-mVvkUyVO.js +11 -0
  25. package/web/dist/index.html +1 -1
  26. package/web/dist/assets/github-C7SNDPf3.js +0 -1
  27. package/web/dist/assets/run-header-B3kW2sWC.js +0 -1
  28. package/web/dist/assets/workflows-bPYx0nbO.js +0 -11
@@ -1 +1 @@
1
- import{a as e,s as t,u as n}from"./bundle-mjs-BegPhL5c.js";import{$ as r,A as i,B as a,L as o,Q as s,Tt as c,Wt as l,Z as u,a as d,fn as f,i as p,k as m,mn as h,t as g,un as _,yt as v}from"./centered-state-CLmJ67EV.js";import{n as y,t as b}from"./utils-B8s5qIcK.js";import{t as x}from"./arrow-left-CnSdp92h.js";import{t as S}from"./tab-link-vtgjgL_M.js";import{a as C,i as w,r as T,t as E}from"./git-toolbar-CDII-3Uv.js";import{a as D,i as O,n as k,r as A,t as j}from"./use-desktop-4e8LLqMG.js";import{t as M}from"./git-pull-request-DnR8Xh4_.js";import{t as N}from"./search-x-BDjaMrzG.js";import{t as P}from"./triangle-alert-Uy8rokUh.js";import{t as F}from"./project-router-BaWVyqc8.js";import{It as I,Jt as L,Qt as R,et as z,l as B}from"./index-CcfkF2Ey.js";import{t as V}from"./commit-list-CSaWuw-x.js";var H=n(t(),1),U=e();function W({repo:e,info:t}){let n=a(),r=h(),o=e=>p(e.message,{tone:`danger`}),s=f({mutationFn:e=>c({name:e}),onSuccess:async e=>{p(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([r.invalidateQueries({queryKey:i.repo}),r.invalidateQueries({queryKey:i.health})]),r.setQueryData(i.repo,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),r.setQueryData(i.health,n=>n?.repo?.root===t.root?{...n,repo:{...n.repo,branch:e.branch}}:n)},onError:o}),u=f({mutationFn:e=>l({baseBranch:e}),onSuccess:e=>{p(e.baseBranch?`Agents now branch from ${e.baseBranch}`:`Agents now branch from the current checkout`),r.invalidateQueries({queryKey:i.repo})},onError:o}),[g,_]=(0,H.useState)(``),[v,y]=(0,H.useState)(``),x=v.trim().toLowerCase(),S=x?e.branches.filter(e=>e.toLowerCase().includes(x)):e.branches;return(0,U.jsxs)(`section`,{"data-slot":`repo-branches`,className:`flex flex-col gap-6 px-4 py-4 md:px-6`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h2`,{className:`text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Branches`}),(0,U.jsx)(I,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:v,onChange:e=>y(e.target.value),className:`mt-2 max-w-xl`}),(0,U.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-2 flex max-w-xl flex-col divide-y divide-border`,children:[S.map(e=>{let n=e===t.branch;return(0,U.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,className:`flex min-h-9 items-center gap-2 py-1`,children:[(0,U.jsx)(R,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:b(`min-w-0 truncate font-mono text-xs`,n&&`font-semibold`),children:e}),n?(0,U.jsxs)(`span`,{"data-slot":`branch-current`,className:`flex shrink-0 items-center gap-1 rounded-sm bg-muted px-1.5 py-px text-[10px] font-medium text-muted-foreground`,children:[(0,U.jsx)(m,{"aria-hidden":`true`,className:`size-3`}),`current`]}):(0,U.jsx)(d,{variant:`ghost`,size:`sm`,"data-action":`switch-branch`,className:`ml-auto`,disabled:s.isPending,onClick:()=>s.mutate(e),children:`Switch`})]},e)}),S.length===0?(0,U.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-soft-foreground`,children:[`No branches match “`,v.trim(),`”.`]}):null]}),(0,U.jsxs)(`form`,{"data-slot":`branch-create`,className:`mt-3 flex max-w-md items-center gap-2`,onSubmit:e=>{e.preventDefault();let t=g.trim();t&&s.mutate(t,{onSuccess:()=>_(``)})},children:[(0,U.jsx)(I,{"aria-label":`New branch name`,placeholder:`new-branch-name`,value:g,onChange:e=>_(e.target.value)}),(0,U.jsxs)(d,{type:`submit`,variant:`outline`,size:`sm`,"data-action":`create-branch`,disabled:!g.trim()||s.isPending,children:[(0,U.jsx)(L,{"aria-hidden":`true`}),`Create`]})]})]}),(0,U.jsxs)(`div`,{className:`max-w-md`,children:[(0,U.jsx)(`label`,{htmlFor:`base-branch-picker`,className:`text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Agents’ base branch`}),(0,U.jsxs)(`select`,{id:`base-branch-picker`,"data-slot":`base-branch-picker`,value:e.baseBranch??``,disabled:u.isPending,onChange:e=>u.mutate(e.target.value===``?null:e.target.value),className:`mt-1.5 block 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,U.jsx)(`option`,{value:``,children:`current checkout (default)`}),e.branches.map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))]}),(0,U.jsx)(`p`,{className:`mt-1 text-[11px] text-soft-foreground`,children:`New task worktrees branch from this.`})]}),n.data?.forge?.available?(0,U.jsx)(G,{}):null]})}function G(){let e=o({limit:20});return(0,U.jsxs)(`div`,{"data-slot":`repo-prs`,className:`max-w-xl`,children:[(0,U.jsx)(`h2`,{className:`text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Open pull requests`}),e.isPending?(0,U.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Loading pull requests…`}):e.isError?(0,U.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:e.error.message}):e.data.available?e.data.prs.length===0?(0,U.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`No open pull requests.`}):(0,U.jsx)(`ul`,{className:`mt-2 flex flex-col divide-y divide-border`,children:e.data.prs.map(e=>(0,U.jsx)(K,{pr:e},e.number))}):(0,U.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 K({pr:e}){let t=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(M,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,U.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:[`#`,e.number]}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.title}),e.checks?(0,U.jsx)(q,{checks:e.checks}):null]}),n=`flex min-w-0 items-center gap-2 rounded-sm px-1.5 py-2`;return(0,U.jsx)(`li`,{"data-slot":`pr-row`,"data-number":e.number,children:y(e.url)?(0,U.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:b(n,`hover:bg-muted`),children:t}):(0,U.jsx)(`span`,{className:n,children:t})})}function q({checks:e}){return(0,U.jsx)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:b(`shrink-0 text-[10px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:e})}function J(){let e=s(),t=j(),[n,r]=(0,H.useState)(`unified`),[i,a]=(0,H.useState)(!1),[o,c]=(0,H.useState)(null),l=(0,H.useRef)(null),u=e.isError&&e.error instanceof v&&e.error.status===409,d=e.data?.files??[],f=(0,H.useMemo)(()=>T(d),[d]),p=t?n:`unified`,m=!t||i;return(0,U.jsxs)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,U.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,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,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Uncommitted changes`}),e.data?(0,U.jsx)(E,{stat:e.data.stat}):null,(0,U.jsx)(`span`,{className:`ml-auto hidden items-center gap-1 md:flex`,children:(0,U.jsx)(O,{mode:n,wrap:i,onModeChange:r,onWrapChange:a})})]}),e.isPending?(0,U.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading changes…`}):e.isError?(0,U.jsx)(g,{icon:u?(0,U.jsx)(C,{}):(0,U.jsx)(P,{}),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,U.jsx)(g,{icon:(0,U.jsx)(C,{}),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,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-5 px-4 py-4 [--diff-sticky-top:7rem] md:px-6`,children:[(0,U.jsx)(`aside`,{className:`sticky top-28 hidden w-60 shrink-0 md:block lg:w-72`,children:(0,U.jsx)(w,{root:f,selected:o,onSelect:e=>{c(e),l.current?.scrollToPath(e)}})}),(0,U.jsx)(k,{files:d,viewRef:l,mode:p,wrap:m,className:`min-w-0 flex-1`})]})]})}function Y({log:e}){let{sha:t}=_();return t?(0,U.jsx)(X,{sha:t}):e.length===0?(0,U.jsx)(g,{icon:(0,U.jsx)(D,{}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`}):(0,U.jsx)(V,{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 X({sha:e}){let t=r(e),n=j(),[i,a]=(0,H.useState)(`unified`),[o,s]=(0,H.useState)(!1),c=t.isError&&t.error instanceof v&&t.error.status===409,l=n?i:`unified`,u=!n||o;return(0,U.jsxs)(`section`,{"data-slot":`repo-commit`,"data-sha":e,className:`flex min-h-0 flex-1 flex-col`,children:[(0,U.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,U.jsx)(d,{asChild:!0,variant:`ghost`,size:`sm`,"data-slot":`commit-back`,children:(0,U.jsxs)(F,{to:`/git/commits`,children:[(0,U.jsx)(x,{"aria-hidden":`true`}),`All commits`]})}),t.data?(0,U.jsx)(z,{stat:t.data.stat}):null,(0,U.jsx)(`span`,{className:`ml-auto hidden items-center gap-1 md:flex`,children:(0,U.jsx)(O,{mode:i,wrap:o,onModeChange:a,onWrapChange:s})})]}),t.isPending?(0,U.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,U.jsx)(g,{icon:c?(0,U.jsx)(N,{}):(0,U.jsx)(P,{}),tone:c?`neutral`:`danger`,heading:`h2`,title:c?`Commit not found`:`Could not load the commit`,subtitle:t.error.message}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{"data-slot":`commit-meta`,className:`border-b border-border px-4 py-3 md:px-6`,children:[(0,U.jsx)(`h2`,{className:`text-sm font-semibold`,children:t.data.subject}),(0,U.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-soft-foreground`,children:[t.data.author,` · `,t.data.when,` ·`,` `,(0,U.jsx)(`span`,{className:`font-mono select-all`,children:t.data.sha})]})]}),t.data.files.length===0?(0,U.jsx)(g,{icon:(0,U.jsx)(D,{}),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,U.jsx)(`div`,{className:`px-4 py-4 [--diff-sticky-top:7rem] md:px-6`,children:(0,U.jsx)(k,{files:t.data.files,mode:l,wrap:u,className:`min-w-0`})})]})]})}function Z({tab:e}){let t=u();if(t.isPending)return(0,U.jsx)(B,{});if(t.isError)return(0,U.jsx)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:(0,U.jsx)(g,{icon:(0,U.jsx)(P,{}),tone:`danger`,title:`Could not load the repository`,subtitle:t.error.message})});let n=t.data.info;return n?(0,U.jsx)(Q,{repo:t.data,info:n,tab:e}):(0,U.jsx)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:(0,U.jsx)(g,{icon:(0,U.jsx)(R,{}),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 Q({repo:e,info:t,tab:n}){return(0,U.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,U.jsxs)(`header`,{"data-slot":`repo-header`,className:`sticky top-0 z-20 border-b border-border bg-background/95 px-4 pt-3 backdrop-blur md:px-6`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,U.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Git`}),(0,U.jsx)(A,{branch:t.branch}),t.remote?(0,U.jsx)(`span`,{"data-slot":`repo-remote`,className:`hidden min-w-0 truncate text-[11px] text-soft-foreground md:inline`,children:t.remote}):null]}),(0,U.jsxs)(`div`,{"data-slot":`repo-tabs`,className:`mt-2.5 flex items-end gap-1`,children:[(0,U.jsx)(S,{to:`/git`,active:n===`changes`,children:`Changes`}),(0,U.jsx)(S,{to:`/git/commits`,active:n===`commits`,children:`Commits`}),(0,U.jsx)(S,{to:`/git/branches`,active:n===`branches`,children:`Branches`})]})]}),n===`changes`?(0,U.jsx)(J,{}):n===`commits`?(0,U.jsx)(Y,{log:e.log}):(0,U.jsx)(W,{repo:e,info:t})]})}export{Z as RepoGitRoute};
1
+ import{a as e,s as t,u as n}from"./bundle-mjs-BegPhL5c.js";import{$ as r,A as i,B as a,L as o,Q as s,Tt as c,Wt as l,Z as u,a as d,fn as f,i as p,k as m,mn as h,t as g,un as _,yt as v}from"./centered-state-CLmJ67EV.js";import{n as y,t as b}from"./utils-B8s5qIcK.js";import{t as x}from"./arrow-left-CnSdp92h.js";import{t as S}from"./tab-link-vtgjgL_M.js";import{a as C,i as w,r as T,t as E}from"./git-toolbar-A1hGl9ke.js";import{a as D,i as O,n as k,r as A,t as j}from"./use-desktop-DDySz-Hn.js";import{t as M}from"./git-pull-request-DnR8Xh4_.js";import{t as N}from"./search-x-BDjaMrzG.js";import{t as P}from"./triangle-alert-Uy8rokUh.js";import{t as F}from"./project-router-BaWVyqc8.js";import{Zt as I,l as L,rt as R,tn as z,zt as B}from"./index-MN3Lxn3t.js";import{t as V}from"./commit-list-CSaWuw-x.js";var H=n(t(),1),U=e();function W({repo:e,info:t}){let n=a(),r=h(),o=e=>p(e.message,{tone:`danger`}),s=f({mutationFn:e=>c({name:e}),onSuccess:async e=>{p(e.created?`Created and switched to ${e.branch}`:`Switched to ${e.branch}`),await Promise.all([r.invalidateQueries({queryKey:i.repo}),r.invalidateQueries({queryKey:i.health})]),r.setQueryData(i.repo,t=>t?.info?{...t,info:{...t.info,branch:e.branch}}:t),r.setQueryData(i.health,n=>n?.repo?.root===t.root?{...n,repo:{...n.repo,branch:e.branch}}:n)},onError:o}),u=f({mutationFn:e=>l({baseBranch:e}),onSuccess:e=>{p(e.baseBranch?`Agents now branch from ${e.baseBranch}`:`Agents now branch from the current checkout`),r.invalidateQueries({queryKey:i.repo})},onError:o}),[g,_]=(0,H.useState)(``),[v,y]=(0,H.useState)(``),x=v.trim().toLowerCase(),S=x?e.branches.filter(e=>e.toLowerCase().includes(x)):e.branches;return(0,U.jsxs)(`section`,{"data-slot":`repo-branches`,className:`flex flex-col gap-6 px-4 py-4 md:px-6`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h2`,{className:`text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Branches`}),(0,U.jsx)(B,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:v,onChange:e=>y(e.target.value),className:`mt-2 max-w-xl`}),(0,U.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-2 flex max-w-xl flex-col divide-y divide-border`,children:[S.map(e=>{let n=e===t.branch;return(0,U.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,className:`flex min-h-9 items-center gap-2 py-1`,children:[(0,U.jsx)(z,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,U.jsx)(`span`,{className:b(`min-w-0 truncate font-mono text-xs`,n&&`font-semibold`),children:e}),n?(0,U.jsxs)(`span`,{"data-slot":`branch-current`,className:`flex shrink-0 items-center gap-1 rounded-sm bg-muted px-1.5 py-px text-[10px] font-medium text-muted-foreground`,children:[(0,U.jsx)(m,{"aria-hidden":`true`,className:`size-3`}),`current`]}):(0,U.jsx)(d,{variant:`ghost`,size:`sm`,"data-action":`switch-branch`,className:`ml-auto`,disabled:s.isPending,onClick:()=>s.mutate(e),children:`Switch`})]},e)}),S.length===0?(0,U.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-soft-foreground`,children:[`No branches match “`,v.trim(),`”.`]}):null]}),(0,U.jsxs)(`form`,{"data-slot":`branch-create`,className:`mt-3 flex max-w-md items-center gap-2`,onSubmit:e=>{e.preventDefault();let t=g.trim();t&&s.mutate(t,{onSuccess:()=>_(``)})},children:[(0,U.jsx)(B,{"aria-label":`New branch name`,placeholder:`new-branch-name`,value:g,onChange:e=>_(e.target.value)}),(0,U.jsxs)(d,{type:`submit`,variant:`outline`,size:`sm`,"data-action":`create-branch`,disabled:!g.trim()||s.isPending,children:[(0,U.jsx)(I,{"aria-hidden":`true`}),`Create`]})]})]}),(0,U.jsxs)(`div`,{className:`max-w-md`,children:[(0,U.jsx)(`label`,{htmlFor:`base-branch-picker`,className:`text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Agents’ base branch`}),(0,U.jsxs)(`select`,{id:`base-branch-picker`,"data-slot":`base-branch-picker`,value:e.baseBranch??``,disabled:u.isPending,onChange:e=>u.mutate(e.target.value===``?null:e.target.value),className:`mt-1.5 block 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,U.jsx)(`option`,{value:``,children:`current checkout (default)`}),e.branches.map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))]}),(0,U.jsx)(`p`,{className:`mt-1 text-[11px] text-soft-foreground`,children:`New task worktrees branch from this.`})]}),n.data?.forge?.available?(0,U.jsx)(G,{}):null]})}function G(){let e=o({limit:20});return(0,U.jsxs)(`div`,{"data-slot":`repo-prs`,className:`max-w-xl`,children:[(0,U.jsx)(`h2`,{className:`text-xs font-semibold tracking-wide text-soft-foreground uppercase`,children:`Open pull requests`}),e.isPending?(0,U.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Loading pull requests…`}):e.isError?(0,U.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:e.error.message}):e.data.available?e.data.prs.length===0?(0,U.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`No open pull requests.`}):(0,U.jsx)(`ul`,{className:`mt-2 flex flex-col divide-y divide-border`,children:e.data.prs.map(e=>(0,U.jsx)(K,{pr:e},e.number))}):(0,U.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 K({pr:e}){let t=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(M,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,U.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:[`#`,e.number]}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.title}),e.checks?(0,U.jsx)(q,{checks:e.checks}):null]}),n=`flex min-w-0 items-center gap-2 rounded-sm px-1.5 py-2`;return(0,U.jsx)(`li`,{"data-slot":`pr-row`,"data-number":e.number,children:y(e.url)?(0,U.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:b(n,`hover:bg-muted`),children:t}):(0,U.jsx)(`span`,{className:n,children:t})})}function q({checks:e}){return(0,U.jsx)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:b(`shrink-0 text-[10px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:e})}function J(){let e=s(),t=j(),[n,r]=(0,H.useState)(`unified`),[i,a]=(0,H.useState)(!1),[o,c]=(0,H.useState)(null),l=(0,H.useRef)(null),u=e.isError&&e.error instanceof v&&e.error.status===409,d=e.data?.files??[],f=(0,H.useMemo)(()=>T(d),[d]),p=t?n:`unified`,m=!t||i;return(0,U.jsxs)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,U.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,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,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Uncommitted changes`}),e.data?(0,U.jsx)(E,{stat:e.data.stat}):null,(0,U.jsx)(`span`,{className:`ml-auto hidden items-center gap-1 md:flex`,children:(0,U.jsx)(O,{mode:n,wrap:i,onModeChange:r,onWrapChange:a})})]}),e.isPending?(0,U.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading changes…`}):e.isError?(0,U.jsx)(g,{icon:u?(0,U.jsx)(C,{}):(0,U.jsx)(P,{}),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,U.jsx)(g,{icon:(0,U.jsx)(C,{}),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,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-5 px-4 py-4 [--diff-sticky-top:7rem] md:px-6`,children:[(0,U.jsx)(`aside`,{className:`sticky top-28 hidden w-60 shrink-0 md:block lg:w-72`,children:(0,U.jsx)(w,{root:f,selected:o,onSelect:e=>{c(e),l.current?.scrollToPath(e)}})}),(0,U.jsx)(k,{files:d,viewRef:l,mode:p,wrap:m,className:`min-w-0 flex-1`})]})]})}function Y({log:e}){let{sha:t}=_();return t?(0,U.jsx)(X,{sha:t}):e.length===0?(0,U.jsx)(g,{icon:(0,U.jsx)(D,{}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`}):(0,U.jsx)(V,{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 X({sha:e}){let t=r(e),n=j(),[i,a]=(0,H.useState)(`unified`),[o,s]=(0,H.useState)(!1),c=t.isError&&t.error instanceof v&&t.error.status===409,l=n?i:`unified`,u=!n||o;return(0,U.jsxs)(`section`,{"data-slot":`repo-commit`,"data-sha":e,className:`flex min-h-0 flex-1 flex-col`,children:[(0,U.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,U.jsx)(d,{asChild:!0,variant:`ghost`,size:`sm`,"data-slot":`commit-back`,children:(0,U.jsxs)(F,{to:`/git/commits`,children:[(0,U.jsx)(x,{"aria-hidden":`true`}),`All commits`]})}),t.data?(0,U.jsx)(R,{stat:t.data.stat}):null,(0,U.jsx)(`span`,{className:`ml-auto hidden items-center gap-1 md:flex`,children:(0,U.jsx)(O,{mode:i,wrap:o,onModeChange:a,onWrapChange:s})})]}),t.isPending?(0,U.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,U.jsx)(g,{icon:c?(0,U.jsx)(N,{}):(0,U.jsx)(P,{}),tone:c?`neutral`:`danger`,heading:`h2`,title:c?`Commit not found`:`Could not load the commit`,subtitle:t.error.message}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{"data-slot":`commit-meta`,className:`border-b border-border px-4 py-3 md:px-6`,children:[(0,U.jsx)(`h2`,{className:`text-sm font-semibold`,children:t.data.subject}),(0,U.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-soft-foreground`,children:[t.data.author,` · `,t.data.when,` ·`,` `,(0,U.jsx)(`span`,{className:`font-mono select-all`,children:t.data.sha})]})]}),t.data.files.length===0?(0,U.jsx)(g,{icon:(0,U.jsx)(D,{}),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,U.jsx)(`div`,{className:`px-4 py-4 [--diff-sticky-top:7rem] md:px-6`,children:(0,U.jsx)(k,{files:t.data.files,mode:l,wrap:u,className:`min-w-0`})})]})]})}function Z({tab:e}){let t=u();if(t.isPending)return(0,U.jsx)(L,{});if(t.isError)return(0,U.jsx)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:(0,U.jsx)(g,{icon:(0,U.jsx)(P,{}),tone:`danger`,title:`Could not load the repository`,subtitle:t.error.message})});let n=t.data.info;return n?(0,U.jsx)(Q,{repo:t.data,info:n,tab:e}):(0,U.jsx)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:(0,U.jsx)(g,{icon:(0,U.jsx)(z,{}),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 Q({repo:e,info:t,tab:n}){return(0,U.jsxs)(`div`,{"data-route":`repo-git`,className:`flex min-h-full flex-col`,children:[(0,U.jsxs)(`header`,{"data-slot":`repo-header`,className:`sticky top-0 z-20 border-b border-border bg-background/95 px-4 pt-3 backdrop-blur md:px-6`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,U.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Git`}),(0,U.jsx)(A,{branch:t.branch}),t.remote?(0,U.jsx)(`span`,{"data-slot":`repo-remote`,className:`hidden min-w-0 truncate text-[11px] text-soft-foreground md:inline`,children:t.remote}):null]}),(0,U.jsxs)(`div`,{"data-slot":`repo-tabs`,className:`mt-2.5 flex items-end gap-1`,children:[(0,U.jsx)(S,{to:`/git`,active:n===`changes`,children:`Changes`}),(0,U.jsx)(S,{to:`/git/commits`,active:n===`commits`,children:`Commits`}),(0,U.jsx)(S,{to:`/git/branches`,active:n===`branches`,children:`Branches`})]})]}),n===`changes`?(0,U.jsx)(J,{}):n===`commits`?(0,U.jsx)(Y,{log:e.log}):(0,U.jsx)(W,{repo:e,info:t})]})}export{Z as RepoGitRoute};
@@ -1,3 +1,3 @@
1
- import{a as e,s as t,u as n}from"./bundle-mjs-BegPhL5c.js";import{A as r,E as i,_ as a,a as o,b as s,g as c,h as l,it as u,mn as d,v as f,x as p,y as m}from"./centered-state-CLmJ67EV.js";import{t as h}from"./utils-B8s5qIcK.js";import{C as g,S as _,nn as v}from"./index-CcfkF2Ey.js";var y=n(t(),1),b=e(),x=`Collapsible`,[S,C]=s(x),[w,T]=S(x),E=y.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:o,onOpenChange:s,...c}=e,[u,d]=a({prop:r,defaultProp:i??!1,onChange:s,caller:x});return(0,b.jsx)(w,{scope:n,disabled:o,contentId:l(),open:u,onOpenToggle:y.useCallback(()=>d(e=>!e),[d]),children:(0,b.jsx)(p.div,{"data-state":M(u),"data-disabled":o?``:void 0,...c,ref:t})})});E.displayName=x;var D=`CollapsibleTrigger`,O=y.forwardRef((e,t)=>{let{__scopeCollapsible:n,...r}=e,i=T(D,n);return(0,b.jsx)(p.button,{type:`button`,"aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open||!1,"data-state":M(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:m(e.onClick,i.onOpenToggle)})});O.displayName=D;var k=`CollapsibleContent`,A=y.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=T(k,e.__scopeCollapsible);return(0,b.jsx)(c,{present:n||i.open,children:({present:e})=>(0,b.jsx)(j,{...r,ref:t,present:e})})});A.displayName=k;var j=y.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:r,children:a,...o}=e,s=T(k,n),[c,l]=y.useState(r),u=y.useRef(null),d=i(t,u),m=y.useRef(0),h=m.current,g=y.useRef(0),_=g.current,v=s.open||c,x=y.useRef(v),S=y.useRef(void 0);return y.useEffect(()=>{let e=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(e)},[]),f(()=>{let e=u.current;if(e){S.current=S.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();m.current=t.height,g.current=t.width,x.current||(e.style.transitionDuration=S.current.transitionDuration,e.style.animationName=S.current.animationName),l(r)}},[s.open,r]),(0,b.jsx)(p.div,{"data-state":M(s.open),"data-disabled":s.disabled?``:void 0,id:s.contentId,hidden:!v,...o,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":_?`${_}px`:void 0,...e.style},children:v&&a})});function M(e){return e?`open`:`closed`}var N=E;function P({...e}){return(0,b.jsx)(N,{"data-slot":`collapsible`,...e})}function F({...e}){return(0,b.jsx)(O,{"data-slot":`collapsible-trigger`,...e})}function I({...e}){return(0,b.jsx)(A,{"data-slot":`collapsible-content`,...e})}var L=/^diff --git /;function R(e){let t=e.replace(L,``),n=t.lastIndexOf(` b/`);return z(n>=0?t.slice(n+3):t)}function z(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)&&t.length>=2?t.slice(1,-1).replace(/\\(.)/g,`$1`):t}function B(e){let t=z(e.slice(4));if(t!==`/dev/null`)return t.replace(/^[ab]\//,``)}function V(e){let t=[],n=null,r=!1;for(let i of e.split(`
1
+ import{a as e,s as t,u as n}from"./bundle-mjs-BegPhL5c.js";import{A as r,E as i,_ as a,a as o,b as s,g as c,h as l,it as u,mn as d,v as f,x as p,y as m}from"./centered-state-CLmJ67EV.js";import{t as h}from"./utils-B8s5qIcK.js";import{C as g,S as _,an as v}from"./index-MN3Lxn3t.js";var y=n(t(),1),b=e(),x=`Collapsible`,[S,C]=s(x),[w,T]=S(x),E=y.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:o,onOpenChange:s,...c}=e,[u,d]=a({prop:r,defaultProp:i??!1,onChange:s,caller:x});return(0,b.jsx)(w,{scope:n,disabled:o,contentId:l(),open:u,onOpenToggle:y.useCallback(()=>d(e=>!e),[d]),children:(0,b.jsx)(p.div,{"data-state":M(u),"data-disabled":o?``:void 0,...c,ref:t})})});E.displayName=x;var D=`CollapsibleTrigger`,O=y.forwardRef((e,t)=>{let{__scopeCollapsible:n,...r}=e,i=T(D,n);return(0,b.jsx)(p.button,{type:`button`,"aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open||!1,"data-state":M(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:m(e.onClick,i.onOpenToggle)})});O.displayName=D;var k=`CollapsibleContent`,A=y.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=T(k,e.__scopeCollapsible);return(0,b.jsx)(c,{present:n||i.open,children:({present:e})=>(0,b.jsx)(j,{...r,ref:t,present:e})})});A.displayName=k;var j=y.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:r,children:a,...o}=e,s=T(k,n),[c,l]=y.useState(r),u=y.useRef(null),d=i(t,u),m=y.useRef(0),h=m.current,g=y.useRef(0),_=g.current,v=s.open||c,x=y.useRef(v),S=y.useRef(void 0);return y.useEffect(()=>{let e=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(e)},[]),f(()=>{let e=u.current;if(e){S.current=S.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();m.current=t.height,g.current=t.width,x.current||(e.style.transitionDuration=S.current.transitionDuration,e.style.animationName=S.current.animationName),l(r)}},[s.open,r]),(0,b.jsx)(p.div,{"data-state":M(s.open),"data-disabled":s.disabled?``:void 0,id:s.contentId,hidden:!v,...o,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":_?`${_}px`:void 0,...e.style},children:v&&a})});function M(e){return e?`open`:`closed`}var N=E;function P({...e}){return(0,b.jsx)(N,{"data-slot":`collapsible`,...e})}function F({...e}){return(0,b.jsx)(O,{"data-slot":`collapsible-trigger`,...e})}function I({...e}){return(0,b.jsx)(A,{"data-slot":`collapsible-content`,...e})}var L=/^diff --git /;function R(e){let t=e.replace(L,``),n=t.lastIndexOf(` b/`);return z(n>=0?t.slice(n+3):t)}function z(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)&&t.length>=2?t.slice(1,-1).replace(/\\(.)/g,`$1`):t}function B(e){let t=z(e.slice(4));if(t!==`/dev/null`)return t.replace(/^[ab]\//,``)}function V(e){let t=[],n=null,r=!1;for(let i of e.split(`
2
2
  `)){if(L.test(i)){n={path:R(i),status:`modified`,binary:!1,additions:0,deletions:0,lines:[]},t.push(n),r=!1;continue}if(n){if(!r){if(i.startsWith(`@@`))r=!0,n.lines.push(i);else if(i.startsWith(`rename from `))n.status=`renamed`,n.oldPath=z(i.slice(12));else if(i.startsWith(`rename to `))n.status=`renamed`,n.path=z(i.slice(10));else if(i.startsWith(`new file mode`))n.status=`added`;else if(i.startsWith(`deleted file mode`))n.status=`deleted`;else if(i.startsWith(`Binary files `)||i===`GIT binary patch`)n.binary=!0;else if(i.startsWith(`+++ `)){let e=B(i);e!==void 0&&(n.path=e)}else if(i.startsWith(`--- `)){let e=B(i);e!==void 0&&n.status===`deleted`&&(n.path=e)}continue}n.lines.push(i),i.startsWith(`+`)?n.additions+=1:i.startsWith(`-`)&&(n.deletions+=1)}}let i=t.at(-1);return i&&i.lines.at(-1)===``&&i.lines.pop(),t}function H(e){return{files:e.length,additions:e.reduce((e,t)=>e+t.additions,0),deletions:e.reduce((e,t)=>e+t.deletions,0)}}var U=20,W=300;function G({runId:e}){let t=d(),n=u(e);(0,y.useEffect)(()=>{t.invalidateQueries({queryKey:r.runs.diff(e)})},[t,e]);let i=(0,y.useMemo)(()=>V(n.data??``),[n.data]),[a,s]=(0,y.useState)(!1);if(n.isPending)return(0,b.jsx)(`p`,{className:`px-1 text-xs text-soft-foreground`,children:`Loading diff…`});if(n.isError)return(0,b.jsx)(`p`,{className:`px-1 text-xs text-danger`,children:n.error.message});if(i.length===0)return(0,b.jsx)(`p`,{"data-slot":`run-diff-empty`,className:`px-1 font-mono text-xs text-soft-foreground`,children:n.data.trim()||`(no changes)`});let c=H(i),l=a?i:i.slice(0,U);return(0,b.jsxs)(`div`,{"data-slot":`run-diff`,className:`flex min-w-0 flex-col gap-2`,children:[(0,b.jsxs)(`p`,{className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,b.jsxs)(`span`,{children:[c.files,` `,c.files===1?`file`:`files`,` changed`]}),(0,b.jsxs)(`span`,{className:`font-mono font-semibold tabular-nums`,children:[(0,b.jsxs)(`span`,{className:`text-success`,children:[`+`,c.additions]}),` `,(0,b.jsxs)(`span`,{className:`text-danger`,children:[`−`,c.deletions]})]})]}),l.map(e=>(0,b.jsx)(q,{file:e},`${e.oldPath??``}→${e.path}`)),i.length>l.length?(0,b.jsxs)(o,{variant:`ghost`,size:`sm`,className:`self-start`,onClick:()=>s(!0),children:[`Show `,i.length-l.length,` more files`]}):null]})}var K={added:`added`,deleted:`deleted`,renamed:`renamed`};function q({file:e}){let[t,n]=(0,y.useState)(!0),r=K[e.status];return(0,b.jsxs)(P,{open:t,onOpenChange:n,"data-slot":`diff-file`,className:`min-w-0 overflow-hidden rounded-md border border-border bg-card`,children:[(0,b.jsxs)(F,{className:`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-muted/50`,children:[(0,b.jsx)(v,{className:h(`size-3.5 shrink-0 text-soft-foreground transition-transform`,t&&`rotate-90`),"aria-hidden":`true`}),(0,b.jsx)(`span`,{"data-slot":`diff-file-path`,className:`min-w-0 truncate font-mono text-xs font-medium`,children:e.oldPath?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`span`,{className:`text-soft-foreground`,children:[e.oldPath,` → `]}),e.path]}):e.path}),r?(0,b.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[10px] font-medium text-muted-foreground`,children:r}):null,e.binary?(0,b.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[10px] font-medium text-muted-foreground`,children:`binary`}):null,(0,b.jsxs)(`span`,{className:`ml-auto shrink-0 font-mono text-[11px] font-semibold tabular-nums`,children:[(0,b.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions]}),` `,(0,b.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.deletions]})]})]}),(0,b.jsx)(I,{children:(0,b.jsx)(`div`,{className:`border-t border-border/50`,children:e.binary?(0,b.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`Binary file — no text diff.`}):e.lines.length===0?(0,b.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`No content changes (metadata only).`}):(0,b.jsx)(J,{lines:e.lines})})})]})}function J({lines:e}){let[t,n]=(0,y.useState)(!1),r=t?e:e.slice(0,W),i=r.join(`
3
3
  `),[a,o]=(0,y.useState)(null);(0,y.useEffect)(()=>{let e=!1;return _(i,`diff`).then(t=>{e||o({text:i,tokens:t.tokens})}),()=>{e=!0}},[i]);let s=a?.text===i?a.tokens:g(i,`diff`)?.tokens??null;return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`pre`,{"data-slot":`diff-file-body`,className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:r.map((e,t)=>(0,b.jsxs)(`span`,{className:h(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del`,e.startsWith(`@@`)&&`text-soft-foreground`),children:[s?.[t]===void 0?e:s[t].map((e,t)=>(0,b.jsx)(`span`,{style:e.color===void 0?void 0:{color:e.color},children:e.content},t)),e===``?` `:``]},t))}),e.length>W?(0,b.jsx)(`button`,{type:`button`,"data-slot":`diff-file-toggle`,onClick:()=>n(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:t?`Show less`:`Show all ${e.length} lines`}):null]})}export{F as i,P as n,I as r,G as t};
@@ -0,0 +1 @@
1
+ import{a as e,s as t,u as n}from"./bundle-mjs-BegPhL5c.js";import{A as r,B as i,Lt as a,O as o,Rt as s,St as c,U as l,W as u,a as d,ct as ee,fn as f,i as p,jt as te,k as m,kt as ne,mn as h,ot as re,wt as ie,xt as g,yt as _}from"./centered-state-CLmJ67EV.js";import{n as v,r as y,t as b}from"./utils-B8s5qIcK.js";import{n as x,t as S}from"./trash-2-DAyZ0VSi.js";import{t as ae}from"./ellipsis-vertical-CNnSLn5a.js";import{n as C,t as w}from"./tab-link-vtgjgL_M.js";import{t as T}from"./square-terminal-Ckjjn0vb.js";import{c as oe}from"./project-router-BaWVyqc8.js";import{$ as se,$t as ce,At as le,Jt as ue,Kt as de,Ot as fe,Q as E,Qt as D,Z as pe,_ as me,_t as O,d as he,dt as k,et as ge,f as _e,ft as A,g as ve,gt as ye,h as j,in as M,ln as N,lt as P,m as be,mt as F,n as xe,nn as Se,nt as I,p as Ce,pt as L,r as we,rt as Te,sn as R,t as Ee,tt as De,u as Oe,ut as z,x as ke}from"./index-MN3Lxn3t.js";var B=y(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),Ae=y(`boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),je=y(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),Me=y(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),V=y(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),Ne=y(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),Pe=y(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Fe=y(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),Ie=y(`diamond`,[[`path`,{d:`M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z`,key:`1f1r0c`}]]),Le=y(`feather`,[[`path`,{d:`M12.67 19a2 2 0 0 0 1.416-.588l6.154-6.172a6 6 0 0 0-8.49-8.49L5.586 9.914A2 2 0 0 0 5 11.328V18a1 1 0 0 0 1 1z`,key:`18jl4k`}],[`path`,{d:`M16 8 2 22`,key:`vp34q`}],[`path`,{d:`M17.5 15H9`,key:`1oz8nu`}]]),H=y(`file-text`,[[`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:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Re=y(`gem`,[[`path`,{d:`M10.5 3 8 9l4 13 4-13-2.5-6`,key:`b3dvk1`}],[`path`,{d:`M17 3a2 2 0 0 1 1.6.8l3 4a2 2 0 0 1 .013 2.382l-7.99 10.986a2 2 0 0 1-3.247 0l-7.99-10.986A2 2 0 0 1 2.4 7.8l2.998-3.997A2 2 0 0 1 7 3z`,key:`7w4byz`}],[`path`,{d:`M2 9h20`,key:`16fsjt`}]]),U=y(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),ze=y(`hammer`,[[`path`,{d:`m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9`,key:`1hayfq`}],[`path`,{d:`m18 15 4-4`,key:`16gjal`}],[`path`,{d:`m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5`,key:`15ts47`}]]),Be=y(`hexagon`,[[`path`,{d:`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`,key:`yt0hxn`}]]),Ve=y(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),He=y(`rocket`,[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]),Ue=y(`shapes`,[[`path`,{d:`M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z`,key:`1bo67w`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}],[`circle`,{cx:`17.5`,cy:`17.5`,r:`3.5`,key:`w3z12y`}]]),We=y(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),Ge=y(`waves-horizontal`,[[`path`,{d:`M2 12q2.5 2 5 0t5 0 5 0 5 0`,key:`8ddzzs`}],[`path`,{d:`M2 19q2.5 2 5 0t5 0 5 0 5 0`,key:`1wj4st`}],[`path`,{d:`M2 5q2.5 2 5 0t5 0 5 0 5 0`,key:`69x50u`}]]),W=n(t(),1);function G(e){return e===`running`||e===`queued`||e===`waiting`}function K(e){return[...e.steps].reverse().find(e=>e.sessionId)?.sessionId}var Ke=/^[A-Za-z0-9._][A-Za-z0-9._-]{0,199}$/;function qe(e,t){if(Ke.test(t))switch(e){case`codex`:return`codex resume ${t}`;case`opencode`:return`opencode --session ${t}`;default:return`claude --resume ${t}`}}function Je(e){if(G(e.status))return;let t=K(e);if(t===void 0)return;let n=qe(e.runner,t);if(n!==void 0)return e.worktreePath?`cd ${e.worktreePath} && ${n}`:n}function Ye(e){let t=/^cli:(claude|codex|opencode)$/.exec(e);return t?t[1]:void 0}function Xe(e,t){let n=Ye(t);return!n||G(e.status)?!1:n===(e.runner??`claude`)&&K(e)!==void 0}function q(e){let t=G(e.status),n=K(e)!==void 0;return{finish:e.status===`waiting`||e.status===`review`,continueRun:!t&&n,terminal:!t&&n,notes:!0,archive:!t,cancel:t,deleteRun:!t}}function J(e){return e===`review`?`Accept the changes without a PR`:`Close the session`}function Ze(e,t){let n=e.filter(e=>!e.archived&&e.status===`queued`).sort((e,t)=>e.createdAt.localeCompare(t.createdAt)).findIndex(e=>e.id===t);return n>=0?n+1:void 0}var Y=e();function X(e){switch(e){case`done`:return`done`;case`running`:case`waiting`:case`review`:return`active`;case`failed`:case`cancelled`:return`failed`;case`pending`:case`skipped`:return`pending`}}function Qe(e){if(e.length===0)return 0;let t=new Set([`done`,`failed`,`cancelled`,`skipped`]),n=new Set([`running`,`waiting`,`review`]),r=0;for(let i of e)t.has(i.status)?r+=1:n.has(i.status)&&(r+=.5);return r/e.length}function $e({steps:e}){if(e.length===0)return null;let t=Qe(e)*100;return(0,Y.jsxs)(`div`,{"data-slot":`step-rail`,className:`flex min-w-0 flex-col gap-1`,children:[e.map((t,n)=>(0,Y.jsxs)(`div`,{"data-slot":`step-row`,"data-visual":X(t.status),className:`flex min-h-[22px] min-w-0 items-center gap-2 text-[13px] text-muted-foreground`,children:[(0,Y.jsx)(et,{visual:X(t.status)}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground`,children:t.name}),t.iterations>1?(0,Y.jsxs)(`span`,{"data-slot":`step-iterations`,className:`shrink-0 text-xs text-soft-foreground tabular-nums`,children:[`×`,t.iterations]}):null,(0,Y.jsxs)(`span`,{className:`ml-auto shrink-0 pl-2 text-[11.5px] text-soft-foreground tabular-nums`,children:[t.kind,` · step `,n+1,` of `,e.length]})]},t.id)),(0,Y.jsx)(`div`,{"data-slot":`step-progress`,className:`mt-1 h-0.5 overflow-hidden rounded-full bg-muted`,children:(0,Y.jsx)(`div`,{className:`h-full rounded-full bg-pending`,style:{width:`${t}%`}})})]})}function et({visual:e}){let t=`size-[13px] shrink-0`;switch(e){case`done`:return(0,Y.jsx)(Me,{"aria-hidden":!0,className:b(t,`text-success`)});case`active`:return(0,Y.jsx)(o,{role:`status`,"aria-label":`Step running`,className:b(t,`animate-spin stroke-pending motion-reduce:animate-none`)});case`failed`:return(0,Y.jsx)(Ne,{"aria-hidden":!0,className:b(t,`text-danger`)});case`pending`:return(0,Y.jsx)(M,{"aria-hidden":!0,className:b(t,`text-soft-foreground`)})}}function Z(e){let t=h();return f({mutationFn:()=>te(e),onSuccess:()=>t.invalidateQueries({queryKey:r.runs.all}),onError:e=>p(e.message,{tone:`danger`})})}function tt({run:e,planTally:t,tab:n=`session`}){let r=le(e),i=q(e),a=Je(e),[o,s]=(0,W.useState)(!1),c=it(e),l=ee(),u=e.status===`queued`?ye(l.data??[]).get(e.id):void 0;return(0,Y.jsxs)(`header`,{"data-slot":`run-header`,className:`sticky top-0 z-20 border-b border-border bg-background/95 px-4 pt-3 backdrop-blur md:px-6`,children:[(0,Y.jsxs)(`div`,{className:`mx-auto w-full max-w-[820px]`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(at,{run:e}),(0,Y.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2.5`,children:[t?(0,Y.jsxs)(`span`,{"data-slot":`plan-mirror`,className:`text-[11px] text-soft-foreground tabular-nums`,children:[`Plan `,t.done,`/`,t.total]}):null,(0,Y.jsxs)(Ee,{dot:r.tone,pulse:r.pulse,children:[r.label,u===void 0?``:` #${u}`]}),(0,Y.jsx)(ct,{run:e,actions:c,onToggleNotes:()=>s(e=>!e)})]})]}),(0,Y.jsx)(ot,{run:e}),(0,Y.jsxs)(`div`,{"data-slot":`run-tabs`,className:`mt-2.5 flex items-end gap-1`,children:[(0,Y.jsx)(w,{to:`/tasks/${e.id}`,active:n===`session`,children:`Session`}),(0,Y.jsx)(w,{to:`/tasks/${e.id}/changes`,active:n===`changes`,children:`Changes`}),(0,Y.jsx)(w,{to:`/tasks/${e.id}/commits`,active:n===`commits`,children:`Commits`}),(0,Y.jsx)(w,{to:`/tasks/${e.id}/files`,active:n===`files`,children:`Files`}),(0,Y.jsxs)(`div`,{"data-slot":`run-actions`,className:`ml-auto hidden items-center gap-1 pb-1 md:flex`,children:[i.finish?(0,Y.jsxs)(d,{variant:`outline`,size:`sm`,title:J(e.status),onClick:()=>c.finish.mutate(),children:[(0,Y.jsx)(m,{"aria-hidden":`true`}),`Finish`]}):null,i.continueRun?(0,Y.jsxs)(d,{variant:`outline`,size:`sm`,title:`Reopen the session`,onClick:()=>c.continueRun.mutate(),children:[(0,Y.jsx)(D,{"aria-hidden":`true`}),`Continue`]}):null,(0,Y.jsx)(rt,{run:e,canResume:i.terminal,onResume:()=>c.terminal.mutate()}),(0,Y.jsxs)(d,{variant:`ghost`,size:`sm`,title:`Handoff notes — what the agent did and what's left`,"aria-expanded":o,onClick:()=>s(e=>!e),children:[(0,Y.jsx)(H,{"aria-hidden":`true`}),`Notes`]}),i.archive?(0,Y.jsxs)(d,{variant:`ghost`,size:`sm`,onClick:()=>c.archive.mutate(),children:[e.archived?(0,Y.jsx)(B,{"aria-hidden":`true`}):(0,Y.jsx)(N,{"aria-hidden":`true`}),e.archived?`Unarchive`:`Archive`]}):null,i.cancel?(0,Y.jsxs)(d,{variant:`danger-ghost`,size:`sm`,onClick:()=>c.setConfirming(`cancel`),children:[(0,Y.jsx)(V,{"aria-hidden":`true`}),`Cancel`]}):null,i.deleteRun?(0,Y.jsxs)(d,{variant:`danger-ghost`,size:`sm`,onClick:()=>c.setConfirming(`delete`),children:[(0,Y.jsx)(S,{"aria-hidden":`true`}),`Delete`]}):null]})]}),e.steps.length>0?(0,Y.jsx)(`div`,{className:`border-t border-border pt-2.5 pb-1`,children:(0,Y.jsx)($e,{steps:e.steps})}):null,a?(0,Y.jsx)(ut,{hint:a}):null,o?(0,Y.jsx)(dt,{runId:e.id}):null]}),(0,Y.jsx)(lt,{run:e,actions:c})]})}var nt={folder:Se,terminal:T,vscode:Pe,cursor:Ve,zed:de,windsurf:Ge,sublime:Le,idea:Ie,pycharm:Be,webstorm:U,goland:Ue,rubymine:Re,phpstorm:je,clion:Fe,rider:Ae,"android-studio":We,xcode:ze,warp:He,claude:R,codex:ue,opencode:R};function Q(e){return e.icon&&nt[e.icon]||C}function rt({run:e,canResume:t,onResume:n}){let r=l(),i=f({mutationFn:t=>a(e.id,t),onError:e=>p(e.message,{tone:`danger`})}),o=e.worktreePath?r.data?.targets??[]:[];return!t&&o.length===0?null:(0,Y.jsxs)(P,{children:[(0,Y.jsx)(F,{asChild:!0,children:(0,Y.jsxs)(d,{variant:`ghost`,size:`sm`,title:`Resume in a terminal, or open the worktree locally`,children:[(0,Y.jsx)(C,{"aria-hidden":`true`}),`Open in…`]})}),(0,Y.jsxs)(z,{align:`end`,children:[t?(0,Y.jsxs)(k,{"data-target":`terminal-resume`,onSelect:n,children:[(0,Y.jsx)(T,{"aria-hidden":`true`}),`Terminal (resume session)`]}):null,t&&o.length>0?(0,Y.jsx)(L,{}):null,o.map(t=>{let n=Xe(e,t.id),r=Q(t);return(0,Y.jsxs)(k,{"data-target":t.id,title:n?`Resume this run's session`:void 0,onSelect:()=>i.mutate(t.id),children:[(0,Y.jsx)(r,{"aria-hidden":`true`}),t.label,n?` (resume)`:``]},t.id)}),e.worktreePath?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(L,{}),(0,Y.jsxs)(k,{onSelect:()=>{let t=e.worktreePath;t&&navigator.clipboard.writeText(t).then(()=>p(`Worktree path copied`)).catch(()=>p(`Path: ${t}`))},children:[(0,Y.jsx)(x,{"aria-hidden":`true`}),`Copy worktree path`]})]}):null]})]})}function it(e){let t=h(),n=oe(),[i,a]=(0,W.useState)(null),o=()=>t.invalidateQueries({queryKey:r.runs.all}),l=e=>p(e.message,{tone:`danger`});return{finish:Z(e.id),continueRun:f({mutationFn:()=>ie(e.id),onSuccess:o,onError:l}),archive:f({mutationFn:()=>g(e.id,!e.archived),onSuccess:o,onError:l}),cancel:f({mutationFn:()=>c(e.id),onSuccess:o,onError:l}),delete:f({mutationFn:()=>ne(e.id),onSuccess:()=>{o(),n(`/`)},onError:l}),terminal:f({mutationFn:()=>s(e.id),onError:e=>{if(e instanceof _&&e.command){$(e.command,`No terminal found — command copied to clipboard.`);return}l(e)}}),confirming:i,setConfirming:a}}async function $(e,t){try{await navigator.clipboard.writeText(e),p(t)}catch{p(`Run manually: ${e}`)}}function at({run:e}){let t=u(e.id),n=O(e),r=we(n,e=>t.mutate({title:e},{onError:e=>p(e.message,{tone:`danger`})}));return r.editing?(0,Y.jsx)(xe,{editor:r,className:`flex-1 text-[15px] font-semibold`}):(0,Y.jsxs)(`span`,{className:`group flex min-w-0 items-center gap-1`,children:[(0,Y.jsx)(`h1`,{className:`min-w-0 truncate text-[15px] font-semibold`,title:e.task,children:n}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Rename task`,onClick:r.begin,className:`shrink-0 rounded-sm p-1 text-soft-foreground opacity-0 transition-opacity group-hover:opacity-100 hover:bg-muted hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,Y.jsx)(ce,{className:`size-3.5`,"aria-hidden":`true`})})]})}function ot({run:e}){let t=[(0,Y.jsx)(`span`,{children:De(e)},`workflow`)];e.branch&&t.push((0,Y.jsx)(`span`,{"data-slot":`branch-chip`,className:`rounded-sm border border-border bg-card px-1.5 py-px font-mono text-[11px] font-medium`,children:e.branch},`branch`));let n=ge(e);if(n&&v(n)){let r=E(n);t.push((0,Y.jsx)(I,{reference:{kind:`PR`,...r?{number:Number(r)}:{},url:n},taskTitle:O(e),className:`h-5`},`pr`))}let r=se(e);if(r&&v(r)){let n=E(r);t.push((0,Y.jsx)(I,{reference:{kind:`Issue`,...n?{number:Number(n)}:{},url:r},taskTitle:O(e),className:`h-5`},`issue`))}e.diffStat&&t.push((0,Y.jsx)(Te,{stat:e.diffStat},`diff`));let i=[];return e.tokensUsed>0&&i.push((0,Y.jsxs)(`span`,{className:`tabular-nums`,children:[fe(e.tokensUsed),` tokens`]},`tokens`)),e.costUsd&&i.push((0,Y.jsx)(`span`,{className:`tabular-nums`,children:pe(e.costUsd)},`cost`)),(0,Y.jsxs)(`div`,{"data-slot":`run-meta`,className:`mt-1.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground`,children:[t.map((e,t)=>(0,Y.jsxs)(W.Fragment,{children:[t>0?(0,Y.jsx)(`span`,{className:`text-soft-foreground`,"aria-hidden":`true`,children:`·`}):null,e]},t)),(0,Y.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[i.map((e,t)=>(0,Y.jsxs)(W.Fragment,{children:[t>0?(0,Y.jsx)(`span`,{className:`text-soft-foreground`,"aria-hidden":`true`,children:`·`}):null,e]},t)),(0,Y.jsx)(st,{run:e})]})]})}function st({run:e}){let t=i(),n=e.runner??t.data?.defaultRunner??`claude`,r=e.model??`auto`;return(0,Y.jsxs)(P,{children:[(0,Y.jsx)(F,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,"data-slot":`agent-badge`,title:`${n} · ${r}`,"aria-label":`Agent: ${n}, model ${r}`,className:`flex shrink-0 items-center justify-center rounded-sm p-1 text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,Y.jsx)(R,{className:`size-3.5`,"aria-hidden":`true`})})}),(0,Y.jsxs)(z,{align:`end`,className:`min-w-[9rem]`,children:[(0,Y.jsxs)(A,{className:`font-mono text-[11px] font-normal text-muted-foreground`,children:[`runner: `,n]}),(0,Y.jsxs)(A,{className:`font-mono text-[11px] font-normal text-muted-foreground`,children:[`model: `,r]})]})]})}function ct({run:e,actions:t,onToggleNotes:n}){let r=q(e);return(0,Y.jsxs)(P,{children:[(0,Y.jsx)(F,{asChild:!0,children:(0,Y.jsx)(d,{variant:`ghost`,size:`icon-sm`,"aria-label":`Run actions`,className:`md:hidden`,children:(0,Y.jsx)(ae,{"aria-hidden":`true`})})}),(0,Y.jsxs)(z,{align:`end`,"data-slot":`run-actions-menu`,children:[r.finish?(0,Y.jsxs)(k,{onSelect:()=>t.finish.mutate(),children:[(0,Y.jsx)(m,{"aria-hidden":`true`}),` Finish`]}):null,r.continueRun?(0,Y.jsxs)(k,{onSelect:()=>t.continueRun.mutate(),children:[(0,Y.jsx)(D,{"aria-hidden":`true`}),` Continue`]}):null,r.terminal?(0,Y.jsxs)(k,{onSelect:()=>t.terminal.mutate(),children:[(0,Y.jsx)(T,{"aria-hidden":`true`}),` Terminal`]}):null,(0,Y.jsxs)(k,{onSelect:n,children:[(0,Y.jsx)(H,{"aria-hidden":`true`}),` Notes`]}),r.archive?(0,Y.jsxs)(k,{onSelect:()=>t.archive.mutate(),children:[e.archived?(0,Y.jsx)(B,{"aria-hidden":`true`}):(0,Y.jsx)(N,{"aria-hidden":`true`}),e.archived?`Unarchive`:`Archive`]}):null,r.cancel||r.deleteRun?(0,Y.jsx)(L,{}):null,r.cancel?(0,Y.jsxs)(k,{variant:`destructive`,onSelect:()=>t.setConfirming(`cancel`),children:[(0,Y.jsx)(V,{"aria-hidden":`true`}),` Cancel`]}):null,r.deleteRun?(0,Y.jsxs)(k,{variant:`destructive`,onSelect:()=>t.setConfirming(`delete`),children:[(0,Y.jsx)(S,{"aria-hidden":`true`}),` Delete`]}):null]})]})}function lt({run:e,actions:t}){let n=t.confirming;return(0,Y.jsx)(Oe,{open:n!==null,onOpenChange:e=>!e&&t.setConfirming(null),children:(0,Y.jsxs)(Ce,{children:[(0,Y.jsxs)(ve,{children:[(0,Y.jsx)(me,{children:n===`delete`?`Delete this task?`:`Cancel this task?`}),(0,Y.jsx)(be,{children:n===`delete`?(0,Y.jsxs)(Y.Fragment,{children:[`This removes the run, its transcript, its worktree and its branch. There is no undo.`,(0,Y.jsx)(`span`,{className:`mt-1 block truncate font-medium text-foreground`,title:O(e),children:O(e)})]}):`The agent is stopped and the run completes as cancelled. The worktree stays.`})]}),(0,Y.jsxs)(j,{children:[(0,Y.jsx)(_e,{children:`Keep it`}),(0,Y.jsx)(he,{className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{n===`delete`?t.delete.mutate():t.cancel.mutate(),t.setConfirming(null)},children:n===`delete`?`Delete`:`Cancel the run`})]})]})})}function ut({hint:e}){return(0,Y.jsxs)(`button`,{type:`button`,"data-slot":`resume-hint`,title:`Copy the command`,onClick:()=>void $(e,`Command copied to clipboard.`),className:`mb-2 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,Y.jsx)(x,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`truncate`,children:[`take over interactively: `,e]})]})}function dt({runId:e}){let t=re(e);return(0,Y.jsx)(`div`,{"data-slot":`notes-panel`,className:`mb-3 max-h-72 overflow-y-auto rounded-md border border-border bg-card px-4 py-3`,children:t.isPending?(0,Y.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`Loading notes…`}):t.isError?(0,Y.jsx)(`p`,{className:`text-xs text-danger`,children:t.error.message}):t.data.trim().length>0?(0,Y.jsx)(ke,{children:t.data}):(0,Y.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`No notes yet — the handoff file is seeded when the task starts.`})})}export{K as a,U as c,G as i,H as l,Z as n,Ze as o,J as r,q as s,tt as t};
@@ -1 +1 @@
1
- import{a as e,s as t,u as n}from"./bundle-mjs-BegPhL5c.js";import{A as r,V as i,Yt as a,dn as o,fn as s,gt as c,i as l,mn as u,mt as d,qt as f,t as p,ut as m,vt as h}from"./centered-state-CLmJ67EV.js";import{t as g}from"./utils-B8s5qIcK.js";import{t as _}from"./arrow-left-CnSdp92h.js";import{r as v,t as y}from"./skill-empty-hint-DTUSp6Vl.js";import{t as b}from"./refresh-cw-BT8E96Tm.js";import{t as x}from"./triangle-alert-Uy8rokUh.js";import{t as S}from"./project-router-BaWVyqc8.js";import{Gt as C,It as w,Ut as T,_t as E,b as D,gt as O,i as k,v as A,vt as j,wt as M}from"./index-CcfkF2Ey.js";var N=n(t(),1),P=e(),F=`https://github.com/open-mercato/skills`;function I(e){let t=e?.importedSkills;if(Array.isArray(t))return t.filter(e=>typeof e==`string`&&!!e)}function L(e,t){return I(e)??[...t]}function R(){let e=u(),t=c(),n=i(),[a,o]=(0,N.useState)(``),s=n.data??[],d=(0,N.useMemo)(()=>s.map(e=>e.name),[s]),m=(0,N.useRef)([]);m.current=d;let _=(0,N.useMemo)(()=>new Set(L(t.data,d)),[t.data,d]),v=(0,N.useRef)(Promise.resolve()),y=(0,N.useRef)(0),b=(0,N.useCallback)(t=>{let n=h.uiState,i=e.getQueryData(n),a=t(L(i,m.current));e.setQueryData(n,{...i,importedSkills:a});let o=++y.current;v.current=v.current.then(async()=>{try{let t=await f({importedSkills:a});o===y.current&&(e.setQueryData(n,t),e.invalidateQueries({queryKey:r.skills}))}catch(t){l(t instanceof Error?t.message:String(t),{tone:`danger`}),o===y.current&&e.invalidateQueries({queryKey:n})}})},[e]),S=(0,N.useCallback)(e=>{b(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[b]),T=d.length>0&&d.every(e=>_.has(e)),E=(0,N.useCallback)(()=>{if(T){let e=new Set(m.current);b(t=>t.filter(t=>!e.has(t)))}else b(e=>[...new Set([...e,...m.current])])},[T,b]);if(n.isError)return(0,P.jsx)(p,{icon:(0,P.jsx)(x,{}),tone:`danger`,heading:`h2`,title:`Could not load importable skills`,subtitle:n.error.message});let D=a.trim().toLowerCase(),O=D?s.filter(e=>e.name.toLowerCase().includes(D)||(e.description??``).toLowerCase().includes(D)):s;return(0,P.jsxs)(`div`,{"data-slot":`skills-import-panel`,className:`mx-auto w-full max-w-2xl`,children:[(0,P.jsx)(`h2`,{className:`text-base font-semibold`,children:`Manage skills`}),(0,P.jsxs)(`p`,{className:`mt-2 text-[13px] leading-relaxed text-muted-foreground`,children:[`Reusable, technology-agnostic agent skills from`,` `,(0,P.jsx)(`a`,{href:F,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2 hover:text-foreground`,children:`open-mercato/skills`}),` `,`— PR creation, code review, CI stabilisation, spec writing and more. They're all in your catalog and the composer picker by default; uncheck any you don't want.`]}),(0,P.jsxs)(`div`,{className:`mt-4 flex items-center gap-2`,children:[(0,P.jsx)(w,{"data-slot":`import-filter`,placeholder:`Filter skills…`,"aria-label":`Filter skills`,value:a,onChange:e=>o(e.target.value),className:`h-8 text-[13px]`}),(0,P.jsx)(`button`,{type:`button`,"data-slot":`import-all`,disabled:d.length===0||t.isPending,onClick:E,className:`h-8 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:T?`Remove all`:`Enable all`})]}),(0,P.jsx)(`div`,{"data-slot":`import-list`,className:`mt-3 flex flex-col gap-1.5`,children:n.isPending?(0,P.jsx)(`p`,{className:`px-1 py-2 text-[13px] text-soft-foreground`,children:`Loading…`}):O.length>0?O.map(e=>{let t=_.has(e.name);return(0,P.jsxs)(`label`,{"data-slot":`import-row`,"data-skill":e.name,"data-imported":t?`true`:void 0,className:g(`flex cursor-pointer items-start gap-2.5 rounded-md border border-border px-2.5 py-2 transition-colors hover:bg-muted`,t&&`bg-muted`),children:[(0,P.jsx)(`input`,{type:`checkbox`,"data-slot":`import-toggle`,checked:t,onChange:()=>S(e.name),className:`mt-0.5 size-3.5 shrink-0`}),(0,P.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,P.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,P.jsx)(C,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-soft-foreground`}),(0,P.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[13px] font-medium text-foreground`,children:e.name})]}),e.description?(0,P.jsx)(`span`,{className:`mt-0.5 block pl-[22px] text-xs text-soft-foreground`,children:e.description}):null]})]},e.name)}):(0,P.jsx)(`p`,{className:`px-1 py-2 text-xs text-soft-foreground`,children:s.length>0?`(no skills match)`:`(no skills available — the repo may still be cloning)`})})]})}var z=`__bm`,B=`__import`;function V(){return(0,P.jsxs)(`div`,{"data-route":`skills`,className:`flex min-h-full flex-col`,children:[(0,P.jsxs)(`header`,{className:`sticky top-0 z-10 hidden h-14 shrink-0 items-center gap-3 border-b border-border bg-background px-5 md:flex`,children:[(0,P.jsx)(`h1`,{className:`text-base font-semibold`,children:`Skills`}),(0,P.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Markdown playbooks agents can follow.`})]}),(0,P.jsx)(H,{})]})}function H(){let e=m(),t=d(),n=i(),[c]=o(),[f,h]=(0,N.useState)(``),E=u(),D=s({mutationFn:()=>a(),onSuccess:e=>{E.setQueryData(r.skills,e),l(`Team skills refreshed.`)},onError:e=>l(e.message,{tone:`danger`})});if(e.isError)return(0,P.jsx)(p,{icon:(0,P.jsx)(x,{}),tone:`danger`,heading:`h2`,title:`Could not load skills`,subtitle:e.error.message});let F=j(e.data??[]),I=(n.data?.length??0)>0,L=c.get(`skill`),V=L===z||L===B||L!==null&&F.some(e=>e.name===L)?L:F[0]?.name??(I?B:z),H=F.find(e=>e.name===V)??null,W=O(F,f);return(0,P.jsxs)(`div`,{"data-slot":`skills-section`,className:`flex min-h-full flex-1 items-stretch`,children:[(0,P.jsxs)(`section`,{"data-slot":`skills-list`,className:g(`w-full flex-col border-border md:flex md:w-[320px] md:shrink-0 md:border-r`,`md:sticky md:top-14 md:max-h-[calc(100dvh-(var(--spacing)*14))]`,L===null?`flex`:`hidden md:flex`),children:[(0,P.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 p-3 pb-2`,children:[(0,P.jsx)(w,{"data-slot":`skills-filter`,placeholder:`Filter skills…`,"aria-label":`Filter skills`,value:f,onChange:e=>h(e.target.value),className:`h-8 text-[13px]`}),(0,P.jsxs)(`button`,{type:`button`,"data-slot":`skills-refresh`,title:`git fetch the team skills repos`,disabled:D.isPending,onClick:()=>D.mutate(),className:`flex h-8 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,P.jsx)(b,{"aria-hidden":`true`,className:g(`size-3`,D.isPending&&`motion-safe:animate-spin`)}),`Refresh`]})]}),(0,P.jsx)(`ul`,{"data-slot":`skill-rows`,className:`min-h-0 flex-1 overflow-y-auto px-2 pb-2`,children:e.isPending?(0,P.jsx)(`li`,{className:`px-2.5 py-2 text-[13px] text-soft-foreground`,children:`Loading…`}):W.length>0?W.map(e=>(0,P.jsx)(U,{skill:e,active:V===e.name},e.path)):(0,P.jsx)(`li`,{className:`px-2.5 py-2 text-xs leading-relaxed text-soft-foreground`,children:F.length>0?`(no skills match)`:(0,P.jsx)(y,{})})}),(0,P.jsxs)(`div`,{className:`shrink-0 border-t border-border p-2`,children:[I?(0,P.jsxs)(S,{to:`/skills?skill=${B}`,"data-slot":`import-skills-row`,"aria-current":V===B?`page`:void 0,className:g(`mb-1 flex flex-col gap-0.5 rounded-md px-2.5 py-2 transition-colors hover:bg-muted`,V===B&&`bg-muted`),children:[(0,P.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,P.jsx)(v,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}),(0,P.jsx)(`span`,{className:`min-w-0 truncate text-[13px] font-medium`,children:`Manage skills`}),(0,P.jsx)(`span`,{className:`ml-auto shrink-0 rounded-full border border-border px-2 py-px font-mono text-[10.5px] text-soft-foreground`,children:`open-mercato`})]}),(0,P.jsx)(`span`,{className:`pl-[22px] text-xs text-soft-foreground`,children:`Choose which open-mercato skills appear in your catalog.`})]}):null,(0,P.jsxs)(S,{to:`/skills?skill=${z}`,"data-slot":`bookmarklets-row`,"aria-current":V===z?`page`:void 0,className:g(`flex flex-col gap-0.5 rounded-md px-2.5 py-2 transition-colors hover:bg-muted`,V===z&&`bg-muted`),children:[(0,P.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,P.jsx)(T,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}),(0,P.jsx)(`span`,{className:`min-w-0 truncate text-[13px] font-medium`,children:`Run from GitHub`}),(0,P.jsx)(`span`,{className:`ml-auto shrink-0 rounded-full border border-border px-2 py-px font-mono text-[10.5px] text-soft-foreground`,children:`bookmarklets`})]}),(0,P.jsx)(`span`,{className:`pl-[22px] text-xs text-soft-foreground`,children:`One-click skill launch from any GitHub PR or issue.`})]})]})]}),(0,P.jsx)(`section`,{"data-slot":`skills-detail`,className:g(`min-w-0 flex-1 flex-col`,L===null?`hidden md:flex`:`flex`),children:(0,P.jsxs)(`div`,{className:`min-w-0 flex-1 px-4 py-4 md:px-7 md:py-5`,children:[(0,P.jsxs)(S,{to:`/skills`,"data-slot":`skills-back`,className:`mb-3 inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground md:hidden`,children:[(0,P.jsx)(_,{"aria-hidden":`true`,className:`size-3.5`}),`Back to the list`]}),V===B?(0,P.jsx)(R,{}):V===z?(0,P.jsx)(k,{skills:F}):H?(0,P.jsx)(A,{skill:H,usedBy:M(t.data?.workflows??[],H.name)}):e.isPending?null:(0,P.jsx)(p,{icon:(0,P.jsx)(C,{}),tone:`neutral`,heading:`h2`,title:`No skill selected`,subtitle:`Pick a skill from the catalog.`})]})})]})}function U({skill:e,active:t}){let n=E(e);return(0,P.jsx)(`li`,{children:(0,P.jsxs)(S,{to:`/skills?skill=${encodeURIComponent(e.name)}`,"data-slot":`skill-row`,"data-skill":e.name,"data-project":n?`true`:void 0,"aria-current":t?`page`:void 0,className:g(`flex flex-col gap-0.5 rounded-md px-2.5 py-2 transition-colors hover:bg-muted`,t&&`bg-muted`),children:[(0,P.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,P.jsx)(C,{"aria-hidden":`true`,className:g(`size-3.5 shrink-0`,n?`text-violet`:`text-soft-foreground`)}),(0,P.jsx)(`span`,{className:g(`min-w-0 truncate font-mono text-[13px]`,n?`font-semibold text-foreground`:`font-medium text-muted-foreground`),children:e.name}),(0,P.jsx)(D,{source:e.source,className:`ml-auto`})]}),e.description?(0,P.jsx)(`span`,{className:`line-clamp-2 pl-[22px] text-xs text-soft-foreground`,children:e.description}):null]})})}export{V as SkillsRoute};
1
+ import{a as e,s as t,u as n}from"./bundle-mjs-BegPhL5c.js";import{A as r,V as i,Yt as a,dn as o,fn as s,gt as c,i as l,mn as u,mt as d,qt as f,t as p,ut as m,vt as h}from"./centered-state-CLmJ67EV.js";import{t as g}from"./utils-B8s5qIcK.js";import{t as _}from"./arrow-left-CnSdp92h.js";import{r as v,t as y}from"./skill-empty-hint-DTUSp6Vl.js";import{t as b}from"./refresh-cw-BT8E96Tm.js";import{t as x}from"./triangle-alert-Uy8rokUh.js";import{t as S}from"./project-router-BaWVyqc8.js";import{Dt as C,Jt as w,Kt as T,b as E,bt as D,i as O,v as k,xt as A,yt as j,zt as M}from"./index-MN3Lxn3t.js";var N=n(t(),1),P=e(),F=`https://github.com/open-mercato/skills`;function I(e){let t=e?.importedSkills;if(Array.isArray(t))return t.filter(e=>typeof e==`string`&&!!e)}function L(e,t){return I(e)??[...t]}function R(){let e=u(),t=c(),n=i(),[a,o]=(0,N.useState)(``),s=n.data??[],d=(0,N.useMemo)(()=>s.map(e=>e.name),[s]),m=(0,N.useRef)([]);m.current=d;let _=(0,N.useMemo)(()=>new Set(L(t.data,d)),[t.data,d]),v=(0,N.useRef)(Promise.resolve()),y=(0,N.useRef)(0),b=(0,N.useCallback)(t=>{let n=h.uiState,i=e.getQueryData(n),a=t(L(i,m.current));e.setQueryData(n,{...i,importedSkills:a});let o=++y.current;v.current=v.current.then(async()=>{try{let t=await f({importedSkills:a});o===y.current&&(e.setQueryData(n,t),e.invalidateQueries({queryKey:r.skills}))}catch(t){l(t instanceof Error?t.message:String(t),{tone:`danger`}),o===y.current&&e.invalidateQueries({queryKey:n})}})},[e]),S=(0,N.useCallback)(e=>{b(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[b]),C=d.length>0&&d.every(e=>_.has(e)),T=(0,N.useCallback)(()=>{if(C){let e=new Set(m.current);b(t=>t.filter(t=>!e.has(t)))}else b(e=>[...new Set([...e,...m.current])])},[C,b]);if(n.isError)return(0,P.jsx)(p,{icon:(0,P.jsx)(x,{}),tone:`danger`,heading:`h2`,title:`Could not load importable skills`,subtitle:n.error.message});let E=a.trim().toLowerCase(),D=E?s.filter(e=>e.name.toLowerCase().includes(E)||(e.description??``).toLowerCase().includes(E)):s;return(0,P.jsxs)(`div`,{"data-slot":`skills-import-panel`,className:`mx-auto w-full max-w-2xl`,children:[(0,P.jsx)(`h2`,{className:`text-base font-semibold`,children:`Manage skills`}),(0,P.jsxs)(`p`,{className:`mt-2 text-[13px] leading-relaxed text-muted-foreground`,children:[`Reusable, technology-agnostic agent skills from`,` `,(0,P.jsx)(`a`,{href:F,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2 hover:text-foreground`,children:`open-mercato/skills`}),` `,`— PR creation, code review, CI stabilisation, spec writing and more. They're all in your catalog and the composer picker by default; uncheck any you don't want.`]}),(0,P.jsxs)(`div`,{className:`mt-4 flex items-center gap-2`,children:[(0,P.jsx)(M,{"data-slot":`import-filter`,placeholder:`Filter skills…`,"aria-label":`Filter skills`,value:a,onChange:e=>o(e.target.value),className:`h-8 text-[13px]`}),(0,P.jsx)(`button`,{type:`button`,"data-slot":`import-all`,disabled:d.length===0||t.isPending,onClick:T,className:`h-8 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:C?`Remove all`:`Enable all`})]}),(0,P.jsx)(`div`,{"data-slot":`import-list`,className:`mt-3 flex flex-col gap-1.5`,children:n.isPending?(0,P.jsx)(`p`,{className:`px-1 py-2 text-[13px] text-soft-foreground`,children:`Loading…`}):D.length>0?D.map(e=>{let t=_.has(e.name);return(0,P.jsxs)(`label`,{"data-slot":`import-row`,"data-skill":e.name,"data-imported":t?`true`:void 0,className:g(`flex cursor-pointer items-start gap-2.5 rounded-md border border-border px-2.5 py-2 transition-colors hover:bg-muted`,t&&`bg-muted`),children:[(0,P.jsx)(`input`,{type:`checkbox`,"data-slot":`import-toggle`,checked:t,onChange:()=>S(e.name),className:`mt-0.5 size-3.5 shrink-0`}),(0,P.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,P.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,P.jsx)(w,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-soft-foreground`}),(0,P.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[13px] font-medium text-foreground`,children:e.name})]}),e.description?(0,P.jsx)(`span`,{className:`mt-0.5 block pl-[22px] text-xs text-soft-foreground`,children:e.description}):null]})]},e.name)}):(0,P.jsx)(`p`,{className:`px-1 py-2 text-xs text-soft-foreground`,children:s.length>0?`(no skills match)`:`(no skills available — the repo may still be cloning)`})})]})}var z=`__bm`,B=`__import`;function V(){return(0,P.jsxs)(`div`,{"data-route":`skills`,className:`flex min-h-full flex-col`,children:[(0,P.jsxs)(`header`,{className:`sticky top-0 z-10 hidden h-14 shrink-0 items-center gap-3 border-b border-border bg-background px-5 md:flex`,children:[(0,P.jsx)(`h1`,{className:`text-base font-semibold`,children:`Skills`}),(0,P.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Markdown playbooks agents can follow.`})]}),(0,P.jsx)(H,{})]})}function H(){let e=m(),t=d(),n=i(),[c]=o(),[f,h]=(0,N.useState)(``),E=u(),D=s({mutationFn:()=>a(),onSuccess:e=>{E.setQueryData(r.skills,e),l(`Team skills refreshed.`)},onError:e=>l(e.message,{tone:`danger`})});if(e.isError)return(0,P.jsx)(p,{icon:(0,P.jsx)(x,{}),tone:`danger`,heading:`h2`,title:`Could not load skills`,subtitle:e.error.message});let F=A(e.data??[]),I=(n.data?.length??0)>0,L=c.get(`skill`),V=L===z||L===B||L!==null&&F.some(e=>e.name===L)?L:F[0]?.name??(I?B:z),H=F.find(e=>e.name===V)??null,W=j(F,f);return(0,P.jsxs)(`div`,{"data-slot":`skills-section`,className:`flex min-h-full flex-1 items-stretch`,children:[(0,P.jsxs)(`section`,{"data-slot":`skills-list`,className:g(`w-full flex-col border-border md:flex md:w-[320px] md:shrink-0 md:border-r`,`md:sticky md:top-14 md:max-h-[calc(100dvh-(var(--spacing)*14))]`,L===null?`flex`:`hidden md:flex`),children:[(0,P.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 p-3 pb-2`,children:[(0,P.jsx)(M,{"data-slot":`skills-filter`,placeholder:`Filter skills…`,"aria-label":`Filter skills`,value:f,onChange:e=>h(e.target.value),className:`h-8 text-[13px]`}),(0,P.jsxs)(`button`,{type:`button`,"data-slot":`skills-refresh`,title:`git fetch the team skills repos`,disabled:D.isPending,onClick:()=>D.mutate(),className:`flex h-8 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,P.jsx)(b,{"aria-hidden":`true`,className:g(`size-3`,D.isPending&&`motion-safe:animate-spin`)}),`Refresh`]})]}),(0,P.jsx)(`ul`,{"data-slot":`skill-rows`,className:`min-h-0 flex-1 overflow-y-auto px-2 pb-2`,children:e.isPending?(0,P.jsx)(`li`,{className:`px-2.5 py-2 text-[13px] text-soft-foreground`,children:`Loading…`}):W.length>0?W.map(e=>(0,P.jsx)(U,{skill:e,active:V===e.name},e.path)):(0,P.jsx)(`li`,{className:`px-2.5 py-2 text-xs leading-relaxed text-soft-foreground`,children:F.length>0?`(no skills match)`:(0,P.jsx)(y,{})})}),(0,P.jsxs)(`div`,{className:`shrink-0 border-t border-border p-2`,children:[I?(0,P.jsxs)(S,{to:`/skills?skill=${B}`,"data-slot":`import-skills-row`,"aria-current":V===B?`page`:void 0,className:g(`mb-1 flex flex-col gap-0.5 rounded-md px-2.5 py-2 transition-colors hover:bg-muted`,V===B&&`bg-muted`),children:[(0,P.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,P.jsx)(v,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}),(0,P.jsx)(`span`,{className:`min-w-0 truncate text-[13px] font-medium`,children:`Manage skills`}),(0,P.jsx)(`span`,{className:`ml-auto shrink-0 rounded-full border border-border px-2 py-px font-mono text-[10.5px] text-soft-foreground`,children:`open-mercato`})]}),(0,P.jsx)(`span`,{className:`pl-[22px] text-xs text-soft-foreground`,children:`Choose which open-mercato skills appear in your catalog.`})]}):null,(0,P.jsxs)(S,{to:`/skills?skill=${z}`,"data-slot":`bookmarklets-row`,"aria-current":V===z?`page`:void 0,className:g(`flex flex-col gap-0.5 rounded-md px-2.5 py-2 transition-colors hover:bg-muted`,V===z&&`bg-muted`),children:[(0,P.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,P.jsx)(T,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}),(0,P.jsx)(`span`,{className:`min-w-0 truncate text-[13px] font-medium`,children:`Run from GitHub`}),(0,P.jsx)(`span`,{className:`ml-auto shrink-0 rounded-full border border-border px-2 py-px font-mono text-[10.5px] text-soft-foreground`,children:`bookmarklets`})]}),(0,P.jsx)(`span`,{className:`pl-[22px] text-xs text-soft-foreground`,children:`One-click skill launch from any GitHub PR or issue.`})]})]})]}),(0,P.jsx)(`section`,{"data-slot":`skills-detail`,className:g(`min-w-0 flex-1 flex-col`,L===null?`hidden md:flex`:`flex`),children:(0,P.jsxs)(`div`,{className:`min-w-0 flex-1 px-4 py-4 md:px-7 md:py-5`,children:[(0,P.jsxs)(S,{to:`/skills`,"data-slot":`skills-back`,className:`mb-3 inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground md:hidden`,children:[(0,P.jsx)(_,{"aria-hidden":`true`,className:`size-3.5`}),`Back to the list`]}),V===B?(0,P.jsx)(R,{}):V===z?(0,P.jsx)(O,{skills:F}):H?(0,P.jsx)(k,{skill:H,usedBy:C(t.data?.workflows??[],H.name)}):e.isPending?null:(0,P.jsx)(p,{icon:(0,P.jsx)(w,{}),tone:`neutral`,heading:`h2`,title:`No skill selected`,subtitle:`Pick a skill from the catalog.`})]})})]})}function U({skill:e,active:t}){let n=D(e);return(0,P.jsx)(`li`,{children:(0,P.jsxs)(S,{to:`/skills?skill=${encodeURIComponent(e.name)}`,"data-slot":`skill-row`,"data-skill":e.name,"data-project":n?`true`:void 0,"aria-current":t?`page`:void 0,className:g(`flex flex-col gap-0.5 rounded-md px-2.5 py-2 transition-colors hover:bg-muted`,t&&`bg-muted`),children:[(0,P.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,P.jsx)(w,{"aria-hidden":`true`,className:g(`size-3.5 shrink-0`,n?`text-violet`:`text-soft-foreground`)}),(0,P.jsx)(`span`,{className:g(`min-w-0 truncate font-mono text-[13px]`,n?`font-semibold text-foreground`:`font-medium text-muted-foreground`),children:e.name}),(0,P.jsx)(E,{source:e.source,className:`ml-auto`})]}),e.description?(0,P.jsx)(`span`,{className:`line-clamp-2 pl-[22px] text-xs text-soft-foreground`,children:e.description}):null]})})}export{V as SkillsRoute};
@@ -1 +1 @@
1
- import{a as e,s as t,u as n}from"./bundle-mjs-BegPhL5c.js";import{A as r,B as i,Ct as a,Dt as o,Ft as s,It as c,Qt as l,Rt as u,Ut as d,a as f,et as p,fn as m,i as h,mn as g,t as _,tt as v,un as y,yt as b}from"./centered-state-CLmJ67EV.js";import{a as x,i as S,t as C}from"./run-header-B3kW2sWC.js";import{a as w,i as T,n as E,r as D}from"./git-toolbar-CDII-3Uv.js";import{a as O,n as k,t as A}from"./use-desktop-4e8LLqMG.js";import{t as j}from"./textarea-Bj_LCreg.js";import{Bt as M,E as N,Ht as P,Lt as F,Rt as I,Vt as L,mt as R,o as z,s as B,zt as V}from"./index-CcfkF2Ey.js";var H=n(t(),1),U=e=>e===`running`||e===`queued`||e===`waiting`,W=`no worktree — this task ran directly in the repo working tree`;function G(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 — ${W}`)}function K(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 — ${W}`)}function q(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 — ${W}`):e.forge===null?t(`Create PR unavailable — no supported forge remote (GitHub) detected`):e.forge.available?U(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 J(e){let t=e.prUrl?{id:`view-pr`,label:`View PR`,enabled:!0,href:e.prUrl}:G(e),n=e.prUrl?[G(e),K(e)]:[K(e),q(e)],r=[];if(e.localHandoff){let t=e.hasSession?U(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 Y=e();function X({run:e,open:t,onOpenChange:n}){let i=g(),[o,s]=(0,H.useState)(``),c=R(e),l=(0,H.useRef)(c);l.current=c,(0,H.useEffect)(()=>{t&&s(l.current)},[t]);let u=m({mutationFn:t=>a(e.id,t),onSuccess:t=>{h(`Committed ${t.sha.slice(0,7)}`),n(!1),i.invalidateQueries({queryKey:r.runs.changes(e.id)}),i.invalidateQueries({queryKey:r.runs.all})},onError:e=>h(e.message,{tone:`danger`})}),d=()=>{let e=o.trim();e.length===0||u.isPending||u.mutate(e)};return(0,Y.jsx)(F,{open:t,onOpenChange:n,children:(0,Y.jsxs)(I,{"data-slot":`commit-dialog`,children:[(0,Y.jsxs)(L,{children:[(0,Y.jsx)(P,{children:`Commit changes`}),(0,Y.jsxs)(V,{children:[`Stages everything in the task's worktree (git add -A) and commits to`,` `,e.branch?(0,Y.jsx)(`span`,{className:`font-mono`,children:e.branch}):`its branch`,`.`]})]}),(0,Y.jsx)(j,{"data-slot":`commit-message`,"aria-label":`Commit message`,rows:3,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{N({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(),d())}}),(0,Y.jsxs)(M,{children:[(0,Y.jsx)(f,{variant:`outline`,onClick:()=>n(!1),children:`Cancel`}),(0,Y.jsx)(f,{"data-slot":`commit-confirm`,disabled:o.trim().length===0||u.isPending,onClick:d,children:u.isPending?`Committing…`:`Commit`})]})]})})}function Z(){let{id:e}=y(),t=p(e);return t.isPending?(0,Y.jsx)(B,{tab:`changes`}):t.isError?(0,Y.jsx)(z,{tab:`changes`,error:t.error}):(0,Y.jsx)(Q,{run:t.data})}function Q({run:e}){let t=i(),n=v(e.id,S(e.status)),a=A(),[s,f]=(0,H.useState)(`unified`),[p,y]=(0,H.useState)(!1),[j,M]=(0,H.useState)(null),[N,P]=(0,H.useState)(!1),F=(0,H.useRef)(null),I=g(),L=()=>I.invalidateQueries({queryKey:r.runs.all}),R=e=>h(e.message,{tone:`danger`}),z=m({mutationFn:()=>d(e.id),onSuccess:e=>h(e.upstreamSet?`Pushed ${e.branch} to ${e.remote} (upstream set)`:`Pushed ${e.branch} to ${e.remote}`),onError:R}),B=m({mutationFn:()=>o(e.id),onSuccess:e=>{h(`Draft PR created — ${e.url}`),L()},onError:R}),V=m({mutationFn:()=>u(e.id),onError:e=>{if(e instanceof b&&e.command){navigator.clipboard.writeText(e.command).then(()=>h(`No terminal found — command copied to clipboard.`)).catch(()=>h(`Run manually: ${e.command}`));return}R(e)}}),U=m({mutationFn:t=>c(e.id,t),onError:R}),W=n.isError&&n.error instanceof b&&n.error.status===409,G=J({status:e.status,hasWorktree:!!e.worktreePath&&!W,branch:e.branch,changedFiles:n.data?.stat.files,remote:t.data?.repo?.remote,forge:t.data?.forge??null,localHandoff:t.data?.capabilities.localHandoff??!1,hasSession:x(e)!==void 0,prUrl:e.pullRequestUrl}),K=e=>{switch(e){case`commit`:P(!0);break;case`push`:z.mutate();break;case`create-pr`:B.mutate();break;case`open-terminal`:V.mutate();break;case`view-pr`:break}},q=n.data?.files??[],Z=(0,H.useMemo)(()=>D(q),[q]),Q=a?s:`unified`,$=!a||p;return(0,Y.jsxs)(`div`,{"data-route":`task-changes`,className:`flex min-h-full flex-col`,children:[(0,Y.jsx)(C,{run:e,tab:`changes`}),(0,Y.jsx)(E,{bar:G,branch:e.branch,stat:n.data?.stat,mode:Q,wrap:$,onModeChange:f,onWrapChange:y,onAction:K}),n.data?.repointedHead?(0,Y.jsxs)(`p`,{"data-slot":`repointed-head-note`,className:`border-b px-4 py-2 text-xs text-soft-foreground md:px-6`,children:[`HEAD is on `,(0,Y.jsx)(`code`,{children:n.data.repointedHead.headBranch}),`, not this task's branch`,` `,(0,Y.jsx)(`code`,{children:n.data.repointedHead.taskBranch}),` — showing uncommitted changes only.`]}):null,n.isPending?(0,Y.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading changes…`}):n.isError?(0,Y.jsx)(_,{icon:W?(0,Y.jsx)(w,{}):(0,Y.jsx)(O,{}),tone:W?`neutral`:`danger`,heading:`h2`,title:W?`No changes to show`:`Could not load the changes`,subtitle:n.error.message}):q.length===0?(0,Y.jsx)(_,{icon:(0,Y.jsx)(w,{}),tone:`neutral`,heading:`h2`,title:`No changes yet`,subtitle:`The worktree matches its base branch. Changes appear here as the agent works.`}):(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-5 px-4 py-4 [--diff-sticky-top:10rem] md:px-6`,children:[(0,Y.jsx)(`aside`,{className:`sticky top-40 hidden w-60 shrink-0 md:block lg:w-72`,children:(0,Y.jsx)(T,{root:Z,selected:j,onSelect:e=>{M(e),F.current?.scrollToPath(e)}})}),(0,Y.jsx)(k,{files:q,viewRef:F,mode:Q,wrap:$,loadFileText:t=>ee(e.id,t),imageSrc:t=>l(e.id,t),onOpenInApp:t.data?.capabilities.localHandoff?e=>U.mutate(e):void 0,className:`min-w-0 flex-1`})]}),(0,Y.jsx)(X,{run:e,open:N,onOpenChange:P})]})}async function ee(e,t){try{let n=await s(e,t);return n.type!==`file`||n.binary||n.tooLarge?null:n.content??null}catch{return null}}export{Z as TaskChangesRoute};
1
+ import{a as e,s as t,u as n}from"./bundle-mjs-BegPhL5c.js";import{A as r,B as i,Ct as a,Dt as o,Ft as s,It as c,Qt as l,Rt as u,Ut as d,a as f,et as p,fn as m,i as h,mn as g,t as _,tt as v,un as y,yt as b}from"./centered-state-CLmJ67EV.js";import{a as x,i as S,t as C}from"./run-header-fLV2ZvNw.js";import{a as w,i as T,n as E,r as D}from"./git-toolbar-A1hGl9ke.js";import{a as O,n as k,t as A}from"./use-desktop-DDySz-Hn.js";import{t as j}from"./textarea-Bj_LCreg.js";import{Bt as M,E as N,Gt as P,Ht as F,Ut as I,Vt as L,Wt as R,_t as z,o as B,s as V}from"./index-MN3Lxn3t.js";var H=n(t(),1),U=e=>e===`running`||e===`queued`||e===`waiting`,W=`no worktree — this task ran directly in the repo working tree`;function G(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 — ${W}`)}function K(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 — ${W}`)}function q(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 — ${W}`):e.forge===null?t(`Create PR unavailable — no supported forge remote (GitHub) detected`):e.forge.available?U(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 J(e){let t=e.prUrl?{id:`view-pr`,label:`View PR`,enabled:!0,href:e.prUrl}:G(e),n=e.prUrl?[G(e),K(e)]:[K(e),q(e)],r=[];if(e.localHandoff){let t=e.hasSession?U(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 Y=e();function X({run:e,open:t,onOpenChange:n}){let i=g(),[o,s]=(0,H.useState)(``),c=z(e),l=(0,H.useRef)(c);l.current=c,(0,H.useEffect)(()=>{t&&s(l.current)},[t]);let u=m({mutationFn:t=>a(e.id,t),onSuccess:t=>{h(`Committed ${t.sha.slice(0,7)}`),n(!1),i.invalidateQueries({queryKey:r.runs.changes(e.id)}),i.invalidateQueries({queryKey:r.runs.all})},onError:e=>h(e.message,{tone:`danger`})}),d=()=>{let e=o.trim();e.length===0||u.isPending||u.mutate(e)};return(0,Y.jsx)(M,{open:t,onOpenChange:n,children:(0,Y.jsxs)(L,{"data-slot":`commit-dialog`,children:[(0,Y.jsxs)(R,{children:[(0,Y.jsx)(P,{children:`Commit changes`}),(0,Y.jsxs)(F,{children:[`Stages everything in the task's worktree (git add -A) and commits to`,` `,e.branch?(0,Y.jsx)(`span`,{className:`font-mono`,children:e.branch}):`its branch`,`.`]})]}),(0,Y.jsx)(j,{"data-slot":`commit-message`,"aria-label":`Commit message`,rows:3,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{N({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(),d())}}),(0,Y.jsxs)(I,{children:[(0,Y.jsx)(f,{variant:`outline`,onClick:()=>n(!1),children:`Cancel`}),(0,Y.jsx)(f,{"data-slot":`commit-confirm`,disabled:o.trim().length===0||u.isPending,onClick:d,children:u.isPending?`Committing…`:`Commit`})]})]})})}function Z(){let{id:e}=y(),t=p(e);return t.isPending?(0,Y.jsx)(V,{tab:`changes`}):t.isError?(0,Y.jsx)(B,{tab:`changes`,error:t.error}):(0,Y.jsx)(Q,{run:t.data})}function Q({run:e}){let t=i(),n=v(e.id,S(e.status)),a=A(),[s,f]=(0,H.useState)(`unified`),[p,y]=(0,H.useState)(!1),[j,M]=(0,H.useState)(null),[N,P]=(0,H.useState)(!1),F=(0,H.useRef)(null),I=g(),L=()=>I.invalidateQueries({queryKey:r.runs.all}),R=e=>h(e.message,{tone:`danger`}),z=m({mutationFn:()=>d(e.id),onSuccess:e=>h(e.upstreamSet?`Pushed ${e.branch} to ${e.remote} (upstream set)`:`Pushed ${e.branch} to ${e.remote}`),onError:R}),B=m({mutationFn:()=>o(e.id),onSuccess:e=>{h(`Draft PR created — ${e.url}`),L()},onError:R}),V=m({mutationFn:()=>u(e.id),onError:e=>{if(e instanceof b&&e.command){navigator.clipboard.writeText(e.command).then(()=>h(`No terminal found — command copied to clipboard.`)).catch(()=>h(`Run manually: ${e.command}`));return}R(e)}}),U=m({mutationFn:t=>c(e.id,t),onError:R}),W=n.isError&&n.error instanceof b&&n.error.status===409,G=J({status:e.status,hasWorktree:!!e.worktreePath&&!W,branch:e.branch,changedFiles:n.data?.stat.files,remote:t.data?.repo?.remote,forge:t.data?.forge??null,localHandoff:t.data?.capabilities.localHandoff??!1,hasSession:x(e)!==void 0,prUrl:e.pullRequestUrl}),K=e=>{switch(e){case`commit`:P(!0);break;case`push`:z.mutate();break;case`create-pr`:B.mutate();break;case`open-terminal`:V.mutate();break;case`view-pr`:break}},q=n.data?.files??[],Z=(0,H.useMemo)(()=>D(q),[q]),Q=a?s:`unified`,$=!a||p;return(0,Y.jsxs)(`div`,{"data-route":`task-changes`,className:`flex min-h-full flex-col`,children:[(0,Y.jsx)(C,{run:e,tab:`changes`}),(0,Y.jsx)(E,{bar:G,branch:e.branch,stat:n.data?.stat,mode:Q,wrap:$,onModeChange:f,onWrapChange:y,onAction:K}),n.data?.repointedHead?(0,Y.jsxs)(`p`,{"data-slot":`repointed-head-note`,className:`border-b px-4 py-2 text-xs text-soft-foreground md:px-6`,children:[`HEAD is on `,(0,Y.jsx)(`code`,{children:n.data.repointedHead.headBranch}),`, not this task's branch`,` `,(0,Y.jsx)(`code`,{children:n.data.repointedHead.taskBranch}),` — showing uncommitted changes only.`]}):null,n.isPending?(0,Y.jsx)(`p`,{"data-slot":`changes-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading changes…`}):n.isError?(0,Y.jsx)(_,{icon:W?(0,Y.jsx)(w,{}):(0,Y.jsx)(O,{}),tone:W?`neutral`:`danger`,heading:`h2`,title:W?`No changes to show`:`Could not load the changes`,subtitle:n.error.message}):q.length===0?(0,Y.jsx)(_,{icon:(0,Y.jsx)(w,{}),tone:`neutral`,heading:`h2`,title:`No changes yet`,subtitle:`The worktree matches its base branch. Changes appear here as the agent works.`}):(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-5 px-4 py-4 [--diff-sticky-top:10rem] md:px-6`,children:[(0,Y.jsx)(`aside`,{className:`sticky top-40 hidden w-60 shrink-0 md:block lg:w-72`,children:(0,Y.jsx)(T,{root:Z,selected:j,onSelect:e=>{M(e),F.current?.scrollToPath(e)}})}),(0,Y.jsx)(k,{files:q,viewRef:F,mode:Q,wrap:$,loadFileText:t=>ee(e.id,t),imageSrc:t=>l(e.id,t),onOpenInApp:t.data?.capabilities.localHandoff?e=>U.mutate(e):void 0,className:`min-w-0 flex-1`})]}),(0,Y.jsx)(X,{run:e,open:N,onOpenChange:P})]})}async function ee(e,t){try{let n=await s(e,t);return n.type!==`file`||n.binary||n.tooLarge?null:n.content??null}catch{return null}}export{Z as TaskChangesRoute};
@@ -1 +1 @@
1
- import{a as e,s as t,u as n}from"./bundle-mjs-BegPhL5c.js";import{a as r,et as i,nt as a,rt as o,t as s,un as c,yt as l}from"./centered-state-CLmJ67EV.js";import{i as u,t as d}from"./run-header-B3kW2sWC.js";import{t as f}from"./arrow-left-CnSdp92h.js";import{a as p,i as m,n as h,t as g}from"./use-desktop-4e8LLqMG.js";import{t as _}from"./search-x-BDjaMrzG.js";import{t as v}from"./triangle-alert-Uy8rokUh.js";import{t as y}from"./project-router-BaWVyqc8.js";import{et as b,o as x,s as S}from"./index-CcfkF2Ey.js";import{t as C}from"./commit-list-CSaWuw-x.js";var w=n(t(),1),T=e();function E(){let{id:e}=c(),t=i(e);return t.isPending?(0,T.jsx)(S,{tab:`changes`}):t.isError?(0,T.jsx)(x,{tab:`changes`,error:t.error}):(0,T.jsx)(D,{run:t.data})}function D({run:e}){let{sha:t}=c(),n=o(e.id,u(e.status));return(0,T.jsxs)(`div`,{"data-route":`task-commits`,className:`flex min-h-full flex-col`,children:[(0,T.jsx)(d,{run:e,tab:`commits`}),t?(0,T.jsx)(O,{runId:e.id,sha:t}):n.isPending?(0,T.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,T.jsx)(s,{icon:(0,T.jsx)(p,{}),tone:n.error instanceof l&&n.error.status===409?`neutral`:`danger`,heading:`h2`,title:n.error instanceof l&&n.error.status===409?`No commits to show`:`Could not load the commits`,subtitle:n.error.message}):n.data.commits.length===0?(0,T.jsx)(s,{icon:(0,T.jsx)(p,{}),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,T.jsx)(C,{slot:`task-commits`,className:`mx-auto w-full max-w-[820px]`,commits:n.data.commits.map(t=>({...t,shaLabel:t.sha.slice(0,8),href:`/tasks/${e.id}/commits/${t.sha}`}))})]})}function O({runId:e,sha:t}){let n=a(e,t),i=g(),[o,c]=(0,w.useState)(`unified`),[u,d]=(0,w.useState)(!1),x=n.isError&&n.error instanceof l&&n.error.status===409,S=i?o:`unified`,C=!i||u;return(0,T.jsxs)(`section`,{"data-slot":`task-commit`,"data-sha":t,className:`mx-auto flex min-h-0 w-full max-w-[820px] flex-1 flex-col`,children:[(0,T.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,T.jsx)(r,{asChild:!0,variant:`ghost`,size:`sm`,"data-slot":`commit-back`,children:(0,T.jsxs)(y,{to:`/tasks/${e}/commits`,children:[(0,T.jsx)(f,{"aria-hidden":`true`}),`All commits`]})}),n.data?(0,T.jsx)(b,{stat:n.data.stat}):null,(0,T.jsx)(`span`,{className:`ml-auto hidden items-center gap-1 md:flex`,children:(0,T.jsx)(m,{mode:o,wrap:u,onModeChange:c,onWrapChange:d})})]}),n.isPending?(0,T.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,T.jsx)(s,{icon:x?(0,T.jsx)(_,{}):(0,T.jsx)(v,{}),tone:x?`neutral`:`danger`,heading:`h2`,title:x?`Commit not found`:`Could not load the commit`,subtitle:n.error.message}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{"data-slot":`commit-meta`,className:`border-b border-border px-4 py-3 md:px-6`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold`,children:n.data.subject}),(0,T.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-soft-foreground`,children:[n.data.author,` · `,n.data.when,` ·`,` `,(0,T.jsx)(`span`,{className:`font-mono select-all`,children:n.data.sha})]})]}),n.data.files.length===0?(0,T.jsx)(s,{icon:(0,T.jsx)(p,{}),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,T.jsx)(`div`,{className:`px-4 py-4 [--diff-sticky-top:10rem] md:px-6`,children:(0,T.jsx)(h,{files:n.data.files,mode:S,wrap:C,className:`min-w-0`})})]})]})}export{E as TaskCommitsRoute};
1
+ import{a as e,s as t,u as n}from"./bundle-mjs-BegPhL5c.js";import{a as r,et as i,nt as a,rt as o,t as s,un as c,yt as l}from"./centered-state-CLmJ67EV.js";import{i as u,t as d}from"./run-header-fLV2ZvNw.js";import{t as f}from"./arrow-left-CnSdp92h.js";import{a as p,i as m,n as h,t as g}from"./use-desktop-DDySz-Hn.js";import{t as _}from"./search-x-BDjaMrzG.js";import{t as v}from"./triangle-alert-Uy8rokUh.js";import{t as y}from"./project-router-BaWVyqc8.js";import{o as b,rt as x,s as S}from"./index-MN3Lxn3t.js";import{t as C}from"./commit-list-CSaWuw-x.js";var w=n(t(),1),T=e();function E(){let{id:e}=c(),t=i(e);return t.isPending?(0,T.jsx)(S,{tab:`changes`}):t.isError?(0,T.jsx)(b,{tab:`changes`,error:t.error}):(0,T.jsx)(D,{run:t.data})}function D({run:e}){let{sha:t}=c(),n=o(e.id,u(e.status));return(0,T.jsxs)(`div`,{"data-route":`task-commits`,className:`flex min-h-full flex-col`,children:[(0,T.jsx)(d,{run:e,tab:`commits`}),t?(0,T.jsx)(O,{runId:e.id,sha:t}):n.isPending?(0,T.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,T.jsx)(s,{icon:(0,T.jsx)(p,{}),tone:n.error instanceof l&&n.error.status===409?`neutral`:`danger`,heading:`h2`,title:n.error instanceof l&&n.error.status===409?`No commits to show`:`Could not load the commits`,subtitle:n.error.message}):n.data.commits.length===0?(0,T.jsx)(s,{icon:(0,T.jsx)(p,{}),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,T.jsx)(C,{slot:`task-commits`,className:`mx-auto w-full max-w-[820px]`,commits:n.data.commits.map(t=>({...t,shaLabel:t.sha.slice(0,8),href:`/tasks/${e.id}/commits/${t.sha}`}))})]})}function O({runId:e,sha:t}){let n=a(e,t),i=g(),[o,c]=(0,w.useState)(`unified`),[u,d]=(0,w.useState)(!1),b=n.isError&&n.error instanceof l&&n.error.status===409,S=i?o:`unified`,C=!i||u;return(0,T.jsxs)(`section`,{"data-slot":`task-commit`,"data-sha":t,className:`mx-auto flex min-h-0 w-full max-w-[820px] flex-1 flex-col`,children:[(0,T.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,T.jsx)(r,{asChild:!0,variant:`ghost`,size:`sm`,"data-slot":`commit-back`,children:(0,T.jsxs)(y,{to:`/tasks/${e}/commits`,children:[(0,T.jsx)(f,{"aria-hidden":`true`}),`All commits`]})}),n.data?(0,T.jsx)(x,{stat:n.data.stat}):null,(0,T.jsx)(`span`,{className:`ml-auto hidden items-center gap-1 md:flex`,children:(0,T.jsx)(m,{mode:o,wrap:u,onModeChange:c,onWrapChange:d})})]}),n.isPending?(0,T.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,T.jsx)(s,{icon:b?(0,T.jsx)(_,{}):(0,T.jsx)(v,{}),tone:b?`neutral`:`danger`,heading:`h2`,title:b?`Commit not found`:`Could not load the commit`,subtitle:n.error.message}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`div`,{"data-slot":`commit-meta`,className:`border-b border-border px-4 py-3 md:px-6`,children:[(0,T.jsx)(`h2`,{className:`text-sm font-semibold`,children:n.data.subject}),(0,T.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-soft-foreground`,children:[n.data.author,` · `,n.data.when,` ·`,` `,(0,T.jsx)(`span`,{className:`font-mono select-all`,children:n.data.sha})]})]}),n.data.files.length===0?(0,T.jsx)(s,{icon:(0,T.jsx)(p,{}),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,T.jsx)(`div`,{className:`px-4 py-4 [--diff-sticky-top:10rem] md:px-6`,children:(0,T.jsx)(h,{files:n.data.files,mode:S,wrap:C,className:`min-w-0`})})]})]})}export{E as TaskCommitsRoute};
@@ -1,2 +1,2 @@
1
- import{a as e,s as t,u as n}from"./bundle-mjs-BegPhL5c.js";import{Qt as r,at as i,et as a,t as o,un as s,yt as c}from"./centered-state-CLmJ67EV.js";import{r as l,t as u}from"./utils-B8s5qIcK.js";import{t as d}from"./run-header-B3kW2sWC.js";import{t as f}from"./file-D4GBh1ao.js";import{t as p}from"./triangle-alert-Uy8rokUh.js";import{$t as m,C as h,S as g,nn as _,o as v,s as y,w as b}from"./index-CcfkF2Ey.js";var x=l(`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`}]]),S=l(`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`}]]),C=l(`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`}]]),w=l(`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`}]]),T=l(`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`}]]),E=l(`mouse-pointer-click`,[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]),D=n(t(),1),O=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`bmp`,`ico`,`avif`]);function k(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n<=0?!1:O.has(t.slice(n+1).toLowerCase())}function A(e){return e.tooLarge?`too-large`:k(e.path)?`image`:e.binary?`binary`:`text`}function j(e){return e>=1024**2?`${(e/1024**2).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} kB`:`${e} B`}var M=e();function N({runId:e,path:t,className:n}){let r=i(e,t??void 0);if(t===null)return(0,M.jsx)(F,{className:n,children:(0,M.jsx)(o,{icon:(0,M.jsx)(E,{}),tone:`neutral`,heading:`h2`,title:`Select a file`,subtitle:`Pick a file from the tree to preview it here.`})});if(r.isPending)return(0,M.jsx)(F,{className:n,children:(0,M.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 c&&r.error.status===409;return(0,M.jsx)(F,{className:n,children:(0,M.jsx)(o,{icon:e?(0,M.jsx)(C,{}):(0,M.jsx)(p,{}),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,M.jsx)(P,{runId:e,entry:r.data,className:n}):null}function P({runId:e,entry:t,className:n}){let i=A(t);return(0,M.jsxs)(F,{className:n,children:[(0,M.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,M.jsx)(`span`,{className:`min-w-0 truncate font-mono font-medium`,children:t.path}),(0,M.jsx)(`span`,{className:`ml-auto shrink-0 tabular-nums text-soft-foreground`,children:j(t.size)})]}),i===`image`?(0,M.jsx)(`div`,{className:`flex justify-center p-4`,children:(0,M.jsx)(`img`,{"data-slot":`file-preview-image`,src:r(e,t.path),alt:t.path,className:`max-h-[70vh] max-w-full rounded-sm`})}):i===`too-large`?(0,M.jsx)(o,{icon:(0,M.jsx)(x,{}),tone:`neutral`,heading:`h2`,title:`Too large to preview`,subtitle:`${j(t.size)} — past the preview cap. Open it in your editor instead.`}):i===`binary`?(0,M.jsx)(o,{icon:(0,M.jsx)(S,{}),tone:`neutral`,heading:`h2`,title:`Binary file`,subtitle:`${j(t.size)} of binary data — no text preview.`}):(0,M.jsx)(R,{path:t.path,text:t.content??``})]})}function F({className:e,children:t}){return(0,M.jsx)(`section`,{"data-slot":`file-preview`,className:u(`overflow-hidden rounded-lg border border-border bg-card`,e),children:t})}var I=1500;function L(e,t){let n=(0,D.useMemo)(()=>t.split(`
2
- `).map(e=>[{content:e}]),[t]),r=(0,D.useMemo)(()=>b(e),[e]),i=n.length>I,[a,o]=(0,D.useState)(null);return(0,D.useEffect)(()=>{if(r===null||i)return;let n=!1;return g(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:h(t,r)?.tokens??n}function R({path:e,text:t}){let n=L(e,t);return(0,M.jsx)(`div`,{"data-slot":`file-preview-code`,"data-lang":b(e)??`plaintext`,className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7]`,children:n.map((e,t)=>(0,M.jsxs)(`div`,{className:`flex px-4`,children:[(0,M.jsx)(`span`,{className:`w-10 shrink-0 select-none pr-3 text-right tabular-nums text-soft-foreground`,children:t+1}),(0,M.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-pre pr-4`,children:e.map((e,t)=>(0,M.jsx)(`span`,{style:e.color===void 0?void 0:{color:e.color},children:e.content},t))})]},t))})}function z({runId:e,selected:t,onSelect:n}){return(0,M.jsx)(`nav`,{"data-slot":`files-tree`,"aria-label":`Worktree files`,className:`min-w-0 text-[13px]`,children:(0,M.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,M.jsx)(B,{runId:e,path:``,depth:0,selected:t,onSelect:n})})})}function B({runId:e,path:t,depth:n,selected:r,onSelect:a}){let o=i(e,t);return o.isPending?(0,M.jsx)(`li`,{"data-slot":`files-tree-loading`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${24+n*14}px`},children:`Loading…`}):o.isError?(0,M.jsx)(`li`,{"data-slot":`files-tree-error`,className:`px-1.5 py-1 text-xs text-danger`,style:{paddingLeft:`${24+n*14}px`},children:o.error.message}):o.data.type===`dir`?o.data.entries.length===0?(0,M.jsx)(`li`,{"data-slot":`files-tree-empty`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${24+n*14}px`},children:`Empty directory`}):(0,M.jsx)(M.Fragment,{children:o.data.entries.map(i=>i.type===`dir`?(0,M.jsx)(V,{runId:e,name:i.name,path:t===``?i.name:`${t}/${i.name}`,depth:n,selected:r,onSelect:a},i.name):(0,M.jsx)(H,{name:i.name,path:t===``?i.name:`${t}/${i.name}`,size:i.size,depth:n,selected:r,onSelect:a},i.name))}):null}function V({runId:e,name:t,path:n,depth:r,selected:i,onSelect:a}){let[o,s]=(0,D.useState)(!1);return(0,M.jsxs)(`li`,{children:[(0,M.jsxs)(`button`,{type:`button`,"data-slot":`files-dir`,"data-path":n,"data-state":o?`open`:`closed`,"aria-expanded":o,onClick:()=>s(e=>!e),className:`flex 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,M.jsx)(_,{"aria-hidden":`true`,className:u(`size-3.5 shrink-0 transition-transform`,o&&`rotate-90`)}),(0,M.jsx)(m,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,M.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:t})]}),o?(0,M.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,M.jsx)(B,{runId:e,path:n,depth:r+1,selected:i,onSelect:a})}):null]})}function H({name:e,path:t,size:n,depth:r,selected:i,onSelect:a}){let o=i===t,s=k(t)?T:f;return(0,M.jsx)(`li`,{children:(0,M.jsxs)(`button`,{type:`button`,"data-slot":`files-file`,"data-path":t,"aria-current":o?`true`:void 0,onClick:()=>a(t),className:u(`flex 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:`${24+r*14}px`},children:[(0,M.jsx)(s,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,M.jsx)(`span`,{className:`min-w-0 truncate`,children:e}),n===void 0?null:(0,M.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-[11px] tabular-nums text-soft-foreground`,children:j(n)})]})})}function U(){let{id:e}=s(),t=a(e);return t.isPending?(0,M.jsx)(y,{tab:`files`}):t.isError?(0,M.jsx)(v,{tab:`files`,error:t.error}):(0,M.jsx)(W,{run:t.data})}function W({run:e}){let t=i(e.id,``),[n,r]=(0,D.useState)(null),a=t.isError&&t.error instanceof c&&t.error.status===409;return(0,M.jsxs)(`div`,{"data-route":`task-files`,className:`flex min-h-full flex-col`,children:[(0,M.jsx)(d,{run:e,tab:`files`}),t.isPending?(0,M.jsx)(`p`,{"data-slot":`files-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading files…`}):t.isError?(0,M.jsx)(o,{icon:a?(0,M.jsx)(w,{}):(0,M.jsx)(p,{}),tone:a?`neutral`:`danger`,heading:`h2`,title:a?`No files to browse`:`Could not load the files`,subtitle:t.error.message}):(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 px-4 py-4 md:flex-row md:items-start md:px-6`,children:[(0,M.jsx)(`aside`,{className:`w-full shrink-0 md:sticky md:top-28 md:w-60 lg:w-72`,children:(0,M.jsx)(z,{runId:e.id,selected:n,onSelect:r})}),(0,M.jsx)(N,{runId:e.id,path:n,className:`min-w-0 flex-1`})]})]})}export{U as TaskFilesRoute};
1
+ import{a as e,s as t,u as n}from"./bundle-mjs-BegPhL5c.js";import{Qt as r,at as i,et as a,t as o,un as s,yt as c}from"./centered-state-CLmJ67EV.js";import{r as l,t as u}from"./utils-B8s5qIcK.js";import{t as d}from"./run-header-fLV2ZvNw.js";import{t as f}from"./file-D4GBh1ao.js";import{t as p}from"./triangle-alert-Uy8rokUh.js";import{C as m,S as h,an as g,nn as _,o as v,s as y,w as b}from"./index-MN3Lxn3t.js";var x=l(`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`}]]),S=l(`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`}]]),C=l(`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`}]]),w=l(`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`}]]),T=l(`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`}]]),E=l(`mouse-pointer-click`,[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]),D=n(t(),1),O=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`bmp`,`ico`,`avif`]);function k(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n<=0?!1:O.has(t.slice(n+1).toLowerCase())}function A(e){return e.tooLarge?`too-large`:k(e.path)?`image`:e.binary?`binary`:`text`}function j(e){return e>=1024**2?`${(e/1024**2).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} kB`:`${e} B`}var M=e();function N({runId:e,path:t,className:n}){let r=i(e,t??void 0);if(t===null)return(0,M.jsx)(F,{className:n,children:(0,M.jsx)(o,{icon:(0,M.jsx)(E,{}),tone:`neutral`,heading:`h2`,title:`Select a file`,subtitle:`Pick a file from the tree to preview it here.`})});if(r.isPending)return(0,M.jsx)(F,{className:n,children:(0,M.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 c&&r.error.status===409;return(0,M.jsx)(F,{className:n,children:(0,M.jsx)(o,{icon:e?(0,M.jsx)(C,{}):(0,M.jsx)(p,{}),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,M.jsx)(P,{runId:e,entry:r.data,className:n}):null}function P({runId:e,entry:t,className:n}){let i=A(t);return(0,M.jsxs)(F,{className:n,children:[(0,M.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,M.jsx)(`span`,{className:`min-w-0 truncate font-mono font-medium`,children:t.path}),(0,M.jsx)(`span`,{className:`ml-auto shrink-0 tabular-nums text-soft-foreground`,children:j(t.size)})]}),i===`image`?(0,M.jsx)(`div`,{className:`flex justify-center p-4`,children:(0,M.jsx)(`img`,{"data-slot":`file-preview-image`,src:r(e,t.path),alt:t.path,className:`max-h-[70vh] max-w-full rounded-sm`})}):i===`too-large`?(0,M.jsx)(o,{icon:(0,M.jsx)(x,{}),tone:`neutral`,heading:`h2`,title:`Too large to preview`,subtitle:`${j(t.size)} — past the preview cap. Open it in your editor instead.`}):i===`binary`?(0,M.jsx)(o,{icon:(0,M.jsx)(S,{}),tone:`neutral`,heading:`h2`,title:`Binary file`,subtitle:`${j(t.size)} of binary data — no text preview.`}):(0,M.jsx)(R,{path:t.path,text:t.content??``})]})}function F({className:e,children:t}){return(0,M.jsx)(`section`,{"data-slot":`file-preview`,className:u(`overflow-hidden rounded-lg border border-border bg-card`,e),children:t})}var I=1500;function L(e,t){let n=(0,D.useMemo)(()=>t.split(`
2
+ `).map(e=>[{content:e}]),[t]),r=(0,D.useMemo)(()=>b(e),[e]),i=n.length>I,[a,o]=(0,D.useState)(null);return(0,D.useEffect)(()=>{if(r===null||i)return;let n=!1;return h(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:m(t,r)?.tokens??n}function R({path:e,text:t}){let n=L(e,t);return(0,M.jsx)(`div`,{"data-slot":`file-preview-code`,"data-lang":b(e)??`plaintext`,className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7]`,children:n.map((e,t)=>(0,M.jsxs)(`div`,{className:`flex px-4`,children:[(0,M.jsx)(`span`,{className:`w-10 shrink-0 select-none pr-3 text-right tabular-nums text-soft-foreground`,children:t+1}),(0,M.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-pre pr-4`,children:e.map((e,t)=>(0,M.jsx)(`span`,{style:e.color===void 0?void 0:{color:e.color},children:e.content},t))})]},t))})}function z({runId:e,selected:t,onSelect:n}){return(0,M.jsx)(`nav`,{"data-slot":`files-tree`,"aria-label":`Worktree files`,className:`min-w-0 text-[13px]`,children:(0,M.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,M.jsx)(B,{runId:e,path:``,depth:0,selected:t,onSelect:n})})})}function B({runId:e,path:t,depth:n,selected:r,onSelect:a}){let o=i(e,t);return o.isPending?(0,M.jsx)(`li`,{"data-slot":`files-tree-loading`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${24+n*14}px`},children:`Loading…`}):o.isError?(0,M.jsx)(`li`,{"data-slot":`files-tree-error`,className:`px-1.5 py-1 text-xs text-danger`,style:{paddingLeft:`${24+n*14}px`},children:o.error.message}):o.data.type===`dir`?o.data.entries.length===0?(0,M.jsx)(`li`,{"data-slot":`files-tree-empty`,className:`px-1.5 py-1 text-xs text-soft-foreground`,style:{paddingLeft:`${24+n*14}px`},children:`Empty directory`}):(0,M.jsx)(M.Fragment,{children:o.data.entries.map(i=>i.type===`dir`?(0,M.jsx)(V,{runId:e,name:i.name,path:t===``?i.name:`${t}/${i.name}`,depth:n,selected:r,onSelect:a},i.name):(0,M.jsx)(H,{name:i.name,path:t===``?i.name:`${t}/${i.name}`,size:i.size,depth:n,selected:r,onSelect:a},i.name))}):null}function V({runId:e,name:t,path:n,depth:r,selected:i,onSelect:a}){let[o,s]=(0,D.useState)(!1);return(0,M.jsxs)(`li`,{children:[(0,M.jsxs)(`button`,{type:`button`,"data-slot":`files-dir`,"data-path":n,"data-state":o?`open`:`closed`,"aria-expanded":o,onClick:()=>s(e=>!e),className:`flex 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,M.jsx)(g,{"aria-hidden":`true`,className:u(`size-3.5 shrink-0 transition-transform`,o&&`rotate-90`)}),(0,M.jsx)(_,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,M.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:t})]}),o?(0,M.jsx)(`ul`,{className:`flex flex-col gap-px`,children:(0,M.jsx)(B,{runId:e,path:n,depth:r+1,selected:i,onSelect:a})}):null]})}function H({name:e,path:t,size:n,depth:r,selected:i,onSelect:a}){let o=i===t,s=k(t)?T:f;return(0,M.jsx)(`li`,{children:(0,M.jsxs)(`button`,{type:`button`,"data-slot":`files-file`,"data-path":t,"aria-current":o?`true`:void 0,onClick:()=>a(t),className:u(`flex 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:`${24+r*14}px`},children:[(0,M.jsx)(s,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,M.jsx)(`span`,{className:`min-w-0 truncate`,children:e}),n===void 0?null:(0,M.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-[11px] tabular-nums text-soft-foreground`,children:j(n)})]})})}function U(){let{id:e}=s(),t=a(e);return t.isPending?(0,M.jsx)(y,{tab:`files`}):t.isError?(0,M.jsx)(v,{tab:`files`,error:t.error}):(0,M.jsx)(W,{run:t.data})}function W({run:e}){let t=i(e.id,``),[n,r]=(0,D.useState)(null),a=t.isError&&t.error instanceof c&&t.error.status===409;return(0,M.jsxs)(`div`,{"data-route":`task-files`,className:`flex min-h-full flex-col`,children:[(0,M.jsx)(d,{run:e,tab:`files`}),t.isPending?(0,M.jsx)(`p`,{"data-slot":`files-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground md:px-6`,children:`Loading files…`}):t.isError?(0,M.jsx)(o,{icon:a?(0,M.jsx)(w,{}):(0,M.jsx)(p,{}),tone:a?`neutral`:`danger`,heading:`h2`,title:a?`No files to browse`:`Could not load the files`,subtitle:t.error.message}):(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-stretch gap-5 px-4 py-4 md:flex-row md:items-start md:px-6`,children:[(0,M.jsx)(`aside`,{className:`w-full shrink-0 md:sticky md:top-28 md:w-60 lg:w-72`,children:(0,M.jsx)(z,{runId:e.id,selected:n,onSelect:r})}),(0,M.jsx)(N,{runId:e.id,path:n,className:`min-w-0 flex-1`})]})]})}export{U as TaskFilesRoute};
@@ -1,9 +1,9 @@
1
- import{a as e,s as t,u as n}from"./bundle-mjs-BegPhL5c.js";import{A as r,B as i,Dt as a,F as o,O as s,P as c,W as l,X as u,a as d,cn as f,ct as p,et as m,fn as h,i as g,k as _,lt as v,mn as y,n as b,st as x,t as S,un as C,wt as w,yt as T}from"./centered-state-CLmJ67EV.js";import{n as ee,o as E,r as D,t as O}from"./utils-B8s5qIcK.js";import{c as te,l as ne,n as k,o as re,r as ie,s as ae,t as oe}from"./run-header-B3kW2sWC.js";import{n as se,t as ce}from"./trash-2-DAyZ0VSi.js";import{n as le}from"./tab-link-vtgjgL_M.js";import{t as ue}from"./git-pull-request-DnR8Xh4_.js";import{t as de}from"./search-x-BDjaMrzG.js";import{t as fe}from"./square-terminal-Ckjjn0vb.js";import{t as pe}from"./textarea-Bj_LCreg.js";import{i as A,n as j,r as M,t as me}from"./run-diff-Cksr4Dk5.js";import{t as he}from"./project-router-BaWVyqc8.js";import{B as ge,E as _e,G as ve,I as ye,K as be,Kt as xe,Pt as N,Q as Se,T as Ce,U as we,V as Te,W as Ee,a as De,an as Oe,at as ke,en as Ae,in as je,it as Me,nn as P,nt as Ne,q as Pe,rn as Fe,rt as Ie,tt as Le,x as F}from"./index-CcfkF2Ey.js";import{t as Re}from"./lib-DPEZDBUN.js";import{t as ze}from"./zoomable-image-PEDOqyLQ.js";var Be=D(`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`}]]),Ve=D(`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`}]]),He=D(`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`}]]),Ue=D(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),We=D(`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`}]]),Ge=D(`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`}]]),I=D(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),L=n(t(),1),Ke=[`run-event`,`ui-event`];function qe(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 Je(e){let[t,n]=(0,L.useState)([]);return(0,L.useEffect)(()=>{if(n([]),!e)return;let t=globalThis.EventSource;if(typeof t!=`function`)return;let r=0,i=null,a,o=!1,s=Date.now(),c,l=e=>{s=Date.now();let t=qe(e.data);!t||!(t.seq>r)||(r=t.seq,n(e=>[...e,t]))},u=()=>{s=Date.now()},d=()=>{o||a!==void 0||(a=setTimeout(()=>{a=void 0,o||f()},1500))},f=()=>{i?.close(),s=Date.now(),i=new t(E(`/api/runs/${encodeURIComponent(e)}/events`));for(let e of Ke)i.addEventListener(e,l);i.addEventListener(`ping`,u),i.addEventListener(`error`,()=>{i?.readyState===2&&d()})},p=()=>{document.visibilityState===`visible`&&(!i||i.readyState===2)&&(clearTimeout(a),a=void 0,f())},m=()=>{clearTimeout(a),a=void 0,i?.close()},h=e=>{e.persisted&&f()};return c=setInterval(()=>{o||document.visibilityState!==`visible`||Date.now()-s<=4e4||(clearTimeout(a),a=void 0,f())},1e4),document.addEventListener(`visibilitychange`,p),window.addEventListener(`pagehide`,m),window.addEventListener(`pageshow`,h),f(),()=>{o=!0,clearTimeout(a),clearInterval(c),document.removeEventListener(`visibilitychange`,p),window.removeEventListener(`pagehide`,m),window.removeEventListener(`pageshow`,h),i?.close()}},[e]),t}var R=e=>e.kind===`tool`,Ye=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,Xe=(e,t,n)=>`${e} ${e===1?t:n}`;function Ze(e,t){let n=[];return e>0&&n.push(Xe(e,`file`,`files`)),t>0&&n.push(Xe(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function Qe(e){return`${e} earlier tool call${e===1?``:`s`}`}var $e=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function et(e){for(let t of $e)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 tt(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!(e.kind===`reasoning`&&e.text.trim()===``)),n=new Set(t.filter(R).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:Ze(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=[]};for(let e of i)R(e)&&Ye(e)&&!r.has(e.id)?o.push(e):(s(),R(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();let c=e=>e.kind===`context-group`||e.kind===`tool-card`&&e.item.status===`completed`,l=e=>e.kind===`context-group`?e.tools.length:1,u=[],d=[],f=()=>{if(d.length>3){let e=d.slice(0,d.length-3);u.push({kind:`streak`,id:`streak:${e[0].id}`,count:e.reduce((e,t)=>e+l(t),0),blocks:e}),u.push(...d.slice(d.length-3))}else u.push(...d);d=[]};for(let e of a)c(e)?d.push(e):(f(),u.push(e));return f(),u}var z=e(),B=new Map,nt=(0,L.createContext)(null);function rt(){return(0,L.useContext)(nt)}function it({runId:e,children:t}){let n=(0,L.useMemo)(()=>({get:t=>B.get(e)?.get(t),set:(t,n)=>{let r=B.get(e)??new Map;r.set(t,n),B.set(e,r)}}),[e]);return(0,z.jsx)(nt.Provider,{value:n,children:t})}function V(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function at(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var ot=new Map;function st(e,t){ot.set(e,t)}function ct(e){return ot.get(e)}var lt=new Map;function ut(e,t){lt.set(e,t)}function dt(e,t){let n=lt.get(e);return n!==void 0&&n.rows===t?n.cache:void 0}function H({text:e,imageCount:t=0,images:n=[],onEdit:r,onRemove:i,editLabel:a=`Edit message`,removeLabel:o=`Remove message`}){let c=t-n.length,[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)(e),[p,m]=(0,L.useState)(!1),[h,g]=(0,L.useState)(),_=()=>{f(e),g(void 0),u(!0)},v=async()=>{let t=d.trim();if(!t||t===e){u(!1);return}m(!0),g(void 0);try{await r?.(t),u(!1)}catch(e){g(e instanceof Error?e.message:`Could not save the message`)}finally{m(!1)}},y=async()=>{m(!0),g(void 0);try{await i?.()}catch(e){g(e instanceof Error?e.message:`Could not remove the message`)}finally{m(!1)}};return l?(0,z.jsxs)(`div`,{"data-slot":`user-bubble`,"data-editing":`true`,className:`max-w-[78%] self-end rounded-2xl rounded-br-md bg-muted px-[15px] py-2.5 text-[13.5px] leading-[1.55] md:max-w-[70%]`,children:[(0,z.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(),v())},className:`block max-h-[220px] min-h-[60px] w-full resize-none rounded-md bg-background px-2 py-1.5 text-[13.5px] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}),(0,z.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>u(!1),disabled:p,className:`rounded-sm px-2 py-1 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,z.jsx)(`button`,{type:`button`,onClick:()=>void v(),disabled:p,className:`rounded-sm bg-primary px-2 py-1 text-xs font-semibold text-primary-foreground hover:brightness-[0.96] focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:p?(0,z.jsx)(s,{className:`size-3.5 animate-spin`}):`Save`})]}),h?(0,z.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:h}):null]}):(0,z.jsxs)(`div`,{"data-slot":`user-bubble`,className:`group max-w-[78%] min-w-0 self-end rounded-2xl rounded-br-md bg-muted px-[15px] py-2.5 text-[13.5px] leading-[1.55] md:max-w-[70%]`,children:[r||i?(0,z.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:[r?(0,z.jsx)(`button`,{type:`button`,"aria-label":a,onClick:_,disabled:p,className:`rounded-sm p-1 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,z.jsx)(Ge,{className:`size-3.5`})}):null,i?(0,z.jsx)(`button`,{type:`button`,"aria-label":o,onClick:()=>void y(),disabled:p,className:`rounded-sm p-1 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,z.jsx)(ce,{className:`size-3.5`})}):null]}):null,h?(0,z.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:h}):null,(0,z.jsx)(F,{breaks:!0,children:e}),n.length>0?(0,z.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap justify-end gap-1.5`,children:n.map(e=>(0,z.jsx)(ze,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e))}):null,c>0?(0,z.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[c,` image`,c>1?`s`:``,` attached`]}):null]})}function ft({text:e}){return(0,z.jsx)(`div`,{"data-slot":`assistant-message`,className:`min-w-0 text-[15px] leading-[1.65]`,children:(0,z.jsx)(F,{children:e})})}function pt({note:e}){return(0,z.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:O(`px-0.5 text-xs`,e.tone===`danger`?`text-danger`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:`· `,e.text]})}function mt({text:e}){let t=(0,L.useId)();if(e.trim()===``)return null;let n=e.split(`
2
- `,1)[0]??``,r=n.length<e.length;return(0,z.jsxs)(j,{"data-slot":`reasoning`,className:`group/reasoning min-w-0`,children:[(0,z.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,z.jsx)(P,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/reasoning:rotate-90`}),(0,z.jsx)(`span`,{className:`shrink-0`,children:`Thinking — `}),(0,z.jsx)(`div`,{className:`min-w-0 truncate text-muted-foreground`,children:(0,z.jsx)(F,{inline:!0,children:n})}),r?(0,z.jsx)(`span`,{"aria-hidden":!0,children:`…`}):null,(0,z.jsx)(A,{"aria-labelledby":t,className:`absolute inset-0 rounded-md focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`})]}),(0,z.jsx)(M,{children:(0,z.jsx)(`div`,{className:`px-6 py-1.5 text-[13px] leading-[1.6] text-soft-foreground`,children:(0,z.jsx)(F,{children:e})})})]})}function ht(){return(0,z.jsxs)(`div`,{"data-slot":`working-indicator`,className:`flex items-center gap-2 py-1 text-[13px] text-soft-foreground`,children:[(0,z.jsx)(s,{role:`status`,"aria-label":`Working`,className:`size-3.5 shrink-0 animate-spin`}),(0,z.jsx)(`span`,{className:`shimmer font-medium`,children:`Working…`})]})}var gt={read:ne,edit:Ge,delete:ce,move:He,search:xe,execute:fe,think:Be,fetch:te,task:je,plan:Ue,other:I},_t=e=>e.split(`
1
+ import{a as e,s as t,u as n}from"./bundle-mjs-BegPhL5c.js";import{A as r,B as i,Dt as a,F as o,O as s,P as c,W as l,X as u,a as d,cn as f,ct as p,et as m,fn as h,i as g,k as _,lt as v,mn as y,n as b,st as x,t as S,un as C,wt as w,yt as T}from"./centered-state-CLmJ67EV.js";import{n as ee,o as E,r as D,t as O}from"./utils-B8s5qIcK.js";import{c as te,l as ne,n as k,o as re,r as ie,s as ae,t as oe}from"./run-header-fLV2ZvNw.js";import{n as se,t as ce}from"./trash-2-DAyZ0VSi.js";import{n as le}from"./tab-link-vtgjgL_M.js";import{t as ue}from"./git-pull-request-DnR8Xh4_.js";import{t as de}from"./search-x-BDjaMrzG.js";import{t as fe}from"./square-terminal-Ckjjn0vb.js";import{t as pe}from"./textarea-Bj_LCreg.js";import{i as A,n as j,r as M,t as me}from"./run-diff-BGNJAOm7.js";import{t as he}from"./project-router-BaWVyqc8.js";import{B as ge,E as _e,G as ve,I as ye,K as be,Lt as N,T as xe,U as Se,V as Ce,W as we,Yt as Te,a as Ee,an as P,at as De,cn as Oe,ct as ke,et as Ae,it as je,on as Me,ot as Ne,q as Pe,rn as Fe,sn as Ie,st as Le,x as F}from"./index-MN3Lxn3t.js";import{t as Re}from"./lib-DPEZDBUN.js";import{t as ze}from"./zoomable-image-PEDOqyLQ.js";var Be=D(`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`}]]),Ve=D(`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`}]]),He=D(`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`}]]),Ue=D(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),We=D(`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`}]]),Ge=D(`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`}]]),I=D(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),L=n(t(),1),Ke=[`run-event`,`ui-event`];function qe(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 Je(e){let[t,n]=(0,L.useState)([]);return(0,L.useEffect)(()=>{if(n([]),!e)return;let t=globalThis.EventSource;if(typeof t!=`function`)return;let r=0,i=null,a,o=!1,s=Date.now(),c,l=e=>{s=Date.now();let t=qe(e.data);!t||!(t.seq>r)||(r=t.seq,n(e=>[...e,t]))},u=()=>{s=Date.now()},d=()=>{o||a!==void 0||(a=setTimeout(()=>{a=void 0,o||f()},1500))},f=()=>{i?.close(),s=Date.now(),i=new t(E(`/api/runs/${encodeURIComponent(e)}/events`));for(let e of Ke)i.addEventListener(e,l);i.addEventListener(`ping`,u),i.addEventListener(`error`,()=>{i?.readyState===2&&d()})},p=()=>{document.visibilityState===`visible`&&(!i||i.readyState===2)&&(clearTimeout(a),a=void 0,f())},m=()=>{clearTimeout(a),a=void 0,i?.close()},h=e=>{e.persisted&&f()};return c=setInterval(()=>{o||document.visibilityState!==`visible`||Date.now()-s<=4e4||(clearTimeout(a),a=void 0,f())},1e4),document.addEventListener(`visibilitychange`,p),window.addEventListener(`pagehide`,m),window.addEventListener(`pageshow`,h),f(),()=>{o=!0,clearTimeout(a),clearInterval(c),document.removeEventListener(`visibilitychange`,p),window.removeEventListener(`pagehide`,m),window.removeEventListener(`pageshow`,h),i?.close()}},[e]),t}var R=e=>e.kind===`tool`,Ye=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,Xe=(e,t,n)=>`${e} ${e===1?t:n}`;function Ze(e,t){let n=[];return e>0&&n.push(Xe(e,`file`,`files`)),t>0&&n.push(Xe(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function Qe(e){return`${e} earlier tool call${e===1?``:`s`}`}var $e=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function et(e){for(let t of $e)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 tt(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!(e.kind===`reasoning`&&e.text.trim()===``)),n=new Set(t.filter(R).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:Ze(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=[]};for(let e of i)R(e)&&Ye(e)&&!r.has(e.id)?o.push(e):(s(),R(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();let c=e=>e.kind===`context-group`||e.kind===`tool-card`&&e.item.status===`completed`,l=e=>e.kind===`context-group`?e.tools.length:1,u=[],d=[],f=()=>{if(d.length>3){let e=d.slice(0,d.length-3);u.push({kind:`streak`,id:`streak:${e[0].id}`,count:e.reduce((e,t)=>e+l(t),0),blocks:e}),u.push(...d.slice(d.length-3))}else u.push(...d);d=[]};for(let e of a)c(e)?d.push(e):(f(),u.push(e));return f(),u}var z=e(),B=new Map,nt=(0,L.createContext)(null);function rt(){return(0,L.useContext)(nt)}function it({runId:e,children:t}){let n=(0,L.useMemo)(()=>({get:t=>B.get(e)?.get(t),set:(t,n)=>{let r=B.get(e)??new Map;r.set(t,n),B.set(e,r)}}),[e]);return(0,z.jsx)(nt.Provider,{value:n,children:t})}function V(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function at(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var ot=new Map;function st(e,t){ot.set(e,t)}function ct(e){return ot.get(e)}var lt=new Map;function ut(e,t){lt.set(e,t)}function dt(e,t){let n=lt.get(e);return n!==void 0&&n.rows===t?n.cache:void 0}function H({text:e,imageCount:t=0,images:n=[],onEdit:r,onRemove:i,editLabel:a=`Edit message`,removeLabel:o=`Remove message`}){let c=t-n.length,[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)(e),[p,m]=(0,L.useState)(!1),[h,g]=(0,L.useState)(),_=()=>{f(e),g(void 0),u(!0)},v=async()=>{let t=d.trim();if(!t||t===e){u(!1);return}m(!0),g(void 0);try{await r?.(t),u(!1)}catch(e){g(e instanceof Error?e.message:`Could not save the message`)}finally{m(!1)}},y=async()=>{m(!0),g(void 0);try{await i?.()}catch(e){g(e instanceof Error?e.message:`Could not remove the message`)}finally{m(!1)}};return l?(0,z.jsxs)(`div`,{"data-slot":`user-bubble`,"data-editing":`true`,className:`max-w-[78%] self-end rounded-2xl rounded-br-md bg-muted px-[15px] py-2.5 text-[13.5px] leading-[1.55] md:max-w-[70%]`,children:[(0,z.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(),v())},className:`block max-h-[220px] min-h-[60px] w-full resize-none rounded-md bg-background px-2 py-1.5 text-[13.5px] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}),(0,z.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>u(!1),disabled:p,className:`rounded-sm px-2 py-1 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,z.jsx)(`button`,{type:`button`,onClick:()=>void v(),disabled:p,className:`rounded-sm bg-primary px-2 py-1 text-xs font-semibold text-primary-foreground hover:brightness-[0.96] focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:p?(0,z.jsx)(s,{className:`size-3.5 animate-spin`}):`Save`})]}),h?(0,z.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:h}):null]}):(0,z.jsxs)(`div`,{"data-slot":`user-bubble`,className:`group max-w-[78%] min-w-0 self-end rounded-2xl rounded-br-md bg-muted px-[15px] py-2.5 text-[13.5px] leading-[1.55] md:max-w-[70%]`,children:[r||i?(0,z.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:[r?(0,z.jsx)(`button`,{type:`button`,"aria-label":a,onClick:_,disabled:p,className:`rounded-sm p-1 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,z.jsx)(Ge,{className:`size-3.5`})}):null,i?(0,z.jsx)(`button`,{type:`button`,"aria-label":o,onClick:()=>void y(),disabled:p,className:`rounded-sm p-1 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,z.jsx)(ce,{className:`size-3.5`})}):null]}):null,h?(0,z.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:h}):null,(0,z.jsx)(F,{breaks:!0,children:e}),n.length>0?(0,z.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap justify-end gap-1.5`,children:n.map(e=>(0,z.jsx)(ze,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e))}):null,c>0?(0,z.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[c,` image`,c>1?`s`:``,` attached`]}):null]})}function ft({text:e}){return(0,z.jsx)(`div`,{"data-slot":`assistant-message`,className:`min-w-0 text-[15px] leading-[1.65]`,children:(0,z.jsx)(F,{children:e})})}function pt({note:e}){return(0,z.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:O(`px-0.5 text-xs`,e.tone===`danger`?`text-danger`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:`· `,e.text]})}function mt({text:e}){let t=(0,L.useId)();if(e.trim()===``)return null;let n=e.split(`
2
+ `,1)[0]??``,r=n.length<e.length;return(0,z.jsxs)(j,{"data-slot":`reasoning`,className:`group/reasoning min-w-0`,children:[(0,z.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,z.jsx)(P,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/reasoning:rotate-90`}),(0,z.jsx)(`span`,{className:`shrink-0`,children:`Thinking — `}),(0,z.jsx)(`div`,{className:`min-w-0 truncate text-muted-foreground`,children:(0,z.jsx)(F,{inline:!0,children:n})}),r?(0,z.jsx)(`span`,{"aria-hidden":!0,children:`…`}):null,(0,z.jsx)(A,{"aria-labelledby":t,className:`absolute inset-0 rounded-md focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`})]}),(0,z.jsx)(M,{children:(0,z.jsx)(`div`,{className:`px-6 py-1.5 text-[13px] leading-[1.6] text-soft-foreground`,children:(0,z.jsx)(F,{children:e})})})]})}function ht(){return(0,z.jsxs)(`div`,{"data-slot":`working-indicator`,className:`flex items-center gap-2 py-1 text-[13px] text-soft-foreground`,children:[(0,z.jsx)(s,{role:`status`,"aria-label":`Working`,className:`size-3.5 shrink-0 animate-spin`}),(0,z.jsx)(`span`,{className:`shimmer font-medium`,children:`Working…`})]})}var gt={read:ne,edit:Ge,delete:ce,move:He,search:Te,execute:fe,think:Be,fetch:te,task:Ie,plan:Ue,other:I},_t=e=>e.split(`
3
3
  `).length;function vt({text:e,streaming:t}){let[n,r]=(0,L.useState)(!1),i=(0,L.useRef)(null),a=(0,L.useRef)(!0);(0,L.useEffect)(()=>{let e=i.current;t&&e&&a.current&&(e.scrollTop=e.scrollHeight)},[e,t]);let o=_t(e),s=!t&&!n&&o>12;return(0,z.jsxs)(`div`,{"data-slot":`tool-output`,"data-clamped":s?`true`:void 0,children:[(0,z.jsxs)(`div`,{className:`relative`,children:[(0,z.jsx)(`div`,{ref:i,onScroll:t?e=>{a.current=V(e.currentTarget)}:void 0,className:O(`overflow-x-auto`,t&&`max-h-[216px] overflow-y-auto`,s&&`max-h-[216px] overflow-y-hidden`),children:(0,z.jsx)(`pre`,{className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre text-muted-foreground`,children:e})}),s?(0,z.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,z.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 yt({diffs:e}){return(0,z.jsx)(z.Fragment,{children:e.map((e,t)=>(0,z.jsxs)(`div`,{"data-slot":`diff-preview`,className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`border-b border-border/50 px-4 py-1.5 font-mono text-[11px] text-soft-foreground`,children:e.path}),(0,z.jsx)(`pre`,{className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:e.unified===void 0?[...bt(e.oldText).map((e,t)=>(0,z.jsxs)(`span`,{className:`block bg-diff-del px-4 text-muted-foreground`,children:[`- `,e]},`old-${t}`)),...bt(e.newText).map((e,t)=>(0,z.jsxs)(`span`,{className:`block bg-diff-add px-4`,children:[`+ `,e]},`new-${t}`))]:e.unified.split(`
4
4
  `).map((e,t)=>(0,z.jsx)(xt,{text:e},t))})]},`${e.path}:${t}`))})}function bt(e){return e==null||e===``?[]:e.replace(/\n$/,``).split(`
5
- `)}function xt({text:e}){return(0,z.jsx)(`span`,{className:O(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del text-muted-foreground`,e.startsWith(`@@`)&&`text-soft-foreground`),children:e})}function St(e){return e.status===`failed`||e.toolKind===`execute`&&e.status===`running`&&e.output!==void 0}function U({item:e,nested:t=[],cacheKey:n}){let r=rt(),[i,a]=(0,L.useState)(()=>n===void 0?null:r?.get(n)??null),o=e=>{n!==void 0&&r?.set(n,e),a(e)},c=e.status===`running`||e.status===`pending`,l=e.output!==void 0&&e.output!==``||e.error!==void 0&&e.error!==``||e.diffs!==void 0&&e.diffs.length>0||t.length>0,u=l&&(i??St(e)),{verb:d,detail:f}=et(e.title),p=gt[e.toolKind]??I;return(0,z.jsxs)(j,{"data-slot":`tool-card`,"data-status":e.status,"data-kind":e.toolKind,open:u,onOpenChange:o,className:O(`min-w-0 overflow-hidden rounded-md border bg-card`,e.status===`failed`?`border-danger/40`:`border-border`),children:[(0,z.jsxs)(A,{disabled:!l,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,z.jsx)(P,{"aria-hidden":!0,className:O(`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`,!l&&`invisible`)}),(0,z.jsx)(p,{"aria-hidden":!0,className:O(`size-3.5 shrink-0`,e.status===`failed`?`text-danger`:`text-muted-foreground`)}),(0,z.jsx)(`span`,{className:O(`shrink-0 font-semibold`,c&&`shimmer`,e.status===`failed`&&`text-danger`,e.status===`declined`&&`text-muted-foreground`),children:d}),f===void 0?null:(0,z.jsx)(`code`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,children:f}),(0,z.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[c?(0,z.jsx)(s,{role:`status`,"aria-label":`Running`,className:`size-3.5 animate-spin text-soft-foreground`}):null,e.status===`failed`?(0,z.jsx)(`span`,{className:`text-xs text-danger`,children:`failed`}):null,e.status===`declined`?(0,z.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`declined`}):null,e.toolKind===`execute`&&typeof e.exitCode==`number`?(0,z.jsx)(`span`,{"data-slot":`tool-exit`,className:O(`rounded-full px-2 py-px font-mono text-[10.5px] font-semibold`,e.exitCode===0?`bg-success/10 text-success`:`bg-danger/10 text-danger`),children:e.exitCode}):null]})]}),(0,z.jsx)(M,{children:(0,z.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[e.error!==void 0&&e.error!==``?(0,z.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,z.jsx)(yt,{diffs:e.diffs}):null,e.output!==void 0&&e.output!==``?(0,z.jsx)(vt,{text:e.output,streaming:c}):null,t.length>0?(0,z.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:t.map(e=>(0,z.jsx)(Ct,{entry:e,scope:n},e.id))}):null]})})]})}function Ct({entry:e,scope:t}){switch(e.kind){case`message`:return(0,z.jsx)(ft,{text:e.text});case`reasoning`:return(0,z.jsx)(mt,{text:e.text});case`tool`:return(0,z.jsx)(U,{item:e,cacheKey:t===void 0?void 0:`${t}:${e.id}`});case`note`:return(0,z.jsx)(pt,{note:e});case`image`:return(0,z.jsx)(Et,{image:e});case`ask`:return null}}function wt({group:e,scope:t}){return(0,z.jsxs)(j,{"data-slot":`ctx-group`,className:`min-w-0`,children:[(0,z.jsxs)(A,{className:`group flex h-[34px] 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,z.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,z.jsx)(M,{children:(0,z.jsx)(`div`,{className:`flex flex-col gap-1.5 pt-1.5 pl-4`,children:e.tools.map(e=>(0,z.jsx)(U,{item:e,cacheKey:t===void 0?void 0:`${t}:${e.id}`},e.id))})})]})}function Tt({count:e,children:t}){return(0,z.jsxs)(j,{"data-slot":`tool-streak`,className:`min-w-0`,children:[(0,z.jsxs)(A,{className:`group flex items-center gap-1.5 rounded-md p-0.5 text-left text-xs text-soft-foreground hover:text-muted-foreground`,children:[(0,z.jsx)(P,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),Qe(e)]}),(0,z.jsx)(M,{children:(0,z.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t})})]})}function Et({image:e}){return(0,z.jsx)(ze,{"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 Dt(e){let t=y(),n=ae(e).continueRun,a=i(),o=c(),s=x(n),[l,u]=(0,L.useState)(null),[d,f]=(0,L.useState)(null),p=we(a.data?.checks??[]),m=e.runner??`claude`,g=Pe(l,p,m),_=g===m&&e.model?{...o.data?.defaultModels,[g]:e.model}:o.data?.defaultModels,v=ve(g,s.data,[d,_?.[g]]),b=be(d,g,_,s.data),S=h({mutationFn:({text:t,images:n})=>w(e.id,{text:t.trim()?t:void 0,images:n.length?n:void 0,runner:l===null?void 0:g,model:d===null?void 0:b}),onSuccess:()=>t.invalidateQueries({queryKey:r.runs.all})});return{available:n,pills:(0,z.jsxs)(`div`,{"data-slot":`follow-up-engine`,className:`flex flex-wrap items-center gap-1.5`,children:[p.length>1?(0,z.jsx)(Te,{runners:p,value:g,onPick:e=>{u(e),f(null)}}):null,(0,z.jsx)(ge,{slot:`follow-up-model-pill`,ariaLabel:`Model`,label:v.find(e=>e.id===b)?.label??`auto`,value:b,onPick:e=>f(e),options:v.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:Ee(g,s.data,s.isError)})]}),continueWith:(e,t)=>S.mutateAsync({text:e,images:t})}}var Ot=120,W=e=>e!==`pending`&&e!==`running`,kt=e=>e.kind===`tool`&&e.toolKind===`task`,G=e=>kt(e)&&e.parentItemId===void 0,At=e=>(e.kind===`message`||e.kind===`reasoning`||e.kind===`tool`)&&!(e.kind===`tool`&&e.toolKind===`plan`);function jt(e,t){for(let n=0;n<e.length;n+=1)if(e[n].items.some(e=>G(e)&&t.has(e.id)))return n;return 0}function Mt(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 Nt(e){if(e.kind===`tool`)return Pt(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 Pt(n)}}}function Pt(e){return e.length>Ot?`${e.slice(0,Ot-1).trimEnd()}…`:e}function Ft(e,t=!1){let n=Bt(e,e=>e.items.some(G));if(n===-1)return[];let r=e=>!t&&!W(e.status),i=[];for(let t=n-1;t>=0;--t){let n=e[t].items.filter(G);if(n.length!==0){if(!n.some(r))break;i.unshift(...n)}}let a=[...i,...e[n].items.filter(G)];if(n!==e.length-1&&!a.some(r))return[];let o=new Set(a.map(e=>e.id)),s=i.length>0?jt(e,o):n,c=new Map;for(let t=s;t<e.length;t+=1)for(let n of e[t].items){if(!At(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=>It(e,c.get(e.id)??[],t))}function It(e,t,n){let r={id:e.id,title:et(e.title).detail??e.title,status:e.status,toolCalls:t.filter(e=>e.kind===`tool`).length},i=Mt(e);i!==void 0&&(r.agentType=i),n&&!W(e.status)&&(r.stalled=!0);for(let e=t.length-1;e>=0;--e){let n=Nt(t[e]);if(n!==void 0){r.activity=n;break}}return r}function Lt(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.length}}function Rt(e){return e.activity??(e.stalled===!0?`never finished`:`starting…`)}function zt(e){return e.find(e=>!W(e.status))??e[0]}function Bt(e,t){for(let n=e.length-1;n>=0;--n)if(t(e[n]))return n;return-1}function Vt(e,t,n=!1){for(let r=e.length-1;r>=0;--r){let i=e[r].items.find(e=>e.id===t&&G(e));if(i!==void 0)return It(i,Ht(e,t),n)}}function Ht(e,t){let n=e.findIndex(e=>e.items.some(e=>e.id===t&&G(e)));if(n===-1)return[];let r=[];for(let i=n;i<e.length;i+=1)for(let n of e[i].items)At(n)&&n.parentItemId===t&&n.id!==t&&r.push(n);return r}var Ut=new Map;function Wt(){return typeof window.matchMedia!=`function`||window.matchMedia(`(min-width: 768px)`).matches}function Gt({runId:e,agents:t,onSelect:n}){let[r,i]=(0,L.useState)(()=>Ut.get(e)??Wt());if(t.length===0)return null;let{done:a,total:o}=Lt(t),s=zt(t);return(0,z.jsxs)(`section`,{"data-slot":`agents-dock`,"data-state":r?`open`:`collapsed`,className:`min-w-0 overflow-hidden rounded-lg border border-border bg-card shadow-xs`,children:[(0,z.jsx)(`div`,{"aria-hidden":!0,"data-slot":`grad-edge`,className:`h-[3px]`,style:{background:`var(--grad)`}}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>i(t=>(Ut.set(e,!t),!t)),"aria-expanded":r,className:O(`flex w-full items-center gap-2 px-3.5 text-left text-[13px]`,r?`pt-2 pb-1.5`:`py-2`),children:[(0,z.jsx)(je,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground`}),(0,z.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Agents`}),(0,z.jsxs)(`span`,{"data-slot":`agents-count`,className:`shrink-0 text-muted-foreground tabular-nums`,children:[`· `,a,`/`,o]}),!r&&s!==void 0?(0,z.jsxs)(`span`,{"data-slot":`agents-current`,className:`min-w-0 truncate text-muted-foreground`,children:[`— `,Rt(s)]}):null,(0,z.jsx)(Fe,{"aria-hidden":!0,className:O(`ml-auto size-3.5 shrink-0 text-soft-foreground transition-transform`,!r&&`rotate-180`)})]}),r?(0,z.jsx)(`ul`,{"data-slot":`agents-list`,className:`flex flex-col gap-[7px] px-3.5 pb-3`,children:t.map(e=>(0,z.jsx)(Kt,{agent:e,onSelect:n},e.id))}):null]})}function Kt({agent:e,onSelect:t}){let n=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(qt,{status:e.status,stalled:e.stalled===!0}),(0,z.jsx)(`span`,{className:`min-w-0 shrink truncate font-medium`,children:e.title}),e.agentType===void 0?null:(0,z.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-[10.5px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:e.agentType}),(0,z.jsx)(`span`,{"data-slot":`agent-activity`,className:`min-w-0 flex-1 truncate text-muted-foreground`,children:Rt(e)}),(0,z.jsxs)(`span`,{"data-slot":`agent-tools`,className:`shrink-0 text-muted-foreground tabular-nums`,children:[e.toolCalls,` `,e.toolCalls===1?`tool`:`tools`]})]});return(0,z.jsx)(`li`,{"data-slot":`agent-item`,"data-status":e.status,className:`min-w-0 text-[13px]`,children:t?(0,z.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,z.jsx)(`div`,{className:`flex min-h-5 min-w-0 items-center gap-2.5`,children:n})})}function qt({status:e,stalled:t=!1}){return t?(0,z.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,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})}):e===`completed`?(0,z.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,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,z.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`failed`||e===`declined`?(0,z.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,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,z.jsx)(`path`,{d:`m9 9 6 6M15 9l-6 6`})]}):(0,z.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,z.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,z.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]})}var Jt=new Map;function Yt(){return typeof window.matchMedia!=`function`||window.matchMedia(`(min-width: 768px)`).matches}function K(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.filter(e=>e.status!==`cancelled`).length}}function Xt(e){return e.find(e=>e.status===`in_progress`)??e.find(e=>e.status===`pending`)}function Zt({runId:e,entries:t}){let[n,r]=(0,L.useState)(()=>Jt.get(e)??Yt());if(t.length===0)return null;let{done:i,total:a}=K(t),o=Xt(t);return(0,z.jsxs)(`section`,{"data-slot":`plan-dock`,"data-state":n?`open`:`collapsed`,className:`min-w-0 overflow-hidden rounded-lg border border-border bg-card shadow-xs`,children:[(0,z.jsx)(`div`,{"aria-hidden":!0,"data-slot":`grad-edge`,className:`h-[3px]`,style:{background:`var(--grad)`}}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>r(t=>(Jt.set(e,!t),!t)),"aria-expanded":n,className:O(`flex w-full items-center gap-2 px-3.5 text-left text-[13px]`,n?`pt-2 pb-1.5`:`py-2`),children:[(0,z.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Plan`}),(0,z.jsxs)(`span`,{"data-slot":`plan-count`,className:`shrink-0 text-muted-foreground tabular-nums`,children:[`· `,i,`/`,a]}),!n&&o!==void 0?(0,z.jsxs)(`span`,{"data-slot":`plan-current`,className:`min-w-0 truncate text-muted-foreground`,children:[`— `,o.activeForm??o.content]}):null,(0,z.jsx)(Fe,{"aria-hidden":!0,className:O(`ml-auto size-3.5 shrink-0 text-soft-foreground transition-transform`,!n&&`rotate-180`)})]}),n?(0,z.jsx)(`ul`,{"data-slot":`plan-list`,className:`flex flex-col gap-[7px] px-3.5 pb-3`,children:t.map((e,t)=>(0,z.jsx)(Qt,{entry:e},`${t}:${e.content}`))}):null]})}function Qt({entry:e}){return(0,z.jsxs)(`li`,{"data-slot":`plan-item`,"data-status":e.status,className:O(`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,z.jsx)($t,{status:e.status}),(0,z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.content}),e.status===`in_progress`?(0,z.jsx)(`span`,{"data-slot":`plan-tag`,className:`ml-auto shrink-0 rounded-full bg-muted px-2 py-0.5 text-[10.5px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:`in progress`}):null]})}function $t({status:e}){return e===`cancelled`?(0,z.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,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`,opacity:`.5`}),(0,z.jsx)(`path`,{d:`m8.5 15.5 7-7`})]}):e===`completed`?(0,z.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,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,z.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`in_progress`?(0,z.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,z.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,z.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]}):(0,z.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,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})})}function en({agent:e,entries:t,onClose:n}){return(0,z.jsx)(Le,{open:e!==void 0,onOpenChange:e=>{e||n()},children:(0,z.jsx)(Ne,{"data-slot":`subagent-sheet`,side:`right`,className:`w-full gap-0 p-0 sm:max-w-xl`,children:e===void 0?null:(0,z.jsx)(tn,{agent:e,entries:t})})})}function tn({agent:e,entries:t}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Me,{className:`gap-1.5 border-b border-border px-5 py-4`,children:[(0,z.jsxs)(ke,{className:`flex min-w-0 items-center gap-2 pr-8 text-[15px]`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title}),e.agentType===void 0?null:(0,z.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-[10.5px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:e.agentType})]}),(0,z.jsxs)(Ie,{"data-slot":`subagent-meta`,className:`flex items-center gap-2 text-xs`,children:[(0,z.jsx)(rn,{status:e.status}),(0,z.jsxs)(`span`,{className:`tabular-nums`,children:[e.toolCalls,` `,e.toolCalls===1?`tool call`:`tool calls`]})]})]}),(0,z.jsx)(nn,{entries:t,scope:e.id})]})}function nn({entries:e,scope:t}){let n=(0,L.useRef)(null),r=(0,L.useRef)(!0);return(0,L.useEffect)(()=>{let e=n.current;e===null||!r.current||(e.scrollTop=e.scrollHeight)},[e.reduce((e,t)=>e+(t.kind===`message`||t.kind===`reasoning`?t.text.length:t.kind===`tool`?(t.output?.length??0)+(t.error?.length??0):0),e.length)]),e.length===0?(0,z.jsx)(`div`,{"data-slot":`subagent-empty`,className:`px-5 py-6 text-[13px] text-muted-foreground`,children:`No attributed output — see the thread card for this agent's result.`}):(0,z.jsx)(`div`,{ref:n,"data-slot":`subagent-stream`,onScroll:e=>{let t=e.currentTarget;r.current=t.scrollHeight-t.scrollTop-t.clientHeight<24},className:`flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto px-5 py-4`,children:e.map(e=>(0,z.jsx)(Ct,{entry:e,scope:`subagent:${t}`},e.id))})}function rn({status:e}){let t=e===`completed`?`Completed`:e===`failed`?`Failed`:e===`declined`?`Declined`:e===`pending`?`Pending`:`Running`;return(0,z.jsx)(`span`,{"data-slot":`subagent-status`,"data-status":e,className:O(`rounded-full px-2 py-0.5 text-[10.5px] 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 an({run:e}){return(0,z.jsxs)(`section`,{"data-slot":`review-panel`,"aria-label":`Review the changes`,className:`flex flex-col gap-3`,children:[(0,z.jsxs)(`div`,{"data-slot":`review-banner`,className:`flex items-center gap-2.5 rounded-md border border-violet/30 bg-violet/10 px-3.5 py-2.5`,children:[(0,z.jsx)(Ae,{className:`size-4 shrink-0 text-violet`,"aria-hidden":`true`}),(0,z.jsxs)(`p`,{className:`min-w-0 text-[13px]`,children:[(0,z.jsx)(`span`,{className:`font-semibold`,children:`Review the changes before anything lands.`}),` `,(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`Read the diff, send notes back, draft a PR — or accept. Nothing merges on its own.`})]})]}),(0,z.jsx)(me,{runId:e.id}),(0,z.jsx)(on,{run:e})]})}function on({run:e}){let t=y(),n=(0,L.useRef)(null),[i,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(null),l=k(e.id),u=()=>t.invalidateQueries({queryKey:r.runs.all}),f=h({mutationFn:t=>w(e.id,{text:`Review feedback:\n${t}`}),onSuccess:()=>{o(``),u()},onError:e=>g(e.message,{tone:`danger`})}),p=h({mutationFn:()=>a(e.id),onSuccess:e=>{g(`Draft PR created — ${e.url}`),u()},onError:e=>{e instanceof T&&e.manual!==void 0&&c(e.manual),g(e.message,{tone:`danger`})}}),m=()=>{let e=i.trim();if(e.length===0){g(`Write what to change first.`),n.current?.focus();return}f.mutate(e)};return(0,z.jsxs)(`div`,{"data-slot":`review-actions`,className:`flex flex-col gap-2`,children:[(0,z.jsx)(pe,{ref:n,"data-slot":`review-notes`,"aria-label":`Notes for the agent`,placeholder:`Notes for the agent — what should change?`,rows:2,value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{_e({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(),m())},className:`min-h-[52px] text-[13px]`}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsxs)(d,{"data-slot":`review-send-back`,variant:`outline`,size:`sm`,title:`Send the notes back into the agent's session`,disabled:f.isPending,onClick:m,children:[(0,z.jsx)(Ve,{"aria-hidden":`true`}),`Send back`]}),ee(e.pullRequestUrl)?(0,z.jsx)(d,{asChild:!0,variant:`outline`,size:`sm`,children:(0,z.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,z.jsx)(le,{"aria-hidden":`true`}),`PR ↗`]})}):(0,z.jsxs)(d,{"data-slot":`review-draft-pr`,variant:`outline`,size:`sm`,title:`Push the branch and open a draft PR`,disabled:p.isPending,onClick:()=>p.mutate(),children:[(0,z.jsx)(ue,{"aria-hidden":`true`}),`Draft PR`]}),(0,z.jsxs)(d,{"data-slot":`review-accept`,variant:`contrast`,size:`sm`,className:`ml-auto`,title:ie(`review`),disabled:l.isPending,onClick:()=>l.mutate(),children:[(0,z.jsx)(_,{"aria-hidden":`true`}),`Accept`]})]}),s===null?null:(0,z.jsx)(sn,{command:s})]})}function sn({command:e}){return(0,z.jsxs)(`button`,{type:`button`,"data-slot":`review-manual`,title:`Copy the command`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>g(`Command copied to clipboard.`)).catch(()=>g(`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,z.jsx)(se,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,z.jsxs)(`span`,{className:`truncate`,children:[`manual path: `,e]})]})}function cn(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var ln=1500;function un({status:e}){let t=(0,L.useRef)(e),[n,r]=(0,L.useState)(!1);return(0,L.useEffect)(()=>{let n=t.current;if(t.current=e,n!==`review`||e!==`done`||cn())return;r(!0);let i=setTimeout(()=>r(!1),ln);return()=>clearTimeout(i)},[e]),n?(0,z.jsxs)(`div`,{"data-slot":`accept-celebration`,"aria-hidden":`true`,className:`pointer-events-none fixed inset-0 isolate z-40`,children:[(0,z.jsx)(b,{}),(0,z.jsx)(`div`,{className:`flex justify-center pt-24`,children:(0,z.jsx)(`span`,{className:`rounded-full border border-violet/30 bg-violet/15 px-4 py-1.5 text-[13px] font-medium text-violet shadow-modal`,children:`✓ Changes accepted`})})]}):null}function dn(e,t){return`${e.header}: ${t.join(`, `)}`}function fn({ask:e,runId:t}){let n=v(t),r=e.questions,i=r.length===1&&r[0]?.multiSelect!==!0,[a,o]=(0,L.useState)({});if(e.resolved)return(0,z.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,z.jsx)(`span`,{className:`text-soft-foreground`,children:`Answered`}),e.answer?(0,z.jsx)(`span`,{className:`ml-1.5 whitespace-pre-line text-foreground`,children:e.answer}):null]});let s=(e,t)=>o(n=>({...n,[e]:t})),c=r.every((e,t)=>(a[t]?.length??0)>0);return(0,z.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,className:`rounded-lg border border-primary/25 bg-primary/[0.04] px-4 pt-3.5 pb-3.5`,children:[(0,z.jsx)(`div`,{className:`mb-2.5 flex items-center gap-2`,children:(0,z.jsx)(`span`,{className:`text-xs font-medium text-primary`,children:`The agent is asking`})}),(0,z.jsx)(`div`,{className:`flex flex-col gap-4`,children:r.map((e,t)=>(0,z.jsx)(pn,{question:e,disabled:n.isPending,selected:a[t]??[],onSelect:r=>{i?n.mutateAsync({text:dn(e,r)}):s(t,r)}},e.id??t))}),i?null:(0,z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2.5`,children:[(0,z.jsx)(d,{size:`sm`,disabled:n.isPending||!c,onClick:()=>void n.mutateAsync({text:r.map((e,t)=>dn(e,a[t]??[])).join(`
5
+ `)}function xt({text:e}){return(0,z.jsx)(`span`,{className:O(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del text-muted-foreground`,e.startsWith(`@@`)&&`text-soft-foreground`),children:e})}function St(e){return e.status===`failed`||e.toolKind===`execute`&&e.status===`running`&&e.output!==void 0}function U({item:e,nested:t=[],cacheKey:n}){let r=rt(),[i,a]=(0,L.useState)(()=>n===void 0?null:r?.get(n)??null),o=e=>{n!==void 0&&r?.set(n,e),a(e)},c=e.status===`running`||e.status===`pending`,l=e.output!==void 0&&e.output!==``||e.error!==void 0&&e.error!==``||e.diffs!==void 0&&e.diffs.length>0||t.length>0,u=l&&(i??St(e)),{verb:d,detail:f}=et(e.title),p=gt[e.toolKind]??I;return(0,z.jsxs)(j,{"data-slot":`tool-card`,"data-status":e.status,"data-kind":e.toolKind,open:u,onOpenChange:o,className:O(`min-w-0 overflow-hidden rounded-md border bg-card`,e.status===`failed`?`border-danger/40`:`border-border`),children:[(0,z.jsxs)(A,{disabled:!l,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,z.jsx)(P,{"aria-hidden":!0,className:O(`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`,!l&&`invisible`)}),(0,z.jsx)(p,{"aria-hidden":!0,className:O(`size-3.5 shrink-0`,e.status===`failed`?`text-danger`:`text-muted-foreground`)}),(0,z.jsx)(`span`,{className:O(`shrink-0 font-semibold`,c&&`shimmer`,e.status===`failed`&&`text-danger`,e.status===`declined`&&`text-muted-foreground`),children:d}),f===void 0?null:(0,z.jsx)(`code`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,children:f}),(0,z.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[c?(0,z.jsx)(s,{role:`status`,"aria-label":`Running`,className:`size-3.5 animate-spin text-soft-foreground`}):null,e.status===`failed`?(0,z.jsx)(`span`,{className:`text-xs text-danger`,children:`failed`}):null,e.status===`declined`?(0,z.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`declined`}):null,e.toolKind===`execute`&&typeof e.exitCode==`number`?(0,z.jsx)(`span`,{"data-slot":`tool-exit`,className:O(`rounded-full px-2 py-px font-mono text-[10.5px] font-semibold`,e.exitCode===0?`bg-success/10 text-success`:`bg-danger/10 text-danger`),children:e.exitCode}):null]})]}),(0,z.jsx)(M,{children:(0,z.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[e.error!==void 0&&e.error!==``?(0,z.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,z.jsx)(yt,{diffs:e.diffs}):null,e.output!==void 0&&e.output!==``?(0,z.jsx)(vt,{text:e.output,streaming:c}):null,t.length>0?(0,z.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:t.map(e=>(0,z.jsx)(Ct,{entry:e,scope:n},e.id))}):null]})})]})}function Ct({entry:e,scope:t}){switch(e.kind){case`message`:return(0,z.jsx)(ft,{text:e.text});case`reasoning`:return(0,z.jsx)(mt,{text:e.text});case`tool`:return(0,z.jsx)(U,{item:e,cacheKey:t===void 0?void 0:`${t}:${e.id}`});case`note`:return(0,z.jsx)(pt,{note:e});case`image`:return(0,z.jsx)(Et,{image:e});case`ask`:return null}}function wt({group:e,scope:t}){return(0,z.jsxs)(j,{"data-slot":`ctx-group`,className:`min-w-0`,children:[(0,z.jsxs)(A,{className:`group flex h-[34px] 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,z.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,z.jsx)(M,{children:(0,z.jsx)(`div`,{className:`flex flex-col gap-1.5 pt-1.5 pl-4`,children:e.tools.map(e=>(0,z.jsx)(U,{item:e,cacheKey:t===void 0?void 0:`${t}:${e.id}`},e.id))})})]})}function Tt({count:e,children:t}){return(0,z.jsxs)(j,{"data-slot":`tool-streak`,className:`min-w-0`,children:[(0,z.jsxs)(A,{className:`group flex items-center gap-1.5 rounded-md p-0.5 text-left text-xs text-soft-foreground hover:text-muted-foreground`,children:[(0,z.jsx)(P,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),Qe(e)]}),(0,z.jsx)(M,{children:(0,z.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t})})]})}function Et({image:e}){return(0,z.jsx)(ze,{"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 Dt(e){let t=y(),n=ae(e).continueRun,a=i(),o=c(),s=x(n),[l,u]=(0,L.useState)(null),[d,f]=(0,L.useState)(null),p=Se(a.data?.checks??[]),m=e.runner??`claude`,g=Pe(l,p,m),_=g===m&&e.model?{...o.data?.defaultModels,[g]:e.model}:o.data?.defaultModels,v=ve(g,s.data,[d,_?.[g]]),b=be(d,g,_,s.data),S=h({mutationFn:({text:t,images:n})=>w(e.id,{text:t.trim()?t:void 0,images:n.length?n:void 0,runner:l===null?void 0:g,model:d===null?void 0:b}),onSuccess:()=>t.invalidateQueries({queryKey:r.runs.all})});return{available:n,pills:(0,z.jsxs)(`div`,{"data-slot":`follow-up-engine`,className:`flex flex-wrap items-center gap-1.5`,children:[p.length>1?(0,z.jsx)(Ce,{runners:p,value:g,onPick:e=>{u(e),f(null)}}):null,(0,z.jsx)(ge,{slot:`follow-up-model-pill`,ariaLabel:`Model`,label:v.find(e=>e.id===b)?.label??`auto`,value:b,onPick:e=>f(e),options:v.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:we(g,s.data,s.isError)})]}),continueWith:(e,t)=>S.mutateAsync({text:e,images:t})}}var Ot=120,W=e=>e!==`pending`&&e!==`running`,kt=e=>e.kind===`tool`&&e.toolKind===`task`,G=e=>kt(e)&&e.parentItemId===void 0,At=e=>(e.kind===`message`||e.kind===`reasoning`||e.kind===`tool`)&&!(e.kind===`tool`&&e.toolKind===`plan`);function jt(e,t){for(let n=0;n<e.length;n+=1)if(e[n].items.some(e=>G(e)&&t.has(e.id)))return n;return 0}function Mt(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 Nt(e){if(e.kind===`tool`)return Pt(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 Pt(n)}}}function Pt(e){return e.length>Ot?`${e.slice(0,Ot-1).trimEnd()}…`:e}function Ft(e,t=!1){let n=Bt(e,e=>e.items.some(G));if(n===-1)return[];let r=e=>!t&&!W(e.status),i=[];for(let t=n-1;t>=0;--t){let n=e[t].items.filter(G);if(n.length!==0){if(!n.some(r))break;i.unshift(...n)}}let a=[...i,...e[n].items.filter(G)];if(n!==e.length-1&&!a.some(r))return[];let o=new Set(a.map(e=>e.id)),s=i.length>0?jt(e,o):n,c=new Map;for(let t=s;t<e.length;t+=1)for(let n of e[t].items){if(!At(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=>It(e,c.get(e.id)??[],t))}function It(e,t,n){let r={id:e.id,title:et(e.title).detail??e.title,status:e.status,toolCalls:t.filter(e=>e.kind===`tool`).length},i=Mt(e);i!==void 0&&(r.agentType=i),n&&!W(e.status)&&(r.stalled=!0);for(let e=t.length-1;e>=0;--e){let n=Nt(t[e]);if(n!==void 0){r.activity=n;break}}return r}function Lt(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.length}}function Rt(e){return e.activity??(e.stalled===!0?`never finished`:`starting…`)}function zt(e){return e.find(e=>!W(e.status))??e[0]}function Bt(e,t){for(let n=e.length-1;n>=0;--n)if(t(e[n]))return n;return-1}function Vt(e,t,n=!1){for(let r=e.length-1;r>=0;--r){let i=e[r].items.find(e=>e.id===t&&G(e));if(i!==void 0)return It(i,Ht(e,t),n)}}function Ht(e,t){let n=e.findIndex(e=>e.items.some(e=>e.id===t&&G(e)));if(n===-1)return[];let r=[];for(let i=n;i<e.length;i+=1)for(let n of e[i].items)At(n)&&n.parentItemId===t&&n.id!==t&&r.push(n);return r}var Ut=new Map;function Wt(){return typeof window.matchMedia!=`function`||window.matchMedia(`(min-width: 768px)`).matches}function Gt({runId:e,agents:t,onSelect:n}){let[r,i]=(0,L.useState)(()=>Ut.get(e)??Wt());if(t.length===0)return null;let{done:a,total:o}=Lt(t),s=zt(t);return(0,z.jsxs)(`section`,{"data-slot":`agents-dock`,"data-state":r?`open`:`collapsed`,className:`min-w-0 overflow-hidden rounded-lg border border-border bg-card shadow-xs`,children:[(0,z.jsx)(`div`,{"aria-hidden":!0,"data-slot":`grad-edge`,className:`h-[3px]`,style:{background:`var(--grad)`}}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>i(t=>(Ut.set(e,!t),!t)),"aria-expanded":r,className:O(`flex w-full items-center gap-2 px-3.5 text-left text-[13px]`,r?`pt-2 pb-1.5`:`py-2`),children:[(0,z.jsx)(Ie,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground`}),(0,z.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Agents`}),(0,z.jsxs)(`span`,{"data-slot":`agents-count`,className:`shrink-0 text-muted-foreground tabular-nums`,children:[`· `,a,`/`,o]}),!r&&s!==void 0?(0,z.jsxs)(`span`,{"data-slot":`agents-current`,className:`min-w-0 truncate text-muted-foreground`,children:[`— `,Rt(s)]}):null,(0,z.jsx)(Me,{"aria-hidden":!0,className:O(`ml-auto size-3.5 shrink-0 text-soft-foreground transition-transform`,!r&&`rotate-180`)})]}),r?(0,z.jsx)(`ul`,{"data-slot":`agents-list`,className:`flex flex-col gap-[7px] px-3.5 pb-3`,children:t.map(e=>(0,z.jsx)(Kt,{agent:e,onSelect:n},e.id))}):null]})}function Kt({agent:e,onSelect:t}){let n=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(qt,{status:e.status,stalled:e.stalled===!0}),(0,z.jsx)(`span`,{className:`min-w-0 shrink truncate font-medium`,children:e.title}),e.agentType===void 0?null:(0,z.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-[10.5px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:e.agentType}),(0,z.jsx)(`span`,{"data-slot":`agent-activity`,className:`min-w-0 flex-1 truncate text-muted-foreground`,children:Rt(e)}),(0,z.jsxs)(`span`,{"data-slot":`agent-tools`,className:`shrink-0 text-muted-foreground tabular-nums`,children:[e.toolCalls,` `,e.toolCalls===1?`tool`:`tools`]})]});return(0,z.jsx)(`li`,{"data-slot":`agent-item`,"data-status":e.status,className:`min-w-0 text-[13px]`,children:t?(0,z.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,z.jsx)(`div`,{className:`flex min-h-5 min-w-0 items-center gap-2.5`,children:n})})}function qt({status:e,stalled:t=!1}){return t?(0,z.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,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})}):e===`completed`?(0,z.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,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,z.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`failed`||e===`declined`?(0,z.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,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,z.jsx)(`path`,{d:`m9 9 6 6M15 9l-6 6`})]}):(0,z.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,z.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,z.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]})}var Jt=new Map;function Yt(){return typeof window.matchMedia!=`function`||window.matchMedia(`(min-width: 768px)`).matches}function K(e){return{done:e.filter(e=>e.status===`completed`).length,total:e.filter(e=>e.status!==`cancelled`).length}}function Xt(e){return e.find(e=>e.status===`in_progress`)??e.find(e=>e.status===`pending`)}function Zt({runId:e,entries:t}){let[n,r]=(0,L.useState)(()=>Jt.get(e)??Yt());if(t.length===0)return null;let{done:i,total:a}=K(t),o=Xt(t);return(0,z.jsxs)(`section`,{"data-slot":`plan-dock`,"data-state":n?`open`:`collapsed`,className:`min-w-0 overflow-hidden rounded-lg border border-border bg-card shadow-xs`,children:[(0,z.jsx)(`div`,{"aria-hidden":!0,"data-slot":`grad-edge`,className:`h-[3px]`,style:{background:`var(--grad)`}}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>r(t=>(Jt.set(e,!t),!t)),"aria-expanded":n,className:O(`flex w-full items-center gap-2 px-3.5 text-left text-[13px]`,n?`pt-2 pb-1.5`:`py-2`),children:[(0,z.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Plan`}),(0,z.jsxs)(`span`,{"data-slot":`plan-count`,className:`shrink-0 text-muted-foreground tabular-nums`,children:[`· `,i,`/`,a]}),!n&&o!==void 0?(0,z.jsxs)(`span`,{"data-slot":`plan-current`,className:`min-w-0 truncate text-muted-foreground`,children:[`— `,o.activeForm??o.content]}):null,(0,z.jsx)(Me,{"aria-hidden":!0,className:O(`ml-auto size-3.5 shrink-0 text-soft-foreground transition-transform`,!n&&`rotate-180`)})]}),n?(0,z.jsx)(`ul`,{"data-slot":`plan-list`,className:`flex flex-col gap-[7px] px-3.5 pb-3`,children:t.map((e,t)=>(0,z.jsx)(Qt,{entry:e},`${t}:${e.content}`))}):null]})}function Qt({entry:e}){return(0,z.jsxs)(`li`,{"data-slot":`plan-item`,"data-status":e.status,className:O(`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,z.jsx)($t,{status:e.status}),(0,z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.content}),e.status===`in_progress`?(0,z.jsx)(`span`,{"data-slot":`plan-tag`,className:`ml-auto shrink-0 rounded-full bg-muted px-2 py-0.5 text-[10.5px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:`in progress`}):null]})}function $t({status:e}){return e===`cancelled`?(0,z.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,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`,opacity:`.5`}),(0,z.jsx)(`path`,{d:`m8.5 15.5 7-7`})]}):e===`completed`?(0,z.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,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`,opacity:`.35`}),(0,z.jsx)(`path`,{d:`m8.5 12.2 2.4 2.4 4.6-5`})]}):e===`in_progress`?(0,z.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,z.jsx)(`circle`,{className:`stroke-pending`,cx:`12`,cy:`12`,r:`8.5`,strokeWidth:`2`}),(0,z.jsx)(`path`,{className:`fill-pending`,d:`M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z`})]}):(0,z.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,z.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.5`})})}function en({agent:e,entries:t,onClose:n}){return(0,z.jsx)(je,{open:e!==void 0,onOpenChange:e=>{e||n()},children:(0,z.jsx)(De,{"data-slot":`subagent-sheet`,side:`right`,className:`w-full gap-0 p-0 sm:max-w-xl`,children:e===void 0?null:(0,z.jsx)(tn,{agent:e,entries:t})})})}function tn({agent:e,entries:t}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(Le,{className:`gap-1.5 border-b border-border px-5 py-4`,children:[(0,z.jsxs)(ke,{className:`flex min-w-0 items-center gap-2 pr-8 text-[15px]`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title}),e.agentType===void 0?null:(0,z.jsx)(`span`,{"data-slot":`agent-type`,className:`shrink-0 rounded-full bg-muted px-2 py-0.5 text-[10.5px] font-semibold tracking-[0.05em] text-muted-foreground uppercase`,children:e.agentType})]}),(0,z.jsxs)(Ne,{"data-slot":`subagent-meta`,className:`flex items-center gap-2 text-xs`,children:[(0,z.jsx)(rn,{status:e.status}),(0,z.jsxs)(`span`,{className:`tabular-nums`,children:[e.toolCalls,` `,e.toolCalls===1?`tool call`:`tool calls`]})]})]}),(0,z.jsx)(nn,{entries:t,scope:e.id})]})}function nn({entries:e,scope:t}){let n=(0,L.useRef)(null),r=(0,L.useRef)(!0);return(0,L.useEffect)(()=>{let e=n.current;e===null||!r.current||(e.scrollTop=e.scrollHeight)},[e.reduce((e,t)=>e+(t.kind===`message`||t.kind===`reasoning`?t.text.length:t.kind===`tool`?(t.output?.length??0)+(t.error?.length??0):0),e.length)]),e.length===0?(0,z.jsx)(`div`,{"data-slot":`subagent-empty`,className:`px-5 py-6 text-[13px] text-muted-foreground`,children:`No attributed output — see the thread card for this agent's result.`}):(0,z.jsx)(`div`,{ref:n,"data-slot":`subagent-stream`,onScroll:e=>{let t=e.currentTarget;r.current=t.scrollHeight-t.scrollTop-t.clientHeight<24},className:`flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto px-5 py-4`,children:e.map(e=>(0,z.jsx)(Ct,{entry:e,scope:`subagent:${t}`},e.id))})}function rn({status:e}){let t=e===`completed`?`Completed`:e===`failed`?`Failed`:e===`declined`?`Declined`:e===`pending`?`Pending`:`Running`;return(0,z.jsx)(`span`,{"data-slot":`subagent-status`,"data-status":e,className:O(`rounded-full px-2 py-0.5 text-[10.5px] 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 an({run:e}){return(0,z.jsxs)(`section`,{"data-slot":`review-panel`,"aria-label":`Review the changes`,className:`flex flex-col gap-3`,children:[(0,z.jsxs)(`div`,{"data-slot":`review-banner`,className:`flex items-center gap-2.5 rounded-md border border-violet/30 bg-violet/10 px-3.5 py-2.5`,children:[(0,z.jsx)(Fe,{className:`size-4 shrink-0 text-violet`,"aria-hidden":`true`}),(0,z.jsxs)(`p`,{className:`min-w-0 text-[13px]`,children:[(0,z.jsx)(`span`,{className:`font-semibold`,children:`Review the changes before anything lands.`}),` `,(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`Read the diff, send notes back, draft a PR — or accept. Nothing merges on its own.`})]})]}),(0,z.jsx)(me,{runId:e.id}),(0,z.jsx)(on,{run:e})]})}function on({run:e}){let t=y(),n=(0,L.useRef)(null),[i,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(null),l=k(e.id),u=()=>t.invalidateQueries({queryKey:r.runs.all}),f=h({mutationFn:t=>w(e.id,{text:`Review feedback:\n${t}`}),onSuccess:()=>{o(``),u()},onError:e=>g(e.message,{tone:`danger`})}),p=h({mutationFn:()=>a(e.id),onSuccess:e=>{g(`Draft PR created — ${e.url}`),u()},onError:e=>{e instanceof T&&e.manual!==void 0&&c(e.manual),g(e.message,{tone:`danger`})}}),m=()=>{let e=i.trim();if(e.length===0){g(`Write what to change first.`),n.current?.focus();return}f.mutate(e)};return(0,z.jsxs)(`div`,{"data-slot":`review-actions`,className:`flex flex-col gap-2`,children:[(0,z.jsx)(pe,{ref:n,"data-slot":`review-notes`,"aria-label":`Notes for the agent`,placeholder:`Notes for the agent — what should change?`,rows:2,value:i,onChange:e=>o(e.target.value),onKeyDown:e=>{_e({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(),m())},className:`min-h-[52px] text-[13px]`}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsxs)(d,{"data-slot":`review-send-back`,variant:`outline`,size:`sm`,title:`Send the notes back into the agent's session`,disabled:f.isPending,onClick:m,children:[(0,z.jsx)(Ve,{"aria-hidden":`true`}),`Send back`]}),ee(e.pullRequestUrl)?(0,z.jsx)(d,{asChild:!0,variant:`outline`,size:`sm`,children:(0,z.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,z.jsx)(le,{"aria-hidden":`true`}),`PR ↗`]})}):(0,z.jsxs)(d,{"data-slot":`review-draft-pr`,variant:`outline`,size:`sm`,title:`Push the branch and open a draft PR`,disabled:p.isPending,onClick:()=>p.mutate(),children:[(0,z.jsx)(ue,{"aria-hidden":`true`}),`Draft PR`]}),(0,z.jsxs)(d,{"data-slot":`review-accept`,variant:`contrast`,size:`sm`,className:`ml-auto`,title:ie(`review`),disabled:l.isPending,onClick:()=>l.mutate(),children:[(0,z.jsx)(_,{"aria-hidden":`true`}),`Accept`]})]}),s===null?null:(0,z.jsx)(sn,{command:s})]})}function sn({command:e}){return(0,z.jsxs)(`button`,{type:`button`,"data-slot":`review-manual`,title:`Copy the command`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>g(`Command copied to clipboard.`)).catch(()=>g(`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,z.jsx)(se,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,z.jsxs)(`span`,{className:`truncate`,children:[`manual path: `,e]})]})}function cn(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}var ln=1500;function un({status:e}){let t=(0,L.useRef)(e),[n,r]=(0,L.useState)(!1);return(0,L.useEffect)(()=>{let n=t.current;if(t.current=e,n!==`review`||e!==`done`||cn())return;r(!0);let i=setTimeout(()=>r(!1),ln);return()=>clearTimeout(i)},[e]),n?(0,z.jsxs)(`div`,{"data-slot":`accept-celebration`,"aria-hidden":`true`,className:`pointer-events-none fixed inset-0 isolate z-40`,children:[(0,z.jsx)(b,{}),(0,z.jsx)(`div`,{className:`flex justify-center pt-24`,children:(0,z.jsx)(`span`,{className:`rounded-full border border-violet/30 bg-violet/15 px-4 py-1.5 text-[13px] font-medium text-violet shadow-modal`,children:`✓ Changes accepted`})})]}):null}function dn(e,t){return`${e.header}: ${t.join(`, `)}`}function fn({ask:e,runId:t}){let n=v(t),r=e.questions,i=r.length===1&&r[0]?.multiSelect!==!0,[a,o]=(0,L.useState)({});if(e.resolved)return(0,z.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,z.jsx)(`span`,{className:`text-soft-foreground`,children:`Answered`}),e.answer?(0,z.jsx)(`span`,{className:`ml-1.5 whitespace-pre-line text-foreground`,children:e.answer}):null]});let s=(e,t)=>o(n=>({...n,[e]:t})),c=r.every((e,t)=>(a[t]?.length??0)>0);return(0,z.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,className:`rounded-lg border border-primary/25 bg-primary/[0.04] px-4 pt-3.5 pb-3.5`,children:[(0,z.jsx)(`div`,{className:`mb-2.5 flex items-center gap-2`,children:(0,z.jsx)(`span`,{className:`text-xs font-medium text-primary`,children:`The agent is asking`})}),(0,z.jsx)(`div`,{className:`flex flex-col gap-4`,children:r.map((e,t)=>(0,z.jsx)(pn,{question:e,disabled:n.isPending,selected:a[t]??[],onSelect:r=>{i?n.mutateAsync({text:dn(e,r)}):s(t,r)}},e.id??t))}),i?null:(0,z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2.5`,children:[(0,z.jsx)(d,{size:`sm`,disabled:n.isPending||!c,onClick:()=>void n.mutateAsync({text:r.map((e,t)=>dn(e,a[t]??[])).join(`
7
7
  `)}),children:`Send answer`}),(0,z.jsxs)(`span`,{className:`text-[11.5px] text-soft-foreground`,children:[r.length>1?`answer each question`:`pick one or more`,` — or type a reply below`]})]})]})}function pn({question:e,disabled:t,selected:n,onSelect:r}){let i=e.multiSelect===!0,a=e=>{if(!i){r([e]);return}r(n.includes(e)?n.filter(t=>t!==e):[...n,e])};return(0,z.jsxs)(`div`,{role:`group`,"aria-label":e.question,children:[(0,z.jsxs)(`div`,{className:`mb-0.5 flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`rounded-md bg-primary px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-primary-foreground`,children:e.header}),i?(0,z.jsx)(`span`,{className:`ml-auto text-[10.5px] text-soft-foreground`,children:`select all that apply`}):null]}),(0,z.jsx)(`p`,{className:`mb-2.5 text-sm font-semibold text-foreground`,children:e.question}),(0,z.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.options.map(e=>{let r=n.includes(e.label);return(0,z.jsxs)(`button`,{type:`button`,disabled:t,"aria-pressed":r,onClick:()=>a(e.label),className:O(`flex w-full flex-col gap-0.5 rounded-md border px-3.5 py-2.5 text-left transition-colors`,`hover:border-primary/50 hover:bg-primary/[0.06] disabled:pointer-events-none disabled:opacity-50`,r?`border-primary/60 bg-primary/[0.06]`:`border-border bg-card`),children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2 text-[13.5px] font-semibold text-foreground`,children:[i?(0,z.jsx)(`span`,{"aria-hidden":!0,className:O(`flex size-4 items-center justify-center rounded border text-[10px]`,r?`border-primary bg-primary text-primary-foreground`:`border-soft-foreground`),children:r?`✓`:``}):null,e.label]}),e.description?(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.description}):null]},e.label)})})]})}function mn(e){let t=(0,L.useRef)(null),[n,r]=(0,L.useState)(null),[i,a]=(0,L.useState)(!1),o=(0,L.useRef)(!0),s=(0,L.useRef)(null),c=(0,L.useRef)(null),l=(0,L.useRef)(null),u=(0,L.useCallback)(e=>{r(e),e&&(t.current=e.closest(`[data-slot="main"]`))},[]),d=(0,L.useCallback)(e=>{let n=t.current;if(!n)return;let r=l.current;r?r.scrollTo(e):n.scrollTop=e},[]),f=(0,L.useCallback)(()=>{let e=t.current;e&&d(e.scrollHeight-e.clientHeight)},[d]),p=(0,L.useCallback)(()=>{o.current&&f()},[f]),m=(0,L.useCallback)(()=>{let e=t.current;e&&(s.current=null,o.current=!0,e.scrollTo({top:e.scrollHeight-e.clientHeight,behavior:`smooth`}))},[]);return(0,L.useEffect)(()=>{let r=t.current,i=n;if(!r||!i)return;if(c.current!==e){c.current=e;let t=ct(e);t&&!t.atBottom?(o.current=!1,s.current=t.top,r.scrollTop=t.top):(o.current=!0,f())}let l=0,u=null,p=()=>{s.current=null,o.current=!1,l=0},m=()=>{l=Date.now()},h=e=>{e.deltaY<0?p():m()},g=e=>{[`ArrowUp`,`PageUp`,`Home`].includes(e.key)?p():[`ArrowDown`,`PageDown`,`End`].includes(e.key)&&m()},_=()=>{V(r,80)||(p(),m())},v=e=>{u=e.touches[0]?.clientY??null},y=e=>{let t=e.touches[0]?.clientY;t!==void 0&&(u!==null&&t>u+1?p():u!==null&&t<u-1&&m(),u=t)},b=()=>{let t=V(r,80);t&&s.current===null&&(o.current||Date.now()-l<2e3)&&(o.current=!0),a(!t),s.current===null&&st(e,{top:r.scrollTop,atBottom:t})};r.addEventListener(`scroll`,b,{passive:!0}),r.addEventListener(`wheel`,h,{passive:!0}),r.addEventListener(`touchstart`,v,{passive:!0}),r.addEventListener(`touchmove`,y,{passive:!0}),r.addEventListener(`pointerdown`,_,{passive:!0}),r.addEventListener(`keydown`,g);let x;return typeof ResizeObserver<`u`&&(x=new ResizeObserver(()=>{let e=s.current;if(e!==null){let t=r.scrollHeight-r.clientHeight;d(Math.min(e,t)),t>=e&&(s.current=null)}else o.current&&f()}),x.observe(i)),()=>{r.removeEventListener(`scroll`,b),r.removeEventListener(`wheel`,h),r.removeEventListener(`touchstart`,v),r.removeEventListener(`touchmove`,y),r.removeEventListener(`pointerdown`,_),r.removeEventListener(`keydown`,g),x?.disconnect()}},[e,n,d,f]),{attachContent:u,scrollElRef:t,virtualizerRef:l,pillVisible:i,jumpToLatest:m,restickIfStuck:p}}function hn({runId:e,rows:t,mode:n,controls:r}){return n===`virtual`?(0,z.jsx)(gn,{runId:e,rows:t,controls:r}):(0,z.jsx)(`div`,{ref:r.attachContent,"data-slot":`thread-rows`,"data-virtualized":`false`,children:t.map(e=>(0,z.jsx)(`div`,{"data-slot":`thread-row`,className:`flex w-full flex-col pb-2.5 [contain-intrinsic-block-size:auto_3rem] [content-visibility:auto]`,children:e.node},e.key))})}function gn({runId:e,rows:t,controls:n}){let r=(0,L.useRef)(null),[i]=(0,L.useState)(()=>dt(e,t.length)),a=(0,L.useRef)(t.length);a.current=t.length;let o=(0,L.useRef)(null),s=(0,L.useCallback)(t=>{n.virtualizerRef.current=t,t?o.current=t:o.current&&=(ut(e,{rows:a.current,cache:o.current.cache}),null)},[e,n.virtualizerRef]),[c,l]=(0,L.useState)(0);return(0,L.useLayoutEffect)(()=>{let e=()=>{let e=r.current,t=n.scrollElRef.current;!e||!t||l(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,z.jsx)(`div`,{ref:e=>{r.current=e,n.attachContent(e)},"data-slot":`thread-rows`,"data-virtualized":`true`,children:(0,z.jsx)(Re,{ref:s,scrollRef:n.scrollElRef,startMargin:c,...i===void 0?{}:{cache:i},children:t.map(e=>(0,z.jsx)(`div`,{"data-slot":`thread-row`,className:`flex w-full flex-col pb-2.5`,children:e.node},e.key))})})}function _n({onJump:e}){return(0,z.jsxs)(`button`,{type:`button`,"data-slot":`jump-to-latest`,onClick:e,className:`pointer-events-auto inline-flex min-h-8 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,z.jsx)(Oe,{"aria-hidden":!0,className:`size-3.5`}),`Jump to latest`]})}var vn=120;function q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function J(e){let t=e.replace(/\s+/g,` `).trim();return t.length>vn?`${t.slice(0,vn-1)}…`:t}function Y(e,...t){if(q(e))for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim()!==``)return J(t)}}function yn(e){if(!q(e))return;let t=e.command;if(typeof t==`string`&&t.trim()!==``)return J(t);if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return J(e.join(` `))}}function bn(e){if(!q(e)||!Array.isArray(e.changes))return[];let t=[];for(let n of e.changes)q(n)&&typeof n.path==`string`&&n.path.trim()!==``&&t.push(n.path);return t}function xn(e){return Y(e,`description`,`query`,`url`,`filePath`,`file_path`,`path`,`pattern`,`name`)}function X(e,t){return t?`${e} ${t}`:e}function Sn(e,t){let n=typeof e==`string`?e.toLowerCase():``;switch(n){case`bash`:case`commandexecution`:return{toolKind:`execute`,title:X(`Ran`,yn(t)),subtitle:Y(t,`description`)};case`edit`:case`multiedit`:return{toolKind:`edit`,title:X(`Edit`,Y(t,`file_path`,`filePath`,`path`))};case`write`:return{toolKind:`edit`,title:X(`Write`,Y(t,`file_path`,`filePath`,`path`))};case`notebookedit`:return{toolKind:`edit`,title:X(`Edit`,Y(t,`notebook_path`,`notebookPath`,`file_path`,`filePath`,`path`))};case`filechange`:{let e=bn(t);return{toolKind:`edit`,title:X(`Edit`,e.length===1?e[0]:e.length>1?`${e.length} files`:void 0)}}case`read`:return{toolKind:`read`,title:X(`Read`,Y(t,`file_path`,`filePath`,`path`))};case`imageview`:return{toolKind:`read`,title:X(`View image`,Y(t,`path`))};case`glob`:case`grep`:return{toolKind:`search`,title:X(`Search`,Y(t,`pattern`,`query`)),subtitle:Y(t,`path`)};case`webfetch`:return{toolKind:`fetch`,title:X(`Fetch`,Y(t,`url`))};case`websearch`:return{toolKind:`fetch`,title:X(`Web search`,Y(t,`query`))};case`task`:case`agent`:{let e=n===`agent`?`Agent`:`Task`,r=Y(t,`subagent_type`,`subagentType`),i=Y(t,`description`,`prompt`)??r;return{toolKind:`task`,title:i?`${e}: ${i}`:e,subtitle:i===r?void 0:r}}case`skill`:{let e=Y(t,`skill`,`name`,`command`);return{toolKind:`task`,title:e?`Skill: ${e}`:`Skill`,subtitle:Y(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=Y(t,`server`),n=Y(t,`tool`);return e&&n?{toolKind:`other`,title:`${e}.${n}`}:{toolKind:`other`,title:`MCP tool`,subtitle:xn(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()!==``?J(e):`Tool`,subtitle:xn(t)}}function Cn(e){for(let t=e.turns.length-1;t>=0;--t){let n=e.turns[t].planEntries;if(n!==void 0)return n}}function wn(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 Tn(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 Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Q(e){return typeof e==`string`?e:void 0}function $(e){let t=e.replace(/\s*CEZ:DONE\s*$/,``).replace(/\s*CEZ:MONITORING\s*$/,``).replace(/\s*CEZ:ASK[ \t]+\{[\s\S]*\}\s*$/,``);return t.includes(`CEZ:`)?t.split(`
8
8
  `).filter(e=>!/^CEZ:(?:PR=\d+|ISSUE=\d+|TITLE=.+)\s*$/.test(e)).join(`
9
- `):t}function En(e){let t=e=>$(e).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 Dn(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e)}catch{return String(e)}}var On=e=>e.kind===`message`||e.kind===`reasoning`||e.kind===`tool`,kn=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function An(e){if(!Z(e)||!Array.isArray(e.todos))return;let t=[];for(let n of e.todos){if(!Z(n)||typeof n.content!=`string`)return;t.push({content:n.content,status:kn.has(n.status)?n.status:`pending`,...typeof n.activeForm==`string`?{activeForm:n.activeForm}:{}})}return t}function jn(e){let t=[],n=new Map,r,i=0,a,o=()=>{i+=1;let e={id:`turn-${i}`,entries:[],v2Items:!1};return t.push(e),e},s=()=>t.at(-1)??o(),c=(e,t)=>{let n=Q(e.stepId);return n===void 0?t:`${n}:${t}`},l=(e,t,r)=>{let i={...t};if(!e.v2Items){e.v2Items=!0;for(let t of e.entries)t.origin===`v1`&&t.entry.kind===`tool`&&n.delete(t.entry.id);e.entries=e.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`tool`))}let a=n.get(r);if(a&&a.turn===e){a.entry.entry=i,n.set(r,a);return}let o={origin:`v2`,entry:i};e.entries.push(o),n.set(r,{turn:e,entry:o})};for(let i of e)switch(i.type){case`user-message`:{let e=Q(i.text)??``;a&&!a.resolved&&(a.resolved=!0,e!==``&&(a.answer=e),a=void 0);let t=o();t.userMessage={text:e,imageCount:typeof i.imageCount==`number`?i.imageCount:0,images:Array.isArray(i.images)?i.images.filter(e=>typeof e==`string`):[]};break}case`turn.started`:{let e=Q(i.turnId),n=t.at(-1);n&&n.turnId===void 0&&!n.v2Items?n.turnId=e:o().turnId=e;break}case`turn.completed`:{let e=Q(i.turnId),n;for(let r=t.length-1;r>=0&&!n;--r)t[r].turnId===e&&(n=t[r]);let r=n??t.at(-1);r&&(r.completed={stopReason:Q(i.stopReason)??`end_turn`,...typeof i.costUsd==`number`?{costUsd:i.costUsd}:{}});break}case`item.started`:case`item.updated`:case`item.completed`:{if(!Z(i.item))break;let e=i.item.kind,t=i.item.id;if(e!==`message`&&e!==`reasoning`&&e!==`tool`||typeof t!=`string`||t===``)break;let r=i.item,a=c(i,r.id);l(n.get(a)?.turn??s(),r,a);break}case`item.delta`:{let e=Q(i.itemId)??``,t=n.get(c(i,e)),r=Q(i.delta)??``;if(!t||r===``||!On(t.entry.entry))break;let a=t.entry.entry;i.field===`output`&&a.kind===`tool`?a.output=(a.output??``)+r:i.field!==`output`&&a.kind!==`tool`&&(a.text+=r);break}case`text`:{let e=s(),t=Q(i.text)??``;if(t===``)break;e.entries.push({origin:`v1`,entry:{kind:`message`,id:`v1:${i.seq}`,role:`assistant`,text:t}});break}case`tool-call`:{let e=s();if(e.v2Items)break;let t=Q(i.tool)??`Tool`,r=Sn(t,i.input);if(r.toolKind===`plan`){let t=An(i.input);t!==void 0&&(e.planEntries=t)}let a={kind:`tool`,id:Q(i.id)??`v1:${i.seq}`,name:t,toolKind:r.toolKind,title:r.title,status:`running`,input:i.input},o={origin:`v1`,entry:a};e.entries.push(o),n.set(a.id,{turn:e,entry:o});break}case`tool-result`:{let e=n.get(Q(i.toolCallId)??``);if(!e||e.turn.v2Items||e.entry.origin!==`v1`)break;let t=e.entry.entry;if(t.kind!==`tool`)break;t.status=`completed`,t.output=Dn(i.result);break}case`note`:case`lifecycle`:{let e=Q(i.message)??``;if(e===``)break;s().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${i.seq}`,text:e,tone:`dim`}});break}case`error`:{let e=Q(i.message)??``;if(e===``)break;s().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${i.seq}`,text:e,tone:`danger`}});break}case`session.error`:{let e=Q(i.message)??``;if(e===``)break;s().entries.push({origin:`meta`,entry:{kind:`note`,id:`v2:${i.seq}`,text:e,tone:`danger`}});break}case`step-end`:{if(i.status!==`failed`)break;let e=Q(i.error)?` — ${Q(i.error)}`:``;s().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${i.seq}`,text:`step ${Q(i.stepId)??`?`} failed${e}`,tone:`danger`}});break}case`check-output`:{let e=Q(i.command)??`check`,t=typeof i.exitCode==`number`?i.exitCode:-1,n={kind:`tool`,id:`v1:${i.seq}`,name:`check`,toolKind:`execute`,title:`Ran ${e}`,status:t===0?`completed`:`failed`,output:Q(i.text)??``,exitCode:t};s().entries.push({origin:`meta`,entry:n});break}case`image`:{let e=Q(i.url);if(e===void 0)break;let t={kind:`image`,id:`v1:${i.seq}`,url:e},n=Q(i.name);n!==void 0&&(t.name=n),s().entries.push({origin:`meta`,entry:t});break}case`plan.updated`:Array.isArray(i.entries)&&(s().planEntries=i.entries);break;case`session.ended`:r={reason:Q(i.reason)??`end_turn`,...Q(i.message)===void 0?{}:{message:Q(i.message)}};break;case`ask.requested`:{let e=Q(i.requestId);if(e===void 0||!Array.isArray(i.questions))break;let t=i.questions.filter(e=>Z(e)&&typeof e.header==`string`&&Array.isArray(e.options));if(t.length===0)break;let n={kind:`ask`,id:e,questions:t,resolved:!1};s().entries.push({origin:`meta`,entry:n}),a=n;break}case`step-start`:case`token-usage`:case`cost`:case`turn-end`:case`done`:case`session`:break;default:break}for(let e of t){if(!e.v2Items)continue;let t=new Set;for(let{origin:n,entry:r}of e.entries)n===`v2`&&r.kind===`message`&&t.add($(r.text).trim());t.size!==0&&(e.entries=e.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`message`&&t.has($(e.entry.text).trim()))),En(e))}return{turns:t.map(e=>({id:e.id,...e.turnId===void 0?{}:{turnId:e.turnId},...e.userMessage===void 0?{}:{userMessage:e.userMessage},...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:$(e.text)}:e)})),...r===void 0?{}:{sessionEnded:r}}}function Mn(){let{id:e}=C(),t=m(e),n=Je(e),r=(0,L.useMemo)(()=>jn(n),[n]);if(t.isPending)return(0,z.jsx)(De,{});if(t.isError){let e=t.error instanceof T&&t.error.status===404;return(0,z.jsx)(`div`,{"data-route":`task-thread`,className:`flex min-h-full flex-col`,children:(0,z.jsx)(S,{icon:e?(0,z.jsx)(de,{}):(0,z.jsx)(We,{}),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,z.jsx)(d,{asChild:!0,variant:`outline`,children:(0,z.jsx)(he,{to:`/`,children:`Back to tasks`})})})})}return(0,z.jsx)(Pn,{run:t.data,thread:r})}function Nn(e,t,n){let r=[];e.task&&r.push({key:`task`,node:(0,z.jsx)(H,{text:e.task,images:e.taskImages??[],onEdit:n?n.onEditTask:void 0,editLabel:`Edit the prompt`})});for(let t of e.queuedMessages??[])r.push({key:`queued:${t.id}`,node:(0,z.jsx)(H,{text:t.text,images:t.images??[],onEdit:n?e=>n.onEditMessage(t.id,e):void 0,onRemove:n?()=>n.onRemoveMessage(t.id):void 0})});for(let n of t.turns){n.userMessage&&r.push({key:`${n.id}:user`,node:(0,z.jsx)(H,{text:n.userMessage.text,imageCount:n.userMessage.imageCount,images:n.userMessage.images})});for(let t of tt(n.items))r.push({key:`${n.id}:${t.id}`,node:(0,z.jsx)(In,{block:t,scope:n.id,runId:e.id})})}return r}function Pn({run:e,thread:t}){let n=Tn(e.status,e.error),r=Cn(t),i=r!==void 0&&r.length>0?K(r):void 0,a=e.status===`running`||e.status===`waiting`,s=e.status===`queued`,c=Dt(e),d=!a&&!s&&c.available,p=!a&&e.status!==`queued`,m=(0,L.useMemo)(()=>Ft(t.turns,p),[t.turns,p]),[h,g]=(0,L.useState)(void 0),[_,y]=(0,L.useState)(e.id);_!==e.id&&(y(e.id),g(void 0));let b=(0,L.useMemo)(()=>h===void 0?void 0:Vt(t.turns,h,p),[t.turns,h,p]),x=(0,L.useMemo)(()=>h===void 0?[]:Ht(t.turns,h),[t.turns,h]),S=v(e.id),{mutateAsync:C}=l(e.id),{mutateAsync:w}=o(e.id),{mutateAsync:T}=u(e.id),E=(0,L.useMemo)(()=>s?{onEditTask:async e=>{await C({task:e})},onEditMessage:(e,t)=>w({msgId:e,message:{text:t}}).then(()=>void 0),onRemoveMessage:e=>T(e).then(()=>void 0)}:void 0,[s,C,w,T]),D=(0,L.useMemo)(()=>Nn(e,t,E),[e,t,E]),{search:te}=f(),ne=at(te,D.length),k=mn(e.id);return ye(k.restickIfStuck),(0,z.jsxs)(`div`,{"data-route":`task-thread`,className:`flex min-h-full flex-col`,children:[(0,z.jsx)(oe,{run:e,planTally:i}),(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[820px] flex-1 flex-col gap-3.5 px-4 py-5 md:px-6`,children:[(0,z.jsx)(it,{runId:e.id,children:(0,z.jsx)(hn,{runId:e.id,rows:D,mode:ne,controls:k})}),t.turns.length===0?e.status===`queued`?(0,z.jsx)(Fn,{run:e}):(0,z.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`?(0,z.jsx)(ht,{}):null,n&&n.state===`closed`?(0,z.jsxs)(`div`,{"data-slot":`thread-footer`,"data-state":n.state,className:O(`mt-auto flex items-center gap-2 border-t border-border pt-3 text-xs`,n.tone===`danger`?`text-danger`:`text-soft-foreground`),children:[n.label,ee(Se(e))?(0,z.jsx)(`a`,{"data-slot":`pr-link`,href:Se(e),target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`PR ↗`}):null]}):null,e.status===`review`?(0,z.jsx)(an,{run:e}):null]}),(0,z.jsx)(un,{status:e.status}),(0,z.jsx)(it,{runId:e.id,children:(0,z.jsx)(en,{agent:b,entries:x,onClose:()=>g(void 0)})}),(0,z.jsxs)(`div`,{"data-slot":`thread-dock`,className:`sticky bottom-[var(--kb,0px)] z-10 bg-background px-4 pt-1.5 pb-3 max-md:border-t max-md:border-border md:px-6 md:pb-4`,children:[k.pillVisible?(0,z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 -top-12 flex justify-center`,children:(0,z.jsx)(_n,{onJump:k.jumpToLatest})}):null,(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[820px] flex-col gap-2.5`,children:[(0,z.jsx)(Gt,{runId:e.id,agents:m,onSelect:g},`agents:${e.id}`),r!==void 0&&r.length>0?(0,z.jsx)(Zt,{runId:e.id,entries:r},e.id):null,e.status===`waiting`?(0,z.jsxs)(`div`,{"data-slot":`paused-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,z.jsx)(N,{tone:`pending`,pulse:!0}),`The agent is paused, waiting for your reply`]}):null,s?(0,z.jsxs)(`div`,{"data-slot":`queued-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,z.jsx)(N,{tone:`pending`}),`Messages you add now are folded into the prompt before the run starts.`]}):null,(0,z.jsx)(Ce,{onSubmit:d?(e,t)=>c.continueWith(e,t):(e,t)=>S.mutateAsync({text:e,images:t}),disabled:!a&&!s&&!d,disabledReason:`Session closed — no session to resume.`,footerEnd:d?c.pills:void 0,allowEmptySubmit:d,sendAriaLabel:d?`Continue`:`Send`,placeholder:s?`Add to the prompt — sent when the run starts…`:d?`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:()=>wn(t)})]})]})]})}function Fn({run:e}){let t=re(p().data??[],e.id);return(0,z.jsxs)(`div`,{"data-slot":`queued-state`,className:`flex flex-col items-center gap-1.5 py-10 text-center`,children:[(0,z.jsx)(N,{tone:`pending`,pulse:!0}),(0,z.jsxs)(`p`,{className:`text-[13px] font-medium`,children:[`Waiting for a free agent slot`,t===void 0?``:` — #${t} in queue`]}),(0,z.jsxs)(`p`,{className:`text-xs text-soft-foreground`,children:[e.workflow,` · starts automatically when a slot frees up`]})]})}function In({block:e,scope:t,runId:n}){switch(e.kind){case`entry`:return(0,z.jsx)(Ln,{entry:e.entry,scope:t,runId:n});case`tool-card`:return(0,z.jsx)(U,{item:e.item,nested:e.children,cacheKey:`${t}:${e.id}`});case`context-group`:return(0,z.jsx)(wt,{group:e,scope:t});case`streak`:return(0,z.jsx)(Tt,{count:e.count,children:e.blocks.map(e=>(0,z.jsx)(In,{block:e,scope:t,runId:n},e.id))})}}function Ln({entry:e,scope:t,runId:n}){switch(e.kind){case`message`:return e.role===`assistant`?(0,z.jsx)(ft,{text:e.text}):(0,z.jsx)(H,{text:e.text});case`reasoning`:return(0,z.jsx)(mt,{text:e.text});case`tool`:return(0,z.jsx)(U,{item:e,cacheKey:`${t}:${e.id}`});case`note`:return(0,z.jsx)(pt,{note:e});case`image`:return(0,z.jsx)(Et,{image:e});case`ask`:return(0,z.jsx)(fn,{ask:e,runId:n})}}export{Mn as TaskThreadRoute};
9
+ `):t}function En(e){let t=e=>$(e).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 Dn(e){if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e)}catch{return String(e)}}var On=e=>e.kind===`message`||e.kind===`reasoning`||e.kind===`tool`,kn=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function An(e){if(!Z(e)||!Array.isArray(e.todos))return;let t=[];for(let n of e.todos){if(!Z(n)||typeof n.content!=`string`)return;t.push({content:n.content,status:kn.has(n.status)?n.status:`pending`,...typeof n.activeForm==`string`?{activeForm:n.activeForm}:{}})}return t}function jn(e){let t=[],n=new Map,r,i=0,a,o=()=>{i+=1;let e={id:`turn-${i}`,entries:[],v2Items:!1};return t.push(e),e},s=()=>t.at(-1)??o(),c=(e,t)=>{let n=Q(e.stepId);return n===void 0?t:`${n}:${t}`},l=(e,t,r)=>{let i={...t};if(!e.v2Items){e.v2Items=!0;for(let t of e.entries)t.origin===`v1`&&t.entry.kind===`tool`&&n.delete(t.entry.id);e.entries=e.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`tool`))}let a=n.get(r);if(a&&a.turn===e){a.entry.entry=i,n.set(r,a);return}let o={origin:`v2`,entry:i};e.entries.push(o),n.set(r,{turn:e,entry:o})};for(let i of e)switch(i.type){case`user-message`:{let e=Q(i.text)??``;a&&!a.resolved&&(a.resolved=!0,e!==``&&(a.answer=e),a=void 0);let t=o();t.userMessage={text:e,imageCount:typeof i.imageCount==`number`?i.imageCount:0,images:Array.isArray(i.images)?i.images.filter(e=>typeof e==`string`):[]};break}case`turn.started`:{let e=Q(i.turnId),n=t.at(-1);n&&n.turnId===void 0&&!n.v2Items?n.turnId=e:o().turnId=e;break}case`turn.completed`:{let e=Q(i.turnId),n;for(let r=t.length-1;r>=0&&!n;--r)t[r].turnId===e&&(n=t[r]);let r=n??t.at(-1);r&&(r.completed={stopReason:Q(i.stopReason)??`end_turn`,...typeof i.costUsd==`number`?{costUsd:i.costUsd}:{}});break}case`item.started`:case`item.updated`:case`item.completed`:{if(!Z(i.item))break;let e=i.item.kind,t=i.item.id;if(e!==`message`&&e!==`reasoning`&&e!==`tool`||typeof t!=`string`||t===``)break;let r=i.item,a=c(i,r.id);l(n.get(a)?.turn??s(),r,a);break}case`item.delta`:{let e=Q(i.itemId)??``,t=n.get(c(i,e)),r=Q(i.delta)??``;if(!t||r===``||!On(t.entry.entry))break;let a=t.entry.entry;i.field===`output`&&a.kind===`tool`?a.output=(a.output??``)+r:i.field!==`output`&&a.kind!==`tool`&&(a.text+=r);break}case`text`:{let e=s(),t=Q(i.text)??``;if(t===``)break;e.entries.push({origin:`v1`,entry:{kind:`message`,id:`v1:${i.seq}`,role:`assistant`,text:t}});break}case`tool-call`:{let e=s();if(e.v2Items)break;let t=Q(i.tool)??`Tool`,r=Sn(t,i.input);if(r.toolKind===`plan`){let t=An(i.input);t!==void 0&&(e.planEntries=t)}let a={kind:`tool`,id:Q(i.id)??`v1:${i.seq}`,name:t,toolKind:r.toolKind,title:r.title,status:`running`,input:i.input},o={origin:`v1`,entry:a};e.entries.push(o),n.set(a.id,{turn:e,entry:o});break}case`tool-result`:{let e=n.get(Q(i.toolCallId)??``);if(!e||e.turn.v2Items||e.entry.origin!==`v1`)break;let t=e.entry.entry;if(t.kind!==`tool`)break;t.status=`completed`,t.output=Dn(i.result);break}case`note`:case`lifecycle`:{let e=Q(i.message)??``;if(e===``)break;s().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${i.seq}`,text:e,tone:`dim`}});break}case`error`:{let e=Q(i.message)??``;if(e===``)break;s().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${i.seq}`,text:e,tone:`danger`}});break}case`session.error`:{let e=Q(i.message)??``;if(e===``)break;s().entries.push({origin:`meta`,entry:{kind:`note`,id:`v2:${i.seq}`,text:e,tone:`danger`}});break}case`step-end`:{if(i.status!==`failed`)break;let e=Q(i.error)?` — ${Q(i.error)}`:``;s().entries.push({origin:`meta`,entry:{kind:`note`,id:`v1:${i.seq}`,text:`step ${Q(i.stepId)??`?`} failed${e}`,tone:`danger`}});break}case`check-output`:{let e=Q(i.command)??`check`,t=typeof i.exitCode==`number`?i.exitCode:-1,n={kind:`tool`,id:`v1:${i.seq}`,name:`check`,toolKind:`execute`,title:`Ran ${e}`,status:t===0?`completed`:`failed`,output:Q(i.text)??``,exitCode:t};s().entries.push({origin:`meta`,entry:n});break}case`image`:{let e=Q(i.url);if(e===void 0)break;let t={kind:`image`,id:`v1:${i.seq}`,url:e},n=Q(i.name);n!==void 0&&(t.name=n),s().entries.push({origin:`meta`,entry:t});break}case`plan.updated`:Array.isArray(i.entries)&&(s().planEntries=i.entries);break;case`session.ended`:r={reason:Q(i.reason)??`end_turn`,...Q(i.message)===void 0?{}:{message:Q(i.message)}};break;case`ask.requested`:{let e=Q(i.requestId);if(e===void 0||!Array.isArray(i.questions))break;let t=i.questions.filter(e=>Z(e)&&typeof e.header==`string`&&Array.isArray(e.options));if(t.length===0)break;let n={kind:`ask`,id:e,questions:t,resolved:!1};s().entries.push({origin:`meta`,entry:n}),a=n;break}case`step-start`:case`token-usage`:case`cost`:case`turn-end`:case`done`:case`session`:break;default:break}for(let e of t){if(!e.v2Items)continue;let t=new Set;for(let{origin:n,entry:r}of e.entries)n===`v2`&&r.kind===`message`&&t.add($(r.text).trim());t.size!==0&&(e.entries=e.entries.filter(e=>!(e.origin===`v1`&&e.entry.kind===`message`&&t.has($(e.entry.text).trim()))),En(e))}return{turns:t.map(e=>({id:e.id,...e.turnId===void 0?{}:{turnId:e.turnId},...e.userMessage===void 0?{}:{userMessage:e.userMessage},...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:$(e.text)}:e)})),...r===void 0?{}:{sessionEnded:r}}}function Mn(){let{id:e}=C(),t=m(e),n=Je(e),r=(0,L.useMemo)(()=>jn(n),[n]);if(t.isPending)return(0,z.jsx)(Ee,{});if(t.isError){let e=t.error instanceof T&&t.error.status===404;return(0,z.jsx)(`div`,{"data-route":`task-thread`,className:`flex min-h-full flex-col`,children:(0,z.jsx)(S,{icon:e?(0,z.jsx)(de,{}):(0,z.jsx)(We,{}),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,z.jsx)(d,{asChild:!0,variant:`outline`,children:(0,z.jsx)(he,{to:`/`,children:`Back to tasks`})})})})}return(0,z.jsx)(Pn,{run:t.data,thread:r})}function Nn(e,t,n){let r=[];e.task&&r.push({key:`task`,node:(0,z.jsx)(H,{text:e.task,images:e.taskImages??[],onEdit:n?n.onEditTask:void 0,editLabel:`Edit the prompt`})});for(let t of e.queuedMessages??[])r.push({key:`queued:${t.id}`,node:(0,z.jsx)(H,{text:t.text,images:t.images??[],onEdit:n?e=>n.onEditMessage(t.id,e):void 0,onRemove:n?()=>n.onRemoveMessage(t.id):void 0})});for(let n of t.turns){n.userMessage&&r.push({key:`${n.id}:user`,node:(0,z.jsx)(H,{text:n.userMessage.text,imageCount:n.userMessage.imageCount,images:n.userMessage.images})});for(let t of tt(n.items))r.push({key:`${n.id}:${t.id}`,node:(0,z.jsx)(In,{block:t,scope:n.id,runId:e.id})})}return r}function Pn({run:e,thread:t}){let n=Tn(e.status,e.error),r=Cn(t),i=r!==void 0&&r.length>0?K(r):void 0,a=e.status===`running`||e.status===`waiting`,s=e.status===`queued`,c=Dt(e),d=!a&&!s&&c.available,p=!a&&e.status!==`queued`,m=(0,L.useMemo)(()=>Ft(t.turns,p),[t.turns,p]),[h,g]=(0,L.useState)(void 0),[_,y]=(0,L.useState)(e.id);_!==e.id&&(y(e.id),g(void 0));let b=(0,L.useMemo)(()=>h===void 0?void 0:Vt(t.turns,h,p),[t.turns,h,p]),x=(0,L.useMemo)(()=>h===void 0?[]:Ht(t.turns,h),[t.turns,h]),S=v(e.id),{mutateAsync:C}=l(e.id),{mutateAsync:w}=o(e.id),{mutateAsync:T}=u(e.id),E=(0,L.useMemo)(()=>s?{onEditTask:async e=>{await C({task:e})},onEditMessage:(e,t)=>w({msgId:e,message:{text:t}}).then(()=>void 0),onRemoveMessage:e=>T(e).then(()=>void 0)}:void 0,[s,C,w,T]),D=(0,L.useMemo)(()=>Nn(e,t,E),[e,t,E]),{search:te}=f(),ne=at(te,D.length),k=mn(e.id);return ye(k.restickIfStuck),(0,z.jsxs)(`div`,{"data-route":`task-thread`,className:`flex min-h-full flex-col`,children:[(0,z.jsx)(oe,{run:e,planTally:i}),(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[820px] flex-1 flex-col gap-3.5 px-4 py-5 md:px-6`,children:[(0,z.jsx)(it,{runId:e.id,children:(0,z.jsx)(hn,{runId:e.id,rows:D,mode:ne,controls:k})}),t.turns.length===0?e.status===`queued`?(0,z.jsx)(Fn,{run:e}):(0,z.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`?(0,z.jsx)(ht,{}):null,n&&n.state===`closed`?(0,z.jsxs)(`div`,{"data-slot":`thread-footer`,"data-state":n.state,className:O(`mt-auto flex items-center gap-2 border-t border-border pt-3 text-xs`,n.tone===`danger`?`text-danger`:`text-soft-foreground`),children:[n.label,ee(Ae(e))?(0,z.jsx)(`a`,{"data-slot":`pr-link`,href:Ae(e),target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline-offset-2 hover:underline`,children:`PR ↗`}):null]}):null,e.status===`review`?(0,z.jsx)(an,{run:e}):null]}),(0,z.jsx)(un,{status:e.status}),(0,z.jsx)(it,{runId:e.id,children:(0,z.jsx)(en,{agent:b,entries:x,onClose:()=>g(void 0)})}),(0,z.jsxs)(`div`,{"data-slot":`thread-dock`,className:`sticky bottom-[var(--kb,0px)] z-10 bg-background px-4 pt-1.5 pb-3 max-md:border-t max-md:border-border md:px-6 md:pb-4`,children:[k.pillVisible?(0,z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 -top-12 flex justify-center`,children:(0,z.jsx)(_n,{onJump:k.jumpToLatest})}):null,(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-[820px] flex-col gap-2.5`,children:[(0,z.jsx)(Gt,{runId:e.id,agents:m,onSelect:g},`agents:${e.id}`),r!==void 0&&r.length>0?(0,z.jsx)(Zt,{runId:e.id,entries:r},e.id):null,e.status===`waiting`?(0,z.jsxs)(`div`,{"data-slot":`paused-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,z.jsx)(N,{tone:`pending`,pulse:!0}),`The agent is paused, waiting for your reply`]}):null,s?(0,z.jsxs)(`div`,{"data-slot":`queued-hint`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,z.jsx)(N,{tone:`pending`}),`Messages you add now are folded into the prompt before the run starts.`]}):null,(0,z.jsx)(xe,{onSubmit:d?(e,t)=>c.continueWith(e,t):(e,t)=>S.mutateAsync({text:e,images:t}),disabled:!a&&!s&&!d,disabledReason:`Session closed — no session to resume.`,footerEnd:d?c.pills:void 0,allowEmptySubmit:d,sendAriaLabel:d?`Continue`:`Send`,placeholder:s?`Add to the prompt — sent when the run starts…`:d?`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:()=>wn(t)})]})]})]})}function Fn({run:e}){let t=re(p().data??[],e.id);return(0,z.jsxs)(`div`,{"data-slot":`queued-state`,className:`flex flex-col items-center gap-1.5 py-10 text-center`,children:[(0,z.jsx)(N,{tone:`pending`,pulse:!0}),(0,z.jsxs)(`p`,{className:`text-[13px] font-medium`,children:[`Waiting for a free agent slot`,t===void 0?``:` — #${t} in queue`]}),(0,z.jsxs)(`p`,{className:`text-xs text-soft-foreground`,children:[e.workflow,` · starts automatically when a slot frees up`]})]})}function In({block:e,scope:t,runId:n}){switch(e.kind){case`entry`:return(0,z.jsx)(Ln,{entry:e.entry,scope:t,runId:n});case`tool-card`:return(0,z.jsx)(U,{item:e.item,nested:e.children,cacheKey:`${t}:${e.id}`});case`context-group`:return(0,z.jsx)(wt,{group:e,scope:t});case`streak`:return(0,z.jsx)(Tt,{count:e.count,children:e.blocks.map(e=>(0,z.jsx)(In,{block:e,scope:t,runId:n},e.id))})}}function Ln({entry:e,scope:t,runId:n}){switch(e.kind){case`message`:return e.role===`assistant`?(0,z.jsx)(ft,{text:e.text}):(0,z.jsx)(H,{text:e.text});case`reasoning`:return(0,z.jsx)(mt,{text:e.text});case`tool`:return(0,z.jsx)(U,{item:e,cacheKey:`${t}:${e.id}`});case`note`:return(0,z.jsx)(pt,{note:e});case`image`:return(0,z.jsx)(Et,{image:e});case`ask`:return(0,z.jsx)(fn,{ask:e,runId:n})}}export{Mn as TaskThreadRoute};