@tt-a1i/hive 2.1.11 → 2.1.13

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 (44) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +13 -11
  3. package/README.zh.md +9 -8
  4. package/dist/src/cli/hive-defaults.d.ts +1 -0
  5. package/dist/src/cli/hive-defaults.js +1 -0
  6. package/dist/src/cli/hive-mcp.js +2 -1
  7. package/dist/src/cli/hive.d.ts +2 -0
  8. package/dist/src/cli/hive.js +4 -2
  9. package/dist/src/server/agent-run-starter.js +14 -0
  10. package/dist/src/server/agent-stdin-dispatcher.js +2 -2
  11. package/dist/src/server/claude-trust-store.d.ts +14 -0
  12. package/dist/src/server/claude-trust-store.js +67 -0
  13. package/dist/src/server/codex-trust-store.d.ts +14 -0
  14. package/dist/src/server/codex-trust-store.js +72 -0
  15. package/dist/src/server/command-preset-defaults.d.ts +1 -1
  16. package/dist/src/server/command-preset-defaults.js +10 -0
  17. package/dist/src/server/post-start-input-writer.d.ts +1 -0
  18. package/dist/src/server/post-start-input-writer.js +77 -34
  19. package/dist/src/server/sqlite-schema-v38.d.ts +2 -0
  20. package/dist/src/server/sqlite-schema-v38.js +26 -0
  21. package/dist/src/server/sqlite-schema.d.ts +1 -1
  22. package/dist/src/server/sqlite-schema.js +6 -1
  23. package/dist/src/server/workflow-cli-policy.d.ts +1 -1
  24. package/dist/src/server/workflow-cli-policy.js +1 -0
  25. package/package.json +3 -3
  26. package/web/dist/assets/{AddWorkerDialog-CMQdmZJQ.js → AddWorkerDialog-DcEIii34.js} +2 -2
  27. package/web/dist/assets/AddWorkspaceFlow-BTYcc0tV.js +1 -0
  28. package/web/dist/assets/{FirstRunWizard-PRHGFYry.js → FirstRunWizard-Bdb1l71P.js} +1 -1
  29. package/web/dist/assets/{MarketplaceDrawer-Dm-Z-YL8.js → MarketplaceDrawer-C1MjJMok.js} +1 -1
  30. package/web/dist/assets/{TaskGraphDrawer-HaGRlpar.js → TaskGraphDrawer-DFYARCjj.js} +1 -1
  31. package/web/dist/assets/{WhatsNewDialog-9upxbs9b.js → WhatsNewDialog-rUU_Roz8.js} +1 -1
  32. package/web/dist/assets/{WorkerModal-DAC0fORb.js → WorkerModal-CuB3F-m-.js} +1 -1
  33. package/web/dist/assets/WorkflowsDrawer-Bk87nnDw.js +1 -0
  34. package/web/dist/assets/{WorkspaceMemoryDrawer-QvVUM6qp.js → WorkspaceMemoryDrawer-DPfFpEwj.js} +1 -1
  35. package/web/dist/assets/{WorkspaceTaskDrawer-CdiraIBo.js → WorkspaceTaskDrawer-DOWlwBCm.js} +1 -1
  36. package/web/dist/assets/{index-B1vvo0-M.js → index-XUIK5lOA.js} +5 -5
  37. package/web/dist/assets/{search-DgMNPsfM.js → search-DFKWO_9l.js} +1 -1
  38. package/web/dist/assets/{square-terminal-CiDDFh5Z.js → square-terminal-D54LkZqa.js} +1 -1
  39. package/web/dist/cli-icons/pi.svg +26 -0
  40. package/web/dist/index.html +1 -1
  41. package/web/dist/manifest.webmanifest +1 -1
  42. package/web/dist/sw.js +1 -1
  43. package/web/dist/assets/AddWorkspaceFlow-arGy-LVX.js +0 -1
  44. package/web/dist/assets/WorkflowsDrawer-Dqv4vNZW.js +0 -1
@@ -1 +1 @@
1
- import{c}from"./index-B1vvo0-M.js";const e=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],o=c("search",e);export{o as S};
1
+ import{c}from"./index-XUIK5lOA.js";const e=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],o=c("search",e);export{o as S};
@@ -1 +1 @@
1
- import{c as e}from"./index-B1vvo0-M.js";const r=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],a=e("square-terminal",r);export{a as S};
1
+ import{c as e}from"./index-XUIK5lOA.js";const r=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],a=e("square-terminal",r);export{a as S};
@@ -0,0 +1,26 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 800">
3
+ <!-- Self-contained dark tile so the white mark stays visible on any
4
+ container background (avatar surface, dropdown, workflow policy),
5
+ independent of the page's light/dark theme. -->
6
+ <rect width="800" height="800" rx="160" fill="#1a1a1a"/>
7
+ <!-- P shape: outer boundary clockwise, inner hole counter-clockwise -->
8
+ <path fill="#fff" fill-rule="evenodd" d="
9
+ M165.29 165.29
10
+ H517.36
11
+ V400
12
+ H400
13
+ V517.36
14
+ H282.65
15
+ V634.72
16
+ H165.29
17
+ Z
18
+ M282.65 282.65
19
+ V400
20
+ H400
21
+ V282.65
22
+ Z
23
+ "/>
24
+ <!-- i dot -->
25
+ <path fill="#fff" d="M517.36 400 H634.72 V634.72 H517.36 Z"/>
26
+ </svg>
@@ -32,7 +32,7 @@
32
32
  href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=DM+Mono:wght@400;500&display=swap"
