@runfusion/fusion 0.77.0-beta.4 → 0.77.0-beta.5

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 (161) hide show
  1. package/dist/bin.js +4051 -4144
  2. package/dist/child-process-worker.js +2681 -1719
  3. package/dist/client/.vite/manifest.json +261 -261
  4. package/dist/client/assets/{AgentDetailView-CH6GtXl9.js → AgentDetailView-CSK_Rnlk.js} +1 -1
  5. package/dist/client/assets/{AgentPermissionPolicyEditor-YTEpMhUx.js → AgentPermissionPolicyEditor-kG44Adcm.js} +1 -1
  6. package/dist/client/assets/{AgentsView-XOHHDo4a.js → AgentsView-ClKwKWnU.js} +3 -3
  7. package/dist/client/assets/ChatView-DoOqgkPX.js +13 -0
  8. package/dist/client/assets/{CommandCenter-BsH-R15f.js → CommandCenter-CJxvPbgn.js} +1 -1
  9. package/dist/client/assets/{DevServerView-CKOa-lkc.js → DevServerView-C4nyLONX.js} +1 -1
  10. package/dist/client/assets/{DirectoryPicker-DHUYTE-j.js → DirectoryPicker-BIvXWIB5.js} +1 -1
  11. package/dist/client/assets/{DocumentsView-BPzrxeP-.js → DocumentsView-DH_aZysM.js} +1 -1
  12. package/dist/client/assets/{EvalsView-DojCiv47.js → EvalsView-klRK-GJQ.js} +1 -1
  13. package/dist/client/assets/{ExperimentalAgentOnboardingModal-DuurZ8qe.js → ExperimentalAgentOnboardingModal-CgBmukIm.js} +1 -1
  14. package/dist/client/assets/{GoalsView-DDWPXcG1.js → GoalsView-ysh3X2x6.js} +1 -1
  15. package/dist/client/assets/{InsightsView-CgkMOD1A.js → InsightsView-BbMjCu7J.js} +1 -1
  16. package/dist/client/assets/{MemoryView-Cj49_z7O.js → MemoryView-B3IgA8Bx.js} +1 -1
  17. package/dist/client/assets/{PiExtensionsManager-B_rRJiOd.js → PiExtensionsManager-CZlIw7C3.js} +1 -1
  18. package/dist/client/assets/{PluginManager-Dxwi88oY.js → PluginManager-vy0YZ2Nx.js} +1 -1
  19. package/dist/client/assets/{PullRequestView-z-5v2hQT.js → PullRequestView-DhhsJV8I.js} +1 -1
  20. package/dist/client/assets/{ReportModal-DmOPEYWp.js → ReportModal-CQMn4i1y.js} +1 -1
  21. package/dist/client/assets/{ResearchView-D90Jbzbx.js → ResearchView-CVwfs4l3.js} +1 -1
  22. package/dist/client/assets/{SecretsView-CSyjZl5L.js → SecretsView-CrJfHle9.js} +1 -1
  23. package/dist/client/assets/{SessionTerminal-Bwb8nGmU.js → SessionTerminal-BRI8W1-G.js} +1 -1
  24. package/dist/client/assets/{SettingsModal-CJof1Ett.js → SettingsModal-B6U5Umru.js} +1 -1
  25. package/dist/client/assets/SettingsModal-h1A_aFqD.js +21 -0
  26. package/dist/client/assets/{SettingsTextareaRow-BYchnHfW.js → SettingsTextareaRow-O7-u9uMC.js} +1 -1
  27. package/dist/client/assets/{SetupWizardModal-NqV-erVf.js → SetupWizardModal-nXfJp8cA.js} +2 -2
  28. package/dist/client/assets/{SkillsView-BUrkIJ-p.js → SkillsView-CoWAjvWU.js} +1 -1
  29. package/dist/client/assets/{WorkflowNodeEditor-DcPk2A1Z.js → WorkflowNodeEditor-BFMM3RF_.js} +2 -2
  30. package/dist/client/assets/{agent-import-generation-X16OLfrL.js → agent-import-generation-BqDmtTur.js} +1 -1
  31. package/dist/client/assets/{agentsOrgChartLayout-BhPIXckU.js → agentsOrgChartLayout-C4cLqlV6.js} +1 -1
  32. package/dist/client/assets/app-BBSLJDbV.js +13 -0
  33. package/dist/client/assets/app-BKwOvuxE.js +5 -0
  34. package/dist/client/assets/app-Bvr57EZQ.js +5 -0
  35. package/dist/client/assets/app-C_PTWuI1.js +13 -0
  36. package/dist/client/assets/app-DKx18PHE.js +13 -0
  37. package/dist/client/assets/app-DRW5hIgr.js +13 -0
  38. package/dist/client/assets/app-DwvelD-n.js +13 -0
  39. package/dist/client/assets/{architectureDiagram-3BPJPVTR-WArMtdqy.js → architectureDiagram-3BPJPVTR-CdxcwdRe.js} +1 -1
  40. package/dist/client/assets/{blockDiagram-GPEHLZMM-emScogdV.js → blockDiagram-GPEHLZMM-CfQrRfHR.js} +1 -1
  41. package/dist/client/assets/{c4Diagram-AAUBKEIU-CBY7-E0T.js → c4Diagram-AAUBKEIU-Cx7-2SOm.js} +1 -1
  42. package/dist/client/assets/channel-B4WN1jC_.js +1 -0
  43. package/dist/client/assets/{chunk-2J33WTMH-Bcai1sOm.js → chunk-2J33WTMH-D8jvgP3M.js} +1 -1
  44. package/dist/client/assets/{chunk-4BX2VUAB-hjiKRusj.js → chunk-4BX2VUAB-B5tBx_s_.js} +1 -1
  45. package/dist/client/assets/{chunk-55IACEB6-DpO9nIb0.js → chunk-55IACEB6-C-F-HQ5Z.js} +1 -1
  46. package/dist/client/assets/{chunk-727SXJPM-B9JanA0o.js → chunk-727SXJPM-BP8Ln-8C.js} +1 -1
  47. package/dist/client/assets/{chunk-AQP2D5EJ-D6zdnEUE.js → chunk-AQP2D5EJ-DMnTmRmn.js} +1 -1
  48. package/dist/client/assets/{chunk-FMBD7UC4-CRkrJ51d.js → chunk-FMBD7UC4-D_YdfnNc.js} +1 -1
  49. package/dist/client/assets/{chunk-ND2GUHAM-BLQsKt7a.js → chunk-ND2GUHAM-CULXyuXq.js} +1 -1
  50. package/dist/client/assets/{chunk-QZHKN3VN-MCOlJ723.js → chunk-QZHKN3VN-CT1BWEJL.js} +1 -1
  51. package/dist/client/assets/classDiagram-4FO5ZUOK-CKE8RSOv.js +1 -0
  52. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-CKE8RSOv.js +1 -0
  53. package/dist/client/assets/{cose-bilkent-S5V4N54A-Cv1XmKKG.js → cose-bilkent-S5V4N54A-M-3DXa6e.js} +1 -1
  54. package/dist/client/assets/{dagre-BM42HDAG-flnNS_RW.js → dagre-BM42HDAG-Bsiqvroz.js} +1 -1
  55. package/dist/client/assets/{dashboard-view-CrV-rL9Q.js → dashboard-view-BEBh_Ei5.js} +1 -1
  56. package/dist/client/assets/{dashboard-view-Dz7kqcJc.js → dashboard-view-Bo_gFjdO.js} +1 -1
  57. package/dist/client/assets/{dashboard-view-CC1aH-lp.js → dashboard-view-CnFFG3cW.js} +1 -1
  58. package/dist/client/assets/{dashboard-view-DEAYb_TZ.js → dashboard-view-DAHn20ph.js} +1 -1
  59. package/dist/client/assets/{diagram-2AECGRRQ-Z3S7b_6_.js → diagram-2AECGRRQ-CZiHoXo5.js} +1 -1
  60. package/dist/client/assets/{diagram-5GNKFQAL-BAZHdMFq.js → diagram-5GNKFQAL-BoJVz4Or.js} +1 -1
  61. package/dist/client/assets/{diagram-KO2AKTUF-C2y3S8F0.js → diagram-KO2AKTUF-DivGQuAL.js} +1 -1
  62. package/dist/client/assets/{diagram-LMA3HP47-Bfz0_IvT.js → diagram-LMA3HP47-DkMK7OJp.js} +1 -1
  63. package/dist/client/assets/{diagram-OG6HWLK6-BBmSQsTI.js → diagram-OG6HWLK6-DFFvRcpW.js} +1 -1
  64. package/dist/client/assets/{erDiagram-TEJ5UH35-DnpdQi66.js → erDiagram-TEJ5UH35--217vrom.js} +1 -1
  65. package/dist/client/assets/{flowDiagram-I6XJVG4X-IybTR_zf.js → flowDiagram-I6XJVG4X-CQgWO3xf.js} +1 -1
  66. package/dist/client/assets/{folder-open-Dntm63x4.js → folder-open-DR6cRcNR.js} +1 -1
  67. package/dist/client/assets/{ganttDiagram-6RSMTGT7-DEQOe2E9.js → ganttDiagram-6RSMTGT7-BjDMUrS3.js} +1 -1
  68. package/dist/client/assets/{gitGraphDiagram-PVQCEYII-BOKc-h63.js → gitGraphDiagram-PVQCEYII-gKUcDnln.js} +1 -1
  69. package/dist/client/assets/index-Dki2LBAp.css +1 -0
  70. package/dist/client/assets/index-oxnX59eO.js +2774 -0
  71. package/dist/client/assets/{infoDiagram-5YYISTIA-LqaYIdbj.js → infoDiagram-5YYISTIA-BA91T8S5.js} +1 -1
  72. package/dist/client/assets/{ishikawaDiagram-YF4QCWOH-a8qd512s.js → ishikawaDiagram-YF4QCWOH-0BY5xe-c.js} +1 -1
  73. package/dist/client/assets/{journeyDiagram-JHISSGLW-BgoNyeiy.js → journeyDiagram-JHISSGLW-B_OwenbQ.js} +1 -1
  74. package/dist/client/assets/{kanban-definition-UN3LZRKU-Bqwow7D3.js → kanban-definition-UN3LZRKU-GLabUTKp.js} +1 -1
  75. package/dist/client/assets/{mermaid.core-B2zD934i.js → mermaid.core-BXo4rxYI.js} +4 -4
  76. package/dist/client/assets/{mindmap-definition-RKZ34NQL-CCTOigWu.js → mindmap-definition-RKZ34NQL-DZl6LPoE.js} +1 -1
  77. package/dist/client/assets/{pieDiagram-4H26LBE5-Bq5DtXKR.js → pieDiagram-4H26LBE5-DtHq-4py.js} +1 -1
  78. package/dist/client/assets/{puzzle-VhTPiCit.js → puzzle-OVm-I1L4.js} +1 -1
  79. package/dist/client/assets/{quadrantDiagram-W4KKPZXB-CGMP3nUx.js → quadrantDiagram-W4KKPZXB-BdjXhd5d.js} +1 -1
  80. package/dist/client/assets/{requirementDiagram-4Y6WPE33-Ckeu_szu.js → requirementDiagram-4Y6WPE33-BoFVjELN.js} +1 -1
  81. package/dist/client/assets/{sankeyDiagram-5OEKKPKP-SWbBDD4d.js → sankeyDiagram-5OEKKPKP-B0qyJh-P.js} +1 -1
  82. package/dist/client/assets/{sequenceDiagram-3UESZ5HK-CiJrmL_G.js → sequenceDiagram-3UESZ5HK-ByY62Eqp.js} +1 -1
  83. package/dist/client/assets/{shield-alert-BBDlP6A5.js → shield-alert-CDy69fl7.js} +1 -1
  84. package/dist/client/assets/{standing-instructions-template-viu_kgDX.js → standing-instructions-template-BsnnRlwm.js} +1 -1
  85. package/dist/client/assets/{stateDiagram-AJRCARHV-DTCzK5Gt.js → stateDiagram-AJRCARHV-CwJ-_Phi.js} +1 -1
  86. package/dist/client/assets/{stateDiagram-v2-BHNVJYJU-BIGAwFTT.js → stateDiagram-v2-BHNVJYJU-Cfvhq8mV.js} +1 -1
  87. package/dist/client/assets/{timeline-definition-PNZ67QCA-BQZEFEug.js → timeline-definition-PNZ67QCA-Co8VfGN9.js} +1 -1
  88. package/dist/client/assets/{upload-D5w3Ehwp.js → upload-CkqDbEeE.js} +1 -1
  89. package/dist/client/assets/{useDiscoveredSkillsCache-D6zMSIaS.js → useDiscoveredSkillsCache-BHUasRiZ.js} +1 -1
  90. package/dist/client/assets/{users-Bohihi_o.js → users-B8DkpbXD.js} +1 -1
  91. package/dist/client/assets/{vennDiagram-CIIHVFJN-DnHguEv8.js → vennDiagram-CIIHVFJN-XSJteQrL.js} +1 -1
  92. package/dist/client/assets/{wardley-L42UT6IY-BOqYltGN.js → wardley-L42UT6IY-Btc0FRfF.js} +1 -1
  93. package/dist/client/assets/{wardleyDiagram-YWT4CUSO-Re0Ery2M.js → wardleyDiagram-YWT4CUSO--IcDNmrf.js} +1 -1
  94. package/dist/client/assets/{xychartDiagram-2RQKCTM6-CnVq21b2.js → xychartDiagram-2RQKCTM6-CZW93G6X.js} +1 -1
  95. package/dist/client/index.html +2 -2
  96. package/dist/client/version.json +1 -1
  97. package/dist/droid-cli/package.json +1 -1
  98. package/dist/extension.js +3085 -2130
  99. package/dist/migrations/0000_initial.sql +3 -0
  100. package/dist/migrations/0061_fn_066_activity_log_task_id_index.sql +7 -0
  101. package/dist/migrations/0062_remove_task_subtask_splitting.sql +2 -0
  102. package/dist/migrations/0063_fn_090_ai_merge_review_reconciliation.sql +2 -0
  103. package/dist/migrations/0064_fn_094_task_repository_scope.sql +2 -0
  104. package/dist/pi-claude-cli/package.json +1 -1
  105. package/dist/plugin-sdk/index.d.ts +276 -186
  106. package/dist/plugin-sdk/index.js +35 -104
  107. package/dist/plugins/fusion-plugin-acp-runtime/bundled.js +35 -104
  108. package/dist/plugins/fusion-plugin-acp-runtime/package.json +1 -1
  109. package/dist/plugins/fusion-plugin-claude-runtime/bundled.js +35 -104
  110. package/dist/plugins/fusion-plugin-claude-runtime/package.json +1 -1
  111. package/dist/plugins/fusion-plugin-cli-printing-press/bundled.js +35 -104
  112. package/dist/plugins/fusion-plugin-cli-printing-press/package.json +1 -1
  113. package/dist/plugins/fusion-plugin-compound-engineering/bundled.js +35 -104
  114. package/dist/plugins/fusion-plugin-compound-engineering/package.json +1 -1
  115. package/dist/plugins/fusion-plugin-cursor-runtime/bundled.js +35 -104
  116. package/dist/plugins/fusion-plugin-cursor-runtime/package.json +1 -1
  117. package/dist/plugins/fusion-plugin-dependency-graph/bundled.js +35 -104
  118. package/dist/plugins/fusion-plugin-dependency-graph/package.json +1 -1
  119. package/dist/plugins/fusion-plugin-droid-runtime/bundled.js +35 -104
  120. package/dist/plugins/fusion-plugin-droid-runtime/package.json +1 -1
  121. package/dist/plugins/fusion-plugin-grok-runtime/bundled.js +35 -104
  122. package/dist/plugins/fusion-plugin-grok-runtime/package.json +1 -1
  123. package/dist/plugins/fusion-plugin-hermes-runtime/bundled.js +35 -104
  124. package/dist/plugins/fusion-plugin-hermes-runtime/package.json +1 -1
  125. package/dist/plugins/fusion-plugin-linear-import/bundled.js +35 -104
  126. package/dist/plugins/fusion-plugin-linear-import/package.json +1 -1
  127. package/dist/plugins/fusion-plugin-omp-runtime/bundled.js +35 -104
  128. package/dist/plugins/fusion-plugin-omp-runtime/package.json +1 -1
  129. package/dist/plugins/fusion-plugin-openclaw-runtime/bundled.js +35 -104
  130. package/dist/plugins/fusion-plugin-openclaw-runtime/package.json +1 -1
  131. package/dist/plugins/fusion-plugin-paperclip-runtime/bundled.js +35 -104
  132. package/dist/plugins/fusion-plugin-paperclip-runtime/package.json +1 -1
  133. package/dist/plugins/fusion-plugin-quality/bundled.js +35 -104
  134. package/dist/plugins/fusion-plugin-quality/package.json +1 -1
  135. package/dist/plugins/fusion-plugin-reports/bundled.js +35 -104
  136. package/dist/plugins/fusion-plugin-reports/package.json +1 -1
  137. package/dist/plugins/fusion-plugin-roadmap/bundled.js +35 -104
  138. package/dist/plugins/fusion-plugin-roadmap/package.json +1 -1
  139. package/dist/plugins/fusion-plugin-todos/bundled.js +35 -104
  140. package/dist/plugins/fusion-plugin-todos/package.json +1 -1
  141. package/dist/plugins/fusion-plugin-whatsapp-chat/bundled.js +35 -104
  142. package/dist/plugins/fusion-plugin-whatsapp-chat/package.json +1 -1
  143. package/package.json +1 -1
  144. package/skill/fusion/references/extension-tools.md +2 -1
  145. package/skill/fusion/references/fusion-capabilities.md +1 -1
  146. package/skill/fusion/references/task-structure.md +1 -1
  147. package/skill/fusion/workflows/specifications.md +2 -2
  148. package/dist/client/assets/ChatView-gH7QX3TI.js +0 -13
  149. package/dist/client/assets/SettingsModal-BAzmMjr9.js +0 -21
  150. package/dist/client/assets/app-B-TfWH9b.js +0 -5
  151. package/dist/client/assets/app-B2RDV_-t.js +0 -13
  152. package/dist/client/assets/app-CDo0mF2S.js +0 -5
  153. package/dist/client/assets/app-Cc18kAQS.js +0 -13
  154. package/dist/client/assets/app-DFF79EUn.js +0 -13
  155. package/dist/client/assets/app-DSeFHxgj.js +0 -13
  156. package/dist/client/assets/app-Ducr0y6r.js +0 -13
  157. package/dist/client/assets/channel-CP2ySYs0.js +0 -1
  158. package/dist/client/assets/classDiagram-4FO5ZUOK-DKkOBtzM.js +0 -1
  159. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-DKkOBtzM.js +0 -1
  160. package/dist/client/assets/index-DXpztECA.css +0 -1
  161. package/dist/client/assets/index-I32FijPT.js +0 -2821
