@openchamber/web 1.22.1 → 1.23.0

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 (205) hide show
  1. package/bin/cli.js +11 -1
  2. package/bin/cli.test.js +92 -0
  3. package/bin/lib/cli-startup.js +49 -0
  4. package/bin/lib/commands-startup.js +41 -6
  5. package/dist/assets/{CodeMirrorCommentWidgets-BO_2OW4E.js → CodeMirrorCommentWidgets-DbcnxAfY.js} +1 -1
  6. package/dist/assets/DiffView-Dp1tomqK.js +4 -0
  7. package/dist/assets/{DirtyBranchSwitchDialog-jADfXQnR.js → DirtyBranchSwitchDialog-DE2sKIYv.js} +1 -1
  8. package/dist/assets/FilesView-C_of2nIT.js +17 -0
  9. package/dist/assets/{GitView-Cv2xH-S6.js → GitView-CKgUkb5Z.js} +4 -4
  10. package/dist/assets/{JsonTreeView-DUiIpERC.js → JsonTreeView-Bce2ettZ.js} +1 -1
  11. package/dist/assets/{LinearIssuesView-CoZ7pQN5.js → LinearIssuesView-BZVWM2zw.js} +1 -1
  12. package/dist/assets/MarkdownImageGallery-DdROVz29.js +1 -0
  13. package/dist/assets/MarkdownRendererImpl-CenrzmMN.js +12 -0
  14. package/dist/assets/OnboardingScreen-DyqYG_NP.js +1 -0
  15. package/dist/assets/{PatchDiff-BymkP9JA.js → PatchDiff-CR3RVO5I.js} +1 -1
  16. package/dist/assets/PierreDiffViewer-KihzO94X.js +161 -0
  17. package/dist/assets/PlanView-jcQAfr2A.js +5 -0
  18. package/dist/assets/SettingsView-Buvom5A2.js +28 -0
  19. package/dist/assets/{SettingsWindow-COzgfFxM.js → SettingsWindow-CV_hzB5v.js} +1 -1
  20. package/dist/assets/SymbolsNerdFontMono-Regular-aK5vsLov.woff2 +0 -0
  21. package/dist/assets/{ToolOutputDialog-Dlhh_-oe.js → ToolOutputDialog-llKecK_Z.js} +6 -6
  22. package/dist/assets/{ToolPartDiffPreview-b9joNtXH.js → ToolPartDiffPreview-ZDMTdCGn.js} +2 -2
  23. package/dist/assets/{VirtualizedFileDiff-vqW3KKo5.js → VirtualizedFileDiff-ClvqQ4j0.js} +1 -1
  24. package/dist/assets/WalkthroughView-BgpSnSlU.js +4 -0
  25. package/dist/assets/{computeVirtualFileMetrics-DUnyszhW.js → computeVirtualFileMetrics-Nm5_wabb.js} +2 -2
  26. package/dist/assets/contextPanelEmbeddedChat-CirXEPJq.js +1 -0
  27. package/dist/assets/de-DTQDjaiv.js +10 -0
  28. package/dist/assets/es-SOCFd_r-.js +16 -0
  29. package/dist/assets/fr-CP6jqIzw.js +14 -0
  30. package/dist/assets/ghostty-vt-DdA0Zryv.wasm +0 -0
  31. package/dist/assets/index-B68h5S5B.css +1 -0
  32. package/dist/assets/index-CRf2xk51.js +39 -0
  33. package/dist/assets/{index-DLiD86ge.js → index-Du9sZhDb.js} +1 -1
  34. package/dist/assets/{isDiffPlainText-TNageFjy.js → isDiffPlainText-EQERIius.js} +1 -1
  35. package/dist/assets/{isFilePlainText-JPmZOYSp.js → isFilePlainText-BCoVpkQy.js} +1 -1
  36. package/dist/assets/ja-BKfafwsD.js +16 -0
  37. package/dist/assets/ko-BA5xgCYp.js +16 -0
  38. package/dist/assets/main-BNiPEont.js +930 -0
  39. package/dist/assets/{main-DCB4JgVe.js → main-DPf32fO6.js} +2 -2
  40. package/dist/assets/markdownCore-CQ7CAuuV.js +5 -0
  41. package/dist/assets/{miniChat-BtV7N5OF.js → miniChat-CHqVTsgj.js} +2 -2
  42. package/dist/assets/{mobile-DZV_sfX7.js → mobile-BQmgHA57.js} +2 -2
  43. package/dist/assets/patchFileDiff-C4X_trug.js +13 -0
  44. package/dist/assets/pl-B215pG1Y.js +16 -0
  45. package/dist/assets/pt-BR-Bo2pnlEa.js +16 -0
  46. package/dist/assets/renderElectronMiniChatApp-BUcHPOXW.js +2 -0
  47. package/dist/assets/renderMobileApp-BvTmuRE-.js +25 -0
  48. package/dist/assets/runtimeEndpointReset-C8GAA2kS.js +17 -0
  49. package/dist/assets/scheduledTasksApi-BAScWwt3.js +1 -0
  50. package/dist/assets/{shikiHighlight-CRpCl7UT.js → shikiHighlight-BTObuQCR.js} +1 -1
  51. package/dist/assets/surface-BvRzS58U.js +1 -0
  52. package/dist/assets/tr-CUaxHc8X.js +7 -0
  53. package/dist/assets/uk-YTJgyqAZ.js +16 -0
  54. package/dist/assets/{useAppFontEffects-CCgvcQ6u.js → useAppFontEffects-theH_IJL.js} +143 -137
  55. package/dist/assets/useGitComparison-B94I6kOI.js +1 -0
  56. package/dist/assets/useInlineCommentController-Bs3PgeA8.js +2 -0
  57. package/dist/assets/useRootScrollLock-hSYwnxZs.js +1 -0
  58. package/dist/assets/{vendor-base-ui-BeMD8X_w.js → vendor-base-ui-DdV8vhHn.js} +1 -1
  59. package/dist/assets/{vendor-codemirror-language-data-BxpoC5Fp.js → vendor-codemirror-language-data-Cxgr01md.js} +2 -2
  60. package/dist/assets/vendor-legendapp-list-BuBPBC3R.js +1 -0
  61. package/dist/assets/vendor-zod-BPAANqvH.js +39 -0
  62. package/dist/assets/{web-components-B6QgbmTo.js → web-components-CaS0ksnZ.js} +1 -1
  63. package/dist/assets/zh-CN-CZ2BxZS6.js +16 -0
  64. package/dist/assets/zh-TW-BsUrPdXz.js +16 -0
  65. package/dist/index.html +5 -43
  66. package/dist/mini-chat.html +4 -4
  67. package/dist/mobile.html +4 -4
  68. package/package.json +3 -4
  69. package/server/index.d.ts +15 -0
  70. package/server/index.js +52 -10
  71. package/server/lib/changelog/update-notes.js +82 -0
  72. package/server/lib/changelog/update-notes.test.js +59 -0
  73. package/server/lib/data-dir-migration.js +40 -0
  74. package/server/lib/data-dir-migration.test.js +59 -0
  75. package/server/lib/event-stream/runtime.test.js +12 -12
  76. package/server/lib/fs/DOCUMENTATION.md +5 -0
  77. package/server/lib/fs/routes.js +63 -21
  78. package/server/lib/fs/routes.test.js +187 -1
  79. package/server/lib/git/DOCUMENTATION.md +29 -5
  80. package/server/lib/git/routes.js +24 -4
  81. package/server/lib/git/service.js +194 -198
  82. package/server/lib/git/service.test.js +440 -25
  83. package/server/lib/inherited-env.js +16 -9
  84. package/server/lib/inherited-env.test.js +8 -9
  85. package/server/lib/message-queue/DOCUMENTATION.md +20 -7
  86. package/server/lib/message-queue/runtime.js +59 -7
  87. package/server/lib/message-queue/runtime.test.js +59 -3
  88. package/server/lib/network-defaults.js +23 -0
  89. package/server/lib/network-defaults.test.js +52 -0
  90. package/server/lib/opencode/DOCUMENTATION.md +25 -5
  91. package/server/lib/opencode/bootstrap-runtime.js +2 -0
  92. package/server/lib/opencode/config-paths.test.js +116 -0
  93. package/server/lib/opencode/feature-routes-runtime.js +4 -0
  94. package/server/lib/opencode/input-history-scope.js +14 -0
  95. package/server/lib/opencode/openchamber-routes.js +64 -4
  96. package/server/lib/opencode/openchamber-routes.test.js +128 -1
  97. package/server/lib/opencode/plugins.js +2 -2
  98. package/server/lib/opencode/providers.js +44 -2
  99. package/server/lib/opencode/providers.test.js +131 -4
  100. package/server/lib/opencode/routes.js +9 -7
  101. package/server/lib/opencode/server-startup-runtime.js +1 -1
  102. package/server/lib/opencode/settings-files.js +214 -0
  103. package/server/lib/opencode/settings-helpers.js +113 -41
  104. package/server/lib/opencode/settings-helpers.test.js +342 -0
  105. package/server/lib/opencode/settings-registry.json +747 -0
  106. package/server/lib/opencode/settings-runtime.js +139 -18
  107. package/server/lib/opencode/settings-runtime.test.js +163 -5
  108. package/server/lib/opencode/shared.js +4 -1
  109. package/server/lib/opencode/skill-routes.js +2 -1
  110. package/server/lib/opencode/snippets.js +1 -2
  111. package/server/lib/package-manager.js +3 -28
  112. package/server/lib/project-context/DOCUMENTATION.md +25 -1
  113. package/server/lib/project-context/routes.http.test.js +18 -0
  114. package/server/lib/project-context/routes.js +15 -0
  115. package/server/lib/project-context/runtime.js +248 -23
  116. package/server/lib/project-context/runtime.test.js +106 -3
  117. package/server/lib/projects/DOCUMENTATION.md +76 -0
  118. package/server/lib/projects/project-config.js +142 -9
  119. package/server/lib/projects/project-id.js +17 -0
  120. package/server/lib/projects/project-setup.js +409 -0
  121. package/server/lib/projects/project-setup.test.js +557 -0
  122. package/server/lib/projects/routes.js +59 -0
  123. package/server/lib/quota/DOCUMENTATION.md +38 -1
  124. package/server/lib/quota/index.js +1 -0
  125. package/server/lib/quota/providers/cline-pass.js +125 -0
  126. package/server/lib/quota/providers/cline-pass.test.js +103 -0
  127. package/server/lib/quota/providers/hyper.js +118 -0
  128. package/server/lib/quota/providers/hyper.test.js +126 -0
  129. package/server/lib/quota/providers/index.js +15 -0
  130. package/server/lib/quota/providers/neuralwatt.js +3 -6
  131. package/server/lib/quota/providers/neuralwatt.test.js +7 -7
  132. package/server/lib/quota/providers/ollama-cloud.js +31 -0
  133. package/server/lib/quota/providers/ollama-cloud.test.js +33 -1
  134. package/server/lib/quota/providers/opencode-go.js +1 -1
  135. package/server/lib/quota/providers/opencode-go.test.js +26 -1
  136. package/server/lib/quota/providers/openrouter.js +119 -24
  137. package/server/lib/quota/providers/openrouter.test.js +330 -0
  138. package/server/lib/quota/utils/auth.js +1 -1
  139. package/server/lib/relay/DOCUMENTATION.md +55 -0
  140. package/server/lib/relay/cross-compat.test.js +26 -0
  141. package/server/lib/relay/downstream-scheduler.js +154 -0
  142. package/server/lib/relay/downstream-scheduler.test.js +162 -0
  143. package/server/lib/relay/e2ee.js +10 -8
  144. package/server/lib/relay/flow-control.test.js +177 -0
  145. package/server/lib/relay/host-client.js +37 -8
  146. package/server/lib/relay/host-client.test.js +9 -1
  147. package/server/lib/relay/tunnel-codec.js +9 -0
  148. package/server/lib/relay/tunnel-host.js +66 -17
  149. package/server/lib/session-assist/runtime.js +6 -10
  150. package/server/lib/session-goal/DOCUMENTATION.md +20 -7
  151. package/server/lib/session-goal/runtime.js +80 -20
  152. package/server/lib/session-goal/runtime.test.js +426 -0
  153. package/server/lib/skills-catalog/DOCUMENTATION.md +1 -1
  154. package/server/lib/skills-catalog/install.js +3 -2
  155. package/server/lib/small-model/DOCUMENTATION.md +3 -2
  156. package/server/lib/small-model/call.js +9 -4
  157. package/server/lib/small-model/call.test.js +29 -0
  158. package/server/lib/small-model/index.js +5 -10
  159. package/server/lib/small-model/runtime-providers.js +15 -7
  160. package/server/lib/small-model/runtime-providers.test.js +7 -1
  161. package/server/lib/terminal/DOCUMENTATION.md +14 -10
  162. package/server/lib/terminal/runtime.js +160 -24
  163. package/server/lib/terminal/runtime.test.js +571 -37
  164. package/server/lib/terminal/shells.js +17 -0
  165. package/server/lib/terminal/shells.test.js +32 -1
  166. package/server/lib/walkthrough/DOCUMENTATION.md +33 -14
  167. package/server/lib/walkthrough/model-settings.js +8 -12
  168. package/server/lib/walkthrough/prompt.js +3 -1
  169. package/server/lib/walkthrough/routes.test.js +26 -5
  170. package/server/lib/walkthrough/sources.js +23 -2
  171. package/dist/assets/DiffView-CNnDxRmO.js +0 -4
  172. package/dist/assets/FilesView-8wdiG2mj.js +0 -17
  173. package/dist/assets/MarkdownImageGallery-DffjmciG.js +0 -1
  174. package/dist/assets/MarkdownRendererImpl-DxqdYDAx.js +0 -12
  175. package/dist/assets/OnboardingScreen-CTZe6HZn.js +0 -1
  176. package/dist/assets/PierreDiffViewer-BvwtCxW4.js +0 -157
  177. package/dist/assets/PlanView-C1qvAm7m.js +0 -5
  178. package/dist/assets/SettingsView-xGONHFGS.js +0 -28
  179. package/dist/assets/WalkthroughView-D-HFgdmM.js +0 -4
  180. package/dist/assets/contextPanelEmbeddedChat-CV-DwAiX.js +0 -1
  181. package/dist/assets/de-Cv_4FoXm.js +0 -10
  182. package/dist/assets/es-BIWNEbnS.js +0 -16
  183. package/dist/assets/fr-SD3OfMHJ.js +0 -14
  184. package/dist/assets/index-CHUT_bDS.css +0 -1
  185. package/dist/assets/index-DDInLQDd.js +0 -40
  186. package/dist/assets/ja-D7I9HofF.js +0 -16
  187. package/dist/assets/ko-BsVJM_PQ.js +0 -16
  188. package/dist/assets/main-De8Z5w49.js +0 -928
  189. package/dist/assets/markdownCore-BoQVG5-a.js +0 -3
  190. package/dist/assets/patchFileDiff-Chmiz6hq.js +0 -10
  191. package/dist/assets/pl-XR9Bs8Be.js +0 -16
  192. package/dist/assets/pt-BR-Due4be8g.js +0 -16
  193. package/dist/assets/renderElectronMiniChatApp-8tXADjfl.js +0 -2
  194. package/dist/assets/renderMobileApp-Cji7Hma5.js +0 -25
  195. package/dist/assets/runtimeEndpointReset-gWt3Lb5D.js +0 -16
  196. package/dist/assets/scheduledTasksApi-9e-UX6im.js +0 -1
  197. package/dist/assets/tr-DBJcAv4y.js +0 -7
  198. package/dist/assets/uk-COYh2BaN.js +0 -16
  199. package/dist/assets/useInlineCommentController-BkfXnjNZ.js +0 -2
  200. package/dist/assets/useRootScrollLock-KzOUytpn.js +0 -1
  201. package/dist/assets/vendor-ghostty-web-CrxinGGH.js +0 -13
  202. package/dist/assets/vendor-legendapp-list-gg7YLRW7.js +0 -1
  203. package/dist/assets/vendor-zod-DVWEh-IS.js +0 -39
  204. package/dist/assets/zh-CN-Cjk6lzhc.js +0 -16
  205. package/dist/assets/zh-TW-Dk0dOg03.js +0 -16
