cx-chat 0.0.1

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 (404) hide show
  1. package/.cursor/rules/i18n-cn-gloss-comments.mdc +31 -0
  2. package/.cursor/rules/list-page-view-pageconfig.mdc +32 -0
  3. package/.cursor/rules/no-over-defensive-programming.mdc +90 -0
  4. package/.cursor/rules/requirement-description-for-agent.mdc +33 -0
  5. package/.cursor/rules/use-showToast-not-antd-message.mdc +28 -0
  6. package/.docker/Dockerfile +7 -0
  7. package/.env +9 -0
  8. package/.env.development +7 -0
  9. package/.env.production +7 -0
  10. package/.gitlab-ci/docker-build.yaml +28 -0
  11. package/.gitlab-ci/k8s-deploy-dev-master.yaml +42 -0
  12. package/.gitlab-ci/npm-build.yaml +17 -0
  13. package/.gitlab-ci.yml +8 -0
  14. package/.k8s/0-namespace.yaml +6 -0
  15. package/.k8s/1-configmap-web.yaml +7 -0
  16. package/.k8s/1-nginx-conf-dev.yaml +110 -0
  17. package/.k8s/2-deployment.yaml +27 -0
  18. package/.k8s/3-service.yaml +16 -0
  19. package/.k8s/4-ingress-dev.yaml +30 -0
  20. package/.lingma/rules/use-showToast-not-antd-message.md +34 -0
  21. package/.nginx/nginx.conf +52 -0
  22. package/.prettierrc +9 -0
  23. package/README.md +1 -0
  24. package/eslint.config.js +32 -0
  25. package/index.html +13 -0
  26. package/package.json +67 -0
  27. package/postcss.config.js +6 -0
  28. package/public/favicon.ico +0 -0
  29. package/public/vite.svg +1 -0
  30. package/src/App.tsx +96 -0
  31. package/src/_doc/0.docs-overview.md +28 -0
  32. package/src/_doc/cx-ui/0.docs-overview.md +30 -0
  33. package/src/_doc/cx-ui/comp.1.cx-ui-overview.md +82 -0
  34. package/src/_doc/cx-ui/comp.2.cx-modal.md +82 -0
  35. package/src/_doc/cx-ui/comp.3.cx-button.md +89 -0
  36. package/src/_doc/cx-ui/comp.4.cx-form.md +72 -0
  37. package/src/_doc/cx-ui/comp.5.cx-fields.md +76 -0
  38. package/src/_doc/cx-ui/comp.6.cx-tag.md +57 -0
  39. package/src/_doc/cx-ui/comp.7.cx-empty-state.md +29 -0
  40. package/src/_doc/meta/0.docs-overview.md +24 -0
  41. package/src/_doc/meta/comp.1.enum-runtime.md +33 -0
  42. package/src/_doc/meta/comp.2.dict-runtime.md +39 -0
  43. package/src/_doc/router/0.docs-overview.md +14 -0
  44. package/src/_doc/router/guide.1.menu-component-config.md +181 -0
  45. package/src/_doc/router/guide.2.router-auto-registration.md +114 -0
  46. package/src/_doc/table-view/0.docs-overview.md +30 -0
  47. package/src/_doc/table-view/comp.1.table-view.md +542 -0
  48. package/src/_doc/table-view/props.1.create-table-view-config.md +193 -0
  49. package/src/_doc/table-view/props.2.table-view-search-fields.md +106 -0
  50. package/src/api/_mock/README.md +340 -0
  51. package/src/api/_mock/api.ts +1642 -0
  52. package/src/api/_mock/bundle-shim.ts +16 -0
  53. package/src/api/_mock/handler-shim.ts +6 -0
  54. package/src/api/_mock/handler.ts +458 -0
  55. package/src/api/_mock/index.ts +711 -0
  56. package/src/api/_mock/interceptor.ts +15 -0
  57. package/src/api/_mock/mod.ts +12 -0
  58. package/src/api/_mock/utils.ts +65 -0
  59. package/src/api/base/memory.js +24 -0
  60. package/src/api/chat.js +210 -0
  61. package/src/api/common/auth.js +70 -0
  62. package/src/api/menus/business-rules.js +76 -0
  63. package/src/api/menus/feedback.js +102 -0
  64. package/src/api/menus/knowledge.js +159 -0
  65. package/src/api/menus/model-metadata/manage.js +70 -0
  66. package/src/api/menus/model-metadata/role.js +50 -0
  67. package/src/api/menus/model-metadata/training-detail-mock-data.js +569 -0
  68. package/src/api/menus/model-metadata/training.js +28 -0
  69. package/src/api/menus/skill.js +40 -0
  70. package/src/api/system/agent-config.js +16 -0
  71. package/src/api/system/department.js +94 -0
  72. package/src/api/system/dict.js +86 -0
  73. package/src/api/system/menu.js +37 -0
  74. package/src/api/system/permission.js +26 -0
  75. package/src/api/system/role.js +34 -0
  76. package/src/api/system/sys-config.js +16 -0
  77. package/src/api/system/sys-log.js +17 -0
  78. package/src/api/system/user.js +75 -0
  79. package/src/api/upload.js +39 -0
  80. package/src/assets/react.svg +1 -0
  81. package/src/components/auth/current-user-avatar.tsx +77 -0
  82. package/src/components/common/code-view.tsx +149 -0
  83. package/src/components/common/detail-link.tsx +67 -0
  84. package/src/components/common/error-boundary.tsx +98 -0
  85. package/src/components/common/language-switcher.tsx +91 -0
  86. package/src/components/common/lite-table/index.tsx +135 -0
  87. package/src/components/common/md-editor.tsx +126 -0
  88. package/src/components/common/modal/confirm-dialog.tsx +113 -0
  89. package/src/components/common/modal/dep-user-select-multi.tsx +324 -0
  90. package/src/components/common/modal/dep-user-select.tsx +249 -0
  91. package/src/components/common/modal/user-select-multi.tsx +266 -0
  92. package/src/components/common/pagination.tsx +472 -0
  93. package/src/components/common/path.tsx +175 -0
  94. package/src/components/common/system-logo-mark.tsx +48 -0
  95. package/src/components/cx-ui/button/index.less +208 -0
  96. package/src/components/cx-ui/button/index.tsx +611 -0
  97. package/src/components/cx-ui/checkbox/index.tsx +78 -0
  98. package/src/components/cx-ui/date-picker/index.less +17 -0
  99. package/src/components/cx-ui/date-picker/index.tsx +193 -0
  100. package/src/components/cx-ui/drawer/index.tsx +47 -0
  101. package/src/components/cx-ui/empty-state/index.tsx +20 -0
  102. package/src/components/cx-ui/floating-shell/CxFloatingShell.tsx +89 -0
  103. package/src/components/cx-ui/floating-shell/cx-floating-shell.less +283 -0
  104. package/src/components/cx-ui/floating-shell/has-floating-value.ts +41 -0
  105. package/src/components/cx-ui/form/CxForm.tsx +15 -0
  106. package/src/components/cx-ui/form/index.tsx +20 -0
  107. package/src/components/cx-ui/form-item/index.less +26 -0
  108. package/src/components/cx-ui/form-item/index.tsx +36 -0
  109. package/src/components/cx-ui/index.ts +70 -0
  110. package/src/components/cx-ui/input/auto-complete.tsx +134 -0
  111. package/src/components/cx-ui/input/index.tsx +259 -0
  112. package/src/components/cx-ui/input-number/index.jsx +66 -0
  113. package/src/components/cx-ui/modal/index.jsx +212 -0
  114. package/src/components/cx-ui/modal/index.less +144 -0
  115. package/src/components/cx-ui/modal/useCxModal.ts +125 -0
  116. package/src/components/cx-ui/multi-select/index.jsx +74 -0
  117. package/src/components/cx-ui/multi-select/index.less +40 -0
  118. package/src/components/cx-ui/multi-select/index2.tsx +361 -0
  119. package/src/components/cx-ui/radio/index.tsx +33 -0
  120. package/src/components/cx-ui/range-picker/index.less +65 -0
  121. package/src/components/cx-ui/range-picker/index.tsx +219 -0
  122. package/src/components/cx-ui/select/index.less +34 -0
  123. package/src/components/cx-ui/select/index.tsx +196 -0
  124. package/src/components/cx-ui/skeleton/index.tsx +12 -0
  125. package/src/components/cx-ui/steps/index.tsx +14 -0
  126. package/src/components/cx-ui/styles/_tokens.less +79 -0
  127. package/src/components/cx-ui/styles/index.less +246 -0
  128. package/src/components/cx-ui/switch/index.less +106 -0
  129. package/src/components/cx-ui/switch/index.tsx +120 -0
  130. package/src/components/cx-ui/table/index.less +160 -0
  131. package/src/components/cx-ui/table/index.tsx +152 -0
  132. package/src/components/cx-ui/tabs/index.less +15 -0
  133. package/src/components/cx-ui/tabs/index.tsx +34 -0
  134. package/src/components/cx-ui/tag/index.less +51 -0
  135. package/src/components/cx-ui/tag/index.tsx +140 -0
  136. package/src/components/cx-ui/timeline/index.tsx +14 -0
  137. package/src/components/cx-ui/tooltip/index.tsx +67 -0
  138. package/src/components/cx-ui/tree/index.tsx +193 -0
  139. package/src/components/cx-ui/tree-select/index.jsx +91 -0
  140. package/src/components/cx-ui/tree-select/index.less +27 -0
  141. package/src/components/cx-ui/upload-file/index.less +223 -0
  142. package/src/components/cx-ui/upload-file/index.tsx +640 -0
  143. package/src/components/cx-ui/upload-img/index.tsx +291 -0
  144. package/src/components/layout/components/Header.tsx +216 -0
  145. package/src/components/layout/components/Sidebar.tsx +717 -0
  146. package/src/components/layout/index.tsx +95 -0
  147. package/src/components/table-view/components/search-area.tsx +411 -0
  148. package/src/components/table-view/components/table-view-config.tsx +528 -0
  149. package/src/components/table-view/components/table-view.types.ts +478 -0
  150. package/src/components/table-view/components/tree-api-normalize.ts +38 -0
  151. package/src/components/table-view/components/tree-data-annotate.ts +31 -0
  152. package/src/components/table-view/components/tree-sidebar.tsx +74 -0
  153. package/src/components/table-view/index.tsx +61 -0
  154. package/src/components/table-view/list-page-view.tsx +1049 -0
  155. package/src/components/table-view/select-table-view.tsx +1094 -0
  156. package/src/components/table-view/styles/select-table-view.less +51 -0
  157. package/src/config/default-system-name.ts +9 -0
  158. package/src/config/system.ts +165 -0
  159. package/src/constants/countryCodes.ts +3 -0
  160. package/src/contexts/AuthContext.tsx +256 -0
  161. package/src/contexts/ChatContext.tsx +839 -0
  162. package/src/contexts/MenuContext.tsx +62 -0
  163. package/src/contexts/ToastContext.tsx +181 -0
  164. package/src/hooks/useCopyToClipboard.ts +47 -0
  165. package/src/hooks/useModalSubmit.ts +104 -0
  166. package/src/hooks/useRouter.ts +240 -0
  167. package/src/hooks/useStepForm.ts +46 -0
  168. package/src/hooks/useStickyHeader.ts +42 -0
  169. package/src/hooks/useThreadActions.ts +105 -0
  170. package/src/hooks/useUserPreferences.ts +101 -0
  171. package/src/http/axios.js +372 -0
  172. package/src/http/mock.interceptor.ts +9 -0
  173. package/src/http/obfuscationKey.ts +41 -0
  174. package/src/i18n.ts +60 -0
  175. package/src/index.js +1 -0
  176. package/src/index.less +169 -0
  177. package/src/locales/en/auth.ts +70 -0
  178. package/src/locales/en/base/memory.ts +28 -0
  179. package/src/locales/en/base/settings.ts +41 -0
  180. package/src/locales/en/chat.ts +40 -0
  181. package/src/locales/en/common.ts +173 -0
  182. package/src/locales/en/enum.ts +27 -0
  183. package/src/locales/en/menus/business-rules.ts +48 -0
  184. package/src/locales/en/menus/feedback.ts +62 -0
  185. package/src/locales/en/menus/knowledge.ts +120 -0
  186. package/src/locales/en/menus/model-metadata/index.ts +10 -0
  187. package/src/locales/en/menus/model-metadata/manage.ts +151 -0
  188. package/src/locales/en/menus/model-metadata/role.ts +48 -0
  189. package/src/locales/en/menus/model-metadata/training.ts +65 -0
  190. package/src/locales/en/menus/skill.ts +34 -0
  191. package/src/locales/en/system/agent-config.ts +34 -0
  192. package/src/locales/en/system/department.ts +68 -0
  193. package/src/locales/en/system/dict.ts +44 -0
  194. package/src/locales/en/system/menu.ts +45 -0
  195. package/src/locales/en/system/permission.ts +89 -0
  196. package/src/locales/en/system/role.ts +25 -0
  197. package/src/locales/en/system/sys-config.ts +33 -0
  198. package/src/locales/en/system/sys-log.ts +38 -0
  199. package/src/locales/en/system/user.ts +113 -0
  200. package/src/locales/en.ts +68 -0
  201. package/src/locales/zh/auth.ts +70 -0
  202. package/src/locales/zh/base/memory.ts +29 -0
  203. package/src/locales/zh/base/settings.ts +41 -0
  204. package/src/locales/zh/chat.ts +47 -0
  205. package/src/locales/zh/common.ts +178 -0
  206. package/src/locales/zh/enum.ts +28 -0
  207. package/src/locales/zh/menus/business-rules.ts +47 -0
  208. package/src/locales/zh/menus/feedback.ts +62 -0
  209. package/src/locales/zh/menus/knowledge.ts +117 -0
  210. package/src/locales/zh/menus/model-metadata/index.ts +10 -0
  211. package/src/locales/zh/menus/model-metadata/manage.ts +151 -0
  212. package/src/locales/zh/menus/model-metadata/role.ts +47 -0
  213. package/src/locales/zh/menus/model-metadata/training.ts +64 -0
  214. package/src/locales/zh/menus/skill.ts +34 -0
  215. package/src/locales/zh/system/agent-config.ts +33 -0
  216. package/src/locales/zh/system/department.ts +69 -0
  217. package/src/locales/zh/system/dict.ts +44 -0
  218. package/src/locales/zh/system/menu.ts +47 -0
  219. package/src/locales/zh/system/permission.ts +94 -0
  220. package/src/locales/zh/system/role.ts +25 -0
  221. package/src/locales/zh/system/sys-config.ts +32 -0
  222. package/src/locales/zh/system/sys-log.ts +38 -0
  223. package/src/locales/zh/system/user.ts +114 -0
  224. package/src/locales/zh.ts +67 -0
  225. package/src/main.tsx +50 -0
  226. package/src/meta/const/index.ts +40 -0
  227. package/src/meta/index-dict.ts +56 -0
  228. package/src/meta/index-enum.ts +95 -0
  229. package/src/meta/index.ts +14 -0
  230. package/src/meta/module/dict-data/runtime.ts +199 -0
  231. package/src/meta/module/dict-data/types.ts +17 -0
  232. package/src/meta/module/enum-data/runtime.ts +75 -0
  233. package/src/meta/module/enum-data/types.ts +18 -0
  234. package/src/router/index.tsx +312 -0
  235. package/src/styles/AntdThemeProvider.tsx +40 -0
  236. package/src/styles/antd-theme.ts +20 -0
  237. package/src/styles/global.less +107 -0
  238. package/src/styles/variable.less +103 -0
  239. package/src/types/feedback.ts +43 -0
  240. package/src/types/index.ts +85 -0
  241. package/src/types/menu.ts +43 -0
  242. package/src/utils/aesUtil.ts +123 -0
  243. package/src/utils/chatUtils.ts +524 -0
  244. package/src/utils/cn.ts +6 -0
  245. package/src/utils/crypto.ts +164 -0
  246. package/src/utils/date.ts +72 -0
  247. package/src/utils/file-icons.tsx +79 -0
  248. package/src/utils/index.ts +168 -0
  249. package/src/utils/markdown-math-plugins.ts +21 -0
  250. package/src/utils/menuI18n.ts +305 -0
  251. package/src/utils/menuRouteRegistry.ts +78 -0
  252. package/src/utils/permission-crud.ts +147 -0
  253. package/src/utils/routeConfig.ts +350 -0
  254. package/src/utils/storage.ts +135 -0
  255. package/src/utils/toastBridge.ts +26 -0
  256. package/src/utils/url.ts +38 -0
  257. package/src/utils/validation.ts +16 -0
  258. package/src/views/auth/auth-code/index.less +169 -0
  259. package/src/views/auth/auth-code/index.module.less +174 -0
  260. package/src/views/auth/auth-code/index.tsx +233 -0
  261. package/src/views/auth/login.tsx +498 -0
  262. package/src/views/auth/register.tsx +388 -0
  263. package/src/views/base/memory/index.tsx +136 -0
  264. package/src/views/base/memory/modal/detail-modal.tsx +89 -0
  265. package/src/views/base/memory/modal/submit-modal.tsx +134 -0
  266. package/src/views/base/settings/index.tsx +657 -0
  267. package/src/views/chat/chat.less +323 -0
  268. package/src/views/chat/components/chat-input.tsx +298 -0
  269. package/src/views/chat/components/header-thread-title.tsx +210 -0
  270. package/src/views/chat/components/message-list/content-answer.tsx +100 -0
  271. package/src/views/chat/components/message-list/content-question.tsx +18 -0
  272. package/src/views/chat/components/message-list/index.tsx +520 -0
  273. package/src/views/chat/components/message-list/message-item.tsx +199 -0
  274. package/src/views/chat/components/message-list/preparation-demo-items.ts +147 -0
  275. package/src/views/chat/components/message-list/preparation-steps.tsx +506 -0
  276. package/src/views/chat/components/message-list/suggestion-list.tsx +36 -0
  277. package/src/views/chat/components/message-list/thinking-process.tsx +49 -0
  278. package/src/views/chat/components/message-list/toolbar.tsx +224 -0
  279. package/src/views/chat/components/message-list/use-message-list-scroll.ts +214 -0
  280. package/src/views/chat/components/references-knowledge/context.tsx +57 -0
  281. package/src/views/chat/components/references-knowledge/index.ts +9 -0
  282. package/src/views/chat/components/references-knowledge/modal/knowledge-detail-drawer.tsx +556 -0
  283. package/src/views/chat/components/references-knowledge/modal/knowledge-doc-detail-drawer.tsx +529 -0
  284. package/src/views/chat/components/references-knowledge/panel.tsx +115 -0
  285. package/src/views/chat/hooks/use-chat-common.ts +19 -0
  286. package/src/views/chat/index-session.tsx +647 -0
  287. package/src/views/chat/index.tsx +127 -0
  288. package/src/views/page-error/401.tsx +56 -0
  289. package/src/views/page-error/404.tsx +56 -0
  290. package/src/views/page-menus/business-rules/index.tsx +376 -0
  291. package/src/views/page-menus/business-rules/modal/detail-modal.tsx +186 -0
  292. package/src/views/page-menus/business-rules/modal/scope-modal.tsx +272 -0
  293. package/src/views/page-menus/business-rules/modal/submit-modal.tsx +142 -0
  294. package/src/views/page-menus/feedback/components/feedback-dataset-list.tsx +471 -0
  295. package/src/views/page-menus/feedback/index.tsx +166 -0
  296. package/src/views/page-menus/feedback/modal/export-feedback-modal.tsx +367 -0
  297. package/src/views/page-menus/knowledge/components/doc-editor-by-type.tsx +32 -0
  298. package/src/views/page-menus/knowledge/components/doc-editor-type-file.tsx +330 -0
  299. package/src/views/page-menus/knowledge/detail.tsx +600 -0
  300. package/src/views/page-menus/knowledge/index.tsx +337 -0
  301. package/src/views/page-menus/knowledge/modal/detail-modal.tsx +618 -0
  302. package/src/views/page-menus/knowledge/modal/doc-detail-modal.tsx +550 -0
  303. package/src/views/page-menus/knowledge/modal/doc-parse.ts +99 -0
  304. package/src/views/page-menus/knowledge/modal/doc-submit-modal.tsx +349 -0
  305. package/src/views/page-menus/knowledge/modal/doc-type-picker-modal.tsx +88 -0
  306. package/src/views/page-menus/knowledge/modal/knowledge-user-select-modal.tsx +283 -0
  307. package/src/views/page-menus/knowledge/modal/submit-modal.tsx +179 -0
  308. package/src/views/page-menus/model-metadata/manage/components/metadata-detail-schema-tab.tsx +114 -0
  309. package/src/views/page-menus/model-metadata/manage/components/step1-basic-info.tsx +232 -0
  310. package/src/views/page-menus/model-metadata/manage/components/step2-schema.tsx +316 -0
  311. package/src/views/page-menus/model-metadata/manage/components/step3-permissions.tsx +134 -0
  312. package/src/views/page-menus/model-metadata/manage/components/step4-documents.tsx +134 -0
  313. package/src/views/page-menus/model-metadata/manage/components/step5-example-sql.tsx +101 -0
  314. package/src/views/page-menus/model-metadata/manage/components/submit-add.tsx +338 -0
  315. package/src/views/page-menus/model-metadata/manage/components/submit-edit.tsx +276 -0
  316. package/src/views/page-menus/model-metadata/manage/detail.tsx +298 -0
  317. package/src/views/page-menus/model-metadata/manage/hooks/model-metadata-submit-shared.ts +113 -0
  318. package/src/views/page-menus/model-metadata/manage/hooks/use-model-metadata-item-state.ts +20 -0
  319. package/src/views/page-menus/model-metadata/manage/index.tsx +304 -0
  320. package/src/views/page-menus/model-metadata/manage/modal/components/table-schema.ts +374 -0
  321. package/src/views/page-menus/model-metadata/manage/modal/components/use-table-detail-tabs.tsx +151 -0
  322. package/src/views/page-menus/model-metadata/manage/modal/components/use-table-submit-tabs.tsx +423 -0
  323. package/src/views/page-menus/model-metadata/manage/modal/detail-modal.tsx +218 -0
  324. package/src/views/page-menus/model-metadata/manage/modal/submit-modal.tsx +261 -0
  325. package/src/views/page-menus/model-metadata/manage/modal/table-detail-modal.tsx +196 -0
  326. package/src/views/page-menus/model-metadata/manage/modal/table-submit-modal.tsx +229 -0
  327. package/src/views/page-menus/model-metadata/manage/submit.tsx +31 -0
  328. package/src/views/page-menus/model-metadata/role/index.tsx +207 -0
  329. package/src/views/page-menus/model-metadata/role/modal/detail-modal.tsx +97 -0
  330. package/src/views/page-menus/model-metadata/role/modal/role-assign-users-modal.tsx +254 -0
  331. package/src/views/page-menus/model-metadata/role/modal/role-assign-users-panel.tsx +393 -0
  332. package/src/views/page-menus/model-metadata/role/modal/role-assign-users-utils.ts +120 -0
  333. package/src/views/page-menus/model-metadata/role/modal/role-permission-assign-panel.tsx +698 -0
  334. package/src/views/page-menus/model-metadata/role/modal/role-permission-modal.tsx +237 -0
  335. package/src/views/page-menus/model-metadata/role/modal/submit-modal.tsx +135 -0
  336. package/src/views/page-menus/model-metadata/training/components/detail-records/index.ts +4 -0
  337. package/src/views/page-menus/model-metadata/training/components/detail-records/node-card.tsx +72 -0
  338. package/src/views/page-menus/model-metadata/training/components/detail-records/summary-lines.ts +196 -0
  339. package/src/views/page-menus/model-metadata/training/components/detail-records/summary-list.tsx +153 -0
  340. package/src/views/page-menus/model-metadata/training/components/detail-records/timeline.tsx +103 -0
  341. package/src/views/page-menus/model-metadata/training/components/detail-records/types.ts +82 -0
  342. package/src/views/page-menus/model-metadata/training/detail.tsx +159 -0
  343. package/src/views/page-menus/model-metadata/training/index.tsx +236 -0
  344. package/src/views/page-menus/model-metadata/training/modal/update-detail-modal.tsx +154 -0
  345. package/src/views/page-menus/skill/index.tsx +201 -0
  346. package/src/views/page-menus/skill/modal/detail-modal.tsx +156 -0
  347. package/src/views/page-menus/skill/modal/submit-modal.tsx +214 -0
  348. package/src/views/page-system/agent-config/index.tsx +370 -0
  349. package/src/views/page-system/department/departmentFormShared.ts +36 -0
  350. package/src/views/page-system/department/index.tsx +541 -0
  351. package/src/views/page-system/department/modal/detail-modal.tsx +94 -0
  352. package/src/views/page-system/department/modal/member-role-modal.tsx +128 -0
  353. package/src/views/page-system/department/modal/submit-modal.tsx +265 -0
  354. package/src/views/page-system/dict/index.tsx +440 -0
  355. package/src/views/page-system/dict/modal/cate-submit-modal.tsx +315 -0
  356. package/src/views/page-system/dict/modal/submit-modal.tsx +184 -0
  357. package/src/views/page-system/logs/components/index.ts +3 -0
  358. package/src/views/page-system/logs/components/log-message-demo.tsx +30 -0
  359. package/src/views/page-system/logs/components/log-message-stream.ts +184 -0
  360. package/src/views/page-system/logs/components/message-list/content-answer.tsx +100 -0
  361. package/src/views/page-system/logs/components/message-list/content-question.tsx +18 -0
  362. package/src/views/page-system/logs/components/message-list/index.tsx +515 -0
  363. package/src/views/page-system/logs/components/message-list/message-item.tsx +193 -0
  364. package/src/views/page-system/logs/components/message-list/preparation-demo-items.ts +147 -0
  365. package/src/views/page-system/logs/components/message-list/preparation-steps.tsx +506 -0
  366. package/src/views/page-system/logs/components/message-list/suggestion-list.tsx +36 -0
  367. package/src/views/page-system/logs/components/message-list/thinking-process.tsx +49 -0
  368. package/src/views/page-system/logs/components/message-list/toolbar.tsx +134 -0
  369. package/src/views/page-system/logs/components/message-list/use-message-list-scroll.ts +214 -0
  370. package/src/views/page-system/logs/components/message-modal.tsx +239 -0
  371. package/src/views/page-system/logs/index.tsx +132 -0
  372. package/src/views/page-system/logs/modal/detail-modal.tsx +157 -0
  373. package/src/views/page-system/menu/components/menuFormShared.ts +283 -0
  374. package/src/views/page-system/menu/index.less +12 -0
  375. package/src/views/page-system/menu/index.tsx +410 -0
  376. package/src/views/page-system/menu/modal/icon-modal.less +51 -0
  377. package/src/views/page-system/menu/modal/icon-modal.tsx +87 -0
  378. package/src/views/page-system/menu/modal/submit-modal.tsx +263 -0
  379. package/src/views/page-system/permission/index.tsx +562 -0
  380. package/src/views/page-system/permission/modal/detail-modal.tsx +179 -0
  381. package/src/views/page-system/permission/modal/submit-modal.less +146 -0
  382. package/src/views/page-system/permission/modal/submit-modal.tsx +650 -0
  383. package/src/views/page-system/role/index.tsx +163 -0
  384. package/src/views/page-system/role/modal/detail-modal.tsx +127 -0
  385. package/src/views/page-system/role/modal/permission-assign-group-rules.ts +86 -0
  386. package/src/views/page-system/role/modal/permission-modal.tsx +111 -0
  387. package/src/views/page-system/role/modal/role-modal-shell-styles.ts +21 -0
  388. package/src/views/page-system/role/modal/role-permission-assign-panel.tsx +916 -0
  389. package/src/views/page-system/role/modal/role-permission-assign-shared.ts +1047 -0
  390. package/src/views/page-system/role/modal/submit-modal.tsx +193 -0
  391. package/src/views/page-system/sys-config/index.tsx +294 -0
  392. package/src/views/page-system/user/components/user-role-column.tsx +87 -0
  393. package/src/views/page-system/user/index.tsx +439 -0
  394. package/src/views/page-system/user/modal/assign-roles-modal.tsx +389 -0
  395. package/src/views/page-system/user/modal/detail-modal.tsx +72 -0
  396. package/src/views/page-system/user/modal/modal-style/submit-modal.less +40 -0
  397. package/src/views/page-system/user/modal/submit-modal.less +40 -0
  398. package/src/views/page-system/user/modal/submit-modal.tsx +287 -0
  399. package/src/views/page-system/user/userFormShared.ts +51 -0
  400. package/tailwind.config.js +17 -0
  401. package/tsconfig.app.json +48 -0
  402. package/tsconfig.json +11 -0
  403. package/tsconfig.node.json +26 -0
  404. package/vite.config.ts +264 -0
