@openchamber/web 2.0.4 → 2.1.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 (264) hide show
  1. package/dist/assets/{CodeMirrorCommentWidgets-C_zL-eri.js → CodeMirrorCommentWidgets-qlshRzAf.js} +1 -1
  2. package/dist/assets/{DiffView-BeN2_YYF.js → DiffView-BI_YgdKl.js} +3 -3
  3. package/dist/assets/FilesView-B_NJFLBH.js +17 -0
  4. package/dist/assets/{GitView-DLDazOo1.js → GitView-BWKg6TNS.js} +4 -4
  5. package/dist/assets/{GuestAttachDialog-C0xe_Lyy.js → GuestAttachDialog-DO4x4vIR.js} +1 -1
  6. package/dist/assets/{GuestSurfacePane-BdaurnDr.js → GuestSurfacePane-4PY11vEP.js} +1 -1
  7. package/dist/assets/JsonTreeView-u4yx65zn.js +1 -0
  8. package/dist/assets/{LinearIssuesView-BryoAHow.js → LinearIssuesView-C4gGBhU8.js} +1 -1
  9. package/dist/assets/{MarkdownImageGallery-DfuEoaGq.js → MarkdownImageGallery-fqVRCTdC.js} +1 -1
  10. package/dist/assets/MarkdownRendererImpl-Cfb5fTnq.js +39 -0
  11. package/dist/assets/OnboardingScreen-CiTV2_OT.js +1 -0
  12. package/dist/assets/PatchDiff-BrjhzXDM.js +1 -0
  13. package/dist/assets/{PierreDiffViewer-BC950e3F.js → PierreDiffViewer-CVx2e1cx.js} +5 -5
  14. package/dist/assets/{PlanView-B7Xgihqk.js → PlanView-DP9DOnI-.js} +4 -4
  15. package/dist/assets/{PluginPane-2C71F8uF.js → PluginPane-rZvoMQSi.js} +3 -3
  16. package/dist/assets/SettingsView-Dp9jubRs.js +30 -0
  17. package/dist/assets/SettingsWindow-Dst0yiV7.js +1 -0
  18. package/dist/assets/{SubmoduleDiffSummary-BSA9gnIO.js → SubmoduleDiffSummary-CixkM4fI.js} +1 -1
  19. package/dist/assets/{ToolOutputDialog-DprkVKcj.js → ToolOutputDialog-f0cS2DIf.js} +6 -6
  20. package/dist/assets/ToolPartDiffPreview-CFFIAFFY.js +8 -0
  21. package/dist/assets/{VirtualizedFileDiff-Kp8hKJdT.js → VirtualizedFileDiff-B-U_aQwV.js} +4 -4
  22. package/dist/assets/{WalkthroughView-DGnTzqIU.js → WalkthroughView-C1uB3Pl3.js} +2 -2
  23. package/dist/assets/{appThemeRegistry-BdEHBA4s.js → appThemeRegistry-DU-UKEHq.js} +1 -1
  24. package/dist/assets/{commitAndPush-LwtVa2Oc.js → commitAndPush-CtWGqrtW.js} +1 -1
  25. package/dist/assets/{computeVirtualFileMetrics-6V1xNpO9.js → computeVirtualFileMetrics-BmhViPMt.js} +1 -1
  26. package/dist/assets/de-D4hpTCNY.js +10 -0
  27. package/dist/assets/es-Bw9m3H62.js +16 -0
  28. package/dist/assets/fileTreeStatus-CvPnAWSi.js +1 -0
  29. package/dist/assets/fr-Bhll42P0.js +14 -0
  30. package/dist/assets/index-Btd2mmYT.js +42 -0
  31. package/dist/assets/index-C-7hQnEc.css +1 -0
  32. package/dist/assets/{index-CmNPYddV.js → index-DwtCnbiK.js} +1 -1
  33. package/dist/assets/{isDiffPlainText-1bXcWCrw.js → isDiffPlainText-CPDhzF1K.js} +1 -1
  34. package/dist/assets/{isFilePlainText-CBAppvy1.js → isFilePlainText-n8k0lMTZ.js} +1 -1
  35. package/dist/assets/ja-CsHoT43d.js +16 -0
  36. package/dist/assets/ko-BBNdtFa4.js +16 -0
  37. package/dist/assets/{main-CzjTMTfW.js → main-D6rlXjug.js} +2 -2
  38. package/dist/assets/main-kYkr_urz.js +1000 -0
  39. package/dist/assets/markdownCore-CHm8ycaW.js +7 -0
  40. package/dist/assets/{miniChat-CP68IL8Q.js → miniChat-2JY8K3Qw.js} +2 -2
  41. package/dist/assets/mobile-CviaXnnU.js +2 -0
  42. package/dist/assets/nl-DszyktfH.js +16 -0
  43. package/dist/assets/openSessionFromRoute-BIlcJIf3.js +1 -0
  44. package/dist/assets/{web-components-ngpHPEDU.js → parseDiffFromFile-DeZzEah8.js} +5 -5
  45. package/dist/assets/{patchFileDiff-pqRSHLHI.js → patchFileDiff-BnEHIdM2.js} +2 -2
  46. package/dist/assets/pl-Bk9_mUXc.js +16 -0
  47. package/dist/assets/pt-BR-BIXmm3Gw.js +16 -0
  48. package/dist/assets/{renderElectronMiniChatApp-DKIilR7N.js → renderElectronMiniChatApp-DvUphkjj.js} +2 -2
  49. package/dist/assets/renderMobileApp-Cdc49X8Y.js +25 -0
  50. package/dist/assets/runtimeEndpointReset-Cu6RUve4.js +56 -0
  51. package/dist/assets/shikiHighlight-CcVzlYit.js +1 -0
  52. package/dist/assets/space-apply-CgJ5JYPK.js +1 -0
  53. package/dist/assets/space-close-C1tL-_0t.js +1 -0
  54. package/dist/assets/{textMateThemeFromAppTheme-BSUFChBY.js → textMateThemeFromAppTheme-CAOCeVjl.js} +1 -1
  55. package/dist/assets/tr-C_13w7CX.js +7 -0
  56. package/dist/assets/uk-BZTsG-q_.js +16 -0
  57. package/dist/assets/{useAppFontEffects-Dsl_sLrj.js → useAppFontEffects-CeMgbeVa.js} +185 -177
  58. package/dist/assets/{useInlineCommentController-d5vntsQ_.js → useInlineCommentController-U97JJifS.js} +2 -2
  59. package/dist/assets/useRootScrollLock-DMBY2aTT.js +2 -0
  60. package/dist/assets/{vendor-base-ui-DnNniUWp.js → vendor-base-ui-DWgyZK2k.js} +1 -1
  61. package/dist/assets/vendor-codemirror-autocomplete-DetzHhtC.js +1 -0
  62. package/dist/assets/{vendor-codemirror-commands-B7H_j0iU.js → vendor-codemirror-commands-ConqfjLn.js} +1 -1
  63. package/dist/assets/{vendor-codemirror-lang-angular-DEPs2M5t.js → vendor-codemirror-lang-angular-Dbpx8qe-.js} +1 -1
  64. package/dist/assets/{vendor-codemirror-lang-cpp-DhkseaMo.js → vendor-codemirror-lang-cpp-TRtQWrpl.js} +1 -1
  65. package/dist/assets/{vendor-codemirror-lang-css-O0cZX78y.js → vendor-codemirror-lang-css-DY4CGDG2.js} +1 -1
  66. package/dist/assets/{vendor-codemirror-lang-go-fMdQYcON.js → vendor-codemirror-lang-go-CLKXh6B8.js} +1 -1
  67. package/dist/assets/{vendor-codemirror-lang-html-CfgK872x.js → vendor-codemirror-lang-html-CQnNjmg9.js} +1 -1
  68. package/dist/assets/{vendor-codemirror-lang-java-CQj4S3zl.js → vendor-codemirror-lang-java-CokZKqls.js} +1 -1
  69. package/dist/assets/{vendor-codemirror-lang-javascript-Cc2ZYbgX.js → vendor-codemirror-lang-javascript-Kgp6fZRE.js} +1 -1
  70. package/dist/assets/{vendor-codemirror-lang-jinja-BmZZv8g-.js → vendor-codemirror-lang-jinja-DZchyrN1.js} +1 -1
  71. package/dist/assets/{vendor-codemirror-lang-json-CMBS2tG9.js → vendor-codemirror-lang-json-CkdBRvqj.js} +1 -1
  72. package/dist/assets/{vendor-codemirror-lang-less-C6Eo8hVS.js → vendor-codemirror-lang-less-_k-GKz0A.js} +1 -1
  73. package/dist/assets/{vendor-codemirror-lang-liquid-DSTR47-H.js → vendor-codemirror-lang-liquid-DuHUMKoh.js} +1 -1
  74. package/dist/assets/{vendor-codemirror-lang-markdown-BPGOH9ye.js → vendor-codemirror-lang-markdown-CdG1RXm1.js} +1 -1
  75. package/dist/assets/{vendor-codemirror-lang-php-DD9udfPH.js → vendor-codemirror-lang-php-Ca15KQSA.js} +1 -1
  76. package/dist/assets/{vendor-codemirror-lang-python-HahnQaAS.js → vendor-codemirror-lang-python-B4MRHRva.js} +1 -1
  77. package/dist/assets/{vendor-codemirror-lang-rust-nLTovbjv.js → vendor-codemirror-lang-rust-8fLJdxQA.js} +1 -1
  78. package/dist/assets/{vendor-codemirror-lang-sass-pL2Yc72v.js → vendor-codemirror-lang-sass-CASr_yQ1.js} +1 -1
  79. package/dist/assets/{vendor-codemirror-lang-sql-BVBnan19.js → vendor-codemirror-lang-sql-Dc4ER-re.js} +1 -1
  80. package/dist/assets/{vendor-codemirror-lang-vue-BqGzJVm1.js → vendor-codemirror-lang-vue-fu2BqdK2.js} +1 -1
  81. package/dist/assets/{vendor-codemirror-lang-wast-B0_m5DqU.js → vendor-codemirror-lang-wast-BkCOgSpV.js} +1 -1
  82. package/dist/assets/{vendor-codemirror-lang-xml-Dj3voadT.js → vendor-codemirror-lang-xml-7e-kPepH.js} +1 -1
  83. package/dist/assets/{vendor-codemirror-lang-yaml-yu-9Z5u7.js → vendor-codemirror-lang-yaml-Cq3p_9DI.js} +1 -1
  84. package/dist/assets/vendor-codemirror-language-CZcLdzDM.js +3 -0
  85. package/dist/assets/{vendor-codemirror-language-data-B1EetJur.js → vendor-codemirror-language-data-B8HKnqZy.js} +2 -2
  86. package/dist/assets/vendor-codemirror-search-BZNojiZO.js +2 -0
  87. package/dist/assets/{vendor-codemirror-state-C9awkmn-.js → vendor-codemirror-state--21VQleR.js} +1 -1
  88. package/dist/assets/vendor-codemirror-view-8PpN-8l4.js +4 -0
  89. package/dist/assets/vendor-opencode-client-Byb4ZSqI.js +12 -0
  90. package/dist/assets/vendor-remend-DcBOpbSu.js +24 -0
  91. package/dist/assets/{vendor-replit-codemirror-vim-B2DJlAhT.js → vendor-replit-codemirror-vim-EX7OnecQ.js} +1 -1
  92. package/dist/assets/zh-CN-C62wm2Tg.js +16 -0
  93. package/dist/assets/zh-TW-BgGTiQA6.js +16 -0
  94. package/dist/index.html +4 -4
  95. package/dist/mini-chat.html +4 -4
  96. package/dist/mobile.html +4 -4
  97. package/package.json +4 -4
  98. package/server/index.js +58 -1
  99. package/server/lib/browser-control/DOCUMENTATION.md +8 -1
  100. package/server/lib/dev-tunnel/DOCUMENTATION.md +6 -0
  101. package/server/lib/dev-tunnel/runtime.js +94 -38
  102. package/server/lib/dev-tunnel/tunnel.test.js +16 -2
  103. package/server/lib/dictation/DOCUMENTATION.md +23 -10
  104. package/server/lib/dictation/audio.js +28 -0
  105. package/server/lib/dictation/local/sherpa-recognizer.js +33 -7
  106. package/server/lib/dictation/local/sherpa-recognizer.test.js +94 -0
  107. package/server/lib/dictation/local/worker-client.js +28 -10
  108. package/server/lib/dictation/local/worker-process.js +25 -1
  109. package/server/lib/dictation/stream-manager.js +160 -53
  110. package/server/lib/dictation/stream-manager.test.js +108 -7
  111. package/server/lib/enterprise-mode.d.ts +2 -0
  112. package/server/lib/enterprise-mode.js +84 -9
  113. package/server/lib/enterprise-mode.test.js +115 -0
  114. package/server/lib/fs/DOCUMENTATION.md +3 -2
  115. package/server/lib/fs/routes.js +28 -1
  116. package/server/lib/fs/routes.test.js +31 -5
  117. package/server/lib/git/DOCUMENTATION.md +1 -1
  118. package/server/lib/git/service.js +61 -2
  119. package/server/lib/git/service.test.js +141 -0
  120. package/server/lib/github/DOCUMENTATION.md +18 -0
  121. package/server/lib/github/checks-summary.js +76 -0
  122. package/server/lib/github/pr-summaries.js +282 -0
  123. package/server/lib/github/pr-summaries.test.js +209 -0
  124. package/server/lib/github/routes.js +42 -77
  125. package/server/lib/github/routes.test.js +77 -0
  126. package/server/lib/inherited-env.js +51 -0
  127. package/server/lib/inherited-env.test.js +59 -0
  128. package/server/lib/message-search/DOCUMENTATION.md +83 -0
  129. package/server/lib/message-search/indexer.js +336 -0
  130. package/server/lib/message-search/indexer.test.js +341 -0
  131. package/server/lib/message-search/routes.js +92 -0
  132. package/server/lib/message-search/runtime.js +234 -0
  133. package/server/lib/message-search/runtime.test.js +108 -0
  134. package/server/lib/message-search/sqlite.js +74 -0
  135. package/server/lib/message-search/store.js +289 -0
  136. package/server/lib/openchamber-control/DOCUMENTATION.md +6 -1
  137. package/server/lib/openchamber-control/actions.js +1 -1
  138. package/server/lib/openchamber-control/service.js +21 -2
  139. package/server/lib/openchamber-control/service.test.js +50 -0
  140. package/server/lib/openchamber-sessions/routes.js +15 -0
  141. package/server/lib/openchamber-sessions/routes.test.js +31 -0
  142. package/server/lib/opencode/DOCUMENTATION.md +43 -38
  143. package/server/lib/opencode/auth.d.ts +24 -0
  144. package/server/lib/opencode/auth.js +130 -66
  145. package/server/lib/opencode/auth.test.js +114 -70
  146. package/server/lib/opencode/compatibility.js +4 -3
  147. package/server/lib/opencode/compatibility.test.js +10 -10
  148. package/server/lib/opencode/feature-routes-runtime.js +3 -0
  149. package/server/lib/opencode/lifecycle.js +21 -12
  150. package/server/lib/opencode/lifecycle.test.js +38 -5
  151. package/server/lib/opencode/provider-source-route.test.js +55 -2
  152. package/server/lib/opencode/routes.js +17 -4
  153. package/server/lib/opencode/settings-helpers.js +6 -0
  154. package/server/lib/opencode/settings-helpers.test.js +1 -1
  155. package/server/lib/opencode/settings-registry.json +16 -0
  156. package/server/lib/opencode/settings-runtime.js +9 -0
  157. package/server/lib/opencode/shutdown-runtime.js +2 -0
  158. package/server/lib/opencode/v1-migration-topup.js +13 -3
  159. package/server/lib/opencode/v2-install.test.js +13 -13
  160. package/server/lib/quota/DOCUMENTATION.md +11 -5
  161. package/server/lib/quota/providers/claude/auth.js +19 -6
  162. package/server/lib/quota/providers/claude/auth.test.js +22 -9
  163. package/server/lib/quota/providers/claude/index.js +3 -3
  164. package/server/lib/quota/providers/claude/index.test.js +3 -2
  165. package/server/lib/quota/providers/cline-pass.js +4 -4
  166. package/server/lib/quota/providers/codex.js +3 -4
  167. package/server/lib/quota/providers/codex.test.js +1 -1
  168. package/server/lib/quota/providers/copilot.js +4 -5
  169. package/server/lib/quota/providers/copilot.test.js +1 -1
  170. package/server/lib/quota/providers/deepseek.js +3 -4
  171. package/server/lib/quota/providers/deepseek.test.js +1 -1
  172. package/server/lib/quota/providers/google/auth.js +1 -3
  173. package/server/lib/quota/providers/google/index.js +3 -2
  174. package/server/lib/quota/providers/hyper.js +4 -4
  175. package/server/lib/quota/providers/index.js +9 -2
  176. package/server/lib/quota/providers/index.test.js +5 -3
  177. package/server/lib/quota/providers/kimi.js +16 -11
  178. package/server/lib/quota/providers/kimi.test.js +81 -38
  179. package/server/lib/quota/providers/minimax-shared.js +3 -4
  180. package/server/lib/quota/providers/nanogpt.js +3 -4
  181. package/server/lib/quota/providers/neuralwatt.js +3 -4
  182. package/server/lib/quota/providers/neuralwatt.test.js +1 -1
  183. package/server/lib/quota/providers/openai.js +2 -8
  184. package/server/lib/quota/providers/opencode-go.js +5 -5
  185. package/server/lib/quota/providers/opencode-go.test.js +1 -1
  186. package/server/lib/quota/providers/openrouter.js +30 -6
  187. package/server/lib/quota/providers/openrouter.test.js +122 -1
  188. package/server/lib/quota/providers/wafer.js +3 -4
  189. package/server/lib/quota/providers/xai.js +12 -12
  190. package/server/lib/quota/providers/zai.js +3 -4
  191. package/server/lib/quota/providers/zai.test.js +1 -1
  192. package/server/lib/quota/providers/zhipuai-coding-plan.js +5 -6
  193. package/server/lib/quota/providers/zhipuai-coding-plan.test.js +1 -1
  194. package/server/lib/quota/routes.js +1 -1
  195. package/server/lib/routing/DOCUMENTATION.md +4 -0
  196. package/server/lib/routing/runtime.js +45 -4
  197. package/server/lib/routing/runtime.test.js +35 -6
  198. package/server/lib/scheduled-tasks/DOCUMENTATION.md +27 -0
  199. package/server/lib/scheduled-tasks/chats-scope.js +50 -0
  200. package/server/lib/scheduled-tasks/runtime.js +57 -23
  201. package/server/lib/scheduled-tasks/runtime.test.js +103 -1
  202. package/server/lib/scheduled-tasks/service.js +37 -29
  203. package/server/lib/scheduled-tasks/service.test.js +39 -0
  204. package/server/lib/spaces/DOCUMENTATION.md +54 -9
  205. package/server/lib/spaces/host.js +24 -3
  206. package/server/lib/spaces/journey.js +111 -11
  207. package/server/lib/spaces/journey.test.js +189 -8
  208. package/server/lib/spaces/places/docker-disk.js +151 -0
  209. package/server/lib/spaces/places/docker-disk.test.js +167 -0
  210. package/server/lib/spaces/places/docker-tools.js +11 -1
  211. package/server/lib/spaces/places/docker.js +4 -2
  212. package/server/lib/spaces/places/fake-docker.js +36 -2
  213. package/server/lib/spaces/routes.js +21 -4
  214. package/server/lib/spaces/routes.test.js +6 -2
  215. package/server/lib/spaces/space-archive.js +275 -0
  216. package/server/lib/spaces/space-archive.test.js +194 -0
  217. package/server/lib/spaces/space-opencode.js +139 -6
  218. package/server/lib/spaces/space-opencode.test.js +82 -1
  219. package/server/lib/spaces/space-records.js +3 -0
  220. package/server/lib/spaces/space-setup.js +10 -5
  221. package/server/lib/spaces/space-setup.test.js +8 -2
  222. package/server/lib/terminal/DOCUMENTATION.md +1 -0
  223. package/server/lib/terminal/runtime.js +6 -1
  224. package/server/lib/terminal/runtime.test.js +19 -0
  225. package/server/lib/tts/routes.js +2 -2
  226. package/server/lib/tts/service.js +8 -8
  227. package/dist/assets/FilesView-CN34wm_N.js +0 -17
  228. package/dist/assets/JsonTreeView-B1Xq-k2t.js +0 -1
  229. package/dist/assets/MarkdownRendererImpl-B_ZcWOvX.js +0 -12
  230. package/dist/assets/OnboardingScreen-C22bGmnP.js +0 -1
  231. package/dist/assets/PatchDiff-0xd6UeFB.js +0 -1
  232. package/dist/assets/SettingsView-m_zoFiaT.js +0 -30
  233. package/dist/assets/SettingsWindow-CofS020b.js +0 -1
  234. package/dist/assets/ToolPartDiffPreview-Dq0go_fX.js +0 -8
  235. package/dist/assets/de-DlgBHUAI.js +0 -10
  236. package/dist/assets/es-BC8G41U8.js +0 -16
  237. package/dist/assets/fr-I0z3vVjy.js +0 -14
  238. package/dist/assets/index-CgR5rJq_.js +0 -41
  239. package/dist/assets/index-adyy_sEk.css +0 -1
  240. package/dist/assets/ja-BIElEsY8.js +0 -16
  241. package/dist/assets/ko-DRnnHetA.js +0 -16
  242. package/dist/assets/main-DVX34beR.js +0 -886
  243. package/dist/assets/markdownCore-Cxbkn5NR.js +0 -7
  244. package/dist/assets/mobile-BrlBrNfZ.js +0 -2
  245. package/dist/assets/nl-DzUV-kwp.js +0 -16
  246. package/dist/assets/pl-Bb-cb7k7.js +0 -16
  247. package/dist/assets/pt-BR-CyIWrTcE.js +0 -16
  248. package/dist/assets/renderMobileApp-B0z6-x58.js +0 -25
  249. package/dist/assets/runtimeEndpointReset-uu1DBwLL.js +0 -52
  250. package/dist/assets/scheduledTasksApi-BuzWT445.js +0 -1
  251. package/dist/assets/shikiHighlight-BWGrY5YU.js +0 -1
  252. package/dist/assets/tr-DXEDSoYO.js +0 -7
  253. package/dist/assets/uk-C8hN--q_.js +0 -16
  254. package/dist/assets/useRootScrollLock-2rd5Y6gR.js +0 -2
  255. package/dist/assets/vendor-codemirror-autocomplete-DzPz9Wgq.js +0 -1
  256. package/dist/assets/vendor-codemirror-language-BgPj_McA.js +0 -3
  257. package/dist/assets/vendor-codemirror-search-BmS-GmcX.js +0 -2
  258. package/dist/assets/vendor-codemirror-view-CiLROUVV.js +0 -4
  259. package/dist/assets/vendor-opencode-client-DSZl7jSi.js +0 -12
  260. package/dist/assets/vendor-remend-BWYYytN3.js +0 -22
  261. package/dist/assets/zh-CN-CtzXdjMZ.js +0 -16
  262. package/dist/assets/zh-TW-Ds0CADSz.js +0 -16
  263. package/server/lib/opencode/credential-db.js +0 -144
  264. package/server/lib/opencode/credential-db.test.js +0 -104
