@allbluecn/web-app 0.9.5 → 0.10.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 (684) hide show
  1. package/package.json +9 -8
  2. package/public/favicon.ico +0 -0
  3. package/src/__tests__/paraglide.test.ts +43 -0
  4. package/src/__tests__/setup.ts +27 -9
  5. package/src/assets/illustrations/empty-states/workspace-empty.svg +5 -0
  6. package/src/assets/illustrations/knowledge/law-card-illustration.svg +5 -0
  7. package/src/assets/logo/logo.tsx +53 -36
  8. package/src/components/agents/agent-card.tsx +7 -7
  9. package/src/components/agents/agent-form-dialog.tsx +41 -42
  10. package/src/components/agents/agent-selector.tsx +6 -8
  11. package/src/components/agents/agents-page.tsx +26 -28
  12. package/src/components/agents/skill-card.tsx +1 -4
  13. package/src/components/agents/skill-form-dialog.tsx +19 -21
  14. package/src/components/agents/slash-skill-menu.tsx +5 -7
  15. package/src/components/agents/use-agent-handlers.ts +5 -8
  16. package/src/components/ai/ai-chat-prompt.tsx +26 -33
  17. package/src/components/ai/global-chat-panel.tsx +10 -11
  18. package/src/components/ai/use-knowledge-bases.ts +2 -2
  19. package/src/components/anyhub/anyhub-app-card.tsx +13 -15
  20. package/src/components/anyhub/anyhub-app-runner.tsx +5 -7
  21. package/src/components/anyhub/anyhub-install-dialog.tsx +16 -18
  22. package/src/components/anyhub/anyhub-management-view.tsx +9 -11
  23. package/src/components/anyhub/anyhub-marketplace-view.tsx +14 -17
  24. package/src/components/anyhub/anyhub-permission-panel.tsx +8 -11
  25. package/src/components/anyhub/anyhub-provider.tsx +0 -1
  26. package/src/components/anyhub/anyhub-top-nav.tsx +5 -8
  27. package/src/components/auth/auth-header.tsx +2 -2
  28. package/src/components/auth/icon-input.tsx +0 -1
  29. package/src/components/auth/oauth-section.tsx +3 -5
  30. package/src/components/auth/password-input.tsx +2 -4
  31. package/src/components/auth/session-guard.tsx +0 -1
  32. package/src/components/auth/sso-section.tsx +3 -4
  33. package/src/components/billing/__tests__/seats-manager.test.tsx +5 -9
  34. package/src/components/billing/billing-panel.tsx +5 -6
  35. package/src/components/billing/checkout-redirect.ts +6 -10
  36. package/src/components/billing/feature-gate.tsx +2 -3
  37. package/src/components/billing/invoice-history.tsx +9 -11
  38. package/src/components/billing/login-prompt-dialog.tsx +10 -11
  39. package/src/components/billing/pricing-card.tsx +6 -7
  40. package/src/components/billing/pricing-page.tsx +4 -5
  41. package/src/components/billing/seats-manager.tsx +19 -20
  42. package/src/components/billing/subscription-card.tsx +13 -14
  43. package/src/components/billing/upgrade-prompt.tsx +11 -13
  44. package/src/components/changelog/changelog-page.tsx +36 -26
  45. package/src/components/chat/ai-chat-history/components/conversation-header.tsx +4 -5
  46. package/src/components/chat/ai-chat-history/components/conversation-item.tsx +15 -17
  47. package/src/components/chat/ai-chat-history/components/conversation-search.tsx +3 -4
  48. package/src/components/chat/ai-chat-history/components/empty-state.tsx +5 -6
  49. package/src/components/chat/ai-chat-history/index.tsx +11 -15
  50. package/src/components/chat/ai-chat-history/utils/group-conversations.ts +9 -2
  51. package/src/components/chat/ai-citations/components/citation-item.tsx +3 -5
  52. package/src/components/chat/ai-citations/components/citations-list.tsx +4 -6
  53. package/src/components/chat/ai-citations/components/inline-citation.tsx +2 -4
  54. package/src/components/chat/ai-citations/components/source-components.tsx +6 -10
  55. package/src/components/chat/ai-citations/index.tsx +3 -4
  56. package/src/components/chat/ai-citations/utils.ts +15 -3
  57. package/src/components/chat/ai-conversation.tsx +10 -12
  58. package/src/components/chat/ai-message/components/message-actions.tsx +7 -9
  59. package/src/components/chat/ai-message/components/streaming-indicator.tsx +3 -4
  60. package/src/components/chat/ai-message/index.tsx +5 -5
  61. package/src/components/chat/ai-message/utils/dom-utils.ts +1 -1
  62. package/src/components/chat/ai-prompt-input/components/action-buttons.tsx +14 -16
  63. package/src/components/chat/ai-prompt-input/components/agent-mode-select.tsx +10 -5
  64. package/src/components/chat/ai-prompt-input/components/context-badge.tsx +2 -3
  65. package/src/components/chat/ai-prompt-input/components/kb-context-selector.tsx +6 -8
  66. package/src/components/chat/ai-prompt-input/components/model-select.tsx +14 -7
  67. package/src/components/chat/ai-prompt-input/components/page-user-context-selector.tsx +6 -8
  68. package/src/components/chat/ai-prompt-input/index.tsx +18 -11
  69. package/src/components/chat/ai-prompt-input/types.ts +6 -5
  70. package/src/components/chat/ai-thinking.tsx +6 -9
  71. package/src/components/chat/chat-thread-page.tsx +4 -5
  72. package/src/components/chat/interrupt-approval.tsx +6 -8
  73. package/src/components/command/command-palette.tsx +7 -10
  74. package/src/components/design/project-card.tsx +2 -3
  75. package/src/components/design/sketch/code-preview.tsx +3 -4
  76. package/src/components/design/sketch/export-panel.tsx +3 -4
  77. package/src/components/design/sketch/property-panel.tsx +16 -17
  78. package/src/components/error/global-error-boundary.tsx +65 -0
  79. package/src/components/forms/app-array-field.tsx +3 -4
  80. package/src/components/forms/app-combobox.tsx +2 -3
  81. package/src/components/forms/app-date-picker.tsx +2 -3
  82. package/src/components/forms/app-form-dialog.tsx +3 -4
  83. package/src/components/forms/app-select.tsx +2 -3
  84. package/src/components/forms/hooks/use-form-submit.ts +2 -2
  85. package/src/components/forms/schemas/common.ts +4 -6
  86. package/src/components/hotkeys/shortcuts-panel.tsx +2 -3
  87. package/src/components/iteration/auto-schedule-dialog.tsx +12 -13
  88. package/src/components/iteration/burndown-chart.tsx +6 -8
  89. package/src/components/iteration/constants.ts +5 -4
  90. package/src/components/iteration/create-iteration-dialog.tsx +14 -15
  91. package/src/components/iteration/iteration-card.tsx +3 -4
  92. package/src/components/iteration/iteration-editor.tsx +7 -8
  93. package/src/components/iteration/iteration-progress-bar.tsx +3 -5
  94. package/src/components/iteration/iteration-status-badge.tsx +1 -3
  95. package/src/components/kibo-ui/contribution-graph/index.tsx +37 -9
  96. package/src/components/knowledge/dialog/knowledge-form-dialog.tsx +8 -9
  97. package/src/components/knowledge/doc-properties.tsx +12 -13
  98. package/src/components/knowledge/editor/doc-header.tsx +7 -8
  99. package/src/components/knowledge/editor/knowledge-doc-editor.tsx +9 -9
  100. package/src/components/knowledge/knowledge-homepage.tsx +6 -7
  101. package/src/components/knowledge/knowledge-tag-input.tsx +3 -4
  102. package/src/components/knowledge/knowledge-toolbar.tsx +38 -40
  103. package/src/components/knowledge/knowledge-tree-item.tsx +21 -22
  104. package/src/components/knowledge/knowledge-tree.tsx +15 -16
  105. package/src/components/knowledge-public/bookmark-card.tsx +13 -14
  106. package/src/components/knowledge-public/bookmark-form-dialog.tsx +25 -26
  107. package/src/components/knowledge-public/knowledge-card-grid.tsx +3 -3
  108. package/src/components/knowledge-public/knowledge-filters.tsx +9 -10
  109. package/src/components/knowledge-public/knowledge-form-dialog.tsx +62 -63
  110. package/src/components/knowledge-public/knowledge-search-bar.tsx +3 -4
  111. package/src/components/knowledge-public/legal-compliance-editor.tsx +30 -31
  112. package/src/components/knowledge-public/markdown-editor.tsx +3 -4
  113. package/src/components/knowledge-public/markdown-view.tsx +2 -3
  114. package/src/components/knowledge-public/sharers-avatar-group.tsx +3 -4
  115. package/src/components/knowledge-public/tag-filter.tsx +3 -4
  116. package/src/components/layout/sidebar-03/__tests__/nav-workspace.test.tsx +42 -79
  117. package/src/components/layout/sidebar-03/__tests__/user-menu-anonymous.test.tsx +51 -0
  118. package/src/components/layout/sidebar-03/app-sidebar.tsx +3 -4
  119. package/src/components/layout/sidebar-03/index.tsx +0 -1
  120. package/src/components/layout/sidebar-03/nav-anyhub.tsx +4 -5
  121. package/src/components/layout/sidebar-03/nav-knowledge.tsx +80 -37
  122. package/src/components/layout/sidebar-03/nav-main.tsx +10 -12
  123. package/src/components/layout/sidebar-03/nav-notifications.tsx +19 -28
  124. package/src/components/layout/sidebar-03/nav-search-trigger.tsx +3 -5
  125. package/src/components/layout/sidebar-03/nav-workspace.tsx +32 -12
  126. package/src/components/layout/sidebar-03/team-switcher.tsx +0 -1
  127. package/src/components/layout/sidebar-03/user-menu.tsx +33 -13
  128. package/src/components/magicui/components/animate/avatar-group.tsx +0 -1
  129. package/src/components/magicui/primitives/animate/avatar-group.tsx +0 -1
  130. package/src/components/magicui/primitives/animate/slot.tsx +0 -1
  131. package/src/components/magicui/primitives/animate/tooltip.tsx +0 -1
  132. package/src/components/magicui/sparkles-text.tsx +0 -1
  133. package/src/components/mindmap/mindmap-doc-editor.tsx +15 -15
  134. package/src/components/notifications/settings-notifications.tsx +22 -23
  135. package/src/components/notifications/team-notifications.tsx +27 -29
  136. package/src/components/plugin-slots/__tests__/plugin-settings-tabs.test.tsx +4 -4
  137. package/src/components/plugin-slots/plugin-settings-tabs.tsx +15 -11
  138. package/src/components/project/create-project-dialog.tsx +60 -34
  139. package/src/components/project/invite-member-dialog.tsx +20 -21
  140. package/src/components/project/project-activity-list.tsx +19 -24
  141. package/src/components/project/project-member-manager.tsx +27 -28
  142. package/src/components/project/project-module-card.tsx +5 -6
  143. package/src/components/project/schemas/create-project.ts +3 -5
  144. package/src/components/prototype/component/GenericPrototype.tsx +0 -1
  145. package/src/components/prototype/component-preview.tsx +0 -1
  146. package/src/components/settings/ai/api-key-field.tsx +8 -10
  147. package/src/components/settings/ai/create-custom-model-dialog.tsx +28 -21
  148. package/src/components/settings/ai/create-custom-provider-dialog.tsx +15 -16
  149. package/src/components/settings/ai/model-card.tsx +25 -10
  150. package/src/components/settings/ai/model-manager.tsx +24 -16
  151. package/src/components/settings/ai/provider-card.tsx +9 -11
  152. package/src/components/settings/ai/provider-detail-form.tsx +24 -26
  153. package/src/components/settings/ai/provider-grid.tsx +23 -13
  154. package/src/components/settings/language-selector.tsx +13 -15
  155. package/src/components/settings/personal-team/account/account-client.tsx +14 -16
  156. package/src/components/settings/personal-team/account/avatar/notion-avatar-editor.tsx +36 -28
  157. package/src/components/settings/personal-team/account/settings-profile.tsx +39 -40
  158. package/src/components/settings/personal-team/team/team-client.tsx +45 -50
  159. package/src/components/settings/personal-team/team/team-invitations.tsx +89 -95
  160. package/src/components/settings/personal-team/team/team-member-list.tsx +50 -47
  161. package/src/components/shadcn-space/blocks/pricing-01/pricing.tsx +170 -172
  162. package/src/components/shared-kit/data-viz/contribution-graph-tooltip.tsx +128 -15
  163. package/src/components/shared-kit/dialogs/name-confirm-dialog.tsx +16 -16
  164. package/src/components/shared-kit/i18n/language-switcher.tsx +6 -9
  165. package/src/components/shared-kit/i18n/translator-text.tsx +2 -4
  166. package/src/components/shared-kit/icons/lucide-icon-picker/panel.tsx +7 -8
  167. package/src/components/shared-kit/logos/logo-icon.tsx +64 -0
  168. package/src/components/shared-kit/navigation/nav-float-button.tsx +3 -5
  169. package/src/components/shared-kit/pages/placeholder-page.tsx +2 -4
  170. package/src/components/shared-kit/theme/animated-theme-toggler.tsx +0 -1
  171. package/src/components/shared-kit/theme/theme-toggle.tsx +0 -1
  172. package/src/components/shared-kit/timezone/timezone-select.tsx +6 -7
  173. package/src/components/story/__tests__/constants.test.ts +7 -7
  174. package/src/components/story/__tests__/dependency-type-badge.test.ts +5 -5
  175. package/src/components/story/ai/action-registry.ts +12 -11
  176. package/src/components/story/ai/handlers/more-popover.tsx +5 -6
  177. package/src/components/story/ai/prototype-dialog.tsx +9 -10
  178. package/src/components/story/ai/split-dialog.tsx +22 -23
  179. package/src/components/story/ai/story-ai-panel.tsx +29 -30
  180. package/src/components/story/ai/story-ai-preview-list.tsx +16 -9
  181. package/src/components/story/ai/story-ai-toolbar.tsx +12 -13
  182. package/src/components/story/columns.tsx +33 -17
  183. package/src/components/story/constants.ts +73 -69
  184. package/src/components/story/create-story-dialog.tsx +13 -14
  185. package/src/components/story/detail/__tests__/categories.test.tsx +8 -10
  186. package/src/components/story/detail/__tests__/dependencies-button.test.tsx +3 -5
  187. package/src/components/story/detail/activity-tabs.tsx +6 -7
  188. package/src/components/story/detail/activity-timeline.tsx +33 -35
  189. package/src/components/story/detail/comment-input.tsx +7 -8
  190. package/src/components/story/detail/comment-item.tsx +15 -16
  191. package/src/components/story/detail/comment-thread.tsx +6 -7
  192. package/src/components/story/detail/reaction-bar.tsx +2 -3
  193. package/src/components/story/detail/story-detail-body.tsx +26 -28
  194. package/src/components/story/detail/story-detail-toolbar/associated-attachments-panel.tsx +42 -45
  195. package/src/components/story/detail/story-detail-toolbar/categories.tsx +13 -14
  196. package/src/components/story/detail/story-detail-toolbar/children.tsx +19 -22
  197. package/src/components/story/detail/story-detail-toolbar/dependencies.tsx +3 -5
  198. package/src/components/story/detail/story-detail-toolbar/dependency-panel.tsx +30 -20
  199. package/src/components/story/detail/story-detail-toolbar.tsx +16 -11
  200. package/src/components/story/detail/story-properties.tsx +7 -8
  201. package/src/components/story/display/__tests__/display-dropdown.test.tsx +3 -5
  202. package/src/components/story/display/__tests__/use-paged-story-groups.test.ts +2 -0
  203. package/src/components/story/display/constants.ts +27 -26
  204. package/src/components/story/display/display-dropdown.tsx +20 -26
  205. package/src/components/story/display/group-resolver.tsx +12 -14
  206. package/src/components/story/display/use-grouped-stories.ts +3 -5
  207. package/src/components/story/display/use-paged-story-groups.ts +12 -13
  208. package/src/components/story/filters/add-filter-dropdown.tsx +4 -5
  209. package/src/components/story/filters/applied-filters.tsx +7 -9
  210. package/src/components/story/filters/filter-condition.tsx +9 -12
  211. package/src/components/story/filters/filter-row.tsx +5 -6
  212. package/src/components/story/filters/filter-toggle.tsx +2 -3
  213. package/src/components/story/filters/filter-types.ts +24 -23
  214. package/src/components/story/filters/filter-value-input.tsx +3 -4
  215. package/src/components/story/infinite-scroll-sentinel.tsx +2 -3
  216. package/src/components/story/inline-editors/__tests__/dependency-type-select.test.tsx +18 -23
  217. package/src/components/story/inline-editors/__tests__/labels-editor.test.tsx +9 -11
  218. package/src/components/story/inline-editors/__tests__/priority-editor.test.tsx +21 -25
  219. package/src/components/story/inline-editors/__tests__/state-editor.test.tsx +21 -25
  220. package/src/components/story/inline-editors/assignee-editor.tsx +8 -9
  221. package/src/components/story/inline-editors/date-editor.tsx +4 -5
  222. package/src/components/story/inline-editors/dependency-type-select.tsx +15 -12
  223. package/src/components/story/inline-editors/inline-trigger.tsx +2 -3
  224. package/src/components/story/inline-editors/labels-editor.tsx +16 -17
  225. package/src/components/story/inline-editors/parent-story-editor.tsx +3 -4
  226. package/src/components/story/inline-editors/priority-editor.tsx +6 -8
  227. package/src/components/story/inline-editors/state-editor.tsx +6 -7
  228. package/src/components/story/inline-editors/story-select-dialog.tsx +25 -26
  229. package/src/components/story/inline-editors/title-editor.tsx +2 -3
  230. package/src/components/story/peek-panel.tsx +6 -7
  231. package/src/components/story/relations/__tests__/knowledge-select-dialog.test.tsx +2 -0
  232. package/src/components/story/relations/__tests__/link-manage-dialog.test.tsx +2 -0
  233. package/src/components/story/relations/attachment-manage-dialog.tsx +23 -24
  234. package/src/components/story/relations/general-groups.ts +12 -29
  235. package/src/components/story/relations/knowledge-select-dialog.tsx +21 -22
  236. package/src/components/story/relations/link-manage-dialog.tsx +12 -13
  237. package/src/components/story/relations/story-ref-row.tsx +20 -21
  238. package/src/components/story/schemas/story-create.ts +3 -5
  239. package/src/components/story/search-popover.tsx +5 -6
  240. package/src/components/story/story-list-table.tsx +3 -4
  241. package/src/components/story/story-list-view.tsx +9 -10
  242. package/src/components/story/story-panel-header.tsx +27 -28
  243. package/src/components/story/story-toolbar.tsx +11 -12
  244. package/src/components/story/transfer-story-popover.tsx +15 -16
  245. package/src/components/story/views/calendar-view.tsx +12 -14
  246. package/src/components/story/views/create-view-dialog.tsx +19 -52
  247. package/src/components/story/views/kanban-board.tsx +9 -12
  248. package/src/components/story/views/kanban-card.tsx +1 -3
  249. package/src/components/story/views/story-list/__tests__/batch-toolbar.test.tsx +9 -2
  250. package/src/components/story/views/story-list/__tests__/group-header.test.tsx +15 -17
  251. package/src/components/story/views/story-list/batch-preview-dialog.tsx +26 -28
  252. package/src/components/story/views/story-list/batch-toolbar.tsx +12 -13
  253. package/src/components/story/views/story-list/group.tsx +9 -11
  254. package/src/components/story/views/story-list/index.tsx +13 -14
  255. package/src/components/story/views/story-list/inline-story-creator.tsx +6 -7
  256. package/src/components/story/views/story-list/row.tsx +6 -7
  257. package/src/components/story/views/timeline-view.tsx +7 -8
  258. package/src/components/story/views/view-list-section.tsx +14 -16
  259. package/src/components/story/views/view-selector-button.tsx +6 -7
  260. package/src/components/story/views/view-switcher.tsx +9 -10
  261. package/src/components/story/views/view-types.ts +15 -15
  262. package/src/components/tiptap/extension/code-block-ellipsis-input-extension.ts +0 -1
  263. package/src/components/tiptap/hooks/use-composed-ref.ts +0 -1
  264. package/src/components/tiptap/hooks/use-cursor-visibility.ts +0 -1
  265. package/src/components/tiptap/hooks/use-floating-element.ts +0 -1
  266. package/src/components/tiptap/hooks/use-is-breakpoint.ts +0 -1
  267. package/src/components/tiptap/hooks/use-isomorphic-layout-effect.ts +0 -1
  268. package/src/components/tiptap/hooks/use-menu-navigation.ts +0 -1
  269. package/src/components/tiptap/hooks/use-on-click-outside.ts +0 -1
  270. package/src/components/tiptap/hooks/use-tiptap-editor.ts +0 -1
  271. package/src/components/tiptap/hooks/use-ui-editor-state.ts +0 -1
  272. package/src/components/tiptap/mindmap/lib/__tests__/default-mindmap-data.test.ts +3 -2
  273. package/src/components/tiptap/mindmap/lib/default-mindmap-data.ts +2 -2
  274. package/src/components/tiptap/mindmap/mind-map.tsx +36 -39
  275. package/src/components/tiptap/mindmap/mindmap-fullscreen-dialog.tsx +2 -3
  276. package/src/components/tiptap/node/annotation-node/annotation-node-view.tsx +11 -12
  277. package/src/components/tiptap/node/doc-card-extension.tsx +8 -10
  278. package/src/components/tiptap/node/image-node/image-node-floating.tsx +2 -3
  279. package/src/components/tiptap/node/image-upload-node/image-upload-node.tsx +0 -1
  280. package/src/components/tiptap/node/mention-extension.ts +5 -5
  281. package/src/components/tiptap/node/table-node/hooks/use-table-handle-state.ts +0 -1
  282. package/src/components/tiptap/node/table-node/ui/table-add-row-column-button/table-add-row-column-button.tsx +0 -1
  283. package/src/components/tiptap/node/table-node/ui/table-add-row-column-button/use-table-add-row-column.ts +5 -6
  284. package/src/components/tiptap/node/table-node/ui/table-align-cell-button/table-align-cell-button.tsx +0 -1
  285. package/src/components/tiptap/node/table-node/ui/table-align-cell-button/use-table-align-cell.ts +8 -9
  286. package/src/components/tiptap/node/table-node/ui/table-alignment-menu/table-alignment-menu.tsx +2 -4
  287. package/src/components/tiptap/node/table-node/ui/table-cell-handle-menu/table-cell-handle-menu.tsx +2 -5
  288. package/src/components/tiptap/node/table-node/ui/table-clear-row-column-content-button/table-clear-row-column-content-button.tsx +0 -1
  289. package/src/components/tiptap/node/table-node/ui/table-clear-row-column-content-button/use-table-clear-row-column-content.ts +4 -5
  290. package/src/components/tiptap/node/table-node/ui/table-delete-row-column-button/table-delete-row-column-button.tsx +0 -1
  291. package/src/components/tiptap/node/table-node/ui/table-delete-row-column-button/use-table-delete-row-column.ts +3 -4
  292. package/src/components/tiptap/node/table-node/ui/table-duplicate-row-column-button/table-duplicate-row-column-button.tsx +0 -1
  293. package/src/components/tiptap/node/table-node/ui/table-duplicate-row-column-button/use-table-duplicate-row-column.ts +3 -4
  294. package/src/components/tiptap/node/table-node/ui/table-extend-row-column-button/table-extend-row-column-button.tsx +2 -4
  295. package/src/components/tiptap/node/table-node/ui/table-fit-to-width-button/table-fit-to-width-button.tsx +0 -1
  296. package/src/components/tiptap/node/table-node/ui/table-fit-to-width-button/use-table-fit-to-width.ts +3 -4
  297. package/src/components/tiptap/node/table-node/ui/table-handle/table-handle.tsx +0 -1
  298. package/src/components/tiptap/node/table-node/ui/table-handle-menu/table-handle-menu.tsx +3 -5
  299. package/src/components/tiptap/node/table-node/ui/table-header-row-column-button/table-header-row-column-button.tsx +0 -1
  300. package/src/components/tiptap/node/table-node/ui/table-header-row-column-button/use-table-header-row-column.ts +3 -4
  301. package/src/components/tiptap/node/table-node/ui/table-merge-split-cell-button/table-merge-split-cell-button.tsx +0 -1
  302. package/src/components/tiptap/node/table-node/ui/table-merge-split-cell-button/use-table-merge-split-cell.ts +3 -4
  303. package/src/components/tiptap/node/table-node/ui/table-move-row-column-button/table-move-row-column-button.tsx +0 -1
  304. package/src/components/tiptap/node/table-node/ui/table-move-row-column-button/use-table-move-row-column.ts +9 -10
  305. package/src/components/tiptap/node/table-node/ui/table-selection-overlay/table-selection-overlay.tsx +0 -1
  306. package/src/components/tiptap/node/table-node/ui/table-selection-overlay/use-resize-overlay.ts +0 -1
  307. package/src/components/tiptap/node/table-node/ui/table-sort-row-column-button/table-sort-row-column-button.tsx +0 -1
  308. package/src/components/tiptap/node/table-node/ui/table-sort-row-column-button/use-table-sort-row-column.ts +5 -6
  309. package/src/components/tiptap/node/table-node/ui/table-trigger-button/table-grid-selector.tsx +2 -3
  310. package/src/components/tiptap/node/table-node/ui/table-trigger-button/table-trigger-button.tsx +0 -1
  311. package/src/components/tiptap/node/table-node/ui/table-trigger-button/use-table-trigger.ts +3 -4
  312. package/src/components/tiptap/node/toc-node/toc-node.tsx +2 -4
  313. package/src/components/tiptap/node/toc-node/ui/toc-show-title-button/toc-show-title-button.tsx +0 -1
  314. package/src/components/tiptap/node/toc-node/ui/toc-show-title-button/toc-show-title.ts +2 -3
  315. package/src/components/tiptap/node/toc-node/ui/toc-sidebar/toc-sidebar.tsx +2 -5
  316. package/src/components/tiptap/notion-like/notion-like-editor-header.tsx +2 -4
  317. package/src/components/tiptap/notion-like/notion-like-editor-mobile-toolbar.tsx +17 -23
  318. package/src/components/tiptap/notion-like/notion-like-editor-theme-toggle.tsx +2 -5
  319. package/src/components/tiptap/notion-like/notion-like-editor-toolbar-floating.tsx +16 -12
  320. package/src/components/tiptap/notion-like/notion-like-editor.tsx +2 -7
  321. package/src/components/tiptap/notion-like/setup-error-message/setup-error-message.tsx +0 -1
  322. package/src/components/tiptap/ui/ai-ask-button/ai-ask-button.tsx +0 -1
  323. package/src/components/tiptap/ui/ai-ask-button/use-ai-ask.ts +2 -3
  324. package/src/components/tiptap/ui/ai-menu/ai-menu-actions/ai-menu-actions.tsx +4 -6
  325. package/src/components/tiptap/ui/ai-menu/ai-menu-input/ai-menu-input.tsx +6 -10
  326. package/src/components/tiptap/ui/ai-menu/ai-menu-items/ai-menu-items-constants.ts +36 -36
  327. package/src/components/tiptap/ui/ai-menu/ai-menu-items/ai-menu-items.tsx +13 -16
  328. package/src/components/tiptap/ui/ai-menu/ai-menu-items/language-selection-submenu.tsx +3 -4
  329. package/src/components/tiptap/ui/ai-menu/ai-menu-items/tone-selection-submenu.tsx +2 -3
  330. package/src/components/tiptap/ui/ai-menu/ai-menu-utils.ts +3 -3
  331. package/src/components/tiptap/ui/ai-menu/ai-menu.tsx +3 -5
  332. package/src/components/tiptap/ui/blockquote-button/blockquote-button.tsx +2 -6
  333. package/src/components/tiptap/ui/blockquote-button/use-blockquote.ts +2 -3
  334. package/src/components/tiptap/ui/code-block-button/code-block-button.tsx +2 -6
  335. package/src/components/tiptap/ui/code-block-button/use-code-block.ts +2 -3
  336. package/src/components/tiptap/ui/color-highlight-button/color-highlight-button.tsx +0 -1
  337. package/src/components/tiptap/ui/color-highlight-button/use-color-highlight.ts +14 -14
  338. package/src/components/tiptap/ui/color-highlight-popover/color-highlight-popover.tsx +9 -11
  339. package/src/components/tiptap/ui/color-menu/color-menu.tsx +5 -11
  340. package/src/components/tiptap/ui/color-text-button/color-text-button.tsx +2 -3
  341. package/src/components/tiptap/ui/color-text-button/use-color-text.ts +12 -13
  342. package/src/components/tiptap/ui/color-text-popover/color-text-popover.tsx +6 -10
  343. package/src/components/tiptap/ui/color-text-popover/use-color-text-popover.ts +2 -3
  344. package/src/components/tiptap/ui/copy-anchor-link-button/copy-anchor-link-button.tsx +2 -6
  345. package/src/components/tiptap/ui/copy-anchor-link-button/use-copy-anchor-link.ts +2 -3
  346. package/src/components/tiptap/ui/copy-anchor-link-button/use-scroll-to-hash.ts +0 -1
  347. package/src/components/tiptap/ui/copy-to-clipboard-button/copy-to-clipboard-button.tsx +2 -6
  348. package/src/components/tiptap/ui/copy-to-clipboard-button/use-copy-to-clipboard.ts +2 -3
  349. package/src/components/tiptap/ui/delete-node-button/delete-node-button.tsx +2 -6
  350. package/src/components/tiptap/ui/delete-node-button/use-delete-node.ts +2 -3
  351. package/src/components/tiptap/ui/doc-reference-floating/doc-reference-floating.tsx +10 -11
  352. package/src/components/tiptap/ui/doc-reference-interaction/doc-reference-interaction.tsx +10 -11
  353. package/src/components/tiptap/ui/drag-context-menu/drag-context-menu.tsx +7 -9
  354. package/src/components/tiptap/ui/duplicate-button/duplicate-button.tsx +2 -6
  355. package/src/components/tiptap/ui/duplicate-button/use-duplicate.ts +2 -3
  356. package/src/components/tiptap/ui/emoji-dropdown-menu/emoji-dropdown-menu.tsx +0 -1
  357. package/src/components/tiptap/ui/emoji-menu/emoji-menu.tsx +2 -5
  358. package/src/components/tiptap/ui/emoji-trigger-button/emoji-trigger-button.tsx +2 -6
  359. package/src/components/tiptap/ui/emoji-trigger-button/use-emoji-trigger.ts +2 -3
  360. package/src/components/tiptap/ui/heading-button/heading-button.tsx +0 -1
  361. package/src/components/tiptap/ui/heading-button/use-heading.ts +7 -8
  362. package/src/components/tiptap/ui/image-align-button/image-align-button.tsx +0 -1
  363. package/src/components/tiptap/ui/image-align-button/use-image-align.ts +4 -5
  364. package/src/components/tiptap/ui/image-caption-button/image-caption-button.tsx +0 -1
  365. package/src/components/tiptap/ui/image-caption-button/use-image-caption.ts +2 -3
  366. package/src/components/tiptap/ui/image-download-button/image-download-button.tsx +0 -1
  367. package/src/components/tiptap/ui/image-download-button/use-image-download.ts +2 -3
  368. package/src/components/tiptap/ui/image-upload-button/image-upload-button.tsx +0 -1
  369. package/src/components/tiptap/ui/image-upload-button/use-image-upload.ts +2 -3
  370. package/src/components/tiptap/ui/improve-dropdown/improve-dropdown.tsx +14 -17
  371. package/src/components/tiptap/ui/improve-dropdown/use-improve-dropdown.ts +2 -3
  372. package/src/components/tiptap/ui/indent-button/indent-button.tsx +0 -1
  373. package/src/components/tiptap/ui/indent-button/use-indent.ts +3 -4
  374. package/src/components/tiptap/ui/link-popover/link-popover.tsx +7 -12
  375. package/src/components/tiptap/ui/link-popover/use-link-popover.ts +2 -3
  376. package/src/components/tiptap/ui/list-button/list-button.tsx +0 -1
  377. package/src/components/tiptap/ui/list-button/use-list.ts +4 -5
  378. package/src/components/tiptap/ui/mark-button/mark-button.tsx +0 -1
  379. package/src/components/tiptap/ui/mark-button/use-mark.ts +8 -9
  380. package/src/components/tiptap/ui/mention-dropdown-menu/mention-dropdown-menu.tsx +0 -2
  381. package/src/components/tiptap/ui/mention-trigger-button/mention-trigger-button.tsx +0 -1
  382. package/src/components/tiptap/ui/mention-trigger-button/use-mention-trigger.ts +2 -3
  383. package/src/components/tiptap/ui/move-node-button/move-node-button.tsx +2 -6
  384. package/src/components/tiptap/ui/move-node-button/use-move-node.ts +2 -3
  385. package/src/components/tiptap/ui/reference-dropdown-menu/reference-dropdown-menu.tsx +6 -10
  386. package/src/components/tiptap/ui/reset-all-formatting-button/reset-all-formatting-button.tsx +2 -6
  387. package/src/components/tiptap/ui/reset-all-formatting-button/use-reset-all-formatting.ts +2 -3
  388. package/src/components/tiptap/ui/slash-command-trigger-button/slash-command-trigger-button.tsx +0 -1
  389. package/src/components/tiptap/ui/slash-command-trigger-button/use-slash-command-trigger.ts +2 -3
  390. package/src/components/tiptap/ui/slash-dropdown-menu/slash-dropdown-menu.tsx +2 -5
  391. package/src/components/tiptap/ui/slash-dropdown-menu/use-slash-dropdown-menu.ts +78 -79
  392. package/src/components/tiptap/ui/text-align-button/text-align-button.tsx +0 -1
  393. package/src/components/tiptap/ui/text-align-button/use-text-align.ts +5 -6
  394. package/src/components/tiptap/ui/text-button/text-button.tsx +2 -6
  395. package/src/components/tiptap/ui/text-button/use-text.ts +2 -3
  396. package/src/components/tiptap/ui/turn-into-dropdown/turn-into-dropdown.tsx +4 -7
  397. package/src/components/tiptap/ui/turn-into-dropdown/use-turn-into-dropdown.ts +11 -12
  398. package/src/components/tiptap/ui/undo-redo-button/undo-redo-button.tsx +0 -1
  399. package/src/components/tiptap/ui/undo-redo-button/use-undo-redo.ts +3 -4
  400. package/src/components/tiptap/ui-primitive/avatar/avatar.tsx +0 -1
  401. package/src/components/tiptap/ui-primitive/badge/badge.tsx +0 -1
  402. package/src/components/tiptap/ui-primitive/button/button.tsx +0 -1
  403. package/src/components/tiptap/ui-primitive/card/card.tsx +0 -1
  404. package/src/components/tiptap/ui-primitive/combobox/combobox.tsx +0 -1
  405. package/src/components/tiptap/ui-primitive/dropdown-menu/dropdown-menu.tsx +0 -1
  406. package/src/components/tiptap/ui-primitive/input/input.tsx +0 -1
  407. package/src/components/tiptap/ui-primitive/input-group/input-group.tsx +0 -1
  408. package/src/components/tiptap/ui-primitive/label/label.tsx +0 -1
  409. package/src/components/tiptap/ui-primitive/menu/menu-context.ts +0 -1
  410. package/src/components/tiptap/ui-primitive/menu/menu-hooks.ts +0 -1
  411. package/src/components/tiptap/ui-primitive/menu/menu-types.ts +0 -1
  412. package/src/components/tiptap/ui-primitive/menu/menu-utils.ts +0 -1
  413. package/src/components/tiptap/ui-primitive/menu/menu.tsx +0 -1
  414. package/src/components/tiptap/ui-primitive/popover/popover.tsx +0 -1
  415. package/src/components/tiptap/ui-primitive/separator/separator.tsx +0 -1
  416. package/src/components/tiptap/ui-primitive/sidebar/sidebar.tsx +0 -1
  417. package/src/components/tiptap/ui-primitive/spacer/spacer.tsx +0 -1
  418. package/src/components/tiptap/ui-primitive/textarea/textarea.tsx +0 -1
  419. package/src/components/tiptap/ui-primitive/textarea-autosize/textarea-autosize.tsx +0 -1
  420. package/src/components/tiptap/ui-primitive/toolbar/toolbar.tsx +0 -1
  421. package/src/components/tiptap/ui-primitive/tooltip/tooltip.tsx +0 -1
  422. package/src/components/tiptap/ui-utils/floating-element/floating-element.tsx +0 -1
  423. package/src/components/tiptap/ui-utils/suggestion-menu/suggestion-menu.tsx +0 -1
  424. package/src/components/ui/field.tsx +1 -1
  425. package/src/components/ui/radio-group.tsx +2 -3
  426. package/src/components/ui/spinner.tsx +2 -2
  427. package/src/components/workspace/create-workspace-dialog.tsx +12 -13
  428. package/src/components/workspace/delete-workspace-options.tsx +177 -0
  429. package/src/components/workspace/edit-workspace-dialog.tsx +153 -0
  430. package/src/components/workspace/schemas/create-workspace.ts +2 -2
  431. package/src/components/workspace/workspace-activity-card.tsx +60 -0
  432. package/src/components/workspace/workspace-contribution-card.tsx +37 -0
  433. package/src/components/workspace/workspace-header.tsx +100 -0
  434. package/src/components/workspace/workspace-kb-card.tsx +31 -0
  435. package/src/components/workspace/workspace-member-item.tsx +80 -0
  436. package/src/components/workspace/workspace-members-manager.tsx +291 -0
  437. package/src/components/workspace/workspace-project-list.tsx +129 -0
  438. package/src/config/sidebar-routes.tsx +25 -24
  439. package/src/config/sidebar-teams.ts +4 -4
  440. package/src/hooks/__tests__/use-commands.test.tsx +0 -10
  441. package/src/hooks/use-commands.ts +3 -7
  442. package/src/hooks/use-entity-subscription.ts +0 -1
  443. package/src/hooks/use-notifications.ts +5 -6
  444. package/src/hooks/useTranslator.ts +0 -1
  445. package/src/lib/__tests__/edition.test.ts +9 -0
  446. package/src/lib/analytics.ts +0 -1
  447. package/src/lib/anyhub/anyhub-message-bridge.ts +1 -1
  448. package/src/lib/auth/__tests__/anonymous-safe.test.ts +89 -0
  449. package/src/lib/auth/__tests__/page-gate.test.ts +29 -0
  450. package/src/lib/auth/anonymous-safe.ts +39 -0
  451. package/src/lib/auth/page-gate.ts +18 -0
  452. package/src/lib/changelog/sdk-versions.ts +19 -19
  453. package/src/lib/collections/knowledge/knowledge-bases-collection.ts +1 -1
  454. package/src/lib/collections/reference/bookmark-categories-collection.ts +1 -1
  455. package/src/lib/collections/reference/labels-collection.ts +1 -1
  456. package/src/lib/collections/reference/projects-collection.ts +1 -1
  457. package/src/lib/collections/reference/users-brief-collection.ts +1 -1
  458. package/src/lib/collections/reference/workspaces-collection.ts +3 -3
  459. package/src/lib/commands/__tests__/registry.test.ts +3 -3
  460. package/src/lib/commands/registry.ts +22 -21
  461. package/src/lib/commands/types.ts +1 -1
  462. package/src/lib/edition.ts +7 -0
  463. package/src/lib/router-context.ts +1 -2
  464. package/src/plugins/.gen-manifest.json +13 -0
  465. package/src/plugins/core/inspiration/pages/inspiration-page.tsx +2 -3
  466. package/src/plugins/core/inspiration/ui.tsx +2 -3
  467. package/src/plugins/core/prd/components/agent-input.tsx +7 -8
  468. package/src/plugins/core/prd/components/component-editor/content-section.tsx +3 -3
  469. package/src/plugins/core/prd/components/component-editor/position-section.tsx +3 -4
  470. package/src/plugins/core/prd/components/component-editor/style-fields.tsx +13 -16
  471. package/src/plugins/core/prd/components/dialog/create-prd-dialog.tsx +11 -12
  472. package/src/plugins/core/prd/components/dialog/prd-detail-client.tsx +7 -9
  473. package/src/plugins/core/prd/components/page-version-panel/components/create-version-dialog.tsx +7 -8
  474. package/src/plugins/core/prd/components/page-version-panel/components/delete-version-dialog.tsx +5 -6
  475. package/src/plugins/core/prd/components/page-version-panel/components/edit-version-dialog.tsx +7 -8
  476. package/src/plugins/core/prd/components/page-version-panel/constants.tsx +3 -2
  477. package/src/plugins/core/prd/components/page-version-panel.tsx +43 -45
  478. package/src/plugins/core/prd/components/page-version-tree.tsx +6 -8
  479. package/src/plugins/core/prd/components/prd-agent-panel.tsx +29 -23
  480. package/src/plugins/core/prd/components/prd-comment-review-panel.tsx +21 -23
  481. package/src/plugins/core/prd/components/prd-component-editor-content.tsx +6 -7
  482. package/src/plugins/core/prd/components/prd-dashboard.tsx +28 -23
  483. package/src/plugins/core/prd/components/prd-doc-panel.tsx +6 -9
  484. package/src/plugins/core/prd/components/prd-editor-layout.tsx +11 -13
  485. package/src/plugins/core/prd/components/prd-filter-bar.tsx +2 -3
  486. package/src/plugins/core/prd/components/prd-left-sidebar.tsx +19 -20
  487. package/src/plugins/core/prd/components/prd-navigation.tsx +12 -14
  488. package/src/plugins/core/prd/components/prd-outline-tab.tsx +3 -4
  489. package/src/plugins/core/prd/components/prd-prototype-panel.tsx +8 -10
  490. package/src/plugins/core/prd/components/prd-right-sidebar.tsx +10 -12
  491. package/src/plugins/core/prd/components/prd-share-panel/components/single-version-share-card.tsx +13 -14
  492. package/src/plugins/core/prd/components/prd-share-panel/constants.ts +5 -3
  493. package/src/plugins/core/prd/components/prd-share-panel.tsx +58 -60
  494. package/src/plugins/core/prd/components/prd-tree-page-tab.tsx +20 -22
  495. package/src/plugins/core/prd/components/prototype/PrototypeCanvas.tsx +2 -4
  496. package/src/plugins/core/prd/components/prototype/PrototypeElement.tsx +3 -5
  497. package/src/plugins/core/prd/components/prototype/ResizeHandles.tsx +0 -1
  498. package/src/plugins/core/prd/components/prototype/icon-components.ts +19 -21
  499. package/src/plugins/core/prd/components/prototype/index.ts +3 -0
  500. package/src/plugins/core/prd/components/restore-version-dialog.tsx +5 -7
  501. package/src/plugins/core/prd/components/share/prd-share-client.tsx +7 -9
  502. package/src/plugins/core/prd/components/share/share-annotation-overlay.tsx +0 -1
  503. package/src/plugins/core/prd/components/share/share-comment-panel.tsx +15 -16
  504. package/src/plugins/core/prd/components/share/share-comment-review-panel.tsx +7 -9
  505. package/src/plugins/core/prd/components/share/share-directory-tree.tsx +3 -5
  506. package/src/plugins/core/prd/components/share/share-doc-view.tsx +3 -5
  507. package/src/plugins/core/prd/components/share/share-layout.tsx +3 -5
  508. package/src/plugins/core/prd/components/share/share-nav-bar.tsx +3 -5
  509. package/src/plugins/core/prd/components/share/share-password-gate.tsx +8 -9
  510. package/src/plugins/core/prd/components/share/share-prototype-view.tsx +3 -5
  511. package/src/plugins/core/prd/components/share/share-review-panel.tsx +9 -11
  512. package/src/plugins/core/prd/components/share/share-sse-listener.tsx +0 -1
  513. package/src/plugins/core/prd/components/share/version-share-client.tsx +3 -5
  514. package/src/plugins/core/prd/pages/prd-detail-page.tsx +9 -21
  515. package/src/plugins/core/prd/pages/share-prd-page.tsx +6 -16
  516. package/src/plugins/core/prd/prd-nav.tsx +2 -3
  517. package/src/plugins/core/tags/nav-tag.tsx +14 -15
  518. package/src/plugins/core/tags/pages/tag-detail-page.tsx +3 -5
  519. package/src/plugins/core/tags/pages/tag-settings-page.tsx +3 -5
  520. package/src/plugins/core/tags/pages/tags-index-page.tsx +3 -5
  521. package/src/plugins/core/tags/tag-badge.tsx +2 -3
  522. package/src/plugins/core/tags/tag-color-picker.tsx +2 -4
  523. package/src/plugins/core/tags/tag-manager.tsx +23 -25
  524. package/src/plugins/core/tags/tag-selector.tsx +4 -5
  525. package/src/plugins/modules.gen.ts +21 -0
  526. package/src/plugins/plugins.gen.ts +20 -0
  527. package/src/plugins/ui.gen.ts +8 -0
  528. package/src/providers/index.tsx +3 -14
  529. package/src/routeTree.gen.ts +27 -0
  530. package/src/router.tsx +16 -6
  531. package/src/routes/__desktop/onboarding/route.lazy.tsx +22 -23
  532. package/src/routes/__root.tsx +13 -36
  533. package/src/routes/__tests__/-edition-routing.test.tsx +151 -0
  534. package/src/routes/_login/forgot-password/route.lazy.tsx +14 -15
  535. package/src/routes/_login/login/route.lazy.tsx +26 -25
  536. package/src/routes/_login/register/route.lazy.tsx +23 -24
  537. package/src/routes/_login/reset-password/route.lazy.tsx +16 -17
  538. package/src/routes/_login/schemas/-auth.ts +11 -13
  539. package/src/routes/_nav/acceptance-criteria/route.tsx +2 -3
  540. package/src/routes/_nav/apps/anyhub/$id/route.tsx +2 -3
  541. package/src/routes/_nav/chat/route.lazy.tsx +9 -10
  542. package/src/routes/_nav/dashboard/-components/activity-feed.tsx +3 -4
  543. package/src/routes/_nav/dashboard/-components/quick-actions.tsx +3 -4
  544. package/src/routes/_nav/dashboard/-components/stats-grid.tsx +5 -6
  545. package/src/routes/_nav/dashboard/route.lazy.tsx +7 -8
  546. package/src/routes/_nav/design/$projectId/$artboardId/route.lazy.tsx +7 -9
  547. package/src/routes/_nav/design/$projectId/route.lazy.tsx +3 -5
  548. package/src/routes/_nav/design/index.lazy.tsx +26 -27
  549. package/src/routes/_nav/inspiration/route.tsx +8 -0
  550. package/src/routes/_nav/knowledge/$kbId/doc/$docId/route.lazy.tsx +4 -5
  551. package/src/routes/_nav/knowledge/$kbId/route.lazy.tsx +3 -4
  552. package/src/routes/_nav/knowledge/bookmarks/$id.lazy.tsx +29 -30
  553. package/src/routes/_nav/knowledge/bookmarks/index.lazy.tsx +12 -13
  554. package/src/routes/_nav/knowledge/compliance/$id.lazy.tsx +22 -23
  555. package/src/routes/_nav/knowledge/compliance/index.lazy.tsx +18 -19
  556. package/src/routes/_nav/knowledge/dictionaries/$id.lazy.tsx +5 -6
  557. package/src/routes/_nav/knowledge/dictionaries/index.lazy.tsx +17 -18
  558. package/src/routes/_nav/knowledge/index.lazy.tsx +248 -40
  559. package/src/routes/_nav/knowledge/laws/$id.lazy.tsx +22 -23
  560. package/src/routes/_nav/knowledge/laws/index.lazy.tsx +14 -15
  561. package/src/routes/_nav/knowledge/summary/index.lazy.tsx +31 -32
  562. package/src/routes/_nav/notifications/route.lazy.tsx +3 -4
  563. package/src/routes/_nav/notifications/route.tsx +2 -0
  564. package/src/routes/_nav/notion-like/route.tsx +2 -3
  565. package/src/routes/_nav/prd/$id/route.tsx +9 -0
  566. package/src/routes/_nav/prd/index.tsx +9 -0
  567. package/src/routes/_nav/prd/route.tsx +8 -0
  568. package/src/routes/_nav/pricing-02/route.tsx +2 -3
  569. package/src/routes/_nav/projects/$projectId/$storyId/route.lazy.tsx +23 -24
  570. package/src/routes/_nav/projects/$projectId/index.lazy.tsx +54 -74
  571. package/src/routes/_nav/projects/$projectId/iterations/$iterationId/route.lazy.tsx +27 -30
  572. package/src/routes/_nav/projects/$projectId/iterations/index.lazy.tsx +9 -10
  573. package/src/routes/_nav/projects/$projectId/route.tsx +4 -2
  574. package/src/routes/_nav/projects/$projectId/settings/route.lazy.tsx +40 -41
  575. package/src/routes/_nav/route.tsx +13 -16
  576. package/src/routes/_nav/settings/-settings-tabs.tsx +24 -51
  577. package/src/routes/_nav/settings/account/route.lazy.tsx +1 -9
  578. package/src/routes/_nav/settings/ai/index/route.lazy.tsx +5 -6
  579. package/src/routes/_nav/settings/billing/route.lazy.tsx +4 -5
  580. package/src/routes/_nav/settings/connection/route.lazy.tsx +14 -10
  581. package/src/routes/_nav/settings/design/route.lazy.tsx +21 -22
  582. package/src/routes/_nav/settings/general/route.lazy.tsx +10 -11
  583. package/src/routes/_nav/settings/notifications/route.lazy.tsx +3 -5
  584. package/src/routes/_nav/settings/privacy/route.lazy.tsx +15 -16
  585. package/src/routes/_nav/settings/route.lazy.tsx +2 -3
  586. package/src/routes/_nav/settings/route.tsx +10 -15
  587. package/src/routes/_nav/settings/team/route.lazy.tsx +1 -9
  588. package/src/routes/_nav/tags/$id/route.tsx +8 -0
  589. package/src/routes/_nav/tags/index.tsx +8 -0
  590. package/src/routes/_nav/tags/route.tsx +8 -0
  591. package/src/routes/_nav/tags/settings/route.tsx +9 -0
  592. package/src/routes/_nav/test-cases/route.tsx +2 -3
  593. package/src/routes/_nav/workspaces/$workspaceId/activities/route.lazy.tsx +69 -0
  594. package/src/routes/_nav/workspaces/$workspaceId/activities/route.tsx +28 -0
  595. package/src/routes/_nav/workspaces/$workspaceId/route.lazy.tsx +194 -99
  596. package/src/routes/_nav/workspaces/$workspaceId/route.tsx +12 -3
  597. package/src/routes/_nav/workspaces/$workspaceId/settings/route.lazy.tsx +75 -61
  598. package/src/routes/_nav/workspaces/index.lazy.tsx +196 -22
  599. package/src/routes/_nav/workspaces/route.tsx +2 -0
  600. package/src/routes/_public/index/route.tsx +5 -1
  601. package/src/routes/invite/$token/route.lazy.tsx +36 -37
  602. package/src/routes/share/$versionId/route.lazy.tsx +4 -11
  603. package/src/routes/share/compliance/$id/route.lazy.tsx +6 -8
  604. package/src/routes/share/law/$id/route.lazy.tsx +6 -8
  605. package/src/routes/share/prd/$prdId/route.tsx +10 -0
  606. package/src/server/__tests__/agent-client-graph.test.ts +4 -8
  607. package/src/server/ai-ports.ts +7 -6
  608. package/src/server/builtin-project.ts +43 -0
  609. package/src/server/design/sketch/file-storage.ts +1 -1
  610. package/src/server/pro-services.ts +1 -1
  611. package/src/server/serverFns/__tests__/workspace.test.ts +101 -0
  612. package/src/server/serverFns/activity.ts +15 -9
  613. package/src/server/serverFns/knowledge-public/bookmarks/list.ts +1 -1
  614. package/src/server/serverFns/knowledge-public/bookmarks/share.ts +3 -3
  615. package/src/server/serverFns/knowledge-public/compliance/share.ts +3 -3
  616. package/src/server/serverFns/knowledge-public/dictionary/share.ts +3 -3
  617. package/src/server/serverFns/knowledge-public/legal/share.ts +3 -3
  618. package/src/server/serverFns/knowledge.ts +27 -2
  619. package/src/server/serverFns/notifications.ts +3 -0
  620. package/src/server/serverFns/project.ts +48 -35
  621. package/src/server/serverFns/story/story-crud/bulk.ts +2 -2
  622. package/src/server/serverFns/story/story-crud.ts +9 -7
  623. package/src/server/serverFns/story/story-groups.ts +6 -6
  624. package/src/server/serverFns/workspace.ts +334 -13
  625. package/src/server-entry.ts +29 -0
  626. package/vite.shared.ts +4 -1
  627. package/src/components/layout/sidebar-03/logo.tsx +0 -41
  628. package/src/i18n/__tests__/detect.test.ts +0 -48
  629. package/src/i18n/__tests__/integration.test.tsx +0 -32
  630. package/src/i18n/__tests__/server.test.ts +0 -33
  631. package/src/i18n/client.ts +0 -32
  632. package/src/i18n/config.ts +0 -116
  633. package/src/i18n/detect.ts +0 -43
  634. package/src/i18n/locales/en/agents.json +0 -134
  635. package/src/i18n/locales/en/apps.json +0 -6
  636. package/src/i18n/locales/en/auth.json +0 -90
  637. package/src/i18n/locales/en/billing.json +0 -78
  638. package/src/i18n/locales/en/chat.json +0 -194
  639. package/src/i18n/locales/en/common.json +0 -242
  640. package/src/i18n/locales/en/dashboard.json +0 -38
  641. package/src/i18n/locales/en/design.json +0 -70
  642. package/src/i18n/locales/en/desktop.json +0 -35
  643. package/src/i18n/locales/en/display.json +0 -37
  644. package/src/i18n/locales/en/editor.json +0 -304
  645. package/src/i18n/locales/en/enterprise.json +0 -1
  646. package/src/i18n/locales/en/invite.json +0 -56
  647. package/src/i18n/locales/en/iterations.json +0 -92
  648. package/src/i18n/locales/en/knowledge.json +0 -462
  649. package/src/i18n/locales/en/mindmap.json +0 -28
  650. package/src/i18n/locales/en/notifications.json +0 -79
  651. package/src/i18n/locales/en/prd.json +0 -51
  652. package/src/i18n/locales/en/projects.json +0 -140
  653. package/src/i18n/locales/en/settings.json +0 -428
  654. package/src/i18n/locales/en/share.json +0 -20
  655. package/src/i18n/locales/en/story.json +0 -923
  656. package/src/i18n/locales/en/tags.json +0 -42
  657. package/src/i18n/locales/en/workspace.json +0 -90
  658. package/src/i18n/locales/zh/agents.json +0 -134
  659. package/src/i18n/locales/zh/apps.json +0 -6
  660. package/src/i18n/locales/zh/auth.json +0 -90
  661. package/src/i18n/locales/zh/billing.json +0 -78
  662. package/src/i18n/locales/zh/chat.json +0 -194
  663. package/src/i18n/locales/zh/common.json +0 -242
  664. package/src/i18n/locales/zh/dashboard.json +0 -38
  665. package/src/i18n/locales/zh/design.json +0 -70
  666. package/src/i18n/locales/zh/desktop.json +0 -35
  667. package/src/i18n/locales/zh/display.json +0 -37
  668. package/src/i18n/locales/zh/editor.json +0 -304
  669. package/src/i18n/locales/zh/enterprise.json +0 -1
  670. package/src/i18n/locales/zh/invite.json +0 -56
  671. package/src/i18n/locales/zh/iterations.json +0 -92
  672. package/src/i18n/locales/zh/knowledge.json +0 -462
  673. package/src/i18n/locales/zh/mindmap.json +0 -28
  674. package/src/i18n/locales/zh/notifications.json +0 -79
  675. package/src/i18n/locales/zh/prd.json +0 -51
  676. package/src/i18n/locales/zh/projects.json +0 -140
  677. package/src/i18n/locales/zh/settings.json +0 -428
  678. package/src/i18n/locales/zh/share.json +0 -20
  679. package/src/i18n/locales/zh/story.json +0 -923
  680. package/src/i18n/locales/zh/tags.json +0 -42
  681. package/src/i18n/locales/zh/workspace.json +0 -90
  682. package/src/i18n/server.ts +0 -18
  683. package/src/i18n/types.ts +0 -5
  684. package/src/server/serverFns/locale.ts +0 -20