@@ -0,0 +1,506 @@
1
+ import type { Message } from '@/types'
2
+ import type { TFunction } from 'i18next'
3
+ import clsx from 'clsx'
4
+ import { CxSteps } from '@cx-ui'
5
+ import type { StepsProps } from 'antd'
6
+ import { Spin } from 'antd'
7
+ import { CheckCircle2 } from 'lucide-react'
8
+ import React from 'react'
9
+ import { useTranslation } from 'react-i18next'
10
+ import type { Components } from 'react-markdown'
11
+ import ReactMarkdown from 'react-markdown'
12
+ import remarkGfm from 'remark-gfm'
13
+
14
+ // i18n 中文:locales/zh/chat.ts(chat.preparation_heading → 正在分析)
15
+ // 样式:views/chat/chat.less(chat-prep-*、chat-prep-step-desc-scroll、--memory-tail 含知识库检索、chat-prep-step-md)
16
+ // DEV 演示数据:preparation-demo-items.ts(CHAT_PREPARATION_DEMO_ITEMS,与 SSE preparation 对齐)
17
+ // 与 use-message-list-scroll 约定:chat-prep-layout 事件(副标题区布局增高时粘底)
18
+ // 副标题串行:按 preparation 行顺序,上一行打字播完再开始下一行(无副标题行自动跳过)
19
+
20
+ /** 消息列表在「靠近底部」时响应此事件做粘底(use-message-list-scroll 内监听同名) */
21
+ export const CHAT_MESSAGE_LIST_PREP_LAYOUT_EVENT = 'chat-prep-layout'
22
+
23
+ let prepLayoutBumpTimer: ReturnType<typeof setTimeout> | null = null
24
+
25
+ function bumpChatMessageListPrepLayout() {
26
+ if (prepLayoutBumpTimer != null) return
27
+ prepLayoutBumpTimer = setTimeout(() => {
28
+ prepLayoutBumpTimer = null
29
+ window.dispatchEvent(new CustomEvent(CHAT_MESSAGE_LIST_PREP_LAYOUT_EVENT))
30
+ }, 40)
31
+ }
32
+
33
+ /** preparation 副标题:GFM Markdown;真实换行或字面量 `\n` 均可,`\n\n` 分段落 */
34
+ const prepDescriptionMarkdownComponents: Components = {
35
+ a: (props) => (
36
+ <a {...props} target="_blank" rel="noopener noreferrer" />
37
+ ),
38
+ }
39
+
40
+ /** 将接口里常见的字面量转义还原(如 JSON 里写成 `\\n` 解析后仍是反斜杠+n) */
41
+ function preparationDescriptionUnescapeSequences(raw: string) {
42
+ return raw
43
+ .replace(/\\r\\n/g, '\n')
44
+ .replace(/\\r/g, '\n')
45
+ .replace(/\\n/g, '\n')
46
+ .replace(/\\t/g, '\t')
47
+ }
48
+
49
+ function normalizePreparationDescriptionRaw(raw: string) {
50
+ return preparationDescriptionUnescapeSequences(raw.trim())
51
+ .replace(/\r\n/g, '\n')
52
+ .replace(/\r/g, '\n')
53
+ }
54
+
55
+ function preparationDescriptionToMarkdownFromNormalized(normalized: string) {
56
+ return normalized
57
+ .split(/\n\n/)
58
+ .map((block) => block.replace(/\n/g, ' \n'))
59
+ .join('\n\n')
60
+ }
61
+
62
+ /** 副标题打字机:每档间隔(ms),与「每档字符数」配合控制整体节奏(略快于逐字、慢于一帧刷满) */
63
+ const PREP_DESC_CHUNK_TICK_MS = 44
64
+
65
+ function prepDescCharsPerTick(len: number) {
66
+ return Math.max(2, Math.ceil(len / 88))
67
+ }
68
+
69
+ /** 短期/长期记忆、知识库检索:固定可视约 4 行、裁切顶部、无滚动(与 --memory-tail 样式一致) */
70
+ function isPrepMemoryTailViewStep(code: string) {
71
+ return (
72
+ code === 'short_memory' ||
73
+ code === 'long_memory' ||
74
+ code === 'knowledge_retrieval'
75
+ )
76
+ }
77
+
78
+ /** 无后端 description 时,用参考资料列表拼成副标题(与右侧面板语义一致,键见 locales/zh/chat.ts) */
79
+ function buildKnowledgeRetrievalPrepDescriptionFromRefs(
80
+ refItems: NonNullable<Message['references_knowledge_items']>,
81
+ t: TFunction,
82
+ ) {
83
+ if (!refItems.length) return ''
84
+ const blocks = refItems.map((x, idx) => {
85
+ const docName =
86
+ (typeof x.doc_name === 'string' && x.doc_name) ||
87
+ (typeof x.docName === 'string' && x.docName) ||
88
+ ''
89
+ const titleLine = docName
90
+ ? t('chat.references_item_with_doc', { index: idx + 1, docName }) // 资料 n(文档名)
91
+ : t('chat.references_item_plain', { index: idx + 1 }) // 资料 n
92
+ const rawBody =
93
+ typeof x.page_content === 'string' ? x.page_content.trim() : ''
94
+ const body =
95
+ rawBody || t('chat.references_excerpt_placeholder') // 正文占位
96
+ const kbName =
97
+ typeof x.kb_name === 'string' && x.kb_name.trim()
98
+ ? x.kb_name.trim()
99
+ : '-'
100
+ const kbLine = `${t('chat.references_kb_label')}${kbName}` // 知识库:+ 名称
101
+ return `${titleLine}\n${body}\n${kbLine}`
102
+ })
103
+ return blocks.join('\n\n---\n\n')
104
+ }
105
+
106
+ function PreparationStepDescriptionMd({
107
+ source,
108
+ stepCode,
109
+ rowKey,
110
+ revealMode,
111
+ onRevealStart,
112
+ onRevealComplete,
113
+ }: {
114
+ source: string
115
+ /** 当前 preparation 项 code:记忆类与知识库检索走尾部裁切、不可滚可视区 */
116
+ stepCode: string
117
+ /** 与父级 Steps 行一致,用于打字开始/结束回调 */
118
+ rowKey: string
119
+ /** full:已轮到且之前阶段已播完,整段展示;typing:当前串行阶段,块打字机 */
120
+ revealMode: 'full' | 'typing'
121
+ /** 开始从 0 揭示前调用(父级将本行标为未完成,避免 Strict Mode 下图标先打勾) */
122
+ onRevealStart?: (key: string) => void
123
+ /** 本行副标题揭示到满字时调用一次 */
124
+ onRevealComplete?: (key: string) => void
125
+ }) {
126
+ const normalizedFull = React.useMemo(
127
+ () => normalizePreparationDescriptionRaw(source),
128
+ [source],
129
+ )
130
+ const [revealedLen, setRevealedLen] = React.useState(0)
131
+ const descScrollRef = React.useRef<HTMLDivElement>(null)
132
+ const prevNormRef = React.useRef<string | null>(null)
133
+ const revealDoneNotifiedRef = React.useRef(false)
134
+
135
+ const memoryTailView = isPrepMemoryTailViewStep(stepCode)
136
+
137
+ const scrollDescRefToEnd = React.useCallback(() => {
138
+ if (!memoryTailView) {
139
+ requestAnimationFrame(() => {
140
+ requestAnimationFrame(() => {
141
+ const el = descScrollRef.current
142
+ if (el) el.scrollTop = el.scrollHeight
143
+ bumpChatMessageListPrepLayout()
144
+ })
145
+ })
146
+ } else {
147
+ bumpChatMessageListPrepLayout()
148
+ }
149
+ }, [memoryTailView])
150
+
151
+ React.useLayoutEffect(() => {
152
+ if (revealMode !== 'full') return
153
+ const len = normalizedFull.length
154
+ if (!len) {
155
+ setRevealedLen(0)
156
+ return
157
+ }
158
+ setRevealedLen(len)
159
+ scrollDescRefToEnd()
160
+ }, [revealMode, normalizedFull, scrollDescRefToEnd])
161
+
162
+ React.useEffect(() => {
163
+ if (revealMode !== 'typing') return
164
+
165
+ if (prevNormRef.current !== normalizedFull) {
166
+ prevNormRef.current = normalizedFull
167
+ revealDoneNotifiedRef.current = false
168
+ }
169
+
170
+ const len = normalizedFull.length
171
+ if (!len) {
172
+ setRevealedLen(0)
173
+ return
174
+ }
175
+
176
+ onRevealStart?.(rowKey)
177
+ setRevealedLen(0)
178
+ const t0 = performance.now()
179
+ let rafId = 0
180
+ let revealed = 0
181
+ const tickMs = PREP_DESC_CHUNK_TICK_MS
182
+ const chunk = prepDescCharsPerTick(len)
183
+ let nextTickAt = t0 + tickMs
184
+
185
+ const step = (now: number) => {
186
+ if (now >= nextTickAt && revealed < len) {
187
+ revealed = Math.min(len, revealed + chunk)
188
+ nextTickAt = now + tickMs
189
+ setRevealedLen(revealed)
190
+ scrollDescRefToEnd()
191
+ }
192
+
193
+ if (revealed >= len) {
194
+ if (!revealDoneNotifiedRef.current) {
195
+ revealDoneNotifiedRef.current = true
196
+ onRevealComplete?.(rowKey)
197
+ }
198
+ return
199
+ }
200
+
201
+ rafId = requestAnimationFrame(step)
202
+ }
203
+
204
+ rafId = requestAnimationFrame(step)
205
+ return () => {
206
+ cancelAnimationFrame(rafId)
207
+ }
208
+ }, [
209
+ revealMode,
210
+ normalizedFull,
211
+ scrollDescRefToEnd,
212
+ memoryTailView,
213
+ rowKey,
214
+ onRevealStart,
215
+ onRevealComplete,
216
+ ])
217
+
218
+ if (!normalizedFull.length) return null
219
+
220
+ const md = preparationDescriptionToMarkdownFromNormalized(
221
+ normalizedFull.slice(0, revealedLen),
222
+ )
223
+
224
+ return (
225
+ <div
226
+ ref={descScrollRef}
227
+ className={clsx(
228
+ 'chat-prep-step-desc-scroll',
229
+ memoryTailView && 'chat-prep-step-desc-scroll--memory-tail',
230
+ )}
231
+ >
232
+ <div className="chat-prep-step-md">
233
+ <ReactMarkdown
234
+ remarkPlugins={[remarkGfm]}
235
+ components={prepDescriptionMarkdownComponents}
236
+ >
237
+ {md}
238
+ </ReactMarkdown>
239
+ </div>
240
+ </div>
241
+ )
242
+ }
243
+
244
+ type PrepItem = NonNullable<Message['preparation_items']>[number]
245
+
246
+ function prepRowKey(it: PrepItem) {
247
+ return `${it.code}\t${it.name}`
248
+ }
249
+
250
+ function resolvePrepItemDescription(it: PrepItem, kbRefDesc: string) {
251
+ const fromApi = it.description?.trim()
252
+ const fromRefs =
253
+ it.code === 'knowledge_retrieval' && !fromApi ? kbRefDesc : ''
254
+ return (fromApi || fromRefs).trim()
255
+ }
256
+
257
+ type StepItemStatus = NonNullable<StepsProps['items']>[number]['status']
258
+
259
+ /** SSE 约定 start/end → 内部 phase;其它 phase 为后端透传字符串 */
260
+ function mapPhaseToStepStatus(phase: string): StepItemStatus {
261
+ if (phase === 'done') return 'finish'
262
+ if (phase === 'running') return 'process'
263
+ if (phase === 'error' || phase === 'failed') return 'error'
264
+ return 'wait'
265
+ }
266
+
267
+ export { CHAT_PREPARATION_DEMO_ITEMS } from './preparation-demo-items'
268
+
269
+ /**
270
+ * 开发态:URL 带 `?chatPrep=1` 时在会话页固定展示 preparation(无需发消息)。
271
+ * @param search 传入 `useLocation().search` 以便路由变更时与界面同步
272
+ */
273
+ export function isChatPreparationDemoEnabled(search?: string): boolean {
274
+ if (!import.meta.env.DEV) return false
275
+ const q =
276
+ search ??
277
+ (typeof window !== 'undefined' ? window.location.search : '')
278
+ return new URLSearchParams(q).get('chatPrep') === '1'
279
+ }
280
+
281
+ export function PreparationSteps({
282
+ items,
283
+ referencesKnowledgeItems,
284
+ }: {
285
+ items: NonNullable<Message['preparation_items']>
286
+ /** 流式阶段与 knowledge_retrieval 步同屏:无 description 时用引用列表拼副标题 */
287
+ referencesKnowledgeItems?: Message['references_knowledge_items']
288
+ }) {
289
+ const { t } = useTranslation()
290
+
291
+ const kbRefDesc = React.useMemo(() => {
292
+ if (!referencesKnowledgeItems || referencesKnowledgeItems.length === 0)
293
+ return ''
294
+ return buildKnowledgeRetrievalPrepDescriptionFromRefs(
295
+ referencesKnowledgeItems,
296
+ t,
297
+ )
298
+ }, [referencesKnowledgeItems, t])
299
+
300
+ const prevDescByKeyRef = React.useRef<Record<string, string>>({})
301
+ const [descRevealComplete, setDescRevealComplete] = React.useState<
302
+ Record<string, boolean>
303
+ >({})
304
+ const [sequentialUnlockIdx, setSequentialUnlockIdx] = React.useState(0)
305
+
306
+ /** 前缀 preparation 行 identity 变化或列表变短时串行队列从头来(末尾追加新行不重置) */
307
+ const prevPrepRowKeysRef = React.useRef<string[]>([])
308
+
309
+ React.useLayoutEffect(() => {
310
+ const keys = items.map(prepRowKey)
311
+ const prev = prevPrepRowKeysRef.current
312
+ if (prev.length === 0) {
313
+ prevPrepRowKeysRef.current = keys
314
+ return
315
+ }
316
+ const minLen = Math.min(prev.length, keys.length)
317
+ let prefixBroken = false
318
+ for (let i = 0; i < minLen; i++) {
319
+ if (prev[i] !== keys[i]) {
320
+ prefixBroken = true
321
+ break
322
+ }
323
+ }
324
+ if (prefixBroken || keys.length < prev.length) {
325
+ setSequentialUnlockIdx(0)
326
+ setDescRevealComplete({})
327
+ }
328
+ prevPrepRowKeysRef.current = keys
329
+ }, [items])
330
+
331
+ /** 当前串行指针落在「无副标题」行时直接跳过 */
332
+ React.useLayoutEffect(() => {
333
+ setSequentialUnlockIdx((u) => {
334
+ let v = u
335
+ while (
336
+ v < items.length &&
337
+ !resolvePrepItemDescription(items[v], kbRefDesc)
338
+ ) {
339
+ v += 1
340
+ }
341
+ return v
342
+ })
343
+ }, [items, kbRefDesc, sequentialUnlockIdx])
344
+
345
+ /** 已播完的行副标题视为完成(对勾与后端 phase 对齐用) */
346
+ React.useLayoutEffect(() => {
347
+ setDescRevealComplete((prev) => {
348
+ const next = { ...prev }
349
+ let changed = false
350
+ for (let i = 0; i < sequentialUnlockIdx; i++) {
351
+ const it = items[i]
352
+ const d = resolvePrepItemDescription(it, kbRefDesc)
353
+ const k = prepRowKey(it)
354
+ if (d && next[k] !== true) {
355
+ next[k] = true
356
+ changed = true
357
+ }
358
+ }
359
+ return changed ? next : prev
360
+ })
361
+ }, [sequentialUnlockIdx, items, kbRefDesc])
362
+
363
+ React.useLayoutEffect(() => {
364
+ setDescRevealComplete((prev) => {
365
+ const next = { ...prev }
366
+ let changed = false
367
+ for (const it of items) {
368
+ const key = prepRowKey(it)
369
+ const desc = resolvePrepItemDescription(it, kbRefDesc)
370
+ const prevD = prevDescByKeyRef.current[key]
371
+ if (desc !== prevD) {
372
+ prevDescByKeyRef.current[key] = desc
373
+ if (desc) {
374
+ if (next[key] !== false) {
375
+ next[key] = false
376
+ changed = true
377
+ }
378
+ } else if (key in next) {
379
+ delete next[key]
380
+ changed = true
381
+ }
382
+ }
383
+ }
384
+ return changed ? next : prev
385
+ })
386
+ }, [items, kbRefDesc])
387
+
388
+ const handleDescRevealStart = React.useCallback((key: string) => {
389
+ setDescRevealComplete((prev) => {
390
+ if (prev[key] === false) return prev
391
+ return { ...prev, [key]: false }
392
+ })
393
+ }, [])
394
+
395
+ const handleDescRevealComplete = React.useCallback((key: string) => {
396
+ const idx = items.findIndex((it) => prepRowKey(it) === key)
397
+ if (idx < 0) return
398
+ setDescRevealComplete((prev) => {
399
+ if (prev[key]) return prev
400
+ return { ...prev, [key]: true }
401
+ })
402
+ setSequentialUnlockIdx(idx + 1)
403
+ }, [items])
404
+
405
+ const stepsItems = React.useMemo((): StepsProps['items'] => {
406
+ return items.map((it: PrepItem, idx: number) => {
407
+ const title = it.name || it.code
408
+ const key = prepRowKey(it)
409
+ const backendStatus = mapPhaseToStepStatus(it.phase)
410
+ const desc = resolvePrepItemDescription(it, kbRefDesc)
411
+
412
+ let displayStatus = backendStatus
413
+ if (backendStatus === 'error') {
414
+ displayStatus = 'error'
415
+ } else if (desc) {
416
+ if (idx > sequentialUnlockIdx) {
417
+ displayStatus = 'wait'
418
+ } else if (idx < sequentialUnlockIdx) {
419
+ displayStatus = backendStatus
420
+ } else if (!descRevealComplete[key]) {
421
+ displayStatus = 'process'
422
+ } else {
423
+ displayStatus = backendStatus
424
+ }
425
+ }
426
+
427
+ const row: NonNullable<StepsProps['items']>[number] = {
428
+ title,
429
+ status: displayStatus,
430
+ }
431
+
432
+ if (desc) {
433
+ if (idx > sequentialUnlockIdx) {
434
+ /* 未到串行轮次:不渲染副标题 */
435
+ } else if (idx < sequentialUnlockIdx) {
436
+ row.description = (
437
+ <PreparationStepDescriptionMd
438
+ key={key}
439
+ rowKey={key}
440
+ revealMode="full"
441
+ source={desc}
442
+ stepCode={it.code}
443
+ />
444
+ )
445
+ } else {
446
+ row.description = (
447
+ <PreparationStepDescriptionMd
448
+ key={key}
449
+ rowKey={key}
450
+ revealMode="typing"
451
+ source={desc}
452
+ stepCode={it.code}
453
+ onRevealStart={handleDescRevealStart}
454
+ onRevealComplete={handleDescRevealComplete}
455
+ />
456
+ )
457
+ }
458
+ }
459
+
460
+ if (displayStatus === 'finish') {
461
+ row.icon = (
462
+ <span className="chat-prep-step-icon-inner" aria-hidden>
463
+ <CheckCircle2 size={18} strokeWidth={2} />
464
+ </span>
465
+ )
466
+ } else if (displayStatus === 'process' || displayStatus === 'wait') {
467
+ row.icon = (
468
+ <span
469
+ className="chat-prep-step-spin"
470
+ role="status"
471
+ aria-label={t('common.loading')}
472
+ >
473
+ <Spin size="small" />
474
+ </span>
475
+ )
476
+ }
477
+ return row
478
+ })
479
+ }, [
480
+ items,
481
+ kbRefDesc,
482
+ t,
483
+ descRevealComplete,
484
+ sequentialUnlockIdx,
485
+ handleDescRevealStart,
486
+ handleDescRevealComplete,
487
+ ])
488
+
489
+ if (!items.length) return null
490
+
491
+ return (
492
+ <div className="chat-prep-panel">
493
+ <div className="chat-prep-heading">{t('chat.preparation_heading')}</div>
494
+ <div className="chat-prep-steps-wrap">
495
+ <CxSteps
496
+ orientation="vertical"
497
+ size="small"
498
+ items={stepsItems}
499
+ className="chat-prep-steps"
500
+ />
501
+ </div>
502
+ </div>
503
+ )
504
+ }
505
+
506
+ export default PreparationSteps
@@ -0,0 +1,36 @@
1
+ import React from 'react'
2
+ import clsx from 'clsx'
3
+
4
+ /** 与流式/历史里 `suggested_replies` → `message.options` 同一套样式 */
5
+ const SUGGESTED_REPLY_BTN_CLS = clsx(
6
+ 'w-fit max-w-full',
7
+ 'text-left break-words whitespace-normal',
8
+ 'px-4 py-2.5 rounded-xl text-[13px] leading-relaxed',
9
+ 'text-gray-700 dark:text-gray-200',
10
+ 'bg-[#f2f3f5] dark:bg-[#2d2e30]',
11
+ 'hover:bg-[#e8eaed] dark:hover:bg-[#3a3b3d]',
12
+ 'transition-colors duration-150',
13
+ )
14
+
15
+ export const SuggestionList: React.FC<{
16
+ options: string[]
17
+ keyPrefix: string
18
+ onOptionClick?: (option: string) => void | Promise<void>
19
+ }> = ({ options, keyPrefix, onOptionClick }) => (
20
+ <div className="mt-2 flex flex-col gap-2 items-start">
21
+ {options.map((option, idx) => (
22
+ <button
23
+ type="button"
24
+ key={`${keyPrefix}-${idx}`}
25
+ onClick={() => {
26
+ const fn = onOptionClick
27
+ if (fn) void fn(option)
28
+ }}
29
+ className={SUGGESTED_REPLY_BTN_CLS}
30
+ >
31
+ {option}
32
+ </button>
33
+ ))}
34
+ </div>
35
+ )
36
+
@@ -0,0 +1,49 @@
1
+ import { Spin } from 'antd'
2
+ import React from 'react'
3
+ import { useTranslation } from 'react-i18next'
4
+
5
+ export const ThinkingProcess: React.FC<{
6
+ thoughts: string[]
7
+ isContentVisible: boolean
8
+ }> = ({ thoughts, isContentVisible }) => {
9
+ const { t } = useTranslation()
10
+ const currentThought =
11
+ thoughts && thoughts.length > 0 ? thoughts[thoughts.length - 1] : ''
12
+
13
+ const displayThought = React.useMemo(() => {
14
+ if (!currentThought) return ''
15
+ let text = currentThought
16
+ try {
17
+ if (currentThought.trim().startsWith('{')) {
18
+ const parsed = JSON.parse(currentThought)
19
+ text = parsed.thought || parsed.action || parsed.status || currentThought
20
+ }
21
+ } catch {
22
+ // ignore
23
+ }
24
+ return text.replace(/\.{3}$|…$/, '')
25
+ }, [currentThought])
26
+
27
+ if (isContentVisible) return null
28
+ if (!thoughts || thoughts.length === 0) return null
29
+
30
+ return (
31
+ <div className="mb-2">
32
+ <div className="flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400">
33
+ <span
34
+ key={displayThought}
35
+ className="font-mono animate-fade-in"
36
+ >
37
+ {displayThought}
38
+ </span>
39
+ <div
40
+ className="flex h-6 shrink-0 items-center [&_.ant-spin-nested-loading]:!p-0"
41
+ role="status"
42
+ aria-label={t('common.loading')}
43
+ >
44
+ <Spin size="small" />
45
+ </div>
46
+ </div>
47
+ </div>
48
+ )
49
+ }