@@ -0,0 +1,209 @@
1
+ import { describe, expect, test } from 'bun:test';
2
+
3
+ import {
4
+ MAX_SUMMARY_REFS,
5
+ fetchPrSummaries,
6
+ isGraphqlRateLimitError,
7
+ parseSummaryRefs,
8
+ summarizeCheckContexts,
9
+ } from './pr-summaries.js';
10
+
11
+ const checkRun = (name, status, conclusion, startedAt, overrides = {}) => ({
12
+ __typename: 'CheckRun',
13
+ databaseId: Date.parse(startedAt),
14
+ name,
15
+ status,
16
+ conclusion,
17
+ startedAt,
18
+ checkSuite: { app: { databaseId: 15368 } },
19
+ ...overrides,
20
+ });
21
+
22
+ const prNode = (number, overrides = {}) => ({
23
+ number,
24
+ title: `PR ${number}`,
25
+ state: 'OPEN',
26
+ isDraft: false,
27
+ mergeable: 'MERGEABLE',
28
+ mergeStateStatus: 'CLEAN',
29
+ headRefOid: `sha-${number}`,
30
+ commits: {
31
+ nodes: [{
32
+ commit: {
33
+ statusCheckRollup: {
34
+ contexts: {
35
+ nodes: [
36
+ checkRun('build', 'COMPLETED', 'SUCCESS', '2026-09-30T10:00:00Z'),
37
+ checkRun('tests', 'COMPLETED', 'SUCCESS', '2026-09-30T10:00:00Z'),
38
+ ],
39
+ },
40
+ },
41
+ },
42
+ }],
43
+ },
44
+ ...overrides,
45
+ });
46
+
47
+ // Answers every alias of a document from `nodes` (PRs) and `issues` (by
48
+ // number) and records how many refs each document carried.
49
+ const fakeOctokit = (nodes, { fail, issues = new Map() } = {}) => {
50
+ const documents = [];
51
+ return {
52
+ documents,
53
+ graphql: async (query, variables) => {
54
+ const indexes = Object.keys(variables).filter((name) => name.startsWith('p')).map((name) => name.slice(1));
55
+ documents.push(indexes.length);
56
+ const data = Object.fromEntries(indexes.map((index) => {
57
+ const number = variables[`p${index}`];
58
+ if (query.includes(`issue(number: $p${index})`)) {
59
+ const issue = issues.get(number) ?? null;
60
+ return [`a${index}`, issue ? { issue } : null];
61
+ }
62
+ const node = nodes.get(number) ?? null;
63
+ return [`a${index}`, node ? { pullRequest: node } : null];
64
+ }));
65
+ if (fail) {
66
+ throw fail(data);
67
+ }
68
+ return data;
69
+ },
70
+ };
71
+ };
72
+
73
+ describe('parseSummaryRefs', () => {
74
+ test('dedupes refs case-insensitively', () => {
75
+ expect(parseSummaryRefs([
76
+ { owner: 'Acme', repo: 'App', number: 7 },
77
+ { owner: 'acme', repo: 'app', number: 7 },
78
+ { owner: 'acme', repo: 'app', number: 8 },
79
+ ])).toEqual([
80
+ { owner: 'acme', repo: 'app', number: 7 },
81
+ { owner: 'acme', repo: 'app', number: 8 },
82
+ ]);
83
+ });
84
+
85
+ test('rejects malformed payloads', () => {
86
+ expect(parseSummaryRefs(null)).toBe(null);
87
+ expect(parseSummaryRefs([{ owner: 'acme', repo: 'app', number: 0 }])).toBe(null);
88
+ expect(parseSummaryRefs([{ owner: 'acme', repo: 'app', number: '7' }])).toBe(null);
89
+ expect(parseSummaryRefs([{ owner: 'ac me', repo: 'app', number: 7 }])).toBe(null);
90
+ expect(parseSummaryRefs([{ owner: 'acme', repo: 'app"){x}', number: 7 }])).toBe(null);
91
+ const tooMany = Array.from({ length: MAX_SUMMARY_REFS + 1 }, (_, index) => ({ owner: 'acme', repo: 'app', number: index + 1 }));
92
+ expect(parseSummaryRefs(tooMany)).toBe(null);
93
+ });
94
+ });
95
+
96
+ describe('summarizeCheckContexts', () => {
97
+ test('a re-run that passed hides the failed attempt it replaced', () => {
98
+ expect(summarizeCheckContexts([
99
+ checkRun('automation', 'COMPLETED', 'FAILURE', '2026-09-28T06:51:15Z'),
100
+ checkRun('automation', 'COMPLETED', 'SUCCESS', '2026-09-28T06:56:33Z'),
101
+ checkRun('label', 'COMPLETED', 'SUCCESS', '2026-09-28T06:51:14Z'),
102
+ ])).toEqual({ state: 'success', total: 2, success: 2, failure: 0, pending: 0, inProgress: 0, queued: 0 });
103
+ });
104
+
105
+ test('buckets check runs like the REST summary', () => {
106
+ expect(summarizeCheckContexts([
107
+ checkRun('a', 'COMPLETED', 'SUCCESS', '2026-09-30T10:00:00Z'),
108
+ checkRun('b', 'COMPLETED', 'SKIPPED', '2026-09-30T10:00:00Z'),
109
+ checkRun('c', 'COMPLETED', 'NEUTRAL', '2026-09-30T10:00:00Z'),
110
+ checkRun('d', 'IN_PROGRESS', null, '2026-09-30T10:01:00Z'),
111
+ checkRun('e', 'QUEUED', null, '2026-09-30T10:00:00Z'),
112
+ checkRun('f', 'COMPLETED', 'TIMED_OUT', '2026-09-30T10:00:00Z'),
113
+ { __typename: 'StatusContext', context: 'ci/legacy', state: 'FAILURE' },
114
+ ])).toEqual({
115
+ state: 'failure', total: 6, success: 3, failure: 1, pending: 2, inProgress: 1, queued: 1, startedAt: '2026-09-30T10:01:00Z',
116
+ });
117
+ });
118
+
119
+ test('falls back to commit statuses without check runs', () => {
120
+ expect(summarizeCheckContexts([
121
+ { __typename: 'StatusContext', context: 'ci/a', state: 'SUCCESS' },
122
+ { __typename: 'StatusContext', context: 'ci/b', state: 'PENDING' },
123
+ ])).toEqual({ state: 'pending', total: 2, success: 1, failure: 0, pending: 1, inProgress: 1, queued: 0 });
124
+ });
125
+
126
+ test('a commit without any checks is unknown', () => {
127
+ expect(summarizeCheckContexts([])).toEqual({ state: 'unknown', total: 0, success: 0, failure: 0, pending: 0, inProgress: 0, queued: 0 });
128
+ });
129
+ });
130
+
131
+ describe('fetchPrSummaries', () => {
132
+ test('packs 25 PRs per GraphQL document', async () => {
133
+ const refs = Array.from({ length: 26 }, (_, index) => ({ owner: 'acme', repo: 'app', number: index + 1 }));
134
+ const octokit = fakeOctokit(new Map(refs.map((ref) => [ref.number, prNode(ref.number)])));
135
+
136
+ const { summaries } = await fetchPrSummaries({ octokit, refs });
137
+
138
+ expect(octokit.documents).toEqual([25, 1]);
139
+ expect(summaries).toHaveLength(26);
140
+ });
141
+
142
+ test('maps a merged PR without checks or mergeability', async () => {
143
+ const octokit = fakeOctokit(new Map([[7, prNode(7, { state: 'MERGED', mergeable: 'UNKNOWN', mergeStateStatus: 'UNKNOWN' })]]));
144
+
145
+ const { summaries: [summary] } = await fetchPrSummaries({ octokit, refs: [{ owner: 'acme', repo: 'app', number: 7 }] });
146
+
147
+ expect(summary).toEqual({
148
+ owner: 'acme',
149
+ repo: 'app',
150
+ number: 7,
151
+ state: 'merged',
152
+ draft: false,
153
+ title: 'PR 7',
154
+ headSha: 'sha-7',
155
+ mergeable: null,
156
+ mergeableState: 'unknown',
157
+ checks: null,
158
+ });
159
+ });
160
+
161
+ test('keeps partial data when some PRs cannot be resolved', async () => {
162
+ const octokit = fakeOctokit(new Map([[7, prNode(7)]]), {
163
+ fail: (data) => Object.assign(new Error('Could not resolve to a PullRequest'), {
164
+ data,
165
+ errors: [{ type: 'NOT_FOUND', path: ['a1', 'pullRequest'] }],
166
+ }),
167
+ });
168
+
169
+ const { summaries } = await fetchPrSummaries({
170
+ octokit,
171
+ refs: [{ owner: 'acme', repo: 'app', number: 7 }, { owner: 'acme', repo: 'app', number: 8 }],
172
+ });
173
+
174
+ expect(summaries.map((summary) => summary.number)).toEqual([7]);
175
+ });
176
+
177
+ test('reads issues in the same documents as PRs', async () => {
178
+ const issue = (number, state, stateReason) => ({ number, title: `Issue ${number}`, state, stateReason });
179
+ const octokit = fakeOctokit(new Map([[7, prNode(7)]]), {
180
+ issues: new Map([
181
+ [11, issue(11, 'OPEN', null)],
182
+ [12, issue(12, 'CLOSED', 'COMPLETED')],
183
+ [13, issue(13, 'CLOSED', 'NOT_PLANNED')],
184
+ [14, issue(14, 'CLOSED', 'DUPLICATE')],
185
+ ]),
186
+ });
187
+ const ref = (number) => ({ owner: 'acme', repo: 'app', number });
188
+
189
+ const { summaries, issueSummaries } = await fetchPrSummaries({ octokit, refs: [ref(7)], issueRefs: [11, 12, 13, 14, 15].map(ref) });
190
+
191
+ expect(octokit.documents).toEqual([6]);
192
+ expect(summaries.map((summary) => summary.number)).toEqual([7]);
193
+ expect(issueSummaries.map((summary) => [summary.number, summary.state])).toEqual([
194
+ [11, 'open'], [12, 'completed'], [13, 'not_planned'], [14, 'not_planned'],
195
+ ]);
196
+ expect(issueSummaries[0].title).toBe('Issue 11');
197
+ });
198
+
199
+ test('a rate-limited document fails the call instead of reading as empty', async () => {
200
+ const limited = Object.assign(new Error('API rate limit exceeded'), {
201
+ data: {},
202
+ errors: [{ type: 'RATE_LIMITED' }],
203
+ });
204
+ const octokit = fakeOctokit(new Map([[7, prNode(7)]]), { fail: () => limited });
205
+
206
+ await expect(fetchPrSummaries({ octokit, refs: [{ owner: 'acme', repo: 'app', number: 7 }] })).rejects.toBe(limited);
207
+ expect(isGraphqlRateLimitError(limited)).toBe(true);
208
+ });
209
+ });
@@ -1,3 +1,5 @@
1
+ import { dedupeCheckRuns, summarizeCheckRuns, summarizeCombinedStatuses } from './checks-summary.js';
2
+
1
3
  const PR_STATUS_CACHE_TTL_MS = 90_000;
