@tuturuuu/ui 0.23.0 → 0.25.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 (72) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/biome.json +1 -1
  3. package/package.json +78 -78
  4. package/src/components/ui/calendar-app/components/require-workspace-timezone-dialog.test.tsx +121 -0
  5. package/src/components/ui/calendar-app/components/require-workspace-timezone-dialog.tsx +37 -4
  6. package/src/components/ui/chat/ai-message-markdown.tsx +6 -1
  7. package/src/components/ui/chat/chat-external-context-sidebar.tsx +113 -0
  8. package/src/components/ui/chat/chat-sidebar-conversation-groups.tsx +5 -1
  9. package/src/components/ui/chat/chat-sidebar-groups.test.ts +33 -0
  10. package/src/components/ui/chat/chat-sidebar-items.tsx +89 -5
  11. package/src/components/ui/chat/chat-sidebar-panel.test.tsx +29 -1
  12. package/src/components/ui/chat/chat-sidebar-panel.tsx +4 -3
  13. package/src/components/ui/chat/chat-sidebar-sections.ts +24 -10
  14. package/src/components/ui/chat/chat-sidebar.tsx +3 -0
  15. package/src/components/ui/chat/chat-utils.test.ts +173 -0
  16. package/src/components/ui/chat/chat-workspace-header.tsx +11 -5
  17. package/src/components/ui/chat/chat-workspace.tsx +105 -28
  18. package/src/components/ui/chat/hooks-conversations.ts +9 -1
  19. package/src/components/ui/chat/hooks-messages.ts +1 -0
  20. package/src/components/ui/chat/hooks-realtime.ts +93 -4
  21. package/src/components/ui/chat/message-bubble.tsx +49 -4
  22. package/src/components/ui/chat/message-composer.tsx +29 -23
  23. package/src/components/ui/chat/message-list.tsx +5 -3
  24. package/src/components/ui/chat/message-markdown.tsx +4 -1
  25. package/src/components/ui/chat/query-keys.ts +7 -1
  26. package/src/components/ui/chat/selection.ts +1 -1
  27. package/src/components/ui/chat/utils.ts +126 -3
  28. package/src/components/ui/custom/__tests__/workspace-select-helpers.test.ts +72 -0
  29. package/src/components/ui/custom/onboarding-settings-panel.tsx +131 -0
  30. package/src/components/ui/custom/settings-dialog-shell.tsx +55 -18
  31. package/src/components/ui/custom/workspace-select-helpers.ts +50 -0
  32. package/src/components/ui/custom/workspace-select.tsx +37 -38
  33. package/src/components/ui/finance/analytics/analytics-page.tsx +10 -0
  34. package/src/components/ui/finance/analytics/inventory-provider-summary.tsx +110 -0
  35. package/src/components/ui/finance/finance-overview-metrics.tsx +49 -0
  36. package/src/components/ui/finance/transactions/inventory-reconciliation-entry-row.tsx +122 -0
  37. package/src/components/ui/finance/transactions/inventory-reconciliation-panel.tsx +407 -0
  38. package/src/components/ui/finance/transactions/transaction-card.tsx +15 -0
  39. package/src/components/ui/finance/transactions/transaction-edit-dialog.test.tsx +31 -0
  40. package/src/components/ui/finance/transactions/transaction-edit-dialog.tsx +26 -4
  41. package/src/components/ui/finance/transactions/transactionId/transaction-details-client-page.tsx +22 -0
  42. package/src/components/ui/finance/transactions/transactions-page.tsx +8 -0
  43. package/src/components/ui/finance/wallets/walletId/inventory-wallet-contribution.tsx +84 -0
  44. package/src/components/ui/finance/wallets/walletId/wallet-details-page.test.tsx +4 -0
  45. package/src/components/ui/finance/wallets/walletId/wallet-details-page.tsx +9 -0
  46. package/src/components/ui/legacy/meet/create-plan-dialog.tsx +27 -10
  47. package/src/components/ui/legacy/meet/edit-plan-dialog.tsx +90 -26
  48. package/src/components/ui/legacy/meet/form.tsx +25 -1
  49. package/src/components/ui/legacy/meet/lib/meet-ics.test.ts +40 -0
  50. package/src/components/ui/legacy/meet/lib/meet-ics.ts +50 -0
  51. package/src/components/ui/legacy/meet/lib/meet-insights.test.ts +76 -0
  52. package/src/components/ui/legacy/meet/lib/meet-insights.ts +219 -0
  53. package/src/components/ui/legacy/meet/lib/meet-timezone.test.ts +53 -0
  54. package/src/components/ui/legacy/meet/lib/meet-timezone.ts +45 -0
  55. package/src/components/ui/legacy/meet/page.tsx +1 -0
  56. package/src/components/ui/legacy/meet/planId/agenda-details.tsx +46 -23
  57. package/src/components/ui/legacy/meet/planId/copy-link-button.tsx +24 -197
  58. package/src/components/ui/legacy/meet/planId/date-planner.tsx +3 -28
  59. package/src/components/ui/legacy/meet/planId/meet-insights-panel.tsx +135 -0
  60. package/src/components/ui/legacy/meet/planId/meet-plan-live-root.tsx +41 -0
  61. package/src/components/ui/legacy/meet/planId/meet-query.ts +26 -0
  62. package/src/components/ui/legacy/meet/planId/meet-suggestions-panel.tsx +463 -0
  63. package/src/components/ui/legacy/meet/planId/page.tsx +58 -18
  64. package/src/components/ui/legacy/meet/planId/plan-details-client.tsx +154 -140
  65. package/src/components/ui/legacy/meet/planId/selectable-day-time.tsx +88 -56
  66. package/src/components/ui/legacy/meet/planId/show-qr-button.tsx +3 -5
  67. package/src/components/ui/legacy/meet/planId/unified-availability.tsx +36 -13
  68. package/src/components/ui/legacy/meet/planId/utility-buttons.tsx +3 -24
  69. package/src/components/ui/legacy/meet/plans-grid.tsx +1 -1
  70. package/src/components/ui/legacy/meet/plans-list-view.tsx +1 -1
  71. package/src/components/ui/nuqs-adapter.tsx +1 -0
  72. package/src/hooks/time-blocking-provider.tsx +127 -211