package/dist/index.html CHANGED
@@ -509,16 +509,16 @@
509
509
  pointer-events: none;
510
510
  }
511
511
  </style>
512
- <script type="module" crossorigin src="/assets/main-DCB4JgVe.js"></script>
512
+ <script type="module" crossorigin src="/assets/main-DPf32fO6.js"></script>
513
513
  <link rel="modulepreload" crossorigin href="/assets/vendor-vite-runtime-DD1OZmLC.js">
514
514
  <link rel="modulepreload" crossorigin href="/assets/vendor-scheduler-7OC5HNn7.js">
515
515
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-BUCujlKS.js">
516
516
  <link rel="modulepreload" crossorigin href="/assets/vendor-zustand-BAGL70zf.js">
517
- <link rel="modulepreload" crossorigin href="/assets/vendor-zod-DVWEh-IS.js">
517
+ <link rel="modulepreload" crossorigin href="/assets/vendor-zod-BPAANqvH.js">
518
518
  <link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-BJ73u-bH.js">
519
- <link rel="modulepreload" crossorigin href="/assets/index-DDInLQDd.js">
520
- <link rel="modulepreload" crossorigin href="/assets/contextPanelEmbeddedChat-CV-DwAiX.js">
521
- <link rel="stylesheet" crossorigin href="/assets/index-CHUT_bDS.css">
519
+ <link rel="modulepreload" crossorigin href="/assets/index-CRf2xk51.js">
520
+ <link rel="modulepreload" crossorigin href="/assets/contextPanelEmbeddedChat-CirXEPJq.js">
521
+ <link rel="stylesheet" crossorigin href="/assets/index-B68h5S5B.css">
522
522
  </head>
