@openchambery/web 1.18.2-beta.4 → 1.18.2-beta.41

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 (148) hide show
  1. package/dist/assets/{AgentAvatar-B2kZjgaf.js → AgentAvatar-OmE7AspO.js} +1 -1
  2. package/dist/assets/AssistantView-BbFh_0Dg.js +1 -0
  3. package/dist/assets/{ChatContainer-BmLxb00F.js → ChatContainer-Dsu6TrBr.js} +40 -40
  4. package/dist/assets/{DiagramView-GH3vG8Z5.js → DiagramView-B6LoNerQ.js} +1 -1
  5. package/dist/assets/{FadeInOnReveal-aeWlaqVB.js → FadeInOnReveal-EygBOzfu.js} +1 -1
  6. package/dist/assets/{Icon-AXqa-fYB.js → Icon-C0dydAmx.js} +1 -1
  7. package/dist/assets/{MarkdownRendererImpl-tgkSfBku.js → MarkdownRendererImpl-DIIxch1E.js} +2 -2
  8. package/dist/assets/{MobileDetailNavigation-CyDXHPw9.js → MobileDetailNavigation-gJrPjED8.js} +1 -1
  9. package/dist/assets/MobileShareBridge-CywbQFtE.js +4 -0
  10. package/dist/assets/MobileSurface-t3_oHKiU.js +2 -0
  11. package/dist/assets/{MultiRunWindow-CJQ8RU1e.js → MultiRunWindow-C7ytmqsf.js} +1 -1
  12. package/dist/assets/{OnboardingScreen-DiPnIwza.js → OnboardingScreen-Ck8vLrCb.js} +1 -1
  13. package/dist/assets/OverlayScrollbar-DMQhwzR3.js +2 -0
  14. package/dist/assets/SettingsView-BjIXFDJo.js +25 -0
  15. package/dist/assets/{SettingsWindow-zVXnRr6V.js → SettingsWindow-DapIdHCG.js} +1 -1
  16. package/dist/assets/{TerminalView-CE3CCTsi.js → TerminalView-C27XY7Gf.js} +1 -1
  17. package/dist/assets/{ToolOutputDialog-C3_vf7HM.js → ToolOutputDialog-Biq5MW0L.js} +1 -1
  18. package/dist/assets/appThemeRegistry-DSeuIQ8x.js +2 -0
  19. package/dist/assets/assistant-guide-hero-wide-DiFIThB0.jpg +0 -0
  20. package/dist/assets/{button-CDvMVaiO.js → button-Iv9uULki.js} +1 -1
  21. package/dist/assets/capgoAdapter-BSPH5_gX.js +1 -0
  22. package/dist/assets/{clipboard-CbqhDr1g.js → clipboard-DH0BvKYH.js} +1 -1
  23. package/dist/assets/{collapsible-C2aamDvD.js → collapsible-C46kU7ea.js} +1 -1
  24. package/dist/assets/{context-menu-wdR3gf8a.js → context-menu-6-6_ZMPD.js} +1 -1
  25. package/dist/assets/{desktopHosts-CBoBpJ1Z.js → desktopHosts-DV_01iQq.js} +1 -1
  26. package/dist/assets/{desktopRelayRestore-l2R9muux.js → desktopRelayRestore-DhQzRu4d.js} +1 -1
  27. package/dist/assets/{diagram-CEon0BQs.js → diagram-CqOdzPLy.js} +1 -1
  28. package/dist/assets/{dialog--cf4dygO.js → dialog-BPXCMWcj.js} +1 -1
  29. package/dist/assets/{es-DCoGZljP.js → es-DyE3MYjW.js} +4 -4
  30. package/dist/assets/{fileQueries-CE_DaZWQ.js → fileQueries-EAHC6GsF.js} +1 -1
  31. package/dist/assets/{fr-dkEoZpPz.js → fr-T-bfFDvO.js} +4 -4
  32. package/dist/assets/gitApi-DBiUTo9f.js +7 -0
  33. package/dist/assets/{input-k9DGGyZ6.js → input-7arjRNdx.js} +1 -1
  34. package/dist/assets/insertionBoundaries-sHx9jxbo.js +1 -0
  35. package/dist/assets/{ja-bQwSsvRr.js → ja-CZPkddOJ.js} +4 -4
  36. package/dist/assets/{ko-Kq5C3hsv.js → ko-MUUqS5Un.js} +4 -4
  37. package/dist/assets/main-CHJqCV7K.js +2 -0
  38. package/dist/assets/main-DWXng23x.js +172 -0
  39. package/dist/assets/{markdown-worker-DkeWiER6.js → markdown-worker-sIoCa792.js} +1 -1
  40. package/dist/assets/{markdownTheme-DNT93i5L.js → markdownTheme-QtXMKzKz.js} +1 -1
  41. package/dist/assets/miniChat-BESI7TXK.js +2 -0
  42. package/dist/assets/mobile-DHxpMIIL.js +2 -0
  43. package/dist/assets/multirun-B0t49WA8.js +4 -0
  44. package/dist/assets/{persistence-DPNMIbF5.js → persistence-Cm9DnxXq.js} +2 -2
  45. package/dist/assets/pl-g4y8Kn6w.js +15 -0
  46. package/dist/assets/platform-BrOZ1tqx.js +2 -0
  47. package/dist/assets/projectMeta-BKiWwihW.js +3 -0
  48. package/dist/assets/{pt-BR-MSPTLfTm.js → pt-BR-Boqh_bme.js} +4 -4
  49. package/dist/assets/radio-F1ArMGUG.js +1 -0
  50. package/dist/assets/renderElectronMiniChatApp-jT1prGPG.js +2 -0
  51. package/dist/assets/renderMobileApp-DTW_aLud.js +23 -0
  52. package/dist/assets/runtimeConfig-BbXojIxL.js +2 -0
  53. package/dist/assets/runtimeEndpointReset-CnX8ef-9.js +145 -0
  54. package/dist/assets/{sortable-tabs-strip-8qgYIxgY.js → sortable-tabs-strip-OO0ijdmq.js} +1 -1
  55. package/dist/assets/src-BBD2IyWD.css +2 -0
  56. package/dist/assets/{store-OURVnLSN.js → store-BLmIK6EO.js} +4 -4
  57. package/dist/assets/terminalApi-BunCJZ0A.js +1 -0
  58. package/dist/assets/{tooltip-DMNR5rN0.js → tooltip-CO8qCWXw.js} +1 -1
  59. package/dist/assets/types-BuiqMmh_.js +1 -0
  60. package/dist/assets/{uk-cSkRAYFY.js → uk-B4CEXe9W.js} +4 -4
  61. package/dist/assets/{url-7MqoLs9X.js → url-CM2fyKko.js} +1 -1
  62. package/dist/assets/useAppFontEffects-s3g5mFHX.js +7 -0
  63. package/dist/assets/{useAssistantUIStore-Bq3cPj2x.js → useAssistantUIStore-B9YvQgXU.js} +1 -1
  64. package/dist/assets/useDesktopWindowControlsLayout-BaYTRHtA.js +1 -0
  65. package/dist/assets/useEffectiveDirectory-SM-YH736.js +1 -0
  66. package/dist/assets/{useFontPreferences-CIurCeNv.js → useFontPreferences-DKIVD8RE.js} +1 -1
  67. package/dist/assets/useMobileNavigationStore-BcAHNGih.js +476 -0
  68. package/dist/assets/useSessionAutoCleanup-CCxr-ARs.js +1 -0
  69. package/dist/assets/{useUIStore-5agS8bsW.js → useUIStore-CL06MzOk.js} +1 -1
  70. package/dist/assets/{useWorkerHighlightedLines-DEhp2GTh.js → useWorkerHighlightedLines-DCymxLYc.js} +1 -1
  71. package/dist/assets/{utils-Co19EJEL.js → utils-DlvuQ5yV.js} +1 -1
  72. package/dist/assets/{zh-CN-BKqeT_uz.js → zh-CN-C4wauCqC.js} +4 -4
  73. package/dist/assets/{zh-TW-BaNjJ8Y4.js → zh-TW-DtT3aVC7.js} +4 -4
  74. package/dist/index.html +13 -11
  75. package/dist/mini-chat.html +11 -9
  76. package/dist/mobile.html +11 -9
  77. package/package.json +1 -1
  78. package/server/index.js +7 -0
  79. package/server/lib/assistants/DOCUMENTATION.md +2 -2
  80. package/server/lib/assistants/history-state.js +23 -0
  81. package/server/lib/assistants/history-state.test.js +57 -0
  82. package/server/lib/assistants/service.js +44 -15
  83. package/server/lib/assistants/service.test.js +120 -5
  84. package/server/lib/event-stream/DOCUMENTATION.md +2 -2
  85. package/server/lib/event-stream/diff-summary.js +39 -11
  86. package/server/lib/event-stream/diff-summary.test.js +73 -6
  87. package/server/lib/event-stream/protocol.test.js +70 -7
  88. package/server/lib/message-queue/DOCUMENTATION.md +1 -1
  89. package/server/lib/notifications/DOCUMENTATION.md +2 -2
  90. package/server/lib/notifications/runtime.js +68 -27
  91. package/server/lib/notifications/runtime.test.js +176 -0
  92. package/server/lib/opencode/DOCUMENTATION.md +1 -1
  93. package/server/lib/opencode/feature-routes-runtime.test.js +10 -1
  94. package/server/lib/session-index/DOCUMENTATION.md +12 -6
  95. package/server/lib/session-index/routes.js +34 -0
  96. package/server/lib/session-index/routes.test.js +76 -0
  97. package/server/lib/session-index/service.js +53 -4
  98. package/server/lib/session-index/service.test.js +72 -2
  99. package/server/lib/session-title/DOCUMENTATION.md +19 -14
  100. package/server/lib/session-title/runtime.js +8 -8
  101. package/server/lib/session-title/runtime.test.js +231 -0
  102. package/server/lib/session-turn-pages/DOCUMENTATION.md +26 -6
  103. package/server/lib/session-turn-pages/changes.service.js +156 -0
  104. package/server/lib/session-turn-pages/changes.service.test.js +188 -0
  105. package/server/lib/session-turn-pages/reconcile.routes.test.js +52 -0
  106. package/server/lib/session-turn-pages/reconcile.service.js +3 -1
  107. package/server/lib/session-turn-pages/reconcile.service.test.js +44 -0
  108. package/server/lib/session-turn-pages/routes.js +273 -12
  109. package/server/lib/session-turn-pages/routes.test.js +387 -0
  110. package/server/lib/session-turn-pages/service.js +31 -7
  111. package/server/lib/session-turn-pages/service.test.js +40 -0
  112. package/server/lib/small-model/DOCUMENTATION.md +93 -38
  113. package/server/lib/small-model/catalog.js +10 -2
  114. package/server/lib/small-model/catalog.test.js +3 -1
  115. package/server/lib/small-model/index.js +52 -28
  116. package/server/lib/small-model/opencode-session.js +339 -0
  117. package/server/lib/small-model/opencode-session.test.js +177 -0
  118. package/server/lib/small-model/resolve.js +116 -5
  119. package/server/lib/small-model/resolve.test.js +76 -10
  120. package/server/lib/small-model/summary-settings.test.js +60 -3
  121. package/dist/assets/AssistantView-zQDlmCA-.js +0 -1
  122. package/dist/assets/MobileShareBridge-DT2ySSn1.js +0 -4
  123. package/dist/assets/MobileSurface-Bhur0fxY.js +0 -2
  124. package/dist/assets/OverlayScrollbar-DC12_DLb.js +0 -1
  125. package/dist/assets/SettingsView-BywZ5HTE.js +0 -25
  126. package/dist/assets/appThemeRegistry-Y2U1kIMh.js +0 -2
  127. package/dist/assets/gitApi-BL_etF0B.js +0 -7
  128. package/dist/assets/gitApiHttp-D8j1qRH4.js +0 -2
  129. package/dist/assets/insertionBoundaries-CjCybFIP.js +0 -1
  130. package/dist/assets/main-Bpwq1Xh1.js +0 -2
  131. package/dist/assets/main-DIVJIea3.js +0 -172
  132. package/dist/assets/miniChat-BrYw8M4I.js +0 -2
  133. package/dist/assets/mobile-i4Pu_Tak.js +0 -2
  134. package/dist/assets/multirun-OJ8angjt.js +0 -4
  135. package/dist/assets/pl-CYpMAgVn.js +0 -15
  136. package/dist/assets/projectMeta-Dt0loPh9.js +0 -3
  137. package/dist/assets/radio-SXFBBh2O.js +0 -1
  138. package/dist/assets/renderElectronMiniChatApp-BBb29zbe.js +0 -2
  139. package/dist/assets/renderMobileApp-Ctj7sqAE.js +0 -23
  140. package/dist/assets/runtimeConfig-BtWi74Pm.js +0 -1
  141. package/dist/assets/runtimeEndpointReset-By8IWO59.js +0 -145
  142. package/dist/assets/src-DOs1ZW0T.css +0 -2
  143. package/dist/assets/terminalApi-tB3qLcfa.js +0 -1
  144. package/dist/assets/useAppFontEffects-D81CYdad.js +0 -7
  145. package/dist/assets/useDesktopWindowControlsLayout-BWOeSiA5.js +0 -1
  146. package/dist/assets/useEffectiveDirectory-BNDb_82A.js +0 -1
  147. package/dist/assets/useMobileNavigationStore-DBYUoTQ0.js +0 -475
  148. package/dist/assets/useSessionAutoCleanup-Cc_AwEoh.js +0 -1