@@ -0,0 +1,129 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ import { Link } from "@tanstack/react-router";
19
+ import { FolderKanban, Plus, Users, Box } from "lucide-react";
20
+ import { Button } from "@/components/ui/button";
21
+ import { Card } from "@/components/ui/card";
22
+ import { LucideIconByName } from "@/components/shared-kit/icons/lucide-icon-picker/lucide-icon-by-name";
23
+ import { CreateProjectDialog } from "@/components/project/create-project-dialog";
24
+ import { m } from "@/paraglide/messages.js";
25
+ import { useState } from "react";
26
+
27
+ interface WorkspaceProject {
28
+ id: string;
29
+ name: string;
30
+ description: string | null;
31
+ icon: string;
32
+ updatedAt: Date;
33
+ _count: { members: number };
34
+ }
35
+
36
+ interface WorkspaceProjectListProps {
37
+ projects: WorkspaceProject[];
38
+ workspaceId: string;
39
+ workspaceName: string;
40
+ }
41
+
42
+ export function WorkspaceProjectList({ projects, workspaceId, workspaceName }: WorkspaceProjectListProps) {
43
+ const [createOpen, setCreateOpen] = useState(false);
44
+
45
+ if (projects.length === 0) {
46
+ return (
47
+ <div>
48
+ <div className="mb-4 flex items-center justify-between">
49
+ <div className="flex items-center gap-2">
50
+ <FolderKanban className="size-4 text-muted-foreground" />
51
+ <h2 className="text-base font-semibold">{m.workspace_detail_projects()}</h2>
52
+ </div>
53
+ <Button onClick={() => setCreateOpen(true)} size="sm">
54
+ <Plus className="size-4" />
55
+ {m.workspace_detail_createProject()}
56
+ </Button>
57
+ </div>
58
+ <Card className="flex flex-col items-center justify-center gap-4 p-12 text-center">
59
+ <div className="flex size-14 items-center justify-center rounded-full bg-muted">
60
+ <Box className="size-7 text-muted-foreground" />
61
+ </div>
62
+ <div>
63
+ <h3 className="text-lg font-medium">{m.workspace_detail_emptyProjectsTitle()}</h3>
64
+ <p className="mt-1 text-sm text-muted-foreground">
65
+ {m.workspace_detail_emptyProjectsDescription()}
66
+ </p>
67
+ </div>
68
+ </Card>
69
+ <CreateProjectDialog
70
+ open={createOpen}
71
+ onOpenChange={setCreateOpen}
72
+ defaultWorkspaceId={workspaceId}
73
+ defaultWorkspaceName={workspaceName}
74
+ />
75
+ </div>
76
+ );
77
+ }
78
+
79
+ return (
80
+ <div>
81
+ <div className="mb-4 flex items-center justify-between">
82
+ <div className="flex items-center gap-2">
83
+ <FolderKanban className="size-4 text-muted-foreground" />
84
+ <h2 className="text-base font-semibold">{m.workspace_detail_projects()}</h2>
85
+ </div>
86
+ <Button onClick={() => setCreateOpen(true)} size="sm">
87
+ <Plus className="size-4" />
88
+ {m.workspace_detail_createProject()}
89
+ </Button>
90
+ </div>
91
+ <div className="grid gap-4 sm:grid-cols-2">
92
+ {projects.map((project) => (
93
+ <Card key={project.id} className="group relative p-5 transition-colors hover:bg-accent/40 border rounded-lg">
94
+ <Link
95
+ to="/projects/$projectId"
96
+ params={{ projectId: project.id }}
97
+ className="absolute inset-0"
98
+ aria-label={project.name}
99
+ />
100
+ <div className="flex-1">
101
+ <div className="flex size-10 items-center justify-center rounded-lg bg-primary/10">
102
+ <LucideIconByName name={project.icon} size={20} />
103
+ </div>
104
+ <h3 className="mt-4 font-medium text-lg">{project.name}</h3>
105
+ <p className="mt-1 line-clamp-2 text-sm text-muted-foreground">
106
+ {project.description || m.workspace_detail_noDescription()}
107
+ </p>
108
+ </div>
109
+ <div className="mt-4 flex items-center justify-between text-xs text-muted-foreground">
110
+ <span className="flex items-center gap-1">
111
+ <Users className="size-3.5" />
112
+ {project._count.members} {m.workspace_detail_members()}
113
+ </span>
114
+ <span className="flex items-center gap-1">
115
+ <span>{new Intl.DateTimeFormat("zh-CN", { month: "short", day: "numeric" }).format(new Date(project.updatedAt))}</span>
116
+ </span>
117
+ </div>
118
+ </Card>
119
+ ))}
120
+ </div>
121
+ <CreateProjectDialog
122
+ open={createOpen}
123
+ onOpenChange={setCreateOpen}
124
+ defaultWorkspaceId={workspaceId}
125
+ defaultWorkspaceName={workspaceName}
126
+ />
127
+ </div>
128
+ );
129
+ }
@@ -15,6 +15,7 @@
15
15
  // You should have received a copy of the GNU Affero General Public License