523
523
  <body class="h-full bg-background text-foreground">
524
524
  <div id="root" class="h-full">
@@ -603,44 +603,6 @@
603
603
  }, 10000);
604
604
  </script>
605
605
 
606
- <!-- CSS Font Loading API for reliable Nerd Font loading. The ~2 MB of
607
- Nerd Fonts are only used by the terminal viewport, so they are no
608
- longer downloaded on every cold start: the terminal requests them on
609
- first mount through this idempotent hook. -->
610
- <script>
611
- (function() {
612
- let nerdFontsPromise = null;
613
- window.__openchamberEnsureNerdFonts = function() {
614
- if (nerdFontsPromise) {
615
- return nerdFontsPromise;
616
- }
617
- const fonts = [
618
- {
619
- name: 'JetBrainsMono Nerd Font',
620
- url: 'https://cdn.jsdelivr.net/gh/mshaugh/nerdfont-webfonts@v3.3.0/build/fonts/JetBrainsMonoNerdFont-Regular.woff2'
621
- },
622
- {
623
- name: 'FiraCode Nerd Font',
624
- url: 'https://cdn.jsdelivr.net/gh/mshaugh/nerdfont-webfonts@v3.3.0/build/fonts/FiraCodeNerdFont-Regular.woff2'
625
- }
626
- ];
627
-
628
- const fontPromises = fonts.map(font => {
629
- const fontFace = new FontFace(font.name, `url(${font.url}) format('woff2')`);
630
- document.fonts.add(fontFace);
631
- return fontFace.load().catch(err => {
632
- console.warn(`Failed to load font: ${font.name}`, err);
633
- });
634
- });
635
-
636
- nerdFontsPromise = Promise.allSettled(fontPromises).then(() => {
637
- document.documentElement.classList.add('fonts-loaded');
638
- });
639
- return nerdFontsPromise;
640
- };
641
- })();
642
- </script>
643
-
644
606
  <!-- Polyfill for process before loading React -->
645
607
  <script>
646
608
  if (typeof process === 'undefined') {
@@ -74,15 +74,15 @@
74
74
  }
75
75
  </style>
76
76
 
77
- <script type="module" crossorigin src="/assets/miniChat-BtV7N5OF.js"></script>
77
+ <script type="module" crossorigin src="/assets/miniChat-CHqVTsgj.js"></script>
78
78
  <link rel="modulepreload" crossorigin href="/assets/vendor-vite-runtime-DD1OZmLC.js">
79
79
  <link rel="modulepreload" crossorigin href="/assets/vendor-scheduler-7OC5HNn7.js">
80
80
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-BUCujlKS.js">
81
81
  <link rel="modulepreload" crossorigin href="/assets/vendor-zustand-BAGL70zf.js">
