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 { FileViewerModal } from '../components/FileViewerModal';
4
4
  import { ArtifactsLens } from './ArtifactsLens';
5
5
  import { RecentsLens } from './RecentsLens';
6
6
  import { PlansLens } from './PlansLens';
7
+ import { StorageLens } from './StorageLens';
7
8
 
8
9
  // ARTIFACTS (docs/CLIENT.md) - the standalone chromeless explorer window,
9
10
  // mounted by main.tsx on `?app=explorer` INSTEAD of the workspace <App/>. It is
@@ -13,7 +14,7 @@ import { PlansLens } from './PlansLens';
13
14
  // workspace WS in v1 — §3): lenses refetch on window focus (poll-on-focus) plus
14
15
  // a manual refresh.
15
16
 
16
- type LensId = 'artifacts' | 'recents' | 'plans' | 'tree';
17
+ type LensId = 'artifacts' | 'recents' | 'plans' | 'storage' | 'tree';
17
18
 
18
19
  interface LensDef { id: LensId; label: string; icon: string; hint: string }
19
20
 
@@ -22,6 +23,7 @@ const LENSES: LensDef[] = [
22
23
  { id: 'artifacts', label: 'ARTIFACTS', icon: '⌸', hint: 'Projects + agent-produced artifacts' },
23
24
  { id: 'recents', label: 'RECENTS', icon: '⌁', hint: 'Recently written / changed files' },
24
25
  { id: 'plans', label: 'PLANS', icon: '☰', hint: 'Every plan across all projects: review without attaching' },
26
+ { id: 'storage', label: 'STORAGE', icon: '◫', hint: 'Disk use by project; archive, delete and compress closed conversations' },
25
27
  { id: 'tree', label: 'TREE', icon: '⊞', hint: 'Browse the filesystem' },
26
28
  ];
27
29
 
@@ -98,7 +100,7 @@ export function ExplorerApp() {
98
100
 
99
101
  <header style={{ display: 'flex', alignItems: 'center', gap: '12px', padding: '10px 18px', borderBottom: '1px solid var(--color-border-hairline)', background: 'var(--color-bg-panel)', flexShrink: 0 }}>
100
102
  <span className="display-font glow-text-bright" style={{ fontSize: '17px', letterSpacing: '3px' }}>⌸ ARTIFACTS</span>
101
- <span style={{ fontSize: '12px', color: 'var(--color-fg-muted)', letterSpacing: '1px' }}>project documents · artifacts · recents · plans · files</span>
103
+ <span style={{ fontSize: '12px', color: 'var(--color-fg-muted)', letterSpacing: '1px' }}>project documents · artifacts · recents · plans · storage · files</span>
102
104
  <span style={{ flex: 1 }} />
103
105
  {/* Text-size (window zoom) control. */}
104
106
  <div style={{ display: 'flex', alignItems: 'center', gap: '2px', marginRight: '4px' }}>
@@ -146,6 +148,7 @@ export function ExplorerApp() {
146
148
  <RecentsLens focusTick={focusTick} onOpen={setViewerPath} onRevealInTree={revealInTree} />
147
149
  )}
148
150
  {activeLens.id === 'plans' && <PlansLens focusTick={focusTick} />}