package/CHANGELOG.md CHANGED
@@ -1,5 +1,48 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.25.0](https://github.com/tutur3u/platform/compare/ui-v0.24.0...ui-v0.25.0) (2026-08-06)
4
+
5
+
6
+ ### Features
7
+
8
+ * **chat:** add external parity reconciliation ([#5086](https://github.com/tutur3u/platform/issues/5086)) ([5ef796f](https://github.com/tutur3u/platform/commit/5ef796f7812ec6a9f9a62193ba21633cd2503001))
9
+ * **chat:** complete connected-site operational parity ([#5093](https://github.com/tutur3u/platform/issues/5093)) ([397e11b](https://github.com/tutur3u/platform/commit/397e11bd87d583fe1c65f83a2b8019c287650e19))
10
+ * **chat:** complete connected-site parity ([fd4061d](https://github.com/tutur3u/platform/commit/fd4061d8b2f654e521c40ea9819a348ae81575c9))
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **chat:** harden connected-site parity ([a0d3148](https://github.com/tutur3u/platform/commit/a0d31483a87ed0ebd59f2be5c3bdbb342bd67855))
16
+
17
+ ## [0.24.0](https://github.com/tutur3u/platform/compare/ui-v0.23.0...ui-v0.24.0) (2026-08-04)
18
+
19
+
20
+ ### Features
21
+
22
+ * **chat:** add connected site sync bridge ([05c27f5](https://github.com/tutur3u/platform/commit/05c27f5ac4a545af366097ee2a919ec755970b9b))
23
+ * **chat:** add connected site sync bridge ([#5078](https://github.com/tutur3u/platform/issues/5078)) ([3de1a07](https://github.com/tutur3u/platform/commit/3de1a07dfa2fec96982aa0d116e003d0aa3fe47c))
24
+ * **finance:** reconcile inventory provider sales ([56650e0](https://github.com/tutur3u/platform/commit/56650e066c473337700998d8af607380e8ea6202))
25
+ * **inventory:** allocate bundle revenue and add cash checkout ([bd465f9](https://github.com/tutur3u/platform/commit/bd465f9bb35fad16d259378fa49611a8eb5ba95b))
26
+ * **meet:** revamp collaborative scheduling ([9124a5d](https://github.com/tutur3u/platform/commit/9124a5d559e071c7e6c1c713cfbca4d9f5205611))
27
+ * **onboarding:** connect product guidance across apps ([68cf626](https://github.com/tutur3u/platform/commit/68cf626c9650e5044b6c123f9423a6cebf1bba9a))
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * **chat:** address external bridge review findings ([30533fc](https://github.com/tutur3u/platform/commit/30533fc64093fed4b25279bc0e45d43bdb7a6cde))
33
+ * **chat:** close bridge edge cases ([db585c8](https://github.com/tutur3u/platform/commit/db585c8486064837dcbce615a30f66c38c0a3ec0))
34
+ * **chat:** harden bridge review edge cases ([0ecfad7](https://github.com/tutur3u/platform/commit/0ecfad7c66454fdb3bcd971f1362d3789287f086))
35
+ * **chat:** harden connected site migration ([73cccd0](https://github.com/tutur3u/platform/commit/73cccd04e9bd85a443891f3e52b443ef755570cb))
36
+ * **chat:** harden connected site sync ([70e8785](https://github.com/tutur3u/platform/commit/70e8785967e145a77330272e671ca58dfc38fbee))
37
+ * **chat:** harden external bridge boundaries ([2d25202](https://github.com/tutur3u/platform/commit/2d252023e5cfb1c7414ee2ed2d161e7f5de613f8))
38
+ * **chat:** harden external bridge synchronization ([63ccf91](https://github.com/tutur3u/platform/commit/63ccf9129ff8e7cf255bef8c74a3e096ab45cb7d))
39
+ * **chat:** mount query state adapter ([#5084](https://github.com/tutur3u/platform/issues/5084)) ([60253f8](https://github.com/tutur3u/platform/commit/60253f82477fc54923556706d12e4dc525a7a170))
40
+ * **chat:** preserve native message behavior ([fc09530](https://github.com/tutur3u/platform/commit/fc095301f2d26ca2bc39de02ce17b1f341327de9))
41
+ * **deps:** align Streamdown with Shiki 4 ([0d89f55](https://github.com/tutur3u/platform/commit/0d89f555b3228307e893a5d7723aaf8db8505d63))
42
+ * **platform:** stabilize offline and calendar initialization ([8ef8fbc](https://github.com/tutur3u/platform/commit/8ef8fbc1274e108930adf38bb8e998384551058b))
43
+ * **ui:** preserve hosted workspace logos ([1f8e8b2](https://github.com/tutur3u/platform/commit/1f8e8b28c23f659952ad58f00a2a371acd8fcef9))
44
+ * **workspaces:** route satellite creation through setup ([754bf1b](https://github.com/tutur3u/platform/commit/754bf1b81360e4755a171819f3a8e6a7c102f351))
45
+
3
46
  ## [0.23.0](https://github.com/tutur3u/platform/compare/ui-v0.22.0...ui-v0.23.0) (2026-07-28)
4
47
 
5
48
 
package/biome.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "root": false,
3
- "$schema": "https://biomejs.dev/schemas/2.5.5/schema.json",
3
+ "$schema": "https://biomejs.dev/schemas/2.5.6/schema.json",
4
4
  "extends": "//"
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuturuuu/ui",
3
- "version": "0.23.0",
3
+ "version": "0.25.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,36 +21,36 @@
21
21
  "@dnd-kit/sortable": "^10.0.0",
22
22
  "@dnd-kit/utilities": "^3.2.2",
23
23
  "@dqcai/vn-lunar": "^1.0.1",
24
- "@hookform/resolvers": "^5.4.0",
24
+ "@hookform/resolvers": "^5.7.1",
25
25
  "@json-render/core": "^0.19.0",
26
26
  "@json-render/react": "^0.19.0",
27
- "@radix-ui/react-accordion": "^1.2.18",
28
- "@radix-ui/react-alert-dialog": "^1.1.21",
29
- "@radix-ui/react-aspect-ratio": "^1.1.13",
30
- "@radix-ui/react-avatar": "^1.2.4",
31
- "@radix-ui/react-checkbox": "^1.3.9",
32
- "@radix-ui/react-collapsible": "^1.1.18",
33
- "@radix-ui/react-context-menu": "^2.3.5",
34
- "@radix-ui/react-dialog": "^1.1.21",
35
- "@radix-ui/react-dropdown-menu": "^2.1.22",
36
- "@radix-ui/react-hover-card": "^1.1.21",
37
- "@radix-ui/react-label": "^2.1.13",
38
- "@radix-ui/react-menubar": "^1.1.22",
39
- "@radix-ui/react-navigation-menu": "^1.2.20",
40
- "@radix-ui/react-popover": "^1.1.21",
41
- "@radix-ui/react-progress": "^1.1.14",
42
- "@radix-ui/react-radio-group": "^1.4.5",
43
- "@radix-ui/react-scroll-area": "^1.2.16",
44
- "@radix-ui/react-select": "^2.3.5",
45
- "@radix-ui/react-separator": "^1.1.13",
46
- "@radix-ui/react-slider": "^1.4.5",
47
- "@radix-ui/react-slot": "^1.3.1",
48
- "@radix-ui/react-switch": "^1.3.5",
49
- "@radix-ui/react-tabs": "^1.1.19",
50
- "@radix-ui/react-toast": "^1.2.21",
51
- "@radix-ui/react-toggle": "^1.1.16",
52
- "@radix-ui/react-toggle-group": "^1.1.17",
53
- "@radix-ui/react-tooltip": "^1.2.14",
27
+ "@radix-ui/react-accordion": "^1.2.20",
28
+ "@radix-ui/react-alert-dialog": "^1.1.23",
29
+ "@radix-ui/react-aspect-ratio": "^1.1.15",
30
+ "@radix-ui/react-avatar": "^1.2.6",
31
+ "@radix-ui/react-checkbox": "^1.3.11",
32
+ "@radix-ui/react-collapsible": "^1.1.20",
33
+ "@radix-ui/react-context-menu": "^2.3.7",
34
+ "@radix-ui/react-dialog": "^1.1.23",
35
+ "@radix-ui/react-dropdown-menu": "^2.1.24",
36
+ "@radix-ui/react-hover-card": "^1.1.23",
37
+ "@radix-ui/react-label": "^2.1.15",
38
+ "@radix-ui/react-menubar": "^1.1.24",
39
+ "@radix-ui/react-navigation-menu": "^1.2.22",
40
+ "@radix-ui/react-popover": "^1.1.23",
41
+ "@radix-ui/react-progress": "^1.1.16",
42
+ "@radix-ui/react-radio-group": "^1.4.7",
43
+ "@radix-ui/react-scroll-area": "^1.2.18",
44
+ "@radix-ui/react-select": "^2.3.7",
45
+ "@radix-ui/react-separator": "^1.1.15",
46
+ "@radix-ui/react-slider": "^1.4.7",
47
+ "@radix-ui/react-slot": "^1.3.3",
48
+ "@radix-ui/react-switch": "^1.3.7",
49
+ "@radix-ui/react-tabs": "^1.1.21",
50
+ "@radix-ui/react-toast": "^1.2.23",
51
+ "@radix-ui/react-toggle": "^1.1.18",
52
+ "@radix-ui/react-toggle-group": "^1.1.19",
53
+ "@radix-ui/react-tooltip": "^1.2.16",
54
54
  "@streamdown/cjk": "^1.0.3",
55
55
  "@streamdown/code": "^1.1.1",
56
56
  "@streamdown/math": "^1.0.2",
@@ -59,40 +59,40 @@
59
59
  "@tanstack/react-pacer": "^0.22.1",
60
60
  "@tanstack/react-query": "^5.101.2",
61
61
  "@tanstack/react-table": "^8.21.3",
62
- "@tanstack/react-virtual": "^3.14.8",
63
- "@tiptap/core": "3.28.0",
64
- "@tiptap/extension-collaboration": "3.28.0",
65
- "@tiptap/extension-collaboration-caret": "3.28.0",
66
- "@tiptap/extension-color": "3.28.0",
67
- "@tiptap/extension-drag-handle": "3.28.0",
68
- "@tiptap/extension-drag-handle-react": "3.28.0",
69
- "@tiptap/extension-highlight": "3.28.0",
70
- "@tiptap/extension-horizontal-rule": "3.28.0",
71
- "@tiptap/extension-image": "3.28.0",
72
- "@tiptap/extension-link": "3.28.0",
73
- "@tiptap/extension-list": "3.28.0",
74
- "@tiptap/extension-node-range": "3.28.0",
75
- "@tiptap/extension-placeholder": "3.28.0",
76
- "@tiptap/extension-strike": "3.28.0",
77
- "@tiptap/extension-subscript": "3.28.0",
78
- "@tiptap/extension-superscript": "3.28.0",
79
- "@tiptap/extension-table": "3.28.0",
80
- "@tiptap/extension-table-cell": "3.28.0",
81
- "@tiptap/extension-table-header": "3.28.0",
82
- "@tiptap/extension-table-row": "3.28.0",
83
- "@tiptap/extension-text-align": "3.28.0",
84
- "@tiptap/extension-text-style": "3.28.0",
85
- "@tiptap/extension-youtube": "3.28.0",
86
- "@tiptap/pm": "3.28.0",
87
- "@tiptap/react": "3.28.0",
88
- "@tiptap/starter-kit": "3.28.0",
89
- "@tuturuuu/ai": "0.6.0",
90
- "@tuturuuu/apis": "0.10.0",
62
+ "@tanstack/react-virtual": "^3.14.9",
63
+ "@tiptap/core": "3.29.2",
64
+ "@tiptap/extension-collaboration": "3.29.2",
65
+ "@tiptap/extension-collaboration-caret": "3.29.2",
66
+ "@tiptap/extension-color": "3.29.2",
67
+ "@tiptap/extension-drag-handle": "3.29.2",
68
+ "@tiptap/extension-drag-handle-react": "3.29.2",
69
+ "@tiptap/extension-highlight": "3.29.2",
70
+ "@tiptap/extension-horizontal-rule": "3.29.2",
71
+ "@tiptap/extension-image": "3.29.2",
72
+ "@tiptap/extension-link": "3.29.2",
73
+ "@tiptap/extension-list": "3.29.2",
74
+ "@tiptap/extension-node-range": "3.29.2",
75
+ "@tiptap/extension-placeholder": "3.29.2",
76
+ "@tiptap/extension-strike": "3.29.2",
77
+ "@tiptap/extension-subscript": "3.29.2",
78
+ "@tiptap/extension-superscript": "3.29.2",
79
+ "@tiptap/extension-table": "3.29.2",
80
+ "@tiptap/extension-table-cell": "3.29.2",
81
+ "@tiptap/extension-table-header": "3.29.2",
82
+ "@tiptap/extension-table-row": "3.29.2",
83
+ "@tiptap/extension-text-align": "3.29.2",
84
+ "@tiptap/extension-text-style": "3.29.2",
85
+ "@tiptap/extension-youtube": "3.29.2",
86
+ "@tiptap/pm": "3.29.2",
87
+ "@tiptap/react": "3.29.2",
88
+ "@tiptap/starter-kit": "3.29.2",
89
+ "@tuturuuu/ai": "0.8.0",
90
+ "@tuturuuu/apis": "0.11.0",
91
91
  "@tuturuuu/hooks": "0.1.0",
92
92
  "@tuturuuu/icons": "0.1.0",
93
- "@tuturuuu/internal-api": "0.25.0",
93
+ "@tuturuuu/internal-api": "0.28.0",
94
94
  "@tuturuuu/supabase": "0.5.0",
95
- "@tuturuuu/utils": "0.21.0",
95
+ "@tuturuuu/utils": "0.22.0",
96
96
  "@types/debug": "^4.1.13",
97
97
  "browser-image-compression": "^2.0.2",
98
98
  "class-variance-authority": "^0.7.1",
@@ -104,41 +104,41 @@
104
104
  "debug": "^4.4.3",
105
105
  "embla-carousel-react": "^8.6.0",
106
106
  "eventemitter3": "^5.0.4",
107
- "framer-motion": "^12.42.2",
107
+ "framer-motion": "^12.43.0",
108
108
  "gsap": "^3.15.0",
109
- "html2canvas-pro": "^2.3.1",
109
+ "html2canvas-pro": "^2.3.3",
110
110
  "input-otp": "^1.4.2",
111
111
  "katex": "^0.18.1",
112
112
  "lodash": "4.18.1",
113
113
  "moment": "^2.30.1",
114
- "motion": "^12.42.2",
115
- "next": "^16.3.0-preview.9",
114
+ "motion": "^12.43.0",
115
+ "next": "^16.3.0",
116
116
  "next-intl": "^4.13.4",
117
117
  "next-themes": "^0.4.6",
118
- "nuqs": "^2.9.1",
118
+ "nuqs": "^2.9.3",
119
119
  "prosemirror-state": "^1.4.4",
120
- "prosemirror-view": "1.42.1",
120
+ "prosemirror-view": "1.42.2",
121
121
  "qrcode.react": "^4.2.0",
122
122
  "react": "^19.2.8",
123
123
  "react-colorful": "^5.8.0",
124
124
  "react-day-picker": "^10.0.1",
125
125
  "react-dom": "^19.2.8",
126
- "react-dropzone": "^19.1.1",
127
- "react-hook-form": "^7.82.0",
126
+ "react-dropzone": "^20.0.0",
127
+ "react-hook-form": "^7.84.0",
128
128
  "react-markdown": "^10.1.0",
129
129
  "react-papaparse": "^4.4.0",
130
130
  "react-pdf": "^10.4.1",
131
131
  "react-resizable": "^4.0.2",
132
132
  "react-resizable-panels": "^4.12.2",
133
133
  "react-syntax-highlighter": "^16.1.1",
134
- "recharts": "3.10.0",
134
+ "recharts": "3.10.1",
135
135
  "slot-text": "^0.3.3",
136
136
  "sonner": "^2.0.7",
137
137
  "streamdown": "^2.5.0",
138
138
  "tailwind-scrollbar": "^4.0.2",
139
139
  "tailwind-scrollbar-hide": "^4.0.0",
140
140
  "tailwindcss-animate": "^1.0.7",
141
- "tiptap-extension-resize-image": "^1.4.4",
141
+ "tiptap-extension-resize-image": "^1.4.5",
142
142
  "use-debounce": "^10.1.1",
143
143
  "vaul": "^1.1.2",
144
144
  "y-protocols": "^1.0.7",
@@ -152,20 +152,20 @@
152
152
  "@tanstack/react-table": "^8.21.3",
153
153
  "@testing-library/jest-dom": "^7.0.0",
154
154
  "@testing-library/react": "^16.3.2",
155
- "@tuturuuu/types": "0.24.0",
155
+ "@tuturuuu/types": "0.27.0",
156
156
  "@tuturuuu/typescript-config": "0.1.1",
157
157
  "@types/html2canvas": "^1.0.0",
158
- "@types/lodash": "^4.17.24",
159
- "@types/node": "^26.1.1",
160
- "@types/react": "^19.2.17",
161
- "@types/react-dom": "^19.2.3",
158
+ "@types/lodash": "^4.17.25",
159
+ "@types/node": "^26.1.2",
160
+ "@types/react": "^19.2.18",
161
+ "@types/react-dom": "^19.2.4",
162
162
  "@types/react-resizable": "^4.0.0",
163
163
  "@types/react-syntax-highlighter": "^15.5.13",
164
164
  "@types/uuid": "^11.0.0",
165
- "@vitejs/plugin-react": "^6.0.4",
165
+ "@vitejs/plugin-react": "^6.0.5",
166
166
  "autoprefixer": "^10.5.4",
167
- "jsdom": "^29.1.1",
168
- "postcss": "^8.5.22",
167
+ "jsdom": "^30.0.1",
168
+ "postcss": "^8.5.25",
169
169
  "postcss-load-config": "^6.0.1",
170
170
  "tailwindcss": "^4.3.3",
171
171
  "typescript": "7.0.2",
@@ -0,0 +1,121 @@
1
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
2
+ import { fireEvent, render, screen, waitFor } from '@testing-library/react';
3
+ import type { ReactNode } from 'react';
4
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
5
+ import { RequireWorkspaceTimezoneDialog } from './require-workspace-timezone-dialog';
6
+
7
+ vi.mock('next/navigation', () => ({
8
+ useRouter: () => ({ refresh: vi.fn() }),
9
+ }));
10
+
11
+ vi.mock('next-intl', () => ({
12
+ useTranslations: (namespace: string) => (key: string) =>
13
+ `${namespace}.${key}`,
14
+ }));
15
+
16
+ vi.mock('../../dialog', () => ({
17
+ Dialog: ({ children }: { children: ReactNode }) => <div>{children}</div>,
18
+ DialogContent: ({ children }: { children: ReactNode }) => (
19
+ <div>{children}</div>
20
+ ),
21
+ DialogDescription: ({ children }: { children: ReactNode }) => (
22
+ <p>{children}</p>
23
+ ),
24
+ DialogFooter: ({ children }: { children: ReactNode }) => (
25
+ <div>{children}</div>
26
+ ),
27
+ DialogHeader: ({ children }: { children: ReactNode }) => (
28
+ <div>{children}</div>
29
+ ),
30
+ DialogTitle: ({ children }: { children: ReactNode }) => <h2>{children}</h2>,
31
+ }));
32
+
33
+ vi.mock('../../sonner', () => ({
34
+ toast: { error: vi.fn(), success: vi.fn() },
35
+ }));
36
+
37
+ function renderDialog() {
38
+ const queryClient = new QueryClient({
39
+ defaultOptions: {
40
+ mutations: { retry: false },
41
+ queries: { retry: false },
42
+ },
43
+ });
44
+
45
+ return render(
46
+ <QueryClientProvider client={queryClient}>
47
+ <RequireWorkspaceTimezoneDialog
48
+ onCompleted={vi.fn()}
49
+ wsId="workspace-1"
50
+ />
51
+ </QueryClientProvider>
52
+ );
53
+ }
54
+
55
+ describe('RequireWorkspaceTimezoneDialog E2EE initialization', () => {
56
+ beforeEach(() => {
57
+ vi.stubGlobal(
58
+ 'fetch',
59
+ vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => {
60
+ const url = String(input);
61
+
62
+ if (url.endsWith('/calendar-settings')) {
63
+ return Response.json({
64
+ first_day_of_week: 'monday',
65
+ timezone: 'UTC',
66
+ });
67
+ }
68
+
69
+ if (url.endsWith('/encryption') && init?.method === 'POST') {
70
+ return Response.json({ error: 'temporary failure' }, { status: 500 });
71
+ }
72
+
73
+ if (url.endsWith('/encryption')) {
74
+ return Response.json({ enabled: true, hasKey: false });
75
+ }
76
+
77
+ throw new Error(`Unexpected request: ${url}`);
78
+ })
79
+ );
80
+ });
81
+
82
+ afterEach(() => {
83
+ vi.unstubAllGlobals();
84
+ });
85
+
86
+ it('attempts once automatically and waits for an explicit retry', async () => {
87
+ const view = renderDialog();
88
+
89
+ await screen.findByRole('button', { name: 'common.retry' });
90
+
91
+ const postCount = () =>
92
+ vi.mocked(fetch).mock.calls.filter(([, init]) => init?.method === 'POST')
93
+ .length;
94
+
95
+ expect(postCount()).toBe(1);
96
+
97
+ view.rerender(
98
+ <QueryClientProvider
99
+ client={
100
+ new QueryClient({
101
+ defaultOptions: {
102
+ mutations: { retry: false },
103
+ queries: { retry: false },
104
+ },
105
+ })
106
+ }
107
+ >
108
+ <RequireWorkspaceTimezoneDialog
109
+ onCompleted={vi.fn()}
110
+ wsId="workspace-1"
111
+ />
112
+ </QueryClientProvider>
113
+ );
114
+
115
+ await waitFor(() => expect(postCount()).toBe(1));
116
+
117
+ fireEvent.click(screen.getByRole('button', { name: 'common.retry' }));
118
+
119
+ await waitFor(() => expect(postCount()).toBe(2));
120
+ });
121
+ });
@@ -4,7 +4,7 @@ import { useMutation, useQuery } from '@tanstack/react-query';
4
4
  import { Clock, Loader2, ShieldCheck } from '@tuturuuu/icons';
5
5
  import { useRouter } from 'next/navigation';
6
6
  import { useTranslations } from 'next-intl';
7
- import { useEffect, useMemo, useState } from 'react';
7
+ import { useEffect, useMemo, useRef, useState } from 'react';
8
8
  import { detectLocaleFirstDay } from '../../../../lib/calendar-settings-resolver';
9
9
  import { Button } from '../../button';
10
10
  import {
@@ -55,7 +55,9 @@ export function RequireWorkspaceTimezoneDialog({
55
55
  onCompleted,
56
56
  }: RequireWorkspaceTimezoneDialogProps) {
57
57
  const t = useTranslations('calendar');
58
+ const tCommon = useTranslations('common');
58
59
  const router = useRouter();
60
+ const autoEnableAttemptedWorkspace = useRef<string | null>(null);
59
61
 
60
62
  const browserTimezone = useMemo(() => detectBrowserTimezone(), []);
61
63
  const timezones = useMemo(() => getSupportedTimezones(), []);
@@ -216,11 +218,28 @@ export function RequireWorkspaceTimezoneDialog({
216
218
  // This happens automatically since E2EE is mandatory for calendar to work
217
219
  const isEnablingE2EE = enableE2EE.isPending;
218
220
  const isFetchingE2EE = e2eeQuery.isFetching;
221
+ const enableE2EEMutate = enableE2EE.mutate;
219
222
  useEffect(() => {
220
- if (needsE2EESetup && !isEnablingE2EE && !isFetchingE2EE && !hasE2EE) {
221
- enableE2EE.mutate();
223
+ if (
224
+ !needsE2EESetup ||
225
+ isEnablingE2EE ||
226
+ isFetchingE2EE ||
227
+ hasE2EE ||
228
+ autoEnableAttemptedWorkspace.current === wsId
229
+ ) {
230
+ return;
222
231
  }
223
- }, [needsE2EESetup, isEnablingE2EE, isFetchingE2EE, hasE2EE, enableE2EE]);
232
+
233
+ autoEnableAttemptedWorkspace.current = wsId;
234
+ enableE2EEMutate();
235
+ }, [
236
+ needsE2EESetup,
237
+ isEnablingE2EE,
238
+ isFetchingE2EE,
239
+ hasE2EE,
240
+ wsId,
241
+ enableE2EEMutate,
242
+ ]);
224
243
 
225
244
  // Keep local selects in sync with server values once fetched.
226
245
  useEffect(() => {
@@ -375,6 +394,20 @@ export function RequireWorkspaceTimezoneDialog({
375
394
  {t('e2ee.already_enabled')}
376
395
  </span>
377
396
  </div>
397
+ ) : enableE2EE.isError ? (
398
+ <div className="flex items-center justify-between gap-3 rounded-lg border border-dynamic-red/50 bg-dynamic-red/10 p-3">
399
+ <span className="font-medium text-dynamic-red text-sm">
400
+ {t('e2ee.key_generation_failed')}
401
+ </span>
402
+ <Button
403
+ onClick={() => enableE2EEMutate()}
404
+ size="sm"
405
+ type="button"
406
+ variant="outline"
407
+ >
408
+ {tCommon('retry')}
409
+ </Button>
410
+ </div>
378
411
  ) : (
379
412
  <div className="flex items-center gap-2 rounded-lg border border-dynamic-blue/50 bg-dynamic-blue/10 p-3">
380
413
  <Loader2 className="h-4 w-4 animate-spin text-dynamic-blue" />
@@ -8,7 +8,12 @@ import { Component, type ErrorInfo, type ReactNode } from 'react';
8
8
  import { Streamdown } from 'streamdown';
9
9
 
10
10
  const math = createMathPlugin({ singleDollarTextMath: true });
11
- const markdownPlugins = { code, mermaid: mermaidPlugin, math, cjk };
11
+ const markdownPlugins = {
12
+ code,
13
+ mermaid: mermaidPlugin,
14
+ math,
15
+ cjk,
16
+ };
12
17
 
13
18
  class AiMarkdownErrorBoundary extends Component<
14
19
  { children: ReactNode; fallback: ReactNode },
@@ -0,0 +1,113 @@
1
+ 'use client';
2
+
3
+ import { useQuery } from '@tanstack/react-query';
4
+ import { LoaderCircle, MapPin } from '@tuturuuu/icons';
5
+ import {
6
+ type ExternalChatConversationContext,
7
+ getExternalChatConversationContext,
8
+ } from '@tuturuuu/internal-api';
9
+ import { useTranslations } from 'next-intl';
10
+ import { ScrollArea } from '../scroll-area';
11
+ import { formatChatTime } from './utils';
12
+
13
+ export function ChatExternalContextSidebar({
14
+ conversationId,
15
+ open,
16
+ wsId,
17
+ }: {
18
+ conversationId?: string | null;
19
+ open: boolean;
20
+ wsId: string;
21
+ }) {
22
+ const t = useTranslations('chat');
23
+ const query = useQuery({
24
+ enabled: open && Boolean(conversationId),
25
+ queryFn: () =>
26
+ getExternalChatConversationContext(wsId, conversationId as string),
27
+ queryKey: ['chat', wsId, conversationId, 'external-context'],
28
+ });
29
+ if (!open) return null;
30
+ return (
31
+ <aside className="hidden w-80 min-w-0 shrink-0 overflow-hidden border-l bg-background md:flex md:flex-col">
32
+ <div className="border-b p-3">
33
+ <h2 className="font-semibold text-sm">{t('visitor_context')}</h2>
34
+ </div>
35
+ <ScrollArea className="min-h-0 flex-1">
36
+ {query.isLoading ? (
37
+ <div className="flex items-center justify-center p-6 text-muted-foreground text-sm">
38
+ <LoaderCircle className="mr-2 size-4 animate-spin" />
39
+ {t('loading_visitor_context')}
40
+ </div>
41
+ ) : query.data ? (
42
+ <ContextContent context={query.data} />
43
+ ) : (
44
+ <p className="p-4 text-muted-foreground text-sm">
45
+ {t('visitor_context_unavailable')}
46
+ </p>
47
+ )}
48
+ </ScrollArea>
49
+ </aside>
50
+ );
51
+ }
52
+
53
+ function ContextContent({
54
+ context,
55
+ }: {
56
+ context: ExternalChatConversationContext;
57
+ }) {
58
+ const t = useTranslations('chat');
59
+ return (
60
+ <div className="space-y-5 p-4">
61
+ <dl className="space-y-3">
62
+ <Detail label={t('visitor_name')} value={context.profile.displayName} />
63
+ <Detail label={t('visitor_phone')} value={context.profile.phone} />
64
+ <Detail label={t('visitor_email')} value={context.profile.email} />
65
+ <Detail label={t('network_hint')} value={context.networkHint} />
66
+ <Detail
67
+ label={t('first_activity')}
68
+ value={formatChatTime(context.firstActivityAt)}
69
+ />
70
+ <Detail
71
+ label={t('last_activity')}
72
+ value={formatChatTime(context.lastActivityAt)}
73
+ />
74
+ </dl>
75
+ <section>
76
+ <h3 className="font-semibold text-muted-foreground text-xs uppercase">
77
+ {t('visited_routes')}
78
+ </h3>
79
+ <div className="mt-2 space-y-2">
80
+ {context.routes.length ? (
81
+ context.routes.map((route) => (
82
+ <div
83
+ className="flex gap-2 border-l-2 pl-3 text-sm"
84
+ key={`${route.occurredAt}:${route.location}`}
85
+ >
86
+ <MapPin className="mt-0.5 size-3.5 shrink-0 text-muted-foreground" />
87
+ <div className="min-w-0">
88
+ <p className="break-all">{route.location}</p>
89
+ <p className="text-muted-foreground text-xs">
90
+ {formatChatTime(route.occurredAt)}
91
+ </p>
92
+ </div>
93
+ </div>
94
+ ))
95
+ ) : (
96
+ <p className="text-muted-foreground text-sm">
97
+ {t('no_visited_routes')}
98
+ </p>
99
+ )}
100
+ </div>
101
+ </section>
102
+ </div>
103
+ );
104
+ }
105
+
106
+ function Detail({ label, value }: { label: string; value: string | null }) {
107
+ return (
108
+ <div>
109
+ <dt className="text-muted-foreground text-xs">{label}</dt>
110
+ <dd className="mt-0.5 break-words text-sm">{value || '-'}</dd>
111
+ </div>
112
+ );
113
+ }
@@ -48,6 +48,7 @@ export function ConversationGroups({
48
48
  isFetchingMoreConversations,
49
49
  onArchiveConversation,
50
50
  onLoadMoreConversations,
51
+ onlineConversationIds,
51
52
  onPinConversation,
52
53
  onSelectConversation,
53
54
  scope,
@@ -61,6 +62,7 @@ export function ConversationGroups({
61
62
  isFetchingMoreConversations?: boolean;
62
63
  onArchiveConversation?: (conversationId: string) => void;
63
64
  onLoadMoreConversations?: () => Promise<unknown> | undefined;
65
+ onlineConversationIds?: ReadonlySet<string>;
64
66
  onPinConversation?: (conversationId: string, pinned: boolean) => void;
65
67
  onSelectConversation: (conversationId: string) => void;
66
68
  scope?: ChatConversationScope;
@@ -166,7 +168,8 @@ export function ConversationGroups({
166
168
  count: items.length,
167
169
  estimateSize: (index) => {
168
170
  const item = items[index];
169
- if (item?.type === 'conversation') return 36;
171
+ if (item?.type === 'conversation')
172
+ return item.conversation.metadata.externalChat === true ? 66 : 36;
170
173
  if (item?.type === 'loader') return 44;
171
174
  if (item?.type === 'source-group-label') return 34;
172
175
  return 30;
@@ -252,6 +255,7 @@ export function ConversationGroups({
252
255
  conversation={item.conversation}
253
256
  currentUserId={currentUserId}
254
257
  isSelected={item.conversation.id === selectedConversationId}
258
+ isOnline={onlineConversationIds?.has(item.conversation.id)}
255
259
  onArchiveConversation={onArchiveConversation}
256
260
  onPinConversation={onPinConversation}
257
261
  onSelectConversation={onSelectConversation}