@@ -1 +1 @@
1
- import{r as n,j as r}from"./vendor-react-SZ_qB27O.js";import{ab as z,ac as D,ad as S,ae as w,k as j,af as T,E as B,y as A,P as L,L as K,l as N}from"./index-I32FijPT.js";import{u as R}from"./vendor-i18n-Duky4gdQ.js";import{F as U}from"./folder-open-Dntm63x4.js";function M({value:b,onChange:h,placeholder:F,onInputKeyDown:g,nodeId:k,localNodeId:m,selectCreatedDirectory:x=!1}){const{t:i}=R("app"),[e,s]=n.useState({isOpen:!1,loading:!1,error:null,currentPath:"",parentPath:null,entries:[],showHidden:!1,createFolderOpen:!1,createFolderError:null}),[p,u]=n.useState(""),d=n.useCallback(async(t,c=!1)=>{s(o=>({...o,loading:!0,error:null}));try{const o=await z(t,c,k,m);s(a=>({...a,loading:!1,currentPath:o.currentPath,parentPath:o.parentPath,entries:o.entries}))}catch(o){s(a=>({...a,loading:!1,error:o instanceof Error?o.message:"Failed to browse directory"}))}},[k,m]),C=n.useCallback(()=>{s(t=>t.isOpen?{...t,isOpen:!1}:{...t,isOpen:!0})},[]);n.useEffect(()=>{e.isOpen&&!e.loading&&!e.currentPath&&!e.error&&d(b||void 0,e.showHidden)},[e.isOpen,e.loading,e.currentPath,e.error,b,e.showHidden,d,k,m]);const y=n.useCallback(t=>{d(t,e.showHidden)},[d,e.showHidden]),H=n.useCallback(()=>{h(e.currentPath),s(t=>({...t,isOpen:!1}))},[e.currentPath,h]),E=n.useCallback(()=>{s(t=>{const c=!t.showHidden;return{...t,showHidden:c}})},[]);n.useEffect(()=>{e.isOpen&&e.currentPath&&d(e.currentPath,e.showHidden)},[e.showHidden,d]);const f=n.useCallback(()=>{s(t=>({...t,createFolderOpen:!t.createFolderOpen,createFolderError:null})),u("")},[]),P=n.useCallback(async()=>{if(!p.trim()||!e.currentPath)return;const t=p.trim();if(t.includes("/")||t.includes("\\")||t.includes("..")){s(a=>({...a,createFolderError:i("dirPicker.createFolderError","Folder name cannot contain path separators or '..'")}));return}const c=e.currentPath.includes("\\")?"\\":"/",o=e.currentPath.endsWith(c)?e.currentPath+t:e.currentPath+c+t;s(a=>({...a,loading:!0,createFolderError:null}));try{const a=await D(o);u(""),s(l=>({...l,createFolderOpen:!1})),x?(h(a.path),await d(a.path,e.showHidden),s(l=>l.error?{...l,isOpen:!1,error:null}:l)):await d(e.currentPath,e.showHidden)}catch(a){s(l=>({...l,loading:!1,createFolderError:a instanceof Error?a.message:"Failed to create folder"}))}},[p,e.currentPath,e.showHidden,d,h,x]),O=n.useCallback(t=>{t.key==="Enter"?(t.preventDefault(),P()):t.key==="Escape"&&(s(c=>({...c,createFolderOpen:!1,createFolderError:null})),u(""))},[P]),v=e.currentPath?S(e.currentPath):[];return r.jsxs("div",{className:"directory-picker",children:[r.jsxs("div",{className:"directory-picker-input-row",children:[r.jsx("input",{type:"text",className:"input directory-picker-input",value:b,onChange:t=>h(t.target.value),onKeyDown:g,placeholder:F||i("dirPicker.defaultPlaceholder","/path/to/your/project")}),r.jsxs("button",{type:"button",className:"btn btn-secondary btn-sm directory-picker-browse-btn",onClick:C,"aria-label":e.isOpen?i("dirPicker.closeBrowser","Close directory browser"):i("dirPicker.openBrowser","Browse directories"),children:[e.isOpen?r.jsx(U,{size:16}):r.jsx(w,{size:16}),r.jsx("span",{children:i("dirPicker.browse","Browse")})]})]}),e.isOpen&&r.jsxs("div",{className:"directory-picker-browser",role:"tree","aria-label":i("dirPicker.ariaLabel","Directory browser"),children:[r.jsx("div",{className:"directory-picker-breadcrumbs",children:v.map((t,c)=>r.jsxs("span",{className:"directory-picker-breadcrumb-item",children:[c>0&&r.jsx(j,{size:12,className:"directory-picker-breadcrumb-sep"}),r.jsx("button",{type:"button",className:"directory-picker-breadcrumb",onClick:()=>y(t.path),title:t.path,children:t.label})]},t.path))}),r.jsxs("div",{className:"directory-picker-toolbar",children:[e.parentPath&&r.jsxs("button",{type:"button",className:"btn btn-sm btn-secondary directory-picker-up-btn",onClick:()=>y(e.parentPath),"aria-label":i("dirPicker.parentDir","Go to parent directory"),title:i("dirPicker.parentDirTitle","Parent directory"),children:[r.jsx(T,{size:14}),r.jsx("span",{children:i("dirPicker.up","Up")})]}),r.jsxs("button",{type:"button",className:"btn btn-sm btn-secondary directory-picker-hidden-toggle",onClick:E,"aria-label":e.showHidden?i("dirPicker.hideHiddenAria","Hide hidden directories"):i("dirPicker.showHiddenAria","Show hidden directories"),title:e.showHidden?i("dirPicker.hideHiddenTitle","Hide hidden"):i("dirPicker.showHiddenTitle","Show hidden"),children:[e.showHidden?r.jsx(B,{size:14}):r.jsx(A,{size:14}),r.jsx("span",{children:e.showHidden?i("dirPicker.hideHidden","Hide hidden"):i("dirPicker.showHidden","Show hidden")})]}),r.jsxs("button",{type:"button",className:"btn btn-sm btn-secondary directory-picker-create-folder-toggle",onClick:f,"aria-label":i("dirPicker.createFolderAria","Create new folder"),title:i("dirPicker.createFolderTitle","Create folder"),children:[r.jsx(L,{size:14}),r.jsx("span",{children:i("dirPicker.createFolder","New folder")})]})]}),e.loading?r.jsxs("div",{className:"directory-picker-loading",children:[r.jsx(K,{size:20,className:"animate-spin"}),r.jsx("span",{children:i("dirPicker.loading","Loading…")})]}):e.error?r.jsxs("div",{className:"directory-picker-error",children:[r.jsx(N,{size:16}),r.jsx("span",{children:e.error})]}):r.jsx("div",{className:"directory-picker-entries",children:e.entries.length===0?r.jsx("div",{className:"directory-picker-empty",children:i("dirPicker.noSubdirs","No subdirectories")}):e.entries.map(t=>r.jsxs("button",{type:"button",className:"directory-picker-entry",onClick:()=>y(t.path),role:"treeitem",title:t.path,children:[r.jsx(w,{size:16,className:"directory-picker-entry-icon"}),r.jsx("span",{className:"directory-picker-entry-name",children:t.name}),t.hasChildren&&r.jsx(j,{size:14,className:"directory-picker-entry-arrow"})]},t.path))}),e.createFolderOpen&&r.jsxs("div",{className:"directory-picker-create-folder",children:[r.jsx("input",{type:"text",className:"input directory-picker-create-folder-input",value:p,onChange:t=>u(t.target.value),onKeyDown:O,placeholder:i("dirPicker.newFolderPlaceholder","Folder name"),autoFocus:!0}),r.jsxs("div",{className:"directory-picker-create-folder-actions",children:[r.jsx("button",{type:"button",className:"btn btn-sm btn-primary",onClick:P,disabled:!p.trim()||e.loading||!e.currentPath,children:i("dirPicker.createFolderConfirm","Create")}),r.jsx("button",{type:"button",className:"btn btn-sm btn-secondary",onClick:f,children:i("dirPicker.cancel","Cancel")})]}),e.createFolderError&&r.jsxs("div",{className:"directory-picker-create-folder-error",children:[r.jsx(N,{size:14}),r.jsx("span",{children:e.createFolderError})]})]}),r.jsxs("div",{className:"directory-picker-actions",children:[r.jsx("span",{className:"directory-picker-selected-path",title:e.currentPath,children:e.currentPath}),r.jsx("button",{type:"button",className:"btn btn-primary directory-picker-select-btn",onClick:H,children:i("dirPicker.select","Select")})]})]})]})}export{M as D};
1
+ import{r as n,j as r}from"./vendor-react-SZ_qB27O.js";import{ab as z,ac as D,ad as S,ae as w,k as j,af as T,E as B,y as A,P as L,L as K,l as N}from"./index-oxnX59eO.js";import{u as R}from"./vendor-i18n-Duky4gdQ.js";import{F as U}from"./folder-open-DR6cRcNR.js";function M({value:b,onChange:h,placeholder:F,onInputKeyDown:g,nodeId:k,localNodeId:m,selectCreatedDirectory:x=!1}){const{t:i}=R("app"),[e,s]=n.useState({isOpen:!1,loading:!1,error:null,currentPath:"",parentPath:null,entries:[],showHidden:!1,createFolderOpen:!1,createFolderError:null}),[p,u]=n.useState(""),d=n.useCallback(async(t,c=!1)=>{s(o=>({...o,loading:!0,error:null}));try{const o=await z(t,c,k,m);s(a=>({...a,loading:!1,currentPath:o.currentPath,parentPath:o.parentPath,entries:o.entries}))}catch(o){s(a=>({...a,loading:!1,error:o instanceof Error?o.message:"Failed to browse directory"}))}},[k,m]),C=n.useCallback(()=>{s(t=>t.isOpen?{...t,isOpen:!1}:{...t,isOpen:!0})},[]);n.useEffect(()=>{e.isOpen&&!e.loading&&!e.currentPath&&!e.error&&d(b||void 0,e.showHidden)},[e.isOpen,e.loading,e.currentPath,e.error,b,e.showHidden,d,k,m]);const y=n.useCallback(t=>{d(t,e.showHidden)},[d,e.showHidden]),H=n.useCallback(()=>{h(e.currentPath),s(t=>({...t,isOpen:!1}))},[e.currentPath,h]),E=n.useCallback(()=>{s(t=>{const c=!t.showHidden;return{...t,showHidden:c}})},[]);n.useEffect(()=>{e.isOpen&&e.currentPath&&d(e.currentPath,e.showHidden)},[e.showHidden,d]);const f=n.useCallback(()=>{s(t=>({...t,createFolderOpen:!t.createFolderOpen,createFolderError:null})),u("")},[]),P=n.useCallback(async()=>{if(!p.trim()||!e.currentPath)return;const t=p.trim();if(t.includes("/")||t.includes("\\")||t.includes("..")){s(a=>({...a,createFolderError:i("dirPicker.createFolderError","Folder name cannot contain path separators or '..'")}));return}const c=e.currentPath.includes("\\")?"\\":"/",o=e.currentPath.endsWith(c)?e.currentPath+t:e.currentPath+c+t;s(a=>({...a,loading:!0,createFolderError:null}));try{const a=await D(o);u(""),s(l=>({...l,createFolderOpen:!1})),x?(h(a.path),await d(a.path,e.showHidden),s(l=>l.error?{...l,isOpen:!1,error:null}:l)):await d(e.currentPath,e.showHidden)}catch(a){s(l=>({...l,loading:!1,createFolderError:a instanceof Error?a.message:"Failed to create folder"}))}},[p,e.currentPath,e.showHidden,d,h,x]),O=n.useCallback(t=>{t.key==="Enter"?(t.preventDefault(),P()):t.key==="Escape"&&(s(c=>({...c,createFolderOpen:!1,createFolderError:null})),u(""))},[P]),v=e.currentPath?S(e.currentPath):[];return r.jsxs("div",{className:"directory-picker",children:[r.jsxs("div",{className:"directory-picker-input-row",children:[r.jsx("input",{type:"text",className:"input directory-picker-input",value:b,onChange:t=>h(t.target.value),onKeyDown:g,placeholder:F||i("dirPicker.defaultPlaceholder","/path/to/your/project")}),r.jsxs("button",{type:"button",className:"btn btn-secondary btn-sm directory-picker-browse-btn",onClick:C,"aria-label":e.isOpen?i("dirPicker.closeBrowser","Close directory browser"):i("dirPicker.openBrowser","Browse directories"),children:[e.isOpen?r.jsx(U,{size:16}):r.jsx(w,{size:16}),r.jsx("span",{children:i("dirPicker.browse","Browse")})]})]}),e.isOpen&&r.jsxs("div",{className:"directory-picker-browser",role:"tree","aria-label":i("dirPicker.ariaLabel","Directory browser"),children:[r.jsx("div",{className:"directory-picker-breadcrumbs",children:v.map((t,c)=>r.jsxs("span",{className:"directory-picker-breadcrumb-item",children:[c>0&&r.jsx(j,{size:12,className:"directory-picker-breadcrumb-sep"}),r.jsx("button",{type:"button",className:"directory-picker-breadcrumb",onClick:()=>y(t.path),title:t.path,children:t.label})]},t.path))}),r.jsxs("div",{className:"directory-picker-toolbar",children:[e.parentPath&&r.jsxs("button",{type:"button",className:"btn btn-sm btn-secondary directory-picker-up-btn",onClick:()=>y(e.parentPath),"aria-label":i("dirPicker.parentDir","Go to parent directory"),title:i("dirPicker.parentDirTitle","Parent directory"),children:[r.jsx(T,{size:14}),r.jsx("span",{children:i("dirPicker.up","Up")})]}),r.jsxs("button",{type:"button",className:"btn btn-sm btn-secondary directory-picker-hidden-toggle",onClick:E,"aria-label":e.showHidden?i("dirPicker.hideHiddenAria","Hide hidden directories"):i("dirPicker.showHiddenAria","Show hidden directories"),title:e.showHidden?i("dirPicker.hideHiddenTitle","Hide hidden"):i("dirPicker.showHiddenTitle","Show hidden"),children:[e.showHidden?r.jsx(B,{size:14}):r.jsx(A,{size:14}),r.jsx("span",{children:e.showHidden?i("dirPicker.hideHidden","Hide hidden"):i("dirPicker.showHidden","Show hidden")})]}),r.jsxs("button",{type:"button",className:"btn btn-sm btn-secondary directory-picker-create-folder-toggle",onClick:f,"aria-label":i("dirPicker.createFolderAria","Create new folder"),title:i("dirPicker.createFolderTitle","Create folder"),children:[r.jsx(L,{size:14}),r.jsx("span",{children:i("dirPicker.createFolder","New folder")})]})]}),e.loading?r.jsxs("div",{className:"directory-picker-loading",children:[r.jsx(K,{size:20,className:"animate-spin"}),r.jsx("span",{children:i("dirPicker.loading","Loading…")})]}):e.error?r.jsxs("div",{className:"directory-picker-error",children:[r.jsx(N,{size:16}),r.jsx("span",{children:e.error})]}):r.jsx("div",{className:"directory-picker-entries",children:e.entries.length===0?r.jsx("div",{className:"directory-picker-empty",children:i("dirPicker.noSubdirs","No subdirectories")}):e.entries.map(t=>r.jsxs("button",{type:"button",className:"directory-picker-entry",onClick:()=>y(t.path),role:"treeitem",title:t.path,children:[r.jsx(w,{size:16,className:"directory-picker-entry-icon"}),r.jsx("span",{className:"directory-picker-entry-name",children:t.name}),t.hasChildren&&r.jsx(j,{size:14,className:"directory-picker-entry-arrow"})]},t.path))}),e.createFolderOpen&&r.jsxs("div",{className:"directory-picker-create-folder",children:[r.jsx("input",{type:"text",className:"input directory-picker-create-folder-input",value:p,onChange:t=>u(t.target.value),onKeyDown:O,placeholder:i("dirPicker.newFolderPlaceholder","Folder name"),autoFocus:!0}),r.jsxs("div",{className:"directory-picker-create-folder-actions",children:[r.jsx("button",{type:"button",className:"btn btn-sm btn-primary",onClick:P,disabled:!p.trim()||e.loading||!e.currentPath,children:i("dirPicker.createFolderConfirm","Create")}),r.jsx("button",{type:"button",className:"btn btn-sm btn-secondary",onClick:f,children:i("dirPicker.cancel","Cancel")})]}),e.createFolderError&&r.jsxs("div",{className:"directory-picker-create-folder-error",children:[r.jsx(N,{size:14}),r.jsx("span",{children:e.createFolderError})]})]}),r.jsxs("div",{className:"directory-picker-actions",children:[r.jsx("span",{className:"directory-picker-selected-path",title:e.currentPath,children:e.currentPath}),r.jsx("button",{type:"button",className:"btn btn-primary directory-picker-select-btn",onClick:H,children:i("dirPicker.select","Select")})]})]})]})}export{M as D};
@@ -1 +1 @@
1
- import{r as n,j as e}from"./vendor-react-SZ_qB27O.js";import{r as Ve,e as _e,S as Ht,au as It,av as Ot,aw as Ye,b as zt,ax as $t,ay as fe,az as Bt,aA as qe,aB as Ut,aC as Vt,aD as _t,aE as qt,aF as Pe,aG as Qt,aH as Qe,V as Gt,aI as ce,E as Wt,y as Kt,aJ as Yt,X as Xt,R as Jt,aK as ke,A as Ge,D as We,aL as Ke,n as Ee,o as De,aM as Zt,aN as Xe,aO as es,aP as ts,aQ as ss,aR as ns,H as as,aS as cs,aT as os,aU as rs,aV as is}from"./index-I32FijPT.js";import{u as ls}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";function ds(a){const{projectId:d,searchQuery:m,includeProjectFiles:y=!0}=a??{},v=d?`${Ht.DOCUMENTS_PREFIX}${d}`:null,[w,t]=n.useState(()=>{if(!v)return[];const b=Ve(v,{maxAgeMs:_e});return Array.isArray(b)?b:[]}),[l,r]=n.useState([]),[A,u]=n.useState(()=>w.length===0),[P,p]=n.useState(null),f=n.useRef(null),j=n.useRef(w.length>0),h=n.useRef(null),{capture:N}=It(d,"useDocuments"),E=n.useCallback(async()=>{const b=N();f.current&&f.current.abort();const T=new AbortController;f.current=T;const J=!j.current;J&&u(!0),p(null);const _=Ot(m?{q:m}:void 0,d),Z=y?Ye(d):Promise.resolve({files:[]}),[S,C]=await Promise.allSettled([_,Z]);if(T.signal.aborted||b.isStale())return;let re=null;if(S.status==="fulfilled"){if(t(S.value),v){const D=S.value.length>500?S.value.slice(0,500):S.value;zt(v,D,{maxBytes:5e5})}j.current=!0}else re=S.reason instanceof Error?S.reason.message:String(S.reason);if(C.status==="fulfilled"){const D=C.value.files,W=m?.trim().toLowerCase(),ie=W?D.filter(ee=>ee.name.toLowerCase().includes(W)||ee.path.toLowerCase().includes(W)):D;r(ie)}p(re),J&&u(!1)},[v,N,y,d,m]);return n.useEffect(()=>{if(r([]),!v){j.current=!1,t([]),u(!0);return}const b=Ve(v,{maxAgeMs:_e});Array.isArray(b)?(t(b),j.current=!0,u(!1)):(j.current=!1,t([]),u(!0))},[v]),n.useEffect(()=>(h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{E()},300),()=>{h.current&&clearTimeout(h.current)}),[E]),n.useEffect(()=>(E(),()=>{f.current&&f.current.abort()}),[]),{documents:w,projectFiles:l,loading:A,error:P,refresh:E}}function us(a,d){const[m,y]=n.useState([]),[v,w]=n.useState(!0),[t,l]=n.useState(null),r=n.useRef(null),A=n.useRef(!1),u=d?.showHidden??!1,P=n.useCallback(async p=>{r.current&&r.current.abort();const f=new AbortController;r.current=f;const j=!A.current;j&&w(!0),l(null);try{const h=await Ye(a,{showHidden:p?.showHidden??u});if(f.signal.aborted)return;y(h.files),A.current=!0}catch(h){if(f.signal.aborted)return;l(h instanceof Error?h.message:String(h))}finally{!f.signal.aborted&&j&&w(!1)}},[a,u]);return n.useEffect(()=>(A.current=!1,P({showHidden:u}),()=>{r.current&&r.current.abort()}),[P,u]),{files:m,loading:v,error:t,refresh:P}}const ms=768,hs={image:ns,doc:ce,pdf:ss,video:ts,audio:es,other:Xe};function oe(a){return a?new Date(a).toLocaleString():""}function fs(a){return a<1024?`${a} B`:a<1024*1024?`${(a/1024).toFixed(a>=10*1024?0:1)} KB`:`${(a/(1024*1024)).toFixed(1)} MB`}function ks(a,d){return d?d.archived?"status-dot status-dot--offline":d.complete?"status-dot status-dot--online":d.intake||d.hold?"status-dot status-dot--pending":"status-dot status-dot--connecting":a==="done"?"status-dot status-dot--online":a==="archived"?"status-dot status-dot--offline":ps.has(a)?"status-dot status-dot--pending":"status-dot status-dot--connecting"}const ps=new Set(["triage","todo"]);function Je(a,d){switch(d){case"image":return a("documents.artifactCategoryImage","Image");case"doc":return a("documents.artifactCategoryDoc","Document");case"pdf":return a("documents.artifactCategoryPdf","PDF");case"video":return a("documents.artifactCategoryVideo","Video");case"audio":return a("documents.artifactCategoryAudioSingle","Audio");case"other":return a("documents.artifactCategoryOtherSingle","Other")}}function js(a,d){return d?[a.title,a.description,a.taskId,a.taskTitle,a.mimeType,a.authorId].some(m=>m?.toLowerCase().includes(d)):!0}function xs(a){const d=a.mimeType?.toLowerCase().split(";",1)[0]??"";return!!a.content||a.type==="document"||d.startsWith("text/")||d==="application/json"||d==="application/xml"}function bs({artifact:a,projectId:d,content:m,loading:y,error:v,renderMarkdown:w,onToggleMarkdown:t,onOpenTask:l,t:r}){const[A,u]=n.useState(null),[P,p]=n.useState(!1),f=Pe(a),j=Je(r,f),h=a.title||r("documents.untitledArtifact","Untitled artifact"),N=as(a.id,d),E=f==="doc"&&xs(a);n.useEffect(()=>{u(null)},[a.id]);const b=A?e.jsx("p",{className:"documents-content-state documents-content-state--error",children:A}):null,T=f==="image"?e.jsxs(e.Fragment,{children:[b,e.jsx("button",{type:"button",className:"documents-task-artifact-image-button",onClick:()=>p(!0),"aria-label":r("documents.expandImageArtifact","Expand image artifact {{title}}",{title:h}),children:e.jsx(cs,{className:"documents-task-artifact-media",artifactId:a.id,projectId:d,title:h,onError:()=>u(r("documents.artifactMediaFailed","Failed to load artifact preview."))})}),P&&e.jsx(os,{artifactId:a.id,projectId:d,title:h,onClose:()=>p(!1)})]}):f==="video"?e.jsxs(e.Fragment,{children:[b,e.jsx("video",{className:"documents-task-artifact-media",controls:!0,src:N,"aria-label":r("documents.videoArtifactLabel","Video artifact: {{title}}",{title:h}),onError:()=>u(r("documents.artifactMediaFailed","Failed to load artifact preview."))})]}):f==="audio"?e.jsxs(e.Fragment,{children:[b,e.jsx("audio",{className:"documents-task-artifact-audio",controls:!0,src:N,"aria-label":r("documents.audioArtifactLabel","Audio artifact: {{title}}",{title:h}),onError:()=>u(r("documents.artifactMediaFailed","Failed to load artifact preview."))})]}):f==="pdf"?e.jsxs("div",{className:"documents-task-artifact-pdf",children:[e.jsx("iframe",{title:r("documents.pdfArtifactTitle","PDF artifact: {{title}}",{title:h}),src:N}),e.jsxs("a",{className:"btn btn-sm",href:N,target:"_blank",rel:"noreferrer",children:[e.jsx(rs,{size:14,"aria-hidden":"true"}),r("documents.openInNewTab","Open in new tab")]})]}):f==="doc"&&E?y?e.jsx("p",{className:"documents-content-state",children:e.jsx(ke,{label:r("documents.loadingArtifactContent","Loading artifact content…")})}):v?e.jsx("p",{className:"documents-content-state documents-content-state--error",children:v}):w?e.jsx("div",{className:"documents-content-markdown documents-task-artifact-doc-content",children:e.jsx("div",{className:"markdown-body",children:e.jsx(Ee,{remarkPlugins:[De],children:m??a.content??""})})}):e.jsx("pre",{className:"document-card-content-text documents-content-viewer-text documents-task-artifact-doc-content",children:m??a.content??""}):e.jsxs("div",{className:"documents-task-artifact-download",children:[e.jsx(Xe,{size:24,"aria-hidden":"true"}),e.jsx("p",{children:a.description||r("documents.binaryArtifactFallback","This artifact cannot be previewed inline.")}),e.jsxs("a",{className:"btn btn-sm",href:N,target:"_blank",rel:"noreferrer","data-testid":"task-artifact-open-link",children:[e.jsx(is,{size:14,"aria-hidden":"true"}),r("documents.openArtifact","Open artifact")]})]});return e.jsxs("div",{className:"documents-content-viewer documents-task-artifact-viewer",children:[e.jsxs("div",{className:"documents-content-header documents-task-document-header",children:[e.jsxs("p",{className:"documents-file-path-header",children:[a.taskId," / ",h]}),f==="doc"&&E?e.jsx("button",{className:"btn btn-sm document-mode-toggle",onClick:t,"aria-label":w?r("documents.switchToPlainText","Switch to plain text"):r("documents.switchToMarkdown","Switch to markdown"),"aria-pressed":w,title:w?r("documents.switchToPlainText","Switch to plain text"):r("documents.switchToMarkdown","Switch to markdown"),children:w?r("documents.markdown","Markdown"):r("documents.plain","Plain")}):null]}),e.jsxs("div",{className:"document-card-meta documents-task-document-meta documents-task-artifact-meta",children:[e.jsx("span",{children:j}),e.jsx("span",{className:"document-card-separator",children:"·"}),e.jsx("span",{children:a.authorId||r("documents.unknownAuthor","unknown")}),e.jsx("span",{className:"document-card-separator",children:"·"}),e.jsx("span",{children:oe(a.updatedAt)}),a.taskId?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"document-card-separator",children:"·"}),e.jsx("button",{className:"documents-task-artifact-open-task",onClick:()=>void l(a.taskId),children:r("documents.openTask","Open task")})]}):null]}),a.description?e.jsx("p",{className:"documents-task-artifact-description",children:a.description}):null,e.jsx("div",{className:`documents-task-artifact-preview documents-task-artifact-preview--${f}`,children:T})]})}function ys({projectId:a,columnFlagsByTaskId:d,addToast:m,onOpenDetail:y,onOpenArtifactTaskDetail:v,onSendSelectionToTask:w}){const{t}=ls("app"),[l,r]=n.useState("artifacts"),A=$t(),[u,P]=n.useState(""),[p,f]=n.useState(null),[j,h]=n.useState(null),[N,E]=n.useState(!1),[b,T]=n.useState(null),[J,_]=n.useState(!1),[Z,S]=n.useState(null),[C,re]=n.useState(!1),D=n.useRef(0),W=n.useRef(null),ie=n.useRef(null),ee=n.useRef(null),Le=n.useRef(null),[K,Me]=n.useState(!1),[Ze,Re]=n.useState(new Map),[et,R]=n.useState(null),[pe,L]=n.useState(""),[le,M]=n.useState(null),[q,F]=n.useState(null),[de,je]=n.useState(!1),[tt,H]=n.useState(null),[st,B]=n.useState(!1),[nt,I]=n.useState(null),[at,xe]=n.useState(!0),te=n.useRef(0),[be,Q]=n.useState(!1),[ue,U]=n.useState(""),[we,ge]=n.useState(!1),[me,He]=n.useState(!1),ct=fe(W,{locked:me}),ot=fe(ie,{locked:me}),rt=fe(ee,{locked:me}),it=fe(Le,{locked:me}),ve=K?ct:ot,Ne=l==="tasks"?u.trim():"",lt=l==="artifacts"?u.trim():"",{documents:se,loading:dt,error:ut,refresh:ne}=ds({projectId:a,searchQuery:Ne||void 0,includeProjectFiles:!1}),{files:G,loading:mt,error:ht,refresh:Ie}=us(a,{showHidden:N}),{artifacts:O,loading:ft,error:kt,refresh:Se}=Bt({projectId:a,searchQuery:lt||void 0});n.useEffect(()=>{const s=()=>{re(window.innerWidth<=ms)};return s(),window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s)}},[]),n.useEffect(()=>{r("artifacts"),f(null),h(null),E(!1),T(null),S(null),_(!1),Me(!1),Re(new Map),R(null),L(""),M(null),F(null),je(!1),H(null),B(!1),I(null),xe(!0),Q(!1),U(""),ge(!1)},[a]);const Y=n.useMemo(()=>{const s=Ne.toLowerCase(),c=new Map;for(const o of se){const x=c.get(o.taskId)??{documents:[],artifacts:[]};x.documents.push(o),c.set(o.taskId,x)}for(const o of O){if(!o.taskId||!js(o,s))continue;const x=c.get(o.taskId)??{documents:[],artifacts:[]};x.artifacts.push(o),c.set(o.taskId,x)}return Array.from(c.entries()).map(([o,x])=>{const $=[...x.documents].sort((g,ae)=>ae.updatedAt.localeCompare(g.updatedAt)),V=[...x.artifacts].sort((g,ae)=>ae.updatedAt.localeCompare(g.updatedAt)),Ae=[$[0]?.updatedAt,V[0]?.updatedAt].filter(Boolean).sort().at(-1)??"",k=$.find(g=>g.taskTitle)?.taskTitle??V.find(g=>g.taskTitle)?.taskTitle;return{taskId:o,taskTitle:k,taskColumn:$.find(g=>g.taskColumn)?.taskColumn??V.find(g=>g.taskColumn)?.taskColumn,documents:$,artifacts:V,latestUpdated:Ae}}).filter(o=>o.documents.length>0||o.artifacts.length>0).sort((o,x)=>x.latestUpdated.localeCompare(o.latestUpdated))},[O,se,Ne]),i=n.useMemo(()=>j?.kind!=="document"?null:se.find(s=>s.id===j.id)??null,[se,j]),z=n.useMemo(()=>j?.kind!=="artifact"?null:O.find(s=>s.id===j.id)??null,[O,j]),he=i??z;n.useEffect(()=>{if(!j)return;Y.some(c=>j.kind==="document"?c.documents.some(o=>o.id===j.id):c.artifacts.some(o=>o.id===j.id))||(h(null),R(null),L(""),M(null),F(null),H(null),B(!1),I(null))},[Y,j]);const Ce=n.useMemo(()=>{const s=u.trim().toLowerCase();return s?G.filter(c=>{const o=c.path.toLowerCase(),x=c.name.toLowerCase();return o.includes(s)||x.includes(s)}):G},[G,u]);n.useEffect(()=>{if(!p)return;G.some(c=>c.path===p.path)||(f(null),T(null),S(null),_(!1))},[G,p]);const pt=n.useCallback(s=>{P(s.target.value)},[]),jt=n.useCallback(()=>{P("")},[]),ye=n.useCallback(s=>{r(s),s!=="tasks"&&(h(null),R(null),L(""),M(null),F(null),H(null),B(!1),I(null)),s!=="project"&&(Q(!1),U(""))},[]),xt=n.useCallback(async s=>{try{const c=await qe(s,a);y(c)}catch{m(`Failed to open task ${s}`,"error")}},[a,y,m]),Oe=n.useCallback(async s=>{try{const c=await qe(s,a);(v??y)(c)}catch{m(`Failed to open task ${s}`,"error")}},[a,v,y,m]),bt=n.useCallback(async s=>{f(s),_(!0),S(null),T(null),Q(!1),U("");const c=D.current+1;D.current=c;try{const o=await Ut("project",s.path,a);if(D.current!==c)return;T(o.content)}catch(o){if(D.current!==c)return;const x=o instanceof Error?o.message:`Failed to open ${s.path}`;S(x),m(x,"error")}finally{D.current===c&&_(!1)}},[a,m]),wt=n.useCallback(()=>{f(null),T(null),S(null),_(!1),Q(!1),U("")},[]),gt=n.useCallback(()=>{b!==null&&(U(b),Q(!0))},[b]),vt=n.useCallback(()=>{Q(!1),U("")},[]),Nt=n.useCallback(async()=>{if(p){ge(!0);try{await Vt("project",p.path,ue,a),T(ue),Q(!1),U(""),m(t("documents.projectFileSaved","File saved"),"success")}catch(s){m(s instanceof Error?s.message:String(s),"error")}finally{ge(!1)}}},[p,ue,a,m,t]),St=n.useCallback(s=>{h({kind:"document",id:s}),R(null),L(""),M(null),F(null),H(null),B(!1),I(null)},[]),Ct=n.useCallback(s=>{h({kind:"artifact",id:s}),R(null),L(""),M(null),F(null),H(null),I(null),xe(!0)},[]),yt=n.useCallback(()=>{h(null),R(null),L(""),M(null),F(null),H(null),B(!1),I(null)},[]),Tt=n.useCallback(s=>{Re(c=>{const o=new Map(c),x=o.get(s)??!0;return o.set(s,!x),o})},[]),Ft=n.useCallback(()=>{i&&(L(i.content),R(i.id),M({revision:i.revision,contentHash:i.contentHash}),F(null))},[i]),At=n.useCallback(()=>{R(null),L(""),M(null),F(null)},[]),Pt=n.useCallback(()=>{q&&(M(q),F(null))},[q]),Et=n.useCallback(async()=>{if(!(!i||!le||q)){je(!0);try{await _t(i.taskId,i.key,pe,{expectedRevision:le.revision,expectedContentHash:le.contentHash},a),await ne(),R(null),L(""),M(null),F(null),m(t("documents.taskDocumentSaved","Document saved"),"success")}catch(s){if(typeof s=="object"&&s!==null&&"status"in s&&s.status===409)try{const c=await qt(i.taskId,i.key,a);await ne(),F({revision:c.revision,contentHash:c.contentHash}),m(t("documents.taskDocumentStale","This document changed since you opened it. Your draft is preserved; review the latest revision, then choose Rebase draft before saving."),"error")}catch(c){m(c instanceof Error?c.message:String(c),"error")}else m(s instanceof Error?s.message:String(s),"error")}finally{je(!1)}}},[i,pe,le,q,a,ne,m,t]);n.useEffect(()=>{if(!z||Pe(z)!=="doc"){H(null),B(!1),I(null);return}const s=te.current+1;te.current=s,B(!0),I(null),H(null),Qt(z.id,a).then(c=>{te.current===s&&H(c.content??z.content??"")}).catch(c=>{te.current===s&&I(c instanceof Error?c.message:String(c))}).finally(()=>{te.current===s&&B(!1)})},[a,z]);const ze=l==="project"?ht:l==="tasks"?ut:kt,Dt=n.useCallback(async()=>{if(l==="project"){await Ie();return}if(l==="tasks"){await ne();return}await Se()},[l,Se,Ie,ne]),$e=l==="project"?Ce.length:l==="tasks"?Y.length:O.length,X=i?Ze.get(i.id)??!0:!1,Te=X?rt:it,Fe=i!==null&&et===i.id,Lt=l==="project"&&p&&!be&&w&&ve?e.jsx(Qe,{selectedText:ve.selectedText,anchorRect:ve.anchorRect,filePath:p.path,onSubmit:w,onOpenChange:He}):null,Mt=l==="tasks"&&i&&!Fe&&w&&Te?e.jsx(Qe,{selectedText:Te.selectedText,anchorRect:Te.anchorRect,filePath:`${i.taskId}/${i.key}`,onSubmit:w,onOpenChange:He}):null,Be=l==="project"?t("documents.searchProjectFiles","Search project markdown files…"):l==="tasks"?t("documents.searchTaskDocuments","Search task documents…"):t("documents.searchArtifacts","Search artifacts…");return e.jsxs("div",{className:"documents-view",children:[e.jsxs("div",{className:"documents-view-header",children:[e.jsx(Gt,{icon:ce,title:t("documents.title","Artifacts"),actions:e.jsx("span",{className:"documents-view-count",children:t("documents.resultCount","{{count}} result{{plural}}",{count:$e,plural:$e!==1?"s":""})})}),e.jsxs("div",{className:"documents-controls-row",children:[e.jsxs("div",{className:"documents-tab-bar",role:"tablist","aria-label":t("documents.sectionsLabel","Documents sections"),children:[e.jsxs("button",{className:`btn documents-tab${l==="artifacts"?" active":""}`,role:"tab","aria-selected":l==="artifacts","aria-label":t("documents.showArtifacts","Show artifacts"),onClick:()=>ye("artifacts"),children:[t("documents.artifactsTab","Artifacts"),e.jsx("span",{className:"documents-tab-count",children:O.length})]}),e.jsxs("button",{className:`btn documents-tab${l==="project"?" active":""}`,role:"tab","aria-selected":l==="project","aria-label":t("documents.showProjectFiles","Show project markdown files"),onClick:()=>ye("project"),children:[t("documents.projectFilesTab","Project Files"),e.jsx("span",{className:"documents-tab-count",children:G.length})]}),e.jsxs("button",{className:`btn documents-tab${l==="tasks"?" active":""}`,role:"tab","aria-selected":l==="tasks","aria-label":t("documents.showTaskDocuments","Show task documents"),onClick:()=>ye("tasks"),children:[t("documents.taskDocumentsTab","Task Documents"),e.jsx("span",{className:"documents-tab-count",children:Y.length})]})]}),l==="project"&&e.jsxs("button",{className:"btn btn-sm documents-hidden-toggle",onClick:()=>E(s=>!s),"aria-pressed":N,"aria-label":N?t("documents.hideHidden","Hide hidden project files"):t("documents.showHidden","Show hidden project files"),title:N?t("documents.hideHiddenFiles","Hide hidden files"):t("documents.showHiddenFiles","Show hidden files"),children:[N?e.jsx(Wt,{size:14}):e.jsx(Kt,{size:14}),N?t("documents.hideHiddenLabel","Hide Hidden"):t("documents.showHiddenLabel","Show Hidden")]}),e.jsxs("div",{className:"documents-search",children:[e.jsx(Yt,{size:16,className:"documents-search-icon"}),e.jsx("input",{type:"text",className:"documents-search-input",placeholder:Be,value:u,onChange:pt,"aria-label":Be}),u&&e.jsx("button",{className:"documents-search-clear",onClick:jt,"aria-label":t("documents.clearSearch","Clear search"),children:e.jsx(Xt,{size:16})})]})]})]}),e.jsx("div",{className:"documents-view-content",children:ze?e.jsxs("div",{className:"documents-view-error",children:[e.jsx("p",{children:t("documents.failedToLoad","Failed to load {{type}}: {{error}}",{type:l==="project"?t("documents.projectFiles","project files"):l==="tasks"?t("documents.taskDocuments","task documents"):t("documents.artifacts","artifacts"),error:ze})}),e.jsxs("button",{className:"btn btn-primary",onClick:()=>void Dt(),"aria-label":t("documents.retryLoading","Retry loading documents"),children:[e.jsx(Jt,{size:16}),t("documents.retry","Retry")]})]}):l==="project"?mt&&G.length===0?e.jsx("div",{className:"documents-view-loading",children:e.jsx("p",{children:e.jsx(ke,{label:t("documents.loadingProjectFiles","Loading project markdown files…")})})}):Ce.length===0?e.jsx("div",{className:"documents-view-empty",children:u.trim()?e.jsx("p",{children:t("documents.noMatchProject",'No project markdown files match "{{query}}".',{query:u.trim()})}):e.jsxs(e.Fragment,{children:[e.jsx(ce,{size:48,className:"documents-view-empty-icon"}),e.jsx("p",{children:t("documents.noMarkdownFiles","No Markdown files found in this project.")})]})}):e.jsxs("div",{className:`documents-project-layout${C?" documents-project-layout--mobile":""}`,children:[(!C||!p)&&e.jsx("aside",{className:"documents-view-sidebar","aria-label":t("documents.projectMarkdownFilesLabel","Project markdown files"),children:e.jsx("ul",{className:"markdown-file-list",children:Ce.map(s=>{const c=p?.path===s.path;return e.jsx("li",{className:"markdown-file-list-item",children:e.jsxs("button",{className:`markdown-file-item${c?" markdown-file-item--selected":""}`,onClick:()=>void bt(s),"aria-label":`Open ${s.path}`,"aria-current":c?"true":void 0,children:[e.jsx("span",{className:"markdown-file-item-name",children:s.name}),e.jsx("span",{className:"markdown-file-item-path",children:s.path}),e.jsxs("span",{className:"markdown-file-item-meta",children:[fs(s.size)," · ",oe(s.mtime)]})]})},s.path)})})}),(!C||p)&&e.jsxs("section",{className:"documents-view-main","aria-label":t("documents.projectFilePreviewLabel","Project file content preview"),children:[C&&p&&e.jsxs("button",{className:"btn btn-sm documents-mobile-back",onClick:wt,"aria-label":t("documents.backToFilesList","Back to project files list"),children:[e.jsx(Ge,{size:14}),t("documents.backToFiles","Back to files")]}),p?e.jsxs("div",{className:"documents-content-viewer",children:[e.jsxs("div",{className:"documents-content-header",children:[e.jsx("p",{className:"documents-file-path-header",children:p.path}),e.jsx("div",{className:"documents-task-document-actions",children:be?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn btn-sm",onClick:vt,disabled:we,children:t("documents.cancelEdit","Cancel")}),e.jsx("button",{className:"btn btn-sm btn-primary",onClick:()=>void Nt(),disabled:we,children:we?t("documents.saving","Saving…"):t("documents.saveProjectFile","Save")})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn btn-sm document-mode-toggle",onClick:()=>Me(s=>!s),"aria-label":K?t("documents.switchToPlainText","Switch to plain text"):t("documents.switchToMarkdown","Switch to markdown"),"aria-pressed":K,title:K?t("documents.switchToPlainText","Switch to plain text"):t("documents.switchToMarkdown","Switch to markdown"),children:K?t("documents.markdown","Markdown"):t("documents.plain","Plain")}),e.jsxs("button",{className:"btn btn-sm",onClick:gt,disabled:J||Z!==null||b===null,"aria-label":t("documents.editProjectFile","Edit project file"),children:[e.jsx(We,{size:14,"aria-hidden":"true"}),t("documents.edit","Edit")]})]})})]}),J?e.jsx("p",{className:"documents-content-state",children:e.jsx(ke,{label:t("documents.loadingFileContent","Loading file content…")})}):Z?e.jsx("p",{className:"documents-content-state documents-content-state--error",children:Z}):be?e.jsx("div",{className:"documents-task-document-editor","aria-label":t("documents.projectFileContentEditor","Project file content editor"),children:e.jsx(Ke,{content:ue,onChange:U,filePath:p.path,forceToolbarActionsVisible:!0})}):K?e.jsx("div",{ref:W,className:"documents-content-markdown",children:e.jsx("div",{className:"markdown-body",children:e.jsx(Ee,{remarkPlugins:[De],children:b??""})})}):e.jsx("pre",{ref:ie,className:"document-card-content-text documents-content-viewer-text",children:b??""}),Lt]}):e.jsx("div",{className:"documents-view-empty",children:e.jsx("p",{children:t("documents.selectFile","Select a Markdown file to view its content.")})})]})]}):l==="artifacts"?ft&&O.length===0?e.jsx("div",{className:"documents-view-loading",children:e.jsx("p",{children:t("documents.loadingArtifacts","Loading artifacts…")})}):O.length===0?e.jsx("div",{className:"documents-view-empty",children:u.trim()?e.jsx("p",{children:t("documents.noMatchArtifacts",'No artifacts match "{{query}}".',{query:u.trim()})}):e.jsxs(e.Fragment,{children:[e.jsx(ce,{size:48,className:"documents-view-empty-icon"}),e.jsx("p",{children:t("documents.noArtifacts","No artifacts yet.")}),e.jsx("p",{className:"documents-view-empty-hint",children:t("documents.artifactsCreatedBy","Agents register screenshots, wireframes, mockups, recordings, and documents here as they work on tasks.")})]})}):e.jsx(Zt,{artifacts:O,projectId:a,isMobile:C,addToast:m,onOpenTask:Oe,onArtifactUpdated:()=>void Se()}):dt&&se.length===0?e.jsx("div",{className:"documents-view-loading",children:e.jsx("p",{children:e.jsx(ke,{label:t("documents.loadingTaskDocuments","Loading task documents…")})})}):Y.length===0?e.jsx("div",{className:"documents-view-empty",children:u.trim()?e.jsx("p",{children:t("documents.noMatchTask",'No task documents match "{{query}}".',{query:u.trim()})}):e.jsxs(e.Fragment,{children:[e.jsx(ce,{size:48,className:"documents-view-empty-icon"}),e.jsx("p",{children:t("documents.noTaskDocuments","No task documents yet.")}),e.jsx("p",{className:"documents-view-empty-hint",children:t("documents.documentsCreatedIn","Documents are created in task detail tabs.")})]})}):e.jsxs("div",{className:`documents-project-layout documents-task-documents-layout${C?" documents-project-layout--mobile":""}`,children:[(!C||!he)&&e.jsx("aside",{className:"documents-view-sidebar documents-task-documents-sidebar","aria-label":t("documents.taskDocumentsListLabel","Task documents"),children:Y.map(({taskId:s,taskTitle:c,taskColumn:o,documents:x,artifacts:$})=>{const V=o?A(o):null,Ae=o?ks(o,d?.get(s)):"status-dot";return e.jsxs("section",{className:"documents-task-sidebar-group","aria-labelledby":`documents-task-group-${s}`,children:[e.jsxs("div",{className:"documents-task-sidebar-group-header",children:[e.jsxs("div",{className:"documents-task-sidebar-title-wrap",children:[e.jsxs("h3",{id:`documents-task-group-${s}`,className:"documents-task-sidebar-title",children:[e.jsx("span",{className:"documents-group-task-id",children:s}),e.jsx("span",{className:"documents-group-task-title",children:c||t("documents.untitled","Untitled")})]}),V?e.jsxs("span",{className:"documents-group-status badge","aria-label":t("documents.taskStatusAria","Task status: {{status}}",{status:V}),children:[e.jsx("span",{className:Ae,"aria-hidden":"true"}),e.jsx("span",{children:V})]}):null]}),e.jsxs("div",{className:"documents-task-sidebar-actions",children:[e.jsx("span",{className:"documents-group-count",children:t("documents.taskOutputCount","{{docCount}} doc{{docPlural}} · {{artifactCount}} artifact{{artifactPlural}}",{docCount:x.length,docPlural:x.length!==1?"s":"",artifactCount:$.length,artifactPlural:$.length!==1?"s":""})}),e.jsx("button",{className:"documents-group-task-link",onClick:()=>void xt(s),"aria-label":t("documents.openTaskAria","Open task {{taskId}}: {{title}}",{taskId:s,title:c||t("documents.untitled","Untitled")}),children:t("documents.openTask","Open task")})]})]}),e.jsxs("ul",{className:"markdown-file-list documents-task-document-list",children:[x.map(k=>{const g=i?.id===k.id;return e.jsx("li",{className:"markdown-file-list-item",children:e.jsxs("button",{className:`markdown-file-item documents-task-document-item${g?" markdown-file-item--selected":""}`,onClick:()=>St(k.id),"aria-label":t("documents.openTaskDocument","Open {{taskId}} {{key}}",{taskId:k.taskId,key:k.key}),"aria-current":g?"true":void 0,children:[e.jsx("span",{className:"markdown-file-item-name",children:k.key}),e.jsxs("span",{className:"markdown-file-item-path",children:[k.taskId," · ",k.taskTitle||t("documents.untitled","Untitled")]}),e.jsxs("span",{className:"markdown-file-item-meta",children:[t("documents.revisionShort","v{{revision}}",{revision:k.revision})," · ",k.author," · ",oe(k.updatedAt)]})]})},`document-${k.id}`)}),$.length>0?e.jsxs("li",{className:"documents-task-artifacts-subsection","aria-label":t("documents.taskArtifactsSubsection","Task artifacts"),children:[e.jsx("div",{className:"documents-task-artifacts-label",children:t("documents.taskArtifactsLabel","Artifacts")}),e.jsx("ul",{className:"markdown-file-list documents-task-artifact-list",children:$.map(k=>{const g=Pe(k),ae=hs[g],Rt=Je(t,g),Ue=z?.id===k.id;return e.jsx("li",{className:"markdown-file-list-item",children:e.jsxs("button",{className:`markdown-file-item documents-task-document-item documents-task-artifact-item${Ue?" markdown-file-item--selected":""}`,onClick:()=>Ct(k.id),"aria-label":t("documents.openTaskArtifact","Open {{taskId}} artifact {{title}}",{taskId:s,title:k.title||t("documents.untitledArtifact","Untitled artifact")}),"aria-current":Ue?"true":void 0,children:[e.jsxs("span",{className:"documents-task-artifact-title-row",children:[e.jsx(ae,{size:14,"aria-hidden":"true"}),e.jsx("span",{className:"markdown-file-item-name",children:k.title||t("documents.untitledArtifact","Untitled artifact")})]}),e.jsxs("span",{className:"markdown-file-item-path",children:[Rt," · ",k.mimeType||k.type]}),e.jsxs("span",{className:"markdown-file-item-meta",children:[k.authorId||t("documents.unknownAuthor","unknown")," · ",oe(k.updatedAt)]})]})},`artifact-${k.id}`)})})]}):null]})]},s)})}),(!C||he)&&e.jsxs("section",{className:"documents-view-main","aria-label":t("documents.taskDocumentPreviewLabel","Task document content preview"),children:[C&&he&&e.jsxs("button",{className:"btn btn-sm documents-mobile-back",onClick:yt,"aria-label":t("documents.backToTaskDocumentsList","Back to task documents list"),children:[e.jsx(Ge,{size:14}),t("documents.backToTaskDocuments","Back to documents")]}),he?z?e.jsx(bs,{artifact:z,projectId:a,content:tt,loading:st,error:nt,renderMarkdown:at,onToggleMarkdown:()=>xe(s=>!s),onOpenTask:Oe,t}):i?e.jsxs("div",{className:"documents-content-viewer documents-task-document-viewer",children:[e.jsxs("div",{className:"documents-content-header documents-task-document-header",children:[e.jsxs("p",{className:"documents-file-path-header",children:[i.taskId," / ",i.key]}),e.jsx("div",{className:"documents-task-document-actions",children:Fe?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn btn-sm",onClick:At,disabled:de,children:t("documents.cancelEdit","Cancel")}),q&&e.jsx("button",{className:"btn btn-sm",onClick:Pt,disabled:de,children:t("documents.rebaseTaskDocument","Rebase draft")}),e.jsx("button",{className:"btn btn-sm btn-primary",onClick:()=>void Et(),disabled:de||q!==null,children:de?t("documents.saving","Saving…"):t("documents.saveTaskDocument","Save")})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn btn-sm document-mode-toggle",onClick:()=>Tt(i.id),"aria-label":X?t("documents.switchToPlainText","Switch to plain text"):t("documents.switchToMarkdown","Switch to markdown"),"aria-pressed":X,title:X?t("documents.switchToPlainText","Switch to plain text"):t("documents.switchToMarkdown","Switch to markdown"),children:X?t("documents.markdown","Markdown"):t("documents.plain","Plain")}),e.jsxs("button",{className:"btn btn-sm",onClick:Ft,"aria-label":t("documents.editTaskDocument","Edit task document"),children:[e.jsx(We,{size:14,"aria-hidden":"true"}),t("documents.edit","Edit")]})]})})]}),e.jsxs("div",{className:"document-card-meta documents-task-document-meta",children:[e.jsx("span",{className:"document-card-author",children:i.author}),e.jsx("span",{className:"document-card-separator",children:"·"}),e.jsx("span",{children:t("documents.revisionShort","v{{revision}}",{revision:i.revision})}),e.jsx("span",{className:"document-card-separator",children:"·"}),e.jsx("span",{className:"document-card-date",children:oe(i.updatedAt)})]}),Fe?e.jsx("div",{className:"documents-task-document-editor","aria-label":t("documents.taskDocumentContentEditor","Task document content editor"),children:e.jsx(Ke,{content:pe,onChange:L,filePath:i.key.includes(".")?i.key:`${i.key}.md`,forceToolbarActionsVisible:!0})}):X?e.jsx("div",{ref:ee,className:"documents-content-markdown",children:e.jsx("div",{className:"markdown-body",children:e.jsx(Ee,{remarkPlugins:[De],children:i.content})})}):e.jsx("pre",{ref:Le,className:"document-card-content-text documents-content-viewer-text",children:i.content}),Mt]}):null:e.jsx("div",{className:"documents-view-empty",children:e.jsx("p",{children:t("documents.selectTaskDocument","Select a task document or artifact to view its content.")})})]})]})})]})}export{ys as DocumentsView,ks as getTaskColumnStatusDotClass};
1
+ import{r as n,j as e}from"./vendor-react-SZ_qB27O.js";import{r as Ve,e as _e,S as Ht,au as It,av as Ot,aw as Ye,b as zt,ax as $t,ay as fe,az as Bt,aA as qe,aB as Ut,aC as Vt,aD as _t,aE as qt,aF as Pe,aG as Qt,aH as Qe,V as Gt,aI as ce,E as Wt,y as Kt,aJ as Yt,X as Xt,R as Jt,aK as ke,A as Ge,D as We,aL as Ke,n as Ee,o as De,aM as Zt,aN as Xe,aO as es,aP as ts,aQ as ss,aR as ns,H as as,aS as cs,aT as os,aU as rs,aV as is}from"./index-oxnX59eO.js";import{u as ls}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";function ds(a){const{projectId:d,searchQuery:m,includeProjectFiles:y=!0}=a??{},v=d?`${Ht.DOCUMENTS_PREFIX}${d}`:null,[w,t]=n.useState(()=>{if(!v)return[];const b=Ve(v,{maxAgeMs:_e});return Array.isArray(b)?b:[]}),[l,r]=n.useState([]),[A,u]=n.useState(()=>w.length===0),[P,p]=n.useState(null),f=n.useRef(null),j=n.useRef(w.length>0),h=n.useRef(null),{capture:N}=It(d,"useDocuments"),E=n.useCallback(async()=>{const b=N();f.current&&f.current.abort();const T=new AbortController;f.current=T;const J=!j.current;J&&u(!0),p(null);const _=Ot(m?{q:m}:void 0,d),Z=y?Ye(d):Promise.resolve({files:[]}),[S,C]=await Promise.allSettled([_,Z]);if(T.signal.aborted||b.isStale())return;let re=null;if(S.status==="fulfilled"){if(t(S.value),v){const D=S.value.length>500?S.value.slice(0,500):S.value;zt(v,D,{maxBytes:5e5})}j.current=!0}else re=S.reason instanceof Error?S.reason.message:String(S.reason);if(C.status==="fulfilled"){const D=C.value.files,W=m?.trim().toLowerCase(),ie=W?D.filter(ee=>ee.name.toLowerCase().includes(W)||ee.path.toLowerCase().includes(W)):D;r(ie)}p(re),J&&u(!1)},[v,N,y,d,m]);return n.useEffect(()=>{if(r([]),!v){j.current=!1,t([]),u(!0);return}const b=Ve(v,{maxAgeMs:_e});Array.isArray(b)?(t(b),j.current=!0,u(!1)):(j.current=!1,t([]),u(!0))},[v]),n.useEffect(()=>(h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{E()},300),()=>{h.current&&clearTimeout(h.current)}),[E]),n.useEffect(()=>(E(),()=>{f.current&&f.current.abort()}),[]),{documents:w,projectFiles:l,loading:A,error:P,refresh:E}}function us(a,d){const[m,y]=n.useState([]),[v,w]=n.useState(!0),[t,l]=n.useState(null),r=n.useRef(null),A=n.useRef(!1),u=d?.showHidden??!1,P=n.useCallback(async p=>{r.current&&r.current.abort();const f=new AbortController;r.current=f;const j=!A.current;j&&w(!0),l(null);try{const h=await Ye(a,{showHidden:p?.showHidden??u});if(f.signal.aborted)return;y(h.files),A.current=!0}catch(h){if(f.signal.aborted)return;l(h instanceof Error?h.message:String(h))}finally{!f.signal.aborted&&j&&w(!1)}},[a,u]);return n.useEffect(()=>(A.current=!1,P({showHidden:u}),()=>{r.current&&r.current.abort()}),[P,u]),{files:m,loading:v,error:t,refresh:P}}const ms=768,hs={image:ns,doc:ce,pdf:ss,video:ts,audio:es,other:Xe};function oe(a){return a?new Date(a).toLocaleString():""}function fs(a){return a<1024?`${a} B`:a<1024*1024?`${(a/1024).toFixed(a>=10*1024?0:1)} KB`:`${(a/(1024*1024)).toFixed(1)} MB`}function ks(a,d){return d?d.archived?"status-dot status-dot--offline":d.complete?"status-dot status-dot--online":d.intake||d.hold?"status-dot status-dot--pending":"status-dot status-dot--connecting":a==="done"?"status-dot status-dot--online":a==="archived"?"status-dot status-dot--offline":ps.has(a)?"status-dot status-dot--pending":"status-dot status-dot--connecting"}const ps=new Set(["triage","todo"]);function Je(a,d){switch(d){case"image":return a("documents.artifactCategoryImage","Image");case"doc":return a("documents.artifactCategoryDoc","Document");case"pdf":return a("documents.artifactCategoryPdf","PDF");case"video":return a("documents.artifactCategoryVideo","Video");case"audio":return a("documents.artifactCategoryAudioSingle","Audio");case"other":return a("documents.artifactCategoryOtherSingle","Other")}}function js(a,d){return d?[a.title,a.description,a.taskId,a.taskTitle,a.mimeType,a.authorId].some(m=>m?.toLowerCase().includes(d)):!0}function xs(a){const d=a.mimeType?.toLowerCase().split(";",1)[0]??"";return!!a.content||a.type==="document"||d.startsWith("text/")||d==="application/json"||d==="application/xml"}function bs({artifact:a,projectId:d,content:m,loading:y,error:v,renderMarkdown:w,onToggleMarkdown:t,onOpenTask:l,t:r}){const[A,u]=n.useState(null),[P,p]=n.useState(!1),f=Pe(a),j=Je(r,f),h=a.title||r("documents.untitledArtifact","Untitled artifact"),N=as(a.id,d),E=f==="doc"&&xs(a);n.useEffect(()=>{u(null)},[a.id]);const b=A?e.jsx("p",{className:"documents-content-state documents-content-state--error",children:A}):null,T=f==="image"?e.jsxs(e.Fragment,{children:[b,e.jsx("button",{type:"button",className:"documents-task-artifact-image-button",onClick:()=>p(!0),"aria-label":r("documents.expandImageArtifact","Expand image artifact {{title}}",{title:h}),children:e.jsx(cs,{className:"documents-task-artifact-media",artifactId:a.id,projectId:d,title:h,onError:()=>u(r("documents.artifactMediaFailed","Failed to load artifact preview."))})}),P&&e.jsx(os,{artifactId:a.id,projectId:d,title:h,onClose:()=>p(!1)})]}):f==="video"?e.jsxs(e.Fragment,{children:[b,e.jsx("video",{className:"documents-task-artifact-media",controls:!0,src:N,"aria-label":r("documents.videoArtifactLabel","Video artifact: {{title}}",{title:h}),onError:()=>u(r("documents.artifactMediaFailed","Failed to load artifact preview."))})]}):f==="audio"?e.jsxs(e.Fragment,{children:[b,e.jsx("audio",{className:"documents-task-artifact-audio",controls:!0,src:N,"aria-label":r("documents.audioArtifactLabel","Audio artifact: {{title}}",{title:h}),onError:()=>u(r("documents.artifactMediaFailed","Failed to load artifact preview."))})]}):f==="pdf"?e.jsxs("div",{className:"documents-task-artifact-pdf",children:[e.jsx("iframe",{title:r("documents.pdfArtifactTitle","PDF artifact: {{title}}",{title:h}),src:N}),e.jsxs("a",{className:"btn btn-sm",href:N,target:"_blank",rel:"noreferrer",children:[e.jsx(rs,{size:14,"aria-hidden":"true"}),r("documents.openInNewTab","Open in new tab")]})]}):f==="doc"&&E?y?e.jsx("p",{className:"documents-content-state",children:e.jsx(ke,{label:r("documents.loadingArtifactContent","Loading artifact content…")})}):v?e.jsx("p",{className:"documents-content-state documents-content-state--error",children:v}):w?e.jsx("div",{className:"documents-content-markdown documents-task-artifact-doc-content",children:e.jsx("div",{className:"markdown-body",children:e.jsx(Ee,{remarkPlugins:[De],children:m??a.content??""})})}):e.jsx("pre",{className:"document-card-content-text documents-content-viewer-text documents-task-artifact-doc-content",children:m??a.content??""}):e.jsxs("div",{className:"documents-task-artifact-download",children:[e.jsx(Xe,{size:24,"aria-hidden":"true"}),e.jsx("p",{children:a.description||r("documents.binaryArtifactFallback","This artifact cannot be previewed inline.")}),e.jsxs("a",{className:"btn btn-sm",href:N,target:"_blank",rel:"noreferrer","data-testid":"task-artifact-open-link",children:[e.jsx(is,{size:14,"aria-hidden":"true"}),r("documents.openArtifact","Open artifact")]})]});return e.jsxs("div",{className:"documents-content-viewer documents-task-artifact-viewer",children:[e.jsxs("div",{className:"documents-content-header documents-task-document-header",children:[e.jsxs("p",{className:"documents-file-path-header",children:[a.taskId," / ",h]}),f==="doc"&&E?e.jsx("button",{className:"btn btn-sm document-mode-toggle",onClick:t,"aria-label":w?r("documents.switchToPlainText","Switch to plain text"):r("documents.switchToMarkdown","Switch to markdown"),"aria-pressed":w,title:w?r("documents.switchToPlainText","Switch to plain text"):r("documents.switchToMarkdown","Switch to markdown"),children:w?r("documents.markdown","Markdown"):r("documents.plain","Plain")}):null]}),e.jsxs("div",{className:"document-card-meta documents-task-document-meta documents-task-artifact-meta",children:[e.jsx("span",{children:j}),e.jsx("span",{className:"document-card-separator",children:"·"}),e.jsx("span",{children:a.authorId||r("documents.unknownAuthor","unknown")}),e.jsx("span",{className:"document-card-separator",children:"·"}),e.jsx("span",{children:oe(a.updatedAt)}),a.taskId?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"document-card-separator",children:"·"}),e.jsx("button",{className:"documents-task-artifact-open-task",onClick:()=>void l(a.taskId),children:r("documents.openTask","Open task")})]}):null]}),a.description?e.jsx("p",{className:"documents-task-artifact-description",children:a.description}):null,e.jsx("div",{className:`documents-task-artifact-preview documents-task-artifact-preview--${f}`,children:T})]})}function ys({projectId:a,columnFlagsByTaskId:d,addToast:m,onOpenDetail:y,onOpenArtifactTaskDetail:v,onSendSelectionToTask:w}){const{t}=ls("app"),[l,r]=n.useState("artifacts"),A=$t(),[u,P]=n.useState(""),[p,f]=n.useState(null),[j,h]=n.useState(null),[N,E]=n.useState(!1),[b,T]=n.useState(null),[J,_]=n.useState(!1),[Z,S]=n.useState(null),[C,re]=n.useState(!1),D=n.useRef(0),W=n.useRef(null),ie=n.useRef(null),ee=n.useRef(null),Le=n.useRef(null),[K,Me]=n.useState(!1),[Ze,Re]=n.useState(new Map),[et,R]=n.useState(null),[pe,L]=n.useState(""),[le,M]=n.useState(null),[q,F]=n.useState(null),[de,je]=n.useState(!1),[tt,H]=n.useState(null),[st,B]=n.useState(!1),[nt,I]=n.useState(null),[at,xe]=n.useState(!0),te=n.useRef(0),[be,Q]=n.useState(!1),[ue,U]=n.useState(""),[we,ge]=n.useState(!1),[me,He]=n.useState(!1),ct=fe(W,{locked:me}),ot=fe(ie,{locked:me}),rt=fe(ee,{locked:me}),it=fe(Le,{locked:me}),ve=K?ct:ot,Ne=l==="tasks"?u.trim():"",lt=l==="artifacts"?u.trim():"",{documents:se,loading:dt,error:ut,refresh:ne}=ds({projectId:a,searchQuery:Ne||void 0,includeProjectFiles:!1}),{files:G,loading:mt,error:ht,refresh:Ie}=us(a,{showHidden:N}),{artifacts:O,loading:ft,error:kt,refresh:Se}=Bt({projectId:a,searchQuery:lt||void 0});n.useEffect(()=>{const s=()=>{re(window.innerWidth<=ms)};return s(),window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s)}},[]),n.useEffect(()=>{r("artifacts"),f(null),h(null),E(!1),T(null),S(null),_(!1),Me(!1),Re(new Map),R(null),L(""),M(null),F(null),je(!1),H(null),B(!1),I(null),xe(!0),Q(!1),U(""),ge(!1)},[a]);const Y=n.useMemo(()=>{const s=Ne.toLowerCase(),c=new Map;for(const o of se){const x=c.get(o.taskId)??{documents:[],artifacts:[]};x.documents.push(o),c.set(o.taskId,x)}for(const o of O){if(!o.taskId||!js(o,s))continue;const x=c.get(o.taskId)??{documents:[],artifacts:[]};x.artifacts.push(o),c.set(o.taskId,x)}return Array.from(c.entries()).map(([o,x])=>{const $=[...x.documents].sort((g,ae)=>ae.updatedAt.localeCompare(g.updatedAt)),V=[...x.artifacts].sort((g,ae)=>ae.updatedAt.localeCompare(g.updatedAt)),Ae=[$[0]?.updatedAt,V[0]?.updatedAt].filter(Boolean).sort().at(-1)??"",k=$.find(g=>g.taskTitle)?.taskTitle??V.find(g=>g.taskTitle)?.taskTitle;return{taskId:o,taskTitle:k,taskColumn:$.find(g=>g.taskColumn)?.taskColumn??V.find(g=>g.taskColumn)?.taskColumn,documents:$,artifacts:V,latestUpdated:Ae}}).filter(o=>o.documents.length>0||o.artifacts.length>0).sort((o,x)=>x.latestUpdated.localeCompare(o.latestUpdated))},[O,se,Ne]),i=n.useMemo(()=>j?.kind!=="document"?null:se.find(s=>s.id===j.id)??null,[se,j]),z=n.useMemo(()=>j?.kind!=="artifact"?null:O.find(s=>s.id===j.id)??null,[O,j]),he=i??z;n.useEffect(()=>{if(!j)return;Y.some(c=>j.kind==="document"?c.documents.some(o=>o.id===j.id):c.artifacts.some(o=>o.id===j.id))||(h(null),R(null),L(""),M(null),F(null),H(null),B(!1),I(null))},[Y,j]);const Ce=n.useMemo(()=>{const s=u.trim().toLowerCase();return s?G.filter(c=>{const o=c.path.toLowerCase(),x=c.name.toLowerCase();return o.includes(s)||x.includes(s)}):G},[G,u]);n.useEffect(()=>{if(!p)return;G.some(c=>c.path===p.path)||(f(null),T(null),S(null),_(!1))},[G,p]);const pt=n.useCallback(s=>{P(s.target.value)},[]),jt=n.useCallback(()=>{P("")},[]),ye=n.useCallback(s=>{r(s),s!=="tasks"&&(h(null),R(null),L(""),M(null),F(null),H(null),B(!1),I(null)),s!=="project"&&(Q(!1),U(""))},[]),xt=n.useCallback(async s=>{try{const c=await qe(s,a);y(c)}catch{m(`Failed to open task ${s}`,"error")}},[a,y,m]),Oe=n.useCallback(async s=>{try{const c=await qe(s,a);(v??y)(c)}catch{m(`Failed to open task ${s}`,"error")}},[a,v,y,m]),bt=n.useCallback(async s=>{f(s),_(!0),S(null),T(null),Q(!1),U("");const c=D.current+1;D.current=c;try{const o=await Ut("project",s.path,a);if(D.current!==c)return;T(o.content)}catch(o){if(D.current!==c)return;const x=o instanceof Error?o.message:`Failed to open ${s.path}`;S(x),m(x,"error")}finally{D.current===c&&_(!1)}},[a,m]),wt=n.useCallback(()=>{f(null),T(null),S(null),_(!1),Q(!1),U("")},[]),gt=n.useCallback(()=>{b!==null&&(U(b),Q(!0))},[b]),vt=n.useCallback(()=>{Q(!1),U("")},[]),Nt=n.useCallback(async()=>{if(p){ge(!0);try{await Vt("project",p.path,ue,a),T(ue),Q(!1),U(""),m(t("documents.projectFileSaved","File saved"),"success")}catch(s){m(s instanceof Error?s.message:String(s),"error")}finally{ge(!1)}}},[p,ue,a,m,t]),St=n.useCallback(s=>{h({kind:"document",id:s}),R(null),L(""),M(null),F(null),H(null),B(!1),I(null)},[]),Ct=n.useCallback(s=>{h({kind:"artifact",id:s}),R(null),L(""),M(null),F(null),H(null),I(null),xe(!0)},[]),yt=n.useCallback(()=>{h(null),R(null),L(""),M(null),F(null),H(null),B(!1),I(null)},[]),Tt=n.useCallback(s=>{Re(c=>{const o=new Map(c),x=o.get(s)??!0;return o.set(s,!x),o})},[]),Ft=n.useCallback(()=>{i&&(L(i.content),R(i.id),M({revision:i.revision,contentHash:i.contentHash}),F(null))},[i]),At=n.useCallback(()=>{R(null),L(""),M(null),F(null)},[]),Pt=n.useCallback(()=>{q&&(M(q),F(null))},[q]),Et=n.useCallback(async()=>{if(!(!i||!le||q)){je(!0);try{await _t(i.taskId,i.key,pe,{expectedRevision:le.revision,expectedContentHash:le.contentHash},a),await ne(),R(null),L(""),M(null),F(null),m(t("documents.taskDocumentSaved","Document saved"),"success")}catch(s){if(typeof s=="object"&&s!==null&&"status"in s&&s.status===409)try{const c=await qt(i.taskId,i.key,a);await ne(),F({revision:c.revision,contentHash:c.contentHash}),m(t("documents.taskDocumentStale","This document changed since you opened it. Your draft is preserved; review the latest revision, then choose Rebase draft before saving."),"error")}catch(c){m(c instanceof Error?c.message:String(c),"error")}else m(s instanceof Error?s.message:String(s),"error")}finally{je(!1)}}},[i,pe,le,q,a,ne,m,t]);n.useEffect(()=>{if(!z||Pe(z)!=="doc"){H(null),B(!1),I(null);return}const s=te.current+1;te.current=s,B(!0),I(null),H(null),Qt(z.id,a).then(c=>{te.current===s&&H(c.content??z.content??"")}).catch(c=>{te.current===s&&I(c instanceof Error?c.message:String(c))}).finally(()=>{te.current===s&&B(!1)})},[a,z]);const ze=l==="project"?ht:l==="tasks"?ut:kt,Dt=n.useCallback(async()=>{if(l==="project"){await Ie();return}if(l==="tasks"){await ne();return}await Se()},[l,Se,Ie,ne]),$e=l==="project"?Ce.length:l==="tasks"?Y.length:O.length,X=i?Ze.get(i.id)??!0:!1,Te=X?rt:it,Fe=i!==null&&et===i.id,Lt=l==="project"&&p&&!be&&w&&ve?e.jsx(Qe,{selectedText:ve.selectedText,anchorRect:ve.anchorRect,filePath:p.path,onSubmit:w,onOpenChange:He}):null,Mt=l==="tasks"&&i&&!Fe&&w&&Te?e.jsx(Qe,{selectedText:Te.selectedText,anchorRect:Te.anchorRect,filePath:`${i.taskId}/${i.key}`,onSubmit:w,onOpenChange:He}):null,Be=l==="project"?t("documents.searchProjectFiles","Search project markdown files…"):l==="tasks"?t("documents.searchTaskDocuments","Search task documents…"):t("documents.searchArtifacts","Search artifacts…");return e.jsxs("div",{className:"documents-view",children:[e.jsxs("div",{className:"documents-view-header",children:[e.jsx(Gt,{icon:ce,title:t("documents.title","Artifacts"),actions:e.jsx("span",{className:"documents-view-count",children:t("documents.resultCount","{{count}} result{{plural}}",{count:$e,plural:$e!==1?"s":""})})}),e.jsxs("div",{className:"documents-controls-row",children:[e.jsxs("div",{className:"documents-tab-bar",role:"tablist","aria-label":t("documents.sectionsLabel","Documents sections"),children:[e.jsxs("button",{className:`btn documents-tab${l==="artifacts"?" active":""}`,role:"tab","aria-selected":l==="artifacts","aria-label":t("documents.showArtifacts","Show artifacts"),onClick:()=>ye("artifacts"),children:[t("documents.artifactsTab","Artifacts"),e.jsx("span",{className:"documents-tab-count",children:O.length})]}),e.jsxs("button",{className:`btn documents-tab${l==="project"?" active":""}`,role:"tab","aria-selected":l==="project","aria-label":t("documents.showProjectFiles","Show project markdown files"),onClick:()=>ye("project"),children:[t("documents.projectFilesTab","Project Files"),e.jsx("span",{className:"documents-tab-count",children:G.length})]}),e.jsxs("button",{className:`btn documents-tab${l==="tasks"?" active":""}`,role:"tab","aria-selected":l==="tasks","aria-label":t("documents.showTaskDocuments","Show task documents"),onClick:()=>ye("tasks"),children:[t("documents.taskDocumentsTab","Task Documents"),e.jsx("span",{className:"documents-tab-count",children:Y.length})]})]}),l==="project"&&e.jsxs("button",{className:"btn btn-sm documents-hidden-toggle",onClick:()=>E(s=>!s),"aria-pressed":N,"aria-label":N?t("documents.hideHidden","Hide hidden project files"):t("documents.showHidden","Show hidden project files"),title:N?t("documents.hideHiddenFiles","Hide hidden files"):t("documents.showHiddenFiles","Show hidden files"),children:[N?e.jsx(Wt,{size:14}):e.jsx(Kt,{size:14}),N?t("documents.hideHiddenLabel","Hide Hidden"):t("documents.showHiddenLabel","Show Hidden")]}),e.jsxs("div",{className:"documents-search",children:[e.jsx(Yt,{size:16,className:"documents-search-icon"}),e.jsx("input",{type:"text",className:"documents-search-input",placeholder:Be,value:u,onChange:pt,"aria-label":Be}),u&&e.jsx("button",{className:"documents-search-clear",onClick:jt,"aria-label":t("documents.clearSearch","Clear search"),children:e.jsx(Xt,{size:16})})]})]})]}),e.jsx("div",{className:"documents-view-content",children:ze?e.jsxs("div",{className:"documents-view-error",children:[e.jsx("p",{children:t("documents.failedToLoad","Failed to load {{type}}: {{error}}",{type:l==="project"?t("documents.projectFiles","project files"):l==="tasks"?t("documents.taskDocuments","task documents"):t("documents.artifacts","artifacts"),error:ze})}),e.jsxs("button",{className:"btn btn-primary",onClick:()=>void Dt(),"aria-label":t("documents.retryLoading","Retry loading documents"),children:[e.jsx(Jt,{size:16}),t("documents.retry","Retry")]})]}):l==="project"?mt&&G.length===0?e.jsx("div",{className:"documents-view-loading",children:e.jsx("p",{children:e.jsx(ke,{label:t("documents.loadingProjectFiles","Loading project markdown files…")})})}):Ce.length===0?e.jsx("div",{className:"documents-view-empty",children:u.trim()?e.jsx("p",{children:t("documents.noMatchProject",'No project markdown files match "{{query}}".',{query:u.trim()})}):e.jsxs(e.Fragment,{children:[e.jsx(ce,{size:48,className:"documents-view-empty-icon"}),e.jsx("p",{children:t("documents.noMarkdownFiles","No Markdown files found in this project.")})]})}):e.jsxs("div",{className:`documents-project-layout${C?" documents-project-layout--mobile":""}`,children:[(!C||!p)&&e.jsx("aside",{className:"documents-view-sidebar","aria-label":t("documents.projectMarkdownFilesLabel","Project markdown files"),children:e.jsx("ul",{className:"markdown-file-list",children:Ce.map(s=>{const c=p?.path===s.path;return e.jsx("li",{className:"markdown-file-list-item",children:e.jsxs("button",{className:`markdown-file-item${c?" markdown-file-item--selected":""}`,onClick:()=>void bt(s),"aria-label":`Open ${s.path}`,"aria-current":c?"true":void 0,children:[e.jsx("span",{className:"markdown-file-item-name",children:s.name}),e.jsx("span",{className:"markdown-file-item-path",children:s.path}),e.jsxs("span",{className:"markdown-file-item-meta",children:[fs(s.size)," · ",oe(s.mtime)]})]})},s.path)})})}),(!C||p)&&e.jsxs("section",{className:"documents-view-main","aria-label":t("documents.projectFilePreviewLabel","Project file content preview"),children:[C&&p&&e.jsxs("button",{className:"btn btn-sm documents-mobile-back",onClick:wt,"aria-label":t("documents.backToFilesList","Back to project files list"),children:[e.jsx(Ge,{size:14}),t("documents.backToFiles","Back to files")]}),p?e.jsxs("div",{className:"documents-content-viewer",children:[e.jsxs("div",{className:"documents-content-header",children:[e.jsx("p",{className:"documents-file-path-header",children:p.path}),e.jsx("div",{className:"documents-task-document-actions",children:be?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn btn-sm",onClick:vt,disabled:we,children:t("documents.cancelEdit","Cancel")}),e.jsx("button",{className:"btn btn-sm btn-primary",onClick:()=>void Nt(),disabled:we,children:we?t("documents.saving","Saving…"):t("documents.saveProjectFile","Save")})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn btn-sm document-mode-toggle",onClick:()=>Me(s=>!s),"aria-label":K?t("documents.switchToPlainText","Switch to plain text"):t("documents.switchToMarkdown","Switch to markdown"),"aria-pressed":K,title:K?t("documents.switchToPlainText","Switch to plain text"):t("documents.switchToMarkdown","Switch to markdown"),children:K?t("documents.markdown","Markdown"):t("documents.plain","Plain")}),e.jsxs("button",{className:"btn btn-sm",onClick:gt,disabled:J||Z!==null||b===null,"aria-label":t("documents.editProjectFile","Edit project file"),children:[e.jsx(We,{size:14,"aria-hidden":"true"}),t("documents.edit","Edit")]})]})})]}),J?e.jsx("p",{className:"documents-content-state",children:e.jsx(ke,{label:t("documents.loadingFileContent","Loading file content…")})}):Z?e.jsx("p",{className:"documents-content-state documents-content-state--error",children:Z}):be?e.jsx("div",{className:"documents-task-document-editor","aria-label":t("documents.projectFileContentEditor","Project file content editor"),children:e.jsx(Ke,{content:ue,onChange:U,filePath:p.path,forceToolbarActionsVisible:!0})}):K?e.jsx("div",{ref:W,className:"documents-content-markdown",children:e.jsx("div",{className:"markdown-body",children:e.jsx(Ee,{remarkPlugins:[De],children:b??""})})}):e.jsx("pre",{ref:ie,className:"document-card-content-text documents-content-viewer-text",children:b??""}),Lt]}):e.jsx("div",{className:"documents-view-empty",children:e.jsx("p",{children:t("documents.selectFile","Select a Markdown file to view its content.")})})]})]}):l==="artifacts"?ft&&O.length===0?e.jsx("div",{className:"documents-view-loading",children:e.jsx("p",{children:t("documents.loadingArtifacts","Loading artifacts…")})}):O.length===0?e.jsx("div",{className:"documents-view-empty",children:u.trim()?e.jsx("p",{children:t("documents.noMatchArtifacts",'No artifacts match "{{query}}".',{query:u.trim()})}):e.jsxs(e.Fragment,{children:[e.jsx(ce,{size:48,className:"documents-view-empty-icon"}),e.jsx("p",{children:t("documents.noArtifacts","No artifacts yet.")}),e.jsx("p",{className:"documents-view-empty-hint",children:t("documents.artifactsCreatedBy","Agents register screenshots, wireframes, mockups, recordings, and documents here as they work on tasks.")})]})}):e.jsx(Zt,{artifacts:O,projectId:a,isMobile:C,addToast:m,onOpenTask:Oe,onArtifactUpdated:()=>void Se()}):dt&&se.length===0?e.jsx("div",{className:"documents-view-loading",children:e.jsx("p",{children:e.jsx(ke,{label:t("documents.loadingTaskDocuments","Loading task documents…")})})}):Y.length===0?e.jsx("div",{className:"documents-view-empty",children:u.trim()?e.jsx("p",{children:t("documents.noMatchTask",'No task documents match "{{query}}".',{query:u.trim()})}):e.jsxs(e.Fragment,{children:[e.jsx(ce,{size:48,className:"documents-view-empty-icon"}),e.jsx("p",{children:t("documents.noTaskDocuments","No task documents yet.")}),e.jsx("p",{className:"documents-view-empty-hint",children:t("documents.documentsCreatedIn","Documents are created in task detail tabs.")})]})}):e.jsxs("div",{className:`documents-project-layout documents-task-documents-layout${C?" documents-project-layout--mobile":""}`,children:[(!C||!he)&&e.jsx("aside",{className:"documents-view-sidebar documents-task-documents-sidebar","aria-label":t("documents.taskDocumentsListLabel","Task documents"),children:Y.map(({taskId:s,taskTitle:c,taskColumn:o,documents:x,artifacts:$})=>{const V=o?A(o):null,Ae=o?ks(o,d?.get(s)):"status-dot";return e.jsxs("section",{className:"documents-task-sidebar-group","aria-labelledby":`documents-task-group-${s}`,children:[e.jsxs("div",{className:"documents-task-sidebar-group-header",children:[e.jsxs("div",{className:"documents-task-sidebar-title-wrap",children:[e.jsxs("h3",{id:`documents-task-group-${s}`,className:"documents-task-sidebar-title",children:[e.jsx("span",{className:"documents-group-task-id",children:s}),e.jsx("span",{className:"documents-group-task-title",children:c||t("documents.untitled","Untitled")})]}),V?e.jsxs("span",{className:"documents-group-status badge","aria-label":t("documents.taskStatusAria","Task status: {{status}}",{status:V}),children:[e.jsx("span",{className:Ae,"aria-hidden":"true"}),e.jsx("span",{children:V})]}):null]}),e.jsxs("div",{className:"documents-task-sidebar-actions",children:[e.jsx("span",{className:"documents-group-count",children:t("documents.taskOutputCount","{{docCount}} doc{{docPlural}} · {{artifactCount}} artifact{{artifactPlural}}",{docCount:x.length,docPlural:x.length!==1?"s":"",artifactCount:$.length,artifactPlural:$.length!==1?"s":""})}),e.jsx("button",{className:"documents-group-task-link",onClick:()=>void xt(s),"aria-label":t("documents.openTaskAria","Open task {{taskId}}: {{title}}",{taskId:s,title:c||t("documents.untitled","Untitled")}),children:t("documents.openTask","Open task")})]})]}),e.jsxs("ul",{className:"markdown-file-list documents-task-document-list",children:[x.map(k=>{const g=i?.id===k.id;return e.jsx("li",{className:"markdown-file-list-item",children:e.jsxs("button",{className:`markdown-file-item documents-task-document-item${g?" markdown-file-item--selected":""}`,onClick:()=>St(k.id),"aria-label":t("documents.openTaskDocument","Open {{taskId}} {{key}}",{taskId:k.taskId,key:k.key}),"aria-current":g?"true":void 0,children:[e.jsx("span",{className:"markdown-file-item-name",children:k.key}),e.jsxs("span",{className:"markdown-file-item-path",children:[k.taskId," · ",k.taskTitle||t("documents.untitled","Untitled")]}),e.jsxs("span",{className:"markdown-file-item-meta",children:[t("documents.revisionShort","v{{revision}}",{revision:k.revision})," · ",k.author," · ",oe(k.updatedAt)]})]})},`document-${k.id}`)}),$.length>0?e.jsxs("li",{className:"documents-task-artifacts-subsection","aria-label":t("documents.taskArtifactsSubsection","Task artifacts"),children:[e.jsx("div",{className:"documents-task-artifacts-label",children:t("documents.taskArtifactsLabel","Artifacts")}),e.jsx("ul",{className:"markdown-file-list documents-task-artifact-list",children:$.map(k=>{const g=Pe(k),ae=hs[g],Rt=Je(t,g),Ue=z?.id===k.id;return e.jsx("li",{className:"markdown-file-list-item",children:e.jsxs("button",{className:`markdown-file-item documents-task-document-item documents-task-artifact-item${Ue?" markdown-file-item--selected":""}`,onClick:()=>Ct(k.id),"aria-label":t("documents.openTaskArtifact","Open {{taskId}} artifact {{title}}",{taskId:s,title:k.title||t("documents.untitledArtifact","Untitled artifact")}),"aria-current":Ue?"true":void 0,children:[e.jsxs("span",{className:"documents-task-artifact-title-row",children:[e.jsx(ae,{size:14,"aria-hidden":"true"}),e.jsx("span",{className:"markdown-file-item-name",children:k.title||t("documents.untitledArtifact","Untitled artifact")})]}),e.jsxs("span",{className:"markdown-file-item-path",children:[Rt," · ",k.mimeType||k.type]}),e.jsxs("span",{className:"markdown-file-item-meta",children:[k.authorId||t("documents.unknownAuthor","unknown")," · ",oe(k.updatedAt)]})]})},`artifact-${k.id}`)})})]}):null]})]},s)})}),(!C||he)&&e.jsxs("section",{className:"documents-view-main","aria-label":t("documents.taskDocumentPreviewLabel","Task document content preview"),children:[C&&he&&e.jsxs("button",{className:"btn btn-sm documents-mobile-back",onClick:yt,"aria-label":t("documents.backToTaskDocumentsList","Back to task documents list"),children:[e.jsx(Ge,{size:14}),t("documents.backToTaskDocuments","Back to documents")]}),he?z?e.jsx(bs,{artifact:z,projectId:a,content:tt,loading:st,error:nt,renderMarkdown:at,onToggleMarkdown:()=>xe(s=>!s),onOpenTask:Oe,t}):i?e.jsxs("div",{className:"documents-content-viewer documents-task-document-viewer",children:[e.jsxs("div",{className:"documents-content-header documents-task-document-header",children:[e.jsxs("p",{className:"documents-file-path-header",children:[i.taskId," / ",i.key]}),e.jsx("div",{className:"documents-task-document-actions",children:Fe?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn btn-sm",onClick:At,disabled:de,children:t("documents.cancelEdit","Cancel")}),q&&e.jsx("button",{className:"btn btn-sm",onClick:Pt,disabled:de,children:t("documents.rebaseTaskDocument","Rebase draft")}),e.jsx("button",{className:"btn btn-sm btn-primary",onClick:()=>void Et(),disabled:de||q!==null,children:de?t("documents.saving","Saving…"):t("documents.saveTaskDocument","Save")})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn btn-sm document-mode-toggle",onClick:()=>Tt(i.id),"aria-label":X?t("documents.switchToPlainText","Switch to plain text"):t("documents.switchToMarkdown","Switch to markdown"),"aria-pressed":X,title:X?t("documents.switchToPlainText","Switch to plain text"):t("documents.switchToMarkdown","Switch to markdown"),children:X?t("documents.markdown","Markdown"):t("documents.plain","Plain")}),e.jsxs("button",{className:"btn btn-sm",onClick:Ft,"aria-label":t("documents.editTaskDocument","Edit task document"),children:[e.jsx(We,{size:14,"aria-hidden":"true"}),t("documents.edit","Edit")]})]})})]}),e.jsxs("div",{className:"document-card-meta documents-task-document-meta",children:[e.jsx("span",{className:"document-card-author",children:i.author}),e.jsx("span",{className:"document-card-separator",children:"·"}),e.jsx("span",{children:t("documents.revisionShort","v{{revision}}",{revision:i.revision})}),e.jsx("span",{className:"document-card-separator",children:"·"}),e.jsx("span",{className:"document-card-date",children:oe(i.updatedAt)})]}),Fe?e.jsx("div",{className:"documents-task-document-editor","aria-label":t("documents.taskDocumentContentEditor","Task document content editor"),children:e.jsx(Ke,{content:pe,onChange:L,filePath:i.key.includes(".")?i.key:`${i.key}.md`,forceToolbarActionsVisible:!0})}):X?e.jsx("div",{ref:ee,className:"documents-content-markdown",children:e.jsx("div",{className:"markdown-body",children:e.jsx(Ee,{remarkPlugins:[De],children:i.content})})}):e.jsx("pre",{ref:Le,className:"document-card-content-text documents-content-viewer-text",children:i.content}),Mt]}):null:e.jsx("div",{className:"documents-view-empty",children:e.jsx("p",{children:t("documents.selectTaskDocument","Select a task document or artifact to view its content.")})})]})]})})]})}export{ys as DocumentsView,ks as getTaskColumnStatusDotClass};
@@ -1 +1 @@
1
- import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{r as P,e as L,S as $,aW as Z,aX as J,b as O,aY as Q,aZ as ee,a_ as se,V as H,T as K,a3 as ae,R as te,aK as le,s as re,q as ne,aU as ie}from"./index-I32FijPT.js";import{u as ce}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";const oe=300,de=15e3;function X(r){if(!r.trim())return;const a=Number(r);return Number.isFinite(a)?a:void 0}function I(...r){for(const a of r)if(Array.isArray(a))return a;return[]}function f(r){return typeof r=="object"&&r!==null?r:{}}function B(r){const a=f(r),m=f(a.taskSnapshot);return{id:String(a.id??a.evalId??""),runId:String(a.runId??a.batchId??""),taskId:String(a.taskId??m.taskId??""),taskTitle:String(m.title??a.taskTitle??a.title??"Untitled task"),createdAt:String(a.createdAt??a.timestamp??a.updatedAt??new Date(0).toISOString()),overallScore:typeof a.overallScore=="number"?a.overallScore:null,maxScore:typeof a.maxScore=="number"?a.maxScore:null,categoryScores:I(a.categoryScores,f(a.scores).categories)}}function ue(r){const a=f(r);return{...B(a),rationale:String(a.rationale??a.summary??""),evidence:I(a.evidence,f(a.details).evidence),followUps:I(a.followUps,f(a.recommendations).followUps)}}function ve(r){const a=r?.projectId,m=a??"",t=`${$.EVALS_RUNS_PREFIX}${m}`,h=`${$.EVALS_RESULTS_PREFIX}${m}`,p=P(t,{maxAgeMs:L}),v=P(h,{maxAgeMs:L}),S=l.useRef(Array.isArray(p)&&p.length>0||Array.isArray(v)&&v.length>0),[o,g]=l.useState({q:"",runId:"",scoreMin:"",scoreMax:""}),[N,w]=l.useState(()=>Array.isArray(p)?p:[]),[d,C]=l.useState(()=>Array.isArray(v)?v:[]),[u,A]=l.useState(null),[F,R]=l.useState(null),[s,i]=l.useState(0),[y,j]=l.useState(!S.current),[W,q]=l.useState(null),M=l.useRef(0),z=l.useRef(a),_=l.useRef(u);_.current=u;const k=l.useCallback(async()=>{const c=++M.current;S.current||j(!0),q(null);try{const[n,x]=await Promise.all([Z({q:o.q||void 0,runId:o.runId||void 0,scoreMin:X(o.scoreMin),scoreMax:X(o.scoreMax),limit:100,offset:0},a),J(a)]);if(c!==M.current)return;const E=I(n.results,n.evals,n.items).map(B);C(E),O(h,E.length>500?E.slice(0,500):E,{maxBytes:5e5}),i(typeof n.count=="number"?n.count:E.length);const V=I(x.runs,x.items).map(U=>{const b=f(U),D=f(b.counts);return{id:String(b.id??""),createdAt:String(b.createdAt??""),completedAt:typeof b.completedAt=="string"?b.completedAt:void 0,status:String(b.status??"pending"),evaluatedTaskCount:typeof D.totalTasks=="number"?D.totalTasks:0}});w(V),O(t,V,{maxBytes:5e5}),S.current=!0,_.current&&!E.some(U=>U.id===_.current)&&(A(null),R(null))}catch(n){if(c!==M.current)return;q(n instanceof Error?n.message:"Failed to load evals")}finally{c===M.current&&j(!1)}},[o.q,o.runId,o.scoreMax,o.scoreMin,a,h,t]),T=l.useCallback(async c=>{const n=await Q(c,a),x=n.result??n;R(ue(x))},[a]);l.useEffect(()=>{if(z.current===a)return;z.current=a;const c=P(t,{maxAgeMs:L}),n=P(h,{maxAgeMs:L}),x=Array.isArray(c)&&c.length>0||Array.isArray(n)&&n.length>0;w(Array.isArray(c)?c:[]),C(Array.isArray(n)?n:[]),j(!x),S.current=x},[a,h,t]),l.useEffect(()=>{const c=window.setTimeout(()=>{k()},oe);return()=>window.clearTimeout(c)},[k]),l.useEffect(()=>{if(!u){R(null);return}T(u)},[T,u]);const Y=l.useCallback(()=>{k(),u&&T(u)},[T,k,u]);ee(Y,de);const G=l.useCallback(c=>{_.current=c,A(c)},[]);return{loading:y,error:W,results:d,count:s,runs:N,filters:o,setFilters:g,refresh:k,selectedEvalId:u,setSelectedEvalId:G,selectedEval:F}}function je({projectId:r,onOpenSettings:a,onOpenTaskDetail:m}){const{t}=ce("app"),{loading:h,error:p,results:v,runs:S,filters:o,setFilters:g,selectedEvalId:N,setSelectedEvalId:w,selectedEval:d,refresh:C}=ve({projectId:r}),[u,A]=l.useState(!0);l.useEffect(()=>{let s=!1;return se(r).then(i=>{if(s)return;const y=i.evalSettings?.enabled;A(y??!1)}).catch(()=>{s||A(!1)}),()=>{s=!0}},[r]);const F=v.length>0,R=l.useMemo(()=>v.find(s=>s.id===N)??null,[v,N]);return u?e.jsxs("section",{className:"evals-view","data-testid":"evals-view",children:[e.jsx(H,{icon:K,title:t("evals.title","Evals")}),e.jsxs("div",{className:"evals-view__body",children:[e.jsxs("div",{className:"evals-list card",children:[e.jsxs("div",{className:"evals-toolbar",children:[e.jsx("input",{className:"input",placeholder:t("evals.searchPlaceholder","Search task or rationale"),value:o.q,onChange:s=>g(i=>({...i,q:s.target.value}))}),e.jsxs("select",{className:"select",value:o.runId,onChange:s=>g(i=>({...i,runId:s.target.value})),children:[e.jsx("option",{value:"",children:t("evals.allRuns","All runs")}),S.map(s=>e.jsx("option",{value:s.id,children:s.id},s.id))]}),e.jsx("input",{className:"input",placeholder:t("evals.minScorePlaceholder","Min score"),value:o.scoreMin,onChange:s=>g(i=>({...i,scoreMin:s.target.value}))}),e.jsx("input",{className:"input",placeholder:t("evals.maxScorePlaceholder","Max score"),value:o.scoreMax,onChange:s=>g(i=>({...i,scoreMax:s.target.value}))}),e.jsx("button",{className:"btn btn-icon",type:"button",onClick:()=>void C(),"aria-label":t("evals.refreshAria","Refresh evals"),children:e.jsx(te,{size:16})})]}),h&&e.jsx("p",{className:"evals-state","data-testid":"evals-loading",children:e.jsx(le,{label:t("evals.loading","Loading evals…")})}),p&&e.jsx("p",{className:"evals-state evals-state--error",children:p}),!h&&!p&&!F&&e.jsx("p",{className:"evals-state",children:t("evals.empty","No evals yet. Scheduled evals review tasks completed since the last run.")}),e.jsx("ul",{className:"evals-results","data-testid":"evals-results",children:v.map(s=>e.jsx("li",{children:e.jsxs("button",{className:`evals-result ${s.id===N?"evals-result--active":""}`,type:"button",onClick:()=>w(s.id),draggable:ne(),onDragStart:i=>{re(i.dataTransfer,{kind:"eval-result",id:s.id,projectId:r})},children:[e.jsx("span",{className:"evals-result-title",children:s.taskTitle}),e.jsxs("span",{className:"evals-result-meta",children:[s.taskId," · ",s.runId," · ",s.overallScore??t("evals.naPlaceholder","n/a")]})]})},s.id))})]}),e.jsxs("div",{className:"evals-detail card","data-testid":"evals-detail",children:[!d&&e.jsx("p",{className:"evals-state",children:t("evals.selectPrompt","Select an evaluation to inspect scores, rationale, and evidence.")}),d&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"evals-detail-title",children:R?.taskTitle??d.taskTitle}),e.jsxs("p",{className:"evals-result-meta",children:[d.taskId," · ",d.runId]}),e.jsx("p",{className:"evals-score",children:t("evals.overallScore","Overall score: {{score}}",{score:d.overallScore??t("evals.naPlaceholder","n/a")})}),e.jsx("ul",{className:"evals-categories",children:d.categoryScores.map(s=>e.jsxs("li",{children:[s.category,": ",s.finalScore]},s.category))}),e.jsx("p",{className:"evals-rationale",children:d.rationale||t("evals.noRationale","No rationale recorded.")}),e.jsxs("div",{children:[e.jsx("h4",{children:t("evals.evidenceHeading","Evidence")}),e.jsx("ul",{className:"evals-links",children:d.evidence.map((s,i)=>{const y=typeof s.metadata?.taskId=="string"?s.metadata.taskId:void 0,j=typeof s.metadata?.url=="string"?s.metadata.url:void 0;return e.jsx("li",{children:y?e.jsx("button",{type:"button",className:"btn",onClick:()=>m?.(y),children:s.ref}):j?e.jsxs("a",{href:j,target:"_blank",rel:"noreferrer",className:"evals-external-link",children:[s.ref,e.jsx(ie,{size:14})]}):e.jsx("span",{children:s.ref})},`${s.ref}-${i}`)})})]}),e.jsxs("div",{children:[e.jsx("h4",{children:t("evals.suggestedFollowupsHeading","Suggested follow-up tasks")}),e.jsxs("ul",{className:"evals-follow-ups",children:[d.followUps.length===0&&e.jsx("li",{children:t("evals.noFollowups","None")}),d.followUps.map(s=>e.jsxs("li",{children:[e.jsx("strong",{children:s.title}),e.jsx("p",{children:s.rationale})]},s.suggestionId))]})]})]})]})]})]}):e.jsxs("section",{className:"evals-view","data-testid":"evals-disabled",children:[e.jsx(H,{icon:K,title:t("evals.title","Evals")}),e.jsxs("div",{className:"evals-view__empty",children:[e.jsx("h2",{className:"evals-title",children:t("evals.disabledTitle","Scheduled evals are disabled")}),e.jsx("p",{className:"evals-empty-copy",children:t("evals.enablePrompt","Enable Scheduled Evals to review scored tasks, evidence, and follow-up recommendations.")}),e.jsxs("button",{className:"btn btn-primary",type:"button",onClick:()=>a?.("scheduled-evals"),children:[e.jsx(ae,{size:16}),t("evals.openSettings","Open Scheduled Evals Settings")]})]})]})}export{je as EvalsView};
1
+ import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{r as P,e as L,S as $,aW as Z,aX as J,b as O,aY as Q,aZ as ee,a_ as se,V as H,T as K,a3 as ae,R as te,aK as le,s as re,q as ne,aU as ie}from"./index-oxnX59eO.js";import{u as ce}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";const oe=300,de=15e3;function X(r){if(!r.trim())return;const a=Number(r);return Number.isFinite(a)?a:void 0}function I(...r){for(const a of r)if(Array.isArray(a))return a;return[]}function f(r){return typeof r=="object"&&r!==null?r:{}}function B(r){const a=f(r),m=f(a.taskSnapshot);return{id:String(a.id??a.evalId??""),runId:String(a.runId??a.batchId??""),taskId:String(a.taskId??m.taskId??""),taskTitle:String(m.title??a.taskTitle??a.title??"Untitled task"),createdAt:String(a.createdAt??a.timestamp??a.updatedAt??new Date(0).toISOString()),overallScore:typeof a.overallScore=="number"?a.overallScore:null,maxScore:typeof a.maxScore=="number"?a.maxScore:null,categoryScores:I(a.categoryScores,f(a.scores).categories)}}function ue(r){const a=f(r);return{...B(a),rationale:String(a.rationale??a.summary??""),evidence:I(a.evidence,f(a.details).evidence),followUps:I(a.followUps,f(a.recommendations).followUps)}}function ve(r){const a=r?.projectId,m=a??"",t=`${$.EVALS_RUNS_PREFIX}${m}`,h=`${$.EVALS_RESULTS_PREFIX}${m}`,p=P(t,{maxAgeMs:L}),v=P(h,{maxAgeMs:L}),S=l.useRef(Array.isArray(p)&&p.length>0||Array.isArray(v)&&v.length>0),[o,g]=l.useState({q:"",runId:"",scoreMin:"",scoreMax:""}),[N,w]=l.useState(()=>Array.isArray(p)?p:[]),[d,C]=l.useState(()=>Array.isArray(v)?v:[]),[u,A]=l.useState(null),[F,R]=l.useState(null),[s,i]=l.useState(0),[y,j]=l.useState(!S.current),[W,q]=l.useState(null),M=l.useRef(0),z=l.useRef(a),_=l.useRef(u);_.current=u;const k=l.useCallback(async()=>{const c=++M.current;S.current||j(!0),q(null);try{const[n,x]=await Promise.all([Z({q:o.q||void 0,runId:o.runId||void 0,scoreMin:X(o.scoreMin),scoreMax:X(o.scoreMax),limit:100,offset:0},a),J(a)]);if(c!==M.current)return;const E=I(n.results,n.evals,n.items).map(B);C(E),O(h,E.length>500?E.slice(0,500):E,{maxBytes:5e5}),i(typeof n.count=="number"?n.count:E.length);const V=I(x.runs,x.items).map(U=>{const b=f(U),D=f(b.counts);return{id:String(b.id??""),createdAt:String(b.createdAt??""),completedAt:typeof b.completedAt=="string"?b.completedAt:void 0,status:String(b.status??"pending"),evaluatedTaskCount:typeof D.totalTasks=="number"?D.totalTasks:0}});w(V),O(t,V,{maxBytes:5e5}),S.current=!0,_.current&&!E.some(U=>U.id===_.current)&&(A(null),R(null))}catch(n){if(c!==M.current)return;q(n instanceof Error?n.message:"Failed to load evals")}finally{c===M.current&&j(!1)}},[o.q,o.runId,o.scoreMax,o.scoreMin,a,h,t]),T=l.useCallback(async c=>{const n=await Q(c,a),x=n.result??n;R(ue(x))},[a]);l.useEffect(()=>{if(z.current===a)return;z.current=a;const c=P(t,{maxAgeMs:L}),n=P(h,{maxAgeMs:L}),x=Array.isArray(c)&&c.length>0||Array.isArray(n)&&n.length>0;w(Array.isArray(c)?c:[]),C(Array.isArray(n)?n:[]),j(!x),S.current=x},[a,h,t]),l.useEffect(()=>{const c=window.setTimeout(()=>{k()},oe);return()=>window.clearTimeout(c)},[k]),l.useEffect(()=>{if(!u){R(null);return}T(u)},[T,u]);const Y=l.useCallback(()=>{k(),u&&T(u)},[T,k,u]);ee(Y,de);const G=l.useCallback(c=>{_.current=c,A(c)},[]);return{loading:y,error:W,results:d,count:s,runs:N,filters:o,setFilters:g,refresh:k,selectedEvalId:u,setSelectedEvalId:G,selectedEval:F}}function je({projectId:r,onOpenSettings:a,onOpenTaskDetail:m}){const{t}=ce("app"),{loading:h,error:p,results:v,runs:S,filters:o,setFilters:g,selectedEvalId:N,setSelectedEvalId:w,selectedEval:d,refresh:C}=ve({projectId:r}),[u,A]=l.useState(!0);l.useEffect(()=>{let s=!1;return se(r).then(i=>{if(s)return;const y=i.evalSettings?.enabled;A(y??!1)}).catch(()=>{s||A(!1)}),()=>{s=!0}},[r]);const F=v.length>0,R=l.useMemo(()=>v.find(s=>s.id===N)??null,[v,N]);return u?e.jsxs("section",{className:"evals-view","data-testid":"evals-view",children:[e.jsx(H,{icon:K,title:t("evals.title","Evals")}),e.jsxs("div",{className:"evals-view__body",children:[e.jsxs("div",{className:"evals-list card",children:[e.jsxs("div",{className:"evals-toolbar",children:[e.jsx("input",{className:"input",placeholder:t("evals.searchPlaceholder","Search task or rationale"),value:o.q,onChange:s=>g(i=>({...i,q:s.target.value}))}),e.jsxs("select",{className:"select",value:o.runId,onChange:s=>g(i=>({...i,runId:s.target.value})),children:[e.jsx("option",{value:"",children:t("evals.allRuns","All runs")}),S.map(s=>e.jsx("option",{value:s.id,children:s.id},s.id))]}),e.jsx("input",{className:"input",placeholder:t("evals.minScorePlaceholder","Min score"),value:o.scoreMin,onChange:s=>g(i=>({...i,scoreMin:s.target.value}))}),e.jsx("input",{className:"input",placeholder:t("evals.maxScorePlaceholder","Max score"),value:o.scoreMax,onChange:s=>g(i=>({...i,scoreMax:s.target.value}))}),e.jsx("button",{className:"btn btn-icon",type:"button",onClick:()=>void C(),"aria-label":t("evals.refreshAria","Refresh evals"),children:e.jsx(te,{size:16})})]}),h&&e.jsx("p",{className:"evals-state","data-testid":"evals-loading",children:e.jsx(le,{label:t("evals.loading","Loading evals…")})}),p&&e.jsx("p",{className:"evals-state evals-state--error",children:p}),!h&&!p&&!F&&e.jsx("p",{className:"evals-state",children:t("evals.empty","No evals yet. Scheduled evals review tasks completed since the last run.")}),e.jsx("ul",{className:"evals-results","data-testid":"evals-results",children:v.map(s=>e.jsx("li",{children:e.jsxs("button",{className:`evals-result ${s.id===N?"evals-result--active":""}`,type:"button",onClick:()=>w(s.id),draggable:ne(),onDragStart:i=>{re(i.dataTransfer,{kind:"eval-result",id:s.id,projectId:r})},children:[e.jsx("span",{className:"evals-result-title",children:s.taskTitle}),e.jsxs("span",{className:"evals-result-meta",children:[s.taskId," · ",s.runId," · ",s.overallScore??t("evals.naPlaceholder","n/a")]})]})},s.id))})]}),e.jsxs("div",{className:"evals-detail card","data-testid":"evals-detail",children:[!d&&e.jsx("p",{className:"evals-state",children:t("evals.selectPrompt","Select an evaluation to inspect scores, rationale, and evidence.")}),d&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"evals-detail-title",children:R?.taskTitle??d.taskTitle}),e.jsxs("p",{className:"evals-result-meta",children:[d.taskId," · ",d.runId]}),e.jsx("p",{className:"evals-score",children:t("evals.overallScore","Overall score: {{score}}",{score:d.overallScore??t("evals.naPlaceholder","n/a")})}),e.jsx("ul",{className:"evals-categories",children:d.categoryScores.map(s=>e.jsxs("li",{children:[s.category,": ",s.finalScore]},s.category))}),e.jsx("p",{className:"evals-rationale",children:d.rationale||t("evals.noRationale","No rationale recorded.")}),e.jsxs("div",{children:[e.jsx("h4",{children:t("evals.evidenceHeading","Evidence")}),e.jsx("ul",{className:"evals-links",children:d.evidence.map((s,i)=>{const y=typeof s.metadata?.taskId=="string"?s.metadata.taskId:void 0,j=typeof s.metadata?.url=="string"?s.metadata.url:void 0;return e.jsx("li",{children:y?e.jsx("button",{type:"button",className:"btn",onClick:()=>m?.(y),children:s.ref}):j?e.jsxs("a",{href:j,target:"_blank",rel:"noreferrer",className:"evals-external-link",children:[s.ref,e.jsx(ie,{size:14})]}):e.jsx("span",{children:s.ref})},`${s.ref}-${i}`)})})]}),e.jsxs("div",{children:[e.jsx("h4",{children:t("evals.suggestedFollowupsHeading","Suggested follow-up tasks")}),e.jsxs("ul",{className:"evals-follow-ups",children:[d.followUps.length===0&&e.jsx("li",{children:t("evals.noFollowups","None")}),d.followUps.map(s=>e.jsxs("li",{children:[e.jsx("strong",{children:s.title}),e.jsx("p",{children:s.rationale})]},s.suggestionId))]})]})]})]})]})]}):e.jsxs("section",{className:"evals-view","data-testid":"evals-disabled",children:[e.jsx(H,{icon:K,title:t("evals.title","Evals")}),e.jsxs("div",{className:"evals-view__empty",children:[e.jsx("h2",{className:"evals-title",children:t("evals.disabledTitle","Scheduled evals are disabled")}),e.jsx("p",{className:"evals-empty-copy",children:t("evals.enablePrompt","Enable Scheduled Evals to review scored tasks, evidence, and follow-up recommendations.")}),e.jsxs("button",{className:"btn btn-primary",type:"button",onClick:()=>a?.("scheduled-evals"),children:[e.jsx(ae,{size:16}),t("evals.openSettings","Open Scheduled Evals Settings")]})]})]})}export{je as EvalsView};
@@ -1 +1 @@
1
- import{r as s,j as e}from"./vendor-react-SZ_qB27O.js";import{I as F,J as K,K as V,N as W,O as $,Q as z,U}from"./index-I32FijPT.js";import{u as J}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";function te({isOpen:l,onClose:R,onUseDraft:M,projectId:x,existingAgents:P,mode:w="create",existingAgentConfig:L}){const{t:n}=J("app"),[g,d]=s.useState("initial"),[f,_]=s.useState(""),[c,S]=s.useState(null),[C,I]=s.useState(""),[k,A]=s.useState("answer"),[p,v]=s.useState(""),[t,H]=s.useState(null),[T,h]=s.useState(null),[E,y]=s.useState([]),b=w==="edit",o=s.useRef(l),N=s.useCallback(()=>{d("initial"),_(""),S(null),I(""),A("answer"),v(""),H(null),h(null),y([])},[]),O=s.useMemo(()=>F.map(a=>({id:a.id,label:a.name,description:a.description})),[]);s.useEffect(()=>{if(o.current=l,!c)return;const a=K(c,x,{onThinking:r=>{o.current&&y(G=>{const u=[...G],j=u[u.length-1];return j&&!j.question?(u[u.length-1]={...j,thinkingOutput:`${j.thinkingOutput??""}${r}`},u):[...u,{response:{},thinkingOutput:r}]})},onQuestion:r=>{o.current&&(I(r.question),A(r.id),d("question"))},onSummary:r=>{o.current&&(H(r),d("summary"))},onError:r=>{o.current&&(h(r),d("error"))}});return()=>{o.current=!1,a.close()}},[l,c,x]);const m=async()=>{o.current=!1;try{c&&await $(c,x)}catch{}finally{N(),R()}};if(s.useEffect(()=>{o.current=l,l||N()},[l,N]),!l)return null;const i=a=>a==null||a===""?e.jsx("em",{className:"experimental-agent-onboarding-modal__summary-empty",children:n("agents.onboarding.notSet","Not set")}):e.jsx("span",{children:a}),Q=async()=>{d("loading"),h(null);try{const a=await z(f,{mode:w,existingAgentConfig:L,existingAgents:P.map(r=>({id:r.id,name:r.name,role:r.role})),templates:O},x);if(!o.current)return;S(a.sessionId)}catch(a){if(!o.current)return;h(a.message),d("error")}},q=async()=>{if(c){d("loading"),h(null);try{const a={[k]:p};if(y(r=>[...r,{question:{id:k,type:"text",question:C},response:a}]),await U(c,a,x),!o.current)return;v("")}catch(a){if(!o.current)return;h(a.message),d("error")}}},D=async()=>{t&&(M(t),await m())};return e.jsx(V,{windowKey:"experimental-agent-onboarding",modal:!0,title:n("agents.onboarding.title","AI Interview"),ariaLabel:n("agents.onboarding.dialogLabel","AI Interview"),onClose:()=>void m(),hideHeader:!0,dragHandleSelector:".experimental-agent-onboarding-modal .modal-header",className:"floating-window--experimental-agent-onboarding",defaultSize:{width:720,height:620},minSize:{width:420,height:320},persistGeometryKey:"floating-window:experimental-agent-onboarding",suspendGeometryPersistenceOnMobile:!0,suspendGeometryPersistenceOnShortViewport:!0,children:e.jsxs("div",{className:"modal modal-lg experimental-agent-onboarding-modal",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:n("agents.onboarding.title","AI Interview")}),e.jsx("button",{className:"modal-close",onClick:()=>void m(),"aria-label":n("common.closeAriaLabel","Close"),children:"×"})]}),E.length>0&&e.jsx(W,{entries:E}),g==="initial"&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"agent-onboarding-intent",children:b?n("agents.onboarding.intentLabelEdit","What should this agent change or improve?"):n("agents.onboarding.intentLabelCreate","What should this new agent own?")}),e.jsx("textarea",{id:"agent-onboarding-intent",className:"input experimental-agent-onboarding-modal__textarea",value:f,onChange:a=>_(a.target.value)}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn",onClick:()=>void m(),children:n("common.cancel","Cancel")}),e.jsx("button",{className:"btn btn-primary",disabled:!f.trim(),onClick:()=>void Q(),children:b?n("agents.onboarding.startInterview","Start interview"):n("agents.onboarding.startOnboarding","Start onboarding")})]})]}),(g==="loading"||g==="question")&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"agent-onboarding-answer",children:C||n("agents.onboarding.thinking","Thinking...")}),e.jsx("textarea",{id:"agent-onboarding-answer",className:"input experimental-agent-onboarding-modal__textarea",value:p,onChange:a=>v(a.target.value)}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn",onClick:()=>void m(),children:n("common.cancel","Cancel")}),e.jsx("button",{className:"btn btn-primary",disabled:g==="loading"||!p.trim(),onClick:()=>void q(),children:n("agents.onboarding.continue","Continue")})]})]}),g==="summary"&&t&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:b?n("agents.onboarding.updatedDraftReady","Updated draft ready for review"):n("agents.onboarding.draftReady","Draft ready for review")}),e.jsx("p",{className:"experimental-agent-onboarding-modal__summary-intro",children:n("agents.onboarding.draftIntro","Review this generated draft. Nothing is applied until you confirm.")}),e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary card",children:[e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[e.jsx("h4",{children:n("agents.onboarding.sectionIdentity","Identity")}),e.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldName","Name")}),e.jsx("dd",{children:i(t.name)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldRole","Role")}),e.jsx("dd",{children:i(t.role)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldTitle","Title")}),e.jsx("dd",{children:i(t.title)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldIcon","Icon")}),e.jsx("dd",{children:i(t.icon)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldReportsTo","Reports To")}),e.jsx("dd",{children:i(t.reportsTo)})]})]})]}),e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[e.jsx("h4",{children:n("agents.onboarding.sectionConfiguration","Configuration")}),e.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldInlineInstructions","Inline Instructions")}),e.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:i(t.instructionsText)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldSoul","Soul")}),e.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:i(t.soul)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldAgentMemory","Agent Memory")}),e.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:i(t.memory)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldSkills","Skills")}),e.jsx("dd",{children:i(t.skills?.join(", "))})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldThinkingLevel","Thinking Level")}),e.jsx("dd",{children:i(t.thinkingLevel)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldMaxTurns","Max Turns")}),e.jsx("dd",{children:i(t.maxTurns)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldTemplate","Template")}),e.jsx("dd",{children:i(t.templateId)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldPatternAgent","Pattern Agent")}),e.jsx("dd",{children:i(t.patternAgentId)})]})]})]}),(t.heartbeatProcedurePath||t.heartbeatIntervalMs||t.heartbeatEnabled!==void 0||t.modelHint||t.runtimeHint)&&e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[e.jsx("h4",{children:n("agents.onboarding.sectionRuntimeHints","Runtime Hints")}),e.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldHeartbeatPath","Heartbeat Procedure Path")}),e.jsx("dd",{children:i(t.heartbeatProcedurePath)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldHeartbeatInterval","Heartbeat Interval")}),e.jsx("dd",{children:i(t.heartbeatIntervalMs?`${t.heartbeatIntervalMs}ms`:void 0)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldHeartbeatEnabled","Heartbeat Enabled")}),e.jsx("dd",{children:i(t.heartbeatEnabled===void 0?void 0:t.heartbeatEnabled?n("agents.onboarding.yes","yes"):n("agents.onboarding.no","no"))})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldModelHint","Model Hint")}),e.jsx("dd",{children:i(t.modelHint)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldRuntimeHint","Runtime Hint")}),e.jsx("dd",{children:i(t.runtimeHint)})]})]})]}),t.rationale&&e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[e.jsx("h4",{children:n("agents.onboarding.sectionRationale","Rationale")}),e.jsx("p",{className:"experimental-agent-onboarding-modal__summary-block",children:t.rationale})]})]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn",onClick:()=>void m(),children:n("common.cancel","Cancel")}),e.jsx("button",{className:"btn btn-primary",onClick:()=>void D(),children:b?n("agents.onboarding.applyDraftSettings","Apply draft to settings form"):n("agents.onboarding.applyDraftAgent","Apply draft to agent form")})]})]}),g==="error"&&T&&e.jsxs("div",{className:"form-group",children:[e.jsx("div",{className:"form-error",children:T}),e.jsx("div",{className:"modal-actions",children:e.jsx("button",{className:"btn",onClick:()=>void m(),children:n("common.close","Close")})})]})]})})}export{te as ExperimentalAgentOnboardingModal};
1
+ import{r as s,j as e}from"./vendor-react-SZ_qB27O.js";import{I as F,J as K,K as V,N as W,O as $,Q as z,U}from"./index-oxnX59eO.js";import{u as J}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";function te({isOpen:l,onClose:R,onUseDraft:M,projectId:x,existingAgents:P,mode:w="create",existingAgentConfig:L}){const{t:n}=J("app"),[g,d]=s.useState("initial"),[f,_]=s.useState(""),[c,S]=s.useState(null),[C,I]=s.useState(""),[k,A]=s.useState("answer"),[p,v]=s.useState(""),[t,H]=s.useState(null),[T,h]=s.useState(null),[E,y]=s.useState([]),b=w==="edit",o=s.useRef(l),N=s.useCallback(()=>{d("initial"),_(""),S(null),I(""),A("answer"),v(""),H(null),h(null),y([])},[]),O=s.useMemo(()=>F.map(a=>({id:a.id,label:a.name,description:a.description})),[]);s.useEffect(()=>{if(o.current=l,!c)return;const a=K(c,x,{onThinking:r=>{o.current&&y(G=>{const u=[...G],j=u[u.length-1];return j&&!j.question?(u[u.length-1]={...j,thinkingOutput:`${j.thinkingOutput??""}${r}`},u):[...u,{response:{},thinkingOutput:r}]})},onQuestion:r=>{o.current&&(I(r.question),A(r.id),d("question"))},onSummary:r=>{o.current&&(H(r),d("summary"))},onError:r=>{o.current&&(h(r),d("error"))}});return()=>{o.current=!1,a.close()}},[l,c,x]);const m=async()=>{o.current=!1;try{c&&await $(c,x)}catch{}finally{N(),R()}};if(s.useEffect(()=>{o.current=l,l||N()},[l,N]),!l)return null;const i=a=>a==null||a===""?e.jsx("em",{className:"experimental-agent-onboarding-modal__summary-empty",children:n("agents.onboarding.notSet","Not set")}):e.jsx("span",{children:a}),Q=async()=>{d("loading"),h(null);try{const a=await z(f,{mode:w,existingAgentConfig:L,existingAgents:P.map(r=>({id:r.id,name:r.name,role:r.role})),templates:O},x);if(!o.current)return;S(a.sessionId)}catch(a){if(!o.current)return;h(a.message),d("error")}},q=async()=>{if(c){d("loading"),h(null);try{const a={[k]:p};if(y(r=>[...r,{question:{id:k,type:"text",question:C},response:a}]),await U(c,a,x),!o.current)return;v("")}catch(a){if(!o.current)return;h(a.message),d("error")}}},D=async()=>{t&&(M(t),await m())};return e.jsx(V,{windowKey:"experimental-agent-onboarding",modal:!0,title:n("agents.onboarding.title","AI Interview"),ariaLabel:n("agents.onboarding.dialogLabel","AI Interview"),onClose:()=>void m(),hideHeader:!0,dragHandleSelector:".experimental-agent-onboarding-modal .modal-header",className:"floating-window--experimental-agent-onboarding",defaultSize:{width:720,height:620},minSize:{width:420,height:320},persistGeometryKey:"floating-window:experimental-agent-onboarding",suspendGeometryPersistenceOnMobile:!0,suspendGeometryPersistenceOnShortViewport:!0,children:e.jsxs("div",{className:"modal modal-lg experimental-agent-onboarding-modal",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:n("agents.onboarding.title","AI Interview")}),e.jsx("button",{className:"modal-close",onClick:()=>void m(),"aria-label":n("common.closeAriaLabel","Close"),children:"×"})]}),E.length>0&&e.jsx(W,{entries:E}),g==="initial"&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"agent-onboarding-intent",children:b?n("agents.onboarding.intentLabelEdit","What should this agent change or improve?"):n("agents.onboarding.intentLabelCreate","What should this new agent own?")}),e.jsx("textarea",{id:"agent-onboarding-intent",className:"input experimental-agent-onboarding-modal__textarea",value:f,onChange:a=>_(a.target.value)}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn",onClick:()=>void m(),children:n("common.cancel","Cancel")}),e.jsx("button",{className:"btn btn-primary",disabled:!f.trim(),onClick:()=>void Q(),children:b?n("agents.onboarding.startInterview","Start interview"):n("agents.onboarding.startOnboarding","Start onboarding")})]})]}),(g==="loading"||g==="question")&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"agent-onboarding-answer",children:C||n("agents.onboarding.thinking","Thinking...")}),e.jsx("textarea",{id:"agent-onboarding-answer",className:"input experimental-agent-onboarding-modal__textarea",value:p,onChange:a=>v(a.target.value)}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn",onClick:()=>void m(),children:n("common.cancel","Cancel")}),e.jsx("button",{className:"btn btn-primary",disabled:g==="loading"||!p.trim(),onClick:()=>void q(),children:n("agents.onboarding.continue","Continue")})]})]}),g==="summary"&&t&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:b?n("agents.onboarding.updatedDraftReady","Updated draft ready for review"):n("agents.onboarding.draftReady","Draft ready for review")}),e.jsx("p",{className:"experimental-agent-onboarding-modal__summary-intro",children:n("agents.onboarding.draftIntro","Review this generated draft. Nothing is applied until you confirm.")}),e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary card",children:[e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[e.jsx("h4",{children:n("agents.onboarding.sectionIdentity","Identity")}),e.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldName","Name")}),e.jsx("dd",{children:i(t.name)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldRole","Role")}),e.jsx("dd",{children:i(t.role)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldTitle","Title")}),e.jsx("dd",{children:i(t.title)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldIcon","Icon")}),e.jsx("dd",{children:i(t.icon)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldReportsTo","Reports To")}),e.jsx("dd",{children:i(t.reportsTo)})]})]})]}),e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[e.jsx("h4",{children:n("agents.onboarding.sectionConfiguration","Configuration")}),e.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldInlineInstructions","Inline Instructions")}),e.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:i(t.instructionsText)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldSoul","Soul")}),e.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:i(t.soul)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldAgentMemory","Agent Memory")}),e.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:i(t.memory)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldSkills","Skills")}),e.jsx("dd",{children:i(t.skills?.join(", "))})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldThinkingLevel","Thinking Level")}),e.jsx("dd",{children:i(t.thinkingLevel)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldMaxTurns","Max Turns")}),e.jsx("dd",{children:i(t.maxTurns)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldTemplate","Template")}),e.jsx("dd",{children:i(t.templateId)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldPatternAgent","Pattern Agent")}),e.jsx("dd",{children:i(t.patternAgentId)})]})]})]}),(t.heartbeatProcedurePath||t.heartbeatIntervalMs||t.heartbeatEnabled!==void 0||t.modelHint||t.runtimeHint)&&e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[e.jsx("h4",{children:n("agents.onboarding.sectionRuntimeHints","Runtime Hints")}),e.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldHeartbeatPath","Heartbeat Procedure Path")}),e.jsx("dd",{children:i(t.heartbeatProcedurePath)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldHeartbeatInterval","Heartbeat Interval")}),e.jsx("dd",{children:i(t.heartbeatIntervalMs?`${t.heartbeatIntervalMs}ms`:void 0)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldHeartbeatEnabled","Heartbeat Enabled")}),e.jsx("dd",{children:i(t.heartbeatEnabled===void 0?void 0:t.heartbeatEnabled?n("agents.onboarding.yes","yes"):n("agents.onboarding.no","no"))})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldModelHint","Model Hint")}),e.jsx("dd",{children:i(t.modelHint)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldRuntimeHint","Runtime Hint")}),e.jsx("dd",{children:i(t.runtimeHint)})]})]})]}),t.rationale&&e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[e.jsx("h4",{children:n("agents.onboarding.sectionRationale","Rationale")}),e.jsx("p",{className:"experimental-agent-onboarding-modal__summary-block",children:t.rationale})]})]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn",onClick:()=>void m(),children:n("common.cancel","Cancel")}),e.jsx("button",{className:"btn btn-primary",onClick:()=>void D(),children:b?n("agents.onboarding.applyDraftSettings","Apply draft to settings form"):n("agents.onboarding.applyDraftAgent","Apply draft to agent form")})]})]}),g==="error"&&T&&e.jsxs("div",{className:"form-group",children:[e.jsx("div",{className:"form-error",children:T}),e.jsx("div",{className:"modal-actions",children:e.jsx("button",{className:"btn",onClick:()=>void m(),children:n("common.close","Close")})})]})]})})}export{te as ExperimentalAgentOnboardingModal};
@@ -1,2 +1,2 @@
1
- import{r as n,j as t}from"./vendor-react-SZ_qB27O.js";import{V as js,T as ws,P as Ns,m as Es,n as Ss,o as $s,p as Ms,X as Cs,s as Ts,q as As,u as Gs,v as Ls}from"./index-I32FijPT.js";import{u as Ds}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";const Ps=5,Fs=3,Rs=280;function h(d,m){if(!m)return d;const r=d.includes("?")?"&":"?";return`${d}${r}projectId=${encodeURIComponent(m)}`}function is(d){return!!(d&&typeof d=="object"&&"code"in d&&d.code==="ACTIVE_GOAL_LIMIT_EXCEEDED")}function Hs({initialGoals:d,anchorGoalId:m,projectId:r,onNavigateToMission:as}){const{t:a}=Ds("app"),[c,k]=n.useState(()=>d??[]),[ns,j]=n.useState(null),p=n.useRef(null),[w,L]=n.useState(d===void 0),[D,l]=n.useState(null),[os,P]=n.useState(!1),[v,F]=n.useState(""),[R,N]=n.useState(""),[U,u]=n.useState(null),[O,_]=n.useState(!1),[y,E]=n.useState(!1),[S,V]=n.useState(null),[q,$]=n.useState(""),[B,M]=n.useState(""),[H,f]=n.useState(null),[I,z]=n.useState(!1),[ls,rs]=n.useState(()=>new Set),[ds,cs]=n.useState([]),[x,C]=n.useState({}),[T,W]=n.useState({}),[A,K]=n.useState(null),[us,X]=n.useState(null);n.useEffect(()=>{if(d!==void 0)return;let s=!0;return(async()=>{try{L(!0),l(null);const i=await fetch(h("/api/goals",r));if(!i.ok)throw new Error(`Failed to load goals (${i.status})`);const o=await i.json();if(!s)return;k(Array.isArray(o.goals)?o.goals:[])}catch{if(!s)return;l(a("goals.loadError","Unable to load goals right now. Please try again."))}finally{s&&L(!1)}})(),()=>{s=!1}},[d,r]),n.useEffect(()=>{let s=!0;return(async()=>{try{const i=await fetch(h("/api/missions",r));if(!i.ok)throw new Error(`Failed to load missions (${i.status})`);const o=await i.json(),g=Array.isArray(o)?o:Array.isArray(o.missions)?o.missions:[];s&&cs(g.map(b=>({id:b.id,title:b.title,status:b.status})))}catch{s&&l(a("goals.missionsLoadError","Unable to load missions right now. Please try again."))}})(),()=>{s=!1}},[r,a]);const J=async s=>{const e=await fetch(h(`/api/goals/${encodeURIComponent(s)}/missions`,r));if(!e.ok)throw new Error(`Failed to load linked missions (${e.status})`);const i=await e.json();return Array.isArray(i.missions)?i.missions:[]};n.useEffect(()=>{let s=!0;return(async()=>{if(c.length===0){C({});return}try{const i=await Promise.all(c.map(async o=>[o.id,await J(o.id)]));s&&C(Object.fromEntries(i))}catch{s&&l(a("goals.linkedMissionsLoadError","Unable to load linked missions right now. Please try again."))}})(),()=>{s=!1}},[c,a]);const G=n.useMemo(()=>c.filter(s=>s.status==="active").length,[c]),gs=G>=Fs&&G<=Ps;n.useEffect(()=>{if(!m){j(null);return}const s=document.getElementById(`goal-card-${m}`);if(s)return j(m),typeof s.scrollIntoView=="function"&&s.scrollIntoView({behavior:"smooth",block:"center"}),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{j(e=>e===m?null:e),p.current=null},1600),()=>{p.current&&(clearTimeout(p.current),p.current=null)}},[m,c]);function ms(){l(null),u(null),P(!0)}function hs(s){V(s.id),$(s.title),M(s.description??""),f(null)}function Q(){V(null),$(""),M(""),f(null)}function Y(){P(!1),F(""),N(""),u(null),E(!1)}async function ps(){const s=v.trim();if(!s){u(a("goals.titleRequired","Title is required."));return}try{E(!0),u(null);const e=await Gs(s,r);N(e)}catch(e){u(Ls(e))}finally{E(!1)}}async function fs(){const s=v.trim();if(!s){u(a("goals.titleRequired","Title is required."));return}try{_(!0),u(null),l(null);const e=await fetch(h("/api/goals",r),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({title:s,description:R})});if(e.ok){const o=await e.json();k(g=>[...g,o]),Y();return}let i=null;try{i=await e.json()}catch{i=null}if(e.status===409&&is(i)){l(a("goals.capError","Cannot activate more than 5 goals. Resolve an active goal before activating another."));return}u(a("goals.createError","Unable to create goal right now. Please try again."))}catch{u(a("goals.createError","Unable to create goal right now. Please try again."))}finally{_(!1)}}async function bs(){if(!S)return;const s=q.trim();if(!s){f(a("goals.titleRequired","Title is required."));return}try{z(!0),f(null);const e=await fetch(h(`/api/goals/${S}`,r),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({title:s,description:B})});if(!e.ok)throw new Error(`Failed to update goal (${e.status})`);const i=await e.json();k(o=>o.map(g=>g.id===i.id?i:g)),Q()}catch{f(a("goals.saveError","Unable to save goal right now. Please try again."))}finally{z(!1)}}function ks(s){return s.length>Rs||s.includes(`
1
+ import{r as n,j as t}from"./vendor-react-SZ_qB27O.js";import{V as js,T as ws,P as Ns,m as Es,n as Ss,o as $s,p as Ms,X as Cs,s as Ts,q as As,u as Gs,v as Ls}from"./index-oxnX59eO.js";import{u as Ds}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";const Ps=5,Fs=3,Rs=280;function h(d,m){if(!m)return d;const r=d.includes("?")?"&":"?";return`${d}${r}projectId=${encodeURIComponent(m)}`}function is(d){return!!(d&&typeof d=="object"&&"code"in d&&d.code==="ACTIVE_GOAL_LIMIT_EXCEEDED")}function Hs({initialGoals:d,anchorGoalId:m,projectId:r,onNavigateToMission:as}){const{t:a}=Ds("app"),[c,k]=n.useState(()=>d??[]),[ns,j]=n.useState(null),p=n.useRef(null),[w,L]=n.useState(d===void 0),[D,l]=n.useState(null),[os,P]=n.useState(!1),[v,F]=n.useState(""),[R,N]=n.useState(""),[U,u]=n.useState(null),[O,_]=n.useState(!1),[y,E]=n.useState(!1),[S,V]=n.useState(null),[q,$]=n.useState(""),[B,M]=n.useState(""),[H,f]=n.useState(null),[I,z]=n.useState(!1),[ls,rs]=n.useState(()=>new Set),[ds,cs]=n.useState([]),[x,C]=n.useState({}),[T,W]=n.useState({}),[A,K]=n.useState(null),[us,X]=n.useState(null);n.useEffect(()=>{if(d!==void 0)return;let s=!0;return(async()=>{try{L(!0),l(null);const i=await fetch(h("/api/goals",r));if(!i.ok)throw new Error(`Failed to load goals (${i.status})`);const o=await i.json();if(!s)return;k(Array.isArray(o.goals)?o.goals:[])}catch{if(!s)return;l(a("goals.loadError","Unable to load goals right now. Please try again."))}finally{s&&L(!1)}})(),()=>{s=!1}},[d,r]),n.useEffect(()=>{let s=!0;return(async()=>{try{const i=await fetch(h("/api/missions",r));if(!i.ok)throw new Error(`Failed to load missions (${i.status})`);const o=await i.json(),g=Array.isArray(o)?o:Array.isArray(o.missions)?o.missions:[];s&&cs(g.map(b=>({id:b.id,title:b.title,status:b.status})))}catch{s&&l(a("goals.missionsLoadError","Unable to load missions right now. Please try again."))}})(),()=>{s=!1}},[r,a]);const J=async s=>{const e=await fetch(h(`/api/goals/${encodeURIComponent(s)}/missions`,r));if(!e.ok)throw new Error(`Failed to load linked missions (${e.status})`);const i=await e.json();return Array.isArray(i.missions)?i.missions:[]};n.useEffect(()=>{let s=!0;return(async()=>{if(c.length===0){C({});return}try{const i=await Promise.all(c.map(async o=>[o.id,await J(o.id)]));s&&C(Object.fromEntries(i))}catch{s&&l(a("goals.linkedMissionsLoadError","Unable to load linked missions right now. Please try again."))}})(),()=>{s=!1}},[c,a]);const G=n.useMemo(()=>c.filter(s=>s.status==="active").length,[c]),gs=G>=Fs&&G<=Ps;n.useEffect(()=>{if(!m){j(null);return}const s=document.getElementById(`goal-card-${m}`);if(s)return j(m),typeof s.scrollIntoView=="function"&&s.scrollIntoView({behavior:"smooth",block:"center"}),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{j(e=>e===m?null:e),p.current=null},1600),()=>{p.current&&(clearTimeout(p.current),p.current=null)}},[m,c]);function ms(){l(null),u(null),P(!0)}function hs(s){V(s.id),$(s.title),M(s.description??""),f(null)}function Q(){V(null),$(""),M(""),f(null)}function Y(){P(!1),F(""),N(""),u(null),E(!1)}async function ps(){const s=v.trim();if(!s){u(a("goals.titleRequired","Title is required."));return}try{E(!0),u(null);const e=await Gs(s,r);N(e)}catch(e){u(Ls(e))}finally{E(!1)}}async function fs(){const s=v.trim();if(!s){u(a("goals.titleRequired","Title is required."));return}try{_(!0),u(null),l(null);const e=await fetch(h("/api/goals",r),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({title:s,description:R})});if(e.ok){const o=await e.json();k(g=>[...g,o]),Y();return}let i=null;try{i=await e.json()}catch{i=null}if(e.status===409&&is(i)){l(a("goals.capError","Cannot activate more than 5 goals. Resolve an active goal before activating another."));return}u(a("goals.createError","Unable to create goal right now. Please try again."))}catch{u(a("goals.createError","Unable to create goal right now. Please try again."))}finally{_(!1)}}async function bs(){if(!S)return;const s=q.trim();if(!s){f(a("goals.titleRequired","Title is required."));return}try{z(!0),f(null);const e=await fetch(h(`/api/goals/${S}`,r),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({title:s,description:B})});if(!e.ok)throw new Error(`Failed to update goal (${e.status})`);const i=await e.json();k(o=>o.map(g=>g.id===i.id?i:g)),Q()}catch{f(a("goals.saveError","Unable to save goal right now. Please try again."))}finally{z(!1)}}function ks(s){return s.length>Rs||s.includes(`
2
2
  `)}function vs(s){rs(e=>{const i=new Set(e);return i.has(s)?i.delete(s):i.add(s),i})}function Z(s){const e=new Set((x[s]??[]).map(i=>i.id));return ds.filter(i=>!e.has(i.id))}async function ss(s){const e=await J(s);C(i=>({...i,[s]:e})),W(i=>({...i,[s]:""}))}async function ys(s){const e=T[s];if(e)try{K(s),l(null);const i=await fetch(h(`/api/missions/${encodeURIComponent(e)}/goals/${encodeURIComponent(s)}`,r),{method:"POST"});if(!i.ok)throw new Error(`Failed to link mission (${i.status})`);await ss(s)}catch{l(a("goals.linkMissionError","Unable to link mission right now. Please try again."))}finally{K(null)}}async function xs(s,e){try{X(`${s}:${e}`),l(null);const i=await fetch(h(`/api/missions/${encodeURIComponent(e)}/goals/${encodeURIComponent(s)}`,r),{method:"DELETE"});if(!i.ok)throw new Error(`Failed to unlink mission (${i.status})`);await ss(s)}catch{l(a("goals.unlinkMissionError","Unable to unlink mission right now. Please try again."))}finally{X(null)}}async function ts(s){const e=s.status==="active"?`/api/goals/${s.id}/archive`:`/api/goals/${s.id}/unarchive`;try{l(null);const i=await fetch(h(e,r),{method:"POST"});if(i.ok){const g=await i.json();k(b=>b.map(es=>es.id===g.id?g:es));return}let o=null;try{o=await i.json()}catch{o=null}if(i.status===409&&is(o)){l(a("goals.capError","Cannot activate more than 5 goals. Resolve an active goal before activating another."));return}l(a("goals.updateError","Unable to update goal status right now. Please try again."))}catch{l(a("goals.updateError","Unable to update goal status right now. Please try again."))}}return t.jsxs("section",{className:"goals-view","data-testid":"goals-view",children:[t.jsx(js,{icon:ws,title:a("goals.title","Goals"),actions:t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"goals-count","data-testid":"goals-active-count",children:a("goals.activeCount","{{count}} active goals",{count:G})}),t.jsxs("button",{type:"button",className:"btn btn-primary goals-add-button",onClick:ms,"data-testid":"goals-add-button",children:[t.jsx(Ns,{size:18,"aria-hidden":"true"}),a("goals.addGoal","Add Goal")]})]})}),t.jsxs("div",{className:"goals-view__content",children:[os?t.jsxs("div",{className:"card goals-form","data-testid":"goals-form",children:[t.jsx("label",{className:"goals-form-label",htmlFor:"goals-form-title",children:a("goals.labelTitle","Title")}),t.jsx("input",{id:"goals-form-title",className:"input",type:"text",value:v,maxLength:200,onChange:s=>F(s.target.value),"data-testid":"goals-form-title"}),t.jsxs("div",{className:"goals-form-label-row",children:[t.jsx("label",{className:"goals-form-label",htmlFor:"goals-form-description",children:a("goals.labelDescription","Description")}),t.jsxs("button",{type:"button",className:"btn goals-form-draft-button",onClick:()=>void ps(),disabled:!v.trim()||y,"data-testid":"goals-form-draft-ai",children:[t.jsx(Es,{"aria-hidden":"true"}),y?a("goals.drafting","Drafting…"):a("goals.draftWithAi","Draft with AI")]})]}),t.jsx("textarea",{id:"goals-form-description",className:"input",value:R,maxLength:5e3,onChange:s=>N(s.target.value),"data-testid":"goals-form-description"}),U?t.jsx("p",{className:"form-error goals-error",role:"alert",children:U}):null,t.jsxs("div",{className:"goals-form-actions",children:[t.jsx("button",{type:"button",className:"btn btn-primary",onClick:()=>void fs(),disabled:O||y,"data-testid":"goals-form-submit",children:a("actions.save","Save")}),t.jsx("button",{type:"button",className:"btn",onClick:Y,disabled:O||y,"data-testid":"goals-form-cancel",children:a("actions.cancel","Cancel")})]})]}):null,gs?t.jsx("p",{className:"goals-warning",role:"status",children:a("goals.capWarning","Approaching the 5-active goal cap. Keep active goals focused.")}):null,D?t.jsx("p",{className:"form-error goals-error",role:"alert","data-testid":"goals-error",children:D}):null,w?t.jsx("p",{className:"goals-loading",role:"status","data-testid":"goals-loading",children:a("goals.loading","Loading goals…")}):null,!w&&c.length===0?t.jsx("div",{className:"goals-empty card","data-testid":"goals-empty-state",children:a("goals.emptyState","No goals yet. Add one to begin tracking strategic outcomes.")}):null,!w&&c.length>0?t.jsx("div",{className:"goals-list","data-testid":"goals-list",children:c.map(s=>t.jsxs("article",{id:`goal-card-${s.id}`,className:`card goals-card ${s.status==="archived"?"goals-card-archived":""} ${ns===s.id?"goals-card--anchored":""}`.trim(),"data-testid":`goal-card-${s.id}`,draggable:As(),onDragStart:e=>{Ts(e.dataTransfer,{kind:"goal",id:s.id,projectId:r})},children:[S===s.id?t.jsxs("div",{className:"goals-card-main goals-card-edit",children:[t.jsx("label",{className:"goals-form-label",htmlFor:`goal-edit-title-${s.id}`,children:a("goals.labelTitle","Title")}),t.jsx("input",{id:`goal-edit-title-${s.id}`,className:"input",type:"text",value:q,maxLength:200,onChange:e=>$(e.target.value),"data-testid":`goal-edit-title-${s.id}`}),t.jsx("label",{className:"goals-form-label",htmlFor:`goal-edit-description-${s.id}`,children:a("goals.labelDescription","Description")}),t.jsx("textarea",{id:`goal-edit-description-${s.id}`,className:"input",value:B,maxLength:5e3,onChange:e=>M(e.target.value),"data-testid":`goal-edit-description-${s.id}`}),H?t.jsx("p",{className:"form-error goals-error",role:"alert",children:H}):null,t.jsxs("div",{className:"goals-card-actions",children:[t.jsx("button",{type:"button",className:"btn btn-primary",onClick:()=>void bs(),disabled:I,"data-testid":`goal-edit-save-${s.id}`,children:a("actions.save","Save")}),t.jsx("button",{type:"button",className:"btn",onClick:Q,disabled:I,"data-testid":`goal-edit-cancel-${s.id}`,children:a("actions.cancel","Cancel")})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"goals-card-main",children:[t.jsx("h3",{className:"goals-card-title",children:s.title}),s.description?(()=>{const e=ks(s.description),i=ls.has(s.id);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`markdown-body goals-card-description ${e&&!i?"goals-card-description-collapsed":""}`.trim(),children:t.jsx(Ss,{remarkPlugins:[$s],children:s.description})}),e?t.jsx("button",{type:"button",className:"btn goals-card-description-toggle","aria-expanded":i,"data-testid":`goal-description-toggle-${s.id}`,onClick:()=>vs(s.id),children:i?a("actions.showLess","Show less"):a("actions.showMore","Show more")}):null]})})():null,t.jsxs("p",{className:"goals-card-status",children:[a("goals.status","Status"),": ",s.status]})]}),t.jsxs("div",{className:"goals-card-actions",children:[t.jsx("button",{type:"button",className:"btn",onClick:()=>hs(s),"data-testid":`goal-edit-${s.id}`,children:a("actions.edit","Edit")}),s.status==="active"?t.jsx("button",{type:"button",className:"btn goals-activate-button",onClick:()=>void ts(s),"data-testid":`goal-archive-${s.id}`,children:a("goals.archive","Archive")}):t.jsx("button",{type:"button",className:"btn goals-activate-button",onClick:()=>void ts(s),"data-testid":`goal-unarchive-${s.id}`,children:a("goals.unarchive","Unarchive")})]})]}),t.jsxs("section",{className:"goals-linked-missions","aria-label":a("goals.linkedMissions","Linked missions"),children:[t.jsxs("div",{className:"goals-linked-missions-header",children:[t.jsx("h4",{className:"goals-linked-missions-title",children:a("goals.linkedMissionsTitle","Linked Missions")}),t.jsx("span",{className:"goals-linked-missions-count",children:a("goals.linkedMissionsCount",{count:x[s.id]?.length??0,defaultValue_one:"{{count}} linked",defaultValue_other:"{{count}} linked"})})]}),t.jsxs("div",{className:"goals-linked-missions-controls",children:[t.jsxs("select",{className:"input goals-linked-missions-picker","data-testid":`goal-mission-picker-${s.id}`,value:T[s.id]??"",onChange:e=>W(i=>({...i,[s.id]:e.target.value})),"aria-label":a("goals.missionPicker","Mission to link"),disabled:A===s.id||Z(s.id).length===0,children:[t.jsx("option",{value:"",children:a("goals.selectMission","Select a mission")}),Z(s.id).map(e=>t.jsx("option",{value:e.id,children:e.title},e.id))]}),t.jsxs("button",{type:"button",className:"btn btn-primary goals-linked-missions-link-button","data-testid":`goal-mission-link-button-${s.id}`,disabled:!T[s.id]||A===s.id,onClick:()=>void ys(s.id),children:[t.jsx(Ms,{size:16,"aria-hidden":"true"}),A===s.id?a("goals.linkingMission","Linking…"):a("goals.linkMission","Link mission")]})]}),(x[s.id]?.length??0)>0?t.jsx("div",{className:"goals-linked-missions-list",children:(x[s.id]??[]).map(e=>t.jsxs("div",{className:"goals-linked-mission-chip","data-testid":`goal-linked-mission-chip-${e.id}`,children:[t.jsx("button",{type:"button",className:"btn goals-linked-mission-link",onClick:()=>as?.(e.id),children:e.title}),t.jsx("span",{className:"goals-linked-mission-status",children:e.status}),t.jsx("button",{type:"button",className:"btn-icon goals-linked-mission-unlink","data-testid":`goal-linked-mission-unlink-${e.id}`,"aria-label":a("goals.unlinkMission","Unlink mission"),disabled:us===`${s.id}:${e.id}`,onClick:()=>void xs(s.id,e.id),children:t.jsx(Cs,{size:16,"aria-hidden":"true"})})]},e.id))}):t.jsx("p",{className:"goals-linked-missions-empty",children:a("goals.noLinkedMissions","No linked missions.")})]})]},s.id))}):null]})]})}export{Hs as GoalsView};
@@ -1,4 +1,4 @@
1
- import{r as i,j as e}from"./vendor-react-SZ_qB27O.js";import{c as ze,r as le,e as Ce,S as je,cL as Me,cM as Je,b as Ne,cN as es,cO as ss,cP as ts,cQ as is,cR as ns,cS as as,cT as Ie,cU as rs,cV as os,cW as cs,cs as ls,cX as Re,V as hs,m as Y,bY as ds,X as Ae,cY as fe,R as q,a3 as gs,cx as us,as as De,l as ae,bH as ve,bG as Te,P as $e,aU as ms,b2 as Pe,cZ as fs,s as vs,q as xs}from"./index-I32FijPT.js";import{u as Ge}from"./vendor-i18n-Duky4gdQ.js";import{U as Ee}from"./users-Bohihi_o.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";/**
1
+ import{r as i,j as e}from"./vendor-react-SZ_qB27O.js";import{c as ze,r as le,e as Ce,S as je,cL as Me,cM as Je,b as Ne,cN as es,cO as ss,cP as ts,cQ as is,cR as ns,cS as as,cT as Ie,cU as rs,cV as os,cW as cs,cs as ls,cX as Re,V as hs,m as Y,bY as ds,X as Ae,cY as fe,R as q,a3 as gs,cx as us,as as De,l as ae,bH as ve,bG as Te,P as $e,aU as ms,b2 as Pe,cZ as fs,s as vs,q as xs}from"./index-oxnX59eO.js";import{u as Ge}from"./vendor-i18n-Duky4gdQ.js";import{U as Ee}from"./users-B8DkpbXD.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";/**
2
2
  * @license lucide-react v1.7.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,3 +1,3 @@
1
- import{r as n,j as e}from"./vendor-react-SZ_qB27O.js";import{u as $e,f as we,a as ke,s as Ke,i as _e,t as Ue,b as Ce,c as Ee,d as Be,e as Qe,g as We,h as Ve}from"./SettingsModal-CJof1Ett.js";import{a as ee,w as te,dc as Ye,a_ as Xe,V as Ze,dd as Je,L as _,aL as Fe}from"./index-I32FijPT.js";import{u as Ne}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";function pe(i){const s=Object.entries(i).flatMap(([r,t])=>Array.isArray(t)?t.filter(Boolean).map(c=>[r,c]):t===void 0||t===""?[]:[[r,String(t)]]);return s.length?`?${s.map(([r,t])=>`${encodeURIComponent(r)}=${encodeURIComponent(t)}`).join("&")}`:""}function et(i){return ee(te("/knowledge/graph/status",i))}function tt(i,s={}){return ee(te(`/knowledge/graph/nodes${pe(s)}`,i))}function st(i,s){return ee(te(`/knowledge/graph/node${pe({id:s})}`,i))}function Ae(i,s){return ee(te(`/knowledge/graph/neighbors${pe(s)}`,i))}function at(i,s){return ee(te(`/knowledge/graph/path${pe(s)}`,i))}function nt(i,s=!1){return ee(te("/knowledge/graph/build",i),{method:"POST",body:JSON.stringify({force:s})})}const J=".fusion/memory/MEMORY.md",rt=5e4,lt="0 3 * * *",it="0 4 * * *";function ge(i){return{memoryEnabled:i.memoryEnabled!==!1,memoryAutoSummarizeEnabled:i.memoryAutoSummarizeEnabled??!1,memoryAutoSummarizeThresholdChars:i.memoryAutoSummarizeThresholdChars??rt,memoryAutoSummarizeSchedule:i.memoryAutoSummarizeSchedule??lt,memoryDreamsEnabled:i.memoryDreamsEnabled??!1,memoryDreamsSchedule:i.memoryDreamsSchedule??it}}function Me(i,s){return i.some(r=>r.path===s)?s:i.find(r=>r.path===J)?.path??i[0]?.path??J}function ot(i={}){const{projectId:s}=i,[r,t]=n.useState(null),[c,v]=n.useState(!0),[d,M]=n.useState(!1),[E,k]=n.useState(()=>ge({})),[f,w]=n.useState(!0),[m,a]=n.useState(!1),[h,F]=n.useState([]),[U,G]=n.useState(!0),[N,D]=n.useState(J),[I,R]=n.useState(""),[se,B]=n.useState(!1),[p,g]=n.useState(!1),[H,L]=n.useState(!1),[S,P]=n.useState(!1),[Y,T]=n.useState(!1),[x,Q]=n.useState(null),[u,y]=n.useState(!0),[b,W]=n.useState(!1),[le,ae]=n.useState(!1),{status:ne,loading:be,refresh:$}=$e({projectId:s}),re=n.useCallback(o=>{R(o),g(!0)},[]),X=n.useCallback(async o=>{B(!0);try{const{content:j}=await we(o,s);D(o),R(j),g(!1)}finally{B(!1)}},[s]),q=n.useCallback(async()=>{G(!0);try{const{files:o}=await ke(s);if(F(o),o.length===0){D(J),R(""),g(!1);return}const j=Me(o,N);j!==N&&await X(j)}finally{G(!1)}},[s,N,X]);n.useEffect(()=>{let o=!1;async function j(){try{const A=await Ee(s);o||(t(A.content),M(A.exists),v(!1))}catch{o||(t(null),M(!1),v(!1))}}return j(),()=>{o=!0}},[s]),n.useEffect(()=>{let o=!1;async function j(){w(!0);try{const A=await Xe(s);o||k(ge(A))}catch{o||k(ge({}))}finally{o||w(!1)}}return j(),()=>{o=!0}},[s]);const ie=n.useRef(N);n.useEffect(()=>{ie.current=N},[N]),n.useEffect(()=>{let o=!1;async function j(){G(!0);try{const{files:A}=await ke(s);if(o)return;if(F(A),A.length===0){D(J),R(""),g(!1);return}const ue=Me(A,ie.current),{content:je}=await we(ue,s);if(o)return;D(ue),R(je),g(!1)}catch{o||(F([]),D(J),R(""),g(!1))}finally{o||G(!1)}}return j(),()=>{o=!0}},[s]),n.useEffect(()=>{let o=!1;async function j(){try{const A=await Ce(s);o||(Q(A),y(!1))}catch{o||(Q(null),y(!1))}}return j(),()=>{o=!0}},[s]);const oe=n.useCallback(async o=>{a(!0);try{const j=await Ye(o,s);k(ge(j))}finally{a(!1)}},[s]),me=n.useCallback(async o=>{await X(o)},[X]),ce=n.useCallback(async()=>{if(p){L(!0);try{await Ke(N,I,s),g(!1),await q()}finally{L(!1)}}},[I,p,N,s,q]),de=n.useCallback(async()=>{ae(!0);try{const o=await _e(s);return await $(),o}finally{ae(!1)}},[s,$]),he=n.useCallback(async o=>Ue(o,s),[s]),Z=n.useCallback(async()=>{try{const o=await Ce(s);Q(o)}catch{Q(null)}},[s]),K=n.useCallback(async()=>{try{const o=await Ee(s);t(o.content),M(o.exists)}catch{t(null),M(!1)}},[s]),z=n.useCallback(async o=>{await Be(o,s),await K()},[s,K]),xe=n.useCallback(async()=>{P(!0);try{const o=await Qe(s);return await Promise.all([K(),Z()]),{success:o.success,summary:o.summary}}finally{P(!1)}},[s,K,Z]),V=n.useCallback(async()=>{T(!0);try{return await We(s)}finally{T(!1)}},[s]),fe=n.useCallback(async o=>{W(!0);try{const j=await Ve(o,s),A=j.path??o;D(A),R(j.content),g(!1),await q()}finally{W(!1)}},[s,q]);return{insightsContent:r,insightsLoading:c,insightsExists:d,refreshInsights:K,saveInsights:z,memorySettings:E,settingsLoading:f,savingMemorySettings:m,saveMemorySettings:oe,memoryFiles:h,memoryFilesLoading:U,selectedFilePath:N,selectedFileContent:I,selectedFileLoading:se,selectedFileDirty:p,setSelectedFileContent:re,selectFile:me,saveSelectedFile:ce,savingSelectedFile:H,reloadMemoryFiles:q,backendStatus:ne,backendLoading:be,extractInsights:xe,extracting:S,triggerDreamNow:V,dreamRunning:Y,auditReport:x,auditLoading:u,refreshAudit:Z,compactMemory:fe,compacting:b,installQmdAction:de,installingQmd:le,testRetrieval:he}}const De={limit:50,offset:0};function mt({projectId:i,enabled:s}){const[r,t]=n.useState(null),[c,v]=n.useState(De),[d,M]=n.useState(null),[E,k]=n.useState(null),[f,w]=n.useState(null),[m,a]=n.useState({direction:"both",depth:1}),[h,F]=n.useState(null),[U,G]=n.useState({fromId:"",toId:"",maxHops:6}),[N,D]=n.useState(null),[I,R]=n.useState(!1),[se,B]=n.useState(!1),[p,g]=n.useState(null),H=n.useRef(0),L=n.useRef(0),S=n.useRef(0),P=n.useCallback(async()=>{try{const u=await et(i);t(u),G(y=>({...y,maxHops:u.pathLimits.defaultMaxHops}))}catch(u){g(u instanceof Error?u.message:String(u))}},[i]);n.useEffect(()=>{P()},[s,P]),n.useEffect(()=>{if(!r?.available)return;const u=++H.current;R(!0);const y=window.setTimeout(()=>void tt(i,c).then(b=>{u===H.current&&M(b)}).catch(b=>{u===H.current&&g(b instanceof Error?b.message:String(b))}).finally(()=>{u===H.current&&R(!1)}),250);return()=>window.clearTimeout(y)},[s,c,i,r?.available]);const Y=n.useCallback(async(u=E)=>{if(!u)return;const y=++L.current;try{const b=await Ae(i,{nodeId:u,...m});y===L.current&&F(b)}catch(b){y===L.current&&g(b instanceof Error?b.message:String(b))}},[m,i,E]),T=n.useCallback(async u=>{const y=++L.current;k(u);try{const[b,W]=await Promise.all([st(i,u),Ae(i,{nodeId:u,...m})]);y===L.current&&(w(b),F(W))}catch(b){y===L.current&&g(b instanceof Error?b.message:String(b))}},[m,i]),x=n.useCallback(async()=>{const u=++S.current;D(null),g(null);try{const y=await at(i,U);u===S.current&&D(y)}catch(y){u===S.current&&g(y instanceof Error?y.message:String(y))}},[U,i]),Q=n.useCallback(async(u=!1)=>{B(!0);try{await nt(i,u),await P()}catch(y){g(y instanceof Error?y.message:String(y))}finally{B(!1)}},[i,P]);return{status:r,filters:c,setFilters:v,nodes:d,loading:I,selectedId:E,detail:f,selectNode:T,neighborOptions:m,setNeighborOptions:a,neighborResults:h,refreshNeighbors:Y,pathInput:U,setPathInput:G,pathResult:N,findPath:x,rebuild:Q,rebuilding:se,refreshStatus:P,error:p,clearFilters:()=>v(De)}}const ct=["file","module","symbol","doc-concept","rationale"],dt=["function","class","interface","type-alias","enum","variable","namespace","alias"],ht=["contains","imports","re-exports","relates-to","rationale-supports"];function ve({id:i,onSelect:s}){return e.jsx("button",{type:"button",className:"btn btn-ghost knowledge-graph-endpoint",onClick:()=>s(i),children:i})}function Ie({title:i,edges:s,total:r,endpoint:t,onSelect:c}){const{t:v}=Ne("app");return e.jsxs("section",{className:"knowledge-graph-edge-list",children:[e.jsxs("h4",{children:[i," ",e.jsx("span",{children:v("knowledgeGraph.showingOf","showing {{shown}} of {{total}}",{shown:s.length,total:r})})]}),s.length===0?e.jsx("p",{className:"knowledge-graph-muted",children:v("knowledgeGraph.none","None")}):e.jsx("ul",{children:s.map(d=>e.jsxs("li",{children:[e.jsx("span",{children:d.kind}),e.jsx("span",{className:`knowledge-graph-provenance knowledge-graph-provenance--${d.provenance}`,children:d.provenance}),e.jsx(ve,{id:d[t],onSelect:c})]},d.id))})]})}function ut({projectId:i,addToast:s}){const{t:r}=Ne("app"),t=mt({projectId:i,enabled:!0}),[c,v]=n.useState(!1);if(n.useEffect(()=>{t.error&&s(t.error,"error")},[s,t.error]),!t.status&&t.error)return e.jsx("div",{className:"knowledge-graph-panel knowledge-graph-error","data-testid":"knowledge-graph-error",children:t.error});if(!t.status)return e.jsx("div",{className:"knowledge-graph-panel","data-testid":"knowledge-graph-loading",children:r("memory.graphLoading","Loading knowledge graph…")});if(!t.status.available)return e.jsxs("div",{className:"knowledge-graph-panel knowledge-graph-empty","data-testid":"knowledge-graph-no-graph",children:[e.jsxs("p",{children:[r("memory.graphUnavailable","Graph unavailable"),": ",t.status.recoveryReason]}),e.jsx("button",{type:"button",className:"btn",onClick:()=>void t.rebuild(!1),children:r("memory.graphBuild","Build graph")})]});const d=a=>t.setFilters({...t.filters,...a,offset:0}),M=a=>{const h=t.filters.kinds??[];d({kinds:h.includes(a)?h.filter(F=>F!==a):[...h,a]})},E=a=>{const h=t.neighborOptions.edgeKinds??[];t.setNeighborOptions({...t.neighborOptions,edgeKinds:h.includes(a)?h.filter(F=>F!==a):[...h,a]})},k=t.selectedId,f=t.status.pathLimits,w=t.pathResult?.outcome==="found"?t.pathResult.path:null,m=t.pathResult?.outcome==="found"?t.pathResult.hops:void 0;return e.jsxs("section",{className:"knowledge-graph-panel","data-testid":"knowledge-graph-panel",children:[e.jsxs("header",{className:"knowledge-graph-status card",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[t.status.nodeCount," ",r("memory.graphNodes","nodes")," · ",t.status.edgeCount," ",r("memory.graphEdges","edges")]}),e.jsx("span",{children:t.status.graphDir})]}),e.jsxs("dl",{children:[e.jsxs("div",{children:[e.jsx("dt",{children:r("knowledgeGraph.nodeKinds","Node kinds")}),e.jsx("dd",{children:Object.entries(t.status.nodeKindCounts??{}).map(([a,h])=>`${a}: ${h}`).join(" · ")||"—"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:r("knowledgeGraph.edgeKinds","Edge kinds")}),e.jsx("dd",{children:Object.entries(t.status.edgeKindCounts??{}).map(([a,h])=>`${a}: ${h}`).join(" · ")||"—"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:r("knowledgeGraph.provenance","Provenance")}),e.jsx("dd",{children:Object.entries(t.status.provenanceCounts??{}).map(([a,h])=>`${a}: ${h}`).join(" · ")||"—"})]})]}),e.jsxs("label",{className:"knowledge-graph-toggle",children:[e.jsx("input",{type:"checkbox",checked:c,onChange:a=>v(a.target.checked)})," ",r("memory.graphForce","Force rebuild")]}),e.jsx("button",{type:"button",className:"btn",disabled:t.rebuilding,onClick:()=>void t.rebuild(c),children:t.rebuilding?r("memory.graphRebuilding","Rebuilding…"):r("memory.graphRebuild","Rebuild")})]}),e.jsxs("section",{className:"knowledge-graph-filters card","aria-label":r("memory.graphFilters","Graph filters"),children:[e.jsx("div",{className:"knowledge-graph-kind-options",children:ct.map(a=>e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:(t.filters.kinds??[]).includes(a),onChange:()=>M(a)})," ",a]},a))}),e.jsx("input",{className:"input","aria-label":"Path prefix",placeholder:"Path prefix",value:t.filters.pathPrefix??"",onChange:a=>d({pathPrefix:a.target.value})}),e.jsx("input",{className:"input","aria-label":"Node id prefix",placeholder:"Node id prefix",value:t.filters.idPrefix??"",onChange:a=>d({idPrefix:a.target.value})}),e.jsx("input",{className:"input","aria-label":"Name regex",placeholder:"Name regex",value:t.filters.namePattern??"",onChange:a=>d({namePattern:a.target.value})}),e.jsxs("select",{className:"select","aria-label":"FNXC area",value:t.filters.fnxcArea??"",onChange:a=>d({fnxcArea:a.target.value||void 0}),children:[e.jsx("option",{value:"",children:r("knowledgeGraph.allFnxcAreas","All FNXC areas")}),t.status.fnxcAreas?.map(a=>e.jsx("option",{value:a,children:a},a))]}),e.jsxs("select",{className:"select","aria-label":"Symbol kind",value:t.filters.symbolKind??"",onChange:a=>d({symbolKind:a.target.value||void 0}),children:[e.jsx("option",{value:"",children:r("knowledgeGraph.allSymbolKinds","All symbol kinds")}),dt.map(a=>e.jsx("option",{children:a},a))]}),e.jsxs("select",{className:"select","aria-label":"Owner",value:t.filters.owner??"",onChange:a=>d({owner:a.target.value||void 0}),children:[e.jsx("option",{value:"",children:r("knowledgeGraph.allOwners","All owners")}),e.jsx("option",{value:"file",children:r("knowledgeGraph.ownerFile","file")}),e.jsx("option",{value:"derived",children:r("knowledgeGraph.ownerDerived","derived")})]}),e.jsx("select",{className:"select","aria-label":"Result limit",value:t.filters.limit??50,onChange:a=>d({limit:Number(a.target.value)}),children:[25,50,100,200].map(a=>e.jsx("option",{value:a,children:r("knowledgeGraph.limitResults","{{limit}} results",{limit:a})},a))}),e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:t.clearFilters,children:r("memory.graphClearFilters","Clear filters")})]}),e.jsxs("div",{className:"knowledge-graph-layout",children:[e.jsxs("section",{className:"card knowledge-graph-results",children:[e.jsxs("h3",{children:[t.nodes?.total??0," ",r("memory.graphResults","results")]}),t.loading?e.jsx("p",{"data-testid":"knowledge-graph-searching",children:r("knowledgeGraph.searching","Searching…")}):t.nodes?.nodes.length?e.jsxs(e.Fragment,{children:[e.jsx("ul",{children:t.nodes.nodes.map(a=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"btn btn-ghost",onClick:()=>void t.selectNode(a.id),children:[e.jsxs("strong",{children:[a.kind,": ",a.name]}),e.jsxs("span",{children:[a.id," · ",a.ownerPath,":",a.source.line]})]})},a.id))}),e.jsxs("div",{className:"knowledge-graph-pagination",children:[e.jsx("button",{type:"button",className:"btn btn-ghost",disabled:!t.filters.offset,onClick:()=>d({offset:Math.max(0,(t.filters.offset??0)-(t.filters.limit??50))}),children:r("knowledgeGraph.previous","Previous")}),e.jsx("button",{type:"button",className:"btn btn-ghost",disabled:(t.filters.offset??0)+(t.filters.limit??50)>=(t.nodes?.total??0),onClick:()=>d({offset:(t.filters.offset??0)+(t.filters.limit??50)}),children:r("knowledgeGraph.next","Next")})]})]}):e.jsx("p",{"data-testid":"knowledge-graph-no-results",children:r("memory.graphNoResults","No matching nodes.")})]}),e.jsx("section",{className:"card knowledge-graph-detail",children:t.detail?e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:t.detail.node.name}),e.jsx("p",{children:t.detail.node.id}),e.jsxs("p",{children:[t.detail.node.ownerPath,":",t.detail.node.source.line]}),e.jsx(Ie,{title:r("knowledgeGraph.outgoing","Outgoing"),edges:t.detail.outgoing,total:t.detail.outgoingTotal,endpoint:"to",onSelect:a=>void t.selectNode(a)}),e.jsx(Ie,{title:r("knowledgeGraph.incoming","Incoming"),edges:t.detail.incoming,total:t.detail.incomingTotal,endpoint:"from",onSelect:a=>void t.selectNode(a)})]}):e.jsx("p",{className:"knowledge-graph-muted",children:r("knowledgeGraph.selectNodeHint","Select a node to inspect its edges.")})})]}),t.detail&&e.jsxs("section",{className:"knowledge-graph-neighbors card",children:[e.jsx("h3",{children:r("knowledgeGraph.neighbors","Neighbors")}),e.jsxs("select",{className:"select","aria-label":"Neighbor direction",value:t.neighborOptions.direction,onChange:a=>t.setNeighborOptions({...t.neighborOptions,direction:a.target.value}),children:[e.jsx("option",{value:"out",children:r("knowledgeGraph.outgoing","Outgoing")}),e.jsx("option",{value:"in",children:r("knowledgeGraph.incoming","Incoming")}),e.jsx("option",{value:"both",children:r("knowledgeGraph.bothDirections","Both directions")})]}),e.jsx("select",{className:"select","aria-label":"Neighbor depth",value:t.neighborOptions.depth,onChange:a=>t.setNeighborOptions({...t.neighborOptions,depth:Number(a.target.value)}),children:[1,2,3].map(a=>e.jsx("option",{value:a,children:r("knowledgeGraph.depth","Depth {{depth}}",{depth:a})},a))}),e.jsx("div",{className:"knowledge-graph-kind-options",children:ht.map(a=>e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:(t.neighborOptions.edgeKinds??[]).includes(a),onChange:()=>E(a)})," ",a]},a))}),e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:()=>void t.refreshNeighbors(),children:r("knowledgeGraph.refreshNeighbors","Refresh neighbors")}),t.neighborResults?.neighbors.length?e.jsx("ul",{children:t.neighborResults.neighbors.map(a=>e.jsxs("li",{children:[e.jsx("span",{children:r("knowledgeGraph.distance","distance {{distance}}",{distance:a.distance})}),e.jsx(ve,{id:a.node.id,onSelect:h=>void t.selectNode(h)})]},a.node.id))}):e.jsx("p",{className:"knowledge-graph-muted",children:r("knowledgeGraph.noNeighbors","No neighbors found.")})]}),e.jsxs("section",{className:"knowledge-graph-path card",children:[e.jsx("h3",{children:r("knowledgeGraph.shortestPath","Shortest path")}),e.jsx("input",{className:"input","aria-label":"From node id",placeholder:"From node id",value:t.pathInput.fromId,onChange:a=>t.setPathInput({...t.pathInput,fromId:a.target.value})}),e.jsx("input",{className:"input","aria-label":"To node id",placeholder:"To node id",value:t.pathInput.toId,onChange:a=>t.setPathInput({...t.pathInput,toId:a.target.value})}),e.jsx("input",{className:"input","aria-label":"Maximum hops",type:"number",min:"1",max:f.maxHops,value:t.pathInput.maxHops,onChange:a=>t.setPathInput({...t.pathInput,maxHops:Number(a.target.value)})}),k&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:()=>t.setPathInput({...t.pathInput,fromId:k}),children:r("knowledgeGraph.useSelectedFrom","Use selected as from")}),e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:()=>t.setPathInput({...t.pathInput,toId:k}),children:r("knowledgeGraph.useSelectedTo","Use selected as to")})]}),e.jsx("button",{type:"button",className:"btn",onClick:()=>void t.findPath(),children:r("knowledgeGraph.findPath","Find path")}),w&&e.jsxs("div",{"data-testid":"knowledge-graph-path-found",children:[e.jsx("strong",{children:r("knowledgeGraph.hops","{{count}} hops",{count:m})}),e.jsx("div",{className:"knowledge-graph-path-chain",children:w.nodes.map((a,h)=>e.jsxs("span",{children:[e.jsx(ve,{id:a.id,onSelect:F=>void t.selectNode(F)}),h<w.edges.length&&e.jsx("em",{children:w.edges[h].kind})]},a.id))})]}),t.pathResult?.outcome==="not-found"&&e.jsx("p",{"data-testid":"knowledge-graph-path-not-found",children:r("knowledgeGraph.noPath","No path exists between these nodes.")}),t.pathResult?.outcome==="limit-reached"&&e.jsxs("div",{"data-testid":"knowledge-graph-path-limit-reached",children:[e.jsx("p",{children:r("knowledgeGraph.pathLimitReached","No path found within {{maxHops}} hops; {{limit}} was reached.",{maxHops:t.pathResult.maxHops,limit:t.pathResult.limit})}),t.pathInput.maxHops<f.maxHops&&e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:()=>t.setPathInput({...t.pathInput,maxHops:Math.min(f.maxHops,t.pathInput.maxHops+1)}),children:r("knowledgeGraph.raiseHopLimit","Raise hop limit")})]}),t.error&&e.jsx("p",{"data-testid":"knowledge-graph-path-error",className:"knowledge-graph-error",children:t.error})]})]})}const yt={Patterns:"pattern",Principles:"principle",Conventions:"convention",Pitfalls:"pitfall",Context:"context"},gt=72;function pt(i,s){if(i.length<=s)return i;const r=Math.max(1,s-1),t=Math.ceil(r/2),c=Math.floor(r/2);return`${i.slice(0,t)}…${i.slice(i.length-c)}`}function bt(i){const s=`${i.label} — ${i.path}`;return pt(s,gt)}function xt(i){if(!i)return[];const s=[],r=i.split(/(?=^## )/m);for(const t of r){const c=t.trim();if(!c)continue;const v=c.match(/^##\s+(.+?)(\n|$)/);if(v){const d=v[1].trim(),M=yt[d]??d.toLowerCase(),E=c.slice(v[0].length).replace(/<!--[\s\S]*?-->/g,"").trim(),k=E.split(`
1
+ import{r as n,j as e}from"./vendor-react-SZ_qB27O.js";import{u as $e,f as we,a as ke,s as Ke,i as _e,t as Ue,b as Ce,c as Ee,d as Be,e as Qe,g as We,h as Ve}from"./SettingsModal-B6U5Umru.js";import{a as ee,w as te,dc as Ye,a_ as Xe,V as Ze,dd as Je,L as _,aL as Fe}from"./index-oxnX59eO.js";import{u as Ne}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";function pe(i){const s=Object.entries(i).flatMap(([r,t])=>Array.isArray(t)?t.filter(Boolean).map(c=>[r,c]):t===void 0||t===""?[]:[[r,String(t)]]);return s.length?`?${s.map(([r,t])=>`${encodeURIComponent(r)}=${encodeURIComponent(t)}`).join("&")}`:""}function et(i){return ee(te("/knowledge/graph/status",i))}function tt(i,s={}){return ee(te(`/knowledge/graph/nodes${pe(s)}`,i))}function st(i,s){return ee(te(`/knowledge/graph/node${pe({id:s})}`,i))}function Ae(i,s){return ee(te(`/knowledge/graph/neighbors${pe(s)}`,i))}function at(i,s){return ee(te(`/knowledge/graph/path${pe(s)}`,i))}function nt(i,s=!1){return ee(te("/knowledge/graph/build",i),{method:"POST",body:JSON.stringify({force:s})})}const J=".fusion/memory/MEMORY.md",rt=5e4,lt="0 3 * * *",it="0 4 * * *";function ge(i){return{memoryEnabled:i.memoryEnabled!==!1,memoryAutoSummarizeEnabled:i.memoryAutoSummarizeEnabled??!1,memoryAutoSummarizeThresholdChars:i.memoryAutoSummarizeThresholdChars??rt,memoryAutoSummarizeSchedule:i.memoryAutoSummarizeSchedule??lt,memoryDreamsEnabled:i.memoryDreamsEnabled??!1,memoryDreamsSchedule:i.memoryDreamsSchedule??it}}function Me(i,s){return i.some(r=>r.path===s)?s:i.find(r=>r.path===J)?.path??i[0]?.path??J}function ot(i={}){const{projectId:s}=i,[r,t]=n.useState(null),[c,v]=n.useState(!0),[d,M]=n.useState(!1),[E,k]=n.useState(()=>ge({})),[f,w]=n.useState(!0),[m,a]=n.useState(!1),[h,F]=n.useState([]),[U,G]=n.useState(!0),[N,D]=n.useState(J),[I,R]=n.useState(""),[se,B]=n.useState(!1),[p,g]=n.useState(!1),[H,L]=n.useState(!1),[S,P]=n.useState(!1),[Y,T]=n.useState(!1),[x,Q]=n.useState(null),[u,y]=n.useState(!0),[b,W]=n.useState(!1),[le,ae]=n.useState(!1),{status:ne,loading:be,refresh:$}=$e({projectId:s}),re=n.useCallback(o=>{R(o),g(!0)},[]),X=n.useCallback(async o=>{B(!0);try{const{content:j}=await we(o,s);D(o),R(j),g(!1)}finally{B(!1)}},[s]),q=n.useCallback(async()=>{G(!0);try{const{files:o}=await ke(s);if(F(o),o.length===0){D(J),R(""),g(!1);return}const j=Me(o,N);j!==N&&await X(j)}finally{G(!1)}},[s,N,X]);n.useEffect(()=>{let o=!1;async function j(){try{const A=await Ee(s);o||(t(A.content),M(A.exists),v(!1))}catch{o||(t(null),M(!1),v(!1))}}return j(),()=>{o=!0}},[s]),n.useEffect(()=>{let o=!1;async function j(){w(!0);try{const A=await Xe(s);o||k(ge(A))}catch{o||k(ge({}))}finally{o||w(!1)}}return j(),()=>{o=!0}},[s]);const ie=n.useRef(N);n.useEffect(()=>{ie.current=N},[N]),n.useEffect(()=>{let o=!1;async function j(){G(!0);try{const{files:A}=await ke(s);if(o)return;if(F(A),A.length===0){D(J),R(""),g(!1);return}const ue=Me(A,ie.current),{content:je}=await we(ue,s);if(o)return;D(ue),R(je),g(!1)}catch{o||(F([]),D(J),R(""),g(!1))}finally{o||G(!1)}}return j(),()=>{o=!0}},[s]),n.useEffect(()=>{let o=!1;async function j(){try{const A=await Ce(s);o||(Q(A),y(!1))}catch{o||(Q(null),y(!1))}}return j(),()=>{o=!0}},[s]);const oe=n.useCallback(async o=>{a(!0);try{const j=await Ye(o,s);k(ge(j))}finally{a(!1)}},[s]),me=n.useCallback(async o=>{await X(o)},[X]),ce=n.useCallback(async()=>{if(p){L(!0);try{await Ke(N,I,s),g(!1),await q()}finally{L(!1)}}},[I,p,N,s,q]),de=n.useCallback(async()=>{ae(!0);try{const o=await _e(s);return await $(),o}finally{ae(!1)}},[s,$]),he=n.useCallback(async o=>Ue(o,s),[s]),Z=n.useCallback(async()=>{try{const o=await Ce(s);Q(o)}catch{Q(null)}},[s]),K=n.useCallback(async()=>{try{const o=await Ee(s);t(o.content),M(o.exists)}catch{t(null),M(!1)}},[s]),z=n.useCallback(async o=>{await Be(o,s),await K()},[s,K]),xe=n.useCallback(async()=>{P(!0);try{const o=await Qe(s);return await Promise.all([K(),Z()]),{success:o.success,summary:o.summary}}finally{P(!1)}},[s,K,Z]),V=n.useCallback(async()=>{T(!0);try{return await We(s)}finally{T(!1)}},[s]),fe=n.useCallback(async o=>{W(!0);try{const j=await Ve(o,s),A=j.path??o;D(A),R(j.content),g(!1),await q()}finally{W(!1)}},[s,q]);return{insightsContent:r,insightsLoading:c,insightsExists:d,refreshInsights:K,saveInsights:z,memorySettings:E,settingsLoading:f,savingMemorySettings:m,saveMemorySettings:oe,memoryFiles:h,memoryFilesLoading:U,selectedFilePath:N,selectedFileContent:I,selectedFileLoading:se,selectedFileDirty:p,setSelectedFileContent:re,selectFile:me,saveSelectedFile:ce,savingSelectedFile:H,reloadMemoryFiles:q,backendStatus:ne,backendLoading:be,extractInsights:xe,extracting:S,triggerDreamNow:V,dreamRunning:Y,auditReport:x,auditLoading:u,refreshAudit:Z,compactMemory:fe,compacting:b,installQmdAction:de,installingQmd:le,testRetrieval:he}}const De={limit:50,offset:0};function mt({projectId:i,enabled:s}){const[r,t]=n.useState(null),[c,v]=n.useState(De),[d,M]=n.useState(null),[E,k]=n.useState(null),[f,w]=n.useState(null),[m,a]=n.useState({direction:"both",depth:1}),[h,F]=n.useState(null),[U,G]=n.useState({fromId:"",toId:"",maxHops:6}),[N,D]=n.useState(null),[I,R]=n.useState(!1),[se,B]=n.useState(!1),[p,g]=n.useState(null),H=n.useRef(0),L=n.useRef(0),S=n.useRef(0),P=n.useCallback(async()=>{try{const u=await et(i);t(u),G(y=>({...y,maxHops:u.pathLimits.defaultMaxHops}))}catch(u){g(u instanceof Error?u.message:String(u))}},[i]);n.useEffect(()=>{P()},[s,P]),n.useEffect(()=>{if(!r?.available)return;const u=++H.current;R(!0);const y=window.setTimeout(()=>void tt(i,c).then(b=>{u===H.current&&M(b)}).catch(b=>{u===H.current&&g(b instanceof Error?b.message:String(b))}).finally(()=>{u===H.current&&R(!1)}),250);return()=>window.clearTimeout(y)},[s,c,i,r?.available]);const Y=n.useCallback(async(u=E)=>{if(!u)return;const y=++L.current;try{const b=await Ae(i,{nodeId:u,...m});y===L.current&&F(b)}catch(b){y===L.current&&g(b instanceof Error?b.message:String(b))}},[m,i,E]),T=n.useCallback(async u=>{const y=++L.current;k(u);try{const[b,W]=await Promise.all([st(i,u),Ae(i,{nodeId:u,...m})]);y===L.current&&(w(b),F(W))}catch(b){y===L.current&&g(b instanceof Error?b.message:String(b))}},[m,i]),x=n.useCallback(async()=>{const u=++S.current;D(null),g(null);try{const y=await at(i,U);u===S.current&&D(y)}catch(y){u===S.current&&g(y instanceof Error?y.message:String(y))}},[U,i]),Q=n.useCallback(async(u=!1)=>{B(!0);try{await nt(i,u),await P()}catch(y){g(y instanceof Error?y.message:String(y))}finally{B(!1)}},[i,P]);return{status:r,filters:c,setFilters:v,nodes:d,loading:I,selectedId:E,detail:f,selectNode:T,neighborOptions:m,setNeighborOptions:a,neighborResults:h,refreshNeighbors:Y,pathInput:U,setPathInput:G,pathResult:N,findPath:x,rebuild:Q,rebuilding:se,refreshStatus:P,error:p,clearFilters:()=>v(De)}}const ct=["file","module","symbol","doc-concept","rationale"],dt=["function","class","interface","type-alias","enum","variable","namespace","alias"],ht=["contains","imports","re-exports","relates-to","rationale-supports"];function ve({id:i,onSelect:s}){return e.jsx("button",{type:"button",className:"btn btn-ghost knowledge-graph-endpoint",onClick:()=>s(i),children:i})}function Ie({title:i,edges:s,total:r,endpoint:t,onSelect:c}){const{t:v}=Ne("app");return e.jsxs("section",{className:"knowledge-graph-edge-list",children:[e.jsxs("h4",{children:[i," ",e.jsx("span",{children:v("knowledgeGraph.showingOf","showing {{shown}} of {{total}}",{shown:s.length,total:r})})]}),s.length===0?e.jsx("p",{className:"knowledge-graph-muted",children:v("knowledgeGraph.none","None")}):e.jsx("ul",{children:s.map(d=>e.jsxs("li",{children:[e.jsx("span",{children:d.kind}),e.jsx("span",{className:`knowledge-graph-provenance knowledge-graph-provenance--${d.provenance}`,children:d.provenance}),e.jsx(ve,{id:d[t],onSelect:c})]},d.id))})]})}function ut({projectId:i,addToast:s}){const{t:r}=Ne("app"),t=mt({projectId:i,enabled:!0}),[c,v]=n.useState(!1);if(n.useEffect(()=>{t.error&&s(t.error,"error")},[s,t.error]),!t.status&&t.error)return e.jsx("div",{className:"knowledge-graph-panel knowledge-graph-error","data-testid":"knowledge-graph-error",children:t.error});if(!t.status)return e.jsx("div",{className:"knowledge-graph-panel","data-testid":"knowledge-graph-loading",children:r("memory.graphLoading","Loading knowledge graph…")});if(!t.status.available)return e.jsxs("div",{className:"knowledge-graph-panel knowledge-graph-empty","data-testid":"knowledge-graph-no-graph",children:[e.jsxs("p",{children:[r("memory.graphUnavailable","Graph unavailable"),": ",t.status.recoveryReason]}),e.jsx("button",{type:"button",className:"btn",onClick:()=>void t.rebuild(!1),children:r("memory.graphBuild","Build graph")})]});const d=a=>t.setFilters({...t.filters,...a,offset:0}),M=a=>{const h=t.filters.kinds??[];d({kinds:h.includes(a)?h.filter(F=>F!==a):[...h,a]})},E=a=>{const h=t.neighborOptions.edgeKinds??[];t.setNeighborOptions({...t.neighborOptions,edgeKinds:h.includes(a)?h.filter(F=>F!==a):[...h,a]})},k=t.selectedId,f=t.status.pathLimits,w=t.pathResult?.outcome==="found"?t.pathResult.path:null,m=t.pathResult?.outcome==="found"?t.pathResult.hops:void 0;return e.jsxs("section",{className:"knowledge-graph-panel","data-testid":"knowledge-graph-panel",children:[e.jsxs("header",{className:"knowledge-graph-status card",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[t.status.nodeCount," ",r("memory.graphNodes","nodes")," · ",t.status.edgeCount," ",r("memory.graphEdges","edges")]}),e.jsx("span",{children:t.status.graphDir})]}),e.jsxs("dl",{children:[e.jsxs("div",{children:[e.jsx("dt",{children:r("knowledgeGraph.nodeKinds","Node kinds")}),e.jsx("dd",{children:Object.entries(t.status.nodeKindCounts??{}).map(([a,h])=>`${a}: ${h}`).join(" · ")||"—"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:r("knowledgeGraph.edgeKinds","Edge kinds")}),e.jsx("dd",{children:Object.entries(t.status.edgeKindCounts??{}).map(([a,h])=>`${a}: ${h}`).join(" · ")||"—"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:r("knowledgeGraph.provenance","Provenance")}),e.jsx("dd",{children:Object.entries(t.status.provenanceCounts??{}).map(([a,h])=>`${a}: ${h}`).join(" · ")||"—"})]})]}),e.jsxs("label",{className:"knowledge-graph-toggle",children:[e.jsx("input",{type:"checkbox",checked:c,onChange:a=>v(a.target.checked)})," ",r("memory.graphForce","Force rebuild")]}),e.jsx("button",{type:"button",className:"btn",disabled:t.rebuilding,onClick:()=>void t.rebuild(c),children:t.rebuilding?r("memory.graphRebuilding","Rebuilding…"):r("memory.graphRebuild","Rebuild")})]}),e.jsxs("section",{className:"knowledge-graph-filters card","aria-label":r("memory.graphFilters","Graph filters"),children:[e.jsx("div",{className:"knowledge-graph-kind-options",children:ct.map(a=>e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:(t.filters.kinds??[]).includes(a),onChange:()=>M(a)})," ",a]},a))}),e.jsx("input",{className:"input","aria-label":"Path prefix",placeholder:"Path prefix",value:t.filters.pathPrefix??"",onChange:a=>d({pathPrefix:a.target.value})}),e.jsx("input",{className:"input","aria-label":"Node id prefix",placeholder:"Node id prefix",value:t.filters.idPrefix??"",onChange:a=>d({idPrefix:a.target.value})}),e.jsx("input",{className:"input","aria-label":"Name regex",placeholder:"Name regex",value:t.filters.namePattern??"",onChange:a=>d({namePattern:a.target.value})}),e.jsxs("select",{className:"select","aria-label":"FNXC area",value:t.filters.fnxcArea??"",onChange:a=>d({fnxcArea:a.target.value||void 0}),children:[e.jsx("option",{value:"",children:r("knowledgeGraph.allFnxcAreas","All FNXC areas")}),t.status.fnxcAreas?.map(a=>e.jsx("option",{value:a,children:a},a))]}),e.jsxs("select",{className:"select","aria-label":"Symbol kind",value:t.filters.symbolKind??"",onChange:a=>d({symbolKind:a.target.value||void 0}),children:[e.jsx("option",{value:"",children:r("knowledgeGraph.allSymbolKinds","All symbol kinds")}),dt.map(a=>e.jsx("option",{children:a},a))]}),e.jsxs("select",{className:"select","aria-label":"Owner",value:t.filters.owner??"",onChange:a=>d({owner:a.target.value||void 0}),children:[e.jsx("option",{value:"",children:r("knowledgeGraph.allOwners","All owners")}),e.jsx("option",{value:"file",children:r("knowledgeGraph.ownerFile","file")}),e.jsx("option",{value:"derived",children:r("knowledgeGraph.ownerDerived","derived")})]}),e.jsx("select",{className:"select","aria-label":"Result limit",value:t.filters.limit??50,onChange:a=>d({limit:Number(a.target.value)}),children:[25,50,100,200].map(a=>e.jsx("option",{value:a,children:r("knowledgeGraph.limitResults","{{limit}} results",{limit:a})},a))}),e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:t.clearFilters,children:r("memory.graphClearFilters","Clear filters")})]}),e.jsxs("div",{className:"knowledge-graph-layout",children:[e.jsxs("section",{className:"card knowledge-graph-results",children:[e.jsxs("h3",{children:[t.nodes?.total??0," ",r("memory.graphResults","results")]}),t.loading?e.jsx("p",{"data-testid":"knowledge-graph-searching",children:r("knowledgeGraph.searching","Searching…")}):t.nodes?.nodes.length?e.jsxs(e.Fragment,{children:[e.jsx("ul",{children:t.nodes.nodes.map(a=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"btn btn-ghost",onClick:()=>void t.selectNode(a.id),children:[e.jsxs("strong",{children:[a.kind,": ",a.name]}),e.jsxs("span",{children:[a.id," · ",a.ownerPath,":",a.source.line]})]})},a.id))}),e.jsxs("div",{className:"knowledge-graph-pagination",children:[e.jsx("button",{type:"button",className:"btn btn-ghost",disabled:!t.filters.offset,onClick:()=>d({offset:Math.max(0,(t.filters.offset??0)-(t.filters.limit??50))}),children:r("knowledgeGraph.previous","Previous")}),e.jsx("button",{type:"button",className:"btn btn-ghost",disabled:(t.filters.offset??0)+(t.filters.limit??50)>=(t.nodes?.total??0),onClick:()=>d({offset:(t.filters.offset??0)+(t.filters.limit??50)}),children:r("knowledgeGraph.next","Next")})]})]}):e.jsx("p",{"data-testid":"knowledge-graph-no-results",children:r("memory.graphNoResults","No matching nodes.")})]}),e.jsx("section",{className:"card knowledge-graph-detail",children:t.detail?e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:t.detail.node.name}),e.jsx("p",{children:t.detail.node.id}),e.jsxs("p",{children:[t.detail.node.ownerPath,":",t.detail.node.source.line]}),e.jsx(Ie,{title:r("knowledgeGraph.outgoing","Outgoing"),edges:t.detail.outgoing,total:t.detail.outgoingTotal,endpoint:"to",onSelect:a=>void t.selectNode(a)}),e.jsx(Ie,{title:r("knowledgeGraph.incoming","Incoming"),edges:t.detail.incoming,total:t.detail.incomingTotal,endpoint:"from",onSelect:a=>void t.selectNode(a)})]}):e.jsx("p",{className:"knowledge-graph-muted",children:r("knowledgeGraph.selectNodeHint","Select a node to inspect its edges.")})})]}),t.detail&&e.jsxs("section",{className:"knowledge-graph-neighbors card",children:[e.jsx("h3",{children:r("knowledgeGraph.neighbors","Neighbors")}),e.jsxs("select",{className:"select","aria-label":"Neighbor direction",value:t.neighborOptions.direction,onChange:a=>t.setNeighborOptions({...t.neighborOptions,direction:a.target.value}),children:[e.jsx("option",{value:"out",children:r("knowledgeGraph.outgoing","Outgoing")}),e.jsx("option",{value:"in",children:r("knowledgeGraph.incoming","Incoming")}),e.jsx("option",{value:"both",children:r("knowledgeGraph.bothDirections","Both directions")})]}),e.jsx("select",{className:"select","aria-label":"Neighbor depth",value:t.neighborOptions.depth,onChange:a=>t.setNeighborOptions({...t.neighborOptions,depth:Number(a.target.value)}),children:[1,2,3].map(a=>e.jsx("option",{value:a,children:r("knowledgeGraph.depth","Depth {{depth}}",{depth:a})},a))}),e.jsx("div",{className:"knowledge-graph-kind-options",children:ht.map(a=>e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:(t.neighborOptions.edgeKinds??[]).includes(a),onChange:()=>E(a)})," ",a]},a))}),e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:()=>void t.refreshNeighbors(),children:r("knowledgeGraph.refreshNeighbors","Refresh neighbors")}),t.neighborResults?.neighbors.length?e.jsx("ul",{children:t.neighborResults.neighbors.map(a=>e.jsxs("li",{children:[e.jsx("span",{children:r("knowledgeGraph.distance","distance {{distance}}",{distance:a.distance})}),e.jsx(ve,{id:a.node.id,onSelect:h=>void t.selectNode(h)})]},a.node.id))}):e.jsx("p",{className:"knowledge-graph-muted",children:r("knowledgeGraph.noNeighbors","No neighbors found.")})]}),e.jsxs("section",{className:"knowledge-graph-path card",children:[e.jsx("h3",{children:r("knowledgeGraph.shortestPath","Shortest path")}),e.jsx("input",{className:"input","aria-label":"From node id",placeholder:"From node id",value:t.pathInput.fromId,onChange:a=>t.setPathInput({...t.pathInput,fromId:a.target.value})}),e.jsx("input",{className:"input","aria-label":"To node id",placeholder:"To node id",value:t.pathInput.toId,onChange:a=>t.setPathInput({...t.pathInput,toId:a.target.value})}),e.jsx("input",{className:"input","aria-label":"Maximum hops",type:"number",min:"1",max:f.maxHops,value:t.pathInput.maxHops,onChange:a=>t.setPathInput({...t.pathInput,maxHops:Number(a.target.value)})}),k&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:()=>t.setPathInput({...t.pathInput,fromId:k}),children:r("knowledgeGraph.useSelectedFrom","Use selected as from")}),e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:()=>t.setPathInput({...t.pathInput,toId:k}),children:r("knowledgeGraph.useSelectedTo","Use selected as to")})]}),e.jsx("button",{type:"button",className:"btn",onClick:()=>void t.findPath(),children:r("knowledgeGraph.findPath","Find path")}),w&&e.jsxs("div",{"data-testid":"knowledge-graph-path-found",children:[e.jsx("strong",{children:r("knowledgeGraph.hops","{{count}} hops",{count:m})}),e.jsx("div",{className:"knowledge-graph-path-chain",children:w.nodes.map((a,h)=>e.jsxs("span",{children:[e.jsx(ve,{id:a.id,onSelect:F=>void t.selectNode(F)}),h<w.edges.length&&e.jsx("em",{children:w.edges[h].kind})]},a.id))})]}),t.pathResult?.outcome==="not-found"&&e.jsx("p",{"data-testid":"knowledge-graph-path-not-found",children:r("knowledgeGraph.noPath","No path exists between these nodes.")}),t.pathResult?.outcome==="limit-reached"&&e.jsxs("div",{"data-testid":"knowledge-graph-path-limit-reached",children:[e.jsx("p",{children:r("knowledgeGraph.pathLimitReached","No path found within {{maxHops}} hops; {{limit}} was reached.",{maxHops:t.pathResult.maxHops,limit:t.pathResult.limit})}),t.pathInput.maxHops<f.maxHops&&e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:()=>t.setPathInput({...t.pathInput,maxHops:Math.min(f.maxHops,t.pathInput.maxHops+1)}),children:r("knowledgeGraph.raiseHopLimit","Raise hop limit")})]}),t.error&&e.jsx("p",{"data-testid":"knowledge-graph-path-error",className:"knowledge-graph-error",children:t.error})]})]})}const yt={Patterns:"pattern",Principles:"principle",Conventions:"convention",Pitfalls:"pitfall",Context:"context"},gt=72;function pt(i,s){if(i.length<=s)return i;const r=Math.max(1,s-1),t=Math.ceil(r/2),c=Math.floor(r/2);return`${i.slice(0,t)}…${i.slice(i.length-c)}`}function bt(i){const s=`${i.label} — ${i.path}`;return pt(s,gt)}function xt(i){if(!i)return[];const s=[],r=i.split(/(?=^## )/m);for(const t of r){const c=t.trim();if(!c)continue;const v=c.match(/^##\s+(.+?)(\n|$)/);if(v){const d=v[1].trim(),M=yt[d]??d.toLowerCase(),E=c.slice(v[0].length).replace(/<!--[\s\S]*?-->/g,"").trim(),k=E.split(`
2
2
  `).reduce((f,w)=>{const m=w.trim();return/^[-*]\s+/.test(w)?f.push(m.replace(/^[-*]\s+/,"")):m.length>0&&f.length>0&&(f[f.length-1]=`${f[f.length-1]}