16
16
  // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
17
 
18
+ import { m } from '@/paraglide/messages.js';
18
19
  import type React from "react";
19
20
  import {
20
21
  Sparkles,
@@ -30,91 +31,91 @@ import {
30
31
  } from "lucide-react";
31
32
 
32
33
  export type RouteSubItem = {
33
- title: string;
34
+ title: () => string;
34
35
  link: string;
35
36
  id: string;
36
- badge: string;
37
+ badge: () => string;
37
38
  icon?: React.ReactNode | string;
38
39
  };
39
40
 
40
41
  export type Route = {
41
42
  id: string;
42
- title: string;
43
+ title: () => string;
43
44
  icon?: React.ReactNode;
44
45
  link: string;
45
- badge: string;
46
+ badge: () => string;
46
47
  subs?: RouteSubItem[];
47
48
  };
48
49
 
49
50
  export const workspaceRoutes: Route[] = [
50
51
  {
51
52
  id: "home",
52
- title: "nav.workspace",
53
+ title: m.common_nav_workspace,
53
54
  icon: <Sparkles className="size-4" />,
54
- badge: " ",
55
+ badge: () => " ",
55
56
  link: "/dashboard",
56
57
  },
57
58
  {
58
59
  id: "chat",
59
- title: "nav.chat",
60
+ title: m.common_nav_chat,
60
61
  icon: <BotMessageSquare className="size-4" />,
61
- badge: " ",
62
+ badge: () => " ",
62
63
  link: "/chat",
63
64
  },
64
65
  {
65
66
  id: "inspiration",
66
- title: "nav.inspiration",
67
+ title: m.common_nav_inspiration,
67
68
  icon: <Lightbulb className="size-4" />,
68
- badge: " ",
69
+ badge: () => " ",
69
70
  link: "/inspiration",
70
71
  },
71
72
  {
72
73
  id: "story",
73
- title: "nav.story",
74
+ title: m.common_nav_story,
74
75
  icon: <ClipboardList className="size-4" />,
75
- badge: " ",
76
+ badge: () => " ",
76
77
  link: "/stories",
77
78
  },
78
79
  {
79
80
  id: "prd",
80
- title: "nav.prd",
81
+ title: m.common_nav_prd,
81
82
  icon: <Package2 className="size-4" />,
82
- badge: "原型画板",
83
+ badge: m.common_nav_prototypeBoard,
83
84
  link: "/prd",
84
85
  },
85
86
  {
86
87
  id: "design",
87
- title: "nav.design",
88
+ title: m.common_nav_design,
88
89
  icon: <PenTool className="size-4" />,
89
- badge: " ",
90
+ badge: () => " ",
90
91
  link: "/design",
91
92
  },
92
93
  {
93
94
  id: "testcase",
94
- title: "nav.testcase",
95
+ title: m.common_nav_testcase,
95
96
  icon: <FlaskConical className="size-4" />,
96
- badge: " ",
97
+ badge: () => " ",
97
98
  link: "/test-cases",
98
99
  },
99
100
  {
100
101
  id: "bug",
101
- title: "nav.bug",
102
+ title: m.common_nav_bug,
102
103
  icon: <Bug className="size-4" />,
103
- badge: " ",
104
+ badge: () => " ",
104
105
  link: "/bugs",
105
106
  },
106
107
  {
107
108
  id: "acceptance",
108
- title: "nav.acceptance",
109
+ title: m.common_nav_acceptance,
109
110
  icon: <CircleCheckBig className="size-4" />,
110
- badge: " ",
111
+ badge: () => " ",
111
112
  link: "/acceptance-criteria",
112
113
  },
113
114
  {
114
115
  id: "debrief",
115
- title: "nav.debrief",
116
+ title: m.common_nav_debrief,
116
117
  icon: <Speech className="size-4" />,
117
- badge: " ",
118
+ badge: () => " ",
118
119
  link: "/debrief",
119
120
  },
120
121
  ];
@@ -16,7 +16,7 @@
16
16
  // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
17
 
18
18
  import type React from "react";
19
- import { Logo } from "@/components/layout/sidebar-03/logo";
19
+ import { LogoIcon } from "@/components/shared-kit/logos/logo-icon";
20
20
 
21
21
  export type Team = {
22
22
  id: string;
@@ -26,7 +26,7 @@ export type Team = {
26
26
  };
27
27
 
28
28
  export const teams: Team[] = [
29
- { id: "1", name: "Alpha Inc.", logo: Logo, plan: "Free" },
30
- { id: "2", name: "Beta Corp.", logo: Logo, plan: "Free" },
31
- { id: "3", name: "Gamma Tech", logo: Logo, plan: "Free" },
29
+ { id: "1", name: "Alpha Inc.", logo: LogoIcon, plan: "Free" },
30
+ { id: "2", name: "Beta Corp.", logo: LogoIcon, plan: "Free" },
31
+ { id: "3", name: "Gamma Tech", logo: LogoIcon, plan: "Free" },
32
32
  ];
@@ -19,16 +19,6 @@ import { describe, it, expect, vi, beforeEach } from 'vitest'
19
19
  import { renderHook } from '@testing-library/react'
20
20
  import { useCommands } from '@/hooks/use-commands'
21
21
 
22
- vi.mock('react-i18next', () => ({
23
- useTranslation: () => ({
24
- t: (key: string) => {
25
- if (key === 'command.gotoDashboard') return '前往工作台'
26
- if (key === 'command.createPrd') return '新建 PRD'
27
- return key
28
- },
29
- }),
30
- }))
31
-
32
22
  const navigateMock = vi.fn()
33
23
  vi.mock('@tanstack/react-router', () => ({
34
24
  useRouter: () => ({ navigate: navigateMock }),
@@ -17,26 +17,22 @@
17
17
 
18
18
  import { useCallback, useMemo } from 'react'
19
19
  import { useRouter } from '@tanstack/react-router'
20
- import { useTranslation } from 'react-i18next'
21
20
  import { useTheme } from 'next-themes'
22
21
  import { signOut } from '@/lib/auth/auth-client'
23
22
  import { COMMAND_REGISTRY } from '@/lib/commands/registry'
24
23
  import type { CommandDefinition } from '@/lib/commands/types'
25
24
 
26
- export interface ResolvedCommand extends CommandDefinition {
27
- title: string
28
- }
25
+ export type ResolvedCommand = Omit<CommandDefinition, 'title'> & { title: string }
29
26
 
30
27
  const DELEGATED_ACTIONS = new Set(['create-prd'])
31
28
 
32
29
  export function useCommands(options?: { onAction?: (id: string) => void }) {
33
30
  const router = useRouter()
34
- const { t } = useTranslation('common')
35
31
  const { theme, setTheme } = useTheme()
36
32
 
37
33
  const commands = useMemo<ResolvedCommand[]>(
38
- () => COMMAND_REGISTRY.map((c) => ({ ...c, title: t(c.titleKey) })),
39
- [t],
34
+ () => COMMAND_REGISTRY.map((c) => ({ ...c, title: c.title() })),
35
+ [],
40
36
  )
41
37
 
42
38
  const execute = useCallback(
@@ -15,7 +15,6 @@
15
15
  // You should have received a copy of the GNU Affero General Public License
16
16
  // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
17
 
18
-
19
18
  import { useEffect, useState } from "react"
20
19
  import type { EntityUpdateEvent } from "@allbluecn/kernel"
21
20
 
@@ -3,10 +3,10 @@ import { useCallback, useEffect } from 'react'
3
3
  import { useQuery, useQueryClient } from '@tanstack/react-query'
4
4
  import { useRouter } from '@tanstack/react-router'
5
5
  import { toast } from 'sonner'
6
- import { useTranslation } from 'react-i18next'
7
6
  import type { NotificationSseValue, NotificationItem } from '@allbluecn/kernel'
8
7
  import { isInDndWindow } from '@allbluecn/kernel'
9
8
  import { getUnreadCountFn, getNotificationPreferencesFn } from '@/server/serverFns/notifications'
9
+ import { m } from "@/paraglide/messages.js";
10
10
 
11
11
  export const NOTIFICATION_ROOT_KEY = ['notifications'] as const
12
12
  export const NOTIFICATION_LIST_KEY = ['notifications', 'list'] as const
@@ -26,12 +26,12 @@ export function parseNotificationEvent(raw: string): NotificationSseValue | null
26
26
  }
27
27
  }
28
28
 
29
- function toastNotification(item: NotificationItem, t: (key: string) => string, navigate: (opts: { to: string }) => void) {
29
+ function toastNotification(item: NotificationItem, navigate: (opts: { to: string }) => void) {
30
30
  toast(item.title, {
31
31
  description: item.body ?? undefined,
32
32
  action: item.link
33
33
  ? {
34
- label: t('actions.view'),
34
+ label: m.notifications_actions_view(),
35
35
  onClick: () => {
36
36
  navigate({ to: item.link! })
37
37
  },
@@ -44,7 +44,6 @@ let source: EventSource | null = null
44
44
  let refCount = 0
45
45
 
46
46
  export function useNotifications(options?: { toastEnabled?: boolean }) {
47
- const { t } = useTranslation('notifications')
48
47
  const queryClient = useQueryClient()
49
48
  const router = useRouter()
50
49
  const toastEnabled = options?.toastEnabled !== false
@@ -101,7 +100,7 @@ export function useNotifications(options?: { toastEnabled?: boolean }) {
101
100
  const now = new Date()
102
101
  const hhmm = `${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}`
103
102
  const inDnd = !!prefs && isInDndWindow(prefs, hhmm)
104
- if (!inDnd) toastNotification(value.notification, t, (opts) => router.navigate({ to: opts.to as never }))
103
+ if (!inDnd) toastNotification(value.notification, (opts) => router.navigate({ to: opts.to as never }))
105
104
  }
106
105
  }
107
106
  }
@@ -116,7 +115,7 @@ export function useNotifications(options?: { toastEnabled?: boolean }) {
116
115
  }
117
116
  }
118
117
  // eslint-disable-next-line react-hooks/exhaustive-deps
119
- }, [toastEnabled, t, router])
118
+ }, [toastEnabled, router])
120
119
 
121
120
  return { unreadCount, setUnreadCount }
122
121
  }
@@ -15,7 +15,6 @@
15
15
  // You should have received a copy of the GNU Affero General Public License
16
16
  // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
17
 
18
-
19
18
  import { useState, useEffect, useRef } from "react";
20
19
  import { translateFn } from '@/server/serverFns/translation'
21
20
 
@@ -0,0 +1,9 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import { isSaasEdition, profileId } from '../edition'
3
+
4
+ describe('edition', () => {
5
+ it('OSS 装配产物下 profileId 为 oss、isSaasEdition 为 false', () => {
6
+ expect(profileId).toBe('oss')
7
+ expect(isSaasEdition).toBe(false)
8
+ })
9
+ })
@@ -15,7 +15,6 @@
15
15
  // You should have received a copy of the GNU Affero General Public License
16
16
  // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
17
 
18
-
19
18
  import { trackAnalyticsFn } from '@/server/serverFns/analytics'
20
19
 
21
20
  export interface LogEvent {
@@ -82,7 +82,7 @@ async function proxyToInternalAPI(
82
82
  method: string,
83
83
  params: Record<string, unknown> | undefined,
84
84
  ): Promise<unknown> {
85
- const [group, action] = method.split(":")
85
+ const [group, action] = method.split('_')
86
86
  const apiMap: Record<string, Record<string, string>> = {
87
87
  prd: {
88
88
  list: "/api/prd",
@@ -0,0 +1,89 @@
1
+ import { describe, expect, it, vi } from 'vitest'
2
+ import { isUnauthorizedError, navigateToLoginOnUnauthorized } from '../anonymous-safe'
3
+
4
+ describe('isUnauthorizedError', () => {
5
+ it('识别 message 为 UNAUTHORIZED 的普通 Error(serverFn RPC 序列化形态)', () => {
6
+ expect(isUnauthorizedError(new Error('UNAUTHORIZED'))).toBe(true)
7
+ })
8
+
9
+ it('识别 name 为 UnauthorizedError 的错误(进程内直抛形态)', () => {
10
+ const e = new Error('别的消息')
11
+ e.name = 'UnauthorizedError'
12
+ expect(isUnauthorizedError(e)).toBe(true)
13
+ })
14
+
15
+ it('非 401 错误返回 false', () => {
16
+ expect(isUnauthorizedError(new Error('网络错误'))).toBe(false)
17
+ expect(isUnauthorizedError(new Error('FORBIDDEN'))).toBe(false)
18
+ expect(isUnauthorizedError(null)).toBe(false)
19
+ expect(isUnauthorizedError(undefined)).toBe(false)
20
+ })
21
+
22
+ it('识别 TanStack Router 包裹形态(error.error 为原始 401)', () => {
23
+ const wrapped = new Error('loader failed')
24
+ ;(wrapped as { error?: unknown }).error = new Error('UNAUTHORIZED')
25
+ expect(isUnauthorizedError(wrapped)).toBe(true)
26
+ })
27
+
28
+ it('自引用错误对象不栈溢出', () => {
29
+ const self = new Error('x')
30
+ ;(self as { error?: unknown }).error = self
31
+ expect(() => isUnauthorizedError(self)).not.toThrow()
32
+ expect(isUnauthorizedError(self)).toBe(false)
33
+ })
34
+
35
+ it('环引用错误对象不栈溢出', () => {
36
+ const a = new Error('a')
37
+ const b = new Error('b')
38
+ ;(a as { error?: unknown }).error = b
39
+ ;(b as { error?: unknown }).error = a
40
+ expect(() => isUnauthorizedError(a)).not.toThrow()
41
+ expect(isUnauthorizedError(a)).toBe(false)
42
+ })
43
+ })
44
+
45
+ describe('navigateToLoginOnUnauthorized', () => {
46
+ it('401 时携带当前页 redirect 跳登录', () => {
47
+ const navigate = vi.fn()
48
+ const router = {
49
+ state: { location: { pathname: '/prd', searchStr: '?tab=all' } },
50
+ navigate,
51
+ }
52
+ const handled = navigateToLoginOnUnauthorized(new Error('UNAUTHORIZED'), router as never)
53
+ expect(handled).toBe(true)
54
+ expect(navigate).toHaveBeenCalledWith({
55
+ to: '/login',
56
+ search: { redirect: '/prd?tab=all' },
57
+ })
58
+ })
59
+
60
+ it('非 401 返回 false 不跳转', () => {
61
+ const navigate = vi.fn()
62
+ const router = { state: { location: { pathname: '/', searchStr: '' } }, navigate }
63
+ expect(navigateToLoginOnUnauthorized(new Error('boom'), router as never)).toBe(false)
64
+ expect(navigate).not.toHaveBeenCalled()
65
+ })
66
+ })
67
+
68
+ describe('MutationCache 集成', () => {
69
+ it('QueryClient 挂载后 mutation 401 触发 navigateToLoginOnUnauthorized', async () => {
70
+ const { QueryClient, MutationCache } = await import('@tanstack/react-query')
71
+ const navigate = vi.fn()
72
+ const router = {
73
+ state: { location: { pathname: '/prd', searchStr: '' } },
74
+ navigate,
75
+ }
76
+ const mutationCache = new MutationCache({
77
+ onError: (error) => navigateToLoginOnUnauthorized(error, router as never),
78
+ })
79
+ const client = new QueryClient({ mutationCache })
80
+ const mutation = mutationCache.build(client, {
81
+ mutationFn: () => Promise.reject(new Error('UNAUTHORIZED')),
82
+ })
83
+ await mutation.execute(undefined as never).catch(() => undefined)
84
+ expect(navigate).toHaveBeenCalledWith({
85
+ to: '/login',
86
+ search: { redirect: '/prd' },
87
+ })
88
+ })
89
+ })
@@ -0,0 +1,29 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import { isRedirect } from '@tanstack/react-router'
3
+ import { requireSessionPage } from '../page-gate'
4
+
5
+ function makeArgs(session: { user?: { id?: string } } | null) {
6
+ return {
7
+ context: { session },
8
+ location: { pathname: '/settings/account', searchStr: '' },
9
+ } as never
10
+ }
11
+
12
+ describe('requireSessionPage', () => {
13
+ it('已登录放行(不抛错)', () => {
14
+ expect(() => requireSessionPage(makeArgs({ user: { id: 'u1' } }))).not.toThrow()
15
+ })
16
+
17
+ it('未登录抛 redirect 到 /login 并携带回跳', () => {
18
+ let caught: unknown
19
+ try {
20
+ requireSessionPage(makeArgs(null))
21
+ } catch (e) {
22
+ caught = e
23
+ }
24
+ const options = (caught as { options?: { to?: string; search?: { redirect?: string } } }).options
25
+ expect(isRedirect(caught as never)).toBe(true)
26
+ expect(options?.to).toBe('/login')
27
+ expect(options?.search?.redirect).toBe('/settings/account')
28
+ })
29
+ })
@@ -0,0 +1,39 @@
1
+ import type { AnyRouter } from '@tanstack/react-router'
2
+
3
+ const UNAUTHORIZED_NAME = 'UnauthorizedError'
4
+ const UNAUTHORIZED_STATUS = 401
5
+
6
+ function isUnauthorizedMessage(msg: unknown): boolean {
7
+ return typeof msg === 'string' && msg.toLowerCase() === 'unauthorized'
8
+ }
9
+
10
+ export function isUnauthorizedError(
11
+ error: unknown,
12
+ seen: WeakSet<object> = new WeakSet(),
13
+ ): boolean {
14
+ if (!error || typeof error !== 'object') return false
15
+ if (seen.has(error)) return false
16
+ seen.add(error)
17
+ const e = error as { message?: unknown; name?: unknown; error?: unknown; status?: unknown; statusCode?: unknown }
18
+ return (
19
+ isUnauthorizedMessage(e.message) ||
20
+ e.name === UNAUTHORIZED_NAME ||
21
+ e.status === UNAUTHORIZED_STATUS ||
22
+ e.statusCode === UNAUTHORIZED_STATUS ||
23
+ isUnauthorizedError(e.error, seen)
24
+ )
25
+ }
26
+
27
+ /** 写操作 401 时跳登录(带当前页回跳),返回是否已处理 */
28
+ export function navigateToLoginOnUnauthorized(
29
+ error: unknown,
30
+ router: Pick<AnyRouter, 'state' | 'navigate'>,
31
+ ): boolean {
32
+ if (!isUnauthorizedError(error)) return false
33
+ const loc = router.state.location
34
+ router.navigate({
35
+ to: '/login',
36
+ search: { redirect: loc.pathname + loc.searchStr },
37
+ })
38
+ return true
39
+ }
@@ -0,0 +1,18 @@
1
+ import { redirect } from '@tanstack/react-router'
2
+
3
+ interface SessionLike {
4
+ user?: { id?: string } | null
5
+ }
6
+
7
+ /** 「需登录页面」beforeLoad gate:未登录跳登录并携带回跳。直接用于路由 beforeLoad。 */
8
+ export function requireSessionPage(args: {
9
+ context: { session: SessionLike | null }
10
+ location: { pathname: string; searchStr: string }
11
+ }): void {
12
+ if (!args.context.session?.user?.id) {
13
+ throw redirect({
14
+ to: '/login',
15
+ search: { redirect: args.location.pathname + args.location.searchStr },
16
+ })
17
+ }
18
+ }