@nextclaw/ui 0.13.13 → 0.14.1-beta.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 (399) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/dist/assets/{api-D0hARyyl.js → api-C6EDHBDR.js} +7 -7
  3. package/dist/assets/channels-list-page-DKj6m1Hc.js +8 -0
  4. package/dist/assets/chat-page-BXngLJY6.js +105 -0
  5. package/dist/assets/config-split-page-CjlmJy8X.js +1 -0
  6. package/dist/assets/{confirm-dialog-CTcaBp-8.js → confirm-dialog-B39X0pYp.js} +2 -2
  7. package/dist/assets/desktop-update-config-DfUQ8nly.js +1 -0
  8. package/dist/assets/{dist-C59BKqbX.js → dist-BIYV2-Ia.js} +1 -1
  9. package/dist/assets/{dist-Di6EHp2x.js → dist-CmMro3nV.js} +1 -1
  10. package/dist/assets/doc-browser-B6Wc_TIY.js +1 -0
  11. package/dist/assets/doc-browser-CDtUtcim.js +1 -0
  12. package/dist/assets/doc-browser-context-DZbC9zVB.js +1 -0
  13. package/dist/assets/{ellipsis-hXUNwi63.js → ellipsis-DDpgTzgx.js} +1 -1
  14. package/dist/assets/{external-link-J0fCK-vu.js → external-link-D2cBOCqn.js} +1 -1
  15. package/dist/assets/index-DTb_XVIH.js +103 -0
  16. package/dist/assets/index-ayiPYhf1.css +1 -0
  17. package/dist/assets/mcp-marketplace-page-DZ9H0v05.js +1 -0
  18. package/dist/assets/mcp-marketplace-page-cnVWf7QQ.js +40 -0
  19. package/dist/assets/model-config-page-Bcb35AVv.js +1 -0
  20. package/dist/assets/plus-CYE1onU2.js +1 -0
  21. package/dist/assets/provider-scoped-model-input-kdoNp4HG.js +1 -0
  22. package/dist/assets/providers-config-page-CQSibSwO.js +1 -0
  23. package/dist/assets/{react-C7HsxuKH.js → react-DYQXXGbH.js} +1 -1
  24. package/dist/assets/remote-BlJDbXOI.js +1 -0
  25. package/dist/assets/rotate-cw-BWbvFDAX.js +1 -0
  26. package/dist/assets/runtime-config-page-Tn2yLQ0c.js +1 -0
  27. package/dist/assets/{save-Z1QTovIt.js → save-BNVTgBVn.js} +1 -1
  28. package/dist/assets/search-CKCzwLId.js +1 -0
  29. package/dist/assets/search-config-page-DG5Q2hF1.js +1 -0
  30. package/dist/assets/secrets-config-page-BXn5Uuwp.js +3 -0
  31. package/dist/assets/select-CIRwTNP4.js +41 -0
  32. package/dist/assets/{tag-chip-3kpiMTST.js → tag-chip-DKhVFtTE.js} +1 -1
  33. package/dist/assets/use-config-DgKM9VIU.js +1 -0
  34. package/dist/assets/x-Cm3JjYut.js +1 -0
  35. package/dist/index.html +14 -27
  36. package/package.json +9 -8
  37. package/src/app/index.tsx +8 -4
  38. package/src/app/presenters/app.presenter.ts +2 -0
  39. package/src/features/account/components/account-panel.tsx +3 -3
  40. package/src/features/account/hooks/{use-auth.test.ts → __tests__/use-auth.test.ts} +1 -1
  41. package/src/features/agents/components/{agents-page.test.tsx → __tests__/agents-page.test.tsx} +41 -2
  42. package/src/features/agents/components/agent-dialogs.tsx +2 -2
  43. package/src/features/agents/components/agents-page.tsx +1 -1
  44. package/src/features/channels/components/config/channel-form.tsx +1 -1
  45. package/src/features/channels/pages/channels-list-page.tsx +18 -15
  46. package/src/features/channels/utils/{channel-form-fields.utils.test.ts → __tests__/channel-form-fields.utils.test.ts} +1 -1
  47. package/src/features/chat/components/{chat-welcome.test.tsx → __tests__/chat-welcome.test.tsx} +1 -1
  48. package/src/features/chat/components/conversation/{chat-conversation-header.test.tsx → __tests__/chat-conversation-header.test.tsx} +25 -32
  49. package/src/features/chat/components/conversation/{chat-conversation-panel.test.tsx → __tests__/chat-conversation-panel.test.tsx} +132 -37
  50. package/src/features/chat/components/conversation/chat-conversation-alerts.tsx +37 -0
  51. package/src/features/chat/components/conversation/chat-conversation-content.tsx +91 -0
  52. package/src/features/chat/components/conversation/chat-conversation-header-section.tsx +152 -0
  53. package/src/features/chat/components/conversation/chat-conversation-header.tsx +26 -89
  54. package/src/features/chat/components/conversation/chat-conversation-panel.tsx +13 -379
  55. package/src/features/chat/components/conversation/chat-conversation-parent-banner.tsx +16 -0
  56. package/src/features/chat/components/conversation/chat-conversation-skeleton.tsx +86 -0
  57. package/src/features/chat/components/conversation/chat-conversation-workspace-section.tsx +42 -0
  58. package/src/features/chat/components/layout/{chat-page-shell.test.tsx → __tests__/chat-page-shell.test.tsx} +1 -1
  59. package/src/features/chat/components/layout/__tests__/chat-sidebar-read-state.test.tsx +167 -0
  60. package/src/features/chat/components/layout/__tests__/chat-sidebar.test.tsx +834 -0
  61. package/src/features/chat/components/layout/chat-page-shell.tsx +11 -30
  62. package/src/features/chat/components/layout/chat-sidebar-toolbar.tsx +33 -53
  63. package/src/features/chat/components/layout/chat-sidebar-utility-menu.tsx +1 -1
  64. package/src/features/chat/components/layout/chat-sidebar.tsx +156 -202
  65. package/src/features/chat/components/providers/chat-presenter.provider.tsx +13 -46
  66. package/src/features/chat/{components/conversation → features/input/components/__tests__}/chat-attachment-upload-limit.test.ts +1 -1
  67. package/src/features/chat/{components/conversation → features/input/components}/chat-input-bar.container.tsx +92 -31
  68. package/src/features/chat/features/input/hooks/use-chat-input-bar-query-state.ts +118 -0
  69. package/src/features/chat/{utils → features/input/utils/__tests__}/chat-composer-state.utils.test.ts +1 -1
  70. package/src/features/chat/{utils → features/input/utils/__tests__}/chat-inline-token.utils.test.ts +1 -1
  71. package/src/features/chat/{utils → features/input/utils/__tests__}/chat-input-bar.utils.test.ts +2 -17
  72. package/src/features/chat/{utils → features/input/utils/__tests__}/ncp-chat-input-availability.utils.test.ts +2 -1
  73. package/src/features/chat/{utils → features/input/utils}/chat-input-bar.utils.ts +1 -24
  74. package/src/features/chat/{utils → features/input/utils}/chat-input-toolbar.utils.ts +0 -27
  75. package/src/features/chat/{utils → features/input/utils}/ncp-chat-input-availability.utils.ts +6 -6
  76. package/src/features/chat/features/message/components/__tests__/chat-inline-panel-app-card.test.tsx +89 -0
  77. package/src/features/chat/{components/conversation → features/message/components/__tests__}/chat-message-list.container.test.tsx +46 -3
  78. package/src/features/chat/features/message/components/chat-inline-panel-app-card.tsx +115 -0
  79. package/src/features/chat/{components/conversation → features/message/components}/chat-message-list.container.tsx +13 -13
  80. package/src/features/chat/{utils → features/message/utils/__tests__}/chat-message-invalid-tool-arguments.utils.test.ts +2 -2
  81. package/src/features/chat/{utils → features/message/utils/__tests__}/chat-message-session-spawn-tool-card.utils.test.ts +2 -2
  82. package/src/features/chat/features/message/utils/__tests__/chat-message-show-content-tool-card.utils.test.ts +172 -0
  83. package/src/features/chat/{utils → features/message/utils/__tests__}/chat-message-summary-truncation.utils.test.ts +2 -2
  84. package/src/features/chat/{utils → features/message/utils/__tests__}/chat-message-tool-agent-id.utils.test.ts +1 -1
  85. package/src/features/chat/{utils → features/message/utils/__tests__}/chat-message.utils.test.ts +2 -2
  86. package/src/features/chat/features/message/utils/chat-inline-panel-app-card.utils.ts +51 -0
  87. package/src/features/chat/{utils → features/message/utils}/chat-message-inline-content.utils.ts +1 -1
  88. package/src/features/chat/{utils → features/message/utils}/chat-message-part.utils.ts +15 -2
  89. package/src/features/chat/{utils → features/message/utils}/chat-message-session-request-tool-card.utils.ts +1 -1
  90. package/src/features/chat/features/message/utils/chat-message-show-content-tool-card.utils.ts +188 -0
  91. package/src/features/chat/{utils → features/message/utils}/chat-message-tool-card.utils.ts +5 -1
  92. package/src/features/chat/{utils → features/message/utils}/chat-message.utils.ts +1 -1
  93. package/src/features/chat/features/ncp/hooks/__tests__/use-hydrated-ncp-agent.test.tsx +57 -0
  94. package/src/features/chat/{hooks → features/ncp/hooks/__tests__}/use-ncp-agent-runtime.test.tsx +2 -2
  95. package/src/features/chat/features/ncp/hooks/__tests__/use-ncp-chat-derived-state.test.tsx +22 -0
  96. package/src/features/chat/features/ncp/hooks/__tests__/use-ncp-chat-query-store-sync.test.tsx +101 -0
  97. package/src/features/chat/{hooks → features/ncp/hooks/__tests__}/use-ncp-session-conversation.test.tsx +1 -1
  98. package/src/features/chat/features/ncp/hooks/__tests__/use-ui-show-content-event.test.tsx +53 -0
  99. package/src/features/chat/features/ncp/hooks/use-ncp-chat-derived-state.ts +37 -0
  100. package/src/features/chat/features/ncp/hooks/use-ncp-chat-query-store-sync.ts +28 -0
  101. package/src/features/chat/{hooks → features/ncp/hooks}/use-ncp-child-session-tabs-view.ts +4 -4
  102. package/src/features/chat/{hooks → features/ncp/hooks}/use-ncp-session-conversation.ts +1 -1
  103. package/src/features/chat/{hooks → features/ncp/hooks}/use-ncp-session-list-view.ts +3 -3
  104. package/src/features/chat/features/ncp/hooks/use-ncp-session-queries.ts +32 -0
  105. package/src/features/chat/features/ncp/hooks/use-ui-show-content-event.ts +14 -0
  106. package/src/features/chat/features/ncp/utils/ncp-chat-query-derived.utils.ts +85 -0
  107. package/src/features/chat/{utils → features/runtime/utils/__tests__}/ncp-app-client-fetch.utils.test.ts +1 -1
  108. package/src/features/chat/{utils → features/runtime/utils/__tests__}/ncp-chat-runtime-availability.utils.test.ts +1 -1
  109. package/src/features/chat/{utils → features/runtime/utils}/chat-runtime.utils.ts +1 -1
  110. package/src/features/chat/{components → features/session/components}/chat-sidebar-project-groups.tsx +21 -42
  111. package/src/features/chat/{components/layout → features/session/components}/chat-sidebar-session-entry.tsx +40 -13
  112. package/src/features/chat/{components → features/session/components}/chat-sidebar-session-item.tsx +36 -44
  113. package/src/features/chat/features/session/components/chat-sidebar-session-list.tsx +78 -0
  114. package/src/features/chat/{components/session → features/session/components}/session-context-icon.tsx +1 -1
  115. package/src/features/chat/{components/conversation/session-header → features/session/components/session-header/__tests__}/chat-session-header-actions.test.tsx +30 -3
  116. package/src/features/chat/{components/conversation/session-header → features/session/components/session-header/__tests__}/chat-session-project-badge.test.tsx +3 -3
  117. package/src/features/chat/{components/conversation → features/session/components}/session-header/chat-session-header-actions.tsx +34 -28
  118. package/src/features/chat/features/session/components/session-header/chat-session-metadata-dialog.tsx +46 -0
  119. package/src/features/chat/{components/conversation → features/session/components}/session-header/chat-session-project-badge.tsx +1 -1
  120. package/src/features/chat/{hooks → features/session/hooks/__tests__}/use-chat-session-project.test.tsx +2 -2
  121. package/src/features/chat/{hooks → features/session/hooks/__tests__}/use-chat-session-update.test.tsx +1 -1
  122. package/src/features/chat/features/session/hooks/__tests__/use-selected-session-context-window-indicator.test.tsx +63 -0
  123. package/src/features/chat/{hooks → features/session/hooks}/use-chat-session-project.ts +1 -1
  124. package/src/features/chat/{hooks → features/session/hooks}/use-chat-session-update.ts +17 -0
  125. package/src/features/chat/{hooks → features/session/hooks}/use-chat-sidebar-session-label-editor.ts +1 -1
  126. package/src/features/chat/features/session/hooks/use-selected-session-context-window-indicator.ts +15 -0
  127. package/src/features/chat/{utils → features/session/utils/__tests__}/chat-session-display.utils.test.ts +1 -1
  128. package/src/features/chat/{utils → features/session/utils/__tests__}/chat-session-route.utils.test.ts +1 -1
  129. package/src/features/chat/{utils → features/session/utils/__tests__}/ncp-session-adapter.utils.cancelled-tool.test.ts +2 -2
  130. package/src/features/chat/{utils → features/session/utils/__tests__}/ncp-session-adapter.utils.test.ts +10 -2
  131. package/src/features/chat/{utils → features/session/utils/__tests__}/session-context.utils.test.ts +1 -1
  132. package/src/features/chat/features/session/utils/chat-run-metadata.utils.ts +60 -0
  133. package/src/features/chat/{utils → features/session/utils}/chat-session-preference-governance.utils.ts +0 -128
  134. package/src/features/chat/features/session/utils/chat-sidebar-session-groups.utils.ts +144 -0
  135. package/src/features/chat/{utils → features/session/utils}/ncp-session-adapter.utils.ts +2 -0
  136. package/src/features/chat/{components → features/session-type/components/__tests__}/chat-session-type-option-item.test.tsx +1 -1
  137. package/src/features/chat/{components → features/session-type/components}/chat-session-type-option-item.tsx +7 -16
  138. package/src/features/chat/features/session-type/components/chat-sidebar-create-menu.tsx +42 -0
  139. package/src/features/chat/{hooks → features/session-type/hooks/__tests__}/use-chat-session-type-state.test.tsx +1 -1
  140. package/src/features/chat/{hooks → features/session-type/hooks}/use-chat-session-type-state.ts +24 -94
  141. package/src/features/chat/features/session-type/utils/chat-session-type.utils.ts +109 -0
  142. package/src/features/chat/{components → features/workspace/components/__tests__}/chat-session-workspace-file-preview.test.tsx +1 -1
  143. package/src/features/chat/{components → features/workspace/components}/chat-session-workspace-file-preview.tsx +2 -2
  144. package/src/features/chat/features/workspace/components/chat-session-workspace-panel-content.tsx +156 -0
  145. package/src/features/chat/features/workspace/components/chat-session-workspace-panel-nav.tsx +84 -0
  146. package/src/features/chat/features/workspace/components/chat-session-workspace-panel.tsx +138 -0
  147. package/src/features/chat/{components/workspace → features/workspace/components}/session-cron-job-content.tsx +1 -1
  148. package/src/features/chat/features/workspace/hooks/use-chat-conversation-workspace-state.ts +63 -0
  149. package/src/features/chat/features/workspace/utils/__tests__/chat-workspace-panel-view-model.utils.test.ts +103 -0
  150. package/src/features/chat/features/workspace/utils/chat-workspace-panel-view-model.utils.ts +183 -0
  151. package/src/features/chat/index.ts +17 -6
  152. package/src/features/chat/managers/__tests__/chat-input.manager.test.ts +383 -0
  153. package/src/features/chat/managers/__tests__/chat-query.manager.test.ts +39 -0
  154. package/src/features/chat/managers/__tests__/chat-run-snapshot.manager.test.ts +129 -0
  155. package/src/features/chat/managers/__tests__/chat-run.manager.test.ts +236 -0
  156. package/src/features/chat/managers/{chat-session-list.manager.test.ts → __tests__/chat-session-list.manager.test.ts} +98 -78
  157. package/src/features/chat/managers/__tests__/chat-session-preference-sync.manager.test.ts +219 -0
  158. package/src/features/chat/managers/__tests__/chat-thread.manager.test.ts +652 -0
  159. package/src/features/chat/managers/__tests__/chat-ui.manager.test.ts +126 -0
  160. package/src/features/chat/managers/{recent-selection.manager.test.ts → __tests__/recent-selection.manager.test.ts} +37 -14
  161. package/src/features/chat/managers/chat-draft-intent.manager.ts +46 -0
  162. package/src/features/chat/managers/{ncp-chat-input.manager.ts → chat-input.manager.ts} +118 -45
  163. package/src/features/chat/managers/chat-query.manager.ts +48 -0
  164. package/src/features/chat/managers/chat-run.manager.ts +110 -0
  165. package/src/features/chat/managers/chat-session-list.manager.ts +45 -15
  166. package/src/features/chat/managers/chat-session-preference-sync.manager.ts +77 -5
  167. package/src/features/chat/managers/{ncp-chat-thread.manager.ts → chat-thread.manager.ts} +67 -36
  168. package/src/features/chat/managers/chat-ui.manager.ts +51 -9
  169. package/src/features/chat/managers/recent-selection.manager.ts +21 -67
  170. package/src/features/chat/pages/{ncp-chat-page.test.ts → __tests__/ncp-chat-page.test.ts} +95 -12
  171. package/src/features/chat/pages/ncp-chat-page.tsx +139 -397
  172. package/src/features/chat/presenters/chat.presenter.ts +39 -0
  173. package/src/features/chat/stores/chat-input.store.ts +12 -2
  174. package/src/features/chat/stores/chat-thread.store.ts +0 -19
  175. package/src/features/chat/stores/ncp-chat-query.store.ts +25 -0
  176. package/src/features/chat/stores/recent-selection.store.ts +85 -0
  177. package/src/features/chat/types/chat-input-bar.types.ts +0 -1
  178. package/src/features/chat/types/chat-input.types.ts +1 -0
  179. package/src/features/chat/types/chat-message.types.ts +1 -0
  180. package/src/features/chat/types/chat-run.types.ts +41 -0
  181. package/src/{shared → features/cron}/components/cron-config.tsx +1 -1
  182. package/src/features/cron/hooks/use-cron-jobs.ts +58 -0
  183. package/src/features/cron/index.ts +7 -0
  184. package/src/features/marketplace/components/curated-shelves/marketplace-curated-shelves.tsx +15 -61
  185. package/src/features/marketplace/components/marketplace-external-skill-source-action.tsx +1 -1
  186. package/src/features/marketplace/components/marketplace-item-list-view.tsx +167 -0
  187. package/src/features/marketplace/components/marketplace-list-card.tsx +27 -31
  188. package/src/features/marketplace/components/marketplace-page-data.ts +0 -6
  189. package/src/features/marketplace/components/marketplace-page.tsx +105 -451
  190. package/src/features/marketplace/components/mcp/mcp-marketplace-card.tsx +1 -1
  191. package/src/features/marketplace/components/mcp/mcp-marketplace-dialogs.tsx +1 -1
  192. package/src/features/marketplace/components/mcp/mcp-marketplace-page.tsx +1 -1
  193. package/src/features/marketplace/hooks/use-marketplace-item-actions.ts +101 -0
  194. package/src/features/marketplace/hooks/use-marketplace-item-detail.ts +109 -0
  195. package/src/features/marketplace/hooks/use-marketplace-list-model.ts +160 -0
  196. package/src/features/marketplace/utils/{marketplace-installed-cache.utils.test.ts → __tests__/marketplace-installed-cache.utils.test.ts} +1 -1
  197. package/src/features/panel-apps/components/{panel-app-list-item.test.tsx → __tests__/panel-app-list-item.test.tsx} +1 -1
  198. package/src/features/panel-apps/components/{panel-app-toolbar.test.tsx → __tests__/panel-app-toolbar.test.tsx} +1 -1
  199. package/src/features/panel-apps/components/__tests__/panel-apps-list.test.tsx +137 -0
  200. package/src/features/panel-apps/components/panel-apps-list.tsx +119 -5
  201. package/src/features/panel-apps/index.ts +2 -0
  202. package/src/features/panel-apps/utils/{panel-app-view.utils.test.ts → __tests__/panel-app-view.utils.test.ts} +1 -1
  203. package/src/features/panel-apps/utils/panel-app-entry-match.utils.ts +17 -0
  204. package/src/features/pwa/managers/{pwa-service-worker-cache.manager.test.ts → __tests__/pwa-service-worker-cache.manager.test.ts} +1 -1
  205. package/src/features/remote/components/remote-access-page.tsx +2 -2
  206. package/src/features/remote/services/{remote-access-feedback.service.test.ts → __tests__/remote-access-feedback.service.test.ts} +1 -1
  207. package/src/{shared → features/settings}/components/config/provider-form.tsx +5 -5
  208. package/src/{shared/components → features/settings/components/config}/provider-status-badge.tsx +1 -1
  209. package/src/{shared/components/model-config.test.tsx → features/settings/pages/__tests__/model-config-page.test.tsx} +40 -5
  210. package/src/{shared/components/config/providers-list.test.tsx → features/settings/pages/__tests__/providers-config-page.test.tsx} +48 -5
  211. package/src/{shared/components/search-config.test.tsx → features/settings/pages/__tests__/search-config-page.test.tsx} +3 -3
  212. package/src/{shared/components/config/secrets-config.test.tsx → features/settings/pages/__tests__/secrets-config-page.test.tsx} +3 -3
  213. package/src/{shared/components/model-config.tsx → features/settings/pages/model-config-page.tsx} +1 -1
  214. package/src/{shared/components/config/providers-list.tsx → features/settings/pages/providers-config-page.tsx} +3 -3
  215. package/src/{shared/components/search-config.tsx → features/settings/pages/search-config-page.tsx} +1 -1
  216. package/src/{shared/components/config/secrets-config.tsx → features/settings/pages/secrets-config-page.tsx} +2 -2
  217. package/src/{shared/components/config/provider-form-support.test.ts → features/settings/utils/__tests__/provider-form-support.utils.test.ts} +1 -1
  218. package/src/features/system-status/components/{runtime-control-card.test.tsx → __tests__/runtime-control-card.test.tsx} +1 -1
  219. package/src/features/system-status/components/{runtime-presence-card.test.tsx → __tests__/runtime-presence-card.test.tsx} +1 -1
  220. package/src/features/system-status/components/runtime-presence-card.tsx +2 -2
  221. package/src/features/system-status/managers/{system-status.manager.bootstrap-polling.test.ts → __tests__/system-status.manager.bootstrap-polling.test.ts} +1 -1
  222. package/src/features/system-status/managers/{system-status.manager.test.ts → __tests__/system-status.manager.test.ts} +1 -1
  223. package/src/features/system-status/utils/{system-status.utils.test.ts → __tests__/system-status.utils.test.ts} +1 -1
  224. package/src/shared/components/common/{agent-avatar.test.tsx → __tests__/agent-avatar.test.tsx} +1 -1
  225. package/src/shared/components/common/agent-identity/use-agent-identity.ts +3 -8
  226. package/src/shared/components/common/brand-header.tsx +1 -1
  227. package/src/shared/components/common/tag-input.tsx +1 -1
  228. package/src/shared/components/doc-browser/{doc-browser-context.test.tsx → __tests__/doc-browser-context.test.tsx} +1 -1
  229. package/src/shared/components/doc-browser/doc-browser-tab-strip.tsx +64 -161
  230. package/src/shared/components/doc-browser/doc-browser.tsx +4 -4
  231. package/src/shared/components/resizable-right-panel/__tests__/resizable-right-panel.test.tsx +66 -0
  232. package/src/shared/components/resizable-right-panel/resizable-right-panel.tsx +11 -8
  233. package/src/shared/components/ui/actions/icon-action-button.tsx +53 -0
  234. package/src/shared/components/ui/tab-strip/__tests__/compact-tab-strip.test.tsx +52 -0
  235. package/src/shared/components/ui/tab-strip/compact-tab-strip.tsx +228 -0
  236. package/src/shared/hooks/use-app-meta.ts +10 -0
  237. package/src/shared/hooks/use-config.ts +1 -148
  238. package/src/shared/lib/api/{ncp-session.test.ts → __tests__/ncp-session.test.ts} +3 -3
  239. package/src/shared/lib/api/{raw-client.test.ts → __tests__/raw-client.test.ts} +1 -1
  240. package/src/shared/lib/api/chat-session-type.types.ts +10 -0
  241. package/src/shared/lib/api/ncp-session.types.ts +1 -0
  242. package/src/shared/lib/api/types.ts +3 -0
  243. package/src/shared/lib/cadence/services/{adaptive-cadence.service.test.ts → __tests__/adaptive-cadence.service.test.ts} +1 -1
  244. package/src/shared/lib/i18n/locales/en-US/chat.json +6 -0
  245. package/src/shared/lib/i18n/locales/en-US/core.json +1 -0
  246. package/src/shared/lib/i18n/locales/en-US/doc-browser.json +10 -0
  247. package/src/shared/lib/i18n/locales/zh-CN/chat.json +6 -0
  248. package/src/shared/lib/i18n/locales/zh-CN/core.json +1 -0
  249. package/src/shared/lib/i18n/locales/zh-CN/doc-browser.json +10 -0
  250. package/src/shared/lib/i18n/locales/zh-CN/marketplace.json +1 -1
  251. package/src/shared/lib/i18n/runtime/{i18n-language-owner.test.ts → __tests__/i18n-language-owner.test.ts} +2 -2
  252. package/src/shared/lib/navigation-history/{navigation-history.utils.test.ts → __tests__/navigation-history.utils.test.ts} +1 -1
  253. package/src/shared/lib/provider-models/{index.test.ts → __tests__/index.test.ts} +1 -1
  254. package/src/shared/lib/transport/{app-client.test.ts → __tests__/app-client.test.ts} +3 -3
  255. package/src/shared/lib/transport/{remote.transport.test.ts → __tests__/remote.transport.test.ts} +1 -1
  256. package/src/shared/lib/transport/{sse-stream.test.ts → __tests__/sse-stream.test.ts} +1 -1
  257. package/tsconfig.json +2 -5
  258. package/vite.config.ts +4 -4
  259. package/vitest.config.ts +4 -0
  260. package/dist/assets/app-presenter-provider-C7EsUuEJ.js +0 -3
  261. package/dist/assets/arrow-left-CzSkR5L6.js +0 -1
  262. package/dist/assets/book-open-DmeQPqkd.js +0 -1
  263. package/dist/assets/channels-list-page-B0yiiH01.js +0 -8
  264. package/dist/assets/chat-page-ChPjx_X9.js +0 -105
  265. package/dist/assets/config-split-page-BzfZSyAr.js +0 -1
  266. package/dist/assets/desktop-update-config-CExpdkqD.js +0 -1
  267. package/dist/assets/doc-browser-EZbnEcdk.js +0 -1
  268. package/dist/assets/doc-browser-XIwe1Tg-.js +0 -1
  269. package/dist/assets/doc-browser-context-BzEA1lm1.js +0 -1
  270. package/dist/assets/es2015-CJlVSTh-.js +0 -41
  271. package/dist/assets/host-capabilities-DjiRQ0Q9.js +0 -1
  272. package/dist/assets/index-DfZTO6Pi.js +0 -101
  273. package/dist/assets/index-mIb_YMrc.css +0 -1
  274. package/dist/assets/key-round-BzYZ0Nno.js +0 -1
  275. package/dist/assets/loader-circle-BbdIlBbQ.js +0 -1
  276. package/dist/assets/mcp-marketplace-page-L22aCzHX.js +0 -40
  277. package/dist/assets/mcp-marketplace-page-f80Jmv37.js +0 -1
  278. package/dist/assets/model-config-DkD7vSQT.js +0 -1
  279. package/dist/assets/notice-card-CD9Ok62G.js +0 -1
  280. package/dist/assets/play-DHuSeKs8.js +0 -1
  281. package/dist/assets/plus-DrV685KC.js +0 -1
  282. package/dist/assets/popover-CoBu3mbV.js +0 -1
  283. package/dist/assets/provider-models-C9VRroK3.js +0 -1
  284. package/dist/assets/provider-scoped-model-input-DZlmTCJU.js +0 -1
  285. package/dist/assets/providers-list-CVkWiqIy.js +0 -1
  286. package/dist/assets/refresh-cw-CVo4nWpq.js +0 -1
  287. package/dist/assets/remote-Bznw9iji.js +0 -1
  288. package/dist/assets/rotate-cw-CXDpRO6D.js +0 -1
  289. package/dist/assets/runtime-config-page-5IycbIxs.js +0 -1
  290. package/dist/assets/search-8nY6PGm0.js +0 -1
  291. package/dist/assets/search-config-DEH80WkC.js +0 -1
  292. package/dist/assets/secrets-config-Gzo5nDJG.js +0 -3
  293. package/dist/assets/status-dot-C1-FKgvv.js +0 -1
  294. package/dist/assets/tabs-BqkKwx1R.js +0 -1
  295. package/dist/assets/tabs-custom-DOkaJZmt.js +0 -1
  296. package/dist/assets/tooltip-Bw-mXQAM.js +0 -1
  297. package/dist/assets/trash-2-CmIwAJIT.js +0 -1
  298. package/dist/assets/x-CSRTOZnM.js +0 -1
  299. package/src/features/chat/components/chat-session-workspace-panel-nav.tsx +0 -264
  300. package/src/features/chat/components/chat-session-workspace-panel.tsx +0 -380
  301. package/src/features/chat/components/layout/chat-sidebar-read-state.test.tsx +0 -145
  302. package/src/features/chat/components/layout/chat-sidebar.test.tsx +0 -896
  303. package/src/features/chat/hooks/use-chat-input-bar-controller.test.tsx +0 -152
  304. package/src/features/chat/hooks/use-chat-input-bar-controller.ts +0 -142
  305. package/src/features/chat/hooks/use-chat-session-label.ts +0 -18
  306. package/src/features/chat/hooks/use-hydrated-ncp-agent.test.tsx +0 -90
  307. package/src/features/chat/hooks/use-ncp-chat-derived-state.ts +0 -181
  308. package/src/features/chat/hooks/use-ncp-chat-page-data.test.tsx +0 -70
  309. package/src/features/chat/hooks/use-ncp-chat-page-data.ts +0 -260
  310. package/src/features/chat/hooks/use-selected-session-context-window-indicator.ts +0 -18
  311. package/src/features/chat/managers/chat-session-preference-sync.manager.test.ts +0 -77
  312. package/src/features/chat/managers/chat-stream-actions.manager.ts +0 -35
  313. package/src/features/chat/managers/ncp-chat-input.manager.test.ts +0 -232
  314. package/src/features/chat/managers/ncp-chat-presenter.manager.ts +0 -28
  315. package/src/features/chat/managers/ncp-chat-thread.manager.test.ts +0 -369
  316. package/src/features/chat/types/chat-stream.types.ts +0 -32
  317. package/src/features/chat/utils/chat-session-preference-governance.utils.test.tsx +0 -114
  318. package/src/features/marketplace/components/marketplace-catalog-grid.tsx +0 -132
  319. package/src/shared/components/resizable-right-panel/resizable-right-panel.test.tsx +0 -38
  320. package/src/shared/components/ui/config-card.tsx +0 -71
  321. package/src/shared/components/ui/highlight-card.tsx +0 -40
  322. package/src/shared/components/ui/tabs-custom.tsx +0 -49
  323. /package/dist/assets/{config-hints-fGnUjDe9.js → config-hints-CTqBnCDp.js} +0 -0
  324. /package/src/{app.test.tsx → __tests__/app.test.tsx} +0 -0
  325. /package/src/app/components/layout/{app-layout.test.tsx → __tests__/app-layout.test.tsx} +0 -0
  326. /package/src/app/components/layout/{runtime-status-entry.test.tsx → __tests__/runtime-status-entry.test.tsx} +0 -0
  327. /package/src/app/components/layout/{settings-entry-page.test.tsx → __tests__/settings-entry-page.test.tsx} +0 -0
  328. /package/src/app/components/layout/{sidebar.layout.test.tsx → __tests__/sidebar.layout.test.tsx} +0 -0
  329. /package/src/features/channels/components/config/{channel-form.test.tsx → __tests__/channel-form.test.tsx} +0 -0
  330. /package/src/features/channels/components/config/{weixin-channel-auth-section.test.tsx → __tests__/weixin-channel-auth-section.test.tsx} +0 -0
  331. /package/src/features/channels/pages/{channels-list-page.test.tsx → __tests__/channels-list-page.test.tsx} +0 -0
  332. /package/src/features/chat/{utils → features/input/utils}/chat-composer-state.utils.ts +0 -0
  333. /package/src/features/chat/{utils → features/input/utils}/chat-inline-token.utils.ts +0 -0
  334. /package/src/features/chat/{utils → features/message/utils}/chat-message-core.utils.ts +0 -0
  335. /package/src/features/chat/{utils → features/message/utils}/chat-message-partial-json.utils.ts +0 -0
  336. /package/src/features/chat/{utils → features/message/utils}/chat-message-tool-agent-id.utils.ts +0 -0
  337. /package/src/features/chat/{utils → features/message/utils}/file-operation/card.utils.ts +0 -0
  338. /package/src/features/chat/{utils → features/message/utils}/file-operation/diff.utils.ts +0 -0
  339. /package/src/features/chat/{utils → features/message/utils}/file-operation/line-builder.utils.ts +0 -0
  340. /package/src/features/chat/{utils → features/message/utils}/file-operation/parsed-block.utils.ts +0 -0
  341. /package/src/features/chat/{utils → features/message/utils}/file-operation/record-readers.utils.ts +0 -0
  342. /package/src/features/chat/{utils → features/runtime/utils}/ncp-app-client-fetch.utils.ts +0 -0
  343. /package/src/features/chat/{utils → features/runtime/utils}/ncp-chat-runtime-availability.utils.ts +0 -0
  344. /package/src/features/chat/{components/conversation → features/session/components}/session-header/chat-session-header-menu-item.tsx +0 -0
  345. /package/src/features/chat/{components/conversation → features/session/components}/session-header/chat-session-project-dialog.tsx +0 -0
  346. /package/src/features/chat/{components/session → features/session/components}/session-run-badge.tsx +0 -0
  347. /package/src/features/chat/{utils → features/session/utils}/chat-context-window-indicator.utils.ts +0 -0
  348. /package/src/features/chat/{utils → features/session/utils}/chat-session-display.utils.ts +0 -0
  349. /package/src/features/chat/{utils → features/session/utils}/chat-session-route.utils.ts +0 -0
  350. /package/src/features/chat/{utils → features/session/utils}/ncp-session-context-metadata.utils.ts +0 -0
  351. /package/src/features/chat/{utils → features/session/utils}/session-context.utils.ts +0 -0
  352. /package/src/features/chat/{hooks → features/session-type/hooks}/use-ncp-chat-session-types.ts +0 -0
  353. /package/src/features/chat/{components/workspace → features/workspace/components}/chat-session-workspace-file-breadcrumbs.tsx +0 -0
  354. /package/src/features/chat/stores/{chat-thread.store.test.ts → __tests__/chat-thread.store.test.ts} +0 -0
  355. /package/src/features/marketplace/components/{marketplace-page-detail.test.tsx → __tests__/marketplace-page-detail.test.tsx} +0 -0
  356. /package/src/features/marketplace/components/{marketplace-page.test.tsx → __tests__/marketplace-page.test.tsx} +0 -0
  357. /package/src/features/marketplace/components/curated-shelves/{marketplace-curated-scene-route.test.tsx → __tests__/marketplace-curated-scene-route.test.tsx} +0 -0
  358. /package/src/features/marketplace/components/detail-doc/{marketplace-detail-doc.test.ts → __tests__/marketplace-detail-doc.test.ts} +0 -0
  359. /package/src/features/marketplace/components/mcp/{mcp-marketplace-page.test.tsx → __tests__/mcp-marketplace-page.test.tsx} +0 -0
  360. /package/src/features/marketplace/hooks/{use-marketplace.test.tsx → __tests__/use-marketplace.test.tsx} +0 -0
  361. /package/src/features/panel-apps/managers/{panel-app-bridge.manager.test.ts → __tests__/panel-app-bridge.manager.test.ts} +0 -0
  362. /package/src/features/panel-apps/utils/{panel-app-doc-browser.utils.test.ts → __tests__/panel-app-doc-browser.utils.test.ts} +0 -0
  363. /package/src/features/pwa/components/{pwa-install-entry.test.tsx → __tests__/pwa-install-entry.test.tsx} +0 -0
  364. /package/src/features/pwa/managers/{pwa-install.manager.test.ts → __tests__/pwa-install.manager.test.ts} +0 -0
  365. /package/src/features/pwa/managers/{pwa-shell-theme.manager.test.ts → __tests__/pwa-shell-theme.manager.test.ts} +0 -0
  366. /package/src/features/remote/components/{remote-access-page.test.tsx → __tests__/remote-access-page.test.tsx} +0 -0
  367. /package/src/features/right-panel-resources/utils/{right-panel-resource-route-resolver.utils.test.ts → __tests__/right-panel-resource-route-resolver.utils.test.ts} +0 -0
  368. /package/src/features/right-panel-resources/utils/{right-panel-resource-uri.utils.test.ts → __tests__/right-panel-resource-uri.utils.test.ts} +0 -0
  369. /package/src/features/service-apps/components/{service-apps-panel.test.tsx → __tests__/service-apps-panel.test.tsx} +0 -0
  370. /package/src/{shared/components → features/settings/components/config}/provider-advanced-settings-section.tsx +0 -0
  371. /package/src/{shared/components → features/settings/components/config}/provider-auth-section.tsx +0 -0
  372. /package/src/{shared → features/settings}/components/config/provider-models-section.tsx +0 -0
  373. /package/src/{shared/components → features/settings/components/config}/provider-pill-selector.tsx +0 -0
  374. /package/src/{shared → features/settings}/components/config/secrets-config-form.tsx +0 -0
  375. /package/src/features/settings/pages/{language-settings-page.test.tsx → __tests__/language-settings-page.test.tsx} +0 -0
  376. /package/src/{shared/components/config/provider-form-support.ts → features/settings/utils/provider-form-support.utils.ts} +0 -0
  377. /package/src/features/side-dock/components/{side-dock.test.tsx → __tests__/side-dock.test.tsx} +0 -0
  378. /package/src/features/side-dock/managers/{side-dock.manager.test.ts → __tests__/side-dock.manager.test.ts} +0 -0
  379. /package/src/features/side-dock/utils/{side-dock-item.utils.test.ts → __tests__/side-dock-item.utils.test.ts} +0 -0
  380. /package/src/features/system-status/components/{desktop-update-config.test.tsx → __tests__/desktop-update-config.test.tsx} +0 -0
  381. /package/src/features/system-status/pages/{runtime-config-page.test.tsx → __tests__/runtime-config-page.test.tsx} +0 -0
  382. /package/src/platforms/desktop/components/{desktop-app-shell.test.tsx → __tests__/desktop-app-shell.test.tsx} +0 -0
  383. /package/src/platforms/mobile/components/{mobile-app-shell.test.tsx → __tests__/mobile-app-shell.test.tsx} +0 -0
  384. /package/src/platforms/mobile/components/{mobile-bottom-nav.test.tsx → __tests__/mobile-bottom-nav.test.tsx} +0 -0
  385. /package/src/shared/components/{ui → actions}/action-link.tsx +0 -0
  386. /package/src/shared/components/common/{brand-header.test.tsx → __tests__/brand-header.test.tsx} +0 -0
  387. /package/src/shared/components/doc-browser/{doc-browser.test.tsx → __tests__/doc-browser.test.tsx} +0 -0
  388. /package/src/shared/components/{ui → feedback}/notice-card.tsx +0 -0
  389. /package/src/shared/components/path-picker/{server-path-picker-dialog.test.tsx → __tests__/server-path-picker-dialog.test.tsx} +0 -0
  390. /package/src/shared/components/{ui → settings}/setting-row.tsx +0 -0
  391. /package/src/shared/components/{ui → status}/status-dot.tsx +0 -0
  392. /package/src/shared/components/{ui → tags}/tag-chip.tsx +0 -0
  393. /package/src/shared/lib/api/{api-base.test.ts → __tests__/api-base.test.ts} +0 -0
  394. /package/src/shared/lib/api/{client.test.ts → __tests__/client.test.ts} +0 -0
  395. /package/src/shared/lib/api/{ncp-session-query-cache.utils.test.ts → __tests__/ncp-session-query-cache.utils.test.ts} +0 -0
  396. /package/src/shared/lib/app-resource-uri/{app-resource-uri.test.ts → __tests__/app-resource-uri.test.ts} +0 -0
  397. /package/src/shared/lib/host-capabilities/{host-capability.manager.test.ts → __tests__/host-capability.manager.test.ts} +0 -0
  398. /package/src/shared/lib/resource-uri/utils/{resource-uri-resolver.utils.test.ts → __tests__/resource-uri-resolver.utils.test.ts} +0 -0
  399. /package/src/shared/lib/session-project/{workspace-file-breadcrumb.test.ts → __tests__/workspace-file-breadcrumb.test.ts} +0 -0
