@tt-a1i/hive 1.4.2 → 1.4.4

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 (54) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.en.md +5 -4
  3. package/README.md +1 -1
  4. package/dist/src/cli/hive-update.d.ts +32 -0
  5. package/dist/src/cli/hive-update.js +113 -22
  6. package/dist/src/cli/hive.d.ts +32 -0
  7. package/dist/src/cli/hive.js +72 -17
  8. package/dist/src/cli/team.js +17 -5
  9. package/dist/src/server/agent-command-resolver.d.ts +10 -1
  10. package/dist/src/server/agent-command-resolver.js +48 -4
  11. package/dist/src/server/agent-launch-resolver.js +9 -3
  12. package/dist/src/server/agent-manager-support.d.ts +28 -0
  13. package/dist/src/server/agent-manager-support.js +58 -4
  14. package/dist/src/server/agent-run-bootstrap.d.ts +17 -1
  15. package/dist/src/server/agent-run-bootstrap.js +30 -2
  16. package/dist/src/server/agent-startup-instructions.js +1 -1
  17. package/dist/src/server/app.d.ts +1 -0
  18. package/dist/src/server/app.js +12 -2
  19. package/dist/src/server/fs-browse.d.ts +14 -1
  20. package/dist/src/server/fs-browse.js +48 -5
  21. package/dist/src/server/fs-pick-folder.js +54 -11
  22. package/dist/src/server/hive-team-guidance.js +5 -4
  23. package/dist/src/server/open-target-commands.js +30 -4
  24. package/dist/src/server/post-start-input-writer.js +6 -3
  25. package/dist/src/server/routes-team.js +10 -1
  26. package/dist/src/server/runtime-store.d.ts +3 -1
  27. package/dist/src/server/session-capture-claude.d.ts +23 -0
  28. package/dist/src/server/session-capture-claude.js +24 -1
  29. package/dist/src/server/session-capture-opencode.d.ts +18 -0
  30. package/dist/src/server/session-capture-opencode.js +27 -2
  31. package/dist/src/server/startup-command-parser.d.ts +15 -0
  32. package/dist/src/server/startup-command-parser.js +33 -2
  33. package/dist/src/server/tasks-file-watcher.d.ts +26 -0
  34. package/dist/src/server/tasks-file-watcher.js +29 -3
  35. package/dist/src/server/team-operations.d.ts +5 -1
  36. package/dist/src/server/team-operations.js +44 -3
  37. package/dist/src/server/terminal-input-profile.js +2 -8
  38. package/dist/src/server/terminal-ws-server.js +26 -8
  39. package/package.json +2 -2
  40. package/web/dist/assets/{AddWorkerDialog-D-XO6MoI.js → AddWorkerDialog-DeZhTQLi.js} +2 -2
  41. package/web/dist/assets/AddWorkspaceDialog-DDpXNEKf.js +1 -0
  42. package/web/dist/assets/{FirstRunWizard-xHiver2Q.js → FirstRunWizard-B5wLcat5.js} +1 -1
  43. package/web/dist/assets/{MarketplaceDrawer-CqE8_4ZP.js → MarketplaceDrawer-BC0eBOEW.js} +1 -1
  44. package/web/dist/assets/{WorkerModal-DgOuzZMW.js → WorkerModal-BwMHq-Bi.js} +1 -1
  45. package/web/dist/assets/WorkspaceTaskDrawer-CxvT4nqs.js +1 -0
  46. package/web/dist/assets/{WorkspaceTerminalPanels-BqEcvvSH.js → WorkspaceTerminalPanels-CvibsPSd.js} +1 -1
  47. package/web/dist/assets/index-Ddb7bDN5.js +75 -0
  48. package/web/dist/assets/path-join-S7qkXQtP.js +1 -0
  49. package/web/dist/index.html +1 -1
  50. package/web/dist/sw.js +1 -1
  51. package/web/dist/assets/AddWorkspaceDialog-D4InpBpd.js +0 -1
  52. package/web/dist/assets/WorkspaceTaskDrawer-D0Y-Gyvw.js +0 -1
  53. package/web/dist/assets/chevron-right-Bmg7DcUj.js +0 -1
  54. package/web/dist/assets/index-CWW5vUjQ.js +0 -76
@@ -0,0 +1 @@
1
+ import{c as s}from"./index-Ddb7bDN5.js";const a=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],h=s("chevron-right",a),o=t=>{const e=t.lastIndexOf("\\"),r=t.lastIndexOf("/");return e>=0&&e>r?"\\":r>=0?"/":/^[A-Za-z]:/u.test(t)?"\\":"/"},d=(t,...e)=>{const r=o(t);return[t.replace(/[\\/]+$/u,""),...e].join(r)};export{h as C,o as d,d as j};
@@ -27,7 +27,7 @@
27
27
  href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=DM+Mono:wght@400;500&display=swap"
28
28
  rel="stylesheet"
29
29
  />
30
- <script type="module" crossorigin src="/assets/index-CWW5vUjQ.js"></script>
30
+ <script type="module" crossorigin src="/assets/index-Ddb7bDN5.js"></script>
31
31
  <link rel="stylesheet" crossorigin href="/assets/index-BEsTmfrO.css">
32
32
  </head>