82
- <link rel="modulepreload" crossorigin href="/assets/vendor-zod-DVWEh-IS.js">
82
+ <link rel="modulepreload" crossorigin href="/assets/vendor-zod-BPAANqvH.js">
83
83
  <link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-BJ73u-bH.js">
84
- <link rel="modulepreload" crossorigin href="/assets/index-DDInLQDd.js">
85
- <link rel="stylesheet" crossorigin href="/assets/index-CHUT_bDS.css">
84
+ <link rel="modulepreload" crossorigin href="/assets/index-CRf2xk51.js">
85
+ <link rel="stylesheet" crossorigin href="/assets/index-B68h5S5B.css">
86
86
  </head>
87
87
  <body class="h-full bg-background text-foreground">
88
88
  <div id="root" class="h-full">
package/dist/mobile.html CHANGED
@@ -63,15 +63,15 @@
63
63
  })();
64
64
  </script>
65
65
 
66
- <script type="module" crossorigin src="/assets/mobile-DZV_sfX7.js"></script>
66
+ <script type="module" crossorigin src="/assets/mobile-BQmgHA57.js"></script>
67
67
  <link rel="modulepreload" crossorigin href="/assets/vendor-vite-runtime-DD1OZmLC.js">
68
68
  <link rel="modulepreload" crossorigin href="/assets/vendor-scheduler-7OC5HNn7.js">
69
69
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-BUCujlKS.js">
70
70
  <link rel="modulepreload" crossorigin href="/assets/vendor-zustand-BAGL70zf.js">
71
- <link rel="modulepreload" crossorigin href="/assets/vendor-zod-DVWEh-IS.js">
71
+ <link rel="modulepreload" crossorigin href="/assets/vendor-zod-BPAANqvH.js">
72
72
  <link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-BJ73u-bH.js">
73
- <link rel="modulepreload" crossorigin href="/assets/index-DDInLQDd.js">
74
- <link rel="stylesheet" crossorigin href="/assets/index-CHUT_bDS.css">
73
+ <link rel="modulepreload" crossorigin href="/assets/index-CRf2xk51.js">
74
+ <link rel="stylesheet" crossorigin href="/assets/index-B68h5S5B.css">
75
75
  </head>
76
76
  <body class="h-full bg-background text-foreground">
77
77
  <div id="root" class="h-full"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openchamber/web",