33
33
  rel="stylesheet"
34
34
  />
35
- <script type="module" crossorigin src="/assets/index-B1vvo0-M.js"></script>
35
+ <script type="module" crossorigin src="/assets/index-XUIK5lOA.js"></script>
36
36
  <link rel="stylesheet" crossorigin href="/assets/index-DYIPzuPD.css">
37
37
  </head>
38
38
  <body>
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "Hive — Multi-agent CLI workbench",
3
3
  "short_name": "Hive",
4
- "description": "Browser-native multi-CLI agent collaboration workbench. Coordinate Claude Code, Codex, Gemini, OpenCode as a real PTY team.",
4
+ "description": "Browser-native multi-CLI agent collaboration workbench. Coordinate real CLI agents as a visible PTY team.",
5
5
  "start_url": "/",
6
6
  "scope": "/",
7
7
  "display": "standalone",
package/web/dist/sw.js CHANGED
@@ -7,7 +7,7 @@
7
7
  // generation must be able to resolve its lazy-loaded hashed chunks, and
8
8
  // storage growth is bounded by Hive's release cadence.
9
9
 
10
- const VERSION = '2.1.11'
10
+ const VERSION = '2.1.13'
11
11
  const SHELL_CACHE = `hive-cache-v${VERSION}-shell`
12
12
  const ASSETS_CACHE = `hive-cache-v${VERSION}-assets`
13
13
  const STATIC_CACHE = `hive-cache-v${VERSION}-static`