@@ -0,0 +1,176 @@
1
+ import { afterEach, describe, expect, it, vi } from 'vitest';
2
+
3
+ import { createNotificationTriggerRuntime } from './runtime.js';
4
+
5
+ const defaultSettings = {
6
+ notifyOnCompletion: true,
7
+ notifyOnQuestion: true,
8
+ notificationMode: 'always',
9
+ nativeNotificationsEnabled: true,
10
+ };
11
+
12
+ const createRuntime = (overrides = {}) => {
13
+ const emitDesktopNotification = vi.fn(() => true);
14
+ const broadcastUiNotification = vi.fn();
15
+ const sendPushToAllUiSessions = vi.fn(async () => {});
16
+ const sendApnsToAllUiSessions = vi.fn(async () => {});
17
+ const runtime = createNotificationTriggerRuntime({
18
+ readSettingsFromDisk: vi.fn(async () => defaultSettings),
19
+ prepareNotificationLastMessage: vi.fn(async ({ message }) => message || ''),
20
+ buildTemplateVariables: vi.fn(async () => ({ session_name: 'Session' })),
21
+ extractLastMessageText: vi.fn(() => ''),
22
+ fetchLastAssistantMessageText: vi.fn(async () => ''),
23
+ resolveNotificationTemplate: vi.fn((template) => template),
24
+ shouldApplyResolvedTemplateMessage: vi.fn(() => true),
25
+ emitDesktopNotification,
26
+ broadcastUiNotification,
27
+ sendPushToAllUiSessions,
28
+ sendApnsToAllUiSessions,
29
+ isAnyInteractiveClientVisible: () => false,
30
+ buildOpenCodeUrl: (path) => `http://opencode.test${path}`,
31
+ getOpenCodeAuthHeaders: () => ({}),
32
+ getIsWindowFocused: () => false,
33
+ ...overrides,
34
+ });
35
+ return {
36
+ runtime,
37
+ emitDesktopNotification,
38
+ broadcastUiNotification,
39
+ sendPushToAllUiSessions,
40
+ sendApnsToAllUiSessions,
41
+ };
42
+ };
43
+
44
+ const jsonResponse = (body, status = 200) => new Response(JSON.stringify(body), {
45
+ status,
46
+ headers: { 'Content-Type': 'application/json' },
47
+ });
48
+
49
+ afterEach(() => {
50
+ vi.unstubAllGlobals();
51
+ vi.useRealTimers();
52
+ });
53
+
54
+ describe('notification trigger runtime smallModel suppression', () => {
55
+ it('skips ready notifications for smallModel sessions', async () => {
56
+ vi.stubGlobal('fetch', vi.fn(async () => jsonResponse({
57
+ id: 'ses_small',
58
+ parentID: null,
59
+ metadata: { openchamber: { smallModel: { purpose: 'session-title' } } },
60
+ })));
61
+
62
+ const { runtime, emitDesktopNotification, sendPushToAllUiSessions } = createRuntime();
63
+ await runtime.maybeSendPushForTrigger({
64
+ type: 'message.updated',
65
+ properties: {
66
+ directory: '/repo',
67
+ info: {
68
+ id: 'msg_1',
69
+ sessionID: 'ses_small',
70
+ role: 'assistant',
71
+ finish: 'stop',
72
+ mode: 'build',
73
+ modelID: 'small',
74
+ },
75
+ },
76
+ });
77
+
78
+ expect(emitDesktopNotification).not.toHaveBeenCalled();
79
+ expect(sendPushToAllUiSessions).not.toHaveBeenCalled();
80
+ });
81
+
82
+ it('skips ready notifications synthesized from session.idle for smallModel sessions', async () => {
83
+ vi.stubGlobal('fetch', vi.fn(async () => jsonResponse({
84
+ id: 'ses_small',
85
+ parentID: null,
86
+ metadata: { openchamber: { smallModel: { purpose: 'commit' } } },
87
+ })));
88
+
89
+ const { runtime, emitDesktopNotification, sendPushToAllUiSessions } = createRuntime();
90
+ await runtime.maybeSendPushForTrigger({
91
+ type: 'session.idle',
92
+ properties: {
93
+ directory: '/repo',
94
+ sessionID: 'ses_small',
95
+ },
96
+ });
97
+
98
+ expect(emitDesktopNotification).not.toHaveBeenCalled();
99
+ expect(sendPushToAllUiSessions).not.toHaveBeenCalled();
100
+ });
101
+
102
+ it('skips question notifications for smallModel sessions', async () => {
103
+ vi.useFakeTimers();
104
+ vi.stubGlobal('fetch', vi.fn(async () => jsonResponse({
105
+ id: 'ses_small',
106
+ parentID: null,
107
+ metadata: { openchamber: { smallModel: { purpose: 'session-title' } } },
108
+ })));
109
+
110
+ const { runtime, emitDesktopNotification, sendPushToAllUiSessions } = createRuntime();
111
+ await runtime.maybeSendPushForTrigger({
112
+ type: 'question.asked',
113
+ properties: {
114
+ directory: '/repo',
115
+ sessionID: 'ses_small',
116
+ questions: [{ header: 'Input needed', question: 'Continue?' }],
117
+ },
118
+ });
119
+ await vi.runAllTimersAsync();
120
+
121
+ expect(emitDesktopNotification).not.toHaveBeenCalled();
122
+ expect(sendPushToAllUiSessions).not.toHaveBeenCalled();
123
+ });
124
+
125
+ it('skips permission notifications for smallModel sessions', async () => {
126
+ vi.useFakeTimers();
127
+ vi.stubGlobal('fetch', vi.fn(async () => jsonResponse({
128
+ id: 'ses_small',
129
+ parentID: null,
130
+ metadata: { openchamber: { smallModel: { purpose: 'session-title' } } },
131
+ })));
132
+
133
+ const { runtime, emitDesktopNotification, sendPushToAllUiSessions } = createRuntime();
134
+ await runtime.maybeSendPushForTrigger({
135
+ type: 'permission.asked',
136
+ properties: {
137
+ directory: '/repo',
138
+ sessionID: 'ses_small',
139
+ id: 'perm_1',
140
+ permission: 'edit',
141
+ },
142
+ });
143
+ await vi.runAllTimersAsync();
144
+
145
+ expect(emitDesktopNotification).not.toHaveBeenCalled();
146
+ expect(sendPushToAllUiSessions).not.toHaveBeenCalled();
147
+ });
148
+
149
+ it('still notifies ordinary root sessions', async () => {
150
+ vi.stubGlobal('fetch', vi.fn(async () => jsonResponse({
151
+ id: 'ses_root',
152
+ parentID: null,
153
+ title: 'Ordinary',
154
+ metadata: {},
155
+ })));
156
+
157
+ const { runtime, emitDesktopNotification, sendPushToAllUiSessions } = createRuntime();
158
+ await runtime.maybeSendPushForTrigger({
159
+ type: 'message.updated',
160
+ properties: {
161
+ directory: '/repo',
162
+ info: {
163
+ id: 'msg_2',
164
+ sessionID: 'ses_root',
165
+ role: 'assistant',
166
+ finish: 'stop',
167
+ mode: 'build',
168
+ modelID: 'gpt',
169
+ },
170
+ },
171
+ });
172
+
173
+ expect(emitDesktopNotification).toHaveBeenCalledTimes(1);
174
+ expect(sendPushToAllUiSessions).toHaveBeenCalledTimes(1);
175
+ });
176
+ });
@@ -28,7 +28,7 @@ This module provides OpenCode server integration utilities for the web server ru
28
28
  - `packages/web/server/lib/opencode/static-routes-runtime.js`: static asset/SPA fallback route registration and manifest route wiring.