3
3
  ${w.trimEnd()}`),f},[]);(k.length>0||E.length>0)&&s.push({name:d,key:M,items:k.length>0?k:E.length>0?[E]:[],expanded:!0})}}return s}function ft(i){if(!i)return null;const s=i.match(/##\s+Last\s+Updated:\s*(\d{4}-\d{2}-\d{2})/i);return s?s[1]:null}function jt(i){return i.reduce((s,r)=>s+r.items.length,0)}function Ft({projectId:i,addToast:s,onSendSelectionToTask:r}){const{t}=Ne("app"),[c,v]=n.useState("working"),[d,M]=n.useState(new Set),[E,k]=n.useState(!1),[f,w]=n.useState(null),[m,a]=n.useState({memoryEnabled:!0,memoryAutoSummarizeEnabled:!1,memoryAutoSummarizeThresholdChars:5e4,memoryAutoSummarizeSchedule:"0 3 * * *",memoryDreamsEnabled:!1,memoryDreamsSchedule:"0 4 * * *"}),[h,F]=n.useState(""),[U,G]=n.useState(!1),[N,D]=n.useState(null),{insightsContent:I,insightsLoading:R,insightsExists:se,saveInsights:B,memorySettings:p,settingsLoading:g,saveMemorySettings:H,savingMemorySettings:L,backendStatus:S,backendLoading:P,extractInsights:Y,extracting:T,auditReport:x,auditLoading:Q,refreshAudit:u,compactMemory:y,compacting:b,installQmdAction:W,installingQmd:le,testRetrieval:ae,memoryFiles:ne,memoryFilesLoading:be,selectedFilePath:$,selectedFileContent:re,selectedFileLoading:X,selectedFileDirty:q,setSelectedFileContent:ie,selectFile:oe,saveSelectedFile:me,savingSelectedFile:ce,reloadMemoryFiles:de,triggerDreamNow:he,dreamRunning:Z}=ot({projectId:i});n.useEffect(()=>{a(p)},[p]);const K=n.useMemo(()=>m.memoryEnabled!==p.memoryEnabled||m.memoryAutoSummarizeEnabled!==p.memoryAutoSummarizeEnabled||m.memoryAutoSummarizeThresholdChars!==p.memoryAutoSummarizeThresholdChars||m.memoryAutoSummarizeSchedule!==p.memoryAutoSummarizeSchedule||m.memoryDreamsEnabled!==p.memoryDreamsEnabled||m.memoryDreamsSchedule!==p.memoryDreamsSchedule,[m,p]),z=n.useMemo(()=>ne.find(l=>l.path===$),[ne,$]),xe=z?z.layer==="long-term"?t("memory.layerDescLongTerm","Curated durable decisions, conventions, constraints, and pitfalls promoted from dreams."):z.layer==="daily"?t("memory.layerDescDaily","Raw daily observations, open loops, and running context for dream processing."):t("memory.layerDescDreams","Synthesized patterns and open loops promoted from daily memory."):t("memory.editorDefaultDescription","Edits the selected memory file."),V=n.useMemo(()=>xt(I),[I]),fe=n.useMemo(()=>jt(V),[V]),o=n.useMemo(()=>ft(I),[I]),j=n.useCallback(l=>{M(C=>{const O=new Set(C);return O.has(l)?O.delete(l):O.add(l),O})},[]),A=n.useCallback(async l=>{try{await oe(l)}catch{s(t("memory.loadFileFailed","Failed to load memory file"),"error")}},[oe,s]),ue=n.useCallback(async()=>{try{await me(),s(t("memory.memorySaved","Memory saved"),"success")}catch{s(t("memory.saveMemoryFailed","Failed to save memory"),"error")}},[me,s]),je=n.useCallback(async()=>{if(!K)return;const l={};m.memoryEnabled!==p.memoryEnabled&&(l.memoryEnabled=m.memoryEnabled),m.memoryAutoSummarizeEnabled!==p.memoryAutoSummarizeEnabled&&(l.memoryAutoSummarizeEnabled=m.memoryAutoSummarizeEnabled),m.memoryAutoSummarizeThresholdChars!==p.memoryAutoSummarizeThresholdChars&&(l.memoryAutoSummarizeThresholdChars=m.memoryAutoSummarizeThresholdChars),m.memoryAutoSummarizeSchedule!==p.memoryAutoSummarizeSchedule&&(l.memoryAutoSummarizeSchedule=m.memoryAutoSummarizeSchedule),m.memoryDreamsEnabled!==p.memoryDreamsEnabled&&(l.memoryDreamsEnabled=m.memoryDreamsEnabled),m.memoryDreamsSchedule!==p.memoryDreamsSchedule&&(l.memoryDreamsSchedule=m.memoryDreamsSchedule);try{await H(l),s(t("memory.settingsSaved","Memory settings saved"),"success")}catch{s(t("memory.saveSettingsFailed","Failed to save memory settings"),"error")}},[K,m,p,H,s]),Re=n.useCallback(async()=>{try{const l=await W();s(l.qmdAvailable?t("memory.qmdInstallSuccess","qmd installed successfully"):t("memory.qmdInstallUnavailable","qmd install finished, but qmd is still unavailable"),l.qmdAvailable?"success":"info")}catch{s(t("memory.installQmdFailed","Failed to install qmd"),"error")}},[W,s]),Le=n.useCallback(async()=>{G(!0),D(null);try{const l=await ae(h);D(l),s(l.qmdAvailable?t("memory.retrievalTestComplete","Memory retrieval test complete"):t("memory.retrievalTestFallback","qmd is not installed; local fallback was used"),l.qmdAvailable?"success":"info")}catch{s(t("memory.retrievalTestFailed","Failed to test memory retrieval"),"error")}finally{G(!1)}},[h,ae,s]),ze=n.useCallback(async()=>{try{await he(),s(t("memory.dreamProcessingComplete","Dream processing completed"),"success"),await de()}catch(l){s(l instanceof Error?l.message:t("memory.dreamProcessingFailed","Failed to run dream processing"),"error")}},[he,de,s]),Pe=n.useCallback(async()=>{try{await y($),s(t("memory.fileCompacted","Memory file compacted"),"success")}catch{s(t("memory.compactFailed","Failed to compact memory"),"error")}},[y,$,s]),Se=n.useCallback(async()=>{try{const l=await Y();s(l.summary,"success")}catch(l){s(l instanceof Error?l.message:t("memory.extractInsightsFailed","Failed to extract insights"),"error")}},[Y,s]),Ge=n.useCallback(async()=>{if(f!==null)try{await B(f),k(!1),w(null),s(t("memory.insightsSaved","Insights saved"),"success")}catch{s(t("memory.saveInsightsFailed","Failed to save insights"),"error")}},[f,B,s]),qe=n.useCallback(()=>{w(I??""),k(!0)},[I]),Oe=n.useCallback(()=>{k(!1),w(null)},[]),He=!P&&S!==null,ye=S?.capabilities?.writable??!1;return e.jsxs("div",{className:"memory-view",children:[e.jsx(Ze,{icon:Je,title:t("memory.title","Memory")}),e.jsxs("div",{className:"memory-view-tabs",role:"tablist",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":c==="working",className:`memory-view-tab${c==="working"?" memory-view-tab--active":""}`,onClick:()=>v("working"),"data-testid":"memory-tab-working",children:t("memory.tabWorking","Working Memory")}),e.jsx("button",{type:"button",role:"tab","aria-selected":c==="insights",className:`memory-view-tab${c==="insights"?" memory-view-tab--active":""}`,onClick:()=>v("insights"),"data-testid":"memory-tab-insights",children:t("memory.tabInsights","Insights")}),e.jsx("button",{type:"button",role:"tab","aria-selected":c==="graph",className:`memory-view-tab${c==="graph"?" memory-view-tab--active":""}`,onClick:()=>v("graph"),"data-testid":"memory-tab-graph",children:t("memory.tabGraph","Knowledge Graph")}),e.jsx("button",{type:"button",role:"tab","aria-selected":c==="engines",className:`memory-view-tab${c==="engines"?" memory-view-tab--active":""}`,onClick:()=>v("engines"),"data-testid":"memory-tab-engines",children:t("memory.tabEngines","Engines")})]}),e.jsxs("div",{className:"memory-view-content",children:[c==="graph"&&e.jsx(ut,{projectId:i,addToast:s}),c==="working"&&e.jsxs("div",{className:"memory-working-tab",children:[He&&!ye&&e.jsx("div",{className:"memory-readonly-banner",children:t("memory.readOnlyBanner","This memory backend is read-only. Changes cannot be saved.")}),be||X?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(_,{size:20,className:"animate-spin"}),e.jsx("span",{children:t("memory.loadingFile","Loading memory file…")})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"memory-editor-section",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryViewFilePath",children:t("memory.fileLabel","Memory File")}),e.jsx("select",{id:"memoryViewFilePath",className:"select",value:$,onChange:l=>{A(l.target.value)},disabled:q,children:ne.map(l=>e.jsx("option",{value:l.path,title:`${l.label} — ${l.path}`,children:bt(l)},l.path))}),e.jsx("small",{children:q?t("memory.fileSwitchDirtyHint","Save or discard the current edits before switching files."):t("memory.fileSwitchHint","Choose any project memory file to view or edit.")})]}),z&&e.jsxs("div",{className:"memory-file-summary",children:[e.jsx("span",{children:z.layer==="long-term"?t("memory.layerLongTerm","Long-term"):z.layer==="daily"?t("memory.layerDaily","Daily"):t("memory.layerDreams","Dreams")}),e.jsx("strong",{children:z.path}),e.jsx("small",{children:t("memory.fileSummary","{{size}} bytes · updated {{updatedAt}}",{size:z.size.toLocaleString(),updatedAt:new Date(z.updatedAt).toLocaleString()})})]}),e.jsxs("div",{className:"form-group memory-editor-form-group",children:[e.jsx("label",{children:z?.label||t("memory.editorLabel","Memory Editor")}),e.jsx("small",{children:xe}),e.jsx("div",{className:"memory-editor-container",children:e.jsx(Fe,{content:re,onChange:ie,readOnly:!ye,filePath:$,forceToolbarActionsVisible:!0,onSendSelectionToTask:r})})]})]}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("span",{className:"memory-char-count",children:t("memory.charCount","{{count}} characters",{count:re.length})}),e.jsx("div",{className:"memory-flex-spacer"}),ye&&re.length>0&&e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Pe,disabled:b||q,children:b?e.jsxs(e.Fragment,{children:[e.jsx(_,{size:14,className:"animate-spin"}),t("memory.compacting","Compacting…")]}):t("memory.compactSelectedFile","Compact Selected File")}),q&&ye&&e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:ue,disabled:ce,children:ce?e.jsxs(e.Fragment,{children:[e.jsx(_,{size:14,className:"animate-spin"}),t("memory.saving","Saving…")]}):t("memory.save","Save")})]}),e.jsxs("div",{className:"memory-config-section",children:[e.jsxs("div",{className:"memory-settings-group",children:[e.jsxs("div",{className:"form-group memory-toggle-row",children:[e.jsxs("label",{htmlFor:"memoryDreamsEnabled",className:"checkbox-label",title:t("memory.dreamsEnabledTooltip","Daily notes are distilled into DREAMS.md and reusable lessons are promoted into MEMORY.md."),children:[e.jsx("input",{id:"memoryDreamsEnabled",type:"checkbox",checked:m.memoryDreamsEnabled,onChange:l=>{a(C=>({...C,memoryDreamsEnabled:l.target.checked}))},disabled:!m.memoryEnabled||g}),t("memory.dreamsEnabledLabel","Process dreams from daily memory")]}),e.jsx("small",{children:t("memory.dreamsEnabledHint","Turns daily notes into DREAMS.md and promotes reusable lessons into MEMORY.md.")})]}),m.memoryEnabled&&m.memoryDreamsEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryDreamsSchedule",children:t("memory.dreamsScheduleLabel","Dream Schedule")}),e.jsx("input",{id:"memoryDreamsSchedule",type:"text",className:"input",value:m.memoryDreamsSchedule,onChange:l=>{a(C=>({...C,memoryDreamsSchedule:l.target.value}))},placeholder:"0 4 * * *",disabled:g}),e.jsx("small",{children:t("memory.dreamsScheduleHint","Cron expression for dream processing.")})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("button",{type:"button",className:"btn btn-sm",onClick:ze,disabled:Z||!m.memoryDreamsEnabled,children:Z?e.jsxs(e.Fragment,{children:[e.jsx(_,{size:14,className:"animate-spin"}),t("memory.dreaming","Dreaming…")]}):t("memory.dreamNow","Dream Now")}),e.jsx("small",{children:t("memory.dreamNowHint","Manually trigger dream processing now.")})]})]})]}),e.jsxs("div",{className:"memory-settings-group",children:[e.jsxs("div",{className:"form-group memory-toggle-row",children:[e.jsxs("label",{htmlFor:"memoryAutoSummarizeEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"memoryAutoSummarizeEnabled",type:"checkbox",checked:m.memoryAutoSummarizeEnabled,onChange:l=>{a(C=>({...C,memoryAutoSummarizeEnabled:l.target.checked}))},disabled:!m.memoryEnabled||g}),t("memory.autoSummarizeLabel","Auto-summarize memory")]}),e.jsx("small",{children:t("memory.autoSummarizeHint","Automatically compacts memory when it exceeds the threshold on a schedule.")})]}),m.memoryEnabled&&m.memoryAutoSummarizeEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryAutoSummarizeThresholdChars",children:t("memory.compactionThresholdLabel","Compaction Threshold (chars)")}),e.jsx("input",{id:"memoryAutoSummarizeThresholdChars",type:"number",className:"input",value:m.memoryAutoSummarizeThresholdChars,onChange:l=>{a(C=>({...C,memoryAutoSummarizeThresholdChars:parseInt(l.target.value,10)||5e4}))},min:1e3,disabled:g}),e.jsx("small",{children:t("memory.compactionThresholdHint","Memory will be compacted when it exceeds this character count")})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryAutoSummarizeSchedule",children:t("memory.autoSummarizeScheduleLabel","Schedule (cron)")}),e.jsx("input",{id:"memoryAutoSummarizeSchedule",type:"text",className:"input",value:m.memoryAutoSummarizeSchedule,onChange:l=>{a(C=>({...C,memoryAutoSummarizeSchedule:l.target.value}))},placeholder:"0 3 * * *",disabled:g}),e.jsx("small",{children:t("memory.autoSummarizeScheduleHint","Cron expression for auto-summarize schedule (default: daily at 3 AM)")})]})]})]}),!m.memoryEnabled&&e.jsx("div",{className:"settings-empty-state memory-status-message",children:t("memory.disabledMessage","Memory is currently disabled. Enable memory tools in Settings to edit these automations.")}),K&&e.jsx("div",{className:"memory-action-bar",children:e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:je,disabled:L||g,children:L?e.jsxs(e.Fragment,{children:[e.jsx(_,{size:14,className:"animate-spin"}),t("memory.saving","Saving…")]}):t("memory.saveSettings","Save Settings")})})]})]})]}),c==="insights"&&e.jsx("div",{className:"memory-insights-tab",children:R?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(_,{size:20,className:"animate-spin"}),e.jsx("span",{children:t("memory.loadingInsights","Loading insights…")})]}):E?e.jsxs("div",{className:"memory-insights-editor-layout",children:[e.jsx("div",{className:"memory-editor-container",children:e.jsx(Fe,{content:f??"",onChange:w,readOnly:!1,filePath:".fusion/memory/memory-insights.md",forceToolbarActionsVisible:!0,onSendSelectionToTask:r})}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Oe,children:t("memory.cancel","Cancel")}),e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:Ge,children:t("memory.saveInsights","Save Insights")})]})]}):!se||V.length===0?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx("p",{children:t("memory.noInsights","No insights extracted yet.")}),e.jsx("p",{children:t("memory.noInsightsHint",'Insights are automatically extracted from working memory. Click "Extract Now" to trigger extraction manually.')}),e.jsx("button",{type:"button",className:"btn btn-primary btn-sm memory-empty-extract-button",onClick:Se,disabled:T,children:T?e.jsxs(e.Fragment,{children:[e.jsx(_,{size:14,className:"animate-spin"}),t("memory.extracting","Extracting…")]}):t("memory.extractNow","Extract Now")})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"memory-stats-row",children:[e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-value",children:fe}),e.jsx("div",{className:"memory-stat-label",children:t("memory.totalInsights","Total Insights")})]}),e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-value",children:V.length}),e.jsx("div",{className:"memory-stat-label",children:t("memory.categories","Categories")})]}),o&&e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-value memory-stat-value--updated",children:o}),e.jsx("div",{className:"memory-stat-label",children:t("memory.lastUpdated","Last Updated")})]})]}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:Se,disabled:T,children:T?e.jsxs(e.Fragment,{children:[e.jsx(_,{size:14,className:"animate-spin"}),t("memory.extracting","Extracting…")]}):t("memory.extractNow","Extract Now")}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:qe,children:t("memory.editRaw","Edit Raw")})]}),e.jsx("div",{className:"memory-categories-list",children:V.map(l=>{const C=!d.has(l.key);return e.jsxs("div",{className:"memory-category-section",children:[e.jsxs("div",{className:"memory-category-header",onClick:()=>j(l.key),role:"button",tabIndex:0,onKeyDown:O=>{(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),j(l.key))},children:[e.jsx("h4",{children:l.name}),e.jsx("span",{className:"memory-category-count",children:l.items.length})]}),C&&e.jsx("div",{className:"memory-category-items",children:l.items.map((O,Te)=>e.jsx("div",{className:"memory-insight-item",children:O.replace(/^-\s+/,"").replace(/^\*\s+/,"")},Te))})]},l.key)})})]})}),c==="engines"&&e.jsx("div",{className:"memory-engines-tab",children:P||Q?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(_,{size:20,className:"animate-spin"}),e.jsx("span",{children:t("memory.loadingEngineStatus","Loading engine status…")})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"memory-engine-card memory-qmd-card",children:[e.jsx("h3",{children:t("memory.qmdIntegrationTitle","QMD Integration")}),S?.qmdAvailable===!0?e.jsxs("div",{className:"memory-engine-status",children:[e.jsx("span",{className:"memory-health-badge memory-health-badge--healthy",children:t("memory.qmdInstalled","Installed")}),e.jsx("span",{className:"memory-char-count",children:t("memory.qmdAvailableOnPath","qmd is available on PATH.")})]}):S?.qmdAvailable===!1?e.jsxs("div",{className:"settings-empty-state memory-status-message",children:[e.jsxs("span",{children:[t("memory.qmdNotInstalled","qmd is not installed. Search will use local files. Install indexed retrieval:")," ",e.jsx("code",{children:S.qmdInstallCommand||"bun install -g @tobilu/qmd"})]}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Re,disabled:le,children:le?t("memory.installing","Installing…"):t("memory.installQmd","Install qmd")})]}):e.jsxs("div",{className:"memory-engine-status",children:[e.jsx("span",{className:"memory-health-badge",children:t("memory.qmdChecking","Checking")}),e.jsx("span",{className:"memory-char-count",children:t("memory.qmdCheckingAvailability","Checking qmd availability…")})]})]}),e.jsxs("div",{className:"memory-engine-card memory-retrieval-card",children:[e.jsx("h3",{children:t("memory.testMemorySearchTitle","Test Memory Search")}),e.jsxs("div",{className:"memory-retrieval-input-row",children:[e.jsx("input",{type:"text",className:"input",value:h,onChange:l=>F(l.target.value),placeholder:t("memory.searchPlaceholder","Search memory with qmd")}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Le,disabled:U,children:U?t("memory.testing","Testing…"):t("memory.testRetrieval","Test Retrieval")})]}),e.jsx("small",{className:"settings-muted",children:t("memory.testSearchHint","Runs the same qmd-backed memory_search path agents use.")}),N&&e.jsxs("div",{className:"memory-test-result",children:[e.jsx("strong",{children:t("memory.testResultCount",'{{count}} result for "{{query}}"',{count:N.results.length,query:N.query,defaultValue_one:'{{count}} result for "{{query}}"',defaultValue_other:'{{count}} results for "{{query}}"'})}),e.jsx("small",{children:t("memory.testResultStatus","qmd {{qmdStatus}} · {{fallbackStatus}}",{qmdStatus:N.qmdAvailable?t("memory.qmdStatusAvailable","available"):t("memory.qmdStatusMissing","missing"),fallbackStatus:N.usedFallback?t("memory.localFallbackUsed","local fallback used"):t("memory.qmdPathUsed","qmd path used")})}),N.results.length>0?e.jsx("ul",{children:N.results.map((l,C)=>e.jsxs("li",{children:[e.jsxs("span",{children:[l.path,":",l.lineStart]}),e.jsx("p",{children:l.snippet})]},`${l.path}-${l.lineStart}-${C}`))}):e.jsx("small",{children:t("memory.noMatchingMemory","No matching memory found.")})]})]}),e.jsxs("div",{className:"memory-engine-card",children:[e.jsx("h3",{children:t("memory.currentBackendTitle","Current Backend")}),e.jsx("div",{className:"memory-engine-status",children:e.jsx("span",{className:"memory-emphasis-text",children:S?.currentBackend==="file"?t("memory.backendFile","File (.fusion/memory/, agent/<agent-name>/memory/)"):S?.currentBackend==="readonly"?t("memory.backendReadonly","Read-Only"):S?.currentBackend==="qmd"?t("memory.backendQmd","QMD (Quantized Memory Distillation)"):S?.currentBackend??"unknown"})}),e.jsxs("div",{className:"memory-capability-row",children:[S?.capabilities?.readable&&e.jsx("span",{className:"memory-capability-badge",children:t("memory.capReadable","Readable")}),S?.capabilities?.writable&&e.jsx("span",{className:"memory-capability-badge",children:t("memory.capWritable","Writable")}),S?.capabilities?.supportsAtomicWrite&&e.jsx("span",{className:"memory-capability-badge",children:t("memory.capAtomicWrites","Atomic Writes")}),S?.capabilities?.persistent&&e.jsx("span",{className:"memory-capability-badge",children:t("memory.capPersistent","Persistent")})]})]}),x&&e.jsxs("div",{className:"memory-engine-card",children:[e.jsxs("div",{className:"memory-health-header",children:[e.jsx("h3",{children:t("memory.healthStatusTitle","Health Status")}),e.jsx("span",{className:`memory-health-badge memory-health-badge--${x.health}`,children:x.health==="healthy"?t("memory.healthHealthy","Healthy"):x.health==="warning"?t("memory.healthWarning","Warning"):t("memory.healthIssues","Issues Found")})]}),e.jsxs("div",{className:"memory-health-grid",children:[e.jsxs("div",{children:[e.jsx("div",{className:"memory-health-label",children:t("memory.workingMemoryLabel","Working Memory")}),e.jsx("div",{className:"memory-emphasis-text",children:t("memory.sizeChars","{{size}} chars",{size:x.workingMemory.size})}),e.jsx("div",{className:"memory-health-detail",children:t("memory.sectionCount","{{count}} sections",{count:x.workingMemory.sectionCount})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"memory-health-label",children:t("memory.insightsMemoryLabel","Insights Memory")}),e.jsx("div",{className:"memory-emphasis-text",children:t("memory.sizeChars","{{size}} chars",{size:x.insightsMemory.size})}),e.jsx("div",{className:"memory-health-detail",children:t("memory.insightCount","{{count}} insights",{count:x.insightsMemory.insightCount})})]})]}),e.jsxs("div",{className:"memory-health-section",children:[e.jsx("div",{className:"memory-health-label",children:t("memory.lastExtractionLabel","Last Extraction")}),e.jsx("div",{className:"memory-emphasis-text",children:x.extraction.success?e.jsx("span",{className:"memory-status-text memory-status-text--success",children:t("memory.extractionSuccess","Success")}):e.jsx("span",{className:"memory-status-text memory-status-text--error",children:t("memory.extractionFailed","Failed")})}),e.jsx("div",{className:"memory-health-detail",children:x.extraction.summary||t("memory.insightsExtracted","{{count}} insights extracted",{count:x.extraction.insightCount})})]}),e.jsxs("div",{className:"memory-health-section",children:[e.jsx("div",{className:"memory-health-label",children:t("memory.pruningLabel","Pruning")}),e.jsx("div",{className:"memory-emphasis-text",children:x.pruning.applied?e.jsx("span",{className:"memory-status-text memory-status-text--warning",children:t("memory.pruningApplied","Applied")}):e.jsx("span",{className:"memory-status-text memory-status-text--muted",children:t("memory.pruningNotNeeded","Not needed")})}),x.pruning.applied&&e.jsx("div",{className:"memory-health-detail",children:x.pruning.reason})]})]}),x&&x.checks.length>0&&e.jsxs("div",{className:"memory-engine-card",children:[e.jsx("h3",{children:t("memory.auditChecksTitle","Audit Checks")}),e.jsx("div",{children:x.checks.map(l=>e.jsxs("div",{className:"memory-audit-check",children:[e.jsx("span",{className:l.passed?"memory-audit-check-passed":"memory-audit-check-failed",children:l.passed?"✓":"✗"}),e.jsxs("div",{className:"memory-audit-check-content",children:[e.jsx("div",{className:"memory-emphasis-text",children:l.name}),e.jsx("div",{className:"memory-health-detail",children:l.details})]})]},l.id))})]}),e.jsx("div",{className:"memory-action-bar",children:e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:()=>u(),children:t("memory.runAudit","Run Audit")})}),e.jsxs("div",{className:"memory-settings-note",children:[e.jsx("span",{children:t("memory.settingsNote","Note: Change backend type in")}),e.jsx("button",{type:"button",className:"memory-settings-note-button",onClick:()=>{s(t("memory.settingsNoteToast","Open Settings → Memory to change backend type"),"info")},children:t("memory.settingsNoteLink","Settings → Memory")})]})]})})]})]})}export{Ft as MemoryView};