2
4
  const PR_STATUS_CACHE_MAX_ENTRIES = 200;
3
5
  // Upper bound for resolving a single PR status. resolveGitHubPrStatus makes many
@@ -25,83 +27,6 @@ function invalidatePrContextCache(directory, number) {
25
27
  }
26
28
  }
27
29
 
28
- // Aggregate check runs into the summary shape shared by pr/status and
29
- // pulls/context. Keeps `pending` as queued+in_progress+unconcluded for
30
- // existing consumers while exposing the split and the earliest start time so
31
- // the UI can show live "running for N minutes" state.
32
- // A re-run leaves the previous completed check run in the listForRef payload
33
- // alongside the new in-progress one. GitHub's UI shows only the latest run
34
- // per (app, name); mirror that so counts match what users see on github.com.
35
- function dedupeCheckRuns(checkRuns) {
36
- const byName = new Map();
37
- for (const run of checkRuns) {
38
- const key = `${run?.app?.id ?? run?.app?.slug ?? ''}::${run?.name ?? ''}`;
39
- const previous = byName.get(key);
40
- if (!previous) {
41
- byName.set(key, run);
42
- continue;
43
- }
44
- const previousStartedAt = Date.parse(previous?.started_at || '') || 0;
45
- const startedAt = Date.parse(run?.started_at || '') || 0;
46
- if (startedAt > previousStartedAt
47
- || (startedAt === previousStartedAt && (run?.id ?? 0) > (previous?.id ?? 0))) {
48
- byName.set(key, run);
49
- }
50
- }
51
- return Array.from(byName.values());
52
- }
53
-
54
- function summarizeCheckRuns(checkRuns) {
55
- const counts = { success: 0, failure: 0, pending: 0, inProgress: 0, queued: 0 };
56
- let startedAt = null;
57
- for (const run of checkRuns) {
58
- const status = run?.status;
59
- const conclusion = run?.conclusion;
60
- if (status === 'in_progress') {
61
- counts.pending += 1;
62
- counts.inProgress += 1;
63
- const runStartedAt = typeof run?.started_at === 'string' ? run.started_at : null;
64
- if (runStartedAt && (!startedAt || runStartedAt < startedAt)) {
65
- startedAt = runStartedAt;
66
- }
67
- continue;
68
- }
69
- if (status === 'queued') {
70
- counts.pending += 1;
71
- counts.queued += 1;
72
- continue;
73
- }
74
- if (!conclusion) {
75
- counts.pending += 1;
76
- continue;
77
- }
78
- if (conclusion === 'success' || conclusion === 'neutral' || conclusion === 'skipped') {
79
- counts.success += 1;
80
- } else {
81
- counts.failure += 1;
82
- }
83
- }
84
- const total = counts.success + counts.failure + counts.pending;
85
- const state = counts.failure > 0
86
- ? 'failure'
87
- : (counts.pending > 0 ? 'pending' : (total > 0 ? 'success' : 'unknown'));
88
- return { state, total, ...counts, ...(startedAt ? { startedAt } : {}) };
89
- }
90
-
91
- function summarizeCombinedStatuses(statuses) {
92
- const counts = { success: 0, failure: 0, pending: 0 };
93
- statuses.forEach((s) => {
94
- if (s.state === 'success') counts.success += 1;
95
- else if (s.state === 'failure' || s.state === 'error') counts.failure += 1;
96
- else if (s.state === 'pending') counts.pending += 1;
97
- });
98
- const total = counts.success + counts.failure + counts.pending;
99
- const state = counts.failure > 0
100
- ? 'failure'
101
- : (counts.pending > 0 ? 'pending' : (total > 0 ? 'success' : 'unknown'));
102
- return { state, total, ...counts, inProgress: counts.pending, queued: 0 };
103
- }
104
-
105
30
  function withTimeout(promise, timeoutMs, label) {
106
31
  let timer;
107
32
  const timeout = new Promise((_resolve, reject) => {
@@ -711,6 +636,46 @@ export function registerGitHubRoutes(app) {
711
636
  }
712
637
  });
713
638
 
639
+ // Batched live status for PRs and issues the client already knows by
640
+ // number. The sidebar polls this instead of re-resolving every branch.
641
+ app.post('/api/github/pr/summaries', async (req, res) => {
642
+ const { parseSummaryRefs, fetchPrSummaries, isGraphqlRateLimitError, MAX_SUMMARY_REFS } = await import('./pr-summaries.js');
643
+ const refs = parseSummaryRefs(req.body?.refs);
644
+ const issueRefs = parseSummaryRefs(req.body?.issueRefs ?? []);
645
+ if (!refs || !issueRefs || refs.length + issueRefs.length > MAX_SUMMARY_REFS) {
646
+ return res.status(400).json({ error: 'refs and issueRefs must be lists of { owner, repo, number }, at most 100 in total' });
647
+ }
648
+ try {
649
+ const { getOctokitOrNull } = await getGitHubLibraries();
650
+ const octokit = getOctokitOrNull();
651
+ if (!octokit) {
652
+ return res.json({ connected: false });
653
+ }
654
+ const { isGitHubRateLimited } = await import('./rate-limit.js');
655
+ if (isGitHubRateLimited()) {
656
+ return res.status(503).json({ error: 'GitHub rate limited' });
657
+ }
658
+ const fetchedAt = Date.now();
659
+ const { summaries, issueSummaries } = refs.length + issueRefs.length > 0
660
+ ? await fetchPrSummaries({ octokit, refs, issueRefs })
661
+ : { summaries: [], issueSummaries: [] };
662
+ return res.json({ connected: true, fetchedAt, summaries, issueSummaries });
663
+ } catch (error) {
664
+ if (error?.status === 401) {
665
+ const { clearGitHubAuth } = await getGitHubLibraries();
666
+ clearGitHubAuth();
667
+ return res.json({ connected: false });
668
+ }
669
+ const { isGitHubRateLimitError, noteGitHubRateLimit } = await import('./rate-limit.js');
670
+ if (isGraphqlRateLimitError(error) || isGitHubRateLimitError(error)) {
671
+ noteGitHubRateLimit(error);
672
+ return res.status(503).json({ error: 'GitHub rate limited' });
673
+ }
674
+ console.error('Failed to load GitHub PR summaries:', error);
675
+ return res.status(500).json({ error: error.message || 'Failed to load GitHub PR summaries' });
676
+ }
677
+ });
678
+
714
679
  app.post('/api/github/pr/create', async (req, res) => {
715
680
  try {
716
681
  const directory = typeof req.body?.directory === 'string' ? req.body.directory.trim() : '';
@@ -110,3 +110,80 @@ describe('GET /api/github/pulls/list free-text search', () => {
110
110
  expect((await search().expect(500)).body.error).toBe('GitHub search unavailable');
111
111
  });
112
112
  });
113
+
114
+ describe('POST /api/github/pr/summaries', () => {
115
+ let app;
116
+ const dataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'openchamber-github-summaries-'));
117
+
118
+ beforeAll(async () => {
119
+ process.env.OPENCHAMBER_DATA_DIR = dataDir;
120
+ const { setGitHubAuth, setGhCliDisabled } = await import('./auth.js');
121
+ setGhCliDisabled(true);
122
+ setGitHubAuth({ accessToken: 'fake-test-token', accountId: 'test' });
123
+ app = express();
124
+ app.use(express.json());
125
+ registerGitHubRoutes(app);
126
+ });
127
+
128
+ afterEach(() => {
129
+ vi.unstubAllGlobals();
130
+ vi.restoreAllMocks();
131
+ });
132
+
133
+ afterAll(() => {
134
+ if (previousDataDir === undefined) delete process.env.OPENCHAMBER_DATA_DIR;
135
+ else process.env.OPENCHAMBER_DATA_DIR = previousDataDir;
136
+ fs.rmSync(dataDir, { recursive: true, force: true });
137
+ });
138
+
139
+ const summaries = (refs) => request(app).post('/api/github/pr/summaries').send({ refs });
140
+
141
+ const serveGraphql = (body) => {
142
+ const fetch = vi.fn(async () => response(body));
143
+ vi.stubGlobal('fetch', fetch);
144
+ return fetch;
145
+ };
146
+
147
+ it('rejects malformed refs before asking GitHub', async () => {
148
+ const fetch = serveGraphql({ data: {} });
149
+
150
+ const res = await summaries([{ owner: 'example', repo: 'project', number: 'seven' }]);
151
+
152
+ expect(res.status).toBe(400);
153
+ expect(fetch).not.toHaveBeenCalled();
154
+ });
155
+
156
+ it('answers with the live state of each resolved PR', async () => {
157
+ serveGraphql({
158
+ data: {
159
+ a0: { pullRequest: { number: 7, title: 'Fix', state: 'MERGED', isDraft: false, mergeable: 'UNKNOWN', mergeStateStatus: 'UNKNOWN', headRefOid: 'abc', commits: { nodes: [] } } },
160
+ a1: null,
161
+ a2: { issue: { number: 3, title: 'Bug', state: 'CLOSED', stateReason: 'COMPLETED' } },
162
+ },
163
+ errors: [{ type: 'NOT_FOUND', path: ['a1'], message: 'Could not resolve to a Repository' }],
164
+ });
165
+
166
+ const res = await request(app).post('/api/github/pr/summaries').send({
167
+ refs: [{ owner: 'example', repo: 'project', number: 7 }, { owner: 'example', repo: 'gone', number: 8 }],
168
+ issueRefs: [{ owner: 'example', repo: 'project', number: 3 }],
169
+ });
170
+
171
+ expect(res.status).toBe(200);
172
+ expect(res.body.connected).toBe(true);
173
+ expect(res.body.summaries).toEqual([
174
+ expect.objectContaining({ owner: 'example', repo: 'project', number: 7, state: 'merged', checks: null }),
175
+ ]);
176
+ expect(res.body.issueSummaries).toEqual([
177
+ { owner: 'example', repo: 'project', number: 3, title: 'Bug', state: 'completed' },
178
+ ]);
179
+ });
180
+
181
+ // Last in the file: the rate-limit cooldown it records is process-global.
182
+ it('reports a GraphQL rate limit as a transient failure', async () => {
183
+ serveGraphql({ data: null, errors: [{ type: 'RATE_LIMITED', message: 'API rate limit exceeded' }] });
184
+
185
+ const res = await summaries([{ owner: 'example', repo: 'project', number: 7 }]);
186
+
187
+ expect(res.status).toBe(503);
188
+ });
189
+ });
@@ -29,6 +29,57 @@ export function stripAppImageArgv0Leak(env) {
29
29
  return env;
30
30
  }