29
29
  - `packages/web/server/lib/opencode/feature-routes-runtime.js`: feature route composition runtime for dynamic import-backed config/skill/provider route registration.
30
30
  - `packages/web/server/lib/conversations/`: combined create-session-and-prompt orchestration (OpenChamber-owned, registered before generic proxy).
31
- - `packages/web/server/lib/session-turn-pages/`: turn-window session message pagination (`GET /api/openchamber/sessions/:sessionID/messages`) and anchor reconcile (`GET .../messages/reconcile`); loops official OpenCode `session.messages` for turn pages and head→anchor gap recovery with continuation/budgets/`resetRequired`; registered before generic proxy. See `session-turn-pages/DOCUMENTATION.md`.
31
+ - `packages/web/server/lib/session-turn-pages/`: turn-window session message pagination (`GET /api/openchamber/sessions/:sessionID/messages`), anchor reconcile (`GET .../messages/reconcile`), Changes L2/L3 (`GET .../changes`), and exact message L1 projection (`GET /api/session/:sessionID/message/:messageID`); loops official OpenCode `session.messages` for turn pages and head→anchor gap recovery with continuation/budgets/`resetRequired`; all registered before generic proxy. L1 first-packet / SSE / exact-message paths keep `summary.diffs` as a slim `{ file, status?, additions, deletions }` list plus additive `diffCount`/`hasDiffs` (patch bodies stay on L3). See `session-turn-pages/DOCUMENTATION.md`.
32
32
  - `packages/web/server/lib/opencode/opencode-resolution-runtime.js`: OpenCode binary resolution snapshot runtime for settings routes and diagnostics.