@@ -1 +0,0 @@
1
- import{c as A,u as R,r as c,j as e,C as B,x as oe,$ as pe,R as G,P as K,O as X,k as Y,m as J,a0 as se,a1 as Ne,q as Ce,b as F,a2 as _e,a3 as Pe,i as Se,z as Ee,X as ze,a4 as ue,a5 as Re,a6 as $e,a7 as Me}from"./index-B1vvo0-M.js";const De=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Ie=A("arrow-up",De);const Le=[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]],Ae=A("folder-search",Le);const Oe=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Q=A("folder",Oe);const Fe=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],me=A("git-branch",Fe);const Be=[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]],We=A("hard-drive",Be);const Te=[["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M12 21v-9",key:"17s77i"}],["path",{d:"M12 8V3",key:"13r4qs"}],["path",{d:"M17 16h4",key:"h1uq16"}],["path",{d:"M19 12V3",key:"o1uvq1"}],["path",{d:"M19 21v-5",key:"qua636"}],["path",{d:"M3 14h4",key:"bcjad9"}],["path",{d:"M5 10V3",key:"cb8scm"}],["path",{d:"M5 21v-7",key:"1w1uti"}]],ee=A("sliders-vertical",Te),xe=t=>{const s=t.trim();if(s.length<2)return s;const n=s[0],a=s[s.length-1];return(n==='"'||n==="'")&&n===a?s.slice(1,-1):s},qe={claude:"/cli-icons/claude.png",codex:"/cli-icons/codex.png",opencode:"/cli-icons/opencode.svg",gemini:"/cli-icons/gemini.png",hermes:"/cli-icons/hermes.png",qwen:"/cli-icons/qwen.png",agy:"/cli-icons/agy.png",cursor:"/cli-icons/cursor.ico",grok:"/cli-icons/grok.ico"},le=({id:t,className:s})=>{const[n,a]=c.useState(!1),r=qe[t];return r&&!n?e.jsx("img",{src:r,alt:"",onError:()=>a(!0),className:`${s} object-contain rounded-xs ${t==="opencode"?"bg-[#ebebeb] p-[1px]":""}`}):e.jsx(pe,{size:14,className:s})},he=({error:t,onChange:s,presets:n,value:a})=>{const{t:r}=R(),[m,i]=c.useState(!1),l=c.useRef(null),f=n.find(x=>x.id===a),o=a==="",d=f?[f.command,...f.args].join(" ").trim():r(o?"workspace.preset.genericPreview":"workspace.preset.loading"),p=f?.displayName??(o?r("workspace.preset.generic"):"Claude Code (CC)"),k=n.length===0&&!o;return c.useEffect(()=>{if(!m)return;const x=h=>{l.current?.contains(h.target)||i(!1)},u=h=>{h.key==="Escape"&&i(!1)};return document.addEventListener("mousedown",x),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",u)}},[m]),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:r("workspace.preset.label")}),e.jsxs("div",{ref:l,className:"cli-select group relative",children:[e.jsx(le,{id:a,className:"cli-select__leading w-3.5 h-3.5"}),e.jsx("button",{type:"button","aria-haspopup":"listbox","aria-expanded":m,"aria-disabled":k||void 0,className:"cli-select__field cli-select__field--button text-left","data-testid":"workspace-command-preset","data-value":a,disabled:k,onClick:()=>i(x=>!x),children:p}),e.jsx(B,{size:14,"aria-hidden":!0,className:"cli-select__trailing"}),m&&n.length>0?e.jsxs("div",{role:"listbox","aria-label":r("workspace.preset.optionsAria"),className:"cli-select__menu","data-testid":"workspace-command-preset-menu",children:[n.map(x=>{const u=x.id===a,h=x.available===!1;return e.jsxs("button",{type:"button",role:"option","aria-selected":u,"data-testid":`workspace-command-preset-option-${x.id}`,className:"cli-select__option",onClick:()=>{s(x.id),i(!1)},children:[e.jsx(oe,{size:12,"aria-hidden":!0,className:"cli-select__check",style:{opacity:u?1:0}}),e.jsx(le,{id:x.id,className:"w-3.5 h-3.5 text-ter shrink-0"}),e.jsxs("span",{children:[x.displayName,h?r("workspace.preset.notFoundSuffix"):""]})]},x.id)}),e.jsxs("button",{type:"button",role:"option","aria-selected":o,"data-testid":"workspace-command-preset-option-generic",className:"cli-select__option",onClick:()=>{s(""),i(!1)},children:[e.jsx(oe,{size:12,"aria-hidden":!0,className:"cli-select__check",style:{opacity:o?1:0}}),e.jsx(pe,{size:14,className:"text-ter shrink-0"}),e.jsx("span",{children:r("workspace.preset.generic")})]})]}):null]}),e.jsxs("div",{className:"mono flex items-center gap-1.5 truncate text-xs text-ter",title:d,children:[e.jsx("span",{className:"text-sec",children:"$"}),e.jsx("span",{className:"truncate",children:d})]}),t?e.jsx("span",{className:"text-xs",style:{color:"var(--status-red)"},children:t}):null]})},H=t=>(t.split(/[\\/]/).filter(Boolean).pop()??"").replace(/:$/u,""),Z=({children:t})=>e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:t}),Ve=({probe:t,pasteFallbackDefault:s=!1,commandPresetError:n,commandPresetId:a,commandPresets:r,onCancel:m,onCommandPresetChange:i,onCreate:l,onOpenServerBrowse:f,onTryDemo:o})=>{const{t:d}=R(),p=t?.path??"",k=t?.suggested_name??H(p),[x,u]=c.useState(k),[h,j]=c.useState(""),[y,S]=c.useState(s),[C,E]=c.useState(!1),[z,$]=c.useState("");c.useEffect(()=>{u(t?.suggested_name??H(t?.path??""))},[t?.path,t?.suggested_name]);const b=xe(h),_=H(b),g=y&&b.length>0?b:t?.path??"",P=z.trim(),N=r.find(v=>v.id===a),T=r.length===0&&!n,I=!a&&P.length===0,O=N?.available===!1&&P.length===0,q=I?d("workspace.preset.genericRequiresStartup"):O?d("workspace.preset.notInstalled",{name:N.displayName}):null,te=r.length>0&&r.every(v=>v.available===!1),V=x.trim().length>0&&g.length>0&&!T&&!I&&!O,U=()=>{V&&l({commandPresetId:a||null,name:x.trim(),path:g,...P?{startupCommand:P}:{}})};return c.useEffect(()=>{y&&b.length>0&&u(_)},[y,b,_]),e.jsx(G,{open:!0,onOpenChange:v=>!v&&m(),children:e.jsxs(K,{children:[e.jsx(X,{"data-testid":"confirm-workspace-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(Y,{"data-testid":"confirm-workspace-dialog",className:"dialog-scale-pop elev-2 pointer-events-auto flex w-[480px] max-w-full flex-col rounded-lg border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-center gap-3 border-b px-5 py-4",style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--accent) 12%, transparent)",color:"var(--accent)"},children:e.jsx(Q,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(J,{className:"text-lg font-semibold text-pri",children:d("workspace.confirm.title")}),e.jsx(se,{className:"text-xs text-ter",children:d("workspace.confirm.description")})]})]}),e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(Z,{children:d("workspace.field.path")}),e.jsx("input",{type:"hidden",value:t?.path??"","data-testid":"confirm-workspace-path",readOnly:!0}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border p-3 transition-all",style:{background:"var(--bg-2)",borderColor:"var(--border)"},children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("span",{className:"block truncate font-mono text-sm text-pri",title:t?.path??"",children:t?.path||d("workspace.field.pathEmptyPlaceholder")})}),t?.is_git_repository?e.jsxs("div",{className:"shrink-0 flex items-center gap-1.5 rounded px-2 py-0.5 text-xs font-medium",style:{background:"color-mix(in oklab, var(--status-blue) 12%, transparent)",color:"var(--status-blue)",border:"1px solid color-mix(in oklab, var(--status-blue) 25%, transparent)"},"data-testid":"confirm-workspace-git-badge",children:[e.jsx(me,{size:12,"aria-hidden":!0}),e.jsx("span",{className:"truncate max-w-[90px]",children:t.current_branch??d("workspace.git.detached")})]}):null]}),t?.ok&&!t?.is_git_repository&&e.jsx("span",{className:"text-xs text-ter pl-1",children:d("workspace.git.none")})]}),e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(Z,{children:d("workspace.field.name")}),e.jsx("input",{value:x,onChange:v=>u(v.target.value),placeholder:H(t?.path??"")||d("workspace.field.nameDefaultPlaceholder"),className:"input","data-testid":"confirm-workspace-name"})]}),e.jsx(he,{error:n??q,onChange:i,presets:r,value:a}),O&&N?e.jsx(Ne,{presetId:N.id,presetName:N.displayName}):null,e.jsx("p",{className:"rounded-lg border p-3 text-xs text-sec",style:{background:"color-mix(in oklab, var(--status-yellow) 5%, transparent)",borderColor:"color-mix(in oklab, var(--status-yellow) 25%, transparent)"},"data-testid":"yolo-mode-notice",children:d("workspace.yolo.notice")}),te&&o?e.jsxs("div",{className:"flex flex-col gap-2 rounded-lg border p-3",style:{background:"color-mix(in oklab, var(--accent) 6%, transparent)",borderColor:"color-mix(in oklab, var(--accent) 30%, transparent)"},"data-testid":"cli-none-available",children:[e.jsx("span",{className:"text-xs text-sec",children:d("workspace.preset.noneAvailable")}),e.jsxs("button",{type:"button",onClick:o,className:"icon-btn w-full justify-center inline-flex items-center gap-2","data-testid":"cli-try-demo",children:[e.jsx(Ce,{size:13,"aria-hidden":!0}),d("workspace.preset.tryDemo")]})]}):null,e.jsxs("div",{className:"mt-2 rounded-lg border overflow-hidden transition-all",style:{borderColor:"var(--border)",background:"var(--bg-1)"},children:[e.jsxs("button",{type:"button",onClick:()=>E(v=>!v),className:"flex w-full items-center justify-between px-3.5 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-sec hover:bg-3 transition-colors cursor-pointer","data-testid":"confirm-workspace-startup-toggle",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ee,{size:12,"aria-hidden":!0,className:"text-ter"}),d("workspace.advanced.startup")]}),C?e.jsx(B,{size:14,"aria-hidden":!0}):e.jsx(F,{size:14,"aria-hidden":!0})]}),C?e.jsxs("div",{className:"flex flex-col gap-2 border-t p-3.5 transition-all",style:{background:"var(--bg-2)",borderColor:"var(--border)"},children:[e.jsx(Z,{children:d("workspace.field.startup")}),e.jsx("input",{type:"text",value:z,onChange:v=>$(v.target.value),placeholder:d("workspace.field.startupPlaceholder"),className:"input mono text-sm","data-testid":"confirm-workspace-startup-command"}),e.jsx("span",{className:"text-[11px] text-ter normal-case tracking-normal leading-relaxed",children:d("workspace.startup.hint")})]}):null]}),e.jsxs("div",{className:"rounded-lg border overflow-hidden transition-all",style:{borderColor:"var(--border)",background:"var(--bg-1)"},children:[e.jsxs("button",{type:"button",onClick:()=>S(v=>!v),className:"flex w-full items-center justify-between px-3.5 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-sec hover:bg-3 transition-colors cursor-pointer","data-testid":"confirm-workspace-paste-toggle",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ee,{size:12,"aria-hidden":!0,className:"text-ter"}),d("workspace.advanced.pastePath")]}),y?e.jsx(B,{size:14,"aria-hidden":!0}):e.jsx(F,{size:14,"aria-hidden":!0})]}),y?e.jsxs("div",{className:"flex flex-col gap-2 border-t p-3.5 transition-all",style:{background:"var(--bg-2)",borderColor:"var(--border)"},children:[e.jsx(Z,{children:d("workspace.field.absolutePath")}),e.jsx("input",{type:"text",value:h,onChange:v=>j(v.target.value),placeholder:d("workspace.field.absolutePathPlaceholder"),className:"input mono text-sm","data-testid":"confirm-workspace-paste-path"})]}):null]}),e.jsxs("button",{type:"button",onClick:f,className:"flex items-center justify-between w-full rounded-lg border border-dashed px-3.5 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-sec hover:bg-3 hover:text-pri transition-all cursor-pointer",style:{borderColor:"var(--border)"},"data-testid":"confirm-workspace-browse-toggle",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Q,{size:12,"aria-hidden":!0,className:"text-ter"}),d("workspace.advanced.browse")]}),e.jsx(F,{size:14,"aria-hidden":!0})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t px-5 py-3",style:{borderColor:"var(--border)"},children:[e.jsx("button",{type:"button",onClick:m,className:"icon-btn",children:d("common.cancel")}),e.jsx("button",{type:"button",onClick:U,disabled:!V,"data-testid":"confirm-workspace-create",className:"icon-btn icon-btn--primary",children:d("workspace.confirm.create")})]})]})})]})})},L="hive://windows-drives",Ue=({entries:t,error:s,loading:n,onNavigate:a,onSelect:r,selected:m})=>{const{t:i}=R();return e.jsx("div",{className:"scroll-y min-h-[200px] flex-1 border-t border-b",style:{borderColor:"var(--border)"},"data-testid":"fs-entry-list",children:n?e.jsx("p",{className:"p-4 text-center text-xs text-ter",children:i("common.loading")}):s?e.jsx("p",{className:"p-4 text-center text-xs",style:{color:"var(--status-red)"},"data-testid":"fs-browse-error",children:s}):t.length===0?e.jsx("p",{className:"p-4 text-center text-xs text-ter",children:i("workspace.browse.empty")}):e.jsx("ul",{children:t.map(l=>{const f=m===l.path;return e.jsxs("li",{className:"flex items-center gap-0",children:[e.jsxs("button",{type:"button","data-testid":`fs-entry-${l.name}`,onClick:()=>r(l.path),onDoubleClick:()=>a(l.path),className:"flex flex-1 items-center gap-2 px-3 py-2 text-left text-xs hover:bg-3",style:f?{background:"var(--bg-3)",color:"var(--text-primary)"}:{color:"var(--text-primary)"},children:[e.jsx("span",{"aria-hidden":!0,className:"inline-flex items-center text-sec",children:l.is_git_repository?e.jsx(me,{size:14}):e.jsx(Q,{size:14})}),e.jsx("span",{className:"mono flex-1 truncate",children:l.name}),l.is_git_repository?e.jsx("span",{className:"text-xs uppercase tracking-wider",style:{color:"var(--accent)"},children:i("workspace.browse.gitBadge")}):null]}),e.jsx("button",{type:"button","data-testid":`fs-entry-open-${l.name}`,onClick:()=>a(l.path),"aria-label":i("workspace.browse.openAria",{name:l.name}),className:"px-3 py-2 text-xs text-ter hover:text-pri",children:"→"})]},l.path)})})})},He=({probe:t,suggestedName:s,onSuggestedNameChange:n})=>{const{t:a}=R(),r=!!t&&t.ok&&t.is_dir;return e.jsxs("div",{className:"flex flex-col gap-2 rounded border p-3 text-xs",style:{background:"var(--bg-1)",borderColor:"var(--border)"},"data-testid":"fs-selection-preview",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-ter uppercase tracking-wider text-xs",children:a("workspace.browse.selected")}),t?.is_git_repository?e.jsx("span",{className:"role-badge role-badge--coder","data-testid":"fs-preview-git-badge",children:a("workspace.git.short",{branch:t.current_branch??a("workspace.git.detached")})}):r?e.jsx("span",{className:"text-ter text-xs",children:a("workspace.git.noneShort")}):null]}),e.jsx("span",{className:"mono truncate text-pri","data-testid":"fs-preview-path",children:t?.path??"—"}),e.jsxs("label",{className:"mt-1 flex flex-col gap-1 text-ter",children:[e.jsx("span",{className:"text-xs uppercase tracking-wider",children:a("workspace.field.name")}),e.jsx("input",{type:"text",value:s,onChange:m=>n(m.target.value),disabled:!r,autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,className:"mono rounded border px-2 py-1 text-sm text-pri disabled:opacity-50 max-md:text-base",style:{background:"var(--bg-0)",borderColor:"var(--border)"},"data-testid":"fs-preview-name-input"})]})]})},fe=t=>{const s=t.lastIndexOf("\\"),n=t.lastIndexOf("/");return s>=0&&s>n?"\\":n>=0?"/":/^[A-Za-z]:/u.test(t)?"\\":"/"},Ze=(t,s)=>{if(t===L)return s;const a=t.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean),r=a[a.length-1];return r?`~ (${r})`:t},W=t=>t.replace(/[\\/]+$/u,"")||t,ce=t=>/^[A-Za-z]:($|[\\/])/u.test(t),ie=t=>/^\\\\[^\\/]+[\\/][^\\/]+/u.test(t),be=(t,s)=>ce(t)&&ce(s)||ie(t)&&ie(s),Ge=t=>{const s=/^(?:\\\\|\/\/)(?<server>[^\\/]+)[\\/](?<share>[^\\/]+)[\\/]*(?<rest>.*)$/u.exec(t);if(!s?.groups)return null;const{server:n,share:a,rest:r}=s.groups,m=`\\\\${n}\\${a}\\`;return{label:`\\\\${n}\\${a}`,rest:r,root:m}},Ke=(t,s)=>{const n=W(t),a=W(s);return be(n,a)?n.toLowerCase()===a.toLowerCase():n===a},Xe=(t,s)=>{const n=W(t),a=W(s);if(a==="/"||a==="\\")return n.startsWith(a);const r=be(n,a),m=r?n.toLowerCase():n,i=r?a.toLowerCase():a;if(m===i)return!0;if(!m.startsWith(i))return!1;const l=m[i.length];return l==="/"||l==="\\"},Ye=(t,s,n="This PC")=>{if(!s||!t)return[];const a=[{label:Ze(s,n),path:s}];if(Ke(t,s))return a;if(s===L){const o=Ge(t);if(o){a.push({label:o.label,path:o.root});const h=o.rest.split(/[\\/]/).filter(Boolean);let j=o.root.replace(/[\\/]+$/,"");for(const y of h)j=`${j}\\${y}`,a.push({label:y,path:j});return a}const d=/^(?<drive>[A-Za-z]:)[\\/]*(?<rest>.*)$/u.exec(t),p=d?.groups?.drive;if(!p)return a;const k=`${p}\\`;a.push({label:p,path:k});const x=(d.groups?.rest??"").split(/[\\/]/).filter(Boolean);let u=k.replace(/[\\/]+$/,"");for(const h of x)u=`${u}\\${h}`,a.push({label:h,path:u});return a}const r=W(s),m=Xe(t,r)?t.slice(r.length).replace(/^[\\/]+/,""):"";if(!m)return a;const i=fe(r),l=m.split(/[\\/]/).filter(Boolean);let f=r;for(const o of l)f=`${f}${i}${o}`,a.push({label:o,path:f});return a},de={current_path:"",entries:[],error:null,ok:!1,parent_path:null,root_path:""},Je=t=>{const[s,n]=c.useState(de),[a,r]=c.useState(!1),[m,i]=c.useState(null),[l,f]=c.useState(null),o=c.useRef(0),d=c.useRef(0),p=c.useCallback(()=>{d.current++,i(null),f(null)},[]),k=c.useCallback(async u=>{const h=++o.current;r(!0);try{const j=await _e(u);if(o.current!==h)return;n(j),j.ok?i(j.current_path):p()}catch{}finally{o.current===h&&r(!1)}},[p]);c.useEffect(()=>{if(!t){o.current++,n(de),p();return}k("")},[p,t,k]),c.useEffect(()=>{if(!m){f(null);return}const u=++d.current;Pe(m).then(h=>{d.current===u&&f(h)}).catch(h=>{console.debug("[hive] discarded:fsBrowser.probe (likely stale token)",h)})},[m]);const x=c.useCallback(u=>{i(u)},[]);return{browse:s,loading:a,navigate:k,probe:l,selectEntry:x,selected:m}},Qe=t=>(t.split(/[\\/]/).filter(Boolean).pop()??"").replace(/:$/u,""),ge=({commandPresetError:t,commandPresetId:s,commandPresets:n,onClose:a,onCommandPresetChange:r,onCreate:m,open:i,initialAdvanced:l=!1,manualHint:f})=>{const{t:o}=R(),d=Se(),{browse:p,loading:k,navigate:x,probe:u,selectEntry:h,selected:j}=Je(i),[y,S]=c.useState(""),[C,E]=c.useState(l),[z,$]=c.useState(""),[b,_]=c.useState(!1),[g,P]=c.useState(""),N=xe(z),T=Qe(N);if(c.useEffect(()=>{i||(S(""),E(l),$(""),_(!1),P(""))},[i,l]),c.useEffect(()=>{u?.suggested_name&&S(u.suggested_name)},[u?.suggested_name]),c.useEffect(()=>{C&&N.length>0&&S(T)},[C,T,N]),!i)return null;const I=o("workspace.browse.drivesRoot"),O=p.root_path===L?I:p.root_path,q=Ye(p.current_path,p.root_path,I),te=p.root_path===L&&p.current_path!==L,V=fe(p.current_path||p.root_path),U=n.find(w=>w.id===s),v=g.trim(),ke=n.length===0&&!t,ae=!s&&v.length===0,re=U?.available===!1&&v.length===0,ve=ae?o("workspace.preset.genericRequiresStartup"):re?o("workspace.preset.notInstalled",{name:U.displayName}):null,we=y.trim().length>0&&(u?.is_dir===!0||C&&N.length>0)&&!ke&&!ae&&!re,je=()=>{const w=C&&N.length>0?N:u?.path??"";w&&m({commandPresetId:s||null,name:y.trim(),path:w,...v?{startupCommand:v}:{}})};return e.jsx(G,{open:!0,onOpenChange:w=>!w&&a(),children:e.jsxs(K,{children:[e.jsx(X,{"data-testid":"server-browse-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 max-md:items-end max-md:p-0 p-4",children:e.jsxs(Y,{"data-testid":"add-workspace-dialog","data-mobile":d||void 0,className:`${d?"dialog-slide-up":"dialog-scale-pop"} elev-2 pointer-events-auto flex w-[760px] max-w-[calc(100vw-32px)] flex-col rounded-lg border max-md:w-full max-md:max-w-full max-md:rounded-b-none max-md:rounded-t-xl`,style:{height:d?"85dvh":"min(600px, calc(100vh - 64px))",background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-3 border-b px-5 py-4",style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--accent) 12%, transparent)",color:"var(--accent)"},children:e.jsx(Q,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(J,{className:"text-lg font-semibold text-pri",children:o("workspace.browse.title")}),e.jsx(se,{className:"mono truncate text-xs text-ter","data-testid":"fs-root-path",children:p.root_path?o("workspace.browse.root",{path:O}):o("workspace.browse.rootLoading")})]}),e.jsx(Ee,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":o("common.closeDialog"),className:"flex h-7 w-7 items-center justify-center rounded text-sec hover:bg-3 hover:text-pri",children:e.jsx(ze,{size:14,"aria-hidden":!0})})})]}),e.jsxs("nav",{className:"flex shrink-0 items-center gap-1 border-b px-4 py-2 text-xs",style:{borderColor:"var(--border)"},"aria-label":o("workspace.browse.breadcrumb"),"data-testid":"fs-breadcrumb",children:[e.jsxs("button",{type:"button",onClick:()=>p.parent_path?x(p.parent_path):null,disabled:!p.parent_path,"aria-label":o("workspace.browse.parentAria"),className:"flex items-center gap-1 rounded px-2 py-0.5 text-sec hover:bg-3 hover:text-pri disabled:opacity-40",children:[e.jsx(Ie,{size:12,"aria-hidden":!0})," ",o("workspace.browse.up")]}),te?e.jsxs("button",{type:"button",onClick:()=>x(L),"aria-label":o("workspace.browse.drivesAria"),"data-testid":"fs-browse-drives",className:"flex items-center gap-1 rounded px-2 py-0.5 text-sec hover:bg-3 hover:text-pri",children:[e.jsx(We,{size:12,"aria-hidden":!0})," ",I]}):null,e.jsx("div",{className:"mx-2 h-4 w-px",style:{background:"var(--border)"}}),q.map((w,ne)=>{const ye=ne===q.length-1;return e.jsxs("span",{className:"flex items-center gap-0.5",children:[ne>0?e.jsx("span",{className:"text-ter",children:V}):null,ye?e.jsx("span",{className:"px-1 py-0.5 font-medium text-pri",children:w.label}):e.jsx("button",{type:"button",onClick:()=>x(w.path),className:"rounded px-1 py-0.5 text-sec hover:bg-3 hover:text-pri",children:w.label})]},w.path)})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 max-md:flex-col",children:[e.jsx("div",{className:"flex min-h-0 flex-1 flex-col max-md:min-h-[40%]",children:e.jsx(Ue,{entries:p.entries,error:p.ok?null:p.error,loading:k,onNavigate:x,onSelect:h,selected:j})}),e.jsxs("div",{className:"flex w-[280px] shrink-0 flex-col gap-3 border-l p-4 max-md:w-full max-md:border-l-0 max-md:border-t max-md:max-h-[45%] max-md:overflow-y-auto",style:{borderColor:"var(--border)"},children:[e.jsx(He,{onSuggestedNameChange:S,probe:u,suggestedName:y}),e.jsx(he,{error:t??ve,onChange:r,presets:n,value:s}),e.jsxs("div",{className:"rounded-lg border overflow-hidden transition-all",style:{borderColor:"var(--border)",background:"var(--bg-1)"},children:[e.jsxs("button",{type:"button",onClick:()=>_(w=>!w),className:"flex w-full items-center justify-between px-3 py-2 text-left text-xs font-semibold uppercase tracking-wider text-sec hover:bg-3 transition-colors cursor-pointer",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(ee,{size:12,"aria-hidden":!0,className:"text-ter"}),o("workspace.advanced.startup")]}),b?e.jsx(B,{size:14,"aria-hidden":!0}):e.jsx(F,{size:14,"aria-hidden":!0})]}),b?e.jsxs("div",{className:"flex flex-col gap-2 border-t p-3 transition-all",style:{background:"var(--bg-2)",borderColor:"var(--border)"},children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:o("workspace.field.startup")}),e.jsx("input",{type:"text",value:g,onChange:w=>P(w.target.value),placeholder:o("workspace.field.startupPlaceholder"),className:"input mono text-sm max-md:text-base",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,inputMode:"text","data-testid":"fs-startup-command"}),e.jsx("span",{className:"text-xs normal-case tracking-normal text-ter leading-relaxed",children:o("workspace.startup.hintShort")})]}):null]}),e.jsxs("div",{className:"rounded-lg border overflow-hidden transition-all",style:{borderColor:"var(--border)",background:"var(--bg-1)"},children:[e.jsxs("button",{type:"button",onClick:()=>E(w=>!w),className:"flex w-full items-center justify-between px-3 py-2 text-left text-xs font-semibold uppercase tracking-wider text-sec hover:bg-3 transition-colors cursor-pointer",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(ee,{size:12,"aria-hidden":!0,className:"text-ter"}),o("workspace.advanced.pastePath")]}),C?e.jsx(B,{size:14,"aria-hidden":!0}):e.jsx(F,{size:14,"aria-hidden":!0})]}),C?e.jsxs("div",{className:"flex flex-col gap-2 border-t p-3 transition-all",style:{background:"var(--bg-2)",borderColor:"var(--border)"},children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:o("workspace.field.absolutePath")}),f?e.jsx("span",{"data-testid":"fs-manual-hint",className:"text-xs normal-case tracking-normal text-ter leading-relaxed",children:f}):null,e.jsx("input",{type:"text",value:z,onChange:w=>$(w.target.value),placeholder:o("workspace.field.absolutePathPlaceholder"),className:"input mono text-sm max-md:text-base",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,inputMode:"url","data-testid":"fs-manual-path"})]}):null]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t px-5 py-3",style:{borderColor:"var(--border)"},children:[e.jsx("button",{type:"button",onClick:a,className:"icon-btn",children:o("common.cancel")}),e.jsx("button",{type:"button",onClick:je,disabled:!we,"data-testid":"add-workspace-create",className:"icon-btn icon-btn--primary",children:o("workspace.confirm.create")})]})]})})]})})},M="claude",et=t=>t.some(s=>s.id===M&&s.available)?M:t.find(s=>s.available)?.id??t[0]?.id??M,tt=(t=typeof navigator>"u"?void 0:navigator)=>{if(!t)return!1;const s=[t.userAgentData?.platform,t.platform,t.userAgent].filter(n=>typeof n=="string"&&n.length>0).join(" ");return/\bWindows?\b|\bWin(?:32|64|CE)\b|Windows NT/i.test(s)},st=({trigger:t,onClose:s,onCreate:n,onTryDemo:a})=>{const{t:r}=R(),m=c.useRef(r);c.useEffect(()=>{m.current=r},[r]);const[i,l]=c.useState({kind:"idle"}),[f,o]=c.useState([]),[d,p]=c.useState(M),[k,x]=c.useState(null),u=c.useRef({error:null,id:M,presets:[]}),h=c.useRef(s);c.useEffect(()=>{h.current=s},[s]),c.useEffect(()=>{if(t===0)return;let b=!1;x(null);const _=ue().then(g=>{if(b)return;const P=g.some(N=>N.id===u.current.id&&N.available)?u.current.id:et(g);u.current={error:null,id:P,presets:g},o(g),p(P)}).catch(()=>{if(b)return;const g=m.current("workspace.preset.loadFailed");u.current={error:g,id:M,presets:[]},o([]),p(M),x(g)});return tt()?(l({kind:"browse"}),()=>{b=!0}):(l({kind:"picking"}),Re().then(async g=>{if(await _,!b){if(g.canceled){if(g.error){l({kind:"error",message:g.error});return}l({kind:"idle"}),h.current();return}if(!g.supported){l({kind:"confirm",probe:null,pasteDefault:!0});return}if(!g.probe?.ok||!g.probe.is_dir){l({kind:"error",message:g.error??m.current("workspace.error.outsideSandbox")});return}l({kind:"confirm",probe:g.probe,pasteDefault:!1})}}).catch(g=>{if(b)return;const P=g instanceof Error?g.message:m.current("workspace.error.pickerFailed");l({kind:"error",message:P})}),()=>{b=!0})},[t]);const j=()=>{l({kind:"idle"}),s()},y=a?()=>{l({kind:"idle"}),s(),a()}:void 0,S=b=>{Promise.resolve(n(b)).then(()=>l({kind:"idle"})).catch(_=>{const g=_ instanceof Error?_.message:r("workspace.error.createFailed");l({kind:"error",title:r("workspace.error.createTitle"),message:g})})},C=b=>{u.current={...u.current,id:b},p(b)},E=f.length>0||k?f:u.current.presets,z=d===""?"":E.length>0&&!E.some(b=>b.id===d&&b.available)?u.current.id:d,$=k??u.current.error;if(i.kind==="idle")return null;if(i.kind==="picking"){const b=()=>l({kind:"idle"});return e.jsx(G,{open:!0,onOpenChange:_=>!_&&b(),children:e.jsxs(K,{children:[e.jsx(X,{className:"app-overlay fixed inset-0 z-40"}),e.jsxs(Y,{"data-testid":"add-workspace-picking","aria-describedby":void 0,className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx(J,{className:"sr-only",children:r("workspace.picking.title")}),e.jsxs("div",{"data-testid":"add-workspace-picking-panel",className:"dialog-scale-pop elev-2 flex items-center gap-3 rounded-lg border px-5 py-4",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsx(Ae,{size:18,"aria-hidden":!0,className:"animate-pulse",style:{color:"var(--accent)"}}),e.jsx("span",{className:"text-sm text-pri",children:r("workspace.picking.message")})]})]})]})})}return i.kind==="error"?e.jsx(G,{open:!0,onOpenChange:b=>!b&&j(),children:e.jsxs(K,{children:[e.jsx(X,{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(Y,{"data-testid":"add-workspace-error",className:"dialog-scale-pop elev-2 pointer-events-auto w-[440px] max-w-[calc(100vw-32px)] rounded-lg border p-5",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--status-red) 14%, transparent)",color:"var(--status-red)"},children:e.jsx($e,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(J,{className:"text-lg font-semibold text-pri",children:i.title??r("workspace.error.pickerFailed")}),e.jsx(se,{className:"mt-1.5 break-words text-sm text-ter",children:i.message})]})]}),e.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:j,className:"icon-btn",children:r("common.close")}),e.jsx("button",{type:"button",onClick:()=>l({kind:"confirm",probe:null,pasteDefault:!0}),className:"icon-btn icon-btn--primary",children:r("workspace.error.pastePathInstead")})]})]})})]})}):i.kind==="browse"?e.jsx(ge,{commandPresetError:$,commandPresetId:z,commandPresets:E,onClose:j,onCommandPresetChange:C,onCreate:S,open:!0}):e.jsx(Ve,{commandPresetError:$,commandPresetId:z,commandPresets:E,pasteFallbackDefault:i.pasteDefault,probe:i.probe,onCancel:j,onCommandPresetChange:C,onCreate:S,onOpenServerBrowse:()=>l({kind:"browse"}),...y?{onTryDemo:y}:{}})},D="claude",at=t=>t.some(s=>s.id===D&&s.available)?D:t.find(s=>s.available)?.id??t[0]?.id??D,rt=t=>{const{t:s}=R(),n=c.useRef(s);c.useEffect(()=>{n.current=s},[s]);const[a,r]=c.useState([]),[m,i]=c.useState(D),[l,f]=c.useState(null),o=c.useRef(D);return c.useEffect(()=>{if(!t)return;let p=!1;return f(null),ue().then(k=>{if(p)return;const u=k.some(h=>h.id===o.current&&h.available)?o.current:at(k);o.current=u,r(k),i(u)}).catch(()=>{p||(o.current=D,r([]),i(D),f(n.current("workspace.preset.loadFailed")))}),()=>{p=!0}},[t]),{commandPresets:a,commandPresetId:m,commandPresetError:l,onCommandPresetChange:p=>{o.current=p,i(p)}}},nt=({trigger:t,onClose:s,onCreate:n})=>{const{t:a}=R(),[r,m]=c.useState(!1),i=c.useRef(0);c.useEffect(()=>{t>0&&t!==i.current&&m(!0)},[t]);const l=rt(r),f=()=>{i.current=t,m(!1),s()},o=d=>{Promise.resolve(n(d)).then(()=>{i.current=t,m(!1)})};return r?e.jsx(ge,{open:!0,initialAdvanced:!0,manualHint:a("workspace.add.manualHint"),commandPresetError:l.commandPresetError,commandPresetId:l.commandPresetId,commandPresets:l.commandPresets,onClose:f,onCommandPresetChange:l.onCommandPresetChange,onCreate:o}):null},lt=({trigger:t,onClose:s,onCreate:n,onTryDemo:a})=>{const{mode:r}=Me();return r==="mobile"?e.jsx(nt,{trigger:t,onClose:s,onCreate:n}):e.jsx(st,{trigger:t,onClose:s,onCreate:n,...a?{onTryDemo:a}:{}})};export{lt as AddWorkspaceFlow};
@@ -1 +0,0 @@
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-B1vvo0-M.js";import{S as Z}from"./square-terminal-CiDDFh5Z.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};