33
33
  <body>
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 = '1.4.2'
10
+ const VERSION = '1.4.4'
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 V,u as D,r as c,j as e,o as se,e as A,i as Z,a as T,P as I,O as q,C as U,b as W,D as K,q as ae,s as re,t as ne,X as ce,v as le,w as oe,T as ie}from"./index-CWW5vUjQ.js";import{C as L}from"./chevron-right-Bmg7DcUj.js";const de=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],pe=V("arrow-up",de);const xe=[["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"}]],ue=V("folder-search",xe);const me=[["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"}]],X=V("folder",me);const he=[["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"}]],Q=V("git-branch",he),ee=({error:t,onChange:o,presets:p,value:a})=>{const{t:i}=D(),[d,r]=c.useState(!1),s=c.useRef(null),u=p.find(l=>l.id===a),n=a==="",k=u?[u.command,...u.args].join(" ").trim():i(n?"workspace.preset.genericPreview":"workspace.preset.loading"),g=u?.displayName??(n?i("workspace.preset.generic"):"Claude Code (CC)"),j=p.length===0&&!n;return c.useEffect(()=>{if(!d)return;const l=f=>{s.current?.contains(f.target)||r(!1)},m=f=>{f.key==="Escape"&&r(!1)};return document.addEventListener("mousedown",l),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",m)}},[d]),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:i("workspace.preset.label")}),e.jsxs("div",{ref:s,className:"cli-select group relative",children:[e.jsx(se,{size:14,"aria-hidden":!0,className:"cli-select__leading"}),e.jsx("button",{type:"button","aria-haspopup":"listbox","aria-expanded":d,"aria-disabled":j||void 0,className:"cli-select__field cli-select__field--button text-left","data-testid":"workspace-command-preset","data-value":a,disabled:j,onClick:()=>r(l=>!l),children:g}),e.jsx(A,{size:14,"aria-hidden":!0,className:"cli-select__trailing"}),d&&p.length>0?e.jsxs("div",{role:"listbox","aria-label":i("workspace.preset.optionsAria"),className:"cli-select__menu","data-testid":"workspace-command-preset-menu",children:[p.map(l=>{const m=l.id===a,f=l.available===!1;return e.jsxs("button",{type:"button",role:"option","aria-selected":m,"data-testid":`workspace-command-preset-option-${l.id}`,className:"cli-select__option",onClick:()=>{o(l.id),r(!1)},children:[e.jsx(Z,{size:12,"aria-hidden":!0,className:"cli-select__check",style:{opacity:m?1:0}}),e.jsxs("span",{children:[l.displayName,f?i("workspace.preset.notFoundSuffix"):""]})]},l.id)}),e.jsxs("button",{type:"button",role:"option","aria-selected":n,"data-testid":"workspace-command-preset-option-generic",className:"cli-select__option",onClick:()=>{o(""),r(!1)},children:[e.jsx(Z,{size:12,"aria-hidden":!0,className:"cli-select__check",style:{opacity:n?1:0}}),e.jsx("span",{children:i("workspace.preset.generic")})]})]}):null]}),e.jsxs("div",{className:"mono flex items-center gap-1.5 truncate text-xs text-ter",title:k,children:[e.jsx("span",{className:"text-sec",children:"$"}),e.jsx("span",{className:"truncate",children:k})]}),t?e.jsx("span",{className:"text-xs",style:{color:"var(--status-red)"},children:t}):null]})},G=t=>t.split(/[\\/]/).filter(Boolean).pop()??"",M=({children:t})=>e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:t}),fe=({probe:t,pasteFallbackDefault:o=!1,commandPresetError:p,commandPresetId:a,commandPresets:i,onCancel:d,onCommandPresetChange:r,onCreate:s,onOpenServerBrowse:u})=>{const{t:n}=D(),k=t?.path??"",g=t?.suggested_name??G(k),[j,l]=c.useState(g),[m,f]=c.useState(""),[C,P]=c.useState(o),[w,E]=c.useState(!1),[_,h]=c.useState("");c.useEffect(()=>{l(t?.suggested_name??G(t?.path??""))},[t?.path,t?.suggested_name]);const y=m.trim(),x=C&&y.length>0?y:t?.path??"",N=_.trim(),S=i.find(v=>v.id===a),R=i.length===0&&!p,B=!a&&N.length===0,F=S?.available===!1&&N.length===0,O=B?n("workspace.preset.genericRequiresStartup"):F?n("workspace.preset.notInstalled",{name:S.displayName}):null,$=j.trim().length>0&&x.length>0&&!R&&!B&&!F,H=()=>{$&&s({commandPresetId:a||null,name:j.trim(),path:x,...N?{startupCommand:N}:{}})};return e.jsx(T,{open:!0,onOpenChange:v=>!v&&d(),children:e.jsxs(I,{children:[e.jsx(q,{"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(U,{"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(X,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(W,{className:"text-lg font-semibold text-pri",children:n("workspace.confirm.title")}),e.jsx(K,{className:"text-xs text-ter",children:n("workspace.confirm.description")})]})]}),e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.path")}),e.jsx("input",{readOnly:!0,value:t?.path??"",placeholder:n("workspace.field.pathEmptyPlaceholder"),className:"input input--readonly mono","data-testid":"confirm-workspace-path"})]}),t?.is_git_repository?e.jsxs("div",{className:"flex items-center gap-2 text-xs","data-testid":"confirm-workspace-git-badge",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded px-2 py-0.5 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) 30%, transparent)"},children:[e.jsx(Q,{size:12,"aria-hidden":!0}),t.current_branch??n("workspace.git.detached")]}),e.jsx("span",{className:"text-ter",children:n("workspace.git.detected")})]}):t?.ok?e.jsx("span",{className:"text-xs text-ter",children:n("workspace.git.none")}):null,e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.name")}),e.jsx("input",{value:j,onChange:v=>l(v.target.value),placeholder:G(t?.path??"")||n("workspace.field.nameDefaultPlaceholder"),className:"input","data-testid":"confirm-workspace-name"})]}),e.jsx(ee,{error:p??O,onChange:r,presets:i,value:a}),e.jsxs("button",{type:"button",onClick:()=>E(v=>!v),className:"flex items-center gap-1.5 self-start text-xs uppercase tracking-wider text-ter hover:text-sec","data-testid":"confirm-workspace-startup-toggle",children:[w?e.jsx(A,{size:12,"aria-hidden":!0}):e.jsx(L,{size:12,"aria-hidden":!0}),n("workspace.advanced.startup")]}),w?e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.startup")}),e.jsx("input",{type:"text",value:_,onChange:v=>h(v.target.value),placeholder:n("workspace.field.startupPlaceholder"),className:"input mono","data-testid":"confirm-workspace-startup-command"}),e.jsx("span",{className:"text-xs text-ter",children:n("workspace.startup.hint")})]}):null,e.jsxs("button",{type:"button",onClick:()=>P(v=>!v),className:"flex items-center gap-1.5 self-start text-xs uppercase tracking-wider text-ter hover:text-sec","data-testid":"confirm-workspace-paste-toggle",children:[C?e.jsx(A,{size:12,"aria-hidden":!0}):e.jsx(L,{size:12,"aria-hidden":!0}),n("workspace.advanced.pastePath")]}),C?e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.absolutePath")}),e.jsx("input",{type:"text",value:m,onChange:v=>f(v.target.value),placeholder:n("workspace.field.absolutePathPlaceholder"),className:"input mono","data-testid":"confirm-workspace-paste-path"})]}):null,e.jsxs("button",{type:"button",onClick:u,className:"flex items-center gap-1.5 self-start text-xs uppercase tracking-wider text-ter hover:text-sec","data-testid":"confirm-workspace-browse-toggle",children:[e.jsx(L,{size:12,"aria-hidden":!0}),n("workspace.advanced.browse")]})]}),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:d,className:"icon-btn",children:n("common.cancel")}),e.jsx("button",{type:"button",onClick:H,disabled:!$,"data-testid":"confirm-workspace-create",className:"icon-btn icon-btn--primary",children:n("workspace.confirm.create")})]})]})})]})})},be=({entries:t,error:o,loading:p,onNavigate:a,onSelect:i,selected:d})=>{const{t:r}=D();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:p?e.jsx("p",{className:"p-4 text-center text-xs text-ter",children:r("common.loading")}):o?e.jsx("p",{className:"p-4 text-center text-xs",style:{color:"var(--status-red)"},"data-testid":"fs-browse-error",children:o}):t.length===0?e.jsx("p",{className:"p-4 text-center text-xs text-ter",children:r("workspace.browse.empty")}):e.jsx("ul",{children:t.map(s=>{const u=d===s.path;return e.jsxs("li",{className:"flex items-center gap-0",children:[e.jsxs("button",{type:"button","data-testid":`fs-entry-${s.name}`,onClick:()=>i(s.path),onDoubleClick:()=>a(s.path),className:"flex flex-1 items-center gap-2 px-3 py-2 text-left text-xs hover:bg-3",style:u?{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:s.is_git_repository?e.jsx(Q,{size:14}):e.jsx(X,{size:14})}),e.jsx("span",{className:"mono flex-1 truncate",children:s.name}),s.is_git_repository?e.jsx("span",{className:"text-xs uppercase tracking-wider",style:{color:"var(--accent)"},children:r("workspace.browse.gitBadge")}):null]}),e.jsx("button",{type:"button","data-testid":`fs-entry-open-${s.name}`,onClick:()=>a(s.path),"aria-label":r("workspace.browse.openAria",{name:s.name}),className:"px-3 py-2 text-xs text-ter hover:text-pri",children:"→"})]},s.path)})})})},ge=({probe:t,suggestedName:o,onSuggestedNameChange:p})=>{const{t:a}=D(),i=!!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")})}):i?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:o,onChange:d=>p(d.target.value),disabled:!i,className:"mono rounded border px-2 py-1 text-sm text-pri disabled:opacity-50",style:{background:"var(--bg-0)",borderColor:"var(--border)"},"data-testid":"fs-preview-name-input"})]})]})},ke=t=>{const p=t.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean),a=p[p.length-1];return a?`~ (${a})`:t},ve=(t,o)=>{if(!o||!t)return[];const p=[{label:ke(o),path:o}];if(t===o)return p;const a=o.replace(/[\\/]+$/,""),i=t.startsWith(a)?t.slice(a.length).replace(/^[\\/]+/,""):"";if(!i)return p;const d=i.split(/[\\/]/).filter(Boolean);let r=a;for(const s of d)r=`${r}/${s}`,p.push({label:s,path:r});return p},J={current_path:"",entries:[],error:null,ok:!1,parent_path:null,root_path:""},je=t=>{const[o,p]=c.useState(J),[a,i]=c.useState(!1),[d,r]=c.useState(null),[s,u]=c.useState(null),n=c.useRef(0),k=c.useRef(0),g=c.useCallback(async l=>{const m=++n.current;i(!0);try{const f=await ae(l);if(n.current!==m)return;p(f),f.ok&&r(f.current_path)}catch{}finally{n.current===m&&i(!1)}},[]);c.useEffect(()=>{if(!t){n.current++,k.current++,p(J),r(null),u(null);return}g("")},[t,g]),c.useEffect(()=>{if(!d){u(null);return}const l=++k.current;re(d).then(m=>{k.current===l&&u(m)}).catch(m=>{console.debug("[hive] discarded:fsBrowser.probe (likely stale token)",m)})},[d]);const j=c.useCallback(l=>{r(l)},[]);return{browse:o,loading:a,navigate:g,probe:s,selectEntry:j,selected:d}},we=({commandPresetError:t,commandPresetId:o,commandPresets:p,onClose:a,onCommandPresetChange:i,onCreate:d,open:r})=>{const{t:s}=D(),{browse:u,loading:n,navigate:k,probe:g,selectEntry:j,selected:l}=je(r),[m,f]=c.useState(""),[C,P]=c.useState(!1),[w,E]=c.useState(""),[_,h]=c.useState(!1),[y,x]=c.useState("");if(c.useEffect(()=>{r||(f(""),P(!1),E(""),h(!1),x(""))},[r]),c.useEffect(()=>{g?.suggested_name&&f(g.suggested_name)},[g?.suggested_name]),!r)return null;const N=ve(u.current_path,u.root_path),S=p.find(b=>b.id===o),R=y.trim(),B=p.length===0&&!t,F=!o&&R.length===0,O=S?.available===!1&&R.length===0,$=F?s("workspace.preset.genericRequiresStartup"):O?s("workspace.preset.notInstalled",{name:S.displayName}):null,H=m.trim().length>0&&(g?.is_dir===!0||C&&w.trim().length>0)&&!B&&!F&&!O,v=()=>{const b=C&&w.trim().length>0?w.trim():g?.path??"";b&&d({commandPresetId:o||null,name:m.trim(),path:b,...R?{startupCommand:R}:{}})};return e.jsx(T,{open:!0,onOpenChange:b=>!b&&a(),children:e.jsxs(I,{children:[e.jsx(q,{"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 p-4",children:e.jsxs(U,{"data-testid":"add-workspace-dialog",className:"dialog-scale-pop elev-2 pointer-events-auto flex w-[760px] max-w-[calc(100vw-32px)] flex-col rounded-lg border",style:{height:"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(X,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(W,{className:"text-lg font-semibold text-pri",children:s("workspace.browse.title")}),e.jsx(K,{className:"mono truncate text-xs text-ter","data-testid":"fs-root-path",children:u.root_path?s("workspace.browse.root",{path:u.root_path}):s("workspace.browse.rootLoading")})]}),e.jsx(ne,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":s("common.closeDialog"),className:"flex h-7 w-7 items-center justify-center rounded text-sec hover:bg-3 hover:text-pri",children:e.jsx(ce,{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":s("workspace.browse.breadcrumb"),"data-testid":"fs-breadcrumb",children:[e.jsxs("button",{type:"button",onClick:()=>u.parent_path?k(u.parent_path):null,disabled:!u.parent_path,"aria-label":s("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(pe,{size:12,"aria-hidden":!0})," ",s("workspace.browse.up")]}),e.jsx("div",{className:"mx-2 h-4 w-px",style:{background:"var(--border)"}}),N.map((b,Y)=>{const te=Y===N.length-1;return e.jsxs("span",{className:"flex items-center gap-0.5",children:[Y>0?e.jsx("span",{className:"text-ter",children:"/"}):null,te?e.jsx("span",{className:"px-1 py-0.5 font-medium text-pri",children:b.label}):e.jsx("button",{type:"button",onClick:()=>k(b.path),className:"rounded px-1 py-0.5 text-sec hover:bg-3 hover:text-pri",children:b.label})]},b.path)})]}),e.jsxs("div",{className:"flex min-h-0 flex-1",children:[e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:e.jsx(be,{entries:u.entries,error:u.ok?null:u.error,loading:n,onNavigate:k,onSelect:j,selected:l})}),e.jsxs("div",{className:"flex w-[280px] shrink-0 flex-col gap-3 border-l p-4",style:{borderColor:"var(--border)"},children:[e.jsx(ge,{onSuggestedNameChange:f,probe:g,suggestedName:m}),e.jsx(ee,{error:t??$,onChange:i,presets:p,value:o}),e.jsxs("button",{type:"button",onClick:()=>h(b=>!b),className:"flex items-center gap-1.5 text-left text-xs uppercase tracking-wider text-ter hover:text-sec",children:[_?e.jsx(A,{size:12,"aria-hidden":!0}):e.jsx(L,{size:12,"aria-hidden":!0}),s("workspace.advanced.startup")]}),_?e.jsxs("label",{className:"flex flex-col gap-2 text-xs uppercase tracking-wider text-ter",children:[s("workspace.field.startup"),e.jsx("input",{type:"text",value:y,onChange:b=>x(b.target.value),placeholder:s("workspace.field.startupPlaceholder"),className:"input mono","data-testid":"fs-startup-command"}),e.jsx("span",{className:"text-xs normal-case tracking-normal text-ter",children:s("workspace.startup.hintShort")})]}):null,e.jsxs("button",{type:"button",onClick:()=>P(b=>!b),className:"flex items-center gap-1.5 text-left text-xs uppercase tracking-wider text-ter hover:text-sec",children:[C?e.jsx(A,{size:12,"aria-hidden":!0}):e.jsx(L,{size:12,"aria-hidden":!0}),s("workspace.advanced.pastePath")]}),C?e.jsxs("label",{className:"flex flex-col gap-2 text-xs uppercase tracking-wider text-ter",children:[s("workspace.field.absolutePath"),e.jsx("input",{type:"text",value:w,onChange:b=>E(b.target.value),placeholder:s("workspace.field.absolutePathPlaceholder"),className:"input mono","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:s("common.cancel")}),e.jsx("button",{type:"button",onClick:v,disabled:!H,"data-testid":"add-workspace-create",className:"icon-btn icon-btn--primary",children:s("workspace.confirm.create")})]})]})})]})})},z="claude",ye=t=>t.some(o=>o.id===z&&o.available)?z:t.find(o=>o.available)?.id??t[0]?.id??z,_e=({trigger:t,onClose:o,onCreate:p})=>{const{t:a}=D(),i=c.useRef(a);c.useEffect(()=>{i.current=a},[a]);const[d,r]=c.useState({kind:"idle"}),[s,u]=c.useState([]),[n,k]=c.useState(z),[g,j]=c.useState(null),l=c.useRef({error:null,id:z,presets:[]}),m=c.useRef(o);c.useEffect(()=>{m.current=o},[o]),c.useEffect(()=>{if(t===0)return;let h=!1;j(null);const y=le().then(x=>{if(h)return;const N=x.some(S=>S.id===l.current.id&&S.available)?l.current.id:ye(x);l.current={error:null,id:N,presets:x},u(x),k(N)}).catch(()=>{if(h)return;const x=i.current("workspace.preset.loadFailed");l.current={error:x,id:z,presets:[]},u([]),k(z),j(x)});return r({kind:"picking"}),oe().then(async x=>{if(await y,!h){if(x.canceled){if(x.error){r({kind:"error",message:x.error});return}r({kind:"idle"}),m.current();return}if(!x.supported){r({kind:"confirm",probe:null,pasteDefault:!0});return}if(!x.probe?.ok||!x.probe.is_dir){r({kind:"error",message:x.error??i.current("workspace.error.outsideSandbox")});return}r({kind:"confirm",probe:x.probe,pasteDefault:!1})}}).catch(x=>{if(h)return;const N=x instanceof Error?x.message:i.current("workspace.error.pickerFailed");r({kind:"error",message:N})}),()=>{h=!0}},[t]);const f=()=>{r({kind:"idle"}),o()},C=h=>{Promise.resolve(p(h)).then(()=>r({kind:"idle"})).catch(y=>{const x=y instanceof Error?y.message:a("workspace.error.createFailed");r({kind:"error",title:a("workspace.error.createTitle"),message:x})})},P=h=>{l.current={...l.current,id:h},k(h)},w=s.length>0||g?s:l.current.presets,E=n===""?"":w.length>0&&!w.some(h=>h.id===n&&h.available)?l.current.id:n,_=g??l.current.error;if(d.kind==="idle")return null;if(d.kind==="picking"){const h=()=>r({kind:"idle"});return e.jsx(T,{open:!0,onOpenChange:y=>!y&&h(),children:e.jsxs(I,{children:[e.jsx(q,{className:"app-overlay fixed inset-0 z-40"}),e.jsxs(U,{"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(W,{className:"sr-only",children:a("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(ue,{size:18,"aria-hidden":!0,className:"animate-pulse",style:{color:"var(--accent)"}}),e.jsx("span",{className:"text-sm text-pri",children:a("workspace.picking.message")})]})]})]})})}return d.kind==="error"?e.jsx(T,{open:!0,onOpenChange:h=>!h&&f(),children:e.jsxs(I,{children:[e.jsx(q,{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(U,{"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(ie,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(W,{className:"text-lg font-semibold text-pri",children:d.title??a("workspace.error.pickerFailed")}),e.jsx(K,{className:"mt-1.5 break-words text-sm text-ter",children:d.message})]})]}),e.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:f,className:"icon-btn",children:a("common.close")}),e.jsx("button",{type:"button",onClick:()=>r({kind:"confirm",probe:null,pasteDefault:!0}),className:"icon-btn icon-btn--primary",children:a("workspace.error.pastePathInstead")})]})]})})]})}):d.kind==="browse"?e.jsx(we,{commandPresetError:_,commandPresetId:E,commandPresets:w,onClose:f,onCommandPresetChange:P,onCreate:C,open:!0}):e.jsx(fe,{commandPresetError:_,commandPresetId:E,commandPresets:w,pasteFallbackDefault:d.pasteDefault,probe:d.probe,onCancel:f,onCommandPresetChange:P,onCreate:C,onOpenServerBrowse:()=>r({kind:"browse"})})};export{_e as AddWorkspaceDialog};
@@ -1 +0,0 @@
1
- import{c as z,j as e,u as O,T as oe,R as ie,r as k,p as re,a as ce,P as de,O as ue,C as pe,b as he,D as xe,d as S,X as ke,E as me,e as te,f as Y,g as fe,h as ge,i as je,k as be,l as we,m as ye,n as D}from"./index-CWW5vUjQ.js";import{C as se}from"./chevron-right-Bmg7DcUj.js";const ve=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],K=z("at-sign",ve);const Ne=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Te=z("circle",Ne);const _e=[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],G=z("corner-down-right",_e);const Ce=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],$e=z("file-code",Ce);const Se=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],ae=z("file-text",Se);const ze=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],Ee=z("save",ze),U=t=>{const n=[];let l="",a=0;const c=()=>{l&&(n.push(l),l="")};let o=0;for(;o<t.length;){const i=t.slice(o),r=i.match(/^\*\*([^*]+?)\*\*/);if(r?.[1]){c(),n.push(e.jsx("strong",{children:U(r[1])},a++)),o+=r[0].length;continue}const s=i.match(/^`([^`]+?)`/);if(s?.[1]){c(),n.push(e.jsx("code",{className:"mono",children:s[1]},a++)),o+=s[0].length;continue}const u=i.match(/^\*([^*]+?)\*/);if(u?.[1]){c(),n.push(e.jsx("em",{children:U(u[1])},a++)),o+=u[0].length;continue}l+=t[o],o+=1}return c(),n},De=({content:t,hasConflict:n,onContentChange:l,onKeepLocal:a,onReload:c,onSave:o})=>{const{t:i}=O(),r=s=>{s.preventDefault(),o()};return e.jsxs("form",{onSubmit:r,className:"flex h-full flex-col gap-3",children:[e.jsxs("label",{className:"flex min-h-0 flex-1 flex-col gap-2 text-xs text-sec",children:[e.jsxs("span",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-sec",children:i("tasks.raw.label")}),e.jsx("span",{className:"mono text-xs text-ter",children:i("tasks.raw.lineCount",{count:t.split(/\r?\n/).length})})]}),e.jsx("textarea",{"aria-label":i("tasks.raw.label"),value:t,onChange:s=>l(s.target.value),className:"mono min-h-[360px] flex-1 resize-none rounded border p-3 text-sm text-pri outline-none focus:border-[var(--accent)]",style:{background:"var(--bg-0)",borderColor:"var(--border)"}})]}),n?e.jsxs("div",{className:"flex items-start gap-2 rounded border p-3 text-xs",style:{borderColor:"var(--status-orange)",color:"var(--status-orange)"},children:[e.jsx(oe,{className:"mt-0.5 shrink-0",size:16}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium",children:i("tasks.raw.conflictTitle")}),e.jsx("p",{className:"mt-1 text-ter",children:i("tasks.raw.conflictDescription")})]}),e.jsxs("div",{className:"flex shrink-0 gap-2",children:[e.jsxs("button",{type:"button",onClick:c,className:"icon-btn",children:[e.jsx(ie,{size:14}),i("tasks.raw.reload")]}),e.jsx("button",{type:"button",onClick:a,className:"icon-btn",children:i("tasks.raw.keepLocal")})]})]}):null,e.jsx("div",{className:"flex justify-end border-t pt-3",style:{borderColor:"var(--border)"},children:e.jsxs("button",{type:"submit",className:"icon-btn icon-btn--primary",children:[e.jsx(Ee,{size:14}),i("tasks.raw.save")]})})]})},B=["#a78bfa","#60a5fa","#5eead4","#86efac","#fde047","#fb923c","#f9a8d4","#fca5a5"],ne=t=>{let n=0;for(let l=0;l<t.length;l+=1)n=n*31+t.charCodeAt(l)>>>0;return B[n%B.length]??B[0]},Me=[{pattern:/^(done|completed?|finished?|ok|success|完成|已完成|搞定)$/i,tone:"green"},{pattern:/^(working|running|in[-_ ]?progress|dispatching|dispatched|进行中|派单中?|执行中|处理中)$/i,tone:"orange"},{pattern:/^(blocked|failed|error|errored|阻塞|失败|出错)$/i,tone:"red"},{pattern:/^(queued|waiting|pending|todo|open|idle|待办|等待中?|队列中|未开始)$/i,tone:"neutral"}],W=new Set(["owner","assignee","负责","负责人","执行人"]),Z=new Set(["status","状态"]),J=new Set(["报告","report","文件","file","path","日志","log","产物"]),Re=/^(.*?)\s*\(([^()]+)\)\s*$/,Ae=/\s*[·,,;;]\s*/,Le=/^([^::]+)[::]\s*(.+)$/,Pe=t=>{for(const{pattern:n,tone:l}of Me)if(n.test(t))return l;return"neutral"},Ke=t=>t.includes("/")?!0:/^[A-Za-z0-9._-]+\.[A-Za-z0-9]+$/.test(t),Oe=t=>{const n=t.match(Re);if(!n)return{title:t,meta:[]};const[,l="",a=""]=n;if(!a.trim())return{title:t,meta:[]};const c=a.split(Ae).filter(Boolean),o=[];for(const i of c){const r=i.match(Le);if(!r){o.push({kind:"note",value:i.trim()});continue}const s=(r[1]??"").trim(),u=(r[2]??"").trim(),h=s.toLowerCase();W.has(h)||W.has(s)?o.push({kind:"owner",value:u}):Z.has(h)||Z.has(s)?o.push({kind:"status",value:u,tone:Pe(u)}):J.has(h)||J.has(s)||Ke(u)?o.push({kind:"path",label:s,value:u}):o.push({kind:"note",value:`${s}: ${u}`})}return{title:l.trim(),meta:o}},Q=3,Ie=({item:t,handlers:n})=>{if(t.kind==="status")return e.jsx("span",{className:`pill pill--${t.tone}`,"data-testid":"task-meta-status",children:t.value});if(t.kind==="owner"){const a={"--owner-tone":ne(t.value)};return n.onSelectOwner?e.jsxs("button",{type:"button",className:"task-owner task-owner--clickable","data-testid":"task-meta-owner","data-owner":t.value,onClick:c=>{c.stopPropagation(),n.onSelectOwner?.(t.value)},style:a,children:[e.jsx(K,{size:10,"aria-hidden":!0}),t.value]}):e.jsxs("span",{className:"task-owner","data-testid":"task-meta-owner","data-owner":t.value,style:a,children:[e.jsx(K,{size:10,"aria-hidden":!0}),t.value]})}return t.kind==="path"?e.jsxs("span",{className:"pill pill--neutral mono inline-flex items-center gap-1","data-testid":"task-meta-path",title:`${t.label}: ${t.value}`,children:[e.jsx(ae,{size:10,"aria-hidden":!0}),t.value]}):e.jsx("span",{className:"text-xs text-ter","data-testid":"task-meta-note",children:t.value})},F=({initial:t,onSubmit:n,onCancel:l,placeholder:a})=>{const[c,o]=k.useState(t),i=()=>{const s=c.trim();if(!s){l();return}n(s)},r=s=>{s.key==="Enter"?(s.preventDefault(),i()):s.key==="Escape"&&(s.preventDefault(),l())};return e.jsx("input",{type:"text",autoFocus:!0,value:c,placeholder:a,onChange:s=>o(s.target.value),onKeyDown:r,onBlur:i,"data-testid":"task-inline-input",className:"task-row__input"})},q=({task:t,handlers:n,depth:l})=>{const{t:a}=O(),c=t.checked?fe:Te,{title:o,meta:i}=Oe(t.text),[r,s]=k.useState(!1),[u,h]=k.useState(!1),[b,M]=k.useState(!1),[_,C]=k.useState(!1),g=k.useRef(null);k.useEffect(()=>()=>{g.current&&clearTimeout(g.current)},[]);const{onToggle:f,onUpdateText:x,onDelete:y,onAppendSubtask:R,onCopyLine:I,onSelectOwner:v,writeDisabled:j=!1}=n,A=!!x&&!j,$=!!y&&!j,N=!!R&&!j,L=!!I,E=!r&&!u&&(A||$||N||L),w=t.children.length,T=ge(t),P=l+1>=Q,H=w>0,V=b?a("tasks.aria.expandSubtasks",{count:w}):a("tasks.aria.collapseSubtasks",{count:w}),p=v?{onSelectOwner:v}:{};return e.jsxs("li",{className:"task-node","data-testid":`task-line-${t.line}`,children:[e.jsxs("div",{className:"task-row group",children:[l>=Q?e.jsx("span",{"aria-hidden":!0,className:"task-row__deep-marker",children:"▸"}):null,e.jsxs("label",{className:"task-row__checkbox-cell",children:[e.jsx("input",{type:"checkbox",checked:t.checked,disabled:j,onChange:()=>{j||f(t.line)},className:"sr-only","data-testid":`task-checkbox-${t.line}`,"aria-label":t.text||`task-line-${t.line}`}),e.jsx("span",{className:`task-row__indicator ${t.checked?"task-status-done":"task-status-open"}`,"aria-hidden":!0,children:e.jsx(c,{size:14})})]}),e.jsx("span",{className:"min-w-0 flex-1",children:r?e.jsx(F,{initial:t.text,placeholder:a("tasks.placeholder.editTask"),onSubmit:d=>{s(!1),x?.(t.line,d)},onCancel:()=>s(!1)}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flex min-w-0 items-start gap-2",children:[e.jsx("span",{className:`task-row__title min-w-0 flex-1 ${t.checked?"text-ter line-through":"text-pri"}`,children:U(o)}),H?e.jsx("button",{type:"button",className:"task-row__collapse",onClick:d=>{d.stopPropagation(),M(m=>!m)},"data-testid":`task-collapse-${t.line}`,"aria-expanded":!b,"aria-label":V,children:b?e.jsx(se,{size:12,"aria-hidden":!0}):e.jsx(te,{size:12,"aria-hidden":!0})}):null,T?e.jsxs("span",{className:"task-child-count mono","data-testid":`task-progress-${t.line}`,title:a("tasks.progress.subtaskTitle",{done:T.done,total:T.total}),children:[T.done,"/",T.total]}):null]}),i.length>0||t.mentions.length>0?e.jsxs("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[i.map(d=>e.jsx(Ie,{item:d,handlers:p},`${t.line}-meta-${d.kind}-${"label"in d?d.label:""}-${d.value}`)),t.mentions.map(d=>{const m=d.replace(/^@/,""),X={"--owner-tone":ne(m)};return v?e.jsxs("button",{type:"button",className:"task-owner task-owner--clickable","data-testid":`task-mention-${m}`,"data-owner":m,onClick:le=>{le.stopPropagation(),v(m)},style:X,children:[e.jsx(K,{size:10,"aria-hidden":!0}),m]},`${t.line}-mention-${d}`):e.jsxs("span",{className:"task-owner","data-testid":`task-mention-${m}`,"data-owner":m,style:X,children:[e.jsx(K,{size:10,"aria-hidden":!0}),m]},`${t.line}-mention-${d}`)})]}):null]})}),E?e.jsxs("div",{className:"task-row__actions",children:[L?e.jsx(S,{label:a(_?"tasks.action.copied":"tasks.action.copyLine"),children:e.jsx("button",{type:"button",className:"task-row__action",onClick:()=>{I?.(t.line),C(!0),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{C(!1),g.current=null},1500)},"data-testid":`task-copy-${t.line}`,"aria-label":a(_?"tasks.aria.copiedTaskLine":"tasks.aria.copyTaskLine"),children:_?e.jsx(je,{size:12}):e.jsx(be,{size:12})})}):null,A?e.jsx(S,{label:a("tasks.action.edit"),children:e.jsx("button",{type:"button",className:"task-row__action",onClick:()=>s(!0),"data-testid":`task-edit-${t.line}`,"aria-label":a("tasks.aria.editTask"),children:e.jsx(we,{size:12})})}):null,N?e.jsx(S,{label:a("tasks.action.addSubtask"),children:e.jsx("button",{type:"button",className:"task-row__action",onClick:()=>{M(!1),h(!0)},"data-testid":`task-add-subtask-${t.line}`,"aria-label":a("tasks.aria.addSubtask"),children:e.jsx(G,{size:12})})}):null,$?e.jsx(S,{label:a("tasks.action.delete"),children:e.jsx("button",{type:"button",className:"task-row__action task-row__action--danger",onClick:()=>y?.(t.line),"data-testid":`task-delete-${t.line}`,"aria-label":a("tasks.aria.deleteTask"),children:e.jsx(ye,{size:12})})}):null]}):null]}),w>0&&!b||u?e.jsxs("ul",{className:`task-children${P?" task-children--deep":""}`,"data-testid":`task-children-${t.line}`,children:[b?null:t.children.map(d=>e.jsx(q,{depth:l+1,handlers:n,task:d},d.line)),u?e.jsx("li",{className:"task-node",children:e.jsxs("div",{className:"task-row task-row--child-input",children:[e.jsx("span",{"aria-hidden":!0,className:"task-row__indicator task-status-open",children:e.jsx(G,{size:12})}),e.jsx(F,{initial:"",placeholder:a("tasks.placeholder.newSubtask"),onSubmit:d=>{h(!1),R?.(t.line,d)},onCancel:()=>h(!1)})]})}):null]}):null]})},ee=({onSubmit:t,disabled:n=!1,variant:l="ghost"})=>{const{t:a}=O(),[c,o]=k.useState(!1),[i,r]=k.useState(""),s=()=>{const h=i.trim();if(!h){o(!1);return}t(h),r("")},u=h=>{h.key==="Enter"?(h.preventDefault(),s()):h.key==="Escape"&&(h.preventDefault(),r(""),o(!1))};return c?e.jsxs("div",{className:"task-add-input",children:[e.jsx("span",{"aria-hidden":!0,className:"task-add-input__icon",children:e.jsx(Y,{size:12})}),e.jsx("input",{type:"text",autoFocus:!0,value:i,placeholder:a("tasks.placeholder.newTask"),onChange:h=>r(h.target.value),onKeyDown:u,onBlur:s,"data-testid":"task-add-input",className:"task-add-input__field"})]}):e.jsxs("button",{type:"button",onClick:()=>o(!0),disabled:n,"data-testid":"task-add-toggle",className:`task-add-toggle${l==="primary"?" task-add-toggle--primary":""}`,children:[e.jsx("span",{"aria-hidden":!0,className:"task-add-toggle__icon",children:e.jsx(Y,{size:12})}),e.jsx("span",{children:a("tasks.button.addTask")})]})},He=t=>{let n=0,l=0;const a=[],c=[],o=r=>{n+=1,r.checked&&(l+=1);for(const s of r.children)o(s)};for(const r of t)r.checked?c.push(r):a.push(r),o(r);const i=n===0?0:Math.round(l/n*100);return{completedTasks:l,completionPercent:i,doneRoots:c,openRoots:a,totalTasks:n}},Ve=({content:t,hasConflict:n,onClose:l,onContentChange:a,onKeepLocal:c,onReload:o,onSave:i,onToggleTaskLine:r,onAppendTask:s,onAppendSubtask:u,onUpdateTaskText:h,onDeleteTask:b,open:M,workspacePath:_,knownWorkerNames:C,onSelectOwner:g,connectionStale:f=!1})=>{const{t:x}=O(),[y,R]=k.useState(!1),v={onToggle:r,onCopyLine:p=>{const d=t.split(/\r?\n/)[p];typeof d=="string"&&navigator.clipboard?.writeText(d).catch(m=>{console.error("[hive] swallowed:tasks.copyLine",m)})},...h&&!f?{onUpdateText:h}:{},...b&&!f?{onDelete:b}:{},...u&&!f?{onAppendSubtask:u}:{},...g?{onSelectOwner:g}:{},...f?{writeDisabled:!0}:{}},j=k.useMemo(()=>re(t,C?{knownWorkerNames:C}:{}),[t,C]),{completedTasks:A,completionPercent:$,doneRoots:N,openRoots:L,totalTasks:E}=k.useMemo(()=>He(j),[j]),[w,T]=k.useState(N.length<=3),P=_?`${_}/.hive/tasks.md`:".hive/tasks.md",H=p=>{if(p.key!=="Escape")return;const d=p.target?.tagName;d==="INPUT"||d==="TEXTAREA"||(p.preventDefault(),l())},V=`dialog-scale-pop elev-2 task-dialog__content pointer-events-auto flex flex-col rounded-lg border${f?" task-dialog--stale":""}`;return e.jsx(ce,{open:M,onOpenChange:p=>!p&&l(),children:e.jsxs(de,{children:[e.jsx(ue,{"data-testid":"task-graph-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(pe,{"aria-label":x("tasks.aria.drawer"),"data-testid":"task-graph-drawer","data-connection-stale":f||void 0,onEscapeKeyDown:p=>p.preventDefault(),onKeyDown:H,className:V,style:{background:"var(--bg-1)",borderColor:"var(--border-bright)",height:"min(780px, calc(100vh - 48px))",width:"min(1040px, calc(100vw - 48px))"},children:[e.jsxs("header",{className:"task-drawer__header",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[e.jsx(he,{className:"font-semibold text-pri leading-tight",children:x("tasks.title.todo")}),e.jsx(xe,{className:"mono truncate text-xs text-ter",title:P,children:P})]}),E>0?e.jsxs("span",{className:"text-xs text-ter tabular-nums","data-testid":"task-graph-summary",children:[e.jsxs("span",{"data-testid":"task-progress-text",children:[A," / ",E]})," ","· ",$,"%"]}):null,e.jsx(S,{label:x(y?"tasks.action.backToList":"tasks.action.viewSource"),children:e.jsx("button",{type:"button",onClick:()=>R(p=>!p),"data-testid":"task-raw-toggle",className:"icon-btn","aria-label":x(y?"tasks.action.backToList":"tasks.action.viewSource"),children:e.jsx($e,{size:14})})}),e.jsx(S,{label:x("tasks.action.closeTodo"),children:e.jsx("button",{type:"button",onClick:l,"aria-label":x("tasks.action.closeTodo"),className:"icon-btn",children:e.jsx(ke,{size:14})})})]}),!y&&E>0?e.jsx("div",{"aria-label":x("tasks.aria.progress"),"aria-valuemax":100,"aria-valuemin":0,"aria-valuenow":$,className:"task-progress-thin task-drawer__progress","data-testid":"task-progress-bar",role:"progressbar",children:e.jsx("span",{style:{width:`${$}%`}})}):null,e.jsx("div",{className:"flex-1 scroll-y px-3 py-3 text-sm",children:y?e.jsx(De,{content:t,hasConflict:n,onContentChange:a,onKeepLocal:c,onReload:o,onSave:i}):j.length===0?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(me,{icon:e.jsx(ae,{size:20}),title:x("tasks.empty.title"),description:x("tasks.empty.description"),...s?{action:e.jsx(ee,{variant:"primary",disabled:f,onSubmit:s})}:{}})}):e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("ul",{className:"task-list","data-testid":"task-graph-list",children:[L.map(p=>e.jsx(q,{depth:0,handlers:v,task:p},p.line)),s?e.jsx("li",{children:e.jsx(ee,{disabled:f,onSubmit:s})}):null]}),N.length>0?e.jsxs("div",{className:"mt-1",children:[e.jsxs("button",{type:"button",onClick:()=>T(p=>!p),"aria-expanded":w,"data-testid":"task-completed-toggle",className:"task-completed-toggle",children:[w?e.jsx(te,{size:12,"aria-hidden":!0}):e.jsx(se,{size:12,"aria-hidden":!0}),e.jsx("span",{children:x("tasks.completed.toggle",{count:N.length})})]}),w?e.jsx("ul",{className:"task-list","data-testid":"task-completed-list",children:N.map(p=>e.jsx(q,{depth:0,handlers:v,task:p},p.line))}):null]}):null]})})]})})]})})},qe=({tasksFile:t,workspacePath:n,open:l,onClose:a,workers:c,onSelectOwner:o,connectionStale:i})=>{const r=k.useMemo(()=>c?.length?c.map(s=>s.name):void 0,[c]);return e.jsx(Ve,{content:t.content,hasConflict:t.hasConflict,onClose:a,onContentChange:t.onChange,onKeepLocal:t.onKeepLocal,onReload:t.onReload,onSave:t.onSave,onToggleTaskLine:s=>{t.toggleTaskAtLine(s).catch(D("tasks.toggleTaskAtLine"))},onAppendTask:s=>{t.appendTask(s).catch(D("tasks.appendTask"))},onAppendSubtask:(s,u)=>{t.appendSubtask(s,u).catch(D("tasks.appendSubtask"))},onUpdateTaskText:(s,u)=>{t.updateTaskText(s,u).catch(D("tasks.updateTaskText"))},onDeleteTask:s=>{t.deleteTask(s).catch(D("tasks.deleteTask"))},open:l,workspacePath:n,...r?{knownWorkerNames:r}:{},...o?{onSelectOwner:o}:{},...i!==void 0?{connectionStale:i}:{}})};export{qe as WorkspaceTaskDrawer};
@@ -1 +0,0 @@
1
- import{c as o}from"./index-CWW5vUjQ.js";const t=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],e=o("chevron-right",t);export{e as C};