@tt-a1i/hive 2.1.7 → 2.1.9

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 (31) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/src/cli/team.js +44 -16
  3. package/dist/src/server/agent-startup-instructions.js +7 -10
  4. package/dist/src/server/hive-team-guidance.d.ts +7 -3
  5. package/dist/src/server/hive-team-guidance.js +178 -123
  6. package/dist/src/server/post-start-input-writer.js +2 -2
  7. package/dist/src/server/recovery-summary.js +4 -4
  8. package/dist/src/server/role-templates.js +9 -5
  9. package/dist/src/server/scenario-presets.js +3 -3
  10. package/dist/src/server/team-memory-dream-prompt.js +2 -2
  11. package/dist/src/server/team-operations.js +2 -2
  12. package/package.json +1 -1
  13. package/web/dist/assets/{AddWorkerDialog-DuUFz6UK.js → AddWorkerDialog-QBN0m0eH.js} +2 -2
  14. package/web/dist/assets/{AddWorkspaceFlow-CFuHJXFe.js → AddWorkspaceFlow-BJy-W2XI.js} +1 -1
  15. package/web/dist/assets/{FirstRunWizard-qA5b90Ru.js → FirstRunWizard-V-idMQB7.js} +1 -1
  16. package/web/dist/assets/{MarketplaceDrawer-BdkVJyI0.js → MarketplaceDrawer-D4ldgvSM.js} +1 -1
  17. package/web/dist/assets/{TaskGraphDrawer-DDhX2p_z.js → TaskGraphDrawer-BSxRbr1h.js} +1 -1
  18. package/web/dist/assets/{WhatsNewDialog-Cp_gv_Co.js → WhatsNewDialog-C-hpR8y4.js} +1 -1
  19. package/web/dist/assets/WorkerModal-EuNxsCtr.js +1 -0
  20. package/web/dist/assets/{WorkflowsDrawer-wk6HSGNl.js → WorkflowsDrawer-CoT6kWcM.js} +1 -1
  21. package/web/dist/assets/{WorkspaceMemoryDrawer-CSxU_0b1.js → WorkspaceMemoryDrawer-BXx4Z0kx.js} +1 -1
  22. package/web/dist/assets/{WorkspaceTaskDrawer-Bz3fMad9.js → WorkspaceTaskDrawer-DKRRttxQ.js} +1 -1
  23. package/web/dist/assets/index-D43vHIy2.js +84 -0
  24. package/web/dist/assets/index-DYIPzuPD.css +1 -0
  25. package/web/dist/assets/{search-BdM5IXYB.js → search-KbSLfFB8.js} +1 -1
  26. package/web/dist/assets/{square-terminal-DnmshYpr.js → square-terminal-C89RIZhu.js} +1 -1
  27. package/web/dist/index.html +2 -2
  28. package/web/dist/sw.js +1 -1
  29. package/web/dist/assets/WorkerModal-BbKQsSSJ.js +0 -1
  30. package/web/dist/assets/index-B3XoRj0C.js +0 -84
  31. package/web/dist/assets/index-CEP_bvOg.css +0 -1
