arco-workbench 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. package/CONTRIBUTING.md +1 -1
  2. package/README.md +5 -1
  3. package/client/dist/assets/{PhosphorBackdrop-CkVIGkeX.js → PhosphorBackdrop-CNumba2X.js} +1 -1
  4. package/client/dist/assets/{ThemedBackgroundShaderImpl-DHF7CnpE.js → ThemedBackgroundShaderImpl-DX5KyCt3.js} +1 -1
  5. package/client/dist/assets/{XtermView-SY0UcZUS.js → XtermView-DhS5g8Rt.js} +1 -1
  6. package/client/dist/assets/{galleryEditor-Ca4F8HiM.js → galleryEditor-fPb76Cjv.js} +1 -1
  7. package/client/dist/assets/index-CjkHb-_n.js +592 -0
  8. package/client/dist/assets/index-DIbh3ae5.css +1 -0
  9. package/client/dist/index.html +2 -2
  10. package/client/src/App.tsx +2 -0
  11. package/client/src/alerts/desktopAlerts.ts +13 -1
  12. package/client/src/brief/briefFacts.ts +22 -0
  13. package/client/src/brief/briefFromStore.ts +7 -2
  14. package/client/src/components/ArtifactMoveDialog.tsx +64 -0
  15. package/client/src/components/BriefControl.tsx +38 -47
  16. package/client/src/components/CatchMeUp.tsx +25 -25
  17. package/client/src/components/CheckpointActions.tsx +7 -4
  18. package/client/src/components/ClusterComposerButtons.tsx +6 -3
  19. package/client/src/components/ClusterPlanTab.tsx +15 -1
  20. package/client/src/components/ClusterRightPanel/AutoPickupControl.tsx +6 -2
  21. package/client/src/components/ClusterTab.tsx +33 -3
  22. package/client/src/components/ClusterTaskBoardTab.tsx +62 -8
  23. package/client/src/components/DialogShell.tsx +115 -0
  24. package/client/src/components/DocsUpdateDialog.tsx +16 -42
  25. package/client/src/components/ForwardMessages.tsx +28 -32
  26. package/client/src/components/GitDialog.tsx +52 -52
  27. package/client/src/components/GitOtherWork.tsx +4 -2
  28. package/client/src/components/HandoffDialog.tsx +19 -45
  29. package/client/src/components/Home/HomeView.tsx +36 -8
  30. package/client/src/components/Home/home.css +7 -0
  31. package/client/src/components/KeepButton.tsx +23 -0
  32. package/client/src/components/MdTuneupDialog.tsx +52 -51
  33. package/client/src/components/MemberCard.tsx +4 -1
  34. package/client/src/components/MemberPane.tsx +1 -1
  35. package/client/src/components/NotificationCenter.tsx +4 -3
  36. package/client/src/components/NotificationChannelsSettings.tsx +25 -7
  37. package/client/src/components/PlanCandidateBanner.tsx +111 -57
  38. package/client/src/components/PlanComposerDialog.tsx +55 -87
  39. package/client/src/components/ProjectStateNotice.tsx +60 -0
  40. package/client/src/components/PublicProjectBox.tsx +25 -0
  41. package/client/src/components/ResearchDialog.tsx +15 -24
  42. package/client/src/components/ReviewDialog.tsx +32 -57
  43. package/client/src/components/RightPanel/OutputsPanel.tsx +4 -0
  44. package/client/src/components/RightPanel/PlanTab.tsx +24 -2
  45. package/client/src/components/RightPanel/UsageTab.tsx +77 -1
  46. package/client/src/components/SkillEditorDialog.tsx +38 -73
  47. package/client/src/components/SpawnDialog.tsx +19 -41
  48. package/client/src/components/StorageWarnings.tsx +21 -0
  49. package/client/src/components/SystemHeader.tsx +2 -2
  50. package/client/src/components/TerminalInput.tsx +6 -2
  51. package/client/src/components/TidyComposer.tsx +24 -41
  52. package/client/src/components/TranscriptSendDialog.tsx +151 -202
  53. package/client/src/components/UtilityAgentPicker.tsx +4 -2
  54. package/client/src/components/WorkflowCreator/index.tsx +2 -0
  55. package/client/src/components/WorkflowView.tsx +4 -1
  56. package/client/src/components/clusterNeedsYou.ts +35 -3
  57. package/client/src/components/compare/CompareDialog.tsx +26 -2
  58. package/client/src/components/terminalInput/planDraft.ts +33 -4
  59. package/client/src/components/utilityResult.ts +5 -1
  60. package/client/src/explorer/ExplorerApp.tsx +5 -2
  61. package/client/src/explorer/PlansLens.tsx +60 -19
  62. package/client/src/explorer/StorageLens.tsx +275 -0
  63. package/client/src/explorer/launch.ts +3 -3
  64. package/client/src/explorer/plansGrouping.ts +15 -0
  65. package/client/src/help/content/cluster.tsx +42 -7
  66. package/client/src/help/content/composer.tsx +26 -6
  67. package/client/src/help/content/header.tsx +16 -14
  68. package/client/src/help/content/misc.tsx +141 -6
  69. package/client/src/help/content/rightPanel.tsx +16 -0
  70. package/client/src/help/content/settings.tsx +4 -4
  71. package/client/src/help/manualSections/actions.tsx +19 -4
  72. package/client/src/help/manualSections/clusters.tsx +29 -16
  73. package/client/src/help/manualSections/configuration.tsx +6 -4
  74. package/client/src/help/manualSections/maintenance.tsx +27 -5
  75. package/client/src/help/manualSections/plans.tsx +96 -2
  76. package/client/src/help/manualSections/powerFeatures.tsx +2 -2
  77. package/client/src/help/manualSections/reference.tsx +6 -0
  78. package/client/src/help/manualSections/workspace.tsx +9 -5
  79. package/client/src/stores/appStore.ts +10 -1
  80. package/client/src/stores/appStore.types.ts +2 -0
  81. package/client/src/stores/mdTuneupStore.ts +5 -4
  82. package/client/src/stores/memoryTrim.ts +18 -2
  83. package/client/src/stores/storageWarningStore.ts +18 -0
  84. package/client/src/utils/gitDialogMemory.ts +26 -0
  85. package/client/src/utils/historyEvents.ts +1 -0
  86. package/client/src/utils/homeModel.ts +19 -0
  87. package/client/src/utils/publicProject.ts +56 -0
  88. package/client/src/ws/handleServerMessage.ts +7 -2
  89. package/docs/ARCHITECTURE.md +1 -1
  90. package/docs/CHECKPOINTS.md +2 -0
  91. package/docs/CLIENT.md +29 -11
  92. package/docs/FEATURES.md +14 -11
  93. package/docs/GETTING_STARTED.md +7 -7
  94. package/docs/GLOSSARY.md +3 -3
  95. package/docs/GOTCHAS.md +3 -2
  96. package/docs/HTTP_API.md +31 -1
  97. package/docs/NOTIFICATIONS.md +13 -14
  98. package/docs/OPERATIONS.md +27 -1
  99. package/docs/OPERATOR_ACTIONS.md +1 -1
  100. package/docs/OUTPUTS.md +9 -0
  101. package/docs/PERSISTENCE.md +34 -4
  102. package/docs/PLAN_OR_BOARD.md +7 -0
  103. package/docs/PRIMITIVES.md +3 -3
  104. package/docs/PROTOCOL.md +14 -4
  105. package/docs/PROTOCOL_CLUSTER.md +3 -2
  106. package/docs/SERVICE_MODE.md +5 -1
  107. package/docs/SETTINGS.md +8 -6
  108. package/docs/STORAGE_PLAN.md +324 -0
  109. package/docs/TASK_LEDGER.md +5 -4
  110. package/native/linux-arm64/manifest.json +1 -1
  111. package/node_modules/@arco/shared/dist/index.d.ts +2 -0
  112. package/node_modules/@arco/shared/dist/index.js +2 -0
  113. package/node_modules/@arco/shared/dist/protocol/autoPickup.d.ts +1 -1
  114. package/node_modules/@arco/shared/dist/protocol/autoPickup.js +1 -1
  115. package/node_modules/@arco/shared/dist/protocol/checkpoints.d.ts +1 -0
  116. package/node_modules/@arco/shared/dist/protocol/clusters.d.ts +2 -1
  117. package/node_modules/@arco/shared/dist/protocol/index.d.ts +1 -0
  118. package/node_modules/@arco/shared/dist/protocol/index.js +1 -0
  119. package/node_modules/@arco/shared/dist/protocol/mdTuneup.d.ts +6 -0
  120. package/node_modules/@arco/shared/dist/protocol/notifications.d.ts +2 -1
  121. package/node_modules/@arco/shared/dist/protocol/notifications.js +3 -2
  122. package/node_modules/@arco/shared/dist/protocol/plans.d.ts +2 -0
  123. package/node_modules/@arco/shared/dist/protocol/serverMessages.d.ts +2 -1
  124. package/node_modules/@arco/shared/dist/protocol/storage.d.ts +21 -0
  125. package/node_modules/@arco/shared/dist/protocol/storage.js +3 -0
  126. package/node_modules/@arco/shared/dist/protocol/tasks.d.ts +3 -0
  127. package/node_modules/@arco/shared/dist/protocol/utilityAgent.d.ts +2 -2
  128. package/node_modules/@arco/shared/dist/protocol/utilityAgent.js +2 -2
  129. package/node_modules/@arco/shared/dist/publicGuardrails.d.ts +7 -0
  130. package/node_modules/@arco/shared/dist/publicGuardrails.js +47 -0
  131. package/node_modules/@arco/shared/dist/publicSafetyRules.d.ts +1 -0
  132. package/node_modules/@arco/shared/dist/publicSafetyRules.js +6 -0
  133. package/node_modules/@arco/shared/package.json +1 -1
  134. package/package.json +3 -2
  135. package/scripts/packaging/arco.mjs +17 -1
  136. package/scripts/packaging/services.mjs +35 -5
  137. package/scripts/packaging/storage.mjs +125 -0
  138. package/scripts/packaging/update.mjs +3 -3
  139. package/server/dist/artifactCopy.d.ts +26 -0
  140. package/server/dist/artifactCopy.js +398 -0
  141. package/server/dist/atomicFile.d.ts +1 -0
  142. package/server/dist/atomicFile.js +1 -1
  143. package/server/dist/attention.d.ts +1 -1
  144. package/server/dist/attention.js +10 -13
  145. package/server/dist/catchUp.d.ts +2 -0
  146. package/server/dist/catchUp.js +46 -23
  147. package/server/dist/clusterPeerOps.d.ts +2 -0
  148. package/server/dist/clusterPeerOps.js +2 -0
  149. package/server/dist/clusterSnapshots.js +22 -12
  150. package/server/dist/eventLog.d.ts +55 -0
  151. package/server/dist/eventLog.js +792 -0
  152. package/server/dist/explorerLaunch.d.ts +4 -1
  153. package/server/dist/explorerLaunch.js +3 -2
  154. package/server/dist/explorerPlans.d.ts +4 -0
  155. package/server/dist/explorerPlans.js +27 -2
  156. package/server/dist/http/clusterRoutes.js +2 -0
  157. package/server/dist/http/explorerRoutes.js +2 -1
  158. package/server/dist/http/publicProjectRoutes.d.ts +2 -0
  159. package/server/dist/http/publicProjectRoutes.js +68 -0
  160. package/server/dist/http/router.js +6 -0
  161. package/server/dist/http/storageRoutes.d.ts +2 -0
  162. package/server/dist/http/storageRoutes.js +254 -0
  163. package/server/dist/http/usageStatsRoutes.js +3 -12
  164. package/server/dist/index.js +4 -0
  165. package/server/dist/keepStore.d.ts +16 -0
  166. package/server/dist/keepStore.js +119 -0
  167. package/server/dist/management/clusterActivity.js +6 -20
  168. package/server/dist/management/initHubLink.js +10 -43
  169. package/server/dist/mcp/clusterMcpTools.js +8 -1
  170. package/server/dist/notifications.d.ts +3 -1
  171. package/server/dist/notifications.js +5 -4
  172. package/server/dist/outputStore.d.ts +1 -0
  173. package/server/dist/outputStore.js +1 -1
  174. package/server/dist/outputs.js +39 -8
  175. package/server/dist/planHistory.d.ts +3 -0
  176. package/server/dist/planHistory.js +60 -0
  177. package/server/dist/primitives/runMdTuneup.d.ts +5 -1
  178. package/server/dist/primitives/runMdTuneup.js +43 -2
  179. package/server/dist/project/taskLedger.d.ts +4 -0
  180. package/server/dist/project/taskLedger.js +19 -0
  181. package/server/dist/providers/claude-native/peerTools.js +4 -0
  182. package/server/dist/providers/claude-native/resumeSummary.js +30 -19
  183. package/server/dist/providers/index.js +8 -13
  184. package/server/dist/providers/localProviderQueue.d.ts +2 -0
  185. package/server/dist/providers/localProviderQueue.js +11 -0
  186. package/server/dist/publicProject.d.ts +54 -0
  187. package/server/dist/publicProject.js +135 -0
  188. package/server/dist/recall/index.js +22 -23
  189. package/server/dist/server/broadcast.d.ts +2 -1
  190. package/server/dist/server/broadcast.js +56 -1
  191. package/server/dist/smartPickupAdapters.d.ts +7 -0
  192. package/server/dist/smartPickupAdapters.js +172 -8
  193. package/server/dist/storageActions.d.ts +50 -0
  194. package/server/dist/storageActions.js +326 -0
  195. package/server/dist/storageArchive.d.ts +24 -0
  196. package/server/dist/storageArchive.js +358 -0
  197. package/server/dist/storageOverview.d.ts +47 -0
  198. package/server/dist/storageOverview.js +197 -0
  199. package/server/dist/storageReport.d.ts +48 -0
  200. package/server/dist/storageReport.js +185 -0
  201. package/server/dist/storageWarnings.d.ts +4 -0
  202. package/server/dist/storageWarnings.js +96 -0
  203. package/server/dist/workers/limits.js +4 -1
  204. package/server/dist/workflowStore.d.ts +2 -0
  205. package/server/dist/workflowStore.js +88 -72
  206. package/server/dist/workflows/purgeWorkflow.d.ts +1 -0
  207. package/server/dist/workflows/purgeWorkflow.js +15 -2
  208. package/server/dist/workflows/sessionDiscovery.js +5 -17
  209. package/server/dist/workflows/sessionIndex.js +22 -17
  210. package/server/dist/ws/taskLedgerHandlers.js +8 -3
  211. package/server/dist/ws/workflowHandlers.js +5 -4
  212. package/server/package.json +1 -1
  213. package/server/src/artifactCopy.ts +254 -0
  214. package/server/src/atomicFile.ts +1 -1
  215. package/server/src/attention.ts +9 -10
  216. package/server/src/catchUp.ts +37 -15
  217. package/server/src/clusterPeerOps.ts +5 -0
  218. package/server/src/clusterSnapshots.ts +20 -13
  219. package/server/src/eventLog.ts +571 -0
  220. package/server/src/explorerLaunch.ts +3 -2
  221. package/server/src/explorerPlans.ts +22 -2
  222. package/server/src/http/clusterRoutes.ts +4 -1
  223. package/server/src/http/explorerRoutes.ts +2 -1
  224. package/server/src/http/publicProjectRoutes.ts +54 -0
  225. package/server/src/http/router.ts +4 -0
  226. package/server/src/http/storageRoutes.ts +187 -0
  227. package/server/src/http/usageStatsRoutes.ts +3 -11
  228. package/server/src/index.ts +4 -0
  229. package/server/src/keepStore.ts +102 -0
  230. package/server/src/management/clusterActivity.ts +6 -16
  231. package/server/src/management/initHubLink.ts +10 -39
  232. package/server/src/mcp/clusterMcpTools.ts +8 -2
  233. package/server/src/notifications.ts +4 -3
  234. package/server/src/outputStore.ts +5 -2
  235. package/server/src/outputs.ts +30 -6
  236. package/server/src/planHistory.ts +48 -0
  237. package/server/src/primitives/runMdTuneup.ts +32 -2
  238. package/server/src/project/taskLedger.ts +20 -0
  239. package/server/src/providers/claude-native/peerTools.ts +4 -0
  240. package/server/src/providers/claude-native/resumeSummary.ts +32 -18
  241. package/server/src/providers/index.ts +2 -16
  242. package/server/src/providers/localProviderQueue.ts +13 -0
  243. package/server/src/publicProject.ts +142 -0
  244. package/server/src/recall/index.ts +4 -9
  245. package/server/src/server/broadcast.ts +53 -1
  246. package/server/src/smartPickupAdapters.ts +128 -5
  247. package/server/src/storageActions.ts +216 -0
  248. package/server/src/storageArchive.ts +277 -0
  249. package/server/src/storageOverview.ts +184 -0
  250. package/server/src/storageReport.ts +210 -0
  251. package/server/src/storageWarnings.ts +84 -0
  252. package/server/src/workers/limits.ts +4 -1
  253. package/server/src/workflowStore.ts +78 -61
  254. package/server/src/workflows/purgeWorkflow.ts +12 -3
  255. package/server/src/workflows/sessionDiscovery.ts +5 -13
  256. package/server/src/workflows/sessionIndex.ts +5 -9
  257. package/server/src/ws/taskLedgerHandlers.ts +8 -3
  258. package/server/src/ws/workflowHandlers.ts +5 -4
  259. package/shared/dist/index.d.ts +2 -0
  260. package/shared/dist/index.js +2 -0
  261. package/shared/dist/protocol/autoPickup.d.ts +1 -1
  262. package/shared/dist/protocol/autoPickup.js +1 -1
  263. package/shared/dist/protocol/checkpoints.d.ts +1 -0
  264. package/shared/dist/protocol/clusters.d.ts +2 -1
  265. package/shared/dist/protocol/index.d.ts +1 -0
  266. package/shared/dist/protocol/index.js +1 -0
  267. package/shared/dist/protocol/mdTuneup.d.ts +6 -0
  268. package/shared/dist/protocol/notifications.d.ts +2 -1
  269. package/shared/dist/protocol/notifications.js +3 -2
  270. package/shared/dist/protocol/plans.d.ts +2 -0
  271. package/shared/dist/protocol/serverMessages.d.ts +2 -1
  272. package/shared/dist/protocol/storage.d.ts +21 -0
  273. package/shared/dist/protocol/storage.js +3 -0
  274. package/shared/dist/protocol/tasks.d.ts +3 -0
  275. package/shared/dist/protocol/utilityAgent.d.ts +2 -2
  276. package/shared/dist/protocol/utilityAgent.js +2 -2
  277. package/shared/dist/publicGuardrails.d.ts +7 -0
  278. package/shared/dist/publicGuardrails.js +47 -0
  279. package/shared/dist/publicSafetyRules.d.ts +1 -0
  280. package/shared/dist/publicSafetyRules.js +6 -0
  281. package/shared/src/index.ts +3 -0
  282. package/shared/src/protocol/autoPickup.ts +1 -1
  283. package/shared/src/protocol/checkpoints.ts +4 -0
  284. package/shared/src/protocol/clusters.ts +6 -1
  285. package/shared/src/protocol/index.ts +1 -0
  286. package/shared/src/protocol/mdTuneup.ts +5 -0
  287. package/shared/src/protocol/notifications.ts +6 -2
  288. package/shared/src/protocol/plans.ts +2 -0
  289. package/shared/src/protocol/serverMessages.ts +2 -0
  290. package/shared/src/protocol/storage.ts +35 -0
  291. package/shared/src/protocol/tasks.ts +6 -0
  292. package/shared/src/protocol/utilityAgent.ts +2 -2
  293. package/shared/src/publicGuardrails.ts +50 -0
  294. package/shared/src/publicSafetyRules.ts +5 -0
  295. package/client/dist/assets/index-CcNtMA2y.js +0 -546
  296. package/client/dist/assets/index-Dl8tYsSp.css +0 -1