31
31
 
32
+ /**
33
+ * Entries the AppImage launcher (electron-builder's AppRun) adds to list
34
+ * variables before starting the app, given the mount point `appDir`.
35
+ * `dropEmpty` marks lists where the launcher leaves an empty entry (a trailing
36
+ * `:`) when the user had not set the variable; PATH is always set, so its
37
+ * empty entries are the user's and are kept.
38
+ */
39
+ const APPIMAGE_LAUNCHER_ENTRIES = Object.freeze({
40
+ PATH: { entries: (appDir) => [appDir, `${appDir}/usr/sbin`], dropEmpty: false },
41
+ LD_LIBRARY_PATH: { entries: (appDir) => [`${appDir}/usr/lib`], dropEmpty: true },
42
+ GSETTINGS_SCHEMA_DIR: { entries: (appDir) => [`${appDir}/usr/share/glib-2.0/schemas`], dropEmpty: true },
43
+ XDG_DATA_DIRS: { entries: (appDir) => [`${appDir}/usr/share`, './share'], dropEmpty: true },
44
+ });
45
+
46
+ const withoutTrailingSlashes = (entry) => (entry.length > 1 ? entry.replace(/\/+$/, '') : entry);
47
+
48
+ /**
49
+ * Remove what the AppImage launcher added to `PATH`, `LD_LIBRARY_PATH`,
50
+ * `GSETTINGS_SCHEMA_DIR` and `XDG_DATA_DIRS` in a mutable child env object.
51
+ *
52
+ * Left in place, user tools load the app's bundled libraries and data, and an
53
+ * empty `LD_LIBRARY_PATH` entry makes the dynamic linker search the current
54
+ * directory (#4177). Runs only when `APPDIR` says we are inside an AppImage.
55
+ * The user's own non-empty entries are kept in order (empty ones are dropped
56
+ * from the lists marked `dropEmpty`), entries the app adds itself (the bundled
57
+ * OpenCode CLI directory) are kept, and a variable left with no entries is
58
+ * removed. `XDG_DATA_DIRS` keeps the system directories the launcher wraps
59
+ * around the user's value: they are the spec's defaults, not the app's files.
60
+ *
61
+ * @param {NodeJS.ProcessEnv | Record<string, string | undefined> | null | undefined} env
62
+ * @returns {typeof env}
63
+ */
64
+ export function stripAppImageLauncherEnv(env) {
65
+ const appDir = env?.APPDIR ? withoutTrailingSlashes(env.APPDIR) : '';
66
+ if (!appDir) return env;
67
+ for (const [name, launcher] of Object.entries(APPIMAGE_LAUNCHER_ENTRIES)) {
68
+ const value = env[name];
69
+ if (value === undefined) continue;
70
+ const added = new Set(launcher.entries(appDir));
71
+ const kept = value
72
+ .split(':')
73
+ .filter((entry) => !(launcher.dropEmpty && entry === '') && !added.has(withoutTrailingSlashes(entry)));
74
+ if (kept.length > 0) {
75
+ env[name] = kept.join(':');
76
+ } else {
77
+ delete env[name];
78
+ }
79
+ }
80
+ return env;
81
+ }
82
+
32
83
  /**
33
84
  * Clear AppImage `ARGV0` from this process.
34
85
  *
@@ -3,6 +3,7 @@ import {
3
3
  clearAppImageArgv0FromProcessEnv,
4
4
  resolvePosixPtyLaunch,
5
5
  stripAppImageArgv0Leak,
6
+ stripAppImageLauncherEnv,
6
7
  } from './inherited-env.js';
7
8
 
8
9
  describe('stripAppImageArgv0Leak', () => {
@@ -32,6 +33,64 @@ describe('stripAppImageArgv0Leak', () => {
32
33
  });
33
34
  });
34
35
 
36
+ describe('stripAppImageLauncherEnv', () => {
37
+ const APPDIR = '/tmp/.mount_OpenChAbC123';
38
+
39
+ it('removes what the launcher added when the user had none of the variables', () => {
40
+ // Values captured from the child environment of a packaged 2.0.4 AppImage on Debian 13.
41
+ const env = {
42
+ APPDIR,
43
+ LD_LIBRARY_PATH: `${APPDIR}/usr/lib:`,
44
+ GSETTINGS_SCHEMA_DIR: `${APPDIR}/usr/share/glib-2.0/schemas:`,
45
+ XDG_DATA_DIRS: `${APPDIR}/usr/share/:./share/:/usr/share/gnome:/usr/local/share/:/usr/share/::/usr/share/gnome/:/usr/local/share/:/usr/share/`,
46
+ PATH: `${APPDIR}/resources/opencode-cli:/usr/local/bin:/usr/bin:/bin:${APPDIR}:${APPDIR}/usr/sbin`,
47
+ };
48
+ expect(stripAppImageLauncherEnv(env)).toBe(env);
49
+ expect(env).toEqual({
50
+ APPDIR,
51
+ XDG_DATA_DIRS: '/usr/share/gnome:/usr/local/share/:/usr/share/:/usr/share/gnome/:/usr/local/share/:/usr/share/',
52
+ PATH: `${APPDIR}/resources/opencode-cli:/usr/local/bin:/usr/bin:/bin`,
53
+ });
54
+ });
55
+
56
+ it('keeps the user entries in order', () => {
57
+ const env = {
58
+ APPDIR: `${APPDIR}/`,
59
+ LD_LIBRARY_PATH: `${APPDIR}/usr/lib:/opt/cuda/lib64::/home/me/lib`,
60
+ GSETTINGS_SCHEMA_DIR: `${APPDIR}/usr/share/glib-2.0/schemas:/home/me/schemas`,
61
+ };
62
+ stripAppImageLauncherEnv(env);
63
+ expect(env.LD_LIBRARY_PATH).toBe('/opt/cuda/lib64:/home/me/lib');
64
+ expect(env.GSETTINGS_SCHEMA_DIR).toBe('/home/me/schemas');
65
+ });
66
+
67
+ it('keeps other directories inside the AppImage and paths that only share its prefix', () => {
68
+ const env = { APPDIR, LD_LIBRARY_PATH: `${APPDIR}-other/usr/lib:${APPDIR}/usr/lib:${APPDIR}/resources/lib` };
69
+ stripAppImageLauncherEnv(env);
70
+ expect(env.LD_LIBRARY_PATH).toBe(`${APPDIR}-other/usr/lib:${APPDIR}/resources/lib`);
71
+ });
72
+
73
+ it('keeps empty PATH entries, which the launcher never adds', () => {
74
+ const env = { APPDIR, PATH: `${APPDIR}:/usr/bin::` };
75
+ stripAppImageLauncherEnv(env);
76
+ expect(env.PATH).toBe('/usr/bin::');
77
+ });
78
+
79
+ it('leaves the environment alone outside an AppImage', () => {
80
+ const env = { LD_LIBRARY_PATH: '/opt/lib::', XDG_DATA_DIRS: './share/:/usr/share' };
81
+ stripAppImageLauncherEnv(env);
82
+ expect(env).toEqual({ LD_LIBRARY_PATH: '/opt/lib::', XDG_DATA_DIRS: './share/:/usr/share' });
83
+ });
84
+
85
+ it('tolerates missing variables and nullish env values', () => {
86
+ const env = { APPDIR };
87
+ stripAppImageLauncherEnv(env);
88
+ expect(env).toEqual({ APPDIR });
89
+ expect(stripAppImageLauncherEnv(null)).toBeNull();
90
+ expect(stripAppImageLauncherEnv(undefined)).toBeUndefined();
91
+ });
92
+ });
93
+
35
94
  describe('clearAppImageArgv0FromProcessEnv', () => {
36
95
  it('removes ARGV0 from process.env', () => {
37
96
  const previous = process.env.ARGV0;
@@ -0,0 +1,83 @@
1
+ # Message search
2
+
3
+ Full-text search over this server's conversations. OpenCode 2 searches session
4
+ titles only, so the server keeps its own index.
5
+
6
+ ## What is indexed
7
+
8
+ User messages and the text of settled agent replies, for root sessions. Tool
9
+ calls and their output, attached context records and subagent sessions stay
10
+ out (maintainer decision, 2026-10-01).
11
+
12
+ Agent reasoning is a second opt-in (`messageSearchReasoningEnabled`, off by
13
+ default: models that think at length can make the index several times
14
+ bigger). Reasoning is stored as its own row (`role = 'reasoning'`, row id
15
+ `<messageId>:reasoning`, `message_id` = the message), so it is filtered and
16
+ dropped without touching replies, and a hit still leads to its message. The
17
+ file records whether it holds reasoning (`meta.reasoning`): turning it on
18
+ clears every session's agent cursor so the next walk reads agent records
19
+ again; turning it off deletes the reasoning rows at once. The UI asks without
20
+ reasoning (`reasoning=0`) while the reader hides reasoning traces. On the maintainer's machine
21
+ that is ~3 MB of text in ~13 MB of index; tool output alone would be ~200 MB.
22
+
23
+ ## Opt-in
24
+
25
+ Search is off until `messageSearchEnabled` (instance scope, `settings.json`)
26
+ is turned on in Settings → Chat (maintainer decision, 2026-10-01: indexing
27
+ must cost nothing on weak hardware unless asked for). Off means no index file
28
+ is opened, no event is looked at, no backfill runs, the route answers 503, and
29
+ the UI shows no message search (no Cmd+P group, Cmd+F left alone).
30
+
31
+ The runtime reads the setting at startup; `persistSettings` calls
32
+ `setEnabled` when the key changes. Switching off stops the indexer (after the
33
+ session being read finishes), closes the file and keeps it. Switching on
34
+ opens it and walks the session list, which re-reads every session changed
35
+ while search was off and drops deleted ones. Start, stop and delete run one
36
+ after another in the order asked.
37
+
38
+ ## Ownership
39
+
40
+ - `sqlite.js` opens the builtin SQLite (`node:sqlite` on Node and Electron,
41
+ `bun:sqlite` on Bun). No dependency; without either the runtime reports
42
+ itself unavailable and the route answers 503.
43
+ - `store.js` owns the file `<dataDir>/message-search.sqlite`: `sessions`,
44
+ `messages`, and an external-content FTS5 index with the trigram tokenizer
45
+ (any 3+ characters inside a word, any script, case-insensitive). The schema
46
+ version lives in `meta`; a mismatch drops and rebuilds, the file is derived.
47
+ It also builds snippets: FTS5's `snippet()` counts trigrams and cuts a hit to
48
+ a few characters, so the window is taken in JS on the returned hits.
49
+ - `indexer.js` keeps the index in step with OpenCode.
50
+ - `runtime.js` follows the setting, wires the indexer to the global event hub
51
+ while on, answers queries, reports status (state, file size, progress) and
52
+ deletes the file (while on, a fresh index starts at once: "rebuild").
53
+ - `routes.js` serves `GET /api/openchamber/message-search`,
54
+ `GET .../message-search/status` and `DELETE .../message-search/index`.
55
+
56
+ ## Keeping in step
57
+
58
+ - Live: `session.idle` and a settled assistant step (`message.updated` with
59
+ `time.completed`) queue that session, debounced; a sync reads each message
60
+ type (`user`, `assistant`) from its stored `cursor.next` onward. OpenCode
61
+ returns a cursor with every non-empty page, so no cursor format is assumed.
62
+ - An assistant record without `time.completed` is still being written: it is
63
+ not indexed and the cursor does not move past it, so the next sync reads it.
64
+ - OpenCode rejecting a cursor (the message is gone) resets the session and
65
+ reads it again from the start, once per sync.
66
+ - A revert hides the conversation's tail and the next prompt deletes it: a
67
+ changed revert boundary resets the session, and while one is set nothing at or
68
+ after the reverted message is indexed and no cursor is kept.
69
+ - Background: on every (re)connect the session list is walked and sessions
70
+ changed since they were read (`time.updated`) are queued behind live work,
71
+ one at a time with a short pause. Sessions the index holds that the list no
72
+ longer has are dropped, but only when the whole list arrived; a failed page
73
+ is not an empty list.
74
+ - `session.updated` (rename, move) and `session.deleted` apply directly.
75
+
76
+ ## Queries
77
+
78
+ Hits carry the message id; pages are cut by row id, since a reply and its
79
+ reasoning share a message. Every word of the query must occur; words shorter than three characters cannot
80
+ be looked up and are left out, and a query made only of them answers
81
+ `query-too-short` rather than everything. Newest first by default; `before`
82
+ pages by creation time with the message id breaking ties, so pages never
83
+ repeat or skip. Snippets mark matches with U+E000 / U+E001 and are plain text.