@@ -1 +1 @@
1
- import{u as x,j as e,R as d,P as h,O as m,k as p,H as j,m as v,a0 as f}from"./index-B3XoRj0C.js";const b=({open:r,entries:n,onClose:t})=>{const{t:a,language:i}=x(),c=s=>{s||t()};return e.jsx(d,{open:r,onOpenChange:c,children:e.jsxs(h,{children:[e.jsx(m,{className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(p,{"aria-label":a("whatsNew.title"),className:"dialog-scale-pop elev-2 pointer-events-auto flex max-h-[calc(100vh-64px)] w-[480px] max-w-[calc(100vw-32px)] flex-col overflow-hidden rounded-lg border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-3 px-6 pt-6",children:[e.jsx("div",{"aria-hidden":!0,className:"flex h-10 w-10 items-center justify-center rounded-lg",style:{background:"color-mix(in oklab, var(--accent) 15%, transparent)",color:"var(--accent)",border:"1px solid color-mix(in oklab, var(--accent) 30%, transparent)"},children:e.jsx(j,{size:20})}),e.jsxs("div",{children:[e.jsx(v,{className:"text-lg font-semibold text-pri",children:a("whatsNew.title")}),e.jsx(f,{className:"text-xs text-ter",children:a("whatsNew.subtitle")})]})]}),e.jsx("div",{className:"scroll-y mx-6 mt-4 flex min-h-0 flex-1 flex-col gap-5 overflow-y-auto pr-3",children:n.map(s=>{const o=i==="zh"?s.zh:s.en;return e.jsxs("section",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-pri",children:a("whatsNew.versionLabel",{version:s.version})}),e.jsx("span",{className:"text-xs text-ter",children:s.date})]}),e.jsx("ul",{className:"flex flex-col gap-1.5",children:o.map(l=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-sec",children:[e.jsx("span",{"aria-hidden":!0,className:"mt-1.5 h-1 w-1 shrink-0 rounded-full bg-accent"}),e.jsx("span",{children:l})]},l))})]},s.version)})}),e.jsx("div",{className:"flex shrink-0 justify-end border-t px-6 py-5",style:{borderColor:"var(--border)"},children:e.jsx("button",{type:"button",onClick:t,className:"icon-btn icon-btn--primary justify-center",children:a("whatsNew.gotIt")})})]})})]})})};export{b as WhatsNewDialog};
1
+ import{u as x,j as e,R as d,P as h,O as m,k as p,H as j,m as v,a0 as f}from"./index-D43vHIy2.js";const b=({open:r,entries:n,onClose:t})=>{const{t:a,language:i}=x(),c=s=>{s||t()};return e.jsx(d,{open:r,onOpenChange:c,children:e.jsxs(h,{children:[e.jsx(m,{className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(p,{"aria-label":a("whatsNew.title"),className:"dialog-scale-pop elev-2 pointer-events-auto flex max-h-[calc(100vh-64px)] w-[480px] max-w-[calc(100vw-32px)] flex-col overflow-hidden rounded-lg border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-3 px-6 pt-6",children:[e.jsx("div",{"aria-hidden":!0,className:"flex h-10 w-10 items-center justify-center rounded-lg",style:{background:"color-mix(in oklab, var(--accent) 15%, transparent)",color:"var(--accent)",border:"1px solid color-mix(in oklab, var(--accent) 30%, transparent)"},children:e.jsx(j,{size:20})}),e.jsxs("div",{children:[e.jsx(v,{className:"text-lg font-semibold text-pri",children:a("whatsNew.title")}),e.jsx(f,{className:"text-xs text-ter",children:a("whatsNew.subtitle")})]})]}),e.jsx("div",{className:"scroll-y mx-6 mt-4 flex min-h-0 flex-1 flex-col gap-5 overflow-y-auto pr-3",children:n.map(s=>{const o=i==="zh"?s.zh:s.en;return e.jsxs("section",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-pri",children:a("whatsNew.versionLabel",{version:s.version})}),e.jsx("span",{className:"text-xs text-ter",children:s.date})]}),e.jsx("ul",{className:"flex flex-col gap-1.5",children:o.map(l=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-sec",children:[e.jsx("span",{"aria-hidden":!0,className:"mt-1.5 h-1 w-1 shrink-0 rounded-full bg-accent"}),e.jsx("span",{children:l})]},l))})]},s.version)})}),e.jsx("div",{className:"flex shrink-0 justify-end border-t px-6 py-5",style:{borderColor:"var(--border)"},children:e.jsx("button",{type:"button",onClick:t,className:"icon-btn icon-btn--primary justify-center",children:a("whatsNew.gotIt")})})]})})]})})};export{b as WhatsNewDialog};
@@ -0,0 +1 @@
1
+ import{r as d,u as C,i as N,aj as f,j as e,R,P as M,O as E,k as S,m as L,a0 as O,a6 as D,T as y,z as j,X as I,ak as W,q as A,al as T,am as P}from"./index-D43vHIy2.js";const _=r=>{switch(r){case"coder":return{badgeClass:"role-badge--coder",label:"Coder"};case"tester":return{badgeClass:"role-badge--tester",label:"Tester"};case"reviewer":return{badgeClass:"role-badge--reviewer",label:"Reviewer"};case"sentinel":return{badgeClass:"role-badge--sentinel",label:"Sentinel"};case"custom":return{badgeClass:"role-badge--custom",label:"Custom"};default:return{badgeClass:"role-badge--custom",label:String(r)}}},k="hive.worker-modal.width",u=480,F=.5,p=r=>{const n=typeof window<"u"?window.innerWidth-24:1200;return Math.min(Math.max(r,u),Math.max(u,n))},g=()=>typeof window>"u"?u:p(Math.round(window.innerWidth*F)),K=()=>{try{const r=localStorage.getItem(k);if(!r)return g();const n=Number.parseInt(r,10);return Number.isFinite(n)?p(n):g()}catch{return g()}},X=()=>{const[r,n]=d.useState(()=>K()),[m,c]=d.useState(!1);d.useEffect(()=>{try{localStorage.setItem(k,String(Math.round(r)))}catch{}},[r]),d.useEffect(()=>{const a=()=>{n(t=>p(t))};return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]);const b=d.useCallback(a=>t=>{t.preventDefault();const s=t.clientX,x=r;c(!0);const h=document.body.style.cursor,v=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";const o=l=>{const w=l.clientX-s,z=a==="left"?x-2*w:x+2*w;n(p(z))},i=()=>{c(!1),document.body.style.cursor=h,document.body.style.userSelect=v,document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",i),document.removeEventListener("pointercancel",i)};document.addEventListener("pointermove",o),document.addEventListener("pointerup",i),document.addEventListener("pointercancel",i)},[r]);return{width:r,resizing:m,beginResize:b}},U=({onClose:r,onStart:n,runId:m,startError:c,starting:b,worker:a})=>{const{t}=C(),s=N(),x=_(a.role),h=!!m,v=T(h),o=X();d.useLayoutEffect(()=>{if(!s)return;const l=P();return f(!0),()=>f(l)},[s]);const i=l=>{l||r()};return e.jsx(R,{open:!0,onOpenChange:i,children:e.jsxs(M,{children:[e.jsx(E,{"data-testid":"worker-modal-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center",children:e.jsxs(S,{"data-testid":"worker-modal","aria-label":t("worker.detail",{name:a.name}),className:"dialog-scale-pop pointer-events-auto relative flex h-screen max-h-screen max-w-full flex-col overflow-hidden","data-mobile":s||void 0,onEscapeKeyDown:l=>l.preventDefault(),style:s?{background:"var(--bg-1)"}:{background:"var(--bg-1)",width:`${o.width}px`},children:[s?null:e.jsxs(e.Fragment,{children:[e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":t("worker.widthResize"),"aria-valuemin":u,"aria-valuenow":Math.round(o.width),className:"modal-resize-handle modal-resize-handle--left",tabIndex:-1,"data-resizing":o.resizing||void 0,onPointerDown:o.beginResize("left")}),e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":t("worker.widthResize"),"aria-valuemin":u,"aria-valuenow":Math.round(o.width),className:"modal-resize-handle modal-resize-handle--right",tabIndex:-1,"data-resizing":o.resizing||void 0,onPointerDown:o.beginResize("right")})]}),e.jsx(L,{className:"sr-only",children:a.name}),e.jsxs(O,{className:"sr-only",children:[x.label," agent — status ",v.label]}),c?e.jsxs("div",{role:"alert",className:"flex shrink-0 items-center gap-2 border-b px-4 py-2 text-xs",style:{background:"color-mix(in oklab, var(--status-red) 10%, transparent)",borderColor:"color-mix(in oklab, var(--status-red) 30%, var(--border))",color:"var(--status-red)"},children:[e.jsx(D,{size:12,"aria-hidden":!0}),e.jsx("span",{className:"break-words",children:c})]}):null,s?null:e.jsx("div",{className:"pointer-events-none absolute top-2 left-1/2 z-10 -translate-x-1/2 rounded border px-2 py-1 text-[11px]","data-testid":"worker-modal-close-hint",style:{background:"color-mix(in oklab, var(--bg-1) 88%, transparent)",borderColor:"var(--border)",color:"var(--text-tertiary)"},children:t("worker.closeOutsideHint")}),e.jsxs("div",{className:`relative flex min-h-0 flex-1 flex-col${s?"":" p-3"}`,"data-testid":"worker-modal-terminal-slot",children:[s?e.jsx(y,{label:t("common.close"),children:e.jsx(j,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"Close worker detail","data-testid":"worker-modal-close",className:"float-action absolute top-2 right-2 z-10",style:{minHeight:44,minWidth:44},children:e.jsx(I,{size:16,"aria-hidden":!0})})})}):e.jsx(y,{label:t("common.close"),children:e.jsx(j,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"Close worker detail","data-testid":"worker-modal-close",className:"sr-only",children:t("common.close")})})}),e.jsx("div",{className:`flex min-h-0 flex-1${s?"":" rounded-lg border"}`,style:{background:"var(--bg-crust)",borderColor:"var(--border)"},children:h?e.jsx("div",{id:`worker-pty-${m}`,className:"flex h-full w-full","data-pty-slot":"worker"}):e.jsxs("div",{className:"m-auto flex max-w-[400px] flex-col items-center gap-3 px-6 text-center",children:[e.jsx(W,{commandPresetId:a.commandPresetId,workerRole:a.role,size:48}),e.jsx("div",{className:"text-sm text-pri",children:a.name}),e.jsxs("div",{className:"text-xs text-ter",children:[a.status==="stopped"?t("worker.terminalStopped"):t("worker.terminalNotStarted"),t("worker.startAgent")]}),e.jsxs("button",{type:"button",onClick:()=>n(a),disabled:b,className:"icon-btn icon-btn--primary","data-testid":"worker-start-empty",children:[e.jsx(A,{size:12,"aria-hidden":!0})," ",t(b?"common.starting":"common.start")]})]})})]})]})})]})})};export{U as WorkerModal};
@@ -1 +1 @@
1
- import{c as T,r as d,l as se,a as te,u as z,g as le,j as e,C as L,b as O,d as M,L as P,S as ae,s as ne,e as re,W as A,I as ie,T as S,X as V,A as oe,E as ce,f as I,h as de,i as ue,R as X,P as G,O as J,k as Q,m as K,n as Y,o as fe,p as me,q as pe,t as he,v as we,w as xe,x as D,y as W,M as je,z as ge,B as be}from"./index-B3XoRj0C.js";import{S as Z}from"./square-terminal-DnmshYpr.js";const ye=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],ee=T("calendar-clock",ye);const Ne=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],q=T("circle-minus",Ne);const ke=[["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],_e=T("octagon-x",ke);const ve=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],Se=T("pause",ve),F=2e3,Ce=({workspaceId:s,enabled:l})=>{const[t,a]=d.useState([]),[i,n]=d.useState([]),[c,m]=d.useState(null),[b,j]=d.useState(!1),f=d.useRef(!1),x=d.useRef(null),y=d.useCallback(async()=>{if(s)try{const r=await se(s);f.current||a(r)}catch(r){f.current||m(r instanceof Error?r.message:String(r))}},[s]),h=d.useCallback(async()=>{if(s)try{const r=await te(s);f.current||n(r)}catch(r){f.current||m(r instanceof Error?r.message:String(r))}},[s]),w=d.useCallback(async()=>{if(!(!s||!l)){j(!0);try{await Promise.all([y(),h()])}finally{f.current||j(!1)}}},[s,l,y,h]),u=d.useCallback(async()=>{await h()},[h]);return d.useEffect(()=>{if(f.current=!1,!s)return()=>{f.current=!0,x.current&&(clearTimeout(x.current),x.current=null)};m(null),j(!0),Promise.all([y(),h()]).finally(()=>{f.current||j(!1)});const r=async()=>{f.current||(await y(),!f.current&&(x.current=setTimeout(r,F)))};return x.current=setTimeout(r,F),()=>{f.current=!0,x.current&&(clearTimeout(x.current),x.current=null)}},[l,s,y,h]),{runs:t,schedules:i,error:c,loading:b,refresh:w,refreshSchedules:u}},ze={agy:"Antigravity CLI",claude:"Claude Code",codex:"Codex",cursor:"Cursor CLI",gemini:"Gemini",grok:"Grok Build",hermes:"Hermes",opencode:"OpenCode",qwen:"Qwen Code"},$e={agy:"/cli-icons/agy.png",claude:"/cli-icons/claude.png",codex:"/cli-icons/codex.png",cursor:"/cli-icons/cursor.ico",gemini:"/cli-icons/gemini.png",grok:"/cli-icons/grok.ico",hermes:"/cli-icons/hermes.png",opencode:"/cli-icons/opencode.svg",qwen:"/cli-icons/qwen.png"},E=({cli:s})=>{const l=$e[s];return l?e.jsx("img",{src:l,alt:"","aria-hidden":!0,className:"wf-cli-option__icon"}):e.jsx(Z,{size:13,"aria-hidden":!0,className:"wf-cli-option__fallback-icon"})},U=s=>s.map(l=>({cli:l,label:ze[l]??l})),Te=()=>{const{t:s}=z(),[l,t]=d.useState([]),[a,i]=d.useState([]),[n,c]=d.useState("claude"),[m,b]=d.useState(!1),[j,f]=d.useState(!1),[x,y]=d.useState(null),[h,w]=d.useState(!0);d.useEffect(()=>{let o=!1;return le().then(g=>{if(o)return;const k=U(g.supported),v=k.map(R=>R.cli),C=v.filter(R=>g.allowed.includes(R));t(k),i(C.length>0?C:v),c(v.includes(g.default)?g.default:v[0]??"claude"),b(!0)}).catch(()=>b(!0)),()=>{o=!0}},[]);const u=o=>{y(null),i(g=>{const k=g.includes(o)?g.filter(v=>v!==o):[...g,o];return!k.includes(n)&&k.length>0&&c(k[0]),k})},r=o=>{y(null),c(o),a.includes(o)||i(g=>[...g,o])},N=!j&&a.length>0&&a.includes(n),p=l.find(o=>o.cli===n)?.label??n,_=async()=>{if(N){f(!0),y(null);try{const o=await ne({default:n,allowed:a}),g=U(o.supported),k=g.map(C=>C.cli),v=k.filter(C=>o.allowed.includes(C));t(g),i(v),c(k.includes(o.default)?o.default:k[0]??"claude"),y("saved")}catch{y("error")}finally{f(!1)}}};return e.jsxs("section",{className:"wf-cli-policy","data-testid":"workflow-cli-policy",children:[e.jsxs("button",{type:"button",className:"wf-cli-policy__toggle","aria-expanded":h,onClick:()=>w(o=>!o),children:[e.jsxs("div",{className:"wf-cli-policy__hero",children:[e.jsx("div",{className:"wf-cli-policy__hero-icon",children:e.jsx(Z,{size:16})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"wf-cli-policy__title",children:s("workflows.cli.title")}),e.jsx("p",{className:"wf-cli-policy__desc",children:s("workflows.cli.desc")})]})]}),e.jsxs("div",{className:"wf-cli-policy__summary",children:[e.jsxs("div",{className:"wf-cli-policy__summary-card",children:[e.jsx("span",{className:"wf-cli-policy__summary-label",children:s("workflows.cli.default")}),e.jsxs("span",{className:"wf-cli-policy__summary-value",children:[e.jsx(E,{cli:n}),p]})]}),e.jsxs("div",{className:"wf-cli-policy__summary-card",children:[e.jsx("span",{className:"wf-cli-policy__summary-label",children:s("workflows.cli.allowed")}),e.jsx("span",{className:"wf-cli-policy__summary-value",children:a.length})]})]}),e.jsx("div",{className:"wf-cli-policy__toggle-icon","aria-hidden":!0,children:h?e.jsx(L,{size:16}):e.jsx(O,{size:16})})]}),h?e.jsxs("div",{className:"wf-cli-policy__body",children:[e.jsxs("fieldset",{className:"wf-cli-policy__fieldset wf-cli-policy__group",children:[e.jsx("legend",{className:"wf-cli-policy__legend",children:s("workflows.cli.default")}),e.jsx("div",{className:"wf-cli-policy__options",children:l.map(o=>e.jsxs("label",{className:`wf-cli-option${n===o.cli?" wf-cli-option--active":""}`,children:[e.jsx("input",{type:"radio",name:"workflow-default-cli",checked:n===o.cli,onChange:()=>r(o.cli),className:"sr-only"}),e.jsx(E,{cli:o.cli}),o.label]},o.cli))})]}),e.jsxs("fieldset",{className:"wf-cli-policy__fieldset wf-cli-policy__group",children:[e.jsx("legend",{className:"wf-cli-policy__legend",children:s("workflows.cli.allowed")}),e.jsx("div",{className:"wf-cli-policy__options",children:l.map(o=>{const g=a.includes(o.cli);return e.jsxs("label",{className:`wf-cli-option${g?" wf-cli-option--active":""}`,children:[e.jsx("input",{type:"checkbox",checked:g,onChange:()=>u(o.cli),className:"sr-only"}),e.jsx(E,{cli:o.cli}),o.label,g?e.jsx(M,{size:12,"aria-hidden":!0,className:"ml-0.5"}):null]},o.cli)})})]}),e.jsxs("div",{className:"wf-cli-policy__footer",children:[e.jsxs("div",{className:"wf-cli-policy__footer-status",children:[x==="saved"?e.jsxs("span",{className:"wf-cli-policy__status wf-cli-policy__status--saved",children:[e.jsx(M,{size:12}),s("workflows.cli.saved")]}):null,x==="error"?e.jsx("span",{className:"wf-cli-policy__status wf-cli-policy__status--error",children:s("workflows.cli.failed")}):null,!N&&a.length===0?e.jsx("span",{className:"wf-cli-policy__status wf-cli-policy__status--error",children:s("workflows.cli.pickOne")}):null,m?null:e.jsxs("span",{className:"wf-cli-policy__status",children:[e.jsx(P,{size:12,className:"animate-spin"}),s("workflows.loading")]})]}),e.jsxs("button",{type:"button",className:"drawer-action-btn wf-cli-policy__save pointer-coarse:min-h-9",onClick:_,disabled:!N,children:[e.jsx(ae,{size:14}),s(j?"workflows.cli.saving":"workflows.cli.save")]})]})]}):null]})},Re=s=>({running:e.jsx(P,{size:14,className:"animate-spin text-accent","aria-label":s("workflows.status.running")}),completed:e.jsx(M,{size:14,className:"text-status-green","aria-label":s("workflows.status.completed")}),failed:e.jsx(Y,{size:14,className:"text-status-red","aria-label":s("workflows.status.failed")}),interrupted:e.jsx(q,{size:14,className:"text-status-orange","aria-label":s("workflows.status.interrupted")}),stopped:e.jsx(q,{size:14,className:"text-ter","aria-label":s("workflows.status.stopped")})}),Ae={running:"drawer-status-badge--running",completed:"drawer-status-badge--completed",failed:"drawer-status-badge--failed",interrupted:"drawer-status-badge--interrupted",stopped:"drawer-status-badge--stopped"},Ee=s=>{const l=s.split(/[\\/]/);return l[l.length-1]??s},B=(s,l)=>{const t=Math.floor((Date.now()-s)/1e3);return t<60?l("common.time.sAgo",{count:t}):t<3600?l("common.time.mAgo",{count:Math.floor(t/60)}):t<86400?l("common.time.hAgo",{count:Math.floor(t/3600)}):l("common.time.dAgo",{count:Math.floor(t/86400)})},$=(s,l=80)=>{if(!s)return"";const t=s.trim();return t.length<=l?t:`${t.slice(0,l-1)}…`},Me=(s,l)=>{const t=(l??Date.now())-s;if(t<1e3)return`${t}ms`;const a=Math.floor(t/1e3);if(a<60)return`${a}s`;if(a<3600){const c=Math.floor(a/60),m=a%60;return m===0?`${c}m`:`${c}m${m}s`}const i=Math.floor(a/3600),n=Math.floor(a%3600/60);return n===0?`${i}h`:`${i}h${n}m`},Le=s=>{if(s==null)return null;if(typeof s=="string")return s;try{return JSON.stringify(s)}catch{return null}},Oe=s=>typeof s=="string"?s:JSON.stringify(s,null,2),Pe=s=>{const l=new Map,t=[];for(const n of s)if(n.parentRunId){const c=l.get(n.parentRunId)??[];c.push(n),l.set(n.parentRunId,c)}else t.push(n);const a=[];for(const n of t){a.push({run:n,depth:0});const c=l.get(n.id)??[];for(const m of c)a.push({run:m,depth:1})}const i=new Set(a.map(n=>n.run.id));for(const n of s)i.has(n.id)||a.push({run:n,depth:0});return a},Ie={queued:{mark:"○",tone:"text-ter"},submitted:{mark:"◐",tone:"text-accent"},reported:{mark:"●",tone:"text-status-green"},cancelled:{mark:"⊘",tone:"text-status-red"}},De=(s,l)=>l(`workflows.dispatchStatus.${s}`),We=({dispatch:s})=>{const[l,t]=d.useState(!1),[a,i]=d.useState(null),[n,c]=d.useState(null),{t:m}=z(),b=Ie[s.status],j=s.label??`step-${s.stepIndex??"?"}`,f=s.reportText?$(s.reportText,80):null,x=s.status==="submitted"&&s.lastPtyLine?$(s.lastPtyLine,80):null,y=s.status==="submitted"?x?null:m("workflows.dispatchStatus.awaitingReport"):s.status==="cancelled"?m("workflows.dispatchStatus.cancelled"):s.status==="queued"?m("workflows.dispatchStatus.queued"):null;return d.useEffect(()=>{if(i(null),c(null),!l)return;let h=!1;return be(s.workspaceId,s.id).then(w=>{h||i(w)}).catch(w=>{h||c(w instanceof Error?w.message:String(w))}),()=>{h=!0}},[s.id,s.workspaceId,l]),e.jsxs("div",{className:"wf-dispatch-item rounded-md text-xs","data-testid":`workflow-dispatch-row-${s.id}`,"data-dispatch-status":s.status,children:[e.jsxs("button",{type:"button",onClick:()=>t(h=>!h),className:"wf-dispatch-header","aria-expanded":l,children:[e.jsx("span",{className:`wf-dispatch-mark ${b.tone}`,"aria-hidden":!0,children:b.mark}),e.jsxs("span",{className:"wf-dispatch-step",title:`step ${s.stepIndex??"?"}`,children:["#",s.stepIndex??"?"]}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"wf-dispatch-title",children:j}),e.jsx("span",{className:`wf-dispatch-status wf-dispatch-status--${s.status}`,children:De(s.status,m)}),f?e.jsxs("span",{className:"wf-dispatch-summary",children:["↳ ",f]}):x?e.jsxs("span",{className:"wf-dispatch-summary",title:s.lastPtyLine,"data-testid":`workflow-dispatch-pty-${s.id}`,children:[e.jsx("span",{className:"text-accent",children:"⟶"}),e.jsx("span",{className:"font-mono",children:x})]}):y?e.jsx("span",{className:"wf-dispatch-summary italic",children:y}):null]})]}),l?e.jsxs("div",{className:"wf-dispatch-detail","data-testid":`workflow-dispatch-detail-${s.id}`,children:[s.text?e.jsxs("div",{children:[e.jsx("div",{className:"wf-dispatch-detail__label",children:"prompt"}),e.jsx("div",{className:"whitespace-pre-wrap text-pri",children:s.text})]}):null,s.reportText?e.jsxs("div",{children:[e.jsx("div",{className:"wf-dispatch-detail__label",children:"report"}),e.jsx("div",{className:"whitespace-pre-wrap text-pri",children:s.reportText})]}):null,a&&a.length>0?e.jsxs("div",{children:[e.jsx("div",{className:"wf-dispatch-detail__label",children:"memory injected"}),e.jsx("ul",{className:"space-y-1",children:a.map(h=>e.jsxs("li",{className:"break-words text-sec",children:[e.jsx("span",{className:"drawer-kind-badge",style:{marginRight:4},children:h.memory.kind})," ",$(h.memory.body,120)]},h.id))})]}):null,n?e.jsxs("div",{className:"drawer-card__error",children:["Memory: ",n]}):null]}):null]})},qe=s=>{const l=[],t=new Map;for(const a of s){const i=a.phase??"—";let n=t.get(i);n||(n={title:i,dispatches:[]},t.set(i,n),l.push(n)),n.dispatches.push(a)}return l},Fe=({group:s,runStatus:l,defaultOpen:t})=>{const[a,i]=d.useState(t),n=s.dispatches.filter(f=>f.status==="reported"||f.status==="cancelled").length,c=s.dispatches.length,m=n===c,b=!m&&l==="running",j=c>0?Math.round(n/c*100):0;return e.jsxs("div",{className:"wf-phase-strip","data-testid":`workflow-phase-${s.title}`,children:[e.jsxs("button",{type:"button",onClick:()=>i(f=>!f),className:"wf-phase-strip__toggle pointer-coarse:min-h-10","aria-expanded":a,children:[e.jsx("span",{className:"wf-phase-strip__chevron",children:a?e.jsx(L,{size:11}):e.jsx(O,{size:11})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-semibold text-sec",children:s.title==="—"?"(no phase)":s.title}),e.jsxs("span",{className:`wf-phase-strip__badge ${m?"wf-phase-strip__badge--done":b?"wf-phase-strip__badge--running":""}`,children:[n,"/",c,b?" ⟳":m?" ✓":""]})]}),e.jsx("div",{className:"wf-phase-strip__bar",children:e.jsx("span",{style:{width:`${j}%`},className:m?"wf-phase-strip__bar-fill--done":b?"wf-phase-strip__bar-fill--running":"wf-phase-strip__bar-fill"})}),a?e.jsx("div",{className:"wf-phase-body","data-testid":`workflow-phase-body-${s.title}`,children:s.dispatches.map(f=>e.jsx(We,{dispatch:f},f.id))}):null]})},Ue=({runId:s,result:l})=>{const[t,a]=d.useState(!1),[i,n]=d.useState(!1),c=Oe(l),m=async()=>{try{await navigator.clipboard.writeText(c),n(!0),setTimeout(()=>n(!1),1200)}catch{}};return e.jsxs("div",{className:"wf-result mb-2","data-testid":`workflow-run-result-${s}`,children:[e.jsxs("div",{className:"wf-result__header",children:[e.jsx("div",{className:"wf-result__label",children:"Result"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(S,{label:i?"Copied!":"Copy result",children:e.jsx("button",{type:"button",onClick:m,"aria-label":"Copy result",className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-run-result-copy-${s}`,children:i?e.jsx(D,{size:11,className:"text-status-green"}):e.jsx(W,{size:11})})}),e.jsx(S,{label:"Expand",children:e.jsx("button",{type:"button",onClick:()=>a(!0),"aria-label":"Expand result",className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-run-result-expand-${s}`,children:e.jsx(je,{size:11})})})]})]}),e.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-xs text-pri",children:c}),t?e.jsx(X,{open:t,onOpenChange:b=>a(b),children:e.jsxs(G,{children:[e.jsx(J,{className:"fixed inset-0 z-40 bg-black/60"}),e.jsxs(Q,{className:"fixed inset-4 z-50 flex flex-col rounded-lg border bg-[var(--bg-1)] p-4 shadow-xl md:inset-8 lg:inset-16",style:{borderColor:"var(--border-bright)"},"data-testid":`workflow-run-result-modal-${s}`,children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx(K,{className:"text-sm font-semibold",children:"Workflow result"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(S,{label:i?"Copied!":"Copy",children:e.jsx("button",{type:"button",onClick:m,"aria-label":"Copy",className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:i?e.jsx(D,{size:14,className:"text-status-green"}):e.jsx(W,{size:14})})}),e.jsx(ge,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"Close",className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:e.jsx(V,{size:14})})})]})]}),e.jsx("textarea",{readOnly:!0,value:c,className:"min-h-0 flex-1 resize-none rounded border bg-[var(--bg-0)] p-2 font-mono text-xs",style:{borderColor:"var(--border)"}})]})]})}):null]})},H=({run:s,onStop:l})=>{const[t,a]=d.useState(!1),[i,n]=d.useState(null),[c,m]=d.useState(null),[b,j]=d.useState(!1),[f,x]=d.useState(null),[y,h]=d.useState(!1),{t:w}=z(),u=[];s.phase&&u.push({key:"phase",text:`phase: ${s.phase}`}),s.agentCount>0&&u.push({key:"agentCount",text:`${s.agentCount} agent${s.agentCount===1?"":"s"}`}),s.status!=="running"&&u.push({key:"duration",text:Me(s.startedAt,s.finishedAt)});const r=Le(s.args),N=r?$(r,60):null;return d.useEffect(()=>{if(!t)return;let p=!1;return j(!0),x(null),Promise.all([fe(s.id),me(s.id)]).then(([_,o])=>{p||(n(_),m(o))}).catch(_=>{p||x(_ instanceof Error?_.message:String(_))}).finally(()=>{p||j(!1)}),()=>{p=!0}},[t,s.id,s.status]),e.jsxs("div",{className:"drawer-card text-xs","data-testid":`workflow-run-row-${s.id}`,"data-run-status":s.status,children:[e.jsxs("div",{className:"wf-run-summary-row",children:[e.jsxs("button",{type:"button",onClick:()=>a(p=>!p),className:"wf-run-toggle","aria-expanded":t,"data-testid":`workflow-run-toggle-${s.id}`,children:[e.jsx("span",{className:"wf-run-toggle__chevron",children:t?e.jsx(L,{size:11}):e.jsx(O,{size:11})}),e.jsx("span",{className:"wf-run-toggle__icon",children:Re(w)[s.status]}),e.jsxs("span",{className:"wf-run-toggle__main",children:[e.jsx("span",{className:"wf-run-toggle__name",children:s.name}),e.jsxs("span",{className:"wf-run-toggle__meta",children:[e.jsx("span",{className:`drawer-status-badge ${Ae[s.status]}`,children:w(`workflows.status.${s.status}`)}),s.status==="running"?B(s.startedAt,w):B(s.finishedAt??s.startedAt,w)]})]})]}),s.status==="running"?e.jsx("div",{className:"drawer-card__actions pr-1 wf-run-stop-area",children:e.jsx(S,{label:w("workflows.stopTooltip"),children:e.jsx("button",{type:"button",onClick:async()=>{h(!0);try{await l()}finally{h(!1)}},disabled:y,"aria-label":w("workflows.stopTooltip"),className:"wf-run-stop-btn icon-btn icon-btn--danger mr-1 disabled:opacity-50 pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-run-stop-${s.id}`,children:e.jsx(_e,{size:12})})})}):null]}),u.length>0||N?e.jsxs("div",{className:"wf-run-meta","data-testid":`workflow-run-meta-${s.id}`,children:[u.length>0?u.map(p=>e.jsx("span",{className:"wf-run-meta__item",children:p.text},p.key)):null,N?e.jsxs("span",{className:"wf-run-meta__item wf-run-meta__args",title:r??void 0,children:["args: ",N]}):null]}):null,t?e.jsxs("div",{className:"wf-run-detail","data-testid":`workflow-run-detail-${s.id}`,children:[s.result!==null&&s.result!==void 0?e.jsx(Ue,{runId:s.id,result:s.result}):null,f?e.jsx("div",{className:"text-error",children:f}):b&&i===null?e.jsx("div",{className:"text-ter",children:w("workflows.loading")}):i&&i.length>0?(()=>{const p=qe(i),_=p.length-1;return e.jsx("div",{className:"space-y-1.5",children:p.map((o,g)=>e.jsx(Fe,{group:o,runStatus:s.status,defaultOpen:p.length===1||g===_},o.title))})})():e.jsx("div",{className:"text-ter italic",children:w("workflows.noAgents")}),c&&c.length>0?e.jsxs("div",{className:"wf-logs-panel","data-testid":`workflow-run-logs-${s.id}`,children:[e.jsx("div",{className:"wf-logs-panel__title",children:c.length===1?w("workflows.narratorOne"):w("workflows.narrator",{count:c.length})}),e.jsx("ul",{className:"space-y-0.5 font-mono text-[11px]",children:c.map(p=>e.jsx("li",{className:"text-sec",children:p.message},p.id))})]}):null,s.error?e.jsx("div",{className:"text-error",children:w("workflows.runError",{error:s.error})}):null]}):null]})},Be=({schedule:s,onToggle:l,onDelete:t})=>{const{t:a}=z();return e.jsxs("div",{className:"drawer-card wf-schedule-row flex items-center gap-3","data-testid":`workflow-schedule-row-${s.id}`,"data-schedule-enabled":s.enabled?"true":"false",children:[e.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md",style:{background:s.enabled?"color-mix(in oklab, var(--accent) 12%, transparent)":"var(--bg-3)",color:s.enabled?"var(--accent)":"var(--text-tertiary)"},children:e.jsx(ee,{size:13})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[12.5px] font-medium text-pri",children:Ee(s.scriptPath)}),e.jsx("div",{className:"truncate font-mono text-[10.5px] text-ter mt-0.5",children:s.cron})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[e.jsx(S,{label:s.enabled?a("workflows.pauseTooltip"):a("workflows.resumeTooltip"),children:e.jsx("button",{type:"button",onClick:()=>{l(!s.enabled)},"aria-label":s.enabled?a("workflows.pauseTooltip"):a("workflows.resumeTooltip"),className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-schedule-toggle-${s.id}`,children:s.enabled?e.jsx(Se,{size:12}):e.jsx(pe,{size:12})})}),e.jsx(S,{label:a("workflows.deleteScheduleTooltip"),children:e.jsx("button",{type:"button",onClick:()=>{t()},"aria-label":a("workflows.deleteScheduleTooltip"),className:"icon-btn icon-btn--danger pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-schedule-delete-${s.id}`,children:e.jsx(he,{size:12})})})]})]})},He=({workspaceId:s,onClose:l})=>{const{t}=z(),a=re(),{runs:i,schedules:n,error:c,refresh:m,refreshSchedules:b}=Ce({workspaceId:s,enabled:!0}),[j,f]=d.useState("all"),x=i.filter(u=>u.status==="running").length,y=i.filter(u=>u.status==="failed"||u.status==="stopped"||u.status==="interrupted").length,h=async(u,r)=>{try{await xe(u,{enabled:r})}catch(N){a.show({kind:"error",message:N instanceof Error?N.message:String(N)})}finally{await b()}},w=async u=>{try{await we(u)}catch(r){a.show({kind:"error",message:r instanceof Error?r.message:String(r)})}finally{await b()}};return e.jsxs("div",{className:"workflows-content flex h-full min-h-0 flex-col","data-testid":"workflows-content",children:[e.jsxs("header",{className:"wf-panel-header border-b px-4 py-3",style:{borderColor:"var(--border)"},children:[e.jsxs("div",{className:"wf-panel-header__main",children:[e.jsx("div",{className:"wf-panel-header__icon",style:{background:"color-mix(in oklab, var(--accent) 14%, transparent)",color:"var(--accent)"},children:e.jsx(A,{size:15,"aria-hidden":!0})}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[e.jsx("span",{className:"text-[13px] font-semibold text-pri leading-tight",children:t("workflows.title")}),e.jsxs("div",{className:"relative group inline-block cursor-help shrink-0",children:[e.jsx(ie,{size:12,className:"text-ter hover:text-sec transition-colors"}),e.jsx("div",{className:"absolute hidden group-hover:block left-0 top-full mt-1.5 w-72 p-3 bg-[var(--bg-2)] border border-border rounded-xl shadow-2xl text-[11px] text-sec leading-relaxed z-50 pointer-events-none",children:t("workflows.description")})]}),e.jsx("span",{className:"wf-panel-count","data-testid":"workflows-summary-count",children:i.length})]})]}),l?e.jsx(S,{label:t("common.close"),children:e.jsx("button",{type:"button",onClick:l,"aria-label":t("common.close"),className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:e.jsx(V,{size:14})})}):null]}),e.jsxs("div",{className:"scroll-y flex-1 px-4 py-3",children:[c?e.jsx("div",{className:"mb-3 rounded-md border px-3 py-2 text-xs",style:{borderColor:"color-mix(in oklab, var(--status-red) 30%, var(--border))",color:"var(--text-error)",background:"color-mix(in oklab, var(--status-red) 8%, transparent)"},"data-testid":"workflows-error",children:c}):null,e.jsxs("div",{className:"flex flex-col md:flex-row gap-5 items-start",children:[e.jsxs("div",{className:"flex-1 min-w-0 w-full space-y-4",children:[e.jsxs("section",{className:"wf-content-section mb-0",children:[e.jsxs("div",{className:"drawer-section__header mb-2",children:[e.jsxs("div",{className:"wf-section-title",children:[e.jsx(oe,{size:14,"aria-hidden":!0,className:"text-sec"}),e.jsxs("div",{children:[e.jsx("h3",{className:"drawer-section-label wf-section-label-tight",children:t("workflows.recentRuns")}),e.jsx("p",{className:"wf-section-subtitle",children:x>0?`${x} ${t("workflows.filterRunning")}`:t("workflows.emptyRunsDesc")})]})]}),i.length>0?(()=>{const u=({id:r,label:N,count:p})=>e.jsxs("button",{type:"button",onClick:()=>f(r),"aria-pressed":j===r,"data-testid":`workflow-runs-filter-${r}`,className:`wf-run-filter-pill pointer-coarse:min-h-9 pointer-coarse:text-xs ${j===r?"wf-run-filter-pill--active":""}`,children:[r==="all"?e.jsx(A,{size:11,"aria-hidden":!0}):r==="running"?e.jsx(P,{size:11,"aria-hidden":!0,className:"animate-spin"}):e.jsx(Y,{size:11,"aria-hidden":!0}),e.jsx("span",{children:N}),e.jsx("span",{className:"wf-run-filter-pill__count",children:p})]});return e.jsxs("div",{className:"wf-run-filters",children:[e.jsx(u,{id:"all",label:t("workflows.filterAll"),count:i.length}),e.jsx(u,{id:"running",label:t("workflows.filterRunning"),count:x}),e.jsx(u,{id:"failed",label:t("workflows.filterFailed"),count:y})]})})():null]}),i.length===0?e.jsx("div",{className:"wf-empty-surface",children:e.jsx(ce,{icon:e.jsx(A,{size:18}),title:t("workflows.emptyRuns"),description:t("workflows.emptyRunsDesc")})}):(()=>{const u=j==="all"?i:j==="running"?i.filter(r=>r.status==="running"):i.filter(r=>r.status==="failed"||r.status==="stopped"||r.status==="interrupted");return u.length===0?e.jsx("div",{className:"wf-empty-inline","data-testid":"workflow-runs-empty-filter",children:t("workflows.emptyFilter")}):e.jsx("ul",{className:"space-y-2",children:Pe(u.slice(0,20)).map(({run:r,depth:N})=>e.jsx("li",{className:`wf-run-tree-item ${N>0?"wf-run-tree-item--child":""}`,"data-testid":`workflow-run-tree-${r.id}`,"data-depth":N,children:N>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"wf-tree-connector","aria-hidden":"true"}),e.jsx("div",{className:"wf-run-tree-item__content",children:e.jsx(H,{run:r,onStop:async()=>{try{await I(r.id)}catch(p){a.show({kind:"error",message:p instanceof Error?p.message:String(p)})}finally{await m()}}})})]}):e.jsx("div",{className:"wf-run-tree-item__content",children:e.jsx(H,{run:r,onStop:async()=>{try{await I(r.id)}catch(p){a.show({kind:"error",message:p instanceof Error?p.message:String(p)})}finally{await m()}}})})},r.id))})})()]}),n.length>0?e.jsxs("section",{className:"wf-content-section mb-0","data-testid":"workflows-schedules-section",children:[e.jsx("div",{className:"drawer-section__header mb-2",children:e.jsxs("div",{className:"wf-section-title",children:[e.jsx(ee,{size:14,"aria-hidden":!0,className:"text-sec"}),e.jsxs("div",{children:[e.jsx("h3",{className:"drawer-section-label wf-section-label-tight",children:t("workflows.schedules")}),e.jsxs("p",{className:"wf-section-subtitle",children:[n.length," ",t("workflows.schedules")]})]})]})}),e.jsx("ul",{className:"space-y-1.5",children:n.map(u=>e.jsx("li",{children:e.jsx(Be,{schedule:u,onToggle:r=>h(u.id,r),onDelete:()=>w(u.id)})},u.id))})]}):null]}),e.jsx("div",{className:"w-full md:w-[280px] shrink-0 wf-sidebar-settings",children:e.jsxs("section",{className:"drawer-section",children:[e.jsx("div",{className:"drawer-section__header mb-2",children:e.jsxs("div",{className:"wf-section-title",children:[e.jsx(de,{size:14,"aria-hidden":!0,className:"text-sec"}),e.jsx("h3",{className:"drawer-section-label wf-section-label-tight",children:t("workflows.cli.title")})]})}),e.jsx(Te,{})]})})]})]})]})},Ge=({open:s,onClose:l,workspaceId:t})=>{const a=ue(),{t:i}=z();return e.jsx(X,{open:s,onOpenChange:n=>!n&&l(),children:e.jsxs(G,{children:[e.jsx(J,{"data-testid":"workflows-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(Q,{"data-testid":"workflows-drawer","aria-label":i("workflows.title"),"data-mobile":a||void 0,className:"dialog-scale-pop elev-2 pointer-events-auto flex flex-col rounded-lg border",style:a?{background:"var(--bg-1)",borderColor:"var(--border-bright)"}:{background:"var(--bg-1)",borderColor:"var(--border-bright)",height:"min(720px, calc(100vh - 48px))",width:"min(780px, calc(100vw - 48px))"},children:[e.jsx(K,{className:"sr-only",children:i("workflows.title")}),e.jsx(He,{workspaceId:t,onClose:l})]})})]})})};export{He as WorkflowsContent,Ge as WorkflowsDrawer};
1
+ import{c as T,r as d,l as se,a as te,u as z,g as le,j as e,C as L,b as O,d as M,L as P,S as ae,s as ne,e as re,W as A,I as ie,T as S,X as V,A as oe,E as ce,f as I,h as de,i as ue,R as X,P as G,O as J,k as Q,m as K,n as Y,o as fe,p as me,q as pe,t as he,v as we,w as xe,x as D,y as W,M as je,z as ge,B as be}from"./index-D43vHIy2.js";import{S as Z}from"./square-terminal-C89RIZhu.js";const ye=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],ee=T("calendar-clock",ye);const Ne=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],q=T("circle-minus",Ne);const ke=[["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],_e=T("octagon-x",ke);const ve=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],Se=T("pause",ve),F=2e3,Ce=({workspaceId:s,enabled:l})=>{const[t,a]=d.useState([]),[i,n]=d.useState([]),[c,m]=d.useState(null),[b,j]=d.useState(!1),f=d.useRef(!1),x=d.useRef(null),y=d.useCallback(async()=>{if(s)try{const r=await se(s);f.current||a(r)}catch(r){f.current||m(r instanceof Error?r.message:String(r))}},[s]),h=d.useCallback(async()=>{if(s)try{const r=await te(s);f.current||n(r)}catch(r){f.current||m(r instanceof Error?r.message:String(r))}},[s]),w=d.useCallback(async()=>{if(!(!s||!l)){j(!0);try{await Promise.all([y(),h()])}finally{f.current||j(!1)}}},[s,l,y,h]),u=d.useCallback(async()=>{await h()},[h]);return d.useEffect(()=>{if(f.current=!1,!s)return()=>{f.current=!0,x.current&&(clearTimeout(x.current),x.current=null)};m(null),j(!0),Promise.all([y(),h()]).finally(()=>{f.current||j(!1)});const r=async()=>{f.current||(await y(),!f.current&&(x.current=setTimeout(r,F)))};return x.current=setTimeout(r,F),()=>{f.current=!0,x.current&&(clearTimeout(x.current),x.current=null)}},[l,s,y,h]),{runs:t,schedules:i,error:c,loading:b,refresh:w,refreshSchedules:u}},ze={agy:"Antigravity CLI",claude:"Claude Code",codex:"Codex",cursor:"Cursor CLI",gemini:"Gemini",grok:"Grok Build",hermes:"Hermes",opencode:"OpenCode",qwen:"Qwen Code"},$e={agy:"/cli-icons/agy.png",claude:"/cli-icons/claude.png",codex:"/cli-icons/codex.png",cursor:"/cli-icons/cursor.ico",gemini:"/cli-icons/gemini.png",grok:"/cli-icons/grok.ico",hermes:"/cli-icons/hermes.png",opencode:"/cli-icons/opencode.svg",qwen:"/cli-icons/qwen.png"},E=({cli:s})=>{const l=$e[s];return l?e.jsx("img",{src:l,alt:"","aria-hidden":!0,className:"wf-cli-option__icon"}):e.jsx(Z,{size:13,"aria-hidden":!0,className:"wf-cli-option__fallback-icon"})},U=s=>s.map(l=>({cli:l,label:ze[l]??l})),Te=()=>{const{t:s}=z(),[l,t]=d.useState([]),[a,i]=d.useState([]),[n,c]=d.useState("claude"),[m,b]=d.useState(!1),[j,f]=d.useState(!1),[x,y]=d.useState(null),[h,w]=d.useState(!0);d.useEffect(()=>{let o=!1;return le().then(g=>{if(o)return;const k=U(g.supported),v=k.map(R=>R.cli),C=v.filter(R=>g.allowed.includes(R));t(k),i(C.length>0?C:v),c(v.includes(g.default)?g.default:v[0]??"claude"),b(!0)}).catch(()=>b(!0)),()=>{o=!0}},[]);const u=o=>{y(null),i(g=>{const k=g.includes(o)?g.filter(v=>v!==o):[...g,o];return!k.includes(n)&&k.length>0&&c(k[0]),k})},r=o=>{y(null),c(o),a.includes(o)||i(g=>[...g,o])},N=!j&&a.length>0&&a.includes(n),p=l.find(o=>o.cli===n)?.label??n,_=async()=>{if(N){f(!0),y(null);try{const o=await ne({default:n,allowed:a}),g=U(o.supported),k=g.map(C=>C.cli),v=k.filter(C=>o.allowed.includes(C));t(g),i(v),c(k.includes(o.default)?o.default:k[0]??"claude"),y("saved")}catch{y("error")}finally{f(!1)}}};return e.jsxs("section",{className:"wf-cli-policy","data-testid":"workflow-cli-policy",children:[e.jsxs("button",{type:"button",className:"wf-cli-policy__toggle","aria-expanded":h,onClick:()=>w(o=>!o),children:[e.jsxs("div",{className:"wf-cli-policy__hero",children:[e.jsx("div",{className:"wf-cli-policy__hero-icon",children:e.jsx(Z,{size:16})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"wf-cli-policy__title",children:s("workflows.cli.title")}),e.jsx("p",{className:"wf-cli-policy__desc",children:s("workflows.cli.desc")})]})]}),e.jsxs("div",{className:"wf-cli-policy__summary",children:[e.jsxs("div",{className:"wf-cli-policy__summary-card",children:[e.jsx("span",{className:"wf-cli-policy__summary-label",children:s("workflows.cli.default")}),e.jsxs("span",{className:"wf-cli-policy__summary-value",children:[e.jsx(E,{cli:n}),p]})]}),e.jsxs("div",{className:"wf-cli-policy__summary-card",children:[e.jsx("span",{className:"wf-cli-policy__summary-label",children:s("workflows.cli.allowed")}),e.jsx("span",{className:"wf-cli-policy__summary-value",children:a.length})]})]}),e.jsx("div",{className:"wf-cli-policy__toggle-icon","aria-hidden":!0,children:h?e.jsx(L,{size:16}):e.jsx(O,{size:16})})]}),h?e.jsxs("div",{className:"wf-cli-policy__body",children:[e.jsxs("fieldset",{className:"wf-cli-policy__fieldset wf-cli-policy__group",children:[e.jsx("legend",{className:"wf-cli-policy__legend",children:s("workflows.cli.default")}),e.jsx("div",{className:"wf-cli-policy__options",children:l.map(o=>e.jsxs("label",{className:`wf-cli-option${n===o.cli?" wf-cli-option--active":""}`,children:[e.jsx("input",{type:"radio",name:"workflow-default-cli",checked:n===o.cli,onChange:()=>r(o.cli),className:"sr-only"}),e.jsx(E,{cli:o.cli}),o.label]},o.cli))})]}),e.jsxs("fieldset",{className:"wf-cli-policy__fieldset wf-cli-policy__group",children:[e.jsx("legend",{className:"wf-cli-policy__legend",children:s("workflows.cli.allowed")}),e.jsx("div",{className:"wf-cli-policy__options",children:l.map(o=>{const g=a.includes(o.cli);return e.jsxs("label",{className:`wf-cli-option${g?" wf-cli-option--active":""}`,children:[e.jsx("input",{type:"checkbox",checked:g,onChange:()=>u(o.cli),className:"sr-only"}),e.jsx(E,{cli:o.cli}),o.label,g?e.jsx(M,{size:12,"aria-hidden":!0,className:"ml-0.5"}):null]},o.cli)})})]}),e.jsxs("div",{className:"wf-cli-policy__footer",children:[e.jsxs("div",{className:"wf-cli-policy__footer-status",children:[x==="saved"?e.jsxs("span",{className:"wf-cli-policy__status wf-cli-policy__status--saved",children:[e.jsx(M,{size:12}),s("workflows.cli.saved")]}):null,x==="error"?e.jsx("span",{className:"wf-cli-policy__status wf-cli-policy__status--error",children:s("workflows.cli.failed")}):null,!N&&a.length===0?e.jsx("span",{className:"wf-cli-policy__status wf-cli-policy__status--error",children:s("workflows.cli.pickOne")}):null,m?null:e.jsxs("span",{className:"wf-cli-policy__status",children:[e.jsx(P,{size:12,className:"animate-spin"}),s("workflows.loading")]})]}),e.jsxs("button",{type:"button",className:"drawer-action-btn wf-cli-policy__save pointer-coarse:min-h-9",onClick:_,disabled:!N,children:[e.jsx(ae,{size:14}),s(j?"workflows.cli.saving":"workflows.cli.save")]})]})]}):null]})},Re=s=>({running:e.jsx(P,{size:14,className:"animate-spin text-accent","aria-label":s("workflows.status.running")}),completed:e.jsx(M,{size:14,className:"text-status-green","aria-label":s("workflows.status.completed")}),failed:e.jsx(Y,{size:14,className:"text-status-red","aria-label":s("workflows.status.failed")}),interrupted:e.jsx(q,{size:14,className:"text-status-orange","aria-label":s("workflows.status.interrupted")}),stopped:e.jsx(q,{size:14,className:"text-ter","aria-label":s("workflows.status.stopped")})}),Ae={running:"drawer-status-badge--running",completed:"drawer-status-badge--completed",failed:"drawer-status-badge--failed",interrupted:"drawer-status-badge--interrupted",stopped:"drawer-status-badge--stopped"},Ee=s=>{const l=s.split(/[\\/]/);return l[l.length-1]??s},B=(s,l)=>{const t=Math.floor((Date.now()-s)/1e3);return t<60?l("common.time.sAgo",{count:t}):t<3600?l("common.time.mAgo",{count:Math.floor(t/60)}):t<86400?l("common.time.hAgo",{count:Math.floor(t/3600)}):l("common.time.dAgo",{count:Math.floor(t/86400)})},$=(s,l=80)=>{if(!s)return"";const t=s.trim();return t.length<=l?t:`${t.slice(0,l-1)}…`},Me=(s,l)=>{const t=(l??Date.now())-s;if(t<1e3)return`${t}ms`;const a=Math.floor(t/1e3);if(a<60)return`${a}s`;if(a<3600){const c=Math.floor(a/60),m=a%60;return m===0?`${c}m`:`${c}m${m}s`}const i=Math.floor(a/3600),n=Math.floor(a%3600/60);return n===0?`${i}h`:`${i}h${n}m`},Le=s=>{if(s==null)return null;if(typeof s=="string")return s;try{return JSON.stringify(s)}catch{return null}},Oe=s=>typeof s=="string"?s:JSON.stringify(s,null,2),Pe=s=>{const l=new Map,t=[];for(const n of s)if(n.parentRunId){const c=l.get(n.parentRunId)??[];c.push(n),l.set(n.parentRunId,c)}else t.push(n);const a=[];for(const n of t){a.push({run:n,depth:0});const c=l.get(n.id)??[];for(const m of c)a.push({run:m,depth:1})}const i=new Set(a.map(n=>n.run.id));for(const n of s)i.has(n.id)||a.push({run:n,depth:0});return a},Ie={queued:{mark:"○",tone:"text-ter"},submitted:{mark:"◐",tone:"text-accent"},reported:{mark:"●",tone:"text-status-green"},cancelled:{mark:"⊘",tone:"text-status-red"}},De=(s,l)=>l(`workflows.dispatchStatus.${s}`),We=({dispatch:s})=>{const[l,t]=d.useState(!1),[a,i]=d.useState(null),[n,c]=d.useState(null),{t:m}=z(),b=Ie[s.status],j=s.label??`step-${s.stepIndex??"?"}`,f=s.reportText?$(s.reportText,80):null,x=s.status==="submitted"&&s.lastPtyLine?$(s.lastPtyLine,80):null,y=s.status==="submitted"?x?null:m("workflows.dispatchStatus.awaitingReport"):s.status==="cancelled"?m("workflows.dispatchStatus.cancelled"):s.status==="queued"?m("workflows.dispatchStatus.queued"):null;return d.useEffect(()=>{if(i(null),c(null),!l)return;let h=!1;return be(s.workspaceId,s.id).then(w=>{h||i(w)}).catch(w=>{h||c(w instanceof Error?w.message:String(w))}),()=>{h=!0}},[s.id,s.workspaceId,l]),e.jsxs("div",{className:"wf-dispatch-item rounded-md text-xs","data-testid":`workflow-dispatch-row-${s.id}`,"data-dispatch-status":s.status,children:[e.jsxs("button",{type:"button",onClick:()=>t(h=>!h),className:"wf-dispatch-header","aria-expanded":l,children:[e.jsx("span",{className:`wf-dispatch-mark ${b.tone}`,"aria-hidden":!0,children:b.mark}),e.jsxs("span",{className:"wf-dispatch-step",title:`step ${s.stepIndex??"?"}`,children:["#",s.stepIndex??"?"]}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"wf-dispatch-title",children:j}),e.jsx("span",{className:`wf-dispatch-status wf-dispatch-status--${s.status}`,children:De(s.status,m)}),f?e.jsxs("span",{className:"wf-dispatch-summary",children:["↳ ",f]}):x?e.jsxs("span",{className:"wf-dispatch-summary",title:s.lastPtyLine,"data-testid":`workflow-dispatch-pty-${s.id}`,children:[e.jsx("span",{className:"text-accent",children:"⟶"}),e.jsx("span",{className:"font-mono",children:x})]}):y?e.jsx("span",{className:"wf-dispatch-summary italic",children:y}):null]})]}),l?e.jsxs("div",{className:"wf-dispatch-detail","data-testid":`workflow-dispatch-detail-${s.id}`,children:[s.text?e.jsxs("div",{children:[e.jsx("div",{className:"wf-dispatch-detail__label",children:"prompt"}),e.jsx("div",{className:"whitespace-pre-wrap text-pri",children:s.text})]}):null,s.reportText?e.jsxs("div",{children:[e.jsx("div",{className:"wf-dispatch-detail__label",children:"report"}),e.jsx("div",{className:"whitespace-pre-wrap text-pri",children:s.reportText})]}):null,a&&a.length>0?e.jsxs("div",{children:[e.jsx("div",{className:"wf-dispatch-detail__label",children:"memory injected"}),e.jsx("ul",{className:"space-y-1",children:a.map(h=>e.jsxs("li",{className:"break-words text-sec",children:[e.jsx("span",{className:"drawer-kind-badge",style:{marginRight:4},children:h.memory.kind})," ",$(h.memory.body,120)]},h.id))})]}):null,n?e.jsxs("div",{className:"drawer-card__error",children:["Memory: ",n]}):null]}):null]})},qe=s=>{const l=[],t=new Map;for(const a of s){const i=a.phase??"—";let n=t.get(i);n||(n={title:i,dispatches:[]},t.set(i,n),l.push(n)),n.dispatches.push(a)}return l},Fe=({group:s,runStatus:l,defaultOpen:t})=>{const[a,i]=d.useState(t),n=s.dispatches.filter(f=>f.status==="reported"||f.status==="cancelled").length,c=s.dispatches.length,m=n===c,b=!m&&l==="running",j=c>0?Math.round(n/c*100):0;return e.jsxs("div",{className:"wf-phase-strip","data-testid":`workflow-phase-${s.title}`,children:[e.jsxs("button",{type:"button",onClick:()=>i(f=>!f),className:"wf-phase-strip__toggle pointer-coarse:min-h-10","aria-expanded":a,children:[e.jsx("span",{className:"wf-phase-strip__chevron",children:a?e.jsx(L,{size:11}):e.jsx(O,{size:11})}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] font-semibold text-sec",children:s.title==="—"?"(no phase)":s.title}),e.jsxs("span",{className:`wf-phase-strip__badge ${m?"wf-phase-strip__badge--done":b?"wf-phase-strip__badge--running":""}`,children:[n,"/",c,b?" ⟳":m?" ✓":""]})]}),e.jsx("div",{className:"wf-phase-strip__bar",children:e.jsx("span",{style:{width:`${j}%`},className:m?"wf-phase-strip__bar-fill--done":b?"wf-phase-strip__bar-fill--running":"wf-phase-strip__bar-fill"})}),a?e.jsx("div",{className:"wf-phase-body","data-testid":`workflow-phase-body-${s.title}`,children:s.dispatches.map(f=>e.jsx(We,{dispatch:f},f.id))}):null]})},Ue=({runId:s,result:l})=>{const[t,a]=d.useState(!1),[i,n]=d.useState(!1),c=Oe(l),m=async()=>{try{await navigator.clipboard.writeText(c),n(!0),setTimeout(()=>n(!1),1200)}catch{}};return e.jsxs("div",{className:"wf-result mb-2","data-testid":`workflow-run-result-${s}`,children:[e.jsxs("div",{className:"wf-result__header",children:[e.jsx("div",{className:"wf-result__label",children:"Result"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(S,{label:i?"Copied!":"Copy result",children:e.jsx("button",{type:"button",onClick:m,"aria-label":"Copy result",className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-run-result-copy-${s}`,children:i?e.jsx(D,{size:11,className:"text-status-green"}):e.jsx(W,{size:11})})}),e.jsx(S,{label:"Expand",children:e.jsx("button",{type:"button",onClick:()=>a(!0),"aria-label":"Expand result",className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-run-result-expand-${s}`,children:e.jsx(je,{size:11})})})]})]}),e.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-xs text-pri",children:c}),t?e.jsx(X,{open:t,onOpenChange:b=>a(b),children:e.jsxs(G,{children:[e.jsx(J,{className:"fixed inset-0 z-40 bg-black/60"}),e.jsxs(Q,{className:"fixed inset-4 z-50 flex flex-col rounded-lg border bg-[var(--bg-1)] p-4 shadow-xl md:inset-8 lg:inset-16",style:{borderColor:"var(--border-bright)"},"data-testid":`workflow-run-result-modal-${s}`,children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx(K,{className:"text-sm font-semibold",children:"Workflow result"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(S,{label:i?"Copied!":"Copy",children:e.jsx("button",{type:"button",onClick:m,"aria-label":"Copy",className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:i?e.jsx(D,{size:14,className:"text-status-green"}):e.jsx(W,{size:14})})}),e.jsx(ge,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"Close",className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:e.jsx(V,{size:14})})})]})]}),e.jsx("textarea",{readOnly:!0,value:c,className:"min-h-0 flex-1 resize-none rounded border bg-[var(--bg-0)] p-2 font-mono text-xs",style:{borderColor:"var(--border)"}})]})]})}):null]})},H=({run:s,onStop:l})=>{const[t,a]=d.useState(!1),[i,n]=d.useState(null),[c,m]=d.useState(null),[b,j]=d.useState(!1),[f,x]=d.useState(null),[y,h]=d.useState(!1),{t:w}=z(),u=[];s.phase&&u.push({key:"phase",text:`phase: ${s.phase}`}),s.agentCount>0&&u.push({key:"agentCount",text:`${s.agentCount} agent${s.agentCount===1?"":"s"}`}),s.status!=="running"&&u.push({key:"duration",text:Me(s.startedAt,s.finishedAt)});const r=Le(s.args),N=r?$(r,60):null;return d.useEffect(()=>{if(!t)return;let p=!1;return j(!0),x(null),Promise.all([fe(s.id),me(s.id)]).then(([_,o])=>{p||(n(_),m(o))}).catch(_=>{p||x(_ instanceof Error?_.message:String(_))}).finally(()=>{p||j(!1)}),()=>{p=!0}},[t,s.id,s.status]),e.jsxs("div",{className:"drawer-card text-xs","data-testid":`workflow-run-row-${s.id}`,"data-run-status":s.status,children:[e.jsxs("div",{className:"wf-run-summary-row",children:[e.jsxs("button",{type:"button",onClick:()=>a(p=>!p),className:"wf-run-toggle","aria-expanded":t,"data-testid":`workflow-run-toggle-${s.id}`,children:[e.jsx("span",{className:"wf-run-toggle__chevron",children:t?e.jsx(L,{size:11}):e.jsx(O,{size:11})}),e.jsx("span",{className:"wf-run-toggle__icon",children:Re(w)[s.status]}),e.jsxs("span",{className:"wf-run-toggle__main",children:[e.jsx("span",{className:"wf-run-toggle__name",children:s.name}),e.jsxs("span",{className:"wf-run-toggle__meta",children:[e.jsx("span",{className:`drawer-status-badge ${Ae[s.status]}`,children:w(`workflows.status.${s.status}`)}),s.status==="running"?B(s.startedAt,w):B(s.finishedAt??s.startedAt,w)]})]})]}),s.status==="running"?e.jsx("div",{className:"drawer-card__actions pr-1 wf-run-stop-area",children:e.jsx(S,{label:w("workflows.stopTooltip"),children:e.jsx("button",{type:"button",onClick:async()=>{h(!0);try{await l()}finally{h(!1)}},disabled:y,"aria-label":w("workflows.stopTooltip"),className:"wf-run-stop-btn icon-btn icon-btn--danger mr-1 disabled:opacity-50 pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-run-stop-${s.id}`,children:e.jsx(_e,{size:12})})})}):null]}),u.length>0||N?e.jsxs("div",{className:"wf-run-meta","data-testid":`workflow-run-meta-${s.id}`,children:[u.length>0?u.map(p=>e.jsx("span",{className:"wf-run-meta__item",children:p.text},p.key)):null,N?e.jsxs("span",{className:"wf-run-meta__item wf-run-meta__args",title:r??void 0,children:["args: ",N]}):null]}):null,t?e.jsxs("div",{className:"wf-run-detail","data-testid":`workflow-run-detail-${s.id}`,children:[s.result!==null&&s.result!==void 0?e.jsx(Ue,{runId:s.id,result:s.result}):null,f?e.jsx("div",{className:"text-error",children:f}):b&&i===null?e.jsx("div",{className:"text-ter",children:w("workflows.loading")}):i&&i.length>0?(()=>{const p=qe(i),_=p.length-1;return e.jsx("div",{className:"space-y-1.5",children:p.map((o,g)=>e.jsx(Fe,{group:o,runStatus:s.status,defaultOpen:p.length===1||g===_},o.title))})})():e.jsx("div",{className:"text-ter italic",children:w("workflows.noAgents")}),c&&c.length>0?e.jsxs("div",{className:"wf-logs-panel","data-testid":`workflow-run-logs-${s.id}`,children:[e.jsx("div",{className:"wf-logs-panel__title",children:c.length===1?w("workflows.narratorOne"):w("workflows.narrator",{count:c.length})}),e.jsx("ul",{className:"space-y-0.5 font-mono text-[11px]",children:c.map(p=>e.jsx("li",{className:"text-sec",children:p.message},p.id))})]}):null,s.error?e.jsx("div",{className:"text-error",children:w("workflows.runError",{error:s.error})}):null]}):null]})},Be=({schedule:s,onToggle:l,onDelete:t})=>{const{t:a}=z();return e.jsxs("div",{className:"drawer-card wf-schedule-row flex items-center gap-3","data-testid":`workflow-schedule-row-${s.id}`,"data-schedule-enabled":s.enabled?"true":"false",children:[e.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md",style:{background:s.enabled?"color-mix(in oklab, var(--accent) 12%, transparent)":"var(--bg-3)",color:s.enabled?"var(--accent)":"var(--text-tertiary)"},children:e.jsx(ee,{size:13})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[12.5px] font-medium text-pri",children:Ee(s.scriptPath)}),e.jsx("div",{className:"truncate font-mono text-[10.5px] text-ter mt-0.5",children:s.cron})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[e.jsx(S,{label:s.enabled?a("workflows.pauseTooltip"):a("workflows.resumeTooltip"),children:e.jsx("button",{type:"button",onClick:()=>{l(!s.enabled)},"aria-label":s.enabled?a("workflows.pauseTooltip"):a("workflows.resumeTooltip"),className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-schedule-toggle-${s.id}`,children:s.enabled?e.jsx(Se,{size:12}):e.jsx(pe,{size:12})})}),e.jsx(S,{label:a("workflows.deleteScheduleTooltip"),children:e.jsx("button",{type:"button",onClick:()=>{t()},"aria-label":a("workflows.deleteScheduleTooltip"),className:"icon-btn icon-btn--danger pointer-coarse:min-h-11 pointer-coarse:min-w-11","data-testid":`workflow-schedule-delete-${s.id}`,children:e.jsx(he,{size:12})})})]})]})},He=({workspaceId:s,onClose:l})=>{const{t}=z(),a=re(),{runs:i,schedules:n,error:c,refresh:m,refreshSchedules:b}=Ce({workspaceId:s,enabled:!0}),[j,f]=d.useState("all"),x=i.filter(u=>u.status==="running").length,y=i.filter(u=>u.status==="failed"||u.status==="stopped"||u.status==="interrupted").length,h=async(u,r)=>{try{await xe(u,{enabled:r})}catch(N){a.show({kind:"error",message:N instanceof Error?N.message:String(N)})}finally{await b()}},w=async u=>{try{await we(u)}catch(r){a.show({kind:"error",message:r instanceof Error?r.message:String(r)})}finally{await b()}};return e.jsxs("div",{className:"workflows-content flex h-full min-h-0 flex-col","data-testid":"workflows-content",children:[e.jsxs("header",{className:"wf-panel-header border-b px-4 py-3",style:{borderColor:"var(--border)"},children:[e.jsxs("div",{className:"wf-panel-header__main",children:[e.jsx("div",{className:"wf-panel-header__icon",style:{background:"color-mix(in oklab, var(--accent) 14%, transparent)",color:"var(--accent)"},children:e.jsx(A,{size:15,"aria-hidden":!0})}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[e.jsx("span",{className:"text-[13px] font-semibold text-pri leading-tight",children:t("workflows.title")}),e.jsxs("div",{className:"relative group inline-block cursor-help shrink-0",children:[e.jsx(ie,{size:12,className:"text-ter hover:text-sec transition-colors"}),e.jsx("div",{className:"absolute hidden group-hover:block left-0 top-full mt-1.5 w-72 p-3 bg-[var(--bg-2)] border border-border rounded-xl shadow-2xl text-[11px] text-sec leading-relaxed z-50 pointer-events-none",children:t("workflows.description")})]}),e.jsx("span",{className:"wf-panel-count","data-testid":"workflows-summary-count",children:i.length})]})]}),l?e.jsx(S,{label:t("common.close"),children:e.jsx("button",{type:"button",onClick:l,"aria-label":t("common.close"),className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:e.jsx(V,{size:14})})}):null]}),e.jsxs("div",{className:"scroll-y flex-1 px-4 py-3",children:[c?e.jsx("div",{className:"mb-3 rounded-md border px-3 py-2 text-xs",style:{borderColor:"color-mix(in oklab, var(--status-red) 30%, var(--border))",color:"var(--text-error)",background:"color-mix(in oklab, var(--status-red) 8%, transparent)"},"data-testid":"workflows-error",children:c}):null,e.jsxs("div",{className:"flex flex-col md:flex-row gap-5 items-start",children:[e.jsxs("div",{className:"flex-1 min-w-0 w-full space-y-4",children:[e.jsxs("section",{className:"wf-content-section mb-0",children:[e.jsxs("div",{className:"drawer-section__header mb-2",children:[e.jsxs("div",{className:"wf-section-title",children:[e.jsx(oe,{size:14,"aria-hidden":!0,className:"text-sec"}),e.jsxs("div",{children:[e.jsx("h3",{className:"drawer-section-label wf-section-label-tight",children:t("workflows.recentRuns")}),e.jsx("p",{className:"wf-section-subtitle",children:x>0?`${x} ${t("workflows.filterRunning")}`:t("workflows.emptyRunsDesc")})]})]}),i.length>0?(()=>{const u=({id:r,label:N,count:p})=>e.jsxs("button",{type:"button",onClick:()=>f(r),"aria-pressed":j===r,"data-testid":`workflow-runs-filter-${r}`,className:`wf-run-filter-pill pointer-coarse:min-h-9 pointer-coarse:text-xs ${j===r?"wf-run-filter-pill--active":""}`,children:[r==="all"?e.jsx(A,{size:11,"aria-hidden":!0}):r==="running"?e.jsx(P,{size:11,"aria-hidden":!0,className:"animate-spin"}):e.jsx(Y,{size:11,"aria-hidden":!0}),e.jsx("span",{children:N}),e.jsx("span",{className:"wf-run-filter-pill__count",children:p})]});return e.jsxs("div",{className:"wf-run-filters",children:[e.jsx(u,{id:"all",label:t("workflows.filterAll"),count:i.length}),e.jsx(u,{id:"running",label:t("workflows.filterRunning"),count:x}),e.jsx(u,{id:"failed",label:t("workflows.filterFailed"),count:y})]})})():null]}),i.length===0?e.jsx("div",{className:"wf-empty-surface",children:e.jsx(ce,{icon:e.jsx(A,{size:18}),title:t("workflows.emptyRuns"),description:t("workflows.emptyRunsDesc")})}):(()=>{const u=j==="all"?i:j==="running"?i.filter(r=>r.status==="running"):i.filter(r=>r.status==="failed"||r.status==="stopped"||r.status==="interrupted");return u.length===0?e.jsx("div",{className:"wf-empty-inline","data-testid":"workflow-runs-empty-filter",children:t("workflows.emptyFilter")}):e.jsx("ul",{className:"space-y-2",children:Pe(u.slice(0,20)).map(({run:r,depth:N})=>e.jsx("li",{className:`wf-run-tree-item ${N>0?"wf-run-tree-item--child":""}`,"data-testid":`workflow-run-tree-${r.id}`,"data-depth":N,children:N>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"wf-tree-connector","aria-hidden":"true"}),e.jsx("div",{className:"wf-run-tree-item__content",children:e.jsx(H,{run:r,onStop:async()=>{try{await I(r.id)}catch(p){a.show({kind:"error",message:p instanceof Error?p.message:String(p)})}finally{await m()}}})})]}):e.jsx("div",{className:"wf-run-tree-item__content",children:e.jsx(H,{run:r,onStop:async()=>{try{await I(r.id)}catch(p){a.show({kind:"error",message:p instanceof Error?p.message:String(p)})}finally{await m()}}})})},r.id))})})()]}),n.length>0?e.jsxs("section",{className:"wf-content-section mb-0","data-testid":"workflows-schedules-section",children:[e.jsx("div",{className:"drawer-section__header mb-2",children:e.jsxs("div",{className:"wf-section-title",children:[e.jsx(ee,{size:14,"aria-hidden":!0,className:"text-sec"}),e.jsxs("div",{children:[e.jsx("h3",{className:"drawer-section-label wf-section-label-tight",children:t("workflows.schedules")}),e.jsxs("p",{className:"wf-section-subtitle",children:[n.length," ",t("workflows.schedules")]})]})]})}),e.jsx("ul",{className:"space-y-1.5",children:n.map(u=>e.jsx("li",{children:e.jsx(Be,{schedule:u,onToggle:r=>h(u.id,r),onDelete:()=>w(u.id)})},u.id))})]}):null]}),e.jsx("div",{className:"w-full md:w-[280px] shrink-0 wf-sidebar-settings",children:e.jsxs("section",{className:"drawer-section",children:[e.jsx("div",{className:"drawer-section__header mb-2",children:e.jsxs("div",{className:"wf-section-title",children:[e.jsx(de,{size:14,"aria-hidden":!0,className:"text-sec"}),e.jsx("h3",{className:"drawer-section-label wf-section-label-tight",children:t("workflows.cli.title")})]})}),e.jsx(Te,{})]})})]})]})]})},Ge=({open:s,onClose:l,workspaceId:t})=>{const a=ue(),{t:i}=z();return e.jsx(X,{open:s,onOpenChange:n=>!n&&l(),children:e.jsxs(G,{children:[e.jsx(J,{"data-testid":"workflows-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(Q,{"data-testid":"workflows-drawer","aria-label":i("workflows.title"),"data-mobile":a||void 0,className:"dialog-scale-pop elev-2 pointer-events-auto flex flex-col rounded-lg border",style:a?{background:"var(--bg-1)",borderColor:"var(--border-bright)"}:{background:"var(--bg-1)",borderColor:"var(--border-bright)",height:"min(720px, calc(100vh - 48px))",width:"min(780px, calc(100vw - 48px))"},children:[e.jsx(K,{className:"sr-only",children:i("workflows.title")}),e.jsx(He,{workspaceId:t,onClose:l})]})})]})})};export{He as WorkflowsContent,Ge as WorkflowsDrawer};
@@ -1 +1 @@
1
- import{c as g,i as te,u as W,r as c,D as ae,F as re,G as ne,j as e,R as ie,P as le,O as oe,k as ce,m as de,T as j,X as me,L as k,H as V,E as H,J as K,K as pe,N as xe,Q as he,U as ue,V as be,Y as U,Z as fe}from"./index-B3XoRj0C.js";import{S as je}from"./search-BdM5IXYB.js";const ge=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],ye=g("archive",ge);const ve=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Ne=g("eye-off",ve);const we=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]],ke=g("pin-off",we);const Se=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],$e=g("pin",Se);const Ce=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Me=g("settings-2",Ce),G={decision:"memory.kind.decision",fact:"memory.kind.fact",pitfall:"memory.kind.pitfall",preference:"memory.kind.preference",procedure_ref:"memory.kind.procedure_ref"},Te=new Intl.DateTimeFormat(void 0,{day:"2-digit",hour:"2-digit",minute:"2-digit",month:"short"}),S=(r,s)=>r?Te.format(new Date(r)):s("common.never"),I=(r,s=140)=>{const a=r.trim();return a.length<=s?a:`${a.slice(0,s-1)}…`},Re=r=>{const s=r.sources[0];return s?.actorNameSnapshot?`${r.source} · ${s.actorNameSnapshot}`:r.source},_e=r=>r==="dreams"?null:r,Ee=({busy:r,memory:s,onArchive:a,onToggleDisabled:p,onTogglePinned:n})=>{const[i,d]=c.useState(!1),{t:o}=W();return e.jsxs("li",{className:"drawer-card p-3","data-testid":`memory-row-${s.id}`,"data-pinned":s.pinned,"data-disabled":s.disabled,children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>d(m=>!m),"aria-expanded":i,className:"min-w-0 flex-1 text-left focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-[var(--accent)]",children:[e.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`drawer-kind-badge drawer-kind-badge--${s.kind}`,children:o(G[s.kind])}),s.pinned?e.jsx("span",{className:"font-medium text-accent",children:o("memory.pinned")}):null,s.scope==="user"?e.jsx("span",{className:"text-ter",children:o("memory.scopeUser")}):null,s.disabled?e.jsx("span",{className:"text-ter",children:o("memory.disabled")}):null,e.jsx("span",{className:"text-ter",children:Re(s)})]}),e.jsx("p",{className:"break-words text-sm text-pri leading-snug",children:i?s.body:I(s.body)}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1 text-[11px] text-ter",children:[s.tags.map(m=>e.jsx("span",{className:"rounded border px-1.5 py-0.5",style:{borderColor:"var(--border)"},children:m},m)),e.jsx("span",{children:o("memory.updated",{time:S(s.updatedAt,o)})}),e.jsx("span",{children:o("memory.injected",{time:S(s.lastInjectedAt,o)})}),s.procedureRef?e.jsx("span",{children:`${s.procedureRef.type}: ${s.procedureRef.title??s.procedureRef.id}`}):null]})]}),e.jsx("div",{className:"flex shrink-0 items-center gap-1 drawer-card__actions",children:s.status==="active"?e.jsxs(e.Fragment,{children:[e.jsx(j,{label:s.pinned?o("memory.unpinTooltip"):o("memory.pinTooltip"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>n(s),"aria-label":s.pinned?o("memory.unpinTooltip"):o("memory.pinTooltip"),className:"icon-btn pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:s.pinned?e.jsx(ke,{size:13}):e.jsx($e,{size:13})})}),e.jsx(j,{label:s.disabled?o("memory.enableTooltip"):o("memory.disableTooltip"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>p(s),"aria-label":s.disabled?o("memory.enableTooltip"):o("memory.disableTooltip"),className:"icon-btn pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:s.disabled?e.jsx(ue,{size:13}):e.jsx(Ne,{size:13})})}),e.jsx(j,{label:o("memory.archiveButton"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>a(s),"aria-label":o("memory.archiveButton"),className:"icon-btn icon-btn--danger pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:e.jsx(ye,{size:13})})})]}):null})]}),i?e.jsxs("div",{className:"drawer-card__expanded",children:[e.jsx("h4",{className:"drawer-section-label",children:o("memory.sources")}),s.sources.length===0?e.jsx("p",{className:"text-ter",children:o("memory.noSources")}):e.jsx("ul",{className:"space-y-2",children:s.sources.map(m=>e.jsxs("li",{className:"break-words",children:[e.jsxs("div",{className:"text-ter",children:[m.sourceType,m.actorNameSnapshot?` · ${m.actorNameSnapshot}`:"",m.actorRoleSnapshot?` · ${m.actorRoleSnapshot}`:""]}),m.excerpt?e.jsx("p",{className:"mt-0.5",children:m.excerpt}):null]},m.id))})]}):null]})},Q=({label:r,checked:s,disabled:a,onChange:p})=>e.jsxs("label",{className:"drawer-settings-row",children:[e.jsx("span",{className:"text-sec",children:r}),e.jsx("input",{type:"checkbox",checked:s,disabled:a,onChange:n=>p(n.currentTarget.checked),className:"h-4 w-4 accent-[var(--accent)]"})]}),De=(r,s)=>r.report?[`${r.report.added.length} ${s("memory.reportAdded")}`,`${r.report.rewritten.length} ${s("memory.reportRewritten")}`,`${r.report.archived.length} ${s("memory.reportArchived")}`,`${r.report.merged.length} ${s("memory.reportMerged")}`].join(" · "):r.error?`${s("common.error")} · ${I(r.error,90)}`:s("memory.noReport"),ze=(r,s)=>r.inputSeqFrom===null||r.inputSeqTo===null?s("memory.noInput"):`${s("memory.seq")} ${r.inputSeqFrom}-${r.inputSeqTo}`,Ae=({busy:r,onRevert:s,run:a})=>{const[p,n]=c.useState(!1),{t:i}=W();return e.jsxs("li",{className:"drawer-card p-3","data-testid":`dream-run-${a.id}`,"data-dream-status":a.status,children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>n(d=>!d),"aria-expanded":p,className:"min-w-0 flex-1 text-left focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-[var(--accent)]",children:[e.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`drawer-status-badge drawer-status-badge--${a.status}`,children:i(`memory.status.${a.status}`)}),e.jsx("span",{className:"text-ter",children:i(`memory.trigger.${a.trigger}`)}),e.jsx("span",{className:"text-ter",children:ze(a,i)}),e.jsx("span",{className:"text-ter",children:i("memory.started",{time:S(a.startedAt,i)})})]}),e.jsx("p",{className:"break-words text-sm text-pri leading-snug",children:De(a,i)}),a.finishedAt?e.jsx("p",{className:"mt-1 text-[11px] text-ter",children:i("memory.finished",{time:S(a.finishedAt,i)})}):null]}),a.status==="completed"?e.jsx("div",{className:"drawer-card__actions",children:e.jsx(j,{label:i("memory.revertButton"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>s(a),"aria-label":i("memory.revertTooltip"),className:"icon-btn icon-btn--danger pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:r?e.jsx(k,{size:13,className:"animate-spin"}):e.jsx(he,{size:13})})})}):null]}),p&&a.report?e.jsxs("div",{className:"drawer-card__expanded space-y-3",children:[a.report.added.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-status-green",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-added flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-status-green"}),i("memory.diff.added")]}),e.jsx("ul",{className:"space-y-1.5 mt-1.5",children:a.report.added.map(d=>e.jsxs("li",{className:"break-words text-[11px] text-pri flex items-start gap-1",children:[e.jsx("span",{className:"text-status-green select-none font-semibold mr-1",children:"+"}),e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:`drawer-kind-badge drawer-kind-badge--${d.kind} scale-90 origin-left inline-block mr-1`,children:i(G[d.kind])}),d.body]})]},d.id))})]}):null,a.report.rewritten.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-[#f59e0b]",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-rewritten flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#f59e0b]"}),i("memory.diff.rewritten")]}),e.jsx("p",{className:"mt-1.5 text-[11px] text-sec leading-relaxed pl-3 break-all",children:a.report.rewritten.map(d=>d.id).join(", ")})]}):null,a.report.archived.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-status-red",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-archived flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-status-red"}),i("memory.diff.archived")]}),e.jsx("p",{className:"mt-1.5 text-[11px] text-sec leading-relaxed pl-3 break-all",children:a.report.archived.map(d=>d.id).join(", ")})]}):null,a.report.merged.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-purple-500",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-merged flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-purple-500"}),i("memory.diff.merged")]}),e.jsx("p",{className:"mt-1.5 text-[11px] text-sec leading-relaxed pl-3 break-all",children:a.report.merged.map(d=>d.into).join(", ")})]}):null]}):null,p&&a.error?e.jsx("p",{className:"drawer-card__error",children:a.error}):null]})},qe=({open:r,onClose:s,workspaceId:a})=>{const p=te(),{t:n}=W(),[i,d]=c.useState("active"),[o,m]=c.useState(""),[y,$]=c.useState([]),[v,C]=c.useState([]),[M,N]=c.useState(null),[q,T]=c.useState(!1),[L,x]=c.useState(null),[J,B]=c.useState(null),[R,w]=c.useState(null),[_,E]=c.useState(null),[D,z]=c.useState(null),[A,F]=c.useState(!1),b=c.useRef(0),X=c.useMemo(()=>[{id:"active",label:n("memory.tabActive")},{id:"archived",label:n("memory.tabArchived")},{id:"dreams",label:n("memory.tabDreams")}],[n]),u=_e(i),f=c.useCallback(async()=>{const t=b.current+1;if(b.current=t,!a||!r){$([]),C([]),N(null),T(!1);return}T(!0),x(null),$([]),C([]),N(null);try{const[l,h,se]=await Promise.all([ae(a),u?re(a,{query:o,scope:"all",status:u}):Promise.resolve([]),u?Promise.resolve([]):ne(a,{limit:20})]);if(b.current!==t)return;N(l),$(h),C(se)}catch(l){b.current===t&&x(l instanceof Error?l.message:String(l))}finally{b.current===t&&T(!1)}},[r,o,u,a]);c.useEffect(()=>{f()},[f]);const P=async(t,l)=>{if(a){B(t.id),x(null);try{await l(a),await f()}catch(h){x(h instanceof Error?h.message:String(h))}finally{B(null)}}},Y=c.useMemo(()=>({current:u?y.length:v.length}),[v.length,y.length,u]),O=async t=>{if(!(!a||A)){F(!0),x(null);try{N(await xe(a,t))}catch(l){x(l instanceof Error?l.message:String(l))}finally{F(!1)}}},Z=async()=>{if(a){w("run-now"),x(null);try{await pe(a),await f()}catch(t){x(t instanceof Error?t.message:String(t))}finally{w(null)}}},ee=async t=>{if(a){w(t.id),x(null);try{await be(a,t.id),await f()}catch(l){x(l instanceof Error?l.message:String(l))}finally{w(null)}}};return e.jsxs(e.Fragment,{children:[e.jsx(ie,{open:r,onOpenChange:t=>!t&&s(),children:e.jsxs(le,{children:[e.jsx(oe,{"data-testid":"memory-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(ce,{"data-testid":"memory-drawer","aria-label":n("memory.title"),"data-mobile":p||void 0,className:"dialog-scale-pop elev-2 pointer-events-auto flex flex-col rounded-lg border",style:p?{background:"var(--bg-1)",borderColor:"var(--border-bright)"}:{background:"var(--bg-1)",borderColor:"var(--border-bright)",height:"min(720px, calc(100vh - 48px))",width:"min(780px, calc(100vw - 48px))"},children:[e.jsxs("header",{className:"flex items-center justify-between border-b px-4 py-2",style:{borderColor:"var(--border)"},children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(de,{className:"text-base font-semibold text-pri",children:n("memory.title")}),e.jsx("p",{className:"text-xs text-ter",children:n("memory.subtitle")})]}),e.jsx(j,{label:n("common.close"),children:e.jsx("button",{type:"button",onClick:s,"aria-label":n("common.close"),className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:e.jsx(me,{size:14})})})]}),e.jsxs("div",{className:`flex gap-2 border-b px-4 py-2 ${p?"flex-col items-stretch":"items-center gap-2"}`,style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"drawer-tabs",style:p?{width:"100%",justifyContent:"flex-start"}:void 0,children:X.map(t=>e.jsx("button",{type:"button",onClick:()=>d(t.id),"aria-pressed":i===t.id,className:`drawer-tab pointer-coarse:min-h-10 ${i===t.id?"drawer-tab--active":""}`,children:t.label},t.id))}),u?e.jsxs("label",{className:"drawer-search",style:p?{width:"100%",maxWidth:"none"}:{marginLeft:"auto"},children:[e.jsx("span",{className:"sr-only",children:n("memory.searchPlaceholder")}),e.jsx(je,{size:14,className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-ter"}),e.jsx("input",{value:o,onChange:t=>m(t.currentTarget.value),placeholder:n("memory.searchPlaceholder"),name:"memory-search",autoComplete:"off",className:"h-8 w-full rounded-md border bg-transparent pl-8 pr-3 text-xs text-pri outline-none transition-colors placeholder:text-ter focus-visible:border-[var(--accent)]",style:{borderColor:"var(--border-bright)"}})]}):null]}),e.jsxs("div",{className:"scroll-y min-h-0 flex-1 px-4 py-3",children:[L?e.jsx("div",{className:"mb-3 rounded-md border px-3 py-2 text-xs",style:{borderColor:"color-mix(in oklab, var(--status-red) 30%, var(--border))",color:"var(--text-error)",background:"color-mix(in oklab, var(--status-red) 8%, transparent)"},children:L}):null,e.jsxs("section",{className:"drawer-section",children:[e.jsxs("div",{className:"drawer-section__header",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Me,{size:14,className:"text-sec"}),e.jsxs("span",{className:"font-medium text-sec",children:[Y.current," ",n(u?"memory.entries":"memory.runs")]})]}),i==="dreams"?e.jsxs("button",{type:"button",onClick:Z,disabled:R!==null,className:"drawer-action-btn pointer-coarse:min-h-10",children:[R==="run-now"?e.jsx(k,{size:14,className:"animate-spin"}):e.jsx(V,{size:14}),n("memory.runNow")]}):null]}),M?e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[e.jsx(Q,{label:n("memory.injection"),checked:M.enabled,disabled:A,onChange:t=>O({enabled:t})}),e.jsx(Q,{label:n("memory.dreamProcessing"),checked:M.dreamEnabled,disabled:A,onChange:t=>O({dreamEnabled:t})})]}):null]}),i==="dreams"?q?e.jsxs("div",{className:"flex h-[320px] items-center justify-center text-ter",children:[e.jsx(k,{size:18,className:"animate-spin"}),e.jsx("span",{className:"ml-2 text-sm",children:n("common.loading")})]}):v.length===0?e.jsx("div",{className:"flex h-[320px] items-center justify-center",children:e.jsx(H,{icon:e.jsx(V,{size:20}),title:n("memory.emptyDreams"),description:n("memory.emptyDreamsDesc")})}):e.jsx("ul",{className:"space-y-2",children:v.map(t=>e.jsx(Ae,{run:t,busy:R===t.id,onRevert:z},t.id))}):q?e.jsxs("div",{className:"flex h-[320px] items-center justify-center text-ter",children:[e.jsx(k,{size:18,className:"animate-spin"}),e.jsx("span",{className:"ml-2 text-sm",children:n("common.loading")})]}):y.length===0?e.jsx("div",{className:"flex h-[320px] items-center justify-center",children:e.jsx(H,{title:n("memory.emptyActive"),description:n("memory.emptyActiveDesc")})}):e.jsx("ul",{className:"space-y-2",children:y.map(t=>e.jsx(Ee,{memory:t,busy:J===t.id,onArchive:E,onToggleDisabled:l=>P(l,h=>U(h,l.id,{disabled:!l.disabled})),onTogglePinned:l=>P(l,h=>U(h,l.id,{pinned:!l.pinned}))},t.id))})]})]})})]})}),e.jsx(K,{open:_!==null,onOpenChange:t=>{t||E(null)},title:n("memory.archiveTitle"),description:n("memory.archiveDesc"),confirmLabel:n("memory.archiveButton"),confirmKind:"danger",onConfirm:()=>{if(!_)return;const t=_;E(null),P(t,l=>fe(l,t.id))}}),e.jsx(K,{open:D!==null,onOpenChange:t=>{t||z(null)},title:n("memory.revertTitle"),description:n("memory.revertDesc"),confirmLabel:n("memory.revertButton"),confirmKind:"danger",onConfirm:()=>{if(!D)return;const t=D;z(null),ee(t)}})]})};export{qe as WorkspaceMemoryDrawer};
1
+ import{c as g,i as te,u as W,r as c,D as ae,F as re,G as ne,j as e,R as ie,P as le,O as oe,k as ce,m as de,T as j,X as me,L as k,H as V,E as H,J as K,K as pe,N as xe,Q as he,U as ue,V as be,Y as U,Z as fe}from"./index-D43vHIy2.js";import{S as je}from"./search-KbSLfFB8.js";const ge=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],ye=g("archive",ge);const ve=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Ne=g("eye-off",ve);const we=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]],ke=g("pin-off",we);const Se=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],$e=g("pin",Se);const Ce=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Me=g("settings-2",Ce),G={decision:"memory.kind.decision",fact:"memory.kind.fact",pitfall:"memory.kind.pitfall",preference:"memory.kind.preference",procedure_ref:"memory.kind.procedure_ref"},Te=new Intl.DateTimeFormat(void 0,{day:"2-digit",hour:"2-digit",minute:"2-digit",month:"short"}),S=(r,s)=>r?Te.format(new Date(r)):s("common.never"),I=(r,s=140)=>{const a=r.trim();return a.length<=s?a:`${a.slice(0,s-1)}…`},Re=r=>{const s=r.sources[0];return s?.actorNameSnapshot?`${r.source} · ${s.actorNameSnapshot}`:r.source},_e=r=>r==="dreams"?null:r,Ee=({busy:r,memory:s,onArchive:a,onToggleDisabled:p,onTogglePinned:n})=>{const[i,d]=c.useState(!1),{t:o}=W();return e.jsxs("li",{className:"drawer-card p-3","data-testid":`memory-row-${s.id}`,"data-pinned":s.pinned,"data-disabled":s.disabled,children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>d(m=>!m),"aria-expanded":i,className:"min-w-0 flex-1 text-left focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-[var(--accent)]",children:[e.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`drawer-kind-badge drawer-kind-badge--${s.kind}`,children:o(G[s.kind])}),s.pinned?e.jsx("span",{className:"font-medium text-accent",children:o("memory.pinned")}):null,s.scope==="user"?e.jsx("span",{className:"text-ter",children:o("memory.scopeUser")}):null,s.disabled?e.jsx("span",{className:"text-ter",children:o("memory.disabled")}):null,e.jsx("span",{className:"text-ter",children:Re(s)})]}),e.jsx("p",{className:"break-words text-sm text-pri leading-snug",children:i?s.body:I(s.body)}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1 text-[11px] text-ter",children:[s.tags.map(m=>e.jsx("span",{className:"rounded border px-1.5 py-0.5",style:{borderColor:"var(--border)"},children:m},m)),e.jsx("span",{children:o("memory.updated",{time:S(s.updatedAt,o)})}),e.jsx("span",{children:o("memory.injected",{time:S(s.lastInjectedAt,o)})}),s.procedureRef?e.jsx("span",{children:`${s.procedureRef.type}: ${s.procedureRef.title??s.procedureRef.id}`}):null]})]}),e.jsx("div",{className:"flex shrink-0 items-center gap-1 drawer-card__actions",children:s.status==="active"?e.jsxs(e.Fragment,{children:[e.jsx(j,{label:s.pinned?o("memory.unpinTooltip"):o("memory.pinTooltip"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>n(s),"aria-label":s.pinned?o("memory.unpinTooltip"):o("memory.pinTooltip"),className:"icon-btn pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:s.pinned?e.jsx(ke,{size:13}):e.jsx($e,{size:13})})}),e.jsx(j,{label:s.disabled?o("memory.enableTooltip"):o("memory.disableTooltip"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>p(s),"aria-label":s.disabled?o("memory.enableTooltip"):o("memory.disableTooltip"),className:"icon-btn pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:s.disabled?e.jsx(ue,{size:13}):e.jsx(Ne,{size:13})})}),e.jsx(j,{label:o("memory.archiveButton"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>a(s),"aria-label":o("memory.archiveButton"),className:"icon-btn icon-btn--danger pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:e.jsx(ye,{size:13})})})]}):null})]}),i?e.jsxs("div",{className:"drawer-card__expanded",children:[e.jsx("h4",{className:"drawer-section-label",children:o("memory.sources")}),s.sources.length===0?e.jsx("p",{className:"text-ter",children:o("memory.noSources")}):e.jsx("ul",{className:"space-y-2",children:s.sources.map(m=>e.jsxs("li",{className:"break-words",children:[e.jsxs("div",{className:"text-ter",children:[m.sourceType,m.actorNameSnapshot?` · ${m.actorNameSnapshot}`:"",m.actorRoleSnapshot?` · ${m.actorRoleSnapshot}`:""]}),m.excerpt?e.jsx("p",{className:"mt-0.5",children:m.excerpt}):null]},m.id))})]}):null]})},Q=({label:r,checked:s,disabled:a,onChange:p})=>e.jsxs("label",{className:"drawer-settings-row",children:[e.jsx("span",{className:"text-sec",children:r}),e.jsx("input",{type:"checkbox",checked:s,disabled:a,onChange:n=>p(n.currentTarget.checked),className:"h-4 w-4 accent-[var(--accent)]"})]}),De=(r,s)=>r.report?[`${r.report.added.length} ${s("memory.reportAdded")}`,`${r.report.rewritten.length} ${s("memory.reportRewritten")}`,`${r.report.archived.length} ${s("memory.reportArchived")}`,`${r.report.merged.length} ${s("memory.reportMerged")}`].join(" · "):r.error?`${s("common.error")} · ${I(r.error,90)}`:s("memory.noReport"),ze=(r,s)=>r.inputSeqFrom===null||r.inputSeqTo===null?s("memory.noInput"):`${s("memory.seq")} ${r.inputSeqFrom}-${r.inputSeqTo}`,Ae=({busy:r,onRevert:s,run:a})=>{const[p,n]=c.useState(!1),{t:i}=W();return e.jsxs("li",{className:"drawer-card p-3","data-testid":`dream-run-${a.id}`,"data-dream-status":a.status,children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>n(d=>!d),"aria-expanded":p,className:"min-w-0 flex-1 text-left focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-[var(--accent)]",children:[e.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`drawer-status-badge drawer-status-badge--${a.status}`,children:i(`memory.status.${a.status}`)}),e.jsx("span",{className:"text-ter",children:i(`memory.trigger.${a.trigger}`)}),e.jsx("span",{className:"text-ter",children:ze(a,i)}),e.jsx("span",{className:"text-ter",children:i("memory.started",{time:S(a.startedAt,i)})})]}),e.jsx("p",{className:"break-words text-sm text-pri leading-snug",children:De(a,i)}),a.finishedAt?e.jsx("p",{className:"mt-1 text-[11px] text-ter",children:i("memory.finished",{time:S(a.finishedAt,i)})}):null]}),a.status==="completed"?e.jsx("div",{className:"drawer-card__actions",children:e.jsx(j,{label:i("memory.revertButton"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>s(a),"aria-label":i("memory.revertTooltip"),className:"icon-btn icon-btn--danger pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:r?e.jsx(k,{size:13,className:"animate-spin"}):e.jsx(he,{size:13})})})}):null]}),p&&a.report?e.jsxs("div",{className:"drawer-card__expanded space-y-3",children:[a.report.added.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-status-green",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-added flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-status-green"}),i("memory.diff.added")]}),e.jsx("ul",{className:"space-y-1.5 mt-1.5",children:a.report.added.map(d=>e.jsxs("li",{className:"break-words text-[11px] text-pri flex items-start gap-1",children:[e.jsx("span",{className:"text-status-green select-none font-semibold mr-1",children:"+"}),e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:`drawer-kind-badge drawer-kind-badge--${d.kind} scale-90 origin-left inline-block mr-1`,children:i(G[d.kind])}),d.body]})]},d.id))})]}):null,a.report.rewritten.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-[#f59e0b]",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-rewritten flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#f59e0b]"}),i("memory.diff.rewritten")]}),e.jsx("p",{className:"mt-1.5 text-[11px] text-sec leading-relaxed pl-3 break-all",children:a.report.rewritten.map(d=>d.id).join(", ")})]}):null,a.report.archived.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-status-red",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-archived flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-status-red"}),i("memory.diff.archived")]}),e.jsx("p",{className:"mt-1.5 text-[11px] text-sec leading-relaxed pl-3 break-all",children:a.report.archived.map(d=>d.id).join(", ")})]}):null,a.report.merged.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-purple-500",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-merged flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-purple-500"}),i("memory.diff.merged")]}),e.jsx("p",{className:"mt-1.5 text-[11px] text-sec leading-relaxed pl-3 break-all",children:a.report.merged.map(d=>d.into).join(", ")})]}):null]}):null,p&&a.error?e.jsx("p",{className:"drawer-card__error",children:a.error}):null]})},qe=({open:r,onClose:s,workspaceId:a})=>{const p=te(),{t:n}=W(),[i,d]=c.useState("active"),[o,m]=c.useState(""),[y,$]=c.useState([]),[v,C]=c.useState([]),[M,N]=c.useState(null),[q,T]=c.useState(!1),[L,x]=c.useState(null),[J,B]=c.useState(null),[R,w]=c.useState(null),[_,E]=c.useState(null),[D,z]=c.useState(null),[A,F]=c.useState(!1),b=c.useRef(0),X=c.useMemo(()=>[{id:"active",label:n("memory.tabActive")},{id:"archived",label:n("memory.tabArchived")},{id:"dreams",label:n("memory.tabDreams")}],[n]),u=_e(i),f=c.useCallback(async()=>{const t=b.current+1;if(b.current=t,!a||!r){$([]),C([]),N(null),T(!1);return}T(!0),x(null),$([]),C([]),N(null);try{const[l,h,se]=await Promise.all([ae(a),u?re(a,{query:o,scope:"all",status:u}):Promise.resolve([]),u?Promise.resolve([]):ne(a,{limit:20})]);if(b.current!==t)return;N(l),$(h),C(se)}catch(l){b.current===t&&x(l instanceof Error?l.message:String(l))}finally{b.current===t&&T(!1)}},[r,o,u,a]);c.useEffect(()=>{f()},[f]);const P=async(t,l)=>{if(a){B(t.id),x(null);try{await l(a),await f()}catch(h){x(h instanceof Error?h.message:String(h))}finally{B(null)}}},Y=c.useMemo(()=>({current:u?y.length:v.length}),[v.length,y.length,u]),O=async t=>{if(!(!a||A)){F(!0),x(null);try{N(await xe(a,t))}catch(l){x(l instanceof Error?l.message:String(l))}finally{F(!1)}}},Z=async()=>{if(a){w("run-now"),x(null);try{await pe(a),await f()}catch(t){x(t instanceof Error?t.message:String(t))}finally{w(null)}}},ee=async t=>{if(a){w(t.id),x(null);try{await be(a,t.id),await f()}catch(l){x(l instanceof Error?l.message:String(l))}finally{w(null)}}};return e.jsxs(e.Fragment,{children:[e.jsx(ie,{open:r,onOpenChange:t=>!t&&s(),children:e.jsxs(le,{children:[e.jsx(oe,{"data-testid":"memory-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(ce,{"data-testid":"memory-drawer","aria-label":n("memory.title"),"data-mobile":p||void 0,className:"dialog-scale-pop elev-2 pointer-events-auto flex flex-col rounded-lg border",style:p?{background:"var(--bg-1)",borderColor:"var(--border-bright)"}:{background:"var(--bg-1)",borderColor:"var(--border-bright)",height:"min(720px, calc(100vh - 48px))",width:"min(780px, calc(100vw - 48px))"},children:[e.jsxs("header",{className:"flex items-center justify-between border-b px-4 py-2",style:{borderColor:"var(--border)"},children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(de,{className:"text-base font-semibold text-pri",children:n("memory.title")}),e.jsx("p",{className:"text-xs text-ter",children:n("memory.subtitle")})]}),e.jsx(j,{label:n("common.close"),children:e.jsx("button",{type:"button",onClick:s,"aria-label":n("common.close"),className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:e.jsx(me,{size:14})})})]}),e.jsxs("div",{className:`flex gap-2 border-b px-4 py-2 ${p?"flex-col items-stretch":"items-center gap-2"}`,style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"drawer-tabs",style:p?{width:"100%",justifyContent:"flex-start"}:void 0,children:X.map(t=>e.jsx("button",{type:"button",onClick:()=>d(t.id),"aria-pressed":i===t.id,className:`drawer-tab pointer-coarse:min-h-10 ${i===t.id?"drawer-tab--active":""}`,children:t.label},t.id))}),u?e.jsxs("label",{className:"drawer-search",style:p?{width:"100%",maxWidth:"none"}:{marginLeft:"auto"},children:[e.jsx("span",{className:"sr-only",children:n("memory.searchPlaceholder")}),e.jsx(je,{size:14,className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-ter"}),e.jsx("input",{value:o,onChange:t=>m(t.currentTarget.value),placeholder:n("memory.searchPlaceholder"),name:"memory-search",autoComplete:"off",className:"h-8 w-full rounded-md border bg-transparent pl-8 pr-3 text-xs text-pri outline-none transition-colors placeholder:text-ter focus-visible:border-[var(--accent)]",style:{borderColor:"var(--border-bright)"}})]}):null]}),e.jsxs("div",{className:"scroll-y min-h-0 flex-1 px-4 py-3",children:[L?e.jsx("div",{className:"mb-3 rounded-md border px-3 py-2 text-xs",style:{borderColor:"color-mix(in oklab, var(--status-red) 30%, var(--border))",color:"var(--text-error)",background:"color-mix(in oklab, var(--status-red) 8%, transparent)"},children:L}):null,e.jsxs("section",{className:"drawer-section",children:[e.jsxs("div",{className:"drawer-section__header",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Me,{size:14,className:"text-sec"}),e.jsxs("span",{className:"font-medium text-sec",children:[Y.current," ",n(u?"memory.entries":"memory.runs")]})]}),i==="dreams"?e.jsxs("button",{type:"button",onClick:Z,disabled:R!==null,className:"drawer-action-btn pointer-coarse:min-h-10",children:[R==="run-now"?e.jsx(k,{size:14,className:"animate-spin"}):e.jsx(V,{size:14}),n("memory.runNow")]}):null]}),M?e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[e.jsx(Q,{label:n("memory.injection"),checked:M.enabled,disabled:A,onChange:t=>O({enabled:t})}),e.jsx(Q,{label:n("memory.dreamProcessing"),checked:M.dreamEnabled,disabled:A,onChange:t=>O({dreamEnabled:t})})]}):null]}),i==="dreams"?q?e.jsxs("div",{className:"flex h-[320px] items-center justify-center text-ter",children:[e.jsx(k,{size:18,className:"animate-spin"}),e.jsx("span",{className:"ml-2 text-sm",children:n("common.loading")})]}):v.length===0?e.jsx("div",{className:"flex h-[320px] items-center justify-center",children:e.jsx(H,{icon:e.jsx(V,{size:20}),title:n("memory.emptyDreams"),description:n("memory.emptyDreamsDesc")})}):e.jsx("ul",{className:"space-y-2",children:v.map(t=>e.jsx(Ae,{run:t,busy:R===t.id,onRevert:z},t.id))}):q?e.jsxs("div",{className:"flex h-[320px] items-center justify-center text-ter",children:[e.jsx(k,{size:18,className:"animate-spin"}),e.jsx("span",{className:"ml-2 text-sm",children:n("common.loading")})]}):y.length===0?e.jsx("div",{className:"flex h-[320px] items-center justify-center",children:e.jsx(H,{title:n("memory.emptyActive"),description:n("memory.emptyActiveDesc")})}):e.jsx("ul",{className:"space-y-2",children:y.map(t=>e.jsx(Ee,{memory:t,busy:J===t.id,onArchive:E,onToggleDisabled:l=>P(l,h=>U(h,l.id,{disabled:!l.disabled})),onTogglePinned:l=>P(l,h=>U(h,l.id,{pinned:!l.pinned}))},t.id))})]})]})})]})}),e.jsx(K,{open:_!==null,onOpenChange:t=>{t||E(null)},title:n("memory.archiveTitle"),description:n("memory.archiveDesc"),confirmLabel:n("memory.archiveButton"),confirmKind:"danger",onConfirm:()=>{if(!_)return;const t=_;E(null),P(t,l=>fe(l,t.id))}}),e.jsx(K,{open:D!==null,onOpenChange:t=>{t||z(null)},title:n("memory.revertTitle"),description:n("memory.revertDesc"),confirmLabel:n("memory.revertButton"),confirmKind:"danger",onConfirm:()=>{if(!D)return;const t=D;z(null),ee(t)}})]})};export{qe as WorkspaceMemoryDrawer};
@@ -1 +1 @@
1
- import{r as k,j as h,_ as e}from"./index-B3XoRj0C.js";import{TaskGraphDrawer as g}from"./TaskGraphDrawer-DDhX2p_z.js";const u=({tasksFile:a,workspacePath:T,open:c,onClose:r,workers:n,onSelectOwner:p,connectionStale:d})=>{const s=k.useMemo(()=>n?.length?n.map(o=>o.name):void 0,[n]);return h.jsx(g,{content:a.content,hasConflict:a.hasConflict,onClose:r,onContentChange:a.onChange,onKeepLocal:a.onKeepLocal,onReload:a.onReload,onSave:a.onSave,onToggleTaskLine:o=>{a.toggleTaskAtLine(o).catch(e("tasks.toggleTaskAtLine"))},onAppendTask:o=>{a.appendTask(o).catch(e("tasks.appendTask"))},onAppendSubtask:(o,t)=>{a.appendSubtask(o,t).catch(e("tasks.appendSubtask"))},onUpdateTaskText:(o,t)=>{a.updateTaskText(o,t).catch(e("tasks.updateTaskText"))},onDeleteTask:o=>{a.deleteTask(o).catch(e("tasks.deleteTask"))},open:c,workspacePath:T,...s?{knownWorkerNames:s}:{},...p?{onSelectOwner:p}:{},...d!==void 0?{connectionStale:d}:{}})};export{u as WorkspaceTaskDrawer};
1
+ import{r as k,j as h,_ as e}from"./index-D43vHIy2.js";import{TaskGraphDrawer as g}from"./TaskGraphDrawer-BSxRbr1h.js";const u=({tasksFile:a,workspacePath:T,open:c,onClose:r,workers:n,onSelectOwner:p,connectionStale:d})=>{const s=k.useMemo(()=>n?.length?n.map(o=>o.name):void 0,[n]);return h.jsx(g,{content:a.content,hasConflict:a.hasConflict,onClose:r,onContentChange:a.onChange,onKeepLocal:a.onKeepLocal,onReload:a.onReload,onSave:a.onSave,onToggleTaskLine:o=>{a.toggleTaskAtLine(o).catch(e("tasks.toggleTaskAtLine"))},onAppendTask:o=>{a.appendTask(o).catch(e("tasks.appendTask"))},onAppendSubtask:(o,t)=>{a.appendSubtask(o,t).catch(e("tasks.appendSubtask"))},onUpdateTaskText:(o,t)=>{a.updateTaskText(o,t).catch(e("tasks.updateTaskText"))},onDeleteTask:o=>{a.deleteTask(o).catch(e("tasks.deleteTask"))},open:c,workspacePath:T,...s?{knownWorkerNames:s}:{},...p?{onSelectOwner:p}:{},...d!==void 0?{connectionStale:d}:{}})};export{u as WorkspaceTaskDrawer};