33
33
  - `packages/web/server/lib/opencode/tunnel-wiring-runtime.js`: active loopback-port wiring shared by pairing/LAN URLs and the private relay host.
34
34
  - `packages/web/server/lib/opencode/startup-pipeline-runtime.js`: server startup tail orchestration runtime for terminal/proxy/static/start-listen flow.
@@ -27,10 +27,19 @@ describe('feature routes runtime composition', () => {
27
27
  const source = await fs.readFile(new URL('./feature-routes-runtime.js', import.meta.url), 'utf8');
28
28
  expect(source).toContain("import { registerSessionTurnPageRoutes } from '../session-turn-pages/routes.js';");
29
29
  expect(source).toMatch(/registerSessionTurnPageRoutes\(app, \{[\s\S]*buildOpenCodeUrl,[\s\S]*getOpenCodeAuthHeaders,/);
30
- // OpenChamber-owned turn-page/reconcile registration comment + call stay before end of feature composition.
30
+ // OpenChamber-owned turn-page/reconcile/changes/exact-message registration stays before end of feature composition.
31
31
  expect(source).toContain('// OpenChamber-owned turn-window messages API — must register before generic proxy.');
32
32
  const turnIdx = source.indexOf('registerSessionTurnPageRoutes(app,');
33
33
  expect(turnIdx).toBeGreaterThan(-1);
34
+ // Exact message + Changes live inside registerSessionTurnPageRoutes (same Host composition Electron reuses).
35
+ const routesSource = await fs.readFile(new URL('../session-turn-pages/routes.js', import.meta.url), 'utf8');
36
+ expect(routesSource).toContain("app.get('/api/session/:sessionID/message/:messageID'");
37
+ expect(routesSource).toContain("app.get('/api/openchamber/sessions/:sessionID/changes'");
38
+ const exactIdx = routesSource.indexOf("app.get('/api/session/:sessionID/message/:messageID'");
39
+ const changesIdx = routesSource.indexOf("app.get('/api/openchamber/sessions/:sessionID/changes'");
40
+ const messagesIdx = routesSource.indexOf("app.get('/api/openchamber/sessions/:sessionID/messages'");
41
+ expect(exactIdx).toBeGreaterThan(messagesIdx);
42
+ expect(changesIdx).toBeGreaterThan(exactIdx);
34
43
  });
35
44
 
36
45
  it('removes broken SSE clients while continuing worktree topology broadcasts', () => {
@@ -13,14 +13,20 @@ newest 20 root-session summaries per runtime and directory. It never stores
13
13
  messages, attachments, permissions, provider data, or model metadata.
14
14
  Sessions titled `smartfetch-secondary` are temporary SmartFetch model calls;
15
15
  the index excludes them from every snapshot and clears prior summaries when a
16
- matching session update arrives. System-owned sessions are excluded by
17
- authoritative metadata only: a non-empty
18
- `metadata.openchamber.assistant.assistantID` or
19
- `metadata.openchamber.scheduledTask.taskID`. Title prefixes are human labels and
20
- never participate in this filter. Metadata is the ownership/isolation signal;
21
- `time.archived` is archive state; titles are for recognition. The index does
16
+ matching session update arrives. System-owned sessions are excluded by
17
+ authoritative metadata only: a non-empty
18
+ `metadata.openchamber.assistant.assistantID`,
19
+ `metadata.openchamber.scheduledTask.taskID`, or
20
+ `metadata.openchamber.smallModel.purpose`. Title prefixes are human labels and
21
+ never participate in this filter. Metadata is the ownership/isolation signal;
22
+ `time.archived` is archive state; `time.pinned` is OpenChamber-owned pin state
23
+ (persisted as `pinned_at`, rescued across directory rebuilds, never overwritten
24
+ by live OpenCode upserts); titles are for recognition. The index does
22
25
  not cache system sessions, so cold-start and live upserts stay aligned with
23
26
  ordinary sidebar lists.
27
+ Pin and unpin use `POST` / `DELETE`
28
+ `/api/openchamber/session-index/session/:id/pin`, update `pinned_at`, then
29
+ `publishChange()` so revision tips broadcast `openchamber:session-index-changed`.
24
30
 
25
31
  The server-side global OpenCode event subscriber writes session summary events
26
32
  directly into this index. User `message.updated` events and `session.idle`
@@ -62,4 +62,38 @@ export const registerSessionIndexRoutes = (app, { sessionIndexService, sessionIn
62
62
  }
63
63
  res.json({ available: true, session: hit });
64
64
  });
65
+
66
+ app.post('/api/openchamber/session-index/session/:id/pin', (req, res) => {
67
+ if (!sessionIndexService) return unsupported(res);
68
+ if (typeof sessionIndexService.setPinned !== 'function') {
69
+ return res.status(501).json({ error: 'Session pin is unavailable' });
70
+ }
71
+ const sessionId = req.params.id;
72
+ if (typeof sessionId !== 'string' || !sessionId.trim()) {
73
+ return res.status(400).json({ error: 'sessionId is required' });
74
+ }
75
+ const changed = sessionIndexService.setPinned(sessionId.trim());
76
+ if (!changed) {
77
+ return res.status(404).json({ error: 'session_not_found', sessionId: sessionId.trim() });
78
+ }
79
+ sessionIndexSyncRuntime?.publishChange?.();
80
+ res.status(204).end();
81
+ });
82
+
83
+ app.delete('/api/openchamber/session-index/session/:id/pin', (req, res) => {
84
+ if (!sessionIndexService) return unsupported(res);
85
+ if (typeof sessionIndexService.clearPinned !== 'function') {
86
+ return res.status(501).json({ error: 'Session unpin is unavailable' });
87
+ }
88
+ const sessionId = req.params.id;
89
+ if (typeof sessionId !== 'string' || !sessionId.trim()) {
90
+ return res.status(400).json({ error: 'sessionId is required' });
91
+ }
92
+ const changed = sessionIndexService.clearPinned(sessionId.trim());
93
+ if (!changed) {
94
+ return res.status(404).json({ error: 'session_not_found', sessionId: sessionId.trim() });
95
+ }
96
+ sessionIndexSyncRuntime?.publishChange?.();
97
+ res.status(204).end();
98
+ });
65
99
  };
@@ -137,4 +137,80 @@ describe('session index routes', () => {
137
137
  expect(res.statusCode).toBe(404);
138
138
  expect(res.body).toMatchObject({ error: 'session_not_found' });
139
139
  });
140
+
141
+ it('pins a session and publishes a session-index change', () => {
142
+ const { app, route } = registry();
143
+ const setPinned = vi.fn(() => true);
144
+ const publishChange = vi.fn();
145
+ registerSessionIndexRoutes(app, {
146
+ sessionIndexService: {
147
+ snapshot: () => ({ directories: [] }),
148
+ setPinned,
149
+ },
150
+ sessionIndexSyncRuntime: { publishChange },
151
+ });
152
+ const res = response();
153
+
154
+ route('POST', '/api/openchamber/session-index/session/:id/pin')(
155
+ { params: { id: 'ses_abc' } },
156
+ res,
157
+ );
158
+
159
+ expect(setPinned).toHaveBeenCalledWith('ses_abc');
160
+ expect(publishChange).toHaveBeenCalledTimes(1);
161
+ expect(res.statusCode).toBe(204);
162
+ });
163
+
164
+ it('unpins a session and publishes a session-index change', () => {
165
+ const { app, route } = registry();
166
+ const clearPinned = vi.fn(() => true);
167
+ const publishChange = vi.fn();
168
+ registerSessionIndexRoutes(app, {
169
+ sessionIndexService: {
170
+ snapshot: () => ({ directories: [] }),
171
+ clearPinned,
172
+ },
173
+ sessionIndexSyncRuntime: { publishChange },
174
+ });
175
+ const res = response();
176
+
177
+ route('DELETE', '/api/openchamber/session-index/session/:id/pin')(
178
+ { params: { id: 'ses_abc' } },
179
+ res,
180
+ );
181
+
182
+ expect(clearPinned).toHaveBeenCalledWith('ses_abc');
183
+ expect(publishChange).toHaveBeenCalledTimes(1);
184
+ expect(res.statusCode).toBe(204);
185
+ });
186
+
187
+ it('returns 404 for pin and unpin when the session is missing', () => {
188
+ const { app, route } = registry();
189
+ const publishChange = vi.fn();
190
+ registerSessionIndexRoutes(app, {
191
+ sessionIndexService: {
192
+ snapshot: () => ({ directories: [] }),
193
+ setPinned: () => false,
194
+ clearPinned: () => false,
195
+ },
196
+ sessionIndexSyncRuntime: { publishChange },
197
+ });
198
+
199
+ const pinRes = response();
200
+ route('POST', '/api/openchamber/session-index/session/:id/pin')(
201
+ { params: { id: 'ses_missing' } },
202
+ pinRes,
203
+ );
204
+ expect(pinRes.statusCode).toBe(404);
205
+ expect(pinRes.body).toMatchObject({ error: 'session_not_found' });
206
+
207
+ const unpinRes = response();
208
+ route('DELETE', '/api/openchamber/session-index/session/:id/pin')(
209
+ { params: { id: 'ses_missing' } },
210
+ unpinRes,
211
+ );
212
+ expect(unpinRes.statusCode).toBe(404);
213
+ expect(unpinRes.body).toMatchObject({ error: 'session_not_found' });
214
+ expect(publishChange).not.toHaveBeenCalled();
215
+ });
140
216
  });