@@ -4,6 +4,7 @@ import { useAppStore } from '../../stores/appStore';
4
4
  import { DirectoryBrowser } from '../media/DirectoryPicker';
5
5
  import { openImageForEdit, openMediaFile } from '../media/launchers';
6
6
  import { FileViewerModal } from '../FileViewerModal';
7
+ import { ArtifactMoveDialog, artifactRelative } from '../ArtifactMoveDialog';
7
8
  const CATEGORIES = ['all', 'images', 'documents', 'audio', 'video', 'other'] as const;
8
9
  const joinFolder = (folder: string, name: string) => folder.replace(/[\\/]+$/, '') + (folder.includes('\\') ? '\\' : '/') + name;
9
10
  const paramsFor = (output: WorkflowOutput) => new URLSearchParams({ cwd: output.cwd, workflowId: output.workflowId, id: output.id });
@@ -78,6 +79,7 @@ export function OutputsPanel({ cwd, workflowId, clusterId }: { cwd: string; work
78
79
  const [viewer, setViewer] = useState<WorkflowOutput | null>(null);
79
80
  const [transfer, setTransfer] = useState<{ output: WorkflowOutput; action: 'copy' | 'move'; destination?: string } | null>(null);
80
81
  const [busy, setBusy] = useState(false);
82
+ const [artifactMove, setArtifactMove] = useState<WorkflowOutput | null>(null);
81
83
  const [desktopOpen, setDesktopOpen] = useState(true), [refusedExt, setRefusedExt] = useState<string[]>([]);
82
84
  const roots = useAppStore(s => s.settings?.projectRoots);
83
85
  const request = useRef(0);
@@ -182,6 +184,7 @@ export function OutputsPanel({ cwd, workflowId, clusterId }: { cwd: string; work
182
184
  {output.path && previewable(output) && ['images', 'documents', 'audio', 'video'].includes(output.category) && <button type="button" disabled={output.missing} onClick={() => open(output, true)}>Open in editor</button>}
183
185
  <button type="button" disabled={output.missing} onClick={() => setTransfer({ output, action: 'copy' })}>Save a copy</button>
184
186
  {output.path && <button type="button" disabled={output.missing} onClick={() => setTransfer({ output, action: 'move' })}>Move</button>}
187
+ {output.path && artifactRelative(output.path, output.workflowId) && <button data-help="storage.move-project" disabled={output.missing} onClick={() => setArtifactMove(output)}>MOVE TO PROJECT</button>}
185
188
  {canOpen(output) && <button type="button" data-testid="output-open" data-help="rightpanel.outputs.open" disabled={output.missing} onClick={() => void openInDefaultApp(output)}>OPEN</button>}
186
189
  {output.path && <a download href={`/api/outputs/file?${paramsFor(output)}&download=1`} aria-disabled={output.missing} onClick={e => { if (output.missing) e.preventDefault(); }}>Download</a>}
187
190
  </div>
@@ -191,6 +194,7 @@ export function OutputsPanel({ cwd, workflowId, clusterId }: { cwd: string; work
191
194
  <p style={{ color: 'var(--color-fg-muted)', fontSize: 10 }}>For files that do not appear automatically, save them in this workflow's artifacts folder and refresh. Up to 2,000 entries.</p>
192
195
  </div>
193
196
  {viewer && <FileViewerModal initialEditing={viewerEditing} path={viewer.path || viewer.name} fallback={{ cwd: viewer.cwd, workflowId: viewer.workflowId }} readUrl={`/api/outputs/content?${paramsFor(viewer)}`} editContext={viewer.path ? { cwd: viewer.cwd, workflowId: viewer.workflowId } : undefined} saveRequest={{ url: '/api/outputs/text', body: { cwd: viewer.cwd, workflowId: viewer.workflowId, id: viewer.id } }} onClose={() => { setViewer(null); void load(true); }} />}
197
+ {artifactMove?.path && <ArtifactMoveDialog cwd={artifactMove.cwd} workflowId={artifactMove.workflowId} itemPath={artifactRelative(artifactMove.path, artifactMove.workflowId)!} onClose={() => setArtifactMove(null)} />}
194
198
  {transfer && <TransferDialog transfer={transfer} roots={roots} busy={busy} error={error} onDestination={destination => setTransfer({ ...transfer, destination })} onConfirm={() => void finishTransfer()} onClose={() => { if (!busy) setTransfer(null); }} />}
195
199
  </section>;
196
200
  }
@@ -1,5 +1,5 @@
1
1
  import { useCallback, useState, useEffect, useMemo, useRef } from 'react';
2
- import type { ProviderName, ModelName, EffortLevel, PlanSummary, PlanFull, WorkflowConfig, ReviewContextRef } from '@arco/shared';
2
+ import { hasGuardrails, insertGuardrails, type ProviderName, type ModelName, type EffortLevel, type PlanSummary, type PlanFull, type WorkflowConfig, type ReviewContextRef } from '@arco/shared';
3
3
  import { useAppStore, type JobState } from '../../stores/appStore';
4
4
  import { SpawnDialog } from '../SpawnDialog';
5
5
  import { ReviewDialog } from '../ReviewDialog';
@@ -284,7 +284,7 @@ export function PlanTab({
284
284
  A plan is an itemized checklist the agent sees as a one-line note before every turn (it reads the file on demand). Long-form detail goes in the plan's reference docs, linked from tasks. Attach an existing plan from this workspace, or create a new one. Plans live at <code>.arco/plans/</code>.
285
285
  </div>
286
286
  <button
287
- onClick={() => { void openArchive('plans'); }}
287
+ onClick={() => { void openArchive('plans', cwd); }}
288
288
  data-help="plan.library"
289
289
  className="display-font"
290
290
  style={{ ...planMiniBtn, marginBottom: '14px' }}
@@ -441,6 +441,28 @@ export function PlanTab({
441
441
  </button>
442
442
  </span>
443
443
  )}
444
+ {(editing || body !== null) && (() => {
445
+ const current = editing ? draftBody : body ?? '';
446
+ const present = hasGuardrails(current);
447
+ return (
448
+ <span data-help="plan.insert-guardrails" style={{ display: 'inline-flex' }}>
449
+ <button
450
+ data-testid="plan-insert-guardrails"
451
+ disabled={present || bodyLoading}
452
+ title={present ? 'Already in this plan' : 'Insert a Privacy and public safety section as an unsaved edit'}
453
+ onClick={() => {
454
+ if (!editing) setDraftTitle(plan.title);
455
+ setDraftBody(insertGuardrails(current));
456
+ setEditing(true);
457
+ }}
458
+ className="display-font"
459
+ style={planMiniBtn}
460
+ >
461
+ INSERT GUARDRAILS
462
+ </button>
463
+ </span>
464
+ );
465
+ })()}
444
466
  <button onClick={onDetach} data-help="plan.detach" className="display-font" style={planMiniBtn}>DETACH</button>
445
467
  {/* Phase 2.6 — copy this plan body to the cluster's shared plan.
446
468
  Only rendered for cluster-member workflows when the operator's
@@ -33,7 +33,7 @@ function providerColor(p: ProviderName): string {
33
33
  return PROVIDER_COLORS[p] ?? 'var(--color-accent-primary)';
34
34
  }
35
35
 
36
- export function UsageTab({ job }: { job: JobState }) {
36
+ function UsageContent({ job }: { job: JobState }) {
37
37
  const cwd = job.config.workingDirectory;
38
38
  // Cursor is the one provider whose usage is POLLED from the authed dashboard
39
39
  // API rather than summed from per-turn events (ACP carries no token counts).
@@ -393,3 +393,79 @@ function RatioBar({ ratio, color }: { ratio: number; color: string }) {
393
393
  </svg>
394
394
  );
395
395
  }
396
+
397
+ interface StorageFileRow { path: string; bytes: number }
398
+ interface StorageItem { id: string; open: boolean; lastActive: number; eventBytes: number; eventTypes: Record<string, number>; artifactBytes: number; handoffBytes: number; checkpointBytes: number; scratchBytes?: number; otherBytes?: number; largestFiles: StorageFileRow[]; largeFiles: StorageFileRow[]; errors: number }
399
+ interface StorageResult { measuredAt: number; stateBytes: number; allocatedBytes?: number; hardLinkBytes?: number; nestedFolders?: number; checkpointBytes: number; buckets?: Record<string, { bytes: number; files: number }>; workflows: StorageItem[]; largestFiles: StorageFileRow[]; largeFiles: StorageFileRow[]; errors: number }
400
+ const LARGE_BYTES = 500 * 1024 * 1024;
401
+ // One label per server bucket; every measured byte is in exactly one.
402
+ const BUCKET_LABELS: Record<string, string> = {
403
+ events: 'Conversation logs', artifacts: 'Artifacts', handoffs: 'Handoffs', checkpoints: 'Checkpoints',
404
+ scratch: 'Scratch files', conversationFiles: 'Other conversation files', plans: 'Plans', boards: 'Task boards',
405
+ worktrees: 'Worktrees and isolated copies', savedClusters: 'Saved clusters', voiceAndModels: 'Voice and media models',
406
+ caches: 'Caches and browser profiles', providerData: 'Provider account data', logs: 'Server logs', archives: 'Archived conversations', other: 'Other',
407
+ };
408
+ function bytes(n: number): string {
409
+ if (n < 1024) return `${n} B`;
410
+ const units = ['KiB', 'MiB', 'GiB', 'TiB']; let value = n / 1024; let unit = 0;
411
+ while (value >= 1024 && unit < units.length - 1) { value /= 1024; unit++; }
412
+ return `${value.toFixed(1)} ${units[unit]}`;
413
+ }
414
+ function useStorageReport(query: Record<string, string>) {
415
+ const [report, setReport] = useState<StorageResult | null>(null);
416
+ const [loading, setLoading] = useState(false);
417
+ const [error, setError] = useState('');
418
+ async function scan(refresh: boolean) {
419
+ setLoading(true); setError('');
420
+ try {
421
+ const params = new URLSearchParams({ ...query, ...(refresh ? { refresh: '1' } : {}) });
422
+ const response = await fetch(`/api/storage-report?${params}`);
423
+ if (!response.ok) throw new Error('Storage report could not be read.');
424
+ setReport(await response.json() as StorageResult);
425
+ } catch (err) { setError(err instanceof Error ? err.message : 'Storage report could not be read.'); }
426
+ finally { setLoading(false); }
427
+ }
428
+ return { report, loading, error, scan };
429
+ }
430
+ function StorageBuckets({ report }: { report: StorageResult }) {
431
+ if (!report.buckets) return null;
432
+ const rows = Object.entries(report.buckets).filter(([, b]) => b.bytes > 0).sort((a, b) => b[1].bytes - a[1].bytes);
433
+ return <ul>{rows.map(([name, b]) => <li key={name}>{BUCKET_LABELS[name] ?? name}: {bytes(b.bytes)} ({b.files} files)</li>)}</ul>;
434
+ }
435
+ function StorageSummary({ report, label }: { report: StorageResult; label: string }) {
436
+ return <>
437
+ <p>Measured {new Date(report.measuredAt).toLocaleString()}: {label} {bytes(report.stateBytes)}{report.allocatedBytes !== undefined ? `, ${bytes(report.allocatedBytes)} on disk` : ''}{report.checkpointBytes ? `; shared checkpoints ${bytes(report.checkpointBytes)}` : ''}. {report.errors ? `${report.errors} read errors; totals may be incomplete.` : ''}</p>
438
+ <StorageBuckets report={report} />
439
+ {(report.hardLinkBytes || report.nestedFolders) ? <p>{report.hardLinkBytes ? `Extra hard links to files already counted: ${bytes(report.hardLinkBytes)} (not added again). ` : ''}{report.nestedFolders ? `${report.nestedFolders} nested project state folders are measured with their own projects.` : ''}</p> : null}
440
+ </>;
441
+ }
442
+ function StorageReportPanel({ cwd }: { cwd: string }) {
443
+ const project = useStorageReport({ path: cwd });
444
+ const home = useStorageReport({ scope: 'home' });
445
+ if (!cwd) return null;
446
+ const { report, loading, error, scan } = project;
447
+ return <section data-help="rightpanel.storage.scan" style={{ overflowWrap: 'anywhere', padding: '10px 14px', borderBottom: '1px solid var(--color-border)' }}>
448
+ <strong>STORAGE</strong>{' '}
449
+ <button type="button" data-help="rightpanel.storage.scan" disabled={loading} onClick={() => void scan(!!report)}>{loading ? 'MEASURING...' : report ? 'MEASURE AGAIN' : 'MEASURE STORAGE'}</button>{' '}
450
+ <button type="button" data-help="rightpanel.storage.home" disabled={home.loading} onClick={() => void home.scan(!!home.report)}>{home.loading ? 'MEASURING...' : 'MEASURE ARCO FOLDER'}</button>
451
+ <p>Read-only sizes. Nothing is changed or deleted.</p>
452
+ {error && <p role="alert">{error}</p>}
453
+ {home.error && <p role="alert">{home.error}</p>}
454
+ {home.report && <details open><summary>Arco folder</summary><StorageSummary report={home.report} label="Arco folder" /></details>}
455
+ {report && <>
456
+ <StorageSummary report={report} label="project state" />
457
+ <p>Files at least 500 MiB are marked LARGE. Sizes can change during a scan.</p>
458
+ {report.workflows.map(w => <details key={w.id}>
459
+ <summary>{w.id.slice(0, 8)} - {w.open ? 'Open' : 'Closed or orphaned'} - {w.lastActive ? new Date(w.lastActive).toLocaleString() : 'No activity time'}</summary>
460
+ <p>Logs {bytes(w.eventBytes)}; artifacts {bytes(w.artifactBytes)}; handoffs {bytes(w.handoffBytes)}; checkpoints {bytes(w.checkpointBytes)}{w.scratchBytes ? `; scratch ${bytes(w.scratchBytes)}` : ''}{w.otherBytes ? `; other files ${bytes(w.otherBytes)}` : ''}. {w.errors ? `${w.errors} read errors.` : ''}</p>
461
+ <ul>{Object.entries(w.eventTypes).sort((a,b) => b[1]-a[1]).map(([type,size]) => <li key={type}>{type}: {bytes(size)}</li>)}</ul>
462
+ <ul>{w.largestFiles.map(file => <li key={file.path}>{file.path}: {bytes(file.bytes)} {file.bytes >= LARGE_BYTES ? 'LARGE' : ''}</li>)}</ul>
463
+ </details>)}
464
+ <details><summary>All large project state files ({report.largeFiles.length})</summary><ul>{report.largeFiles.map(file => <li key={file.path}>{file.path}: {bytes(file.bytes)}</li>)}</ul></details>
465
+ <details><summary>Largest project state files</summary><ul>{report.largestFiles.map(file => <li key={file.path}>{file.path}: {bytes(file.bytes)} {file.bytes >= LARGE_BYTES ? 'LARGE' : ''}</li>)}</ul></details>
466
+ </>}
467
+ </section>;
468
+ }
469
+ export function UsageTab({ job }: { job: JobState }) {
470
+ return <div style={{ overflowY: 'auto', flex: 1 }}><StorageReportPanel key={job.config.workingDirectory || ''} cwd={job.config.workingDirectory || ''} /><UsageContent job={job} /></div>;
471
+ }
@@ -1,4 +1,5 @@
1
1
  import { useEffect, useRef, useState } from 'react';
2
+ import { DialogShell } from './DialogShell';
2
3
 
3
4
  // Phase 1 — Arco-managed skills CRUD dialog. Operator types Name +
4
5
  // Description + Body, picks scope (project / global), and saves. The server
@@ -126,48 +127,45 @@ export function SkillEditorDialog({ cwd, target, onClose, onSaved }: Props) {
126
127
  };
127
128
 
128
129
  return (
129
- <div
130
- onClick={onClose}
131
- style={{
132
- position: 'fixed',
133
- inset: 0,
134
- background: 'rgba(0, 0, 0, 0.75)',
135
- display: 'flex',
136
- alignItems: 'center',
137
- justifyContent: 'center',
138
- zIndex: 9300,
139
- padding: '20px',
140
- }}
141
- >
142
- <div
143
- onClick={(e) => e.stopPropagation()}
144
- style={{
145
- width: '100%',
146
- maxWidth: '560px',
147
- maxHeight: 'calc(calc(100vh / var(--ui-scale, 1)) - 80px)',
148
- overflowY: 'auto',
149
- background: 'var(--color-bg-dialog)',
150
- border: '1px solid var(--color-accent-primary-dim)',
151
- borderRadius: '6px',
152
- padding: '18px 22px',
153
- fontFamily: 'var(--font-body)',
154
- display: 'flex',
155
- flexDirection: 'column',
156
- gap: '12px',
157
- }}
158
- >
159
- <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
160
- <span
130
+ <DialogShell
131
+ title={isEdit ? 'Edit skill' : 'New skill'}
132
+ dataHelp="composer.skills"
133
+ onClose={onClose}
134
+ closeOnBackdrop
135
+ width={560}
136
+ zIndex={9300}
137
+ status={!loading && error ? (
138
+ <div style={{ fontSize: '11px', color: 'var(--color-warning)', fontFamily: 'var(--font-body)' }}>{error}</div>
139
+ ) : undefined}
140
+ actions={loading ? undefined : (
141
+ <>
142
+ <button
143
+ onClick={onSave}
144
+ disabled={saving || (scope === 'project' && !cwd)}
161
145
  className="display-font"
162
- style={{ fontSize: '12px', letterSpacing: '3px', color: 'var(--color-accent-primary)' }}
146
+ style={{
147
+ ...primaryBtnStyle,
148
+ opacity: saving || (scope === 'project' && !cwd) ? 0.5 : 1,
149
+ cursor: saving ? 'default' : 'pointer',
150
+ }}
163
151
  >
164
- {isEdit ? 'EDIT SKILL' : 'NEW SKILL'}
165
- </span>
166
- <button onClick={onClose} className="display-font" style={cancelBtnStyle}>
167
- CLOSE ✕
152
+ {saving ? 'SAVING\u2026' : 'SAVE'}
168
153
  </button>
169
- </div>
170
-
154
+ <button
155
+ onClick={onAudit}
156
+ disabled={auditing}
157
+ className="display-font"
158
+ style={{ ...cancelBtnStyle, opacity: auditing ? 0.5 : 1 }}
159
+ title="Scan the body for invisible unicode + threat patterns (read-only diagnostic)"
160
+ >
161
+ {auditing ? 'AUDITING\u2026' : 'AUDIT'}
162
+ </button>
163
+ <button onClick={onClose} disabled={saving} className="display-font" style={cancelBtnStyle}>
164
+ CANCEL
165
+ </button>
166
+ </>
167
+ )}
168
+ >
171
169
  {loading ? (
172
170
  <div style={{ fontSize: '11px', color: 'var(--color-fg-muted)' }}>Loading…</div>
173
171
  ) : (
@@ -257,12 +255,6 @@ export function SkillEditorDialog({ cwd, target, onClose, onSaved }: Props) {
257
255
  </div>
258
256
  )}
259
257
 
260
- {error && (
261
- <div style={{ fontSize: '11px', color: 'var(--color-warning)', fontFamily: 'var(--font-body)' }}>
262
- {error}
263
- </div>
264
- )}
265
-
266
258
  {/* H35 — diagnostic audit findings (read-only; never gates save). */}
267
259
  {audit && (
268
260
  <div
@@ -287,36 +279,9 @@ export function SkillEditorDialog({ cwd, target, onClose, onSaved }: Props) {
287
279
  </div>
288
280
  )}
289
281
 
290
- <div style={{ display: 'flex', gap: '8px', marginTop: '4px' }}>
291
- <button
292
- onClick={onSave}
293
- disabled={saving || (scope === 'project' && !cwd)}
294
- className="display-font"
295
- style={{
296
- ...primaryBtnStyle,
297
- opacity: saving || (scope === 'project' && !cwd) ? 0.5 : 1,
298
- cursor: saving ? 'default' : 'pointer',
299
- }}
300
- >
301
- {saving ? 'SAVING…' : 'SAVE'}
302
- </button>
303
- <button
304
- onClick={onAudit}
305
- disabled={auditing}
306
- className="display-font"
307
- style={{ ...cancelBtnStyle, opacity: auditing ? 0.5 : 1 }}
308
- title="Scan the body for invisible unicode + threat patterns (read-only diagnostic)"
309
- >
310
- {auditing ? 'AUDITING…' : 'AUDIT'}
311
- </button>
312
- <button onClick={onClose} disabled={saving} className="display-font" style={cancelBtnStyle}>
313
- CANCEL
314
- </button>
315
- </div>
316
282
  </>
317
283
  )}
318
- </div>
319
- </div>
284
+ </DialogShell>
320
285
  );
321
286
  }
322
287
 
@@ -7,6 +7,7 @@ import { useCodexCatalogFor } from '../hooks/useCodexCatalog';
7
7
  import { effortsForModel, clampEffortForProvider } from '../utils/format';
8
8
  import { claudeModelLabel, defaultModelForProvider, modelsForProvider, useModelCatalogs } from '../utils/modelCatalog';
9
9
  import { CursorModelSelect } from './CursorModelSelect';
10
+ import { DialogShell } from './DialogShell';
10
11
 
11
12
  // Shared look for the Cursor family/effort dropdowns — matches the dialog's
12
13
  // text inputs (sunken bg, hairline border, accent text).
@@ -159,37 +160,24 @@ export function SpawnDialog({ parentConfig, parentPlanTitle, initialDirection, i
159
160
  };
160
161
 
161
162
  return (
162
- <div
163
- style={{
164
- position: 'fixed',
165
- inset: 0,
166
- background: 'rgba(0,0,0,0.6)',
167
- zIndex: 50,
168
- display: 'flex',
169
- alignItems: 'center',
170
- justifyContent: 'center',
171
- }}
172
- onClick={onCancel}
163
+ <DialogShell
164
+ title="Spawn from here"
165
+ dataHelp="actions.spawn"
166
+ onClose={onCancel}
167
+ closeOnBackdrop
168
+ width={520}
169
+ zIndex={50}
170
+ actions={(
171
+ <>
172
+ <span data-help="spawn.cancel" style={{ display: 'inline-flex' }}>
173
+ <Btn onClick={onCancel}>CANCEL</Btn>
174
+ </span>
175
+ <span data-help="spawn.confirm" style={{ display: 'inline-flex' }}>
176
+ <Btn primary onClick={() => { if (!roleProblem) submit(); }}>SPAWN</Btn>
177
+ </span>
178
+ </>
179
+ )}
173
180
  >
174
- <div
175
- onClick={(e) => e.stopPropagation()}
176
- style={{
177
- background: 'var(--color-bg-dialog)',
178
- border: '1px solid var(--color-accent-primary-dim)',
179
- borderRadius: '6px',
180
- padding: '18px 22px',
181
- width: 'min(520px, calc(94vw / var(--ui-scale, 1)))',
182
- maxHeight: 'calc(88vh / var(--ui-scale, 1))',
183
- overflowY: 'auto',
184
- fontFamily: 'var(--font-body)',
185
- }}
186
- >
187
- <div
188
- className="display-font"
189
- style={{ fontSize: '12px', letterSpacing: '3px', color: 'var(--color-accent-primary)', marginBottom: '14px' }}
190
- >
191
- SPAWN FROM HERE
192
- </div>
193
181
 
194
182
  <Field label="NAME" helpKey="spawn.name">
195
183
  <input
@@ -457,23 +445,13 @@ export function SpawnDialog({ parentConfig, parentPlanTitle, initialDirection, i
457
445
  </div>
458
446
  )}
459
447
 
460
- <div style={{ display: 'flex', justifyContent: 'flex-end', gap: '8px', marginTop: '6px' }}>
461
- <span data-help="spawn.cancel" style={{ display: 'inline-flex' }}>
462
- <Btn onClick={onCancel}>CANCEL</Btn>
463
- </span>
464
- <span data-help="spawn.confirm" style={{ display: 'inline-flex' }}>
465
- <Btn primary onClick={() => { if (!roleProblem) submit(); }}>SPAWN</Btn>
466
- </span>
467
- </div>
468
-
469
448
  <div
470
449
  className="display-font"
471
450
  style={{ marginTop: '10px', fontSize: '9px', color: 'var(--color-fg-muted)', letterSpacing: '0.5px' }}
472
451
  >
473
452
  Parent tab stays live. A fresh session opens in a new tab pre-warmed with a handoff of the parent's context.
474
453
  </div>
475
- </div>
476
- </div>
454
+ </DialogShell>
477
455
  );
478
456
  }
479
457
 
@@ -0,0 +1,21 @@
1
+ import { useState } from 'react';
2
+ import { useAppStore } from '../stores/appStore';
3
+ import { useStorageWarningStore } from '../stores/storageWarningStore';
4
+ import { KeepButton } from './KeepButton';
5
+
6
+ export function StorageWarnings() {
7
+ const warnings = useStorageWarningStore(s => s.warnings);
8
+ const remove = useStorageWarningStore(s => s.removeItem);
9
+ const jobs = useAppStore(s => s.jobs);
10
+ const [error, setError] = useState('');
11
+ if (!warnings.length) return null;
12
+ return <aside role="status" data-help="storage.warning" style={{ position: 'fixed', right: 16, bottom: 16, zIndex: 9998, maxWidth: 440, padding: 12, background: 'var(--color-bg-dialog)', border: '1px solid var(--color-warning)' }}>
13
+ <strong>Large artifacts</strong><p>These files use considerable storage. KEEP protects them from cleanup and archive.</p>
14
+ {error && <p role="alert">{error}</p>}
15
+ {warnings.flatMap(w => w.items.map(i => <div key={`${w.workflowId}:${i.path}`} style={{ marginTop: 8 }}>
16
+ <span>{jobs[w.workflowId]?.config.name || w.workflowId.slice(0, 8)}: {i.path} ({(i.bytes / 1024 ** 2).toFixed(1)} MiB)</span>{' '}
17
+ <KeepButton cwd={jobs[w.workflowId]?.config.workingDirectory} workflowId={w.workflowId} itemPath={i.path} reason="size-warning" help="storage.warning-keep" onError={setError} onKept={() => remove(w.workflowId, i.path)} />{' '}
18
+ <button data-help="storage.warning-dismiss" onClick={() => remove(w.workflowId, i.path)}>DISMISS</button>
19
+ </div>))}
20
+ </aside>;
21
+ }
@@ -97,7 +97,7 @@ export function SystemHeader({ onReconnect, onRestartServer, reconnectState, onS
97
97
  key: 'plans',
98
98
  label: 'PLANS',
99
99
  icon: '\u2630',
100
- onClick: () => { void openArchive('plans'); },
100
+ onClick: () => { void openArchive('plans', terminalRoot ?? undefined); },
101
101
  dataHelp: 'header.plans',
102
102
  title: 'ALL PLANS: browse and review every plan across projects without attaching one',
103
103
  },
@@ -105,7 +105,7 @@ export function SystemHeader({ onReconnect, onRestartServer, reconnectState, onS
105
105
  key: 'archive',
106
106
  label: 'ARTIFACTS',
107
107
  icon: '\u2338',
108
- onClick: () => { void openArchive(); },
108
+ onClick: () => { void openArchive(undefined, terminalRoot ?? undefined); },
109
109
  dataHelp: 'header.archive',
110
110
  title: 'ARTIFACTS: live view of what agents produced across all projects',
111
111
  },
@@ -28,6 +28,8 @@ import { MdTuneupDialog } from './MdTuneupDialog';
28
28
  import { ResearchDialog } from './ResearchDialog';
29
29
  import { mintResearchSpawnToken, registerPendingResearch } from './terminalInput/research';
30
30
  import { beginPlanReview, planDraftPrompt } from './terminalInput/planDraft';
31
+ import { effectivePublic } from '../utils/publicProject';
32
+ import { DialogPortal } from './DialogShell';
31
33
  import { openCompareDialog } from './terminalInput/compare';
32
34
  import { PrimaryStatus } from './PrimaryStatus';
33
35
  import { QueuedMessagesIndicator } from './QueuedMessagesIndicator';
@@ -2077,6 +2079,7 @@ export function TerminalInput({ job, onSend, onCancel, onCancelQueued, onUpload,
2077
2079
  </div>
2078
2080
  </div>
2079
2081
 
2082
+ <DialogPortal>
2080
2083
  {showSkillEditor && (
2081
2084
  <div data-help="composer.skills">
2082
2085
  <SkillEditorDialog cwd={job.config.workingDirectory ?? ''} target={{ scope: job.config.workingDirectory ? 'project' : 'global' }}
@@ -2177,12 +2180,12 @@ export function TerminalInput({ job, onSend, onCancel, onCancelQueued, onUpload,
2177
2180
  // path) — not just from inside ClusterTab/MemberPane.
2178
2181
  const effectiveMode = isMemberOfACluster && mode === 'autosave' ? 'review' : mode;
2179
2182
  if (effectiveMode === 'review') {
2180
- if (!beginPlanReview(job.id, (prompt) => onSend(prompt, undefined, undefined, 'plan-review'), '', isMemberOfACluster)) {
2183
+ if (!beginPlanReview(job.id, (prompt) => onSend(prompt, undefined, undefined, 'plan-review'), '', isMemberOfACluster, effectivePublic(job.config.workingDirectory ?? ''))) {
2181
2184
  useAppStore.getState().pushNotification('error', 'Wait for the current turn or plan draft to finish before drafting a plan.');
2182
2185
  }
2183
2186
  } else {
2184
2187
  setPendingPlanCapture(job.id, 'autosave');
2185
- if (onSend(planDraftPrompt('', 'autosave')) === false) setPendingPlanCapture(job.id, null);
2188
+ if (onSend(planDraftPrompt('', 'autosave', false, effectivePublic(job.config.workingDirectory ?? ''))) === false) setPendingPlanCapture(job.id, null);
2186
2189
  }
2187
2190
  }}
2188
2191
  onCancel={() => setShowPlanDialog(false)}
@@ -2259,6 +2262,7 @@ export function TerminalInput({ job, onSend, onCancel, onCancelQueued, onUpload,
2259
2262
  onCancel={() => setShowResearchDialog(false)}
2260
2263
  />
2261
2264
  )}
2265
+ </DialogPortal>
2262
2266
  </div>
2263
2267
  );
2264
2268
  }
@@ -4,6 +4,7 @@ import type { UtilityJobResult } from '@arco/shared';
4
4
  import { useAppStore } from '../stores/appStore';
5
5
  import { useDraftStore } from '../stores/draftStore';
6
6
  import { useStartupStore } from '../stores/startupStore';
7
+ import { DialogShell } from './DialogShell';
7
8
 
8
9
  type Revision = { text: string; result: UtilityJobResult };
9
10
  const MAX_DIRECTIVES = 16;
@@ -17,26 +18,9 @@ export function TidyComposer({ jobId, disabled = false }: { jobId: string; disab
17
18
  const [directives, setDirectives] = useState<string[]>([]), [directive, setDirective] = useState(''), [refining, setRefining] = useState(false);
18
19
  const [running, setRunning] = useState(false), [slow, setSlow] = useState(false), [note, setNote] = useState('');
19
20
  const active = useRef('');
20
- const dialogRef = useRef<HTMLDivElement>(null);
21
21
  const cancel = () => { if (active.current) void fetch('/api/utility-agent/cancel', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ jobId: active.current }) }).catch(() => undefined); };
22
22
  const close = () => { cancel(); active.current = ''; setRunning(false); setOpen(false); };
23
23
  useEffect(() => () => { cancel(); active.current = ''; }, [jobId]);
24
- useEffect(() => {
25
- if (!open) return;
26
- const previous = document.activeElement instanceof HTMLElement ? document.activeElement : null;
27
- dialogRef.current?.focus();
28
- const onKey = (event: KeyboardEvent) => {
29
- if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation(); close(); return; }
30
- if (event.key !== 'Tab' || !dialogRef.current) return;
31
- const controls = [...dialogRef.current.querySelectorAll<HTMLElement>('button:not(:disabled), input:not(:disabled), textarea:not(:disabled), summary, a[href]')];
32
- if (!controls.length) { event.preventDefault(); dialogRef.current.focus(); return; }
33
- const index = controls.indexOf(document.activeElement as HTMLElement);
34
- if (event.shiftKey && index <= 0) { event.preventDefault(); controls[controls.length - 1]?.focus(); }
35
- else if (!event.shiftKey && (index < 0 || index === controls.length - 1)) { event.preventDefault(); controls[0]?.focus(); }
36
- };
37
- document.addEventListener('keydown', onKey, true);
38
- return () => { document.removeEventListener('keydown', onKey, true); previous?.focus(); };
39
- }, [open]);
40
24
  const run = async (base: string, proposal: string, prior: string[], added = '') => {
41
25
  const next = added ? [...prior, added] : prior;
42
26
  if (next.length > MAX_DIRECTIVES) { setNote('The refinement limit has been reached.'); return; }
@@ -73,31 +57,30 @@ export function TidyComposer({ jobId, disabled = false }: { jobId: string; disab
73
57
  return <div data-help="composer.tidy" style={{ display: 'inline-flex', gap: '6px', flexWrap: 'wrap' }}>
74
58
  <button type="button" data-help="composer.tidy" disabled={disabled || !draft.trim()} onClick={start}>TIDY</button>
75
59
  {canUndo && <button type="button" data-help="composer.tidy" onClick={() => useDraftStore.getState().undoTidy(jobId)}>UNDO TIDY</button>}
76
- {open && <div ref={dialogRef} tabIndex={-1} role="dialog" aria-modal="true" aria-label="Tidy draft" style={{ position: 'fixed', inset: 0, zIndex: 2000, background: 'rgba(0,0,0,.65)', display: 'grid', placeItems: 'center', padding: '12px' }}>
77
- <div style={{ width: 'min(900px, 100%)', maxHeight: 'calc(85vh / var(--ui-scale, 1))', overflow: 'auto', overflowWrap: 'anywhere', background: 'var(--color-bg-dialog)', border: '1px solid var(--color-border-hairline)', padding: '16px', display: 'grid', gap: '10px' }}>
78
- <h2>Tidy draft</h2>
79
- {!agent ? <p>No utility agent is chosen. <button type="button" data-help="composer.tidy" onClick={() => { close(); useStartupStore.getState().setSettingsSection('utility-agent'); useAppStore.getState().setShowSettings(true); }}>OPEN UTILITY AGENT SETTINGS</button></p>
80
- : <p>The original and refinement instructions are sent to {agent.provider.toUpperCase()} / {agent.model}. The proposal is not sent to the worker until the composer is sent.</p>}
81
- <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(min(100%, 250px), 1fr))', gap: '12px', minWidth: 0 }}>
82
- <div><strong>Original</strong><pre style={{ whiteSpace: 'pre-wrap', overflowWrap: 'anywhere', maxHeight: '240px', overflow: 'auto' }}>{original}</pre></div>
83
- <label>Proposal {revision && `(revision ${current + 1} of ${revisions.length})`}
84
- <textarea className="arco-field" data-help="composer.tidy" aria-label="Proposed draft" disabled={!revision || running} value={revision?.text ?? ''} onChange={(e) => { const value = e.target.value; setRevisions((old) => old.map((r, i) => i === current ? { ...r, text: value } : r)); }} style={{ display: 'block', width: '100%', minHeight: '180px', maxHeight: '300px', resize: 'vertical' }} />
85
- </label>
86
- </div>
60
+ {open && <DialogShell title="Tidy draft" onClose={close} width={900} dataHelp="composer.tidy"
61
+ status={(running || note) ? <>
62
+ {running && <p role="status" style={{ margin: 0 }}>{slow ? 'Still working. A cold start can take a while.' : 'Tidying the draft.'} <button type="button" data-help="composer.tidy" onClick={cancel}>CANCEL</button></p>}
63
+ {note && <p role="status" style={{ margin: 0 }}>{note}</p>}
64
+ </> : undefined}
65
+ actions={<>
87
66
  {agent && !running && (!revision || note) && <button type="button" data-help="composer.tidy" onClick={() => void run(original, revision?.text ?? '', directives)}>TRY AGAIN</button>}
88
- {directives.length > 0 && <details><summary>Refinement instructions ({directives.length})</summary><ol>{directives.map((item, i) => <li key={i}>{item}</li>)}</ol></details>}
89
- {revision?.result.agent && <p>Answered by {revision.result.agent.provider.toUpperCase()} / {revision.result.agent.model}.</p>}
90
- {revision && <details><summary>Facts used ({revision.result.facts.length})</summary><ul>{revision.result.facts.map((fact, i) => <li key={i}><strong>{fact.label}:</strong> {fact.value}</li>)}</ul></details>}
91
- {running && <p role="status">{slow ? 'Still working. A cold start can take a while.' : 'Tidying the draft.'} <button type="button" data-help="composer.tidy" onClick={cancel}>CANCEL</button></p>}
92
- {note && <p role="status">{note}</p>}
93
- {refining && <label>Refinement directive <input className="arco-field" data-help="composer.tidy" aria-label="Refinement directive" maxLength={500} value={directive} onChange={(e) => setDirective(e.target.value)} placeholder="For example: shorter" /></label>}
94
- <div style={{ display: 'flex', flexWrap: 'wrap', gap: '8px' }}>
95
- <button type="button" data-help="composer.tidy" disabled={!revision?.text.trim() || running} onClick={accept}>ACCEPT</button>
96
- <button type="button" data-help="composer.tidy" disabled={!revision || running || directives.length >= MAX_DIRECTIVES} onClick={() => { if (!refining) setRefining(true); else if (directive.trim()) void run(original, revision?.text ?? '', directives, directive.trim()); }}>REFINE</button>
97
- <button type="button" data-help="composer.tidy" disabled={current === 0 || running} onClick={() => setCurrent((n) => n - 1)}>BACK</button>
98
- <button type="button" data-help="composer.tidy" onClick={close}>KEEP ORIGINAL</button>
99
- </div>
67
+ <button type="button" data-help="composer.tidy" disabled={current === 0 || running} onClick={() => setCurrent((n) => n - 1)}>BACK</button>
68
+ <button type="button" data-help="composer.tidy" disabled={!revision || running || directives.length >= MAX_DIRECTIVES} onClick={() => { if (!refining) setRefining(true); else if (directive.trim()) void run(original, revision?.text ?? '', directives, directive.trim()); }}>REFINE</button>
69
+ <button type="button" data-help="composer.tidy" onClick={close}>KEEP ORIGINAL</button>
70
+ <button type="button" data-help="composer.tidy" disabled={!revision?.text.trim() || running} onClick={accept}>ACCEPT</button>
71
+ </>}>
72
+ {!agent ? <p style={{ margin: 0 }}>No utility agent is chosen. <button type="button" data-help="composer.tidy" onClick={() => { close(); useStartupStore.getState().setSettingsSection('utility-agent'); useAppStore.getState().setShowSettings(true); }}>OPEN UTILITY AGENT SETTINGS</button></p>
73
+ : <p style={{ margin: 0 }}>The original and refinement instructions are sent to {agent.provider.toUpperCase()} / {agent.model}. The proposal is not sent to the worker until the composer is sent.</p>}
74
+ <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(min(100%, 250px), 1fr))', gap: '12px', minWidth: 0 }}>
75
+ <div><strong>Original</strong><pre style={{ whiteSpace: 'pre-wrap', overflowWrap: 'anywhere', maxHeight: '240px', overflow: 'auto', margin: '4px 0 0' }}>{original}</pre></div>
76
+ <label>Proposal {revision && `(revision ${current + 1} of ${revisions.length})`}
77
+ <textarea className="arco-field" data-help="composer.tidy" aria-label="Proposed draft" disabled={!revision || running} value={revision?.text ?? ''} onChange={(e) => { const value = e.target.value; setRevisions((old) => old.map((r, i) => i === current ? { ...r, text: value } : r)); }} style={{ display: 'block', width: '100%', minHeight: '140px', maxHeight: '300px', resize: 'vertical' }} />
78
+ </label>
100
79
  </div>
101
- </div>}
80
+ {directives.length > 0 && <details><summary>Refinement instructions ({directives.length})</summary><ol>{directives.map((item, i) => <li key={i}>{item}</li>)}</ol></details>}
81
+ {revision?.result.agent && <p style={{ margin: 0 }}>Answered by {revision.result.agent.provider.toUpperCase()} / {revision.result.agent.model}.</p>}
82
+ {revision && <details><summary>Facts used ({revision.result.facts.length})</summary><ul>{revision.result.facts.map((fact, i) => <li key={i}><strong>{fact.label}:</strong> {fact.value}</li>)}</ul></details>}
83
+ {refining && <label>Refinement directive <input className="arco-field" data-help="composer.tidy" aria-label="Refinement directive" maxLength={500} value={directive} onChange={(e) => setDirective(e.target.value)} placeholder="For example: shorter" /></label>}
84
+ </DialogShell>}
102
85
  </div>;
103
86
  }