@kabmo-labs/kabmo 0.21.0 → 0.22.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 (295) hide show
  1. package/README.md +7 -2
  2. package/dist/client/index.html +9 -8
  3. package/dist/client/index.js +334 -334
  4. package/dist/client/static/js/{index-zg32n2sk.js → index-297dck9a.js} +784 -791
  5. package/dist/client/static/js/index-7ppta1pb.css +1 -0
  6. package/extensions/kabmo-modes/commands.ts +17 -3
  7. package/extensions/kabmo-modes/goal-start.ts +101 -0
  8. package/extensions/kabmo-modes/goal.test.ts +80 -5
  9. package/extensions/kabmo-modes/goal.ts +13 -38
  10. package/extensions/kabmo-modes/prompts.test.ts +12 -0
  11. package/extensions/kabmo-modes/prompts.ts +9 -2
  12. package/index.html +8 -7
  13. package/package.json +2 -2
  14. package/src/cli/lib/args.js +9 -0
  15. package/src/cli/lib/args.test.js +26 -0
  16. package/src/cli/lib/commands/doctor.js +153 -0
  17. package/src/cli/lib/commands/doctor.test.js +139 -0
  18. package/src/cli/lib/commands/serve.js +23 -10
  19. package/src/cli/lib/commands/status.js +22 -3
  20. package/src/cli/lib/omp-setup.js +131 -0
  21. package/src/cli/lib/omp-setup.test.js +115 -0
  22. package/src/cli/main.js +1 -1
  23. package/src/client/components/common/DemoDataBadge.tsx +52 -0
  24. package/src/client/components/common/FolderPicker.tsx +2 -2
  25. package/src/client/components/common/Modal.tsx +15 -1
  26. package/src/client/components/common/code-surface/blame-panel.ts +1 -1
  27. package/src/client/components/common/context-usage-button/index.test.tsx +1 -1
  28. package/src/client/components/common/context-usage-button/index.tsx +4 -4
  29. package/src/client/components/common/demo-data-badge.test.tsx +58 -0
  30. package/src/client/components/common/diagram-viewer/index.tsx +2 -2
  31. package/src/client/components/common/editor-view-buttons/index.tsx +2 -2
  32. package/src/client/components/common/header-controls/MoreMenu.tsx +1 -1
  33. package/src/client/components/common/header-controls/index.tsx +4 -1
  34. package/src/client/components/common/markdown-review/ReviewPopover.tsx +2 -2
  35. package/src/client/components/common/markdown-review/ReviewSummary.tsx +1 -1
  36. package/src/client/components/common/panel-mark/index.tsx +2 -1
  37. package/src/client/components/common/server-control/Panel.tsx +3 -3
  38. package/src/client/components/common/server-control/index.tsx +1 -1
  39. package/src/client/components/common/shell-update-button/Modal.tsx +1 -1
  40. package/src/client/components/common/todo-row/index.tsx +1 -1
  41. package/src/client/components/layout/ActivityBar.tsx +4 -0
  42. package/src/client/components/layout/ShellNotice.tsx +33 -0
  43. package/src/client/components/layout/desktop-layout/index.tsx +14 -16
  44. package/src/client/components/layout/desktop-layout/resizer/index.tsx +14 -1
  45. package/src/client/components/layout/session-sidebar/CategoryHeader.tsx +2 -1
  46. package/src/client/components/layout/session-sidebar/ClassicView.tsx +5 -1
  47. package/src/client/components/layout/session-sidebar/SessionList.tsx +1 -1
  48. package/src/client/components/layout/session-sidebar/SessionListNotice.tsx +56 -0
  49. package/src/client/components/layout/session-sidebar/SessionsView.tsx +2 -0
  50. package/src/client/components/layout/session-sidebar/about-modal/UpdateSection.tsx +1 -1
  51. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +12 -1
  52. package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +2 -1
  53. package/src/client/components/layout/session-sidebar/modern/index.tsx +6 -2
  54. package/src/client/components/layout/session-sidebar/new-workspace-modal/CloneField.tsx +1 -1
  55. package/src/client/components/layout/session-sidebar/new-workspace-modal/index.tsx +2 -2
  56. package/src/client/components/layout/session-sidebar/scheduler-modal/TaskForm.tsx +1 -1
  57. package/src/client/components/layout/session-sidebar/scheduler-modal/TaskList.tsx +3 -3
  58. package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +1 -1
  59. package/src/client/components/layout/session-sidebar/session-list-states.test.tsx +150 -0
  60. package/src/client/components/layout/session-sidebar/variant-props.ts +6 -0
  61. package/src/client/components/mobile/LayoutWrapper.tsx +20 -30
  62. package/src/client/components/mobile/MainView.tsx +5 -2
  63. package/src/client/components/mobile/RightSidebar.tsx +1 -1
  64. package/src/client/components/mobile/SessionSidebar.tsx +3 -0
  65. package/src/client/components/mobile/mobile-main-view/Header.tsx +2 -2
  66. package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +7 -1
  67. package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +1 -1
  68. package/src/client/components/settings/Modal.tsx +15 -1
  69. package/src/client/components/settings/ProjectSelectorDropdown.tsx +1 -1
  70. package/src/client/components/settings/Sidebar.tsx +2 -2
  71. package/src/client/components/settings/categories/OmpSettings.tsx +1 -1
  72. package/src/client/components/settings/categories/TokenUsageSettings.tsx +1 -1
  73. package/src/client/components/settings/categories/agent-settings/DetailPane.tsx +3 -3
  74. package/src/client/components/settings/categories/appearance-settings/EditorFontSection.tsx +1 -1
  75. package/src/client/components/settings/categories/appearance-settings/EditorThemeSection.tsx +2 -2
  76. package/src/client/components/settings/categories/appearance-settings/IconStyleSection.tsx +5 -5
  77. package/src/client/components/settings/categories/appearance-settings/SidebarStyleSection.tsx +1 -1
  78. package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.tsx +1 -1
  79. package/src/client/components/settings/categories/appearance-settings/ThemeCard.tsx +1 -1
  80. package/src/client/components/settings/categories/chat-settings/ComposerStyleSection.tsx +1 -1
  81. package/src/client/components/settings/categories/chat-settings/GoalSection.tsx +1 -1
  82. package/src/client/components/settings/categories/command-settings/DetailPane.tsx +2 -2
  83. package/src/client/components/settings/categories/omp-settings/ConfigTabs.tsx +5 -5
  84. package/src/client/components/settings/categories/omp-settings/EngineHeader.tsx +3 -3
  85. package/src/client/components/settings/categories/omp-settings/RoleRow.tsx +2 -2
  86. package/src/client/components/settings/categories/panel-plugins/LeftDockSettings.tsx +1 -1
  87. package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +1 -1
  88. package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +4 -3
  89. package/src/client/components/settings/categories/plugin-settings/SidebarList.tsx +2 -2
  90. package/src/client/components/settings/categories/project-settings/AddProjectModal.tsx +1 -1
  91. package/src/client/components/settings/categories/project-settings/NameInput.tsx +1 -1
  92. package/src/client/components/settings/categories/project-settings/PathField.tsx +1 -1
  93. package/src/client/components/settings/categories/provider-settings/AddModelModal.tsx +3 -3
  94. package/src/client/components/settings/categories/provider-settings/AddProviderModal.tsx +1 -1
  95. package/src/client/components/settings/categories/provider-settings/AuthSection.tsx +2 -2
  96. package/src/client/components/settings/categories/provider-settings/DeleteProviderModal.tsx +1 -1
  97. package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +4 -4
  98. package/src/client/components/settings/categories/provider-settings/EntryModal.tsx +2 -2
  99. package/src/client/components/settings/categories/provider-settings/LoginModal.tsx +1 -1
  100. package/src/client/components/settings/categories/provider-settings/ModelCapabilitiesModal.tsx +1 -1
  101. package/src/client/components/settings/categories/provider-settings/ModelsList.tsx +2 -2
  102. package/src/client/components/settings/categories/provider-settings/PriceFields.tsx +1 -1
  103. package/src/client/components/settings/categories/token-usage-settings/Breakdown.tsx +4 -4
  104. package/src/client/components/settings/categories/token-usage-settings/Chart.tsx +2 -2
  105. package/src/client/components/settings/categories/token-usage-settings/Controls.tsx +1 -1
  106. package/src/client/components/settings/categories/token-usage-settings/MetricsGrid.tsx +1 -1
  107. package/src/client/components/settings/categories/usage-settings/KenariCard.tsx +5 -5
  108. package/src/client/components/workspace/browser-panel/AddressBar.tsx +1 -1
  109. package/src/client/components/workspace/browser-panel/Screencast.tsx +6 -6
  110. package/src/client/components/workspace/browser-panel/TabStrip.tsx +1 -1
  111. package/src/client/components/workspace/browser-panel/index.tsx +1 -1
  112. package/src/client/components/workspace/browser-toolbar/index.tsx +5 -5
  113. package/src/client/components/workspace/chat-timeline/AttachmentChips.tsx +1 -1
  114. package/src/client/components/workspace/chat-timeline/GeneratingIndicator.tsx +13 -26
  115. package/src/client/components/workspace/chat-timeline/GoalNotice.tsx +2 -2
  116. package/src/client/components/workspace/chat-timeline/MessageItem.tsx +1 -1
  117. package/src/client/components/workspace/chat-timeline/MinimapShortcuts.tsx +1 -1
  118. package/src/client/components/workspace/chat-timeline/QueueList.tsx +1 -1
  119. package/src/client/components/workspace/chat-timeline/SubagentView.tsx +1 -1
  120. package/src/client/components/workspace/chat-timeline/SystemNotice.tsx +5 -5
  121. package/src/client/components/workspace/chat-timeline/TaskResultContent.tsx +2 -2
  122. package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +4 -4
  123. package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +1 -1
  124. package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +1 -1
  125. package/src/client/components/workspace/chat-timeline/chat-input/ArmedGoalStrip.tsx +71 -0
  126. package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +4 -3
  127. package/src/client/components/workspace/chat-timeline/chat-input/GoalBanner.test.ts +1 -1
  128. package/src/client/components/workspace/chat-timeline/chat-input/GoalBanner.tsx +3 -3
  129. package/src/client/components/workspace/chat-timeline/chat-input/GoalModal.test.ts +176 -0
  130. package/src/client/components/workspace/chat-timeline/chat-input/GoalModal.tsx +70 -81
  131. package/src/client/components/workspace/chat-timeline/chat-input/GoalSurfaces.tsx +10 -1
  132. package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.test.ts +20 -0
  133. package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.tsx +13 -7
  134. package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +1 -1
  135. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.test.ts +65 -3
  136. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +69 -19
  137. package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +2 -2
  138. package/src/client/components/workspace/chat-timeline/chat-input/composer-portal.test.tsx +174 -0
  139. package/src/client/components/workspace/chat-timeline/chat-input/goal-modal-parts.tsx +80 -0
  140. package/src/client/components/workspace/chat-timeline/chat-input/modes-props.ts +15 -3
  141. package/src/client/components/workspace/chat-timeline/chat-input/styles.test.tsx +3 -1
  142. package/src/client/components/workspace/chat-timeline/plan-review/index.tsx +1 -1
  143. package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +1 -1
  144. package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +1 -1
  145. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FrameControl.tsx +1 -1
  146. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/OptionRow.tsx +1 -1
  147. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/OrphanAsks.tsx +1 -1
  148. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionBlock.tsx +2 -2
  149. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionCard.tsx +4 -4
  150. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.tsx +2 -2
  151. package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/Header.tsx +1 -1
  152. package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/SelectBody.tsx +1 -1
  153. package/src/client/components/workspace/chat-timeline/tool-renderers/hashline-patch/index.tsx +4 -4
  154. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/AstEdit.tsx +6 -6
  155. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.tsx +13 -13
  156. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Checkpoint.tsx +1 -1
  157. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/ContextNotes.tsx +2 -2
  158. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Debug.tsx +3 -3
  159. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Edit.tsx +9 -9
  160. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Eval.tsx +10 -10
  161. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/FileMatches.tsx +1 -1
  162. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Goal.tsx +5 -5
  163. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/GoalRecord.tsx +5 -5
  164. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Lsp.tsx +6 -6
  165. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/ManageSkill.tsx +5 -5
  166. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Mcp.tsx +2 -2
  167. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Memory.tsx +3 -3
  168. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Proc.tsx +15 -15
  169. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +2 -2
  170. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Resolve.tsx +4 -4
  171. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/SearchFs.tsx +2 -2
  172. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/SearchTool.tsx +1 -1
  173. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/SecurityScan.tsx +4 -4
  174. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/TaskResult.tsx +7 -7
  175. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Think.tsx +2 -2
  176. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Todo.tsx +2 -2
  177. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.missing.test.ts +4 -2
  178. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +17 -17
  179. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/WebSearch.tsx +3 -3
  180. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ArtifactChip.tsx +1 -1
  181. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/EnvelopeHeader.tsx +2 -2
  182. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ExcerptCode.tsx +3 -3
  183. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/FallbackOutput.tsx +3 -3
  184. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/JsonCodeBlock.tsx +3 -3
  185. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/OutputWindow.tsx +2 -2
  186. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody.tsx +2 -2
  187. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolFactChips.tsx +2 -2
  188. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolPanelHeader.tsx +1 -1
  189. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Minimal.tsx +1 -1
  190. package/src/client/components/workspace/context-panel/RawJsonViewer.tsx +2 -2
  191. package/src/client/components/workspace/context-panel/StatsGrid.tsx +1 -1
  192. package/src/client/components/workspace/context-panel/index.tsx +1 -1
  193. package/src/client/components/workspace/diff-panel/ConflictBanner.tsx +1 -1
  194. package/src/client/components/workspace/editor/EmptyEditor.tsx +1 -1
  195. package/src/client/components/workspace/editor/FindWidget.tsx +1 -1
  196. package/src/client/components/workspace/editor/Tabs.tsx +1 -1
  197. package/src/client/components/workspace/editor/Toolbar.tsx +1 -1
  198. package/src/client/components/workspace/file-explorer/OutlineSection.tsx +2 -2
  199. package/src/client/components/workspace/file-explorer/RowLabel.tsx +1 -1
  200. package/src/client/components/workspace/file-explorer/index.tsx +1 -1
  201. package/src/client/components/workspace/git-panel/BranchToolbar.tsx +2 -2
  202. package/src/client/components/workspace/git-panel/ChangesList.tsx +3 -3
  203. package/src/client/components/workspace/git-panel/ConflictItem.tsx +3 -3
  204. package/src/client/components/workspace/git-panel/FileItem.tsx +2 -2
  205. package/src/client/components/workspace/git-panel/StashSection.tsx +5 -5
  206. package/src/client/components/workspace/git-panel/TreeItem.tsx +2 -2
  207. package/src/client/components/workspace/git-panel/branch-modal/BranchRow.tsx +4 -4
  208. package/src/client/components/workspace/git-panel/branch-modal/DeleteDialog.tsx +2 -2
  209. package/src/client/components/workspace/git-panel/index.tsx +1 -1
  210. package/src/client/components/workspace/model-dropdown/Item.tsx +3 -3
  211. package/src/client/components/workspace/model-dropdown/Section.tsx +1 -1
  212. package/src/client/components/workspace/model-dropdown/index.tsx +3 -3
  213. package/src/client/components/workspace/plan-panel/index.tsx +2 -2
  214. package/src/client/components/workspace/repo-picker/Modal.tsx +1 -1
  215. package/src/client/components/workspace/repo-picker/Row.tsx +6 -6
  216. package/src/client/components/workspace/search-panel/Body.tsx +2 -2
  217. package/src/client/components/workspace/search-panel/Results.tsx +1 -1
  218. package/src/client/components/workspace/search-panel/index.tsx +1 -1
  219. package/src/client/components/workspace/terminal-panel/index.tsx +1 -1
  220. package/src/client/components/workspace/todo-panel/PhaseGroup.tsx +1 -1
  221. package/src/client/components/workspace/todo-panel/index.tsx +2 -2
  222. package/src/client/components/workspace/user-browser-panel/AddressBar.tsx +5 -5
  223. package/src/client/components/workspace/user-browser-panel/AnnotateBar.test.tsx +13 -13
  224. package/src/client/components/workspace/user-browser-panel/AnnotateBar.tsx +4 -4
  225. package/src/client/components/workspace/user-browser-panel/AnnotateLayer.tsx +1 -1
  226. package/src/client/components/workspace/user-browser-panel/AnnotateTarget.tsx +7 -7
  227. package/src/client/components/workspace/user-browser-panel/Frame.tsx +1 -1
  228. package/src/client/components/workspace/wiki-panel/Nav.tsx +1 -1
  229. package/src/client/components/workspace/wiki-panel/index.tsx +2 -2
  230. package/src/client/glass.css +50 -0
  231. package/src/client/glass.test.ts +68 -24
  232. package/src/client/hooks/chat/composer/browser-context.test.ts +6 -6
  233. package/src/client/hooks/chat/composer/use-draft.test.ts +2 -2
  234. package/src/client/hooks/chat/omp/prompt-send.test.ts +36 -0
  235. package/src/client/hooks/chat/omp/prompt-send.ts +24 -18
  236. package/src/client/hooks/chat/omp/session-list.tsx +24 -70
  237. package/src/client/hooks/chat/omp/session-merges.ts +89 -0
  238. package/src/client/hooks/chat/omp/session-sidebar-controller.ts +4 -1
  239. package/src/client/hooks/chat/timeline/armed-goal-send.test.ts +168 -0
  240. package/src/client/hooks/chat/timeline/armed-goal.test.ts +178 -0
  241. package/src/client/hooks/chat/timeline/goal-command.ts +57 -27
  242. package/src/client/hooks/chat/timeline/index.ts +7 -4
  243. package/src/client/hooks/chat/timeline/mode-post.ts +46 -0
  244. package/src/client/hooks/chat/timeline/modes-contract.ts +94 -0
  245. package/src/client/hooks/chat/timeline/modes.ts +60 -95
  246. package/src/client/hooks/chat/timeline/send-props.ts +97 -0
  247. package/src/client/hooks/chat/timeline/send-steer.test.ts +6 -0
  248. package/src/client/hooks/chat/timeline/send.test-util.ts +55 -8
  249. package/src/client/hooks/chat/timeline/send.test.ts +17 -1
  250. package/src/client/hooks/chat/timeline/send.ts +64 -72
  251. package/src/client/hooks/ui/dialog-behaviour.ts +143 -0
  252. package/src/client/hooks/ui/theme.ts +17 -0
  253. package/src/client/hooks/workspace/copy-tab-path.ts +23 -0
  254. package/src/client/hooks/workspace/mobile-back.ts +71 -0
  255. package/src/client/palette-class.test.ts +93 -0
  256. package/src/client/tailwind-contrast.test.ts +194 -0
  257. package/src/client/tailwind.css +327 -8
  258. package/src/server/lib/assets/theme-shell.server.ts +4 -10
  259. package/src/server/lib/omp/config/provider-seeds.test.ts +39 -1
  260. package/src/server/lib/omp/config/provider-seeds.ts +32 -3
  261. package/src/server/lib/omp/config/provider-vision-compat.test.ts +140 -0
  262. package/src/server/lib/omp/core/host-resolution.test.ts +1 -55
  263. package/src/server/lib/omp/core/install-hint.test.ts +48 -0
  264. package/src/server/lib/omp/core/install-hint.ts +64 -0
  265. package/src/server/lib/omp/core/startup.test.ts +125 -0
  266. package/src/server/lib/omp/core/startup.ts +5 -1
  267. package/src/server/lib/omp/mode/request.ts +14 -6
  268. package/src/server/plugins/ssr.ts +2 -1
  269. package/src/shared/lib/browser/annotate.test.ts +22 -22
  270. package/src/shared/lib/browser/annotate.ts +14 -14
  271. package/src/shared/lib/browser/page-context.ts +6 -6
  272. package/src/shared/lib/icons/icon-paint-authority.test.ts +86 -0
  273. package/src/shared/lib/icons/icon-paint-authority.ts +94 -0
  274. package/src/shared/lib/icons/icon-paint-css.test.ts +139 -25
  275. package/src/shared/lib/icons/icon-paint-css.ts +76 -50
  276. package/src/shared/lib/icons/icon-paint-panel.ts +15 -18
  277. package/src/shared/lib/icons/icon-paint-weight.ts +142 -0
  278. package/src/shared/lib/icons/icon-tone.ts +58 -13
  279. package/src/shared/lib/icons/tint-hues.generated.ts +51 -6
  280. package/src/shared/lib/icons/tint-tones.test.ts +257 -0
  281. package/src/shared/lib/icons/tint.test.ts +3 -211
  282. package/src/shared/lib/icons/tint.ts +23 -25
  283. package/src/shared/lib/omp/mode/actions.ts +40 -0
  284. package/src/shared/lib/omp/mode/types.ts +12 -0
  285. package/src/shared/lib/theme/css.ts +21 -0
  286. package/src/shared/lib/theme/first-frame.ts +38 -0
  287. package/src/shared/lib/theme/ink-scale.test.ts +151 -0
  288. package/src/shared/lib/theme/ink-scale.ts +103 -0
  289. package/src/shared/lib/theme/shell-palette.test.ts +22 -5
  290. package/src/shared/lib/theme/shell-palette.ts +9 -4
  291. package/src/shared/lib/theme/theme.test.ts +28 -3
  292. package/src/shared/lib/workspace/project-accent.test.ts +33 -1
  293. package/src/shared/lib/workspace/project-accent.ts +23 -0
  294. package/src/shared/types/omp/agent.ts +24 -9
  295. package/dist/client/static/js/index-0721wrkf.css +0 -1