@@ -15,6 +15,7 @@ const isSystemSession = (session) => {
15
15
  if (!openchamber || typeof openchamber !== 'object') return false;
16
16
  if (nonEmptySystemID(openchamber.assistant?.assistantID)) return true;
17
17
  if (nonEmptySystemID(openchamber.scheduledTask?.taskID)) return true;
18
+ if (nonEmptySystemID(openchamber.smallModel?.purpose)) return true;
18
19
  return false;
19
20
  };
20
21
 
@@ -116,6 +117,7 @@ export const createSessionIndexService = ({ dbPath, getRuntimeConfig = () => nul
116
117
  updated_at INTEGER NOT NULL,
117
118
  activity_updated_at INTEGER NOT NULL,
118
119
  archived_at INTEGER NOT NULL DEFAULT 0,
120
+ pinned_at INTEGER,
119
121
  status TEXT,
120
122
  status_changed_at INTEGER NOT NULL DEFAULT 0,
121
123
  parent_id TEXT,
@@ -139,6 +141,12 @@ export const createSessionIndexService = ({ dbPath, getRuntimeConfig = () => nul
139
141
  CREATE INDEX IF NOT EXISTS session_child_parent
140
142
  ON session_child(runtime_key, directory, parent_id);
141
143
  `);
144
+ const sessionSummaryColumns = new Set(
145
+ db.prepare("SELECT name FROM pragma_table_info('session_summary')").all().map((column) => column.name),
146
+ );
147
+ if (!sessionSummaryColumns.has('pinned_at')) {
148
+ db.exec('ALTER TABLE session_summary ADD COLUMN pinned_at INTEGER');
149
+ }
142
150
  db.prepare('INSERT OR REPLACE INTO session_index_meta(key, value) VALUES (?, ?)')
143
151
  .run('schema_version', String(SCHEMA_VERSION));
144
152
 
@@ -165,7 +173,7 @@ export const createSessionIndexService = ({ dbPath, getRuntimeConfig = () => nul
165
173
  const deleteDirectoryRows = db.prepare('DELETE FROM session_summary WHERE runtime_key = ? AND directory = ?');
166
174
  const existingSummaryState = db.prepare(`
167
175
  SELECT session_id, has_children AS hasChildren, activity_updated_at AS activityUpdatedAt,
168
- status, status_changed_at AS statusChangedAt
176
+ status, status_changed_at AS statusChangedAt, pinned_at AS pinnedAt
169
177
  FROM session_summary WHERE runtime_key = ? AND directory = ?
170
178
  `);
171
179
  const readSummary = db.prepare(`
@@ -183,8 +191,8 @@ export const createSessionIndexService = ({ dbPath, getRuntimeConfig = () => nul
183
191
  LIMIT 1 OFFSET ?
184
192
  `);
185
193
  const insertSummary = db.prepare(`
186
- INSERT INTO session_summary(runtime_key, directory, session_id, title, created_at, updated_at, activity_updated_at, archived_at, status, status_changed_at, parent_id, has_children, assistant_id, assistant_name)
187
- VALUES (@runtimeKey, @directory, @id, @title, @createdAt, @updatedAt, @activityUpdatedAt, @archivedAt, @status, @statusChangedAt, @parentID, @hasChildren, @assistantID, @assistantName)
194
+ INSERT INTO session_summary(runtime_key, directory, session_id, title, created_at, updated_at, activity_updated_at, archived_at, pinned_at, status, status_changed_at, parent_id, has_children, assistant_id, assistant_name)
195
+ VALUES (@runtimeKey, @directory, @id, @title, @createdAt, @updatedAt, @activityUpdatedAt, @archivedAt, @pinnedAt, @status, @statusChangedAt, @parentID, @hasChildren, @assistantID, @assistantName)
188
196
  `);
189
197
  const upsertSummary = db.prepare(`
190
198
  INSERT INTO session_summary(runtime_key, directory, session_id, title, created_at, updated_at, activity_updated_at, archived_at, status, status_changed_at, parent_id, has_children, assistant_id, assistant_name)
@@ -259,6 +267,7 @@ export const createSessionIndexService = ({ dbPath, getRuntimeConfig = () => nul
259
267
  insertSummary.run({
260
268
  ...summary,
261
269
  activityUpdatedAt: Math.max(summary.activityUpdatedAt, toTimestamp(previous?.activityUpdatedAt)),
270
+ pinnedAt: previous?.pinnedAt != null ? toTimestamp(previous.pinnedAt) : null,
262
271
  status: typeof previous?.status === 'string' ? previous.status : null,
263
272
  statusChangedAt: toTimestamp(previous?.statusChangedAt),
264
273
  hasChildren: toBooleanInt(summary.hasChildren ?? Boolean(previous?.hasChildren)),
@@ -364,6 +373,7 @@ export const createSessionIndexService = ({ dbPath, getRuntimeConfig = () => nul
364
373
  sessions: db.prepare(`
365
374
  SELECT session_id AS id, title, created_at AS createdAt, updated_at AS updatedAt,
366
375
  activity_updated_at AS activityUpdatedAt, archived_at AS archivedAt,
376
+ pinned_at AS pinnedAt,
367
377
  status, status_changed_at AS statusChangedAt, parent_id AS parentID,
368
378
  has_children AS hasChildren, assistant_id AS assistantID, assistant_name AS assistantName
369
379
  FROM session_summary WHERE runtime_key = ? AND directory = ?
@@ -373,7 +383,12 @@ export const createSessionIndexService = ({ dbPath, getRuntimeConfig = () => nul
373
383
  id: session.id,
374
384
  title: session.title,
375
385
  directory: directory.directory,
376
- time: { created: session.createdAt, updated: session.updatedAt, ...(session.archivedAt ? { archived: session.archivedAt } : {}) },
386
+ time: {
387
+ created: session.createdAt,
388
+ updated: session.updatedAt,
389
+ ...(session.archivedAt ? { archived: session.archivedAt } : {}),
390
+ ...(session.pinnedAt ? { pinned: session.pinnedAt } : {}),
391
+ },
377
392
  metadata: {
378
393
  openchamber: {
379
394
  titleRefresh: { activityUpdatedAt: session.activityUpdatedAt },
@@ -465,6 +480,38 @@ export const createSessionIndexService = ({ dbPath, getRuntimeConfig = () => nul
465
480
  return result.changes > 0;
466
481
  };
467
482
 
483
+ const summaryExists = db.prepare(`
484
+ SELECT 1 AS present FROM session_summary
485
+ WHERE runtime_key = ? AND session_id = ?
486
+ LIMIT 1
487
+ `);
488
+
489
+ const setPinned = (sessionID, pinnedAt = Date.now()) => {
490
+ if (typeof sessionID !== 'string' || !sessionID) return false;
491
+ const timestamp = toTimestamp(pinnedAt);
492
+ if (!timestamp) return false;
493
+ const key = runtimeKey();
494
+ if (!summaryExists.get(key, sessionID)) return false;
495
+ db.prepare(`
496
+ UPDATE session_summary
497
+ SET pinned_at = ?
498
+ WHERE runtime_key = ? AND session_id = ?
499
+ `).run(timestamp, key, sessionID);
500
+ return true;
501
+ };
502
+
503
+ const clearPinned = (sessionID) => {
504
+ if (typeof sessionID !== 'string' || !sessionID) return false;
505
+ const key = runtimeKey();
506
+ if (!summaryExists.get(key, sessionID)) return false;
507
+ db.prepare(`
508
+ UPDATE session_summary
509
+ SET pinned_at = NULL
510
+ WHERE runtime_key = ? AND session_id = ?
511
+ `).run(key, sessionID);
512
+ return true;
513
+ };
514
+
468
515
  const replaceChildSessions = db.transaction((directory, parentSessionID, children) => {
469
516
  const normalizedDirectory = normalizeDirectory(directory);
470
517
  if (!normalizedDirectory || typeof parentSessionID !== 'string' || !parentSessionID) return false;
@@ -487,6 +534,8 @@ export const createSessionIndexService = ({ dbPath, getRuntimeConfig = () => nul
487
534
  upsertAndReportChange,
488
535
  touchActivity,
489
536
  updateStatus,
537
+ setPinned,
538
+ clearPinned,
490
539
  remove,
491
540
  findBySessionId,
492
541
  replaceChildSessions,
@@ -68,7 +68,7 @@ describe('Electron session index', () => {
68
68
  service.close();
69
69
  });
70
70
 
71
- it('excludes Assistant and Scheduled system sessions from ordinary sidebar summaries', () => {
71
+ it('excludes Assistant, Scheduled, and smallModel system sessions from ordinary sidebar summaries', () => {
72
72
  const runtimeRef = { value: 'http://runtime-a.test' };
73
73
  const service = createService(runtimeRef);
74
74
  const assistantSession = {
@@ -79,11 +79,15 @@ describe('Electron session index', () => {
79
79
  ...session('ses_scheduled', 99),
80
80
  metadata: { openchamber: { scheduledTask: { taskID: 'task_1' } } },
81
81
  };
82
+ const smallModelSession = {
83
+ ...session('ses_small_model', 97),
84
+ metadata: { openchamber: { smallModel: { purpose: 'session-title' } } },
85
+ };
82
86
  const ordinary = session('ses_ordinary', 98);
83
87
 
84
88
  service.replaceDirectory({
85
89
  directory: '/repo',
86
- sessions: [assistantSession, scheduledSession, ordinary],
90
+ sessions: [assistantSession, scheduledSession, smallModelSession, ordinary],
87
91
  cursor: null,
88
92
  hasMore: false,
89
93
  });
@@ -91,6 +95,7 @@ describe('Electron session index', () => {
91
95
 
92
96
  service.upsert(assistantSession);
93
97
  service.upsert(scheduledSession);
98
+ service.upsert(smallModelSession);
94
99
  expect(service.snapshot().directories[0].sessions.map((item) => item.id)).toEqual(['ses_ordinary']);
95
100
  service.close();
96
101
  });
@@ -318,4 +323,69 @@ describe('Electron session index', () => {
318
323
  expect(rebuilt.snapshot().directories).toEqual([]);
319
324
  rebuilt.close();
320
325
  });
326
+
327
+ it('exposes time.pinned in snapshots and clears it on unpin', () => {
328
+ const runtimeRef = { value: 'http://runtime-a.test' };
329
+ const service = createService(runtimeRef);
330
+ service.replaceDirectory({ directory: '/repo', sessions: [session('ses_a', 10)], cursor: null, hasMore: false });
331
+
332
+ expect(service.setPinned('ses_a', 55)).toBe(true);
333
+ expect(service.snapshot().directories[0].sessions[0].time).toMatchObject({
334
+ created: 9,
335
+ updated: 10,
336
+ pinned: 55,
337
+ });
338
+
339
+ expect(service.clearPinned('ses_a')).toBe(true);
340
+ expect(service.snapshot().directories[0].sessions[0].time).toEqual({
341
+ created: 9,
342
+ updated: 10,
343
+ });
344
+ service.close();
345
+ });
346
+
347
+ it('rescues pinned_at across replaceDirectory rebuilds', () => {
348
+ const runtimeRef = { value: 'http://runtime-a.test' };
349
+ const service = createService(runtimeRef);
350
+ service.replaceDirectory({ directory: '/repo', sessions: [session('ses_a', 10)], cursor: null, hasMore: false });
351
+ expect(service.setPinned('ses_a', 77)).toBe(true);
352
+
353
+ service.replaceDirectory({
354
+ directory: '/repo',
355
+ sessions: [session('ses_a', 20)],
356
+ cursor: null,
357
+ hasMore: false,
358
+ now: 2000,
359
+ });
360
+
361
+ expect(service.snapshot().directories[0].sessions[0].time).toMatchObject({
362
+ updated: 20,
363
+ pinned: 77,
364
+ });
365
+ service.close();
366
+ });
367
+
368
+ it('does not let live upsert overwrite pinned_at', () => {
369
+ const runtimeRef = { value: 'http://runtime-a.test' };
370
+ const service = createService(runtimeRef);
371
+ service.replaceDirectory({ directory: '/repo', sessions: [session('ses_a', 10)], cursor: null, hasMore: false });
372
+ expect(service.setPinned('ses_a', 88)).toBe(true);
373
+
374
+ service.upsert(session('ses_a', 30));
375
+
376
+ expect(service.snapshot().directories[0].sessions[0].time.pinned).toBe(88);
377
+ service.close();
378
+ });
379
+
380
+ it('removes pinned rows when an archived upsert deletes the session', () => {
381
+ const runtimeRef = { value: 'http://runtime-a.test' };
382
+ const service = createService(runtimeRef);
383
+ service.replaceDirectory({ directory: '/repo', sessions: [session('ses_a', 10)], cursor: null, hasMore: false });
384
+ expect(service.setPinned('ses_a', 99)).toBe(true);
385
+
386
+ expect(service.upsert({ ...session('ses_a', 11), time: { created: 9, updated: 11, archived: 12 } })).toBe(true);
387
+ expect(service.snapshot().directories[0].sessions).toEqual([]);
388
+ expect(service.clearPinned('ses_a')).toBe(false);
389
+ service.close();
390
+ });
321
391
  });
@@ -5,10 +5,11 @@ conversation's **main subject** (overall feature / goal) with the small model
5
5
  (`lib/small-model`), then PATCHes `title` plus `metadata.openchamber.titleRefresh`.
6
6
 
7
7
  OpenCode only auto-titles once from the first user message
8
- (`SessionPrompt.ensureTitle`). Long sessions often need a refresh; this module
9
- keeps the sidebar title aligned with the durable work being done not the last
10
- wrap-up utterance like "commit and push"throttled to at most once per 5
11
- minutes per session.
8
+ (`SessionPrompt.ensureTitle`). This module auto-refreshes sparsely (first idle
9
+ of a new session, first newly-sent reply on a fork) and on explicit smart-title
10
+ requests, naming the durable work being done not the last wrap-up utterance
11
+ like "commit and push". Background auto refreshes still respect a 5-minute
12
+ throttle (`TITLE_THROTTLE_MS`) when a refresh is armed.
12
13
 
13
14
  ## Flow
14
15
 
@@ -16,19 +17,23 @@ minutes per session.
16
17
  fan-out (`index.js` → `globalMessageStreamHub.subscribeEvent`), same
17
18
  pattern as session-assist. Purely event-driven — dormant sessions never
18
19
  generate anything.
19
- 2. A newly observed root `session.created` generates its first title immediately
20
- on the first `session.status: idle`. A fork title (`(fork #n)`) waits for its
21
- first newly-created user message; the matching assistant completion triggers
22
- an immediate title refresh that bypasses inherited title metadata and throttle.
23
- Later idle transitions arm a 15-second quiet timer; any `busy`/`retry` status
24
- or a fresh user `message.updated` clears it.
25
- A sidebar smart-title request sets `titleRefresh.requestedAt`; its
26
- `session.updated` event arms the same flow immediately.
20
+ 2. Auto title refresh is intentionally sparse (title stability first). A newly
21
+ observed root `session.created` generates its first title immediately on the
22
+ first `session.status: idle`. A fork title (`(fork #n)`) waits for its first
23
+ newly-created user message; the matching assistant completion triggers an
24
+ immediate title refresh that bypasses inherited title metadata and throttle.
25
+ Ordinary later idle transitions do **not** arm another refresh. Any
26
+ `busy`/`retry` status or a fresh user `message.updated` still clears an
27
+ already-armed timer (so initial/fork timers cancel if the user keeps going).
28
+ A sidebar smart-title request sets `titleRefresh.requestedAt`; its
29
+ `session.updated` event arms the same flow immediately (forced / manual
30
+ refresh is unaffected by the background gate).
27
31
  3. On fire:
28
32
  - Skip when Settings → Chat → session title refresh is off.
29
33
  - Skip system-owned sessions whose metadata carries a non-empty
30
- `openchamber.assistant.assistantID` or `openchamber.scheduledTask.taskID`
31
- (fixed Assistant / scheduled titles must not be rewritten). Early
34
+ `openchamber.assistant.assistantID`, `openchamber.scheduledTask.taskID`, or
35
+ `openchamber.smallModel.purpose`
36
+ (fixed Assistant / scheduled / small-model titles must not be rewritten). Early
32
37
  `session.created` and smart-title request extraction skip the same
33
38
  metadata when present so timers are not armed.
34
39
  - Skip sub-agent sessions (`parentID`), multi-run/fusion structural titles,