@tt-a1i/hive 2.1.14 → 2.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/src/cli/team.js +19 -6
- package/dist/src/server/agent-startup-instructions.d.ts +1 -0
- package/dist/src/server/agent-startup-instructions.js +4 -1
- package/dist/src/server/hive-team-guidance.js +2 -0
- package/dist/src/server/route-types.d.ts +1 -0
- package/dist/src/server/routes-team.js +3 -0
- package/dist/src/server/routes-workers.d.ts +2 -0
- package/dist/src/server/routes-workers.js +112 -0
- package/dist/src/server/routes-workspaces.js +4 -85
- package/dist/src/server/routes.js +2 -0
- package/dist/src/server/runtime-store-contract.d.ts +5 -0
- package/dist/src/server/runtime-store.js +2 -0
- package/dist/src/server/sqlite-schema-v39.d.ts +2 -0
- package/dist/src/server/sqlite-schema-v39.js +6 -0
- package/dist/src/server/sqlite-schema.d.ts +1 -1
- package/dist/src/server/sqlite-schema.js +8 -1
- package/dist/src/server/team-list-serializer.d.ts +5 -1
- package/dist/src/server/team-list-serializer.js +2 -1
- package/dist/src/server/team-memory-dream-prompt.js +18 -5
- package/dist/src/server/team-operations.d.ts +4 -0
- package/dist/src/server/team-operations.js +18 -5
- package/dist/src/server/workspace-store-contract.d.ts +6 -0
- package/dist/src/server/workspace-store-hydration.js +2 -1
- package/dist/src/server/workspace-store-support.d.ts +1 -0
- package/dist/src/server/workspace-store.js +57 -2
- package/dist/src/shared/types.d.ts +4 -0
- package/dist/src/shared/worker-avatar.d.ts +2 -0
- package/dist/src/shared/worker-avatar.js +55 -0
- package/package.json +1 -1
- package/web/dist/assets/AddWorkerDialog-Dfg4e74k.js +2 -0
- package/web/dist/assets/AddWorkspaceFlow-Bt5i_6p3.js +1 -0
- package/web/dist/assets/FirstRunWizard--NAbC5zC.js +1 -0
- package/web/dist/assets/{MarketplaceDrawer-BHTvxLMz.js → MarketplaceDrawer-CJhft0Xd.js} +1 -1
- package/web/dist/assets/{TaskGraphDrawer-woCXhUwp.js → TaskGraphDrawer-BUCR4zPH.js} +1 -1
- package/web/dist/assets/WhatsNewDialog-B05r5jd4.js +1 -0
- package/web/dist/assets/WorkerModal-CSM87uaz.js +1 -0
- package/web/dist/assets/{WorkflowsDrawer-Diw0TiiJ.js → WorkflowsDrawer-pBezljLE.js} +1 -1
- package/web/dist/assets/WorkspaceMemoryDrawer-Akq36Iaz.js +1 -0
- package/web/dist/assets/{WorkspaceTaskDrawer-D10RcAUj.js → WorkspaceTaskDrawer-CDhs_vbw.js} +1 -1
- package/web/dist/assets/index-BTPjdp2B.js +84 -0
- package/web/dist/assets/index-Cs7E1UKt.css +1 -0
- package/web/dist/assets/{search-D6bjVJKH.js → search-CWX42x_k.js} +1 -1
- package/web/dist/assets/{square-terminal-BUBEjTQZ.js → square-terminal-DoiN9oxG.js} +1 -1
- package/web/dist/index.html +2 -2
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/AddWorkerDialog-BdIc_ZDz.js +0 -2
- package/web/dist/assets/AddWorkspaceFlow-h-UH433o.js +0 -1
- package/web/dist/assets/FirstRunWizard-ChuB1siy.js +0 -1
- package/web/dist/assets/WhatsNewDialog-BcRbRAJI.js +0 -1
- package/web/dist/assets/WorkerModal-CTf1k881.js +0 -1
- package/web/dist/assets/WorkspaceMemoryDrawer-B7Z1_COx.js +0 -1
- package/web/dist/assets/index-BTaZgzo0.js +0 -84
- package/web/dist/assets/index-DYIPzuPD.css +0 -1
|
@@ -1 +0,0 @@
|
|
|
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-BTaZgzo0.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","data-terminal-auto-focus":"true"}):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 +0,0 @@
|
|
|
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-BTaZgzo0.js";import{S as je}from"./search-D6bjVJKH.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};
|