3
- "version": "1.22.1",
3
+ "version": "1.23.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./server/index.js",
@@ -14,7 +14,7 @@
14
14
  "scripts": {
15
15
  "dev": "bun run build:watch",
16
16
  "dev:server": "OPENCHAMBER_RELAY_HOST=${OPENCHAMBER_RELAY_HOST:-off} bun server/index.js --port ${OPENCHAMBER_PORT:-3001}",
17
- "dev:server:watch": "OPENCHAMBER_RELAY_HOST=${OPENCHAMBER_RELAY_HOST:-off} nodemon --watch server --ext js --exec \"bun server/index.js --port ${OPENCHAMBER_PORT:-3001}\"",
17
+ "dev:server:watch": "node ./scripts/dev-server-watch.mjs",
18
18
  "build": "vite build",
19
19
  "build:watch": "vite build --watch",
20
20
  "type-check": "tsc --noEmit",
@@ -25,7 +25,7 @@
25
25
  "dependencies": {
26
26
  "@clack/prompts": "^1.1.0",
27
27
  "@octokit/rest": "^22.0.1",
28
- "@opencode-ai/sdk": "1.18.28",
28
+ "@opencode-ai/sdk": "1.18.30",
29
29
  "@simplewebauthn/server": "13.3.1",
30
30
  "bun-pty": "^0.4.5",
31
31
  "compression": "^1.8.1",
@@ -77,7 +77,6 @@
77
77
  "eslint": "^9.33.0",
78
78
  "eslint-plugin-react-hooks": "^5.2.0",
79
79
  "eslint-plugin-react-refresh": "^0.5.0",
80
- "ghostty-web": "0.4.0",
81
80
  "globals": "^16.3.0",
82
81
  "next-themes": "^0.4.6",
83
82
  "nodemon": "^3.1.7",
package/server/index.d.ts CHANGED
@@ -11,12 +11,27 @@ export interface WebUiServerController {
11
11
  stop: (options?: { exitProcess?: boolean }) => Promise<void>;
12
12
  }
13
13
 
14
+ export interface DesktopUpdateInfo {
15
+ available: boolean;
16
+ currentVersion?: string;
17
+ version?: string | null;
18
+ body?: string | null;
19
+ date?: string | null;
20
+ }
21
+
22
+ export interface DesktopUpdater {
23
+ check: () => Promise<DesktopUpdateInfo>;
24
+ install: () => Promise<DesktopUpdateInfo>;
25
+ restart: () => Promise<void> | void;
26
+ }
27
+
14
28
  export interface StartWebUiServerOptions {
15
29
  port?: number;
16
30
  host?: string;
17
31
  attachSignals?: boolean;
18
32
  exitOnShutdown?: boolean;
19
33
  uiPassword?: string | null;
34
+ desktopUpdater?: DesktopUpdater;
20
35
  }
21
36
 
22
37
  export declare function startWebUiServer(
package/server/index.js CHANGED
@@ -94,6 +94,7 @@ import { createPermissionAutoAcceptRuntime } from './lib/permission-auto-accept/
94
94
  import { createMessageQueueRuntime } from './lib/message-queue/runtime.js';
95
95
  import { createGracefulShutdownRuntime } from './lib/opencode/shutdown-runtime.js';
96
96
  import { createProjectConfigRuntime } from './lib/projects/project-config.js';
97
+ import { migrateLegacyUserDirs } from './lib/data-dir-migration.js';
97
98
  import { createProjectContextRuntime } from './lib/project-context/runtime.js';
98
99
  import { createAgentMemoryRuntime } from './lib/agent-memory/runtime.js';
99
100
  import { createAgentMemoryActions } from './lib/agent-memory/actions.js';
@@ -117,6 +118,10 @@ import { createScheduledTaskService } from './lib/scheduled-tasks/service.js';
117
118
  import { createOpenChamberControlService } from './lib/openchamber-control/service.js';
118
119
  import { OpenChamberControlError } from './lib/openchamber-control/error.js';
119
120
  import webPush from 'web-push';
121
+ import { applyConnectAttemptTimeout } from './lib/network-defaults.js';
122
+
123
+ // Background CLI launches enter here in a fresh process, without CLI defaults.
124
+ applyConnectAttemptTimeout();
120
125
 
121
126
  const __filename = fileURLToPath(import.meta.url);
122
127
  const __dirname = path.dirname(__filename);
@@ -259,16 +264,27 @@ const normalizeManagedRemoteTunnelPresets = (...args) =>
259
264
  const normalizeManagedRemoteTunnelPresetTokens = (...args) =>
260
265
  settingsNormalizationRuntime.normalizeManagedRemoteTunnelPresetTokens(...args);
261
266
  const isUnsafeSkillRelativePath = (...args) => settingsNormalizationRuntime.isUnsafeSkillRelativePath(...args);
262
- const sanitizeTypographySizesPartial = (...args) =>
263
- settingsNormalizationRuntime.sanitizeTypographySizesPartial(...args);
264
267
  const normalizeStringArray = (...args) => settingsNormalizationRuntime.normalizeStringArray(...args);
265
268
  const sanitizeModelRefs = (...args) => settingsNormalizationRuntime.sanitizeModelRefs(...args);
266
269
  const sanitizeSkillCatalogs = (...args) => settingsNormalizationRuntime.sanitizeSkillCatalogs(...args);
267
270
  const sanitizeProjects = (...args) => settingsNormalizationRuntime.sanitizeProjects(...args);
268
271
 
269
- const OPENCHAMBER_USER_CONFIG_ROOT = path.join(os.homedir(), '.config', 'openchamber');
272
+ // Every OpenChamber-owned file and folder hangs off one root: the default
273
+ // `~/.config/openchamber`, or `OPENCHAMBER_DATA_DIR` when set. The user
274
+ // folders (`projects/`, `themes/`, `speech-models/`) are copied into a custom
275
+ // root once at startup (`migrateLegacyUserDirs`), because they used to ignore
276
+ // the variable.
277
+ const OPENCHAMBER_DEFAULT_CONFIG_ROOT = path.join(os.homedir(), '.config', 'openchamber');
278
+ const OPENCHAMBER_USER_CONFIG_ROOT = process.env.OPENCHAMBER_DATA_DIR
279
+ ? path.resolve(process.env.OPENCHAMBER_DATA_DIR)
280
+ : OPENCHAMBER_DEFAULT_CONFIG_ROOT;
270
281
  const OPENCHAMBER_USER_THEMES_DIR = path.join(OPENCHAMBER_USER_CONFIG_ROOT, 'themes');
271
282
  const OPENCHAMBER_PROJECTS_CONFIG_DIR = path.join(OPENCHAMBER_USER_CONFIG_ROOT, 'projects');
283
+ // OPENCHAMBER_CHATS_DIR relocates managed chat worktrees — needed when the
284
+ // OpenCode server runs as a separate user that cannot traverse $HOME.
285
+ const OPENCHAMBER_CHATS_DIR = process.env.OPENCHAMBER_CHATS_DIR && process.env.OPENCHAMBER_CHATS_DIR.trim()
286
+ ? path.resolve(process.env.OPENCHAMBER_CHATS_DIR.trim())
287
+ : path.join(OPENCHAMBER_USER_CONFIG_ROOT, 'chats');
272
288
 
273
289
  const MAX_THEME_JSON_BYTES = 512 * 1024;
274
290
 
@@ -300,9 +316,7 @@ const maybeCacheSessionInfoFromEvent = (...args) => notificationTemplateRuntime.
300
316
  const buildTemplateVariables = (...args) => notificationTemplateRuntime.buildTemplateVariables(...args);
301
317
  const getCachedZenModels = (...args) => notificationTemplateRuntime.getCachedZenModels(...args);
302
318
 
303
- const OPENCHAMBER_DATA_DIR = process.env.OPENCHAMBER_DATA_DIR
304
- ? path.resolve(process.env.OPENCHAMBER_DATA_DIR)
305
- : path.join(os.homedir(), '.config', 'openchamber');
319
+ const OPENCHAMBER_DATA_DIR = OPENCHAMBER_USER_CONFIG_ROOT;
306
320
  const SETTINGS_FILE_PATH = path.join(OPENCHAMBER_DATA_DIR, 'settings.json');
307
321
  const PUSH_SUBSCRIPTIONS_FILE_PATH = path.join(OPENCHAMBER_DATA_DIR, 'push-subscriptions.json');
308
322
  const APNS_TOKENS_FILE_PATH = path.join(OPENCHAMBER_DATA_DIR, 'apns-tokens.json');
@@ -340,7 +354,6 @@ const settingsHelpers = createSettingsHelpers({
340
354
  normalizeManagedRemoteTunnelHostname,
341
355
  normalizeManagedRemoteTunnelPresets,
342
356
  normalizeManagedRemoteTunnelPresetTokens,
343
- sanitizeTypographySizesPartial,
344
357
  normalizeStringArray,
345
358
  sanitizeModelRefs,
346
359
  sanitizeSkillCatalogs,
@@ -479,6 +492,17 @@ const getUpstreamStallTimeoutMs = () => (
479
492
  : DEFAULT_UPSTREAM_STALL_TIMEOUT_MS
480
493
  );
481
494
 
495
+ const movedUserDirs = await migrateLegacyUserDirs({
496
+ fsPromises,
497
+ path,
498
+ dataDir: OPENCHAMBER_USER_CONFIG_ROOT,
499
+ legacyRoot: OPENCHAMBER_DEFAULT_CONFIG_ROOT,
500
+ warn: (message) => console.warn(`[data-dir] ${message}`),
501
+ });
502
+ if (movedUserDirs.length > 0) {
503
+ console.log(`[data-dir] Copied ${movedUserDirs.join(', ')} into ${OPENCHAMBER_USER_CONFIG_ROOT}`);
504
+ }
505
+
482
506
  const projectConfigRuntime = createProjectConfigRuntime({
483
507
  fsPromises,
484
508
  path,
@@ -489,6 +513,7 @@ const projectContextRuntime = createProjectContextRuntime({
489
513
  fsPromises,
490
514
  path,
491
515
  projectsDirPath: OPENCHAMBER_PROJECTS_CONFIG_DIR,
516
+ resolveSharedPlansDir: (projectId) => projectConfigRuntime.resolveSharedPlansDir(projectId),
492
517
  });
493
518
 
494
519
  const agentMemoryRuntime = createAgentMemoryRuntime({
@@ -888,7 +913,13 @@ const messageQueueRuntime = createMessageQueueRuntime({
888
913
  buildOpenCodeUrl,
889
914
  getOpenCodeAuthHeaders,
890
915
  sessionKnowledgeRuntime,
891
- broadcastGlobalUiEvent,
916
+ // OpenCode's /global/event SSE proxy cannot carry OpenChamber-owned events.
917
+ // Use the shared control stream for SSE clients and the existing WS fan-out.
918
+ broadcastGlobalUiEvent: createGlobalUiEventBroadcaster({
919
+ sseClients: uiOpenChamberEventClients,
920
+ wsClients: uiNotificationWsClients,
921
+ writeSseEvent,
922
+ }),
892
923
  onPromptSent: (sessionId) => sessionRuntime.markUserMessageSent(sessionId),
893
924
  dataDir: OPENCHAMBER_DATA_DIR,
894
925
  });
@@ -1315,7 +1346,7 @@ const resolveMemoryProjectId = createMemoryProjectResolver({
1315
1346
  return sanitizeProjects(settings?.projects || []).map((project) => project.path);
1316
1347
  },
1317
1348
  resolvePrimaryWorktreeRoot,
1318
- managedProjectRoots: [path.join(OPENCHAMBER_USER_CONFIG_ROOT, 'chats')],
1349
+ managedProjectRoots: [...new Set([path.join(OPENCHAMBER_USER_CONFIG_ROOT, 'chats'), OPENCHAMBER_CHATS_DIR])],
1319
1350
  });
1320
1351
 
1321
1352
  /**
@@ -1637,6 +1668,12 @@ async function main(options = {}) {
1637
1668
  const getDesktopRuntimeConfig = typeof options.getDesktopRuntimeConfig === 'function'
1638
1669
  ? options.getDesktopRuntimeConfig
1639
1670
  : null;
1671
+ const desktopUpdater = options.desktopUpdater
1672
+ && typeof options.desktopUpdater.check === 'function'
1673
+ && typeof options.desktopUpdater.install === 'function'
1674
+ && typeof options.desktopUpdater.restart === 'function'
1675
+ ? options.desktopUpdater
1676
+ : null;
1640
1677
 
1641
1678
  console.log(`Starting OpenChamber on port ${port === 0 ? 'auto' : port}`);
1642
1679
 
@@ -1671,7 +1708,10 @@ async function main(options = {}) {
1671
1708
  res.setHeader('Access-Control-Allow-Origin', origin);
1672
1709
  res.setHeader('Access-Control-Allow-Credentials', 'true');
1673
1710
  res.setHeader('Access-Control-Allow-Methods', 'GET,POST,PUT,PATCH,DELETE,OPTIONS');
1674
- res.setHeader('Access-Control-Allow-Headers', 'Content-Type,Authorization,Accept,X-Requested-With,Cache-Control,X-OpenCode-Directory,X-OpenCode-Directory-Encoding,Ngrok-Skip-Browser-Warning');
1711
+ // The packaged desktop UI (openchamber-ui://) and the dev UI sit on a
1712
+ // different origin, so every custom request header must be listed here or
1713
+ // the browser refuses the request at preflight, before it reaches a route.
1714
+ res.setHeader('Access-Control-Allow-Headers', 'Content-Type,Authorization,Accept,X-Requested-With,Cache-Control,X-OpenCode-Directory,X-OpenCode-Directory-Encoding,Ngrok-Skip-Browser-Warning,X-OpenChamber-Surface');
1675
1715
  res.setHeader('Access-Control-Expose-Headers', 'x-next-cursor');
1676
1716
  res.setHeader('Vary', 'Origin');
1677
1717
  if (req.method === 'OPTIONS') {
@@ -1812,6 +1852,7 @@ async function main(options = {}) {
1812
1852
  getCachedZenModels,
1813
1853
  setAutoAcceptSession,
1814
1854
  agentToolRuntime,
1855
+ desktopUpdater,
1815
1856
  });
1816
1857
  uiAuthController = bootstrapResult.uiAuthController;
1817
1858
  realtimeProxyRuntime = attachRealtimeProxy({
@@ -1903,6 +1944,7 @@ async function main(options = {}) {
1903
1944
  createFsSearchRuntime: createFsSearchRuntimeFactory,
1904
1945
  openchamberDataDir: OPENCHAMBER_DATA_DIR,
1905
1946
  openchamberUserConfigRoot: OPENCHAMBER_USER_CONFIG_ROOT,
1947
+ managedChatsRoot: OPENCHAMBER_CHATS_DIR,
1906
1948
  normalizeDirectoryPath,
1907
1949
  resolveProjectDirectory,
1908
1950
  resolveOptionalProjectDirectory,
@@ -0,0 +1,82 @@
1
+ // Release notes for the update dialog.
2
+ //
3
+ // The repo publishes `changelog/index.json` on `main`: one object per release,
4
+ // newest first, with the app notes grouped as New / Improvements / Fixes /
5
+ // Misc. This module fetches it and renders the releases between the installed
6
+ // version (exclusive) and the offered one (inclusive) as the Markdown the
7
+ // dialog already understands: a `## [x.y.z] - YYYY-MM-DD` header per release,
8
+ // the release title in bold, the intro, then the groups.
9
+ //
10
+ // Any failure (network, 404, unexpected shape) yields null: the update is
11
+ // still offered, only without notes.
12
+
13
+ export const CHANGELOG_INDEX_URL = 'https://raw.githubusercontent.com/openchamber/openchamber/main/changelog/index.json';
14
+
15
+ const GROUPS = [
16
+ ['new', 'New'],
17
+ ['improvements', 'Improvements'],
18
+ ['fixes', 'Fixes'],
19
+ ['misc', 'Misc'],
20
+ ];
21
+
22
+ const VERSION_PATTERN = /^\d+\.\d+\.\d+$/;
23
+ const DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
24
+
25
+ // The file crosses a network boundary with no schema library on this side, so
26
+ // each field is coerced into its domain shape here; a release without a valid
27
+ // version and date is dropped.
28
+ const text = (value) => (value === null || value === undefined ? null : String(value).trim() || null);
29
+ const bulletList = (value) => (Array.isArray(value) ? value.map((item) => String(item)) : []);
30
+
31
+ const parseRelease = (entry) => {
32
+ if (entry === null || entry === undefined) return null;
33
+ const version = text(entry.version);
34
+ const date = text(entry.date);
35
+ if (!version || !VERSION_PATTERN.test(version) || !date || !DATE_PATTERN.test(date)) return null;
36
+ const app = entry.app ?? {};
37
+ return {
38
+ version,
39
+ date,
40
+ title: text(entry.title),
41
+ intro: text(entry.intro),
42
+ groups: GROUPS.map(([key, heading]) => ({ heading, bullets: bulletList(app[key]) })),
43
+ };
44
+ };
45
+
46
+ const renderRelease = (release) => {
47
+ const lines = [`## [${release.version}] - ${release.date}`, ''];
48
+ if (release.title) lines.push(`**${release.title}**`, '');
49
+ if (release.intro) lines.push(release.intro, '');
50
+ for (const { heading, bullets } of release.groups) {
51
+ if (bullets.length === 0) continue;
52
+ lines.push(`### ${heading}`, '', ...bullets.map((bullet) => `- ${bullet}`), '');
53
+ }
54
+ return lines.join('\n').trim();
55
+ };
56
+
57
+ /**
58
+ * Markdown for the releases in (fromVersion, toVersion], newest first, or
59
+ * null when the index holds none of them.
60
+ */
61
+ export function renderUpdateNotes(index, fromVersion, toVersion, compareVersions) {
62
+ if (!Array.isArray(index)) return null;
63
+ const relevant = index
64
+ .map(parseRelease)
65
+ .filter((release) => release !== null)
66
+ .filter((release) => compareVersions(release.version, fromVersion) > 0 && compareVersions(release.version, toVersion) <= 0)
67
+ .sort((a, b) => compareVersions(b.version, a.version));
68
+ if (relevant.length === 0) return null;
69
+ return relevant.map(renderRelease).join('\n\n');
70
+ }
71
+
72
+ /** Fetch the index and render the notes for one update; null on any failure. */
73
+ export async function fetchUpdateNotes(fromVersion, toVersion, compareVersions, options = {}) {
74
+ const fetchImpl = options.fetch ?? fetch;
75
+ try {
76
+ const response = await fetchImpl(CHANGELOG_INDEX_URL, { signal: AbortSignal.timeout(options.timeoutMs ?? 10_000) });
77
+ if (!response.ok) return null;
78
+ return renderUpdateNotes(await response.json(), fromVersion, toVersion, compareVersions);
79
+ } catch {
80
+ return null;
81
+ }
82
+ }
@@ -0,0 +1,59 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { fetchUpdateNotes, renderUpdateNotes } from './update-notes.js';
3
+
4
+ const compare = (a, b) => {
5
+ const pa = a.split('.').map(Number);
6
+ const pb = b.split('.').map(Number);
7
+ for (let i = 0; i < 3; i += 1) if (pa[i] !== pb[i]) return pa[i] - pb[i];
8
+ return 0;
9
+ };
10
+
11
+ const index = [
12
+ { version: '1.2.3', date: '2026-03-03', title: 'Comments everywhere', intro: 'A short intro.', app: { new: ['**Comments:** on code.'], improvements: [], fixes: ['Chat: no freeze.'], misc: [] }, vscode: null },
13
+ { version: '1.2.2', date: '2026-03-02', title: null, intro: null, app: { new: [], improvements: ['Faster.'], fixes: [], misc: [] }, vscode: null },
14
+ { version: '1.2.1', date: '2026-03-01', title: 'Old', intro: null, app: { new: ['Older.'], improvements: [], fixes: [], misc: [] }, vscode: null },
15
+ ];
16
+
17
+ describe('renderUpdateNotes', () => {
18
+ it('renders the releases after the installed version up to the offered one, newest first', () => {
19
+ expect(renderUpdateNotes(index, '1.2.1', '1.2.3', compare)).toBe(`## [1.2.3] - 2026-03-03
20
+
21
+ **Comments everywhere**
22
+
23
+ A short intro.
24
+
25
+ ### New
26
+
27
+ - **Comments:** on code.
28
+
29
+ ### Fixes
30
+
31
+ - Chat: no freeze.
32
+
33
+ ## [1.2.2] - 2026-03-02
34
+
35
+ ### Improvements
36
+
37
+ - Faster.`);
38
+ });
39
+
40
+ it('returns null when nothing lies in the range or the payload is not an index', () => {
41
+ expect(renderUpdateNotes(index, '1.2.3', '1.2.3', compare)).toBe(null);
42
+ expect(renderUpdateNotes({ entries: [] }, '1.0.0', '9.9.9', compare)).toBe(null);
43
+ expect(renderUpdateNotes([{ version: 'nope' }, { version: '1.2.2', date: '2026' }], '1.0.0', '9.9.9', compare)).toBe(null);
44
+ });
45
+ });
46
+
47
+ describe('fetchUpdateNotes', () => {
48
+ it('turns a failed request or a thrown fetch into null', async () => {
49
+ const notFound = async () => ({ ok: false });
50
+ expect(await fetchUpdateNotes('1.0.0', '2.0.0', compare, { fetch: notFound })).toBe(null);
51
+ const throwing = async () => { throw new Error('offline'); };
52
+ expect(await fetchUpdateNotes('1.0.0', '2.0.0', compare, { fetch: throwing })).toBe(null);
53
+ });
54
+
55
+ it('renders a successful response', async () => {
56
+ const ok = async () => ({ ok: true, json: async () => index });
57
+ expect(await fetchUpdateNotes('1.2.2', '1.2.3', compare, { fetch: ok })).toMatch(/^## \[1\.2\.3\] - 2026-03-03\n\n\*\*Comments everywhere\*\*/);
58
+ });
59
+ });
@@ -0,0 +1,40 @@
1
+ // One-time copy of the user-authored folders into a custom data directory.
2
+ //
3
+ // `OPENCHAMBER_DATA_DIR` is documented as "the OpenChamber data directory",
4
+ // but for a long time only the flat files (settings, auth, push tokens)
5
+ // followed it while `projects/`, `themes/`, and `speech-models/` stayed under
6
+ // `~/.config/openchamber`. Now every folder hangs off the data directory, so an
7
+ // instance that already ran with a custom directory finds those folders in
8
+ // the old place. This copies each one over once: only when the new location
9
+ // does not exist yet and the old one does. It copies rather than moves
10
+ // because a second instance on the same machine (a custom directory next to
11
+ // the default one) must not strip the default instance of its projects.
12
+
13
+ const USER_DIR_ENTRIES = Object.freeze(['projects', 'themes', 'speech-models']);
14
+
15
+ const exists = async (fsPromises, target) => fsPromises.access(target).then(() => true, () => false);
16
+
17
+ /**
18
+ * Copy the user folders from `legacyRoot` into `dataDir`. Returns the entries
19
+ * copied. A no-op when the two roots are the same directory. A folder whose
20
+ * copy fails is reported through `warn` and its partial copy removed; the
21
+ * server keeps starting, reading the (empty) new location.
22
+ */
23
+ export const migrateLegacyUserDirs = async ({ fsPromises, path, dataDir, legacyRoot, warn = () => {}, entries = USER_DIR_ENTRIES }) => {
24
+ if (path.resolve(dataDir) === path.resolve(legacyRoot)) return [];
25
+ const moved = [];
26
+ for (const entry of entries) {
27
+ const from = path.join(legacyRoot, entry);
28
+ const to = path.join(dataDir, entry);
29
+ if (await exists(fsPromises, to) || !(await exists(fsPromises, from))) continue;
30
+ try {
31
+ await fsPromises.mkdir(dataDir, { recursive: true });
32
+ await fsPromises.cp(from, to, { recursive: true, errorOnExist: true, force: false });
33
+ moved.push(entry);
34
+ } catch (error) {
35
+ await fsPromises.rm(to, { recursive: true, force: true }).catch(() => {});
36
+ warn(`Failed to copy ${from} to ${to}: ${error instanceof Error ? error.message : String(error)}`);
37
+ }
38
+ }
39
+ return moved;
40
+ };
@@ -0,0 +1,59 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import os from 'os';
3
+ import path from 'path';
4
+ import fsPromises from 'fs/promises';
5
+
6
+ import { migrateLegacyUserDirs } from './data-dir-migration.js';
7
+
8
+ const setup = async () => {
9
+ const root = await fsPromises.mkdtemp(path.join(os.tmpdir(), 'oc-data-dir-'));
10
+ const legacyRoot = path.join(root, 'legacy');
11
+ const dataDir = path.join(root, 'custom');
12
+ await fsPromises.mkdir(path.join(legacyRoot, 'projects'), { recursive: true });
13
+ await fsPromises.writeFile(path.join(legacyRoot, 'projects', 'p.json'), '{"a":1}');
14
+ await fsPromises.mkdir(path.join(legacyRoot, 'themes'), { recursive: true });
15
+ return { root, legacyRoot, dataDir, cleanup: () => fsPromises.rm(root, { recursive: true, force: true }) };
16
+ };
17
+
18
+ describe('migrateLegacyUserDirs', () => {
19
+ it('copies the user folders once into a custom data dir and leaves the originals', async () => {
20
+ const { legacyRoot, dataDir, cleanup } = await setup();
21
+ try {
22
+ const warnings = [];
23
+ const moved = await migrateLegacyUserDirs({ fsPromises, path, dataDir, legacyRoot, warn: (message) => warnings.push(message) });
24
+ expect(moved).toEqual(['projects', 'themes']);
25
+ expect(warnings).toEqual([]);
26
+ expect(await fsPromises.readFile(path.join(dataDir, 'projects', 'p.json'), 'utf8')).toBe('{"a":1}');
27
+ // The default instance keeps its own copy: a second instance must not strip it.
28
+ expect(await fsPromises.readFile(path.join(legacyRoot, 'projects', 'p.json'), 'utf8')).toBe('{"a":1}');
29
+ // A second start copies nothing more.
30
+ expect(await migrateLegacyUserDirs({ fsPromises, path, dataDir, legacyRoot })).toEqual([]);
31
+ } finally {
32
+ await cleanup();
33
+ }
34
+ });
35
+
36
+ it('never merges into a folder that already exists in the data dir', async () => {
37
+ const { legacyRoot, dataDir, cleanup } = await setup();
38
+ try {
39
+ await fsPromises.mkdir(path.join(dataDir, 'projects'), { recursive: true });
40
+ await fsPromises.writeFile(path.join(dataDir, 'projects', 'q.json'), '{}');
41
+ const moved = await migrateLegacyUserDirs({ fsPromises, path, dataDir, legacyRoot });
42
+ expect(moved).toEqual(['themes']);
43
+ expect(await fsPromises.readdir(path.join(dataDir, 'projects'))).toEqual(['q.json']);
44
+ expect(await fsPromises.readdir(path.join(legacyRoot, 'projects'))).toEqual(['p.json']);
45
+ } finally {
46
+ await cleanup();
47
+ }
48
+ });
49
+
50
+ it('is a no-op when the data dir is the default root', async () => {
51
+ const { legacyRoot, cleanup } = await setup();
52
+ try {
53
+ expect(await migrateLegacyUserDirs({ fsPromises, path, dataDir: legacyRoot, legacyRoot })).toEqual([]);
54
+ expect(await fsPromises.readdir(path.join(legacyRoot, 'projects'))).toEqual(['p.json']);
55
+ } finally {
56
+ await cleanup();
57
+ }
58
+ });
59
+ });
@@ -446,18 +446,18 @@ describe('message stream websocket runtime', () => {
446
446
  const socket = new FakeSocket();
447
447
  runtime.wsServer.emit('connection', socket, { url: '/api/global/event/ws' });
448
448
 
449
- await new Promise((resolve) => setTimeout(resolve, 35));
450
-
451
- const readyFrames = socket.sent.filter((frame) => frame.type === 'ready');
452
- const eventFrames = socket.sent.filter((frame) => frame.type === 'event' && frame.payload?.type === 'server.connected');
453
-
454
- expect(readyFrames.length).toBeGreaterThanOrEqual(2);
455
- expect(eventFrames.length).toBeGreaterThanOrEqual(2);
456
- expect(fetchCalls.slice(0, 2)).toEqual([null, 'evt-1']);
457
- expect(triggerHealthCheckCalls).toBe(0);
458
-
459
- socket.close();
460
- await runtime.close();
449
+ try {
450
+ // Wait for the reconnect event itself; a 35ms sleep raced the event
451
+ // loop when the workspace build and test workers ran together.
452
+ await expect.poll(() => socket.sent.filter((frame) => frame.type === 'ready').length).toBeGreaterThanOrEqual(2);
453
+ const eventFrames = socket.sent.filter((frame) => frame.type === 'event' && frame.payload?.type === 'server.connected');
454
+ expect(eventFrames.length).toBeGreaterThanOrEqual(2);
455
+ expect(fetchCalls.slice(0, 2)).toEqual([null, 'evt-1']);
456
+ expect(triggerHealthCheckCalls).toBe(0);
457
+ } finally {
458
+ socket.close();
459
+ await runtime.close();
460
+ }
461
461
  });
462
462
 
463
463
  it('keeps synthetic event processing on forwarded upstream events', async () => {
@@ -14,6 +14,8 @@ Own filesystem API behavior for the web server runtime, including workspace-boun
14
14
  - `POST /api/fs/mkdir`
15
15
  - `GET /api/fs/read`
16
16
  - `GET /api/fs/raw`
17
+ - `GET /api/fs/stat`
18
+ - `GET /api/fs/directory-stat`
17
19
  - `GET /api/fs/serve/:path(*)`
18
20
  - `POST /api/fs/write`
19
21
  - `POST /api/fs/upload`
@@ -40,7 +42,10 @@ Own filesystem API behavior for the web server runtime, including workspace-boun
40
42
 
41
43
  ## Notes for contributors
42
44
  - Keep filesystem policy (workspace root checks, error mapping, exec timeout behavior) inside this module, not in the composition root.
45
+ - Workspace checks accept, besides the active workspace and its worktrees, the **managed roots**: the OpenChamber config root and the managed chats root (`managedChatsRoot` dependency; `OPENCHAMBER_CHATS_DIR` upstream, default `<config root>/chats`). Chat worktrees may legitimately live outside every project workspace.
46
+ - `GET /api/fs/home` answers `{ home, chatsRoot }`. `chatsRoot` is the server-resolved managed chats root; clients must use it instead of joining `home` + the well-known segment (a relocated root does not contain that segment).
43
47
  - Filesystem `EPERM`/`EACCES` failures use the stable `reason: "os-permission"` response marker. Policy denials such as workspace-boundary or missing-grant failures must not use that marker because a native folder picker cannot remediate them.
48
+ - `GET /api/fs/directory-stat?path=...` uses one `stat` without listing contents or resolving project topology. It follows the same authenticated directory-discovery path policy as `/api/fs/list`, including targets outside the active workspace. A directory returns `{ isDirectory: true }`; `ENOENT` returns `not-found`, and a file or `ENOTDIR` returns `not-directory`. Permission and other failures remain distinct from a missing path. VS Code explicitly returns 501, so the shared client treats its probe as unknown.
44
49
  - Read-only routes authorize the requested path against the workspace before resolving symlinks. A symlink reached through the workspace may therefore target a file outside it, while a directly requested outside path still requires an exact-path grant. Write routes keep canonical-target boundary checks.
45
50
  - If adding new `/api/fs/*` endpoints, add them in `routes.js` and extend this document.
46
51
  - `GET /api/fs/list` may resolve symlinks with `realpath` to read directory contents, but the response `path` and each entry `path` must stay in the caller's requested path space (`path.join(requestedPath, name)`). Returning real paths breaks file-tree expansion for directories reached through workspace symlinks.