@@ -234,6 +234,21 @@
234
234
  * to 2.88:1 while 92% holds 4.59:1, because bright code behind a menu is what
235
235
  * a dark theme actually has under it. */
236
236
  --glass-popover: color-mix(in srgb, var(--theme-paper) 84%, transparent);
237
+ /* The fill for a popover that CANNOT blur: one nested inside another frosted
238
+ * surface, which is a backdrop root (see the rule near the bottom of this
239
+ * file). Declared here, surface-independent, because the composer's `glass`
240
+ * style is offered in the classic look too.
241
+ *
242
+ * **OPAQUE, and the number is a measurement rather than a preference.** With
243
+ * no blur the panel is a straight alpha over its backdrop, so every percent of
244
+ * transparency is readable text behind a list of model names. Measured with
245
+ * ghost text painted exactly behind the panel: 84% left it at `1.47:1`, 92%
246
+ * `1.21:1`, 96% `1.10:1` — all still legible in the screenshot. This is the
247
+ * file's own rule ("a raised surface that is READ keeps its own opaque
248
+ * `bg-paper`"), and a dropdown is the most-read surface there is. The material
249
+ * still reads as glass through the sheen, the rim and the bloom, which is
250
+ * where a pane is legible anyway. */
251
+ --glass-popover-nested: var(--theme-paper);
237
252
  /* A STUCK sticky header's fill — see `.glass-sticky[data-stuck]`.
238
253
  *
239
254
  * OPAQUE, and mixed toward the CANVAS, not transparent. Two measured reasons.
@@ -712,6 +727,39 @@
712
727
  background-color: var(--glass-popover);
713
728
  }
714
729
 
730
+ /*
731
+ * A popover NESTED in another frosted surface cannot lean on its blur, so its
732
+ * fill has to carry the legibility by itself.
733
+ *
734
+ * `backdrop-filter` makes an element a BACKDROP ROOT: a descendant's filter
735
+ * samples that ancestor's painted output, not the page. The composer card is
736
+ * `[data-composer-style="glass"]`, whose own `backdrop-filter:
737
+ * var(--glass-card-filter)` IS the material — so the model dropdown (with the
738
+ * thinking and access panels and the specs card beside it) ran a `blur(24px)`
739
+ * that sampled nothing. Measured on the real dropdown over 6px black/white
740
+ * stripes: inside the card the stripes stayed at min/max `0/255` (variance
741
+ * 16216), while the same panel portalled to `<body>` read `221/224` (variance
742
+ * 0.7). The panel was therefore a straight alpha over RAW content, and a
743
+ * transcript showing through measured `1.47:1` — reported as the composer's
744
+ * model dropdown being "terlalu transparan sehingga teks tidak terlihat ketika
745
+ * di belakannya ada teks juga". Raising the tint alone did not fix it: 92%
746
+ * measured `1.21:1` and 96% `1.10:1`, both still readable in a screenshot.
747
+ *
748
+ * So this tier takes the file's own answer for a surface that is READ: the
749
+ * palette's opaque paper. The sheen, the rim and the bloom still paint at full
750
+ * strength, so it still reads as glass at its edges — which is where a pane is
751
+ * legible anyway.
752
+ *
753
+ * The scope is the composer card ONLY. A popover that hangs in `<body>` (every
754
+ * `AnchoredMenu`, the settings menus) keeps `--glass-popover`: there the blur IS
755
+ * alive, and 84% measured free. A dialog is not the same case either — its own
756
+ * 96% tint and the veil already flatten what it covers, verified with the same
757
+ * stripe probe.
758
+ */
759
+ [data-surface="glass"] [data-composer-style="glass"] .glass-popover {
760
+ background-color: var(--glass-popover-nested);
761
+ }
762
+
715
763
  /* A browser that cannot blur, or a user who asked for less transparency: the
716
764
  * opaque palette. `--glass-panel` IS the plane's fill, so overriding it here
717
765
  * also fixes the sheen's contrast, which is why the sheen is switched off too.
@@ -741,6 +789,7 @@
741
789
  --glass-chrome: var(--theme-paper);
742
790
  --glass-overlay: var(--theme-paper);
743
791
  --glass-popover: var(--theme-paper);
792
+ --glass-popover-nested: var(--theme-paper);
744
793
  --glass-card: var(--theme-paper);
745
794
  --glass-stuck: var(--theme-paper);
746
795
  --glass-bloom: none;
@@ -769,6 +818,7 @@
769
818
  --glass-chrome: var(--theme-paper);
770
819
  --glass-overlay: var(--theme-paper);
771
820
  --glass-popover: var(--theme-paper);
821
+ --glass-popover-nested: var(--theme-paper);
772
822
  --glass-card: var(--theme-paper);
773
823
  --glass-stuck: var(--theme-paper);
774
824
  --glass-bloom: none;
@@ -9,18 +9,17 @@ import { mixHex } from '@/shared/lib/theme/color';
9
9
  import { contrastRatio } from '@/shared/lib/theme/legibility';
10
10
 
11
11
  /**
12
- * The composer's `glass` style is a STYLE, not a surface style: it is offered in
13
- * the classic look too, where `[data-surface="glass"]` is not set. A `--glass-*`
14
- * token that is only declared inside that attribute block therefore does not
15
- * exist for the composer, and `background-color: var(--glass-card)` silently
16
- * computes to `rgba(0,0,0,0)` — a card with no fill at all. That is not
17
- * hypothetical: it shipped for the length of one edit, and the browser reported
18
- * it as a transparent composer while `getComputedStyle` on the token returned an
12
+ * The composer's `glass` STYLE is not a surface style: it is offered in the
13
+ * classic look too, where `[data-surface="glass"]` is not set. A `--glass-*`
14
+ * token declared only inside that attribute block therefore does not exist for
15
+ * the composer, and `background-color: var(--glass-card)` silently computes to
16
+ * `rgba(0,0,0,0)` — a card with no fill. That shipped for the length of one
17
+ * edit: a transparent composer while `getComputedStyle` on the token returned an
19
18
  * empty string.
20
19
  *
21
- * This asserts the shape of the contract rather than one value: every material
22
- * token the composer rule READS has to be declared where the rule can see it,
23
- * i.e. in `:root` (or a variant block), never only under the surface attribute.
20
+ * So this asserts the SHAPE of the contract, not one value: every material token
21
+ * the composer rule READS must be declared where the rule can see it — `:root`
22
+ * or a variant block, never only under the surface attribute.
24
23
  */