151
+ {activeLens.id === 'storage' && <StorageLens focusTick={focusTick} />}
149
152
  {activeLens.id === 'tree' && (
150
153
  root ? (
151
154
  <FileExplorer cwd={root} revealPath={reveal?.path} revealNonce={reveal?.nonce} />
@@ -5,6 +5,7 @@ import { PlanBodyRenderer, CHECKBOX_RE } from '../components/PlanBodyRenderer';
5
5
  import { PlanWorkflowsSection } from '../components/RightPanel/PlanWorkflowsSection';
6
6
  import { PlanRefsSection, PlanRefChips } from '../components/plans/PlanRefsSection';
7
7
  import { usePlanRefs } from '../components/plans/planRefs';
8
+ import { probablyFinished, foldVersions } from './plansGrouping';
8
9
 
9
10
  // PLANS lens — the plans library. Every plan across every known project
10
11
  // (GET /api/explorer/plans), browsable and reviewable without attaching it to
@@ -18,12 +19,34 @@ type StatusFilter = 'active' | 'completed' | 'all';
18
19
 
19
20
  interface Selection { cwd: string; planId: string }
20
21
 
22
+ const CURRENT_PROJECT = new URLSearchParams(window.location.search).get('cwd');
23
+ const EXPANDED_KEY = 'arco_plans_expanded_projects';
24
+
21
25
  export function PlansLens({ focusTick }: { focusTick: number }) {
22
26
  const [projects, setProjects] = useState<PlanLibraryProject[] | null>(null);
23
27
  const [status, setStatus] = useState<StatusFilter>('active');
24
28
  const [query, setQuery] = useState('');
25
29
  const [sel, setSel] = useState<Selection | null>(null);
26
30
  const [tick, setTick] = useState(0);
31
+ const [expanded, setExpanded] = useState<Record<string, boolean>>(() => {
32
+ try { return JSON.parse(localStorage.getItem(EXPANDED_KEY) || '{}') as Record<string, boolean>; } catch { return {}; }
33
+ });
34
+ const [finishedOpen, setFinishedOpen] = useState<Record<string, boolean>>({});
35
+ const [versionsOpen, setVersionsOpen] = useState<Record<string, boolean>>({});
36
+ const [actionError, setActionError] = useState('');
37
+ const toggleProject = (cwd: string, open: boolean) => setExpanded((old) => {
38
+ const next = { ...old, [cwd]: open };
39
+ try { localStorage.setItem(EXPANDED_KEY, JSON.stringify(next)); } catch { /* storage unavailable */ }
40
+ return next;
41
+ });
42
+ const markDone = async (cwd: string, plan: PlanLibraryEntry) => {
43
+ try {
44
+ const url = `/api/plans?path=${encodeURIComponent(cwd)}&planId=${encodeURIComponent(plan.id)}`;
45
+ const r = await fetch(url, { method: 'PATCH', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ completedAt: Date.now() }) });
46
+ if (!r.ok) throw new Error(`HTTP ${r.status}`);
47
+ setActionError(''); setTick((v) => v + 1);
48
+ } catch (e) { setActionError(e instanceof Error ? e.message : String(e)); }
49
+ };
27
50
 
28
51
  useEffect(() => {
29
52
  let cancelled = false;
@@ -56,7 +79,22 @@ export function PlansLens({ focusTick }: { focusTick: number }) {
56
79
  return proj && plan ? { project: proj, plan } : null;
57
80
  }, [projects, sel]);
58
81
 
59
- const total = (projects ?? []).reduce((n, p) => n + p.plans.length, 0);
82
+ const visiblePlans = filtered.flatMap((p) => p.plans);
83
+ const total = visiblePlans.length;
84
+ const inUse = visiblePlans.filter((p) => p.attached).length;
85
+ const finished = visiblePlans.filter((p) => probablyFinished(p)).length;
86
+ const rows = (cwd: string, plans: PlanLibraryEntry[], offerDone: boolean) => foldVersions(plans).map((versions) => {
87
+ const key = `${cwd}:${versions[0].title.trim().toLowerCase()}`;
88
+ const open = versionsOpen[key] ?? false;
89
+ const renderRow = (pl: PlanLibraryEntry) => <div key={pl.id}>
90
+ <PlanRow plan={pl} active={sel?.cwd === cwd && sel.planId === pl.id} onClick={() => setSel({ cwd, planId: pl.id })} />
91
+ {(offerDone || (status === 'active' && versions.length > 1 && versions.some((p) => p.attached) && !pl.attached)) && <button style={chip(false)} data-help="plans.mark-done" onClick={() => void markDone(cwd, pl)}>MARK DONE</button>}
92
+ </div>;
93
+ return versions.length === 1 ? renderRow(versions[0]) : <div key={key}>
94
+ <button style={chip(false)} data-help="plans.versions" aria-expanded={open} onClick={() => setVersionsOpen((v) => ({ ...v, [key]: !open }))}>{versions[0].title} - {versions.length} versions</button>
95
+ {open && versions.map(renderRow)}
96
+ </div>;
97
+ });
60
98
 
61
99
  return (
62
100
  <div style={{ flex: 1, minHeight: 0, display: 'flex', overflow: 'hidden' }}>
@@ -65,30 +103,33 @@ export function PlansLens({ focusTick }: { focusTick: number }) {
65
103
  {(['active', 'completed', 'all'] as StatusFilter[]).map((s) => (
66
104
  <button key={s} onClick={() => setStatus(s)} className="display-font" style={chip(status === s)}>{s.toUpperCase()}</button>
67
105
  ))}
68
- <span style={{ flex: 1 }} />
69
- <span style={{ fontSize: '11px', color: 'var(--color-fg-muted)', alignSelf: 'center' }}>{total} plans</span>
70
106
  </div>
107
+ <div style={{ fontSize: '11px', color: 'var(--color-fg-muted)', marginBottom: '8px' }}>{total} plans, {inUse} in use, {finished} probably finished</div>
108
+ {actionError && <div role="alert">{actionError}</div>}
71
109
  <input value={query} onChange={(e) => setQuery(e.target.value)} placeholder="Search plan or project…" style={searchStyle} />
72
110
  <div style={{ flex: 1, overflowY: 'auto', marginTop: '10px', paddingBottom: '12px' }}>
73
111
  {projects === null ? (
74
112
  <Muted text="Loading plans…" />
75
113
  ) : filtered.length === 0 ? (
76
114
  <Muted text={query || status !== 'all' ? 'No plans match.' : 'No plans in any known project.'} />
77
- ) : filtered.map((proj) => (
78
- <div key={proj.cwd} style={{ marginBottom: '12px' }}>
79
- <div className="display-font" title={proj.cwd} style={{ fontSize: '11px', letterSpacing: '2px', color: 'var(--color-accent-secondary-dim)', marginBottom: '4px', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
80
- {proj.name.toUpperCase()} <span style={{ color: 'var(--color-fg-muted)' }}>· {proj.plans.length}</span>
81
- </div>
82
- {proj.plans.map((pl) => (
83
- <PlanRow
84
- key={pl.id}
85
- plan={pl}
86
- active={sel?.cwd === proj.cwd && sel.planId === pl.id}
87
- onClick={() => setSel({ cwd: proj.cwd, planId: pl.id })}
88
- />
89
- ))}
90
- </div>
91
- ))}
115
+ ) : filtered.map((proj) => {
116
+ const isOpen = Boolean(query.trim()) || (expanded[proj.cwd] ?? proj.cwd === CURRENT_PROJECT);
117
+ const groups = foldVersions(proj.plans);
118
+ const probable = status === 'active' ? groups.filter((g) => g.every((p) => probablyFinished(p))).flat() : [];
119
+ const normal = status === 'active' ? groups.filter((g) => !g.every((p) => probablyFinished(p))).flat() : proj.plans;
120
+ return <div key={proj.cwd} style={{ marginBottom: '12px' }}>
121
+ <button className="display-font" data-help="plans.project-group" aria-expanded={isOpen} onClick={() => toggleProject(proj.cwd, !isOpen)} style={chip(false)} title={proj.cwd}>
122
+ {isOpen ? '▾' : '▸'} {proj.name} - {proj.plans.length} plans - {formatRelativeTime(Math.max(...proj.plans.map((p) => p.updatedAt)))}
123
+ </button>
124
+ {isOpen && <>
125
+ {rows(proj.cwd, normal, false)}
126
+ {probable.length > 0 && <div>
127
+ <button style={chip(false)} data-help="plans.probably-finished" aria-expanded={Boolean(finishedOpen[proj.cwd]) || Boolean(query.trim())} onClick={() => setFinishedOpen((v) => ({ ...v, [proj.cwd]: !v[proj.cwd] }))}>Probably finished ({probable.length})</button>
128
+ {(finishedOpen[proj.cwd] || query.trim()) && rows(proj.cwd, probable, true)}
129
+ </div>}
130
+ </>}
131
+ </div>;
132
+ })}
92
133
  </div>
93
134
  </div>
94
135
  <div style={{ flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column', overflow: 'hidden' }}>
@@ -125,7 +166,7 @@ function PlanRow({ plan, active, onClick }: { plan: PlanLibraryEntry; active: bo
125
166
  <span title={done ? 'Completed' : plan.attached ? 'Attached' : 'Not attached'} style={{ width: '10px', flexShrink: 0, color: done ? 'var(--color-fg-muted)' : plan.attached ? 'var(--color-accent-primary)' : 'var(--color-accent-primary-dim)' }}>
126
167
  {done ? '✓' : plan.attached ? '●' : '○'}
127
168
  </span>
128
- <span style={{ flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', opacity: done ? 0.65 : 1 }}>{plan.title}</span>
169
+ <span style={{ flex: 1, minWidth: 0, opacity: done ? 0.65 : 1 }}>{plan.title}{plan.attached && <span data-help="plans.in-use" style={{ display: 'block', fontSize: '10px' }}>In use: {[...(plan.attachments ?? []).filter((a) => a.detachedAt === null).map((a) => a.workflowName), ...plan.clusters.map((c) => c.name)].join(', ') || 'attached'}</span>}</span>
129
170
  {plan.refCount > 0 && <span title={`${plan.refCount} reference docs`} style={{ fontSize: '10px', color: 'var(--color-accent-secondary-dim)', flexShrink: 0 }}>⧉{plan.refCount}</span>}
130
171
  <span style={{ fontSize: '10px', color: 'var(--color-fg-muted)', flexShrink: 0 }}>{formatRelativeTime(plan.updatedAt)}</span>
131
172
  </button>
@@ -0,0 +1,275 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { KeepButton } from '../components/KeepButton';
3
+ import { formatRelativeTime } from '../components/RightPanel/format';
4
+
5
+ // STORAGE lens (docs/STORAGE_PLAN.md, P7.5) - where the disk space goes, for
6
+ // every project Arco knows about plus Arco's own folder, largest first. Reads
7
+ // the bounded, read-only storage report; every action (COMPRESS OLD LOGS,
8
+ // ARCHIVE, RESTORE, DELETE, EMPTY SCRATCH) is an operator click with a
9
+ // confirmation and goes through /api/storage/*. Worktrees and caches are
10
+ // shown but have no clean-up action. Plans are never touched.
11
+
12
+ type Buckets = Partial<Record<string, number>>;
13
+ interface Biggest { path: string; bytes: number }
14
+ interface ProjectRow {
15
+ path: string; kind: 'project' | 'chat'; stateBytes: number; buckets: Buckets; biggest: Biggest | null;
16
+ conversations: number; openConversations: number; archives: Archive[]; errors: number;
17
+ }
18
+ interface Overview {
19
+ measuredAt: number; totalBytes: number;
20
+ home: { stateBytes: number; buckets: Buckets; biggest: Biggest | null };
21
+ projects: ProjectRow[];
22
+ budget: { enabled: boolean; limitBytes: number; over: boolean };
23
+ }
24
+ interface Archive { workflowId: string; bytes: number; archivedAt: number }
25
+ interface Conversation {
26
+ id: string; name?: string; open: boolean; busy?: boolean; lastActive: number;
27
+ eventBytes: number; artifactBytes: number; handoffBytes: number; checkpointBytes: number; scratchBytes?: number; otherBytes?: number;
28
+ keep?: { readable: boolean; whole: boolean; items: number };
29
+ }
30
+ interface ProjectReport { measuredAt: number; workflows: Conversation[]; archives?: Archive[] }
31
+ interface Policy { autoArchiveClosedDays: number | null; budgetGiB: number; budgetNotice: boolean }
32
+
33
+ // One label per server bucket (same as USAGE > MEASURE STORAGE).
34
+ const LABELS: Record<string, string> = {
35
+ events: 'Conversation logs', artifacts: 'Artifacts', handoffs: 'Handoffs', checkpoints: 'Checkpoints',
36
+ scratch: 'Scratch files', conversationFiles: 'Other conversation files', plans: 'Plans', boards: 'Task boards',
37
+ worktrees: 'Worktrees and isolated copies', savedClusters: 'Saved clusters', voiceAndModels: 'Voice and media models',
38
+ caches: 'Caches and browser profiles', providerData: 'Provider account data', logs: 'Server logs',
39
+ archives: 'Archived conversations', other: 'Other',
40
+ };
41
+
42
+ export function formatBytes(n: number): string {
43
+ if (n < 1024) return `${n} B`;
44
+ const units = ['KiB', 'MiB', 'GiB', 'TiB']; let value = n / 1024; let unit = 0;
45
+ while (value >= 1024 && unit < units.length - 1) { value /= 1024; unit++; }
46
+ return `${value.toFixed(1)} ${units[unit]}`;
47
+ }
48
+ const baseName = (p: string) => p.split(/[\\/]/).filter(Boolean).pop() ?? p;
49
+
50
+ async function post(action: string, body: Record<string, unknown>): Promise<Record<string, unknown>> {
51
+ const r = await fetch(`/api/storage/${action}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ ...body, confirm: true }) });
52
+ const data = await r.json().catch(() => ({})) as Record<string, unknown>;
53
+ if (!r.ok) throw new Error(typeof data.message === 'string' ? data.message : `Request failed (${r.status})`);
54
+ return data;
55
+ }
56
+
57
+ export function StorageLens({ focusTick }: { focusTick: number }) {
58
+ const [overview, setOverview] = useState<Overview | null>(null);
59
+ const [loading, setLoading] = useState(false);
60
+ const [error, setError] = useState('');
61
+ const [notice, setNotice] = useState('');
62
+ const [expanded, setExpanded] = useState<string | null>(null);
63
+ const [stale, setStale] = useState(false);
64
+
65
+ async function measure(refresh: boolean) {
66
+ setLoading(true); setError('');
67
+ try {
68
+ const r = await fetch(`/api/storage-report?scope=all${refresh ? '&refresh=1' : ''}`);
69
+ if (!r.ok) throw new Error('The storage report could not be read.');
70
+ setOverview(await r.json() as Overview);
71
+ setStale(false);
72
+ } catch (e) { setError(e instanceof Error ? e.message : String(e)); }
73
+ finally { setLoading(false); }
74
+ }
75
+ // The first measurement can take a while on large folders; it is only
76
+ // started from here or by the daily run, never in the background of the lens.
77
+ useEffect(() => { void measure(false); }, []);
78
+ void focusTick;
79
+
80
+ const rows: Array<{ key: string; label: string; path?: string; kind: 'home' | 'project' | 'chat'; bytes: number; buckets: Buckets; biggest: Biggest | null; row?: ProjectRow }> = overview
81
+ ? [
82
+ { key: '\0home', label: "Arco's folder", kind: 'home' as const, bytes: overview.home.stateBytes, buckets: overview.home.buckets, biggest: overview.home.biggest },
83
+ ...overview.projects.map((p) => ({ key: p.path, label: p.kind === 'chat' ? `Chat ${baseName(p.path).slice(0, 8)}` : baseName(p.path), path: p.path, kind: p.kind, bytes: p.stateBytes, buckets: p.buckets, biggest: p.biggest, row: p })),
84
+ ].sort((a, b) => b.bytes - a.bytes)
85
+ : [];
86
+
87
+ const done = (message: string) => { setNotice(message); setStale(true); };
88
+
89
+ return (
90
+ <div data-help="storage.lens" style={{ flex: 1, minHeight: 0, overflowY: 'auto', padding: '14px 18px' }}>
91
+ <div style={{ display: 'flex', alignItems: 'center', gap: '10px', flexWrap: 'wrap', marginBottom: '10px' }}>
92
+ <strong className="display-font" style={{ letterSpacing: '2px' }}>STORAGE</strong>
93
+ <button className="display-font" data-help="storage.measure" disabled={loading} onClick={() => void measure(true)} style={btn}>{loading ? 'MEASURING...' : 'MEASURE AGAIN'}</button>
94
+ {overview && <span style={muted}>Total {formatBytes(overview.totalBytes)}, measured {formatRelativeTime(overview.measuredAt)}.{stale ? ' Sizes changed since; MEASURE AGAIN updates them.' : ''}</span>}
95
+ </div>
96
+ <p style={muted}>Read-only sizes. Nothing is changed or deleted without your click. Plans are never touched.</p>
97
+ {error && <div role="alert" style={alert}>{error}</div>}
98
+ {notice && <div role="status" style={{ ...muted, color: 'var(--color-accent-primary)' }}>{notice}</div>}
99
+ {overview?.budget.over && (
100
+ <div role="alert" data-help="storage.budget-notice" style={alert}>
101
+ Arco's storage ({formatBytes(overview.totalBytes)}) is over the disk budget of {formatBytes(overview.budget.limitBytes)}. Archive or delete closed conversations below, or raise the budget.
102
+ </div>
103
+ )}
104
+ <PolicyControls />
105
+ {!overview && loading && <p style={muted}>Measuring every project; large folders take a while.</p>}
106
+ <div>
107
+ {rows.map((r) => {
108
+ const open = expanded === r.key;
109
+ const expandable = r.kind === 'project';
110
+ return (
111
+ <section key={r.key} style={{ borderTop: '1px solid var(--color-border-hairline)', padding: '8px 0' }}>
112
+ <div style={{ display: 'flex', alignItems: 'center', gap: '10px', flexWrap: 'wrap' }}>
113
+ {expandable ? (
114
+ <button className="display-font" data-help="storage.project" aria-expanded={open} title={r.path} onClick={() => setExpanded(open ? null : r.key)} style={chip(open)}>
115
+ {open ? '▾' : '▸'} {r.label} - {formatBytes(r.bytes)}
116
+ </button>
117
+ ) : r.kind === 'home' ? (
118
+ <span className="display-font" data-help="storage.home" style={{ ...chip(false), cursor: 'default' }}>{r.label} - {formatBytes(r.bytes)}</span>
119
+ ) : (
120
+ <span className="display-font" data-help="storage.project" title={r.path} style={{ ...chip(false), cursor: 'default' }}>{r.label} - {formatBytes(r.bytes)}</span>
121
+ )}
122
+ {r.row && <span style={muted}>{r.row.conversations} conversations{r.row.openConversations ? `, ${r.row.openConversations} open` : ''}{r.row.archives.length ? `, ${r.row.archives.length} archived` : ''}</span>}
123
+ {r.kind === 'project' && r.path && <CompressButton path={r.path} onDone={done} onError={setError} />}
124
+ </div>
125
+ <ul style={{ ...muted, margin: '4px 0 0 18px', padding: 0 }}>
126
+ {Object.entries(r.buckets).filter(([, b]) => (b ?? 0) > 0).sort((a, b) => (b[1] ?? 0) - (a[1] ?? 0)).map(([name, b]) => (
127
+ <li key={name}>{LABELS[name] ?? name}: {formatBytes(b ?? 0)}</li>
128
+ ))}
129
+ {r.biggest && <li>Biggest item: {baseName(r.biggest.path)} ({formatBytes(r.biggest.bytes)})</li>}
130
+ </ul>
131
+ {open && r.path && <Conversations path={r.path} onDone={done} onError={setError} />}
132
+ </section>
133
+ );
134
+ })}
135
+ </div>
136
+ </div>
137
+ );
138
+ }
139
+
140
+ function CompressButton({ path, onDone, onError }: { path: string; onDone: (m: string) => void; onError: (m: string) => void }) {
141
+ const [busy, setBusy] = useState(false);
142
+ return <button className="display-font" data-help="storage.compress-logs" aria-label={`COMPRESS OLD LOGS in ${baseName(path)}`} disabled={busy} style={btn} onClick={async () => {
143
+ if (!window.confirm(`Compress the logs of closed conversations in ${baseName(path)}? Nothing is deleted; open conversations are skipped.`)) return;
144
+ setBusy(true);
145
+ try {
146
+ const r = await post('compress-logs', { path }) as { sealed?: number; skippedOpen?: string[]; deferred?: number; beforeBytes?: number; afterBytes?: number };
147
+ onDone(`Compressed ${r.sealed ?? 0} logs in ${baseName(path)}: ${formatBytes(r.beforeBytes ?? 0)} to ${formatBytes(r.afterBytes ?? 0)}${r.skippedOpen?.length ? `; ${r.skippedOpen.length} open conversations skipped` : ''}${r.deferred ? `; ${r.deferred} logs were in use by another program and finish on the next COMPRESS OLD LOGS` : ''}.`);
148
+ } catch (e) { onError(e instanceof Error ? e.message : String(e)); }
149
+ finally { setBusy(false); }
150
+ }}>{busy ? 'COMPRESSING...' : 'COMPRESS OLD LOGS'}</button>;
151
+ }
152
+
153
+ function Conversations({ path, onDone, onError }: { path: string; onDone: (m: string) => void; onError: (m: string) => void }) {
154
+ const [report, setReport] = useState<ProjectReport | null>(null);
155
+ const [busy, setBusy] = useState('');
156
+ const [tick, setTick] = useState(0);
157
+ useEffect(() => {
158
+ let cancelled = false;
159
+ fetch(`/api/storage-report?path=${encodeURIComponent(path)}${tick ? '&refresh=1' : ''}`)
160
+ .then((r) => { if (!r.ok) throw new Error('This project could not be measured.'); return r.json() as Promise<ProjectReport>; })
161
+ .then((d) => { if (!cancelled) setReport(d); })
162
+ .catch((e) => { if (!cancelled) onError(e instanceof Error ? e.message : String(e)); });
163
+ return () => { cancelled = true; };
164
+ }, [path, tick]);
165
+ async function act(action: string, id: string, question: string, done: (r: Record<string, unknown>) => string) {
166
+ if (!window.confirm(question)) return;
167
+ setBusy(`${action}:${id}`);
168
+ try { onDone(done(await post(action, { path, workflowId: id }))); setTick((t) => t + 1); }
169
+ catch (e) { onError(e instanceof Error ? e.message : String(e)); }
170
+ finally { setBusy(''); }
171
+ }
172
+ if (!report) return <p style={muted}>Reading conversations...</p>;
173
+ const size = (c: Conversation) => c.eventBytes + c.artifactBytes + c.handoffBytes + c.checkpointBytes + (c.scratchBytes ?? 0) + (c.otherBytes ?? 0);
174
+ const live = report.workflows.filter((c) => size(c) > 0);
175
+ return (
176
+ <div style={{ margin: '6px 0 4px 18px' }}>
177
+ {live.length === 0 && !(report.archives ?? []).length && <p style={muted}>No conversations.</p>}
178
+ {live.map((c) => {
179
+ const title = c.name || c.id.slice(0, 8);
180
+ const working = c.open || c.busy;
181
+ const keepText = !c.keep ? '' : !c.keep.readable ? 'KEEP list unreadable' : c.keep.whole ? 'Kept' : c.keep.items ? `${c.keep.items} kept ${c.keep.items === 1 ? 'item' : 'items'}` : '';
182
+ return (
183
+ <div key={c.id} style={{ display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'wrap', padding: '3px 0' }}>
184
+ <span style={{ minWidth: '180px' }} title={c.id}>{title}</span>
185
+ <span style={muted}>{formatBytes(size(c))} - {working ? 'Open' : 'Closed'}{c.lastActive ? ` - ${formatRelativeTime(c.lastActive)}` : ''}</span>
186
+ {keepText && <span data-help="storage.keep" style={{ ...muted, color: 'var(--color-accent-primary)' }}>{keepText}</span>}
187
+ <KeepButton cwd={path} workflowId={c.id} itemPath="." help="storage.keep" className="display-font" style={btn}
188
+ disabled={!!busy || !c.keep?.readable || c.keep.whole}
189
+ confirmMessage={`Keep all of "${title}"? Archive and delete will leave it in place.`}
190
+ onError={onError} onKept={() => { onDone(`Kept "${title}".`); setTick((t) => t + 1); }} />
191
+ <button className="display-font" data-help="storage.archive" aria-label={`ARCHIVE ${title}`} style={btn} disabled={!!busy || working || c.keep?.whole}
192
+ title={working ? 'Close the conversation first' : c.keep?.whole ? 'The whole conversation is kept' : undefined}
193
+ onClick={() => void act('archive', c.id, `Archive "${title}"? Its files are packed into one compressed file and can be restored. Kept items stay in place.`,
194
+ (r) => `Archived "${title}": ${formatBytes(Number(r.originalBytes) || 0)} into ${formatBytes(Number(r.archiveBytes) || 0)}.`)}>ARCHIVE</button>
195
+ <button className="display-font" data-help="storage.delete" aria-label={`DELETE ${title}`} style={btn} disabled={!!busy || working || c.keep?.whole}
196
+ title={working ? 'Close the conversation first' : c.keep?.whole ? 'The whole conversation is kept' : undefined}
197
+ onClick={() => void act('delete', c.id, `Delete "${title}" permanently? Its log, artifacts, checkpoints and search entry are removed. Kept items stay. This cannot be undone.`,
198
+ (r) => `Deleted "${title}" (${formatBytes(Number(r.removedBytes) || 0)}).`)}>DELETE</button>
199
+ {(c.scratchBytes ?? 0) > 0 && <button className="display-font" data-help="storage.empty-scratch" aria-label={`EMPTY SCRATCH of ${title}`} style={btn} disabled={!!busy || !!c.busy}
200
+ onClick={() => void act('empty-scratch', c.id, `Empty the scratch folder of "${title}" (${formatBytes(c.scratchBytes ?? 0)})? Kept items stay.`,
201
+ (r) => `Emptied scratch of "${title}" (${formatBytes(Number(r.removedBytes) || 0)}).`)}>EMPTY SCRATCH</button>}
202
+ </div>
203
+ );
204
+ })}
205
+ {(report.archives ?? []).map((a) => (
206
+ <div key={`a:${a.workflowId}`} style={{ display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'wrap', padding: '3px 0' }}>
207
+ <span style={{ minWidth: '180px' }} title={a.workflowId}>{a.workflowId.slice(0, 8)}</span>
208
+ <span style={muted}>Archived {formatRelativeTime(a.archivedAt)} - {formatBytes(a.bytes)}</span>
209
+ <button className="display-font" data-help="storage.restore" aria-label={`RESTORE ${a.workflowId.slice(0, 8)}`} style={btn} disabled={!!busy}
210
+ onClick={() => void act('restore', a.workflowId, 'Restore this archived conversation? Nothing that already exists is overwritten.',
211
+ (r) => `Restored ${Number(r.files) || 0} files.`)}>RESTORE</button>
212
+ <button className="display-font" data-help="storage.delete" aria-label={`DELETE archive ${a.workflowId.slice(0, 8)}`} style={btn} disabled={!!busy}
213
+ onClick={() => void act('delete', a.workflowId, 'Delete this archived conversation permanently? The archive and its search entry are removed. This cannot be undone.',
214
+ (r) => `Deleted the archive (${formatBytes(Number(r.removedBytes) || 0)}).`)}>DELETE</button>
215
+ </div>
216
+ ))}
217
+ </div>
218
+ );
219
+ }
220
+
221
+ function PolicyControls() {
222
+ const [policy, setPolicy] = useState<Policy | null>(null);
223
+ const [days, setDays] = useState('30');
224
+ const [budget, setBudget] = useState('100');
225
+ const [error, setError] = useState('');
226
+ useEffect(() => {
227
+ fetch('/api/storage/policy').then((r) => r.json() as Promise<Policy>).then((p) => {
228
+ setPolicy(p); setBudget(String(p.budgetGiB)); if (p.autoArchiveClosedDays) setDays(String(p.autoArchiveClosedDays));
229
+ }).catch(() => setError('The storage settings could not be read.'));
230
+ }, []);
231
+ async function save(patch: Partial<Policy>) {
232
+ try {
233
+ const r = await fetch('/api/storage/policy', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(patch) });
234
+ if (!r.ok) throw new Error(`HTTP ${r.status}`);
235
+ const next = await r.json() as Policy; setPolicy(next); setBudget(String(next.budgetGiB)); setError('');
236
+ } catch (e) { setError(e instanceof Error ? e.message : String(e)); }
237
+ }
238
+ if (!policy) return error ? <div role="alert" style={alert}>{error}</div> : null;
239
+ const on = policy.autoArchiveClosedDays !== null;
240
+ return (
241
+ <details style={{ margin: '6px 0 10px' }}>
242
+ <summary className="display-font" style={{ cursor: 'pointer', letterSpacing: '1px' }}>STORAGE SETTINGS</summary>
243
+ <div style={{ display: 'flex', flexDirection: 'column', gap: '6px', padding: '6px 0 0 12px' }}>
244
+ <label data-help="storage.auto-archive" style={{ display: 'flex', alignItems: 'center', gap: '6px', flexWrap: 'wrap' }}>
245
+ <input type="checkbox" checked={on} onChange={(e) => void save({ autoArchiveClosedDays: e.target.checked ? Math.max(1, Number(days) || 30) : null })} />
246
+ Archive conversations closed for more than
247
+ <input type="number" min={1} max={3650} value={days} aria-label="Days closed before archiving" style={{ width: '64px' }}
248
+ onChange={(e) => setDays(e.target.value)} onBlur={() => { if (on) void save({ autoArchiveClosedDays: Math.max(1, Number(days) || 30) }); }} />
249
+ days (off by default; never deletes)
250
+ </label>
251
+ <label data-help="storage.budget" style={{ display: 'flex', alignItems: 'center', gap: '6px', flexWrap: 'wrap' }}>
252
+ <input type="checkbox" checked={policy.budgetNotice} onChange={(e) => void save({ budgetNotice: e.target.checked })} />
253
+ Show a notice when Arco's storage passes
254
+ <input type="number" min={1} value={budget} aria-label="Disk budget in GiB" style={{ width: '72px' }}
255
+ onChange={(e) => setBudget(e.target.value)} onBlur={() => void save({ budgetGiB: Number(budget) })} />
256
+ GiB
257
+ </label>
258
+ {error && <div role="alert" style={alert}>{error}</div>}
259
+ </div>
260
+ </details>
261
+ );
262
+ }
263
+
264
+ const muted: React.CSSProperties = { fontSize: '11px', color: 'var(--color-fg-muted)' };
265
+ const alert: React.CSSProperties = { fontSize: '12px', color: 'var(--color-warning, var(--color-accent-primary))', border: '1px solid var(--color-border-hairline)', borderRadius: '3px', padding: '6px 9px', margin: '6px 0' };
266
+ const chip = (on: boolean): React.CSSProperties => ({
267
+ background: on ? 'var(--color-accent-primary-a10)' : 'transparent',
268
+ border: `1px solid ${on ? 'var(--color-accent-primary)' : 'var(--color-border-hairline)'}`,
269
+ borderRadius: '3px', color: on ? 'var(--color-accent-primary)' : 'var(--color-accent-primary-dim)',
270
+ cursor: 'pointer', fontSize: '12px', letterSpacing: '1px', padding: '4px 9px',
271
+ });
272
+ const btn: React.CSSProperties = {
273
+ background: 'transparent', border: '1px solid var(--color-accent-primary-dim)', borderRadius: '3px',
274
+ color: 'var(--color-accent-primary)', cursor: 'pointer', fontSize: '11px', letterSpacing: '1.5px', padding: '4px 9px',
275
+ };
@@ -18,8 +18,8 @@ const EXPLORER_URL = '/?app=explorer';
18
18
 
19
19
  // `lens` picks the landing lens (`&lens=plans` → the PLANS library). An
20
20
  // already-open explorer window is re-navigated to it, not duplicated.
21
- export async function openArchive(lens?: 'plans'): Promise<void> {
22
- const url = lens ? `${EXPLORER_URL}&lens=${lens}` : EXPLORER_URL;
21
+ export async function openArchive(lens?: 'plans', cwd?: string): Promise<void> {
22
+ const url = `${EXPLORER_URL}${lens ? `&lens=${lens}` : ''}${cwd ? `&cwd=${encodeURIComponent(cwd)}` : ''}`;
23
23
  // Same-browser popup — inherits correct per-monitor DPI. Named so a second
24
24
  // click focuses the existing window instead of stacking duplicates.
25
25
  const win = window.open(url, 'arco-explorer', 'popup,width=1400,height=900');
@@ -27,7 +27,7 @@ export async function openArchive(lens?: 'plans'): Promise<void> {
27
27
 
28
28
  // Popup refused (rare for a user gesture) → server-spawned chromeless window.
29
29
  try {
30
- const res = await fetch('/api/explorer/open', { method: 'POST' });
30
+ const res = await fetch(`/api/explorer/open?${new URLSearchParams({ ...(lens ? { lens } : {}), ...(cwd ? { cwd } : {}) })}`, { method: 'POST' });
31
31
  const body = (await res.json()) as { ok?: boolean };
32
32
  if (body.ok) return;
33
33
  } catch {
@@ -0,0 +1,15 @@
1
+ import type { PlanLibraryEntry } from '@arco/shared';
2
+
3
+ export function probablyFinished(plan: PlanLibraryEntry, now = Date.now()): boolean {
4
+ return !plan.attached && plan.completedAt == null &&
5
+ ((Boolean(plan.checkboxTotal) && plan.checkboxTotal === plan.checkboxDone) || now - plan.updatedAt >= 30 * 86400000);
6
+ }
7
+
8
+ export function foldVersions(plans: PlanLibraryEntry[]): PlanLibraryEntry[][] {
9
+ const groups = new Map<string, PlanLibraryEntry[]>();
10
+ for (const plan of plans) {
11
+ const key = plan.title.trim().toLocaleLowerCase();
12
+ groups.set(key, [...(groups.get(key) ?? []), plan]);
13
+ }
14
+ return [...groups.values()];
15
+ }
@@ -140,7 +140,8 @@ export const clusterHelp: Record<string, HelpEntry> = {
140
140
  The number of messages waiting for this member. They are delivered at
141
141
  its next turn. While the member is busy the mark is muted. When the
142
142
  member is idle with mail it is highlighted like a question, counts the
143
- tab as Needs you, and clicking it nudges that member. It makes no
143
+ tab as Needs you, and clicking it nudges that member. After a nudge the
144
+ mark reads Nudged until the member starts its turn. It makes no
144
145
  sound and shows no pop-up.
145
146
  </p>
146
147
  ),
@@ -186,7 +187,7 @@ export const clusterHelp: Record<string, HelpEntry> = {
186
187
  body: (
187
188
  <>
188
189
  <p>
189
- NUDGE sits beside the send area of the cluster message box and shows the total of waiting mail (for example <C>NUDGE 2</C>), highlighted while any member has mail. It opens the NUDGE modal: a per-member checkbox list with each
190
+ NUDGE sits beside the send area of the cluster message box and shows the total of waiting mail (for example <C>NUDGE 2</C>), highlighted while any member has mail. After a nudge it reads <C>NUDGED 1</C> (the number of members nudged) until they start their turn, or for two minutes. It opens the NUDGE modal: a per-member checkbox list with each
190
191
  member&apos;s role chip, mailbox depth (e.g. <C>3 MAIL</C>),
191
192
  and a BUSY badge when applicable. Default selection is{' '}
192
193
  <strong>empty</strong>; you pick recipients explicitly. SEND
@@ -889,8 +890,42 @@ export const clusterHelp: Record<string, HelpEntry> = {
889
890
  title: 'Show done',
890
891
  body: (
891
892
  <p>
892
- Done and archived tasks are hidden by default so the board shows only live
893
- work. Turn this on to list them again. The count at the top still counts all tasks.
893
+ Done and archived tasks are shown by default so finished work stays in view.
894
+ Turn this off to hide them and show only live work; the choice is remembered.
895
+ The count at the top matches the tasks drawn, and says how many done tasks are hidden.
896
+ </p>
897
+ ),
898
+ manualSection: 'cluster-board',
899
+ },
900
+ 'cluster.board-release-filter': {
901
+ title: 'Release filter',
902
+ body: (
903
+ <p>
904
+ Appears once any task has a release label. Pick a label to show only the
905
+ tasks for that release, NO RELEASE for unlabeled tasks, or ALL RELEASES
906
+ for everything. Labels are set in a card&apos;s drawer or by the director.
907
+ </p>
908
+ ),
909
+ manualSection: 'cluster-board',
910
+ },
911
+ 'cluster.board-release-summary': {
912
+ title: 'Ready to release',
913
+ body: (
914
+ <p>
915
+ For the chosen release: how many tasks are in it, how many you accepted
916
+ (done), and how many are left. It reads READY TO RELEASE when none are
917
+ left. Archived tasks are not counted.
918
+ </p>
919
+ ),
920
+ manualSection: 'cluster-board',
921
+ },
922
+ 'cluster.task-release': {
923
+ title: 'Release label',
924
+ body: (
925
+ <p>
926
+ An optional label such as 0.1.4 that says which release this task
927
+ belongs to. Leave it empty for no label; saving an empty field removes
928
+ the label.
894
929
  </p>
895
930
  ),
896
931
  manualSection: 'cluster-board',
@@ -962,8 +997,8 @@ export const clusterHelp: Record<string, HelpEntry> = {
962
997
  <p>
963
998
  Saves the worker-drafted plan to disk and routes the body up to the
964
999
  cluster's shared PLAN slot (standard members see it on their next turn).
965
- Only shown when this workflow is a cluster member; standalone tabs
966
- only see SAVE &amp; ATTACH / DISCARD.
1000
+ In a cluster this is the only save choice; standalone tabs see
1001
+ SAVE &amp; ATTACH instead. REFINE and DISCARD appear in both.
967
1002
  </p>
968
1003
  ),
969
1004
  manualSection: 'cluster-attach-from-banner',
@@ -1255,7 +1290,7 @@ export const clusterHelp: Record<string, HelpEntry> = {
1255
1290
  },
1256
1291
  'cluster.auto-pickup-evaluator': {
1257
1292
  title: 'Smart evaluator',
1258
- body: <p>Choose the provider and model that judge waiting mail. A provider is offered only while it is enabled, connected and able to answer without tools here: Claude with Native sign-in, Cursor, Codex, and Ollama. Codex runs as a one-shot read-only session with no MCP servers or web search, and any tool use ends the request with no decision. Nothing is chosen in advance, and the last choice is offered again only while it is still offered. The evaluator receives only the waiting mail and short member and task facts and answers wake, wait or ask, so a fast, low-cost model suits it. The mail goes to the chosen provider and any cost depends on that provider. USE UTILITY AGENT, shown when a utility agent is saved and usable, only fills in the provider and model from Settings; nothing is armed until you press ARM.</p>,
1293
+ body: <p>Choose the provider and model that judge waiting mail. A provider is offered only while it is enabled, connected and able to answer without tools here: Claude with Native sign-in, Cursor, Codex, Ollama, LM Studio, llama.cpp, Strata, and DeepSeek through Xolotl. LM Studio, llama.cpp, Strata and DeepSeek require the selected model to be loaded first; these requests never load or switch models. Codex runs as a one-shot read-only session with no MCP servers or web search, and any tool use ends the request with no decision. Nothing is chosen in advance, and the last choice is offered again only while it is still offered. The evaluator receives only the waiting mail and short member and task facts and answers wake, wait or ask, so a fast, low-cost model suits it. The mail goes to the chosen provider and any cost depends on that provider. USE UTILITY AGENT, shown when a utility agent is saved and usable, only fills in the provider and model from Settings; nothing is armed until you press ARM.</p>,
1259
1294
  manualSection: 'cluster-auto-pickup',
1260
1295
  },
1261
1296
  'cluster.auto-pickup-limits': {