@@ -0,0 +1,652 @@
1
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
2
+ import { appQueryClient } from '@/app-query-client';
3
+ import { ChatThreadManager } from '@/features/chat/managers/chat-thread.manager';
4
+ import { useChatSessionListStore } from '@/features/chat/stores/chat-session-list.store';
5
+ import { useChatThreadStore } from '@/features/chat/stores/chat-thread.store';
6
+ import type * as SharedApi from '@/shared/lib/api';
7
+
8
+ const { deleteNcpSessionMock, deleteSummaryMock } = vi.hoisted(() => ({
9
+ deleteNcpSessionMock: vi.fn(async () => ({ deleted: true, sessionId: 'parent-session-1' })),
10
+ deleteSummaryMock: vi.fn(),
11
+ }));
12
+
13
+ vi.mock('@/shared/lib/api', async (importOriginal) => {
14
+ const actual = await importOriginal<typeof SharedApi>();
15
+ return {
16
+ ...actual,
17
+ deleteNcpSession: deleteNcpSessionMock,
18
+ deleteNcpSessionSummaryInQueryClient: deleteSummaryMock,
19
+ };
20
+ });
21
+
22
+ beforeEach(() => {
23
+ useChatSessionListStore.setState({
24
+ optimisticReadAtBySessionKey: {},
25
+ snapshot: {
26
+ ...useChatSessionListStore.getState().snapshot,
27
+ selectedSessionKey: 'parent-session-1',
28
+ },
29
+ });
30
+ useChatThreadStore.setState({
31
+ snapshot: {
32
+ ...useChatThreadStore.getState().snapshot,
33
+ sessionKey: 'parent-session-1',
34
+ workspacePanelParentKey: null,
35
+ childSessionTabs: [
36
+ {
37
+ sessionKey: 'child-session-1',
38
+ parentSessionKey: 'parent-session-1',
39
+ label: 'Child Session 1',
40
+ agentId: 'reviewer',
41
+ },
42
+ ],
43
+ activeChildSessionKey: null,
44
+ workspaceFileTabs: [],
45
+ activeWorkspaceFileKey: null,
46
+ workspaceNavigationHistory: [],
47
+ workspaceNavigationHistoryIndex: 0,
48
+ },
49
+ });
50
+ });
51
+
52
+ function createUiManager(
53
+ overrides: Record<string, unknown> = {},
54
+ ): ConstructorParameters<typeof ChatThreadManager>[0] {
55
+ return {
56
+ goToSession: vi.fn(),
57
+ goToChatRoot: vi.fn(),
58
+ goToProviders: vi.fn(),
59
+ confirm: vi.fn(),
60
+ isCompactViewport: vi.fn(() => false),
61
+ showContent: vi.fn().mockResolvedValue(undefined),
62
+ ...overrides,
63
+ } as unknown as ConstructorParameters<typeof ChatThreadManager>[0];
64
+ }
65
+
66
+ describe('ChatThreadManager', () => {
67
+ it('opens the child-session panel for the requested parent session and keeps focus on the chosen child', () => {
68
+ const uiManager = {
69
+ goToSession: vi.fn(),
70
+ goToChatRoot: vi.fn(),
71
+ goToProviders: vi.fn(),
72
+ confirm: vi.fn(),
73
+ } as unknown as ConstructorParameters<typeof ChatThreadManager>[0];
74
+
75
+ const manager = new ChatThreadManager(
76
+ uiManager,
77
+ {} as ConstructorParameters<typeof ChatThreadManager>[1],
78
+ {} as ConstructorParameters<typeof ChatThreadManager>[2],
79
+ );
80
+
81
+ manager.openChildSessionPanel({
82
+ parentSessionKey: 'parent-session-1',
83
+ activeChildSessionKey: 'child-session-1',
84
+ });
85
+
86
+ expect(useChatThreadStore.getState().snapshot.workspacePanelParentKey).toBe('parent-session-1');
87
+ expect(useChatThreadStore.getState().snapshot.activeChildSessionKey).toBe('child-session-1');
88
+ expect(uiManager.goToSession).not.toHaveBeenCalled();
89
+ });
90
+
91
+ it('routes to the parent session before opening the child-session panel when needed', () => {
92
+ useChatSessionListStore.setState({
93
+ snapshot: {
94
+ ...useChatSessionListStore.getState().snapshot,
95
+ selectedSessionKey: 'another-session',
96
+ },
97
+ });
98
+ const uiManager = {
99
+ goToSession: vi.fn(),
100
+ goToChatRoot: vi.fn(),
101
+ goToProviders: vi.fn(),
102
+ confirm: vi.fn(),
103
+ } as unknown as ConstructorParameters<typeof ChatThreadManager>[0];
104
+
105
+ const manager = new ChatThreadManager(
106
+ uiManager,
107
+ {} as ConstructorParameters<typeof ChatThreadManager>[1],
108
+ {} as ConstructorParameters<typeof ChatThreadManager>[2],
109
+ );
110
+
111
+ manager.openChildSessionPanel({
112
+ parentSessionKey: 'parent-session-1',
113
+ activeChildSessionKey: 'child-session-1',
114
+ });
115
+
116
+ expect(uiManager.goToSession).toHaveBeenCalledWith('parent-session-1');
117
+ });
118
+
119
+ it('opens the session cron panel without changing route when already selected', () => {
120
+ const uiManager = {
121
+ goToSession: vi.fn(),
122
+ goToChatRoot: vi.fn(),
123
+ goToProviders: vi.fn(),
124
+ confirm: vi.fn(),
125
+ } as unknown as ConstructorParameters<typeof ChatThreadManager>[0];
126
+
127
+ const manager = new ChatThreadManager(
128
+ uiManager,
129
+ {} as ConstructorParameters<typeof ChatThreadManager>[1],
130
+ {} as ConstructorParameters<typeof ChatThreadManager>[2],
131
+ );
132
+
133
+ manager.openSessionCronPanel('parent-session-1');
134
+
135
+ expect(useChatThreadStore.getState().snapshot).toMatchObject({
136
+ workspacePanelParentKey: 'parent-session-1',
137
+ activeWorkspacePanelKind: 'cron',
138
+ activeChildSessionKey: null,
139
+ activeWorkspaceFileKey: null,
140
+ });
141
+ expect(uiManager.goToSession).not.toHaveBeenCalled();
142
+ });
143
+
144
+ it('routes to the session before opening its cron panel when needed', () => {
145
+ useChatSessionListStore.setState({
146
+ snapshot: {
147
+ ...useChatSessionListStore.getState().snapshot,
148
+ selectedSessionKey: 'another-session',
149
+ },
150
+ });
151
+ const uiManager = {
152
+ goToSession: vi.fn(),
153
+ goToChatRoot: vi.fn(),
154
+ goToProviders: vi.fn(),
155
+ confirm: vi.fn(),
156
+ } as unknown as ConstructorParameters<typeof ChatThreadManager>[0];
157
+
158
+ const manager = new ChatThreadManager(
159
+ uiManager,
160
+ {} as ConstructorParameters<typeof ChatThreadManager>[1],
161
+ {} as ConstructorParameters<typeof ChatThreadManager>[2],
162
+ );
163
+
164
+ manager.openSessionCronPanel('parent-session-1');
165
+
166
+ expect(uiManager.goToSession).toHaveBeenCalledWith('parent-session-1');
167
+ });
168
+
169
+ it('keeps preview and diff for the same file as separate workspace tabs', () => {
170
+ const uiManager = {
171
+ goToSession: vi.fn(),
172
+ goToChatRoot: vi.fn(),
173
+ goToProviders: vi.fn(),
174
+ confirm: vi.fn(),
175
+ } as unknown as ConstructorParameters<typeof ChatThreadManager>[0];
176
+
177
+ const manager = new ChatThreadManager(
178
+ uiManager,
179
+ {} as ConstructorParameters<typeof ChatThreadManager>[1],
180
+ {} as ConstructorParameters<typeof ChatThreadManager>[2],
181
+ );
182
+
183
+ manager.openFilePreview({
184
+ path: 'README.md',
185
+ label: 'README.md',
186
+ viewMode: 'preview',
187
+ });
188
+ manager.openFilePreview({
189
+ path: 'README.md',
190
+ label: 'README.md',
191
+ viewMode: 'diff',
192
+ beforeText: 'old\n',
193
+ afterText: 'new\n',
194
+ });
195
+
196
+ expect(useChatThreadStore.getState().snapshot.workspaceFileTabs).toEqual(
197
+ expect.arrayContaining([
198
+ expect.objectContaining({
199
+ key: 'parent-session-1::preview::README.md',
200
+ path: 'README.md',
201
+ viewMode: 'preview',
202
+ }),
203
+ expect.objectContaining({
204
+ key: 'parent-session-1::diff::README.md',
205
+ path: 'README.md',
206
+ viewMode: 'diff',
207
+ }),
208
+ ]),
209
+ );
210
+ });
211
+ });
212
+
213
+ describe('ChatThreadManager workspace navigation', () => {
214
+ it('navigates backward and forward through workspace selections', () => {
215
+ const uiManager = {
216
+ goToSession: vi.fn(),
217
+ goToChatRoot: vi.fn(),
218
+ goToProviders: vi.fn(),
219
+ confirm: vi.fn(),
220
+ } as unknown as ConstructorParameters<typeof ChatThreadManager>[0];
221
+ const manager = new ChatThreadManager(
222
+ uiManager,
223
+ {} as ConstructorParameters<typeof ChatThreadManager>[1],
224
+ {} as ConstructorParameters<typeof ChatThreadManager>[2],
225
+ );
226
+
227
+ manager.openChildSessionPanel({
228
+ parentSessionKey: 'parent-session-1',
229
+ activeChildSessionKey: 'child-session-1',
230
+ });
231
+ manager.openFilePreview({
232
+ path: 'README.md',
233
+ label: 'README.md',
234
+ viewMode: 'preview',
235
+ });
236
+ manager.openSessionCronPanel('parent-session-1');
237
+
238
+ expect(useChatThreadStore.getState().snapshot.workspaceNavigationHistory).toEqual([
239
+ { kind: 'child-session', key: 'child-session-1' },
240
+ { kind: 'file', key: 'parent-session-1::preview::README.md' },
241
+ { kind: 'cron' },
242
+ ]);
243
+
244
+ manager.goBackWorkspacePanel();
245
+ expect(useChatThreadStore.getState().snapshot).toMatchObject({
246
+ activeWorkspacePanelKind: 'file',
247
+ activeWorkspaceFileKey: 'parent-session-1::preview::README.md',
248
+ workspaceNavigationHistoryIndex: 1,
249
+ });
250
+
251
+ manager.goBackWorkspacePanel();
252
+ expect(useChatThreadStore.getState().snapshot).toMatchObject({
253
+ activeWorkspacePanelKind: 'child-session',
254
+ activeChildSessionKey: 'child-session-1',
255
+ workspaceNavigationHistoryIndex: 0,
256
+ });
257
+
258
+ manager.goForwardWorkspacePanel();
259
+ expect(useChatThreadStore.getState().snapshot).toMatchObject({
260
+ activeWorkspacePanelKind: 'file',
261
+ activeWorkspaceFileKey: 'parent-session-1::preview::README.md',
262
+ workspaceNavigationHistoryIndex: 1,
263
+ });
264
+ });
265
+
266
+ it('truncates workspace forward history after selecting a new entry', () => {
267
+ useChatThreadStore.getState().setSnapshot({
268
+ childSessionTabs: [
269
+ ...useChatThreadStore.getState().snapshot.childSessionTabs,
270
+ {
271
+ sessionKey: 'child-session-2',
272
+ parentSessionKey: 'parent-session-1',
273
+ label: 'Child Session 2',
274
+ agentId: 'writer',
275
+ },
276
+ ],
277
+ });
278
+ const manager = new ChatThreadManager(
279
+ { goToSession: vi.fn() } as unknown as ConstructorParameters<typeof ChatThreadManager>[0],
280
+ {} as ConstructorParameters<typeof ChatThreadManager>[1],
281
+ {} as ConstructorParameters<typeof ChatThreadManager>[2],
282
+ );
283
+
284
+ manager.openChildSessionPanel({
285
+ parentSessionKey: 'parent-session-1',
286
+ activeChildSessionKey: 'child-session-1',
287
+ });
288
+ manager.openFilePreview({
289
+ path: 'README.md',
290
+ label: 'README.md',
291
+ viewMode: 'preview',
292
+ });
293
+ manager.goBackWorkspacePanel();
294
+ manager.selectChildSessionDetail('child-session-2');
295
+
296
+ expect(useChatThreadStore.getState().snapshot.workspaceNavigationHistory).toEqual([
297
+ { kind: 'child-session', key: 'child-session-1' },
298
+ { kind: 'child-session', key: 'child-session-2' },
299
+ ]);
300
+ expect(useChatThreadStore.getState().snapshot.workspaceNavigationHistoryIndex).toBe(1);
301
+ });
302
+
303
+ it('removes a closed active file from workspace history and restores the previous entry', () => {
304
+ const manager = new ChatThreadManager(
305
+ { goToSession: vi.fn() } as unknown as ConstructorParameters<typeof ChatThreadManager>[0],
306
+ {} as ConstructorParameters<typeof ChatThreadManager>[1],
307
+ {} as ConstructorParameters<typeof ChatThreadManager>[2],
308
+ );
309
+
310
+ manager.openChildSessionPanel({
311
+ parentSessionKey: 'parent-session-1',
312
+ activeChildSessionKey: 'child-session-1',
313
+ });
314
+ manager.openFilePreview({
315
+ path: 'README.md',
316
+ label: 'README.md',
317
+ viewMode: 'preview',
318
+ });
319
+ manager.closeWorkspaceFile('parent-session-1::preview::README.md');
320
+
321
+ expect(useChatThreadStore.getState().snapshot).toMatchObject({
322
+ activeWorkspacePanelKind: 'child-session',
323
+ activeChildSessionKey: 'child-session-1',
324
+ activeWorkspaceFileKey: null,
325
+ workspaceNavigationHistory: [
326
+ { kind: 'child-session', key: 'child-session-1' },
327
+ ],
328
+ workspaceNavigationHistoryIndex: 0,
329
+ });
330
+ });
331
+ });
332
+
333
+ describe('ChatThreadManager showContent', () => {
334
+ it('routes tool actions through the thread manager owner', async () => {
335
+ const uiManager = createUiManager({
336
+ goToSession: vi.fn(),
337
+ });
338
+ const manager = new ChatThreadManager(
339
+ uiManager,
340
+ {} as ConstructorParameters<typeof ChatThreadManager>[1],
341
+ {} as ConstructorParameters<typeof ChatThreadManager>[2],
342
+ );
343
+
344
+ await manager.handleToolAction({
345
+ kind: 'show-content',
346
+ label: 'Show content',
347
+ request: {
348
+ target: {
349
+ type: 'url',
350
+ payload: {
351
+ url: 'https://example.com/read',
352
+ },
353
+ },
354
+ title: 'Example URL',
355
+ },
356
+ });
357
+ await manager.handleToolAction({
358
+ kind: 'open-session',
359
+ sessionId: 'child-session-1',
360
+ sessionKind: 'session',
361
+ });
362
+
363
+ expect(uiManager.showContent).toHaveBeenCalledWith({
364
+ target: {
365
+ type: 'url',
366
+ payload: {
367
+ url: 'https://example.com/read',
368
+ },
369
+ },
370
+ title: 'Example URL',
371
+ });
372
+ expect(uiManager.goToSession).toHaveBeenCalledWith('child-session-1');
373
+ });
374
+
375
+ it('shows file content through the existing workspace file preview', async () => {
376
+ const manager = new ChatThreadManager(
377
+ { goToSession: vi.fn() } as unknown as ConstructorParameters<typeof ChatThreadManager>[0],
378
+ {} as ConstructorParameters<typeof ChatThreadManager>[1],
379
+ {} as ConstructorParameters<typeof ChatThreadManager>[2],
380
+ );
381
+
382
+ await manager.handleToolAction({
383
+ kind: 'show-content',
384
+ label: 'Show content',
385
+ request: {
386
+ target: {
387
+ type: 'file',
388
+ payload: {
389
+ path: 'docs/example.md',
390
+ line: 5,
391
+ },
392
+ },
393
+ title: 'Example',
394
+ purpose: 'read',
395
+ },
396
+ });
397
+
398
+ expect(useChatThreadStore.getState().snapshot).toMatchObject({
399
+ activeWorkspacePanelKind: 'file',
400
+ activeWorkspaceFileKey: 'parent-session-1::preview::docs/example.md',
401
+ workspaceFileTabs: [
402
+ expect.objectContaining({
403
+ path: 'docs/example.md',
404
+ label: 'Example',
405
+ line: 5,
406
+ viewMode: 'preview',
407
+ }),
408
+ ],
409
+ });
410
+ });
411
+
412
+ it('shows URL and panel app content through DocBrowser', async () => {
413
+ const uiManager = createUiManager();
414
+ const manager = new ChatThreadManager(
415
+ uiManager,
416
+ {} as ConstructorParameters<typeof ChatThreadManager>[1],
417
+ {} as ConstructorParameters<typeof ChatThreadManager>[2],
418
+ );
419
+
420
+ await manager.handleToolAction({
421
+ kind: 'show-content',
422
+ label: 'Show content',
423
+ request: {
424
+ target: {
425
+ type: 'url',
426
+ payload: {
427
+ url: 'https://example.com/read',
428
+ },
429
+ },
430
+ title: 'Example URL',
431
+ },
432
+ });
433
+ await manager.handleToolAction({
434
+ kind: 'show-content',
435
+ label: 'Show content',
436
+ request: {
437
+ target: {
438
+ type: 'panel_app',
439
+ payload: {
440
+ appId: 'reader',
441
+ },
442
+ },
443
+ title: 'Reader',
444
+ },
445
+ });
446
+
447
+ expect(uiManager.showContent).toHaveBeenCalledWith({
448
+ target: {
449
+ type: 'url',
450
+ payload: {
451
+ url: 'https://example.com/read',
452
+ },
453
+ },
454
+ title: 'Example URL',
455
+ });
456
+ expect(uiManager.showContent).toHaveBeenCalledWith({
457
+ target: {
458
+ type: 'panel_app',
459
+ payload: {
460
+ appId: 'reader',
461
+ },
462
+ },
463
+ title: 'Reader',
464
+ });
465
+ });
466
+
467
+ it('handles ui.show-content events once through the same owner path', async () => {
468
+ const uiManager = createUiManager();
469
+ const manager = new ChatThreadManager(
470
+ uiManager,
471
+ {} as ConstructorParameters<typeof ChatThreadManager>[1],
472
+ {} as ConstructorParameters<typeof ChatThreadManager>[2],
473
+ );
474
+
475
+ await manager.handleUiShowContentEvent({
476
+ id: 'tool:call-show-content-1:show-content',
477
+ toolCallId: 'call-show-content-1',
478
+ target: {
479
+ type: 'url',
480
+ payload: {
481
+ url: 'https://example.com/read',
482
+ },
483
+ },
484
+ title: 'Example URL',
485
+ purpose: 'read',
486
+ placement: undefined,
487
+ });
488
+ await manager.handleUiShowContentEvent({
489
+ id: 'tool:call-show-content-1:show-content',
490
+ toolCallId: 'call-show-content-1',
491
+ target: {
492
+ type: 'url',
493
+ payload: {
494
+ url: 'https://example.com/read',
495
+ },
496
+ },
497
+ title: 'Example URL',
498
+ purpose: 'read',
499
+ placement: undefined,
500
+ });
501
+
502
+ expect(uiManager.showContent).toHaveBeenCalledTimes(1);
503
+ expect(uiManager.showContent).toHaveBeenCalledWith({
504
+ target: {
505
+ type: 'url',
506
+ payload: {
507
+ url: 'https://example.com/read',
508
+ },
509
+ },
510
+ title: 'Example URL',
511
+ });
512
+ });
513
+
514
+ it('delegates panel app content to the UI manager owner', async () => {
515
+ const uiManager = createUiManager();
516
+ const manager = new ChatThreadManager(
517
+ uiManager,
518
+ {} as ConstructorParameters<typeof ChatThreadManager>[1],
519
+ {} as ConstructorParameters<typeof ChatThreadManager>[2],
520
+ );
521
+
522
+ await manager.handleToolAction({
523
+ kind: 'show-content',
524
+ label: 'Show content',
525
+ request: {
526
+ target: {
527
+ type: 'panel_app',
528
+ payload: {
529
+ appId: 'encoded-reader',
530
+ },
531
+ },
532
+ title: 'Reader',
533
+ },
534
+ });
535
+
536
+ expect(uiManager.showContent).toHaveBeenCalledWith({
537
+ target: {
538
+ type: 'panel_app',
539
+ payload: {
540
+ appId: 'encoded-reader',
541
+ },
542
+ },
543
+ title: 'Reader',
544
+ });
545
+ });
546
+
547
+ });
548
+
549
+ describe('ChatThreadManager inline showContent', () => {
550
+ it('does not auto-open inline panel app content outside the message card', async () => {
551
+ const uiManager = createUiManager();
552
+ const manager = new ChatThreadManager(
553
+ uiManager,
554
+ {} as ConstructorParameters<typeof ChatThreadManager>[1],
555
+ {} as ConstructorParameters<typeof ChatThreadManager>[2],
556
+ );
557
+
558
+ await manager.handleUiShowContentEvent({
559
+ id: 'tool:call-show-content-inline:show-content',
560
+ toolCallId: 'call-show-content-inline',
561
+ target: {
562
+ type: 'panel_app',
563
+ payload: {
564
+ appId: 'reader',
565
+ },
566
+ },
567
+ title: 'Reader',
568
+ purpose: 'interact',
569
+ placement: 'inline',
570
+ });
571
+
572
+ expect(uiManager.showContent).not.toHaveBeenCalled();
573
+ });
574
+ });
575
+
576
+ describe('ChatThreadManager visible workspace selection', () => {
577
+ it('delegates visible child-session read state to the session list owner', () => {
578
+ const sessionListManager = {
579
+ markVisibleWorkspaceChildRead: vi.fn(),
580
+ } as unknown as ConstructorParameters<typeof ChatThreadManager>[1];
581
+ const manager = new ChatThreadManager(
582
+ { goToSession: vi.fn() } as unknown as ConstructorParameters<typeof ChatThreadManager>[0],
583
+ sessionListManager,
584
+ {} as ConstructorParameters<typeof ChatThreadManager>[2],
585
+ );
586
+ const tab = {
587
+ sessionKey: 'child-session-1',
588
+ lastMessageAt: '2026-04-10T10:00:00.000Z',
589
+ readAt: null,
590
+ runStatus: 'completed',
591
+ };
592
+
593
+ manager.syncVisibleWorkspaceSelection({ kind: 'child-session', tab });
594
+ manager.syncVisibleWorkspaceSelection({ kind: 'file' });
595
+ manager.syncVisibleWorkspaceSelection(null);
596
+
597
+ expect(sessionListManager.markVisibleWorkspaceChildRead).toHaveBeenCalledTimes(1);
598
+ expect(sessionListManager.markVisibleWorkspaceChildRead).toHaveBeenCalledWith(tab);
599
+ });
600
+ });
601
+
602
+ describe('ChatThreadManager deletion', () => {
603
+ it('clears the selected thread state after deleting the current session', async () => {
604
+ const removeQueries = vi.spyOn(appQueryClient, 'removeQueries').mockImplementation(async () => undefined);
605
+ const uiManager = {
606
+ goToSession: vi.fn(),
607
+ goToChatRoot: vi.fn(),
608
+ goToProviders: vi.fn(),
609
+ confirm: vi.fn(async () => true),
610
+ } as unknown as ConstructorParameters<typeof ChatThreadManager>[0];
611
+ const sessionListManager = {
612
+ setSelectedSessionKey: vi.fn((value: string | null) => {
613
+ useChatSessionListStore.getState().setSnapshot({
614
+ selectedSessionKey: value,
615
+ });
616
+ }),
617
+ } as unknown as ConstructorParameters<typeof ChatThreadManager>[1];
618
+ const chatRunManager = {
619
+ clearRunState: vi.fn(),
620
+ } as unknown as ConstructorParameters<typeof ChatThreadManager>[2];
621
+ const manager = new ChatThreadManager(
622
+ uiManager,
623
+ sessionListManager,
624
+ chatRunManager,
625
+ );
626
+
627
+ await manager.deleteSession();
628
+
629
+ expect(sessionListManager.setSelectedSessionKey).toHaveBeenCalledWith(null);
630
+ expect(useChatSessionListStore.getState().snapshot.selectedSessionKey).toBeNull();
631
+ expect(useChatThreadStore.getState().snapshot).toMatchObject({
632
+ sessionKey: null,
633
+ canDeleteSession: false,
634
+ messages: [],
635
+ workspacePanelParentKey: null,
636
+ childSessionTabs: [],
637
+ activeChildSessionKey: null,
638
+ workspaceFileTabs: [],
639
+ activeWorkspaceFileKey: null,
640
+ workspaceNavigationHistory: [],
641
+ workspaceNavigationHistoryIndex: 0,
642
+ });
643
+ expect(chatRunManager.clearRunState).toHaveBeenCalledTimes(1);
644
+ expect(deleteSummaryMock).toHaveBeenCalledWith(appQueryClient, 'parent-session-1');
645
+ expect(removeQueries).toHaveBeenCalledWith({
646
+ queryKey: ['ncp-session-messages', 'parent-session-1'],
647
+ });
648
+ expect(uiManager.goToChatRoot).toHaveBeenCalledWith({ replace: true });
649
+
650
+ removeQueries.mockRestore();
651
+ });
652
+ });