25
24
  const read = (file: string): Promise<string> => Bun.file(new URL(file, import.meta.url)).text();
26
25
 
@@ -91,11 +90,11 @@ describe('glass composer material', () => {
91
90
  });
92
91
 
93
92
  /**
94
- * The popover tier is the same argument as the composer's, one size down: a
95
- * dropdown that carries only a tint reads as a LIFTED BOX, because on a dark
96
- * palette a translucent paper only ever darkens it. Measured on the
97
- * session-actions menu before the bloom — corner `(56,61,71)` over a body of
98
- * `(41,44,52)` on a sidebar of `(51,58,67)`, 1.09:1 against what it covers.
93
+ * The popover tier is the composer's argument one size down: a dropdown carrying
94
+ * only a tint reads as a LIFTED BOX, because on a dark palette translucent paper
95
+ * only ever darkens it. Measured on the session-actions menu before the bloom —
96
+ * corner `(56,61,71)` over a body of `(41,44,52)` on a sidebar of `(51,58,67)`,
97
+ * 1.09:1 against what it covers.
99
98
  */
100
99
  describe('glass popover material', () => {
101
100
  test('the popover adds its own bloom on top of the shared material', async () => {
@@ -116,8 +115,7 @@ describe('glass popover material', () => {
116
115
  expect(sharedBody).toContain('background-image: linear-gradient(');
117
116
 
118
117
  // A dialog keeps the sheen and the rim it was measured with: a dialog has
119
- // prose in the middle, and the bloom's whole point is that it stays in the
120
- // corners — which a dialog cannot afford to guess at.
118
+ // prose in the middle, and the bloom stays in the corners.
121
119
  expect(tailwind).toContain('[data-composer-style="glass"]');
122
120
  });
123
121
 
@@ -129,13 +127,62 @@ describe('glass popover material', () => {
129
127
  expect(menu).toContain('glass-popover fixed');
130
128
  expect(list).toContain('glass-popover fixed');
131
129
  });
130
+
131
+ /**
132
+ * The `/` and `@` lists are the composer's own popovers and render INSIDE
133
+ * `[data-composer-style="glass"]`, exactly where a blur is dead, so the nested
134
+ * tier has to reach them. The picker is a plain div, not an `AnchoredMenu`, so
135
+ * the tier is a literal in its className — and that class is what makes the
136
+ * list a popover at all in the glass surface.
137
+ */
138
+ test('the composer picker carries the popover tier', async () => {
139
+ const picker = await read('./components/common/ComposerPicker.tsx');
140
+ expect(picker).toContain('glass-popover');
141
+ });
142
+
143
+ /**
144
+ * A popover INSIDE another frosted surface has no working blur:
145
+ * `backdrop-filter` makes its host a backdrop root, so the descendant's filter
146
+ * samples that host, not the page. Measured on the composer's model dropdown
147
+ * over 6px black/white stripes — min/max `0/255` (variance 16216) nested in the
148
+ * glass card against `221/224` (variance 0.7) portalled to `<body>`; text
149
+ * behind it measured `1.47:1` and was still readable at 96%.
150
+ *
151
+ * So the NESTED tier is OPAQUE, scoped to the composer card, so a
152
+ * body-portalled menu keeps its 84% with a live blur.
153
+ */
154
+ test('a popover nested in a frosted surface is opaque, and only there', async () => {
155
+ const glass = await read('./glass.css');
156
+ const surface = ruleBody(glass, '[data-surface="glass"]');
157
+ const nested = ruleBody(glass, '[data-surface="glass"] [data-composer-style="glass"] .glass-popover');
158
+
159
+ // The rule reads a token, not a literal: a second recipe for the material is
160
+ // the defect every assertion in this file exists to prevent.
161
+ expect(nested).toContain('background-color: var(--glass-popover-nested)');
162
+ // Opaque paper: no blur hides the backdrop, and every percent of transparency
163
+ // is legible text behind a list of model names.
164
+ expect(surface).toContain('--glass-popover-nested: var(--theme-paper);');
165
+ // The blurred tier stays translucent — a body-portalled menu still blurs.
166
+ expect(surface).toContain('--glass-popover: color-mix(');
167
+
168
+ // A browser without `backdrop-filter`, or a reduced-transparency request,
169
+ // resolves every tint to solid paper — the nested token must be in BOTH
170
+ // blocks, or it keeps compositing a translucent panel with nothing behind.
171
+ for (const block of [
172
+ glass.slice(glass.indexOf('@supports not ('), glass.indexOf('@media (prefers-reduced-transparency')),
173
+ glass.slice(glass.indexOf('@media (prefers-reduced-transparency')),
174
+ ]) {
175
+ expect(block).toContain('--glass-popover-nested: var(--theme-paper);');
176
+ }
177
+ });
132
178
  });
133
179
 
134
180
  /**
135
181
  * A workspace column is the same chrome as the sidebar beside it. Every view
136
- * under it opens with its own `bg-paper` root, which is right in the classic look
137
- * and wrong under the glass surface — measured, the 293px column composited to
138
- * the palette's solid paper while the sidebar was the plane's chrome.
182
+ * under it opens with its own `bg-paper` root, right in the classic look and
183
+ * wrong under the glass surface — measured, the 293px column composited to the
184
+ * palette's solid paper while the sidebar was the plane's chrome ("right panel
185
+ * juga belum glass banget").
139
186
  */
140
187
  describe('glass column material', () => {
141
188
  test('a workspace column is chrome, and its view roots step aside for it', async () => {
@@ -143,10 +190,7 @@ describe('glass column material', () => {
143
190
  read('./glass.css'),
144
191
  read('./components/layout/desktop-layout/WorkspacePanels.tsx'),
145
192
  ]);
146
- // Measured: every right-panel view opens with its own `bg-paper` root, so the
147
- // 293px column composited to solid paper while the sidebar beside it was the
148
- // plane's chrome — two materials in one window ("right panel juga belum glass
149
- // banget"). The marker is on the SLOT (one owner), never on each view.
193
+ // The marker is on the SLOT (one owner), never on each view.
150
194
  expect(panels).toContain('data-panel-chrome=""');
151
195
  expect(panels).toContain('glass-chrome w-full h-full');
152
196
  expect(glass).toContain('[data-surface="glass"] [data-panel-chrome] > .bg-paper,');
@@ -72,7 +72,7 @@ describe('useBrowserPageContextInsert', () => {
72
72
  test('a plain page lands in the draft as the URL block', () => {
73
73
  mountBridge();
74
74
  act(() => emitBrowserPageContext({ url: 'https://a.test/x' }));
75
- expect(draft).toBe('[Konteks halaman browser]\nURL: https://a.test/x\n(Lanjutkan dari halaman ini.)');
75
+ expect(draft).toBe('[Browser page context]\nURL: https://a.test/x\n(Continue from this page.)');
76
76
  });
77
77
 
78
78
  test('an annotated page lands as the block with its numbered marks', () => {
@@ -82,16 +82,16 @@ describe('useBrowserPageContextInsert', () => {
82
82
  annotations: [{ id: 'a', tool: 'box', start: { x: 0.1, y: 0.1 }, end: { x: 0.2, y: 0.2 }, label: '', note: 'mati' }],
83
83
  panel: { width: 1000, height: 500, viewportMode: 'laptop', zoom: 100 },
84
84
  }));
85
- expect(draft).toContain('Anotasi (1):');
86
- expect(draft).toContain('1. kotak kiri 10.0%, atas 10.0%');
87
- expect(draft).toContain('— mati');
85
+ expect(draft).toContain('Annotations (1):');
86
+ expect(draft).toContain('1. box left 10.0%, top 10.0%');
87
+ expect(draft).toContain(': mati');
88
88
  });
89
89
 
90
90
  test('two events append two blocks rather than overwriting the draft', () => {
91
91
  mountBridge();
92
92
  act(() => emitBrowserPageContext({ url: 'https://a.test' }));
93
93
  act(() => emitBrowserPageContext({ url: 'https://b.test' }));
94
- expect(draft.match(/\[Konteks halaman browser\]/g)).toHaveLength(2);
94
+ expect(draft.match(/\[Browser page context\]/g)).toHaveLength(2);
95
95
  expect(draft).toContain('https://a.test');
96
96
  expect(draft).toContain('https://b.test');
97
97
  });
@@ -111,7 +111,7 @@ describe('useBrowserPageContextInsert', () => {
111
111
  annotations: [{ id: 'a', tool: 'box', start: { x: 1, y: 0 } } as never],
112
112
  panel: { width: 1000, height: 500, viewportMode: 'laptop', zoom: 100 },
113
113
  }));
114
- expect(draft).not.toContain('Anotasi');
114
+ expect(draft).not.toContain('Annotations');
115
115
  expect(draft).toContain('URL: https://a.test');
116
116
  });
117
117
  });
@@ -38,7 +38,7 @@ import type { ComposerDraftState } from '@/client/hooks/chat/composer/use-draft'
38
38
  import type { SessionStateContextValue } from '@/client/hooks/workspace/session-state/context';
39
39
 
40
40
  const LANDING_ID = '1';
41
- const SEEDED = '[Konteks halaman browser]\nURL: http://localhost:7801/\n(Lanjutkan dari halaman ini.)';
41
+ const SEEDED = '[Browser page context]\nURL: http://localhost:7801/\n(Continue from this page.)';
42
42
 
43
43
  let container: HTMLElement | undefined;
44
44
  let holder: { api: ComposerDraftState | null };
@@ -118,7 +118,7 @@ describe('useComposerDraft', () => {
118
118
  test('an annotation sent at the landing stays out of the persisted draft', () => {
119
119
  mount('');
120
120
  act(() => emitBrowserPageContext({ url: 'https://a.test/x' }));
121
- expect(holder.api!.inputValue).toContain('[Konteks halaman browser]');
121
+ expect(holder.api!.inputValue).toContain('[Browser page context]');
122
122
  expect(getSessionValue(LANDING_ID, CHAT_DRAFT_KEY)).toBeUndefined();
123
123
  });
124
124
 
@@ -202,6 +202,42 @@ describe('useOmpPromptSender.sendPrompt', () => {
202
202
  });
203
203
  });
204
204
 
205
+ describe('useOmpPromptSender.sendNewPrompt — ordering', () => {
206
+ const NEW = '/api/agent/new';
207
+
208
+ test('beforePrompt runs after the id exists and before the prompt', async () => {
209
+ const order: string[] = [];
210
+ const requests = installFetch({ [NEW]: { body: { success: true, sessionId: 'omp-5' } } });
211
+ const probe = mountSender(null);
212
+ // One extra hook: the prompt POST is the last call, so its ORDER is what
213
+ // the armed goal depends on — a goal created after it can miss the turn.
214
+ const original = (globalThis as unknown as Record<string, unknown>).fetch as typeof fetch;
215
+ (globalThis as unknown as Record<string, unknown>).fetch = (async (input: unknown, init?: { method?: string; body?: string }) => {
216
+ order.push(String(input));
217
+ return original(input as never, init as never);
218
+ }) as typeof fetch;
219
+
220
+ const result = await probe.sender().sendNewPrompt('first', '/w', undefined, {}, async (sid) => {
221
+ order.push(`goal:${sid}`);
222
+ return false;
223
+ });
224
+
225
+ expect(result).toEqual({ sessionId: 'omp-5', model: null });
226
+ expect(order).toEqual([NEW, 'goal:omp-5', '/api/agent/omp-5']);
227
+ expect(requests.length).toBe(2);
228
+ });
229
+
230
+ test('a spawn with no armed goal passes no hook at all', async () => {
231
+ const requests = installFetch({ [NEW]: { body: { success: true, sessionId: 'omp-6' } } });
232
+ const probe = mountSender(null);
233
+
234
+ // The goal-less path: exactly two requests (create + prompt), no third call.
235
+ await probe.sender().sendNewPrompt('first', '/w');
236
+
237
+ expect(requests.map((r) => r.url)).toEqual([NEW, '/api/agent/omp-6']);
238
+ });
239
+ });
240
+
205
241
  describe('useOmpPromptSender.sendNewPrompt', () => {
206
242
  const NEW = '/api/agent/new';
207
243
 
@@ -20,7 +20,7 @@ import { useCallback } from 'preact/hooks';
20
20
  import type { Dispatch, SetStateAction } from 'preact/compat';
21
21
  import { setSessionTitleHint } from '@/client/hooks/chat/omp/sidebar-overlay';
22
22
  import { redirectToOwningInstance, type SessionOwnerConflict } from '@/client/hooks/chat/omp/owner-redirect';
23
- import type { AgentImage, OmpAgentState, PromptDispatchResult } from '@/shared/types';
23
+ import type { AgentImage, OmpAgentState, PromptDispatchResult, SpawnOptions, SpawnedSession } from '@/shared/types';
24
24
  import type { ApprovalMode } from '@/shared/lib/omp/config/access-mode';
25
25
 
26
26
  export interface OmpPromptSenderDeps {
@@ -37,16 +37,19 @@ export interface OmpPromptSender {
37
37
  message: string,
38
38
  cwd: string,
39
39
  images?: AgentImage[],
40
- composerOptions?: {
41
- model?: { provider: string; modelId: string } | null;
42
- thinkingLevel?: string | null;
43
- accessMode?: ApprovalMode;
44
- /** Plan/goal picks made on the pending view. Applied through the spawn
45
- * ENVIRONMENT, because a brand-new session has no transcript for the
46
- * extension to restore from — see the route's `modes` handling. */
47
- modes?: { plan: boolean; goal: boolean } | null;
48
- },
49
- ) => Promise<{ sessionId: string; model: { provider: string; modelId: string } | null } | null>;
40
+ composerOptions?: SpawnOptions,
41
+ /**
42
+ * Runs once the session exists and its stream is attached, BEFORE the
43
+ * prompt is dispatched. The armed goal is started here: the record must
44
+ * exist before the turn it belongs to starts, and this is the only moment
45
+ * that is both after the id exists and before the prompt.
46
+ *
47
+ * Resolves TRUE when it CONSUMED the prompt — an armed interview renders
48
+ * its own opening turn with the operator's words folded in, so dispatching
49
+ * the raw message after it would be a second turn asking the same thing.
50
+ */
51
+ beforePrompt?: (sessionId: string) => Promise<boolean>,
52
+ ) => Promise<SpawnedSession | null>;
50
53
  }
51
54
 
52
55
  export function useOmpPromptSender(deps: OmpPromptSenderDeps): OmpPromptSender {
@@ -118,13 +121,9 @@ export function useOmpPromptSender(deps: OmpPromptSenderDeps): OmpPromptSender {
118
121
  message: string,
119
122
  cwd: string,
120
123
  images?: AgentImage[],
121
- composerOptions?: {
122
- model?: { provider: string; modelId: string } | null;
123
- thinkingLevel?: string | null;
124
- accessMode?: ApprovalMode;
125
- modes?: { plan: boolean; goal: boolean } | null;
126
- },
127
- ): Promise<{ sessionId: string; model: { provider: string; modelId: string } | null } | null> => {
124
+ composerOptions?: SpawnOptions,
125
+ beforePrompt?: (sessionId: string) => Promise<boolean>,
126
+ ): Promise<SpawnedSession | null> => {
128
127
  setState((prev) => ({ ...prev, isGenerating: true, error: null }));
129
128
  // The real id does not exist until `ensure_session` answers, so the mark
130
129
  // can only be armed past that point — the spawn itself is covered by the
@@ -162,6 +161,13 @@ export function useOmpPromptSender(deps: OmpPromptSenderDeps): OmpPromptSender {
162
161
  // first assistant message), so until then the row would read
163
162
  // `New Session - <clock>`. A hint only — the real row supersedes it.
164
163
  setSessionTitleHint(sid, message);
164
+ // The goal (when one is armed) is STARTED HERE — after the id exists,
165
+ // before the prompt — so the prompt below is its first turn. Awaiting it
166
+ // is what makes the order a fact rather than a race. An armed interview
167
+ // answers true: it already opened the turn, so this prompt is not sent.
168
+ if (beforePrompt && await beforePrompt(sid)) {
169
+ return { sessionId: sid, model: createdBody.model ?? null };
170
+ }
165
171
  const res = await fetch(`/api/agent/${encodeURIComponent(sid)}`, {
166
172
  method: 'POST',
167
173
  headers: { 'Content-Type': 'application/json' },
@@ -50,6 +50,17 @@ export interface SidebarDataHandle {
50
50
  isMock: boolean;
51
51
  /** True only before the first snapshot lands — drives the skeleton. */
52
52
  initializing: boolean;
53
+ /**
54
+ * The first snapshot never arrived and the channel is not connected: the
55
+ * list has no data and no answer is coming on its own.
56
+ *
57
+ * This is what separates "still loading" from "failed", and before it existed
58
+ * the sidebar could only tell them apart by waiting — measured with `/api/**`
59
+ * aborted, the skeleton was still drawn after seven seconds with no message,
60
+ * no retry and no `role="alert"`. A UI that cannot say "this did not work" is
61
+ * an unfinished UI, so the state is a field rather than an inferred flag.
62
+ */
63
+ failed: boolean;
53
64
  /** True when the socket is down or a sequence gap was seen. */
54
65
  stale: boolean;
55
66
  /**
@@ -100,81 +111,20 @@ export interface SidebarDataHandle {
100
111
 
101
112
  const SidebarDataContext = createContext<SidebarDataHandle | null>(null);
102
113
 
103
- /** Merge a structure payload with the volatile map, by session id. */
104
- function mergeStatus(
105
- folders: WorkspaceFolderData[],
106
- status: SidebarStatusPayload | null,
107
- ): WorkspaceFolderData[] {
108
- if (!status) return folders;
109
- return folders.map((folder) => ({
110
- ...folder,
111
- sessions: (folder.sessions ?? []).map((session) => {
112
- const volatile = status[String(session.id)];
113
- return volatile ? { ...session, ...volatile } : session;
114
- }),
115
- }));
116
- }
117
-
118
- /**
119
- * Advance each row's live fields from the activity payload.
120
- *
121
- * `sidebar:activity` carries only the RUNNING sessions (see its doc), so an id
122
- * it does not name keeps whatever the structure gave it. Three rules, each of
123
- * which is a way this can go wrong:
124
- *
125
- * - the `updated_at` comparison is what makes two sources safe to
126
- * interleave: the structure is re-scanned at every turn boundary and may
127
- * already carry a stamp this payload has not caught up with, and a late
128
- * activity frame must never move a row BACKWARDS (that reorders the
129
- * sidebar under the reader);
130
- * - `hasSubagents` only ever turns ON, because the payload is a live read of
131
- * what is on disk and a subagent transcript does not disappear when its run
132
- * ends — a `false` here is "not seen yet", not "none exist";
133
- * - nothing else is touched. Every other field of a row changes on a
134
- * STRUCTURAL event, and those publish the structure for their own reason.
135
- */
136
- function mergeActivity(
137
- folders: WorkspaceFolderData[],
138
- activity: SidebarActivityPayload | null,
139
- ): WorkspaceFolderData[] {
140
- if (!activity) return folders;
141
- let changed = false;
142
- const merged = folders.map((folder) => ({
143
- ...folder,
144
- sessions: (folder.sessions ?? []).map((session) => {
145
- const live = activity[String(session.id)];
146
- if (!live) return session;
147
- const updated_at = live.updatedAt && isNewerStamp(live.updatedAt, session.updated_at)
148
- ? live.updatedAt
149
- : session.updated_at;
150
- const hasSubagents = session.hasSubagents || live.hasSubagents === true;
151
- if (updated_at === session.updated_at && hasSubagents === Boolean(session.hasSubagents)) return session;
152
- changed = true;
153
- return { ...session, updated_at, hasSubagents };
154
- }),
155
- }));
156
- // A stable identity matters: the sidebar's own `useMemo` chain (filter, sort,
157
- // pending overlay) keys on this array, and returning a fresh one per activity
158
- // frame would re-sort 731 rows for a stamp that did not move.
159
- return changed ? merged : folders;
160
- }
161
-
162
- /** Whether `next` is a later ISO stamp than `current`. An absent current is older. */
163
- function isNewerStamp(next: string, current?: string): boolean {
164
- if (!current) return true;
165
- const nextMs = Date.parse(next);
166
- const currentMs = Date.parse(current);
167
- // An unparseable value on either side is not evidence of a newer stamp; the
168
- // structure's own field stays authoritative.
169
- if (!Number.isFinite(nextMs) || !Number.isFinite(currentMs)) return false;
170
- return nextMs > currentMs;
171
- }
114
+ import { mergeActivity, mergeStatus } from '@/client/hooks/chat/omp/session-merges';
172
115
 
173
116
  export function SidebarDataProvider({ children, initialFolders = [] }: { children: ReactNode; initialFolders?: WorkspaceFolderData[] }) {
174
117
  const structure = useRealtimeTopic<SidebarPayload>(TOPIC_SIDEBAR);
175
118
  const status = useRealtimeTopic<SidebarStatusPayload>(TOPIC_SIDEBAR_STATUS);
176
119
  const activity = useRealtimeTopic<SidebarActivityPayload>(TOPIC_SIDEBAR_ACTIVITY);
177
120
 
121
+ // "Loading" is only true while an answer is still plausible. The channel
122
+ // reports its own verdict, so a socket that closed before the first snapshot
123
+ // is a FAILED read rather than an eternal skeleton: measured with `/api/**`
124
+ // aborted, the drawer drew placeholders forever with nothing on screen saying
125
+ // why and no control to try again.
126
+ const failed = structure.data === null && structure.status === 'closed';
127
+
178
128
  // Session ids whose badge the user has already dismissed on this mount.
179
129
  // Optimistic strip: keeps the click→disappearance instant and stops the
180
130
  // pending ack effect in useSessionStatusAck from double-POSTing.
@@ -310,6 +260,7 @@ export function SidebarDataProvider({ children, initialFolders = [] }: { childre
310
260
  streamStatusMap,
311
261
  isMock,
312
262
  initializing,
263
+ failed,
313
264
  stale: structure.stale || status.stale,
314
265
  refresh,
315
266
  refreshNow,
@@ -320,7 +271,7 @@ export function SidebarDataProvider({ children, initialFolders = [] }: { childre
320
271
  titleHint: (id) => (id === null || id === undefined ? undefined : titleHintRef.current.get(String(id))),
321
272
  };
322
273
  // `overlayVersion` is the re-render trigger for the two refs above.
323
- }, [folders, isMock, initializing, structure.stale, status.stale, structure.refreshing, refresh, refreshNow, refreshing, isRefreshing, markSeen, overlayVersion]);
274
+ }, [folders, isMock, initializing, failed, structure.stale, status.stale, structure.refreshing, refresh, refreshNow, refreshing, isRefreshing, markSeen, overlayVersion]);
324
275
 
325
276
  return <SidebarDataContext.Provider value={value}>{children}</SidebarDataContext.Provider>;
326
277
  }
@@ -337,6 +288,9 @@ export function useSidebarData(): SidebarDataHandle {
337
288
  streamStatusMap: {},
338
289
  isMock: false,
339
290
  initializing: true,
291
+ // No provider means no channel was ever asked; claiming a failure would be
292
+ // a guess, and the honest state is still "loading".
293
+ failed: false,
340
294
  stale: false,
341
295
  refresh: () => {},
342
296
  refreshNow: () => {},
@@ -0,0 +1,89 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The three MERGES the session list performs on a server snapshot, split out of
8
+ * `session-list.tsx` so the provider stays under the repo's size ceiling.
9
+ *
10
+ * Each one is a pure folder array in, folder array out, and each has the same
11
+ * contract: return the SAME array when nothing moved. That identity is what the
12
+ * sidebar's memo chain (filter, sort, pending overlay) keys on — returning a
13
+ * fresh array per activity frame re-sorted 731 rows for a stamp that had not
14
+ * changed.
15
+ */
16
+
17
+ import type { WorkspaceFolderData } from '@/shared/types';
18
+ import type { SidebarActivityPayload, SidebarStatusPayload } from '@/shared/types/realtime';
19
+
20
+ /** Merge a structure payload with the volatile map, by session id. */
21
+ export function mergeStatus(
22
+ folders: WorkspaceFolderData[],
23
+ status: SidebarStatusPayload | null,
24
+ ): WorkspaceFolderData[] {
25
+ if (!status) return folders;
26
+ return folders.map((folder) => ({
27
+ ...folder,
28
+ sessions: (folder.sessions ?? []).map((session) => {
29
+ const volatile = status[String(session.id)];
30
+ return volatile ? { ...session, ...volatile } : session;
31
+ }),
32
+ }));
33
+ }
34
+
35
+ /**
36
+ * Advance each row's live fields from the activity payload.
37
+ *
38
+ * `sidebar:activity` carries only the RUNNING sessions (see its doc), so an id
39
+ * it does not name keeps whatever the structure gave it. Three rules, each of
40
+ * which is a way this can go wrong:
41
+ *
42
+ * - the `updated_at` comparison is what makes two sources safe to
43
+ * interleave: the structure is re-scanned at every turn boundary and may
44
+ * already carry a stamp this payload has not caught up with, and a late
45
+ * activity frame must never move a row BACKWARDS (that reorders the
46
+ * sidebar under the reader);
47
+ * - `hasSubagents` only ever turns ON, because the payload is a live read of
48
+ * what is on disk and a subagent transcript does not disappear when its run
49
+ * ends — a `false` here is "not seen yet", not "none exist";
50
+ * - nothing else is touched. Every other field of a row changes on a
51
+ * STRUCTURAL event, and those publish the structure for their own reason.
52
+ */
53
+ export function mergeActivity(
54
+ folders: WorkspaceFolderData[],
55
+ activity: SidebarActivityPayload | null,
56
+ ): WorkspaceFolderData[] {
57
+ if (!activity) return folders;
58
+ let changed = false;
59
+ const merged = folders.map((folder) => ({
60
+ ...folder,
61
+ sessions: (folder.sessions ?? []).map((session) => {
62
+ const live = activity[String(session.id)];
63
+ if (!live) return session;
64
+ const updated_at = live.updatedAt && isNewerStamp(live.updatedAt, session.updated_at)
65
+ ? live.updatedAt
66
+ : session.updated_at;
67
+ const hasSubagents = session.hasSubagents || live.hasSubagents === true;
68
+ if (updated_at === session.updated_at && hasSubagents === Boolean(session.hasSubagents)) return session;
69
+ changed = true;
70
+ return { ...session, updated_at, hasSubagents };
71
+ }),
72
+ }));
73
+ // A stable identity matters: the sidebar's own `useMemo` chain (filter, sort,
74
+ // pending overlay) keys on this array, and returning a fresh one per activity
75
+ // frame would re-sort 731 rows for a stamp that did not move.
76
+ return changed ? merged : folders;
77
+ }
78
+
79
+ /** Whether `next` is a later ISO stamp than `current`. An absent current is older. */
80
+ export function isNewerStamp(next: string, current?: string): boolean {
81
+ if (!current) return true;
82
+ const nextMs = Date.parse(next);
83
+ const currentMs = Date.parse(current);
84
+ // An unparseable value on either side is not evidence of a newer stamp; the
85
+ // structure's own field stays authoritative.
86
+ if (!Number.isFinite(nextMs) || !Number.isFinite(currentMs)) return false;
87
+ return nextMs > currentMs;
88
+ }
89
+
@@ -61,6 +61,8 @@ export interface SessionSidebarControllerOptions {
61
61
  export interface SessionSidebarController {
62
62
  folders: WorkspaceFolderData[];
63
63
  initializing: boolean;
64
+ /** The first read failed; the list has no data and no reply is coming. */
65
+ failed: boolean;
64
66
  refresh: () => void;
65
67
  /** User-initiated refresh — raises `refreshing` until that load settles. */
66
68
  refreshNow: () => void;
@@ -88,7 +90,7 @@ export function useSessionSidebarController(
88
90
  options: SessionSidebarControllerOptions = {},
89
91
  ): SessionSidebarController {
90
92
  const { expandSearchMatches = false, onSelectSession, onAfterSelect } = options;
91
- const { folders, initializing, refresh, refreshNow, refreshing, isRefreshing, markSeen, hasSeen, streamStatusMap, titleHint } = useSidebarData();
93
+ const { folders, initializing, failed, refresh, refreshNow, refreshing, isRefreshing, markSeen, hasSeen, streamStatusMap, titleHint } = useSidebarData();
92
94
  const [searchParams, setSearchParams] = useSearchParams();
93
95
  const sessionParam = searchParams.get('sessionId');
94
96
  // Read as a string, never off the `searchParams` object: `useSearchParams`
@@ -313,6 +315,7 @@ export function useSessionSidebarController(
313
315
  return {
314
316
  folders,
315
317
  initializing,
318
+ failed,
316
319
  refresh: revalidate,
317
320
  refreshNow,
318
321
  refreshing,