@micha.bigler/ui-core-micha 3.14.4 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (341) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +7 -0
  3. package/dist/chat/kitSxRegistry.js +9 -0
  4. package/dist/components/charts/kitSxRegistry.js +6 -0
  5. package/dist/entries/charts.js +6 -0
  6. package/dist/entries/chat.js +8 -0
  7. package/dist/entries/markdown.js +1 -0
  8. package/dist/index.js +0 -14
  9. package/dist/pages/AccountPage.js +1 -2
  10. package/dist/pages/LoginPage.js +1 -2
  11. package/dist/pages/PasswordChangePage.js +1 -2
  12. package/dist/pages/PasswordInvitePage.js +1 -2
  13. package/dist/pages/PasswordResetRequestPage.js +1 -2
  14. package/dist/pages/SignUpPage.js +1 -2
  15. package/dist/pages/SignupConfirmPage.js +1 -2
  16. package/dist/theme/kitSxEntry.js +11 -0
  17. package/dist/theme/kitSxRegistry.js +2 -15
  18. package/package.json +31 -7
  19. package/.github/workflows/ci.yml +0 -35
  20. package/.github/workflows/publish.yml +0 -126
  21. package/DESIGN.md +0 -60
  22. package/WORK_ORDERS.md +0 -150
  23. package/dev/entries.jsx +0 -721
  24. package/dev/fixtures.js +0 -26
  25. package/dev/main.jsx +0 -75
  26. package/dev/mockTransport.jsx +0 -128
  27. package/docs/CHART-LAYOUT.md +0 -157
  28. package/docs/DARK-TOKENS.md +0 -140
  29. package/docs/TYPE-SCALE.md +0 -111
  30. package/docs/messaging-deviations.md +0 -118
  31. package/index.html +0 -12
  32. package/renovate.json +0 -10
  33. package/scripts/chart-api-census.mjs +0 -415
  34. package/src/auth/AuthContext.jsx +0 -158
  35. package/src/auth/ReauthModal.jsx +0 -82
  36. package/src/auth/UserMenu.jsx +0 -121
  37. package/src/auth/apiClient.jsx +0 -232
  38. package/src/auth/authApi.jsx +0 -539
  39. package/src/auth/authConfig.jsx +0 -34
  40. package/src/auth/reauth.js +0 -47
  41. package/src/chat/ChatComposer.jsx +0 -36
  42. package/src/chat/ChatList.jsx +0 -87
  43. package/src/chat/ChatThread.jsx +0 -128
  44. package/src/chat/ChatWorkspace.jsx +0 -244
  45. package/src/chat/MarkdownReply.jsx +0 -22
  46. package/src/chat/ModelPicker.jsx +0 -85
  47. package/src/chat/api.js +0 -18
  48. package/src/chat/useChatSocket.js +0 -32
  49. package/src/chat/wire.js +0 -7
  50. package/src/components/AccessCodeManager.jsx +0 -288
  51. package/src/components/AccessCodeSingleUseToggle.jsx +0 -92
  52. package/src/components/AllowedEmailDomainsManager.jsx +0 -92
  53. package/src/components/AuthFactorRequirementCard.jsx +0 -95
  54. package/src/components/BulkInviteCsvTab.jsx +0 -198
  55. package/src/components/EmptyState.jsx +0 -38
  56. package/src/components/LoginForm.jsx +0 -159
  57. package/src/components/MFAComponent.jsx +0 -350
  58. package/src/components/MfaLoginComponent.jsx +0 -252
  59. package/src/components/MobileBottomNav.jsx +0 -82
  60. package/src/components/PasskeysComponent.jsx +0 -252
  61. package/src/components/PasswordChangeForm.jsx +0 -87
  62. package/src/components/PasswordResetRequestForm.jsx +0 -43
  63. package/src/components/PasswordSetForm.jsx +0 -97
  64. package/src/components/ProfileComponent.jsx +0 -348
  65. package/src/components/QrSignupManager.jsx +0 -404
  66. package/src/components/QrSignupValidityManager.jsx +0 -106
  67. package/src/components/RegistrationMethodsManager.jsx +0 -150
  68. package/src/components/SecurityComponent.jsx +0 -141
  69. package/src/components/SocialLoginButtons.jsx +0 -83
  70. package/src/components/SoftChip.jsx +0 -93
  71. package/src/components/StatTile.jsx +0 -39
  72. package/src/components/SupportRecoveryRequestsTab.jsx +0 -482
  73. package/src/components/TurnstileWidget.jsx +0 -99
  74. package/src/components/UserInviteComponent.jsx +0 -76
  75. package/src/components/UserListComponent.jsx +0 -618
  76. package/src/components/charts/BarChart.jsx +0 -102
  77. package/src/components/charts/ChartFrame.jsx +0 -214
  78. package/src/components/charts/LineChart.jsx +0 -126
  79. package/src/components/charts/ScatterChart.jsx +0 -299
  80. package/src/components/charts/TimeSeriesChart.jsx +0 -300
  81. package/src/components/charts/chartDefaults.js +0 -644
  82. package/src/components/charts/chartLabels.js +0 -36
  83. package/src/components/charts/exportChart.js +0 -258
  84. package/src/components/charts/formatters.js +0 -39
  85. package/src/components/charts/palette.js +0 -33
  86. package/src/components/charts/yearTickInterval.js +0 -7
  87. package/src/i18n/authTranslations.ts +0 -2651
  88. package/src/i18n/chartsTranslations.ts +0 -91
  89. package/src/i18n/chatTranslations.ts +0 -55
  90. package/src/i18n/messagingTranslations.ts +0 -120
  91. package/src/i18n/notificationsTranslations.ts +0 -32
  92. package/src/i18n/onboardingTranslations.ts +0 -29
  93. package/src/i18n/sectionNavTranslations.ts +0 -20
  94. package/src/i18n/uiCoreTranslations.js +0 -29
  95. package/src/i18n/userMenuTranslations.ts +0 -5
  96. package/src/index.js +0 -158
  97. package/src/layout/PageLayout.jsx +0 -36
  98. package/src/layout/SectionNav.jsx +0 -320
  99. package/src/messaging/AttachmentList.jsx +0 -145
  100. package/src/messaging/Composer.jsx +0 -197
  101. package/src/messaging/ConversationLaunchers.jsx +0 -51
  102. package/src/messaging/ConversationList.jsx +0 -109
  103. package/src/messaging/DirectMessageLauncher.jsx +0 -112
  104. package/src/messaging/MessageBubble.jsx +0 -183
  105. package/src/messaging/MessagingProvider.jsx +0 -0
  106. package/src/messaging/MessagingScopeConfig.jsx +0 -24
  107. package/src/messaging/PollCard.jsx +0 -163
  108. package/src/messaging/ReactionBar.jsx +0 -43
  109. package/src/messaging/ReadTicks.jsx +0 -82
  110. package/src/messaging/Thread.jsx +0 -195
  111. package/src/messaging/api.js +0 -48
  112. package/src/messaging/composerImageCompression.js +0 -35
  113. package/src/messaging/linkifyText.jsx +0 -37
  114. package/src/notifications/NotificationBell.jsx +0 -84
  115. package/src/notifications/NotificationSettings.jsx +0 -330
  116. package/src/notifications/NotificationsProvider.jsx +0 -224
  117. package/src/notifications/PopupSurface.jsx +0 -105
  118. package/src/notifications/api.js +0 -55
  119. package/src/notifications/feedApi.js +0 -18
  120. package/src/notifications/realtime.jsx +0 -138
  121. package/src/notifications/serviceWorker/sw.js +0 -50
  122. package/src/onboarding/OnboardingProvider.jsx +0 -326
  123. package/src/onboarding/OnboardingWizard.jsx +0 -61
  124. package/src/onboarding/WizardDialogShell.jsx +0 -51
  125. package/src/onboarding/api.js +0 -13
  126. package/src/onboarding/stepSelection.js +0 -16
  127. package/src/onboarding/steps/BrowserPushStep.jsx +0 -121
  128. package/src/onboarding/steps/CompleteNameStep.jsx +0 -46
  129. package/src/onboarding/steps/CookieConsentStep.jsx +0 -133
  130. package/src/onboarding/steps/PwaInstallStep.jsx +0 -47
  131. package/src/pages/AccountPage.jsx +0 -394
  132. package/src/pages/LoginPage.jsx +0 -343
  133. package/src/pages/PasswordChangePage.jsx +0 -62
  134. package/src/pages/PasswordInvitePage.jsx +0 -177
  135. package/src/pages/PasswordResetRequestPage.jsx +0 -68
  136. package/src/pages/SignUpPage.jsx +0 -268
  137. package/src/pages/SignupConfirmPage.jsx +0 -155
  138. package/src/testing/checkKitIntegration.js +0 -233
  139. package/src/theme/createAppTheme.js +0 -423
  140. package/src/theme/fonts.js +0 -3
  141. package/src/theme/index.js +0 -21
  142. package/src/theme/kitSxRegistry.js +0 -285
  143. package/src/theme/themeCompleteness.js +0 -1045
  144. package/src/theme/tokens.js +0 -478
  145. package/src/utils/auth-errors.js +0 -76
  146. package/src/utils/authService.js +0 -223
  147. package/src/utils/resolveErrorText.js +0 -28
  148. package/src/utils/webauthn.js +0 -51
  149. package/tests/AccountPage.profileStatements.test.jsx +0 -162
  150. package/tests/AccountPage.test.jsx +0 -200
  151. package/tests/AuthContext.test.jsx +0 -129
  152. package/tests/BarChart.test.jsx +0 -112
  153. package/tests/BrowserPushStep.test.jsx +0 -110
  154. package/tests/ChartFrame.test.jsx +0 -336
  155. package/tests/ConversationList.test.jsx +0 -144
  156. package/tests/CookieConsentStep.test.jsx +0 -69
  157. package/tests/EmptyState.test.jsx +0 -62
  158. package/tests/LineChart.test.jsx +0 -80
  159. package/tests/MessagingProvider.test.jsx +0 -50
  160. package/tests/MobileBottomNav.test.jsx +0 -319
  161. package/tests/NotificationBell.test.jsx +0 -60
  162. package/tests/NotificationSettings.test.jsx +0 -276
  163. package/tests/NotificationsProvider.test.jsx +0 -240
  164. package/tests/OnboardingProvider.test.jsx +0 -294
  165. package/tests/OnboardingWizard.test.jsx +0 -143
  166. package/tests/PasswordChangeForm.test.jsx +0 -70
  167. package/tests/PasswordInvitePage.test.jsx +0 -142
  168. package/tests/PasswordSetForm.test.jsx +0 -70
  169. package/tests/PopupSurface.test.jsx +0 -142
  170. package/tests/ProfileComponent.refresh.test.jsx +0 -194
  171. package/tests/QrSignupManager.registrationContext.test.jsx +0 -106
  172. package/tests/QrSignupManagerInfoBox.test.jsx +0 -49
  173. package/tests/ScatterChart.test.jsx +0 -270
  174. package/tests/SectionNav.test.jsx +0 -363
  175. package/tests/SignUpPage.test.jsx +0 -208
  176. package/tests/SoftChip.test.jsx +0 -105
  177. package/tests/StatTile.test.jsx +0 -57
  178. package/tests/Thread.test.jsx +0 -151
  179. package/tests/TimeSeriesChart.test.jsx +0 -367
  180. package/tests/UserListComponent.test.jsx +0 -192
  181. package/tests/UserMenu.test.jsx +0 -171
  182. package/tests/apiClientLanguage.test.js +0 -33
  183. package/tests/apiClientPublicPaths.test.js +0 -178
  184. package/tests/authApiLogin.test.js +0 -42
  185. package/tests/authApiRegistration.test.js +0 -31
  186. package/tests/authErrorCodeRendering.test.jsx +0 -77
  187. package/tests/authErrors.test.js +0 -74
  188. package/tests/authTranslations.test.js +0 -74
  189. package/tests/chart-api-census.test.js +0 -366
  190. package/tests/chartAxisTickBand.test.jsx +0 -95
  191. package/tests/chartDefaults.test.js +0 -902
  192. package/tests/chartLabels.test.js +0 -50
  193. package/tests/chartsPalette.test.js +0 -99
  194. package/tests/chatApi.test.js +0 -48
  195. package/tests/chatDriverNames.test.jsx +0 -71
  196. package/tests/chatExports.test.js +0 -3
  197. package/tests/chatList.test.jsx +0 -84
  198. package/tests/chatPicker.test.jsx +0 -82
  199. package/tests/chatSocket.test.jsx +0 -26
  200. package/tests/chatThread.test.jsx +0 -116
  201. package/tests/chatTranslations.test.js +0 -47
  202. package/tests/chatWorkspace.test.jsx +0 -234
  203. package/tests/checkKitIntegration.test.jsx +0 -219
  204. package/tests/createAppTheme.test.js +0 -132
  205. package/tests/createAppThemeDark.test.js +0 -127
  206. package/tests/createAppThemeLightGuard.test.js +0 -40
  207. package/tests/createAppThemePageContrast.test.js +0 -108
  208. package/tests/createAppThemeTypography.test.js +0 -53
  209. package/tests/errorCallSiteGuard.test.js +0 -32
  210. package/tests/exportChart.test.js +0 -313
  211. package/tests/feedApi.test.js +0 -46
  212. package/tests/fixtures/light-theme-baseline.json +0 -2234
  213. package/tests/i18nAggregate.test.js +0 -120
  214. package/tests/i18nGermanVariant.test.js +0 -65
  215. package/tests/loginPageErrorResolution.test.jsx +0 -102
  216. package/tests/messagingApi.test.js +0 -32
  217. package/tests/messagingChunk6.test.jsx +0 -116
  218. package/tests/messagingCompactBubble.test.jsx +0 -64
  219. package/tests/messagingComposer.test.jsx +0 -136
  220. package/tests/messagingComposerChunk5.test.jsx +0 -113
  221. package/tests/messagingContractConformance.test.js +0 -69
  222. package/tests/messagingDirectMessageLauncher.test.jsx +0 -151
  223. package/tests/messagingExports.test.js +0 -21
  224. package/tests/messagingInteractions.test.jsx +0 -136
  225. package/tests/messagingLastMessagePreview.test.jsx +0 -93
  226. package/tests/messagingLinkify.test.jsx +0 -51
  227. package/tests/messagingMessageActions.test.jsx +0 -163
  228. package/tests/messagingMsg6.test.jsx +0 -105
  229. package/tests/messagingMsg6f.test.jsx +0 -155
  230. package/tests/messagingMsg6g.test.jsx +0 -166
  231. package/tests/messagingMsg6h.test.jsx +0 -136
  232. package/tests/messagingMsg6i.test.jsx +0 -129
  233. package/tests/messagingPollRendering.test.jsx +0 -142
  234. package/tests/messagingReactionMerge.test.jsx +0 -77
  235. package/tests/messagingReadTicksTooltip.test.jsx +0 -36
  236. package/tests/messagingThreadReceipts.test.jsx +0 -178
  237. package/tests/messagingThreadingQuoting.test.jsx +0 -87
  238. package/tests/messagingUnreadLifecycle.test.jsx +0 -78
  239. package/tests/notificationsApi.test.js +0 -41
  240. package/tests/notificationsExports.test.js +0 -34
  241. package/tests/onboardingDescriptors.test.js +0 -132
  242. package/tests/packageTreeShaking.test.js +0 -126
  243. package/tests/realtime.test.jsx +0 -219
  244. package/tests/resolveErrorText.test.js +0 -72
  245. package/tests/stepSelection.test.js +0 -53
  246. package/tests/themeCompleteness.test.js +0 -626
  247. package/tests/timeSeriesLegend.test.js +0 -99
  248. package/tests/userScreenTranslations.test.jsx +0 -218
  249. package/tsconfig.build.json +0 -18
  250. package/vite.config.mjs +0 -6
  251. package/work-orders/AUTH-1.md +0 -74
  252. package/work-orders/AUTH-2.md +0 -74
  253. package/work-orders/AUTH-4.md +0 -183
  254. package/work-orders/AUTH-5.md +0 -154
  255. package/work-orders/AUTH-7.md +0 -181
  256. package/work-orders/AUTH-8.md +0 -184
  257. package/work-orders/CHART-1.md +0 -285
  258. package/work-orders/CHART-2.md +0 -222
  259. package/work-orders/CHART-3.md +0 -163
  260. package/work-orders/CHART-4.md +0 -203
  261. package/work-orders/CHART-5.md +0 -226
  262. package/work-orders/CHART-6.md +0 -428
  263. package/work-orders/CHART-7.md +0 -175
  264. package/work-orders/DX-1.md +0 -169
  265. package/work-orders/DX-2.md +0 -188
  266. package/work-orders/DX-3.md +0 -195
  267. package/work-orders/I18N-1.md +0 -254
  268. package/work-orders/I18N-3.md +0 -207
  269. package/work-orders/MSG-3.md +0 -375
  270. package/work-orders/MSG-3b.md +0 -1002
  271. package/work-orders/MSG-3c.md +0 -378
  272. package/work-orders/MSG-3d.md +0 -268
  273. package/work-orders/MSG-3e.md +0 -164
  274. package/work-orders/MSG-3f.md +0 -391
  275. package/work-orders/MSG-6e.md +0 -308
  276. package/work-orders/MSG-6f.md +0 -214
  277. package/work-orders/MSG-6g.md +0 -244
  278. package/work-orders/MSG-6h.md +0 -238
  279. package/work-orders/MSG-6i.md +0 -271
  280. package/work-orders/MSG-6j.md +0 -117
  281. package/work-orders/NOTIF-12.md +0 -214
  282. package/work-orders/NOTIF-13.md +0 -142
  283. package/work-orders/NOTIF-14.md +0 -151
  284. package/work-orders/PRIM-1.md +0 -177
  285. package/work-orders/SHELL-1.md +0 -255
  286. package/work-orders/SHELL-2.md +0 -197
  287. package/work-orders/SHELL-3.md +0 -359
  288. package/work-orders/SHELL-4.md +0 -351
  289. package/work-orders/SHELL-5.md +0 -345
  290. package/work-orders/SHELL-6.md +0 -210
  291. package/work-orders/THEME-1.md +0 -587
  292. package/work-orders/THEME-10.md +0 -303
  293. package/work-orders/THEME-11.md +0 -208
  294. package/work-orders/THEME-2.md +0 -339
  295. package/work-orders/THEME-3.md +0 -210
  296. package/work-orders/THEME-4.md +0 -271
  297. package/work-orders/THEME-5.md +0 -341
  298. package/work-orders/THEME-6.md +0 -247
  299. package/work-orders/THEME-7.md +0 -82
  300. package/work-orders/THEME-8.md +0 -211
  301. package/work-orders/THEME-9.md +0 -194
  302. package/work-orders/UCM-AUTH-10.md +0 -490
  303. package/work-orders/UCM-AUTH-11.md +0 -185
  304. package/work-orders/UCM-AUTH-12.md +0 -98
  305. package/work-orders/UCM-AUTH-13.md +0 -47
  306. package/work-orders/UCM-AUTH-9.md +0 -207
  307. package/work-orders/UCM-CHART-10.md +0 -150
  308. package/work-orders/UCM-CHART-11.md +0 -132
  309. package/work-orders/UCM-CHART-12.md +0 -348
  310. package/work-orders/UCM-CHART-13.md +0 -122
  311. package/work-orders/UCM-CHART-14.md +0 -198
  312. package/work-orders/UCM-CHART-15.md +0 -187
  313. package/work-orders/UCM-CHART-16.md +0 -169
  314. package/work-orders/UCM-CHART-17.md +0 -195
  315. package/work-orders/UCM-CHART-18.md +0 -200
  316. package/work-orders/UCM-CHART-8.md +0 -147
  317. package/work-orders/UCM-CHART-9.md +0 -265
  318. package/work-orders/UCM-CHAT-1.md +0 -190
  319. package/work-orders/UCM-CHAT-2.md +0 -75
  320. package/work-orders/UCM-CI-1.md +0 -65
  321. package/work-orders/UCM-DEP-1.md +0 -63
  322. package/work-orders/UCM-I18N-4.md +0 -226
  323. package/work-orders/UCM-I18N-5.md +0 -211
  324. package/work-orders/UCM-MSG-20.md +0 -192
  325. package/work-orders/UCM-PRIM-2.md +0 -114
  326. package/work-orders/UCM-SHELL-7.md +0 -134
  327. package/work-orders/UCM-SHELL-8.md +0 -125
  328. package/work-orders/UCM-TEST-1.md +0 -304
  329. package/work-orders/UCM-THEME-13.md +0 -69
  330. package/work-orders/UCM-THEME-14.md +0 -312
  331. package/work-orders/UCM-THEME-15.md +0 -356
  332. package/work-orders/UCM-THEME-16.md +0 -80
  333. package/work-orders/UCM-THEME-17.md +0 -111
  334. package/work-orders/UCM-THEME-18.md +0 -184
  335. package/work-orders/assets/AUTH-4-user-list-card.html +0 -407
  336. package/work-orders/assets/PRIM-1-dashboard-primitives.html +0 -624
  337. package/work-orders/assets/SHELL-2-account-navigation.html +0 -1159
  338. package/work-orders/assets/THEME-1-baseline-reference-sheet.html +0 -1352
  339. package/work-orders/assets/UCM-CHAT-1-ai-chat.html +0 -447
  340. package/work-orders/assets/UCM-THEME-13-dark-prototype.html +0 -390
  341. package/work-orders/assets/UCM-THEME-17-type-scale.html +0 -391
@@ -1,183 +0,0 @@
1
- import { Alert, Box, Button, ButtonBase, Dialog, DialogActions, DialogContent, DialogTitle, IconButton, Menu, MenuItem, Paper, Stack, TextField, Typography } from '@mui/material';
2
- import MoreVertIcon from '@mui/icons-material/MoreVert';
3
- import { alpha } from '@mui/material/styles';
4
- import { useEffect, useRef, useState } from 'react';
5
- import { useTranslation } from 'react-i18next';
6
- import { AttachmentList } from './AttachmentList';
7
- import { extractApiErrorMessage, useOptionalMessaging } from './MessagingProvider';
8
- import { ReactionBar } from './ReactionBar';
9
- import { PollCard } from './PollCard';
10
- import { linkifyText } from './linkifyText';
11
-
12
- export const MESSAGE_BUBBLE_ROOT_SX = {
13
- position: 'relative',
14
- p: 1.25,
15
- minWidth: 0,
16
- overflowWrap: 'anywhere',
17
- '& .message-actions': {
18
- opacity: 0,
19
- pointerEvents: 'none',
20
- transition: 'opacity 120ms ease-in-out',
21
- },
22
- '&:hover .message-actions, &:focus-within .message-actions, &[data-actions-visible="true"] .message-actions': {
23
- opacity: 1,
24
- pointerEvents: 'auto',
25
- },
26
- };
27
- export const MESSAGE_BUBBLE_ACTION_SX = {
28
- position: 'absolute',
29
- top: -12,
30
- right: -12,
31
- bgcolor: 'background.paper',
32
- boxShadow: 1,
33
- };
34
-
35
- function senderName(message) {
36
- return message.sender?.display_name || message.sender?.username || message.sender_name || message.sender?.name;
37
- }
38
- function quoteSnippet(message) {
39
- const content = message.body || message.title;
40
- if (!content) return null;
41
- return content.length > 120 ? `${content.slice(0, 117)}...` : content;
42
- }
43
- // A quoted source can be textless for two different reasons: it was deleted
44
- // (server blanks body/title/link_target on soft delete), or it always had no
45
- // text — an attachment-only chat send is a real, reachable case (Composer
46
- // only requires body OR files). Collapsing both into "This message was
47
- // deleted" would mislabel the second case, so they're distinguished here.
48
- function quoteLabel(message, t) {
49
- if (message.deleted_at) return t('MessagingThread.DELETED');
50
- const snippet = quoteSnippet(message);
51
- if (snippet) return snippet;
52
- return message.attachments?.length ? t('MessagingThread.QUOTE_ATTACHMENT') : '';
53
- }
54
-
55
- /** Provider-backed timeline collaborator, including per-message mutations. */
56
- export function MessageBubble({ message, replyTo, conversation, onReply, onJumpToMessage, onAnnouncementLink, canModerateMessages = false, children }) {
57
- const { t, i18n } = useTranslation();
58
- const messaging = useOptionalMessaging();
59
- const { currentUser, editMessage, removeMessage } = messaging || {};
60
- const deleted = Boolean(message.deleted_at);
61
- const attachments = message.attachments || [];
62
- const isOwn = Boolean(currentUser?.id) && message.sender?.id === currentUser.id;
63
- const canAct = !deleted && message.kind !== 'poll' && (isOwn || canModerateMessages);
64
- const canOpenMenu = !deleted;
65
- const reactions = message.reactions || [];
66
- const hasMeta = Boolean(message.created_at || (message.edited_at && !deleted) || children);
67
- const [menuAnchor, setMenuAnchor] = useState(null);
68
- const [actionsVisible, setActionsVisible] = useState(false);
69
- const [reactionPickerVisible, setReactionPickerVisible] = useState(false);
70
- const [editing, setEditing] = useState(false);
71
- const [draft, setDraft] = useState(message.body || '');
72
- const [confirmingDelete, setConfirmingDelete] = useState(false);
73
- const [saving, setSaving] = useState(false);
74
- const [error, setError] = useState(null);
75
- const bubbleRef = useRef(null);
76
- useEffect(() => {
77
- if (deleted) {
78
- setEditing(false); setConfirmingDelete(false); setMenuAnchor(null); setReactionPickerVisible(false);
79
- }
80
- }, [deleted]);
81
- // The touch/tap reveal is a one-way state flip with no dismiss path of its
82
- // own (unlike hover/focus, which un-reveal on mouseleave/blur automatically)
83
- // — without this, any ordinary tap on the bubble (selecting text, opening a
84
- // poll option, following the reply quote) would leave the overflow icon
85
- // permanently visible, contradicting the at-rest "no visible affordance"
86
- // requirement. Dismiss on any pointerdown outside this message's own DOM
87
- // subtree (bubbleRef spans the Paper plus the reaction-picker sibling, so
88
- // interacting with either never counts as "outside"); a pointerdown that
89
- // lands on the Menu/Dialog portals does count as outside, but that's
90
- // harmless — they already close themselves via their own handlers on the
91
- // same interaction.
92
- useEffect(() => {
93
- if (!actionsVisible) return undefined;
94
- const dismissIfOutside = (event) => {
95
- if (bubbleRef.current && !bubbleRef.current.contains(event.target)) {
96
- setActionsVisible(false);
97
- }
98
- };
99
- document.addEventListener('pointerdown', dismissIfOutside, true);
100
- return () => document.removeEventListener('pointerdown', dismissIfOutside, true);
101
- }, [actionsVisible]);
102
- const closeMenu = () => setMenuAnchor(null);
103
- const revealActions = () => setActionsVisible(true);
104
- const openMenu = (event) => { event.preventDefault(); revealActions(); setMenuAnchor(event.currentTarget); };
105
- const startEdit = () => { setDraft(message.body || ''); setEditing(true); closeMenu(); };
106
- const startReply = () => { onReply?.(message); closeMenu(); };
107
- const startReact = () => { setReactionPickerVisible(true); closeMenu(); };
108
- const saveEdit = async () => {
109
- setSaving(true); setError(null);
110
- try { await editMessage?.(message.id, { body: draft.trim() }); setEditing(false); }
111
- catch (saveError) { setError(t('MessagingActions.EDIT_ERROR', { message: extractApiErrorMessage(saveError) })); } finally { setSaving(false); }
112
- };
113
- const confirmDelete = async () => {
114
- setSaving(true); setError(null);
115
- try { await removeMessage?.(message.id); setConfirmingDelete(false); }
116
- catch (deleteError) { setError(t('MessagingActions.DELETE_ERROR', { message: extractApiErrorMessage(deleteError) })); } finally { setSaving(false); }
117
- };
118
- const copyMessage = async () => {
119
- closeMenu();
120
- try { await navigator.clipboard.writeText(message.body || ''); }
121
- catch (copyError) { setError(t('MessagingActions.COPY_ERROR', { message: extractApiErrorMessage(copyError) })); }
122
- };
123
- return (
124
- <Box ref={bubbleRef} component="article" data-message-id={message.id} data-message-side={isOwn ? 'own' : 'incoming'} aria-label={t('MessagingThread.MESSAGE')} sx={{ alignSelf: isOwn ? 'flex-end' : 'flex-start', width: 'fit-content', maxWidth: 'min(75%, 680px)', minWidth: 0 }}>
125
- <Paper
126
- variant="outlined"
127
- data-actions-visible={actionsVisible || undefined}
128
- onClick={revealActions}
129
- onContextMenu={canOpenMenu ? openMenu : undefined}
130
- sx={[
131
- MESSAGE_BUBBLE_ROOT_SX,
132
- {
133
- bgcolor: isOwn ? (theme) => alpha(theme.palette.primary.light, 0.24) : 'background.paper',
134
- borderColor: isOwn ? (theme) => alpha(theme.palette.primary.main, 0.35) : 'divider',
135
- },
136
- ]}
137
- >
138
- {canOpenMenu && <IconButton className="message-actions" size="small" aria-label={t('MessagingActions.MENU')} onClick={openMenu} sx={MESSAGE_BUBBLE_ACTION_SX}><MoreVertIcon fontSize="small" /></IconButton>}
139
- <Stack spacing={0.75}>
140
- {replyTo && <ButtonBase type="button" onClick={() => onJumpToMessage?.(replyTo.id)} sx={{ display: 'block', width: '100%', px: 0.75, py: 0.5, textAlign: 'left', borderLeft: 3, borderColor: 'primary.main', bgcolor: 'action.hover', borderRadius: 0.5 }}>
141
- <Stack spacing={0} alignItems="flex-start">
142
- <Typography variant="caption" color="text.secondary">{t('MessagingThread.REPLY_TO', { sender: senderName(replyTo) || t('MessagingThread.UNKNOWN_SENDER') })}</Typography>
143
- <Typography variant="caption" color="text.secondary">{quoteLabel(replyTo, t)}</Typography>
144
- </Stack>
145
- </ButtonBase>}
146
- {conversation?.kind !== 'direct' && <Typography variant="subtitle2">{senderName(message) || t('MessagingThread.UNKNOWN_SENDER')}</Typography>}
147
- {!deleted && message.kind === 'announcement' && message.title && <Typography variant="subtitle1" fontWeight={700}>{message.title}</Typography>}
148
- {!deleted && message.kind === 'announcement' && message.link_target && onAnnouncementLink && <Button type="button" size="small" onClick={() => onAnnouncementLink(message.link_target)}>{t('MessagingAnnouncement.OPEN_LINK')}</Button>}
149
- {error && <Alert severity="error" role="alert">{error}</Alert>}
150
- {editing ? <Stack spacing={0.75}><TextField label={t('MessagingActions.EDIT')} value={draft} onChange={(event) => setDraft(event.target.value)} multiline minRows={2} autoFocus disabled={saving} /><Stack direction="row" spacing={1}><Button type="button" onClick={saveEdit} disabled={saving}>{t('MessagingActions.SAVE')}</Button><Button type="button" onClick={() => setEditing(false)} disabled={saving}>{t('MessagingActions.CANCEL')}</Button></Stack></Stack> : <Typography sx={{ whiteSpace: 'pre-wrap', overflowWrap: 'anywhere' }}>{deleted ? t('MessagingThread.DELETED') : linkifyText((message.kind === 'announcement' ? message.body : (message.body || message.title)) || '')}</Typography>}
151
- {!deleted && <Stack spacing={0.75}>
152
- {attachments.length > 0 && <AttachmentList attachments={attachments} />}
153
- {message.poll && <PollCard message={message} />}
154
- </Stack>}
155
- {hasMeta && <Stack data-testid="message-meta" direction="row" spacing={0.5} justifyContent="flex-end" alignItems="center" flexWrap="wrap" sx={{ color: 'text.disabled', minWidth: 0, '& .MuiSvgIcon-root': { fontSize: '1rem' } }}>
156
- {message.created_at && <Typography component="span" variant="caption" color="inherit" sx={{ whiteSpace: 'nowrap' }}>{new Date(message.created_at).toLocaleTimeString(i18n?.language, { hour: '2-digit', minute: '2-digit' })}</Typography>}
157
- {message.edited_at && !deleted && <Typography component="span" variant="caption" color="inherit">{t('MessagingThread.EDITED')}</Typography>}
158
- {children}
159
- </Stack>}
160
- </Stack>
161
- </Paper>
162
- {/* A small positive gap, not the negative-margin "peek from the bottom
163
- edge" trick this used to have -- that pull was tuned against a
164
- plain text line and read as an unnatural collision once the
165
- bubble's actual bottom content became variable (an attachment
166
- row's bordered Button, or MSG-6g's poll bars), both visually
167
- boxier than text and closer to the bubble's edge. */}
168
- {!deleted && (reactions.length > 0 || reactionPickerVisible) && <ReactionBar message={message} expanded={reactionPickerVisible} onExpandedChange={setReactionPickerVisible} sx={{ mt: 0.5, ml: 0.75 }} />}
169
- <Menu anchorEl={menuAnchor} open={Boolean(menuAnchor)} onClose={closeMenu}>
170
- <MenuItem onClick={startReply}>{t('MessagingThread.REPLY')}</MenuItem>
171
- <MenuItem onClick={startReact}>{t('MessagingReactions.ADD')}</MenuItem>
172
- {canAct && <MenuItem onClick={startEdit}>{t('MessagingActions.EDIT')}</MenuItem>}
173
- {canAct && <MenuItem onClick={() => { setConfirmingDelete(true); closeMenu(); }}>{t('MessagingActions.DELETE')}</MenuItem>}
174
- <MenuItem onClick={copyMessage}>{t('MessagingActions.COPY')}</MenuItem>
175
- </Menu>
176
- <Dialog open={confirmingDelete} onClose={() => !saving && setConfirmingDelete(false)}>
177
- <DialogTitle>{t('MessagingActions.DELETE_CONFIRM_TITLE')}</DialogTitle>
178
- <DialogContent>{t('MessagingActions.DELETE_CONFIRM_BODY')}</DialogContent>
179
- <DialogActions><Button onClick={() => setConfirmingDelete(false)} disabled={saving}>{t('MessagingActions.CANCEL')}</Button><Button onClick={confirmDelete} disabled={saving} color="error">{t('MessagingActions.DELETE')}</Button></DialogActions>
180
- </Dialog>
181
- </Box>
182
- );
183
- }
Binary file
@@ -1,24 +0,0 @@
1
- import { Alert, Box, CircularProgress, FormControl, FormControlLabel, InputLabel, MenuItem, Select, Stack, Switch, Typography } from '@mui/material';
2
- import { useEffect, useState } from 'react';
3
- import { useTranslation } from 'react-i18next';
4
-
5
- import { extractApiErrorMessage, useMessaging } from './MessagingProvider';
6
-
7
- /** Provider-backed scope configuration surface; hosts choose its placement and capability gate. */
8
- export function MessagingScopeConfig({ conversationId }) {
9
- const { t } = useTranslation();
10
- const { loadConversationConfig, saveConversationConfig } = useMessaging();
11
- const [config, setConfig] = useState(null);
12
- const [error, setError] = useState(null);
13
- const [saving, setSaving] = useState(false);
14
- useEffect(() => { let live = true; loadConversationConfig(conversationId).then((value) => live && setConfig(value)).catch((loadError) => live && setError(t('MessagingConfig.LOAD_ERROR', { message: extractApiErrorMessage(loadError) }))); return () => { live = false; }; }, [conversationId, loadConversationConfig, t]);
15
- const update = async (patch) => { setSaving(true); setError(null); try { setConfig(await saveConversationConfig(conversationId, patch)); } catch (saveError) { setError(t('MessagingConfig.SAVE_ERROR', { message: extractApiErrorMessage(saveError) })); } finally { setSaving(false); } };
16
- if (!config) return error
17
- ? <Alert severity="error" role="alert">{error}</Alert>
18
- : <Box aria-label={t('MessagingConfig.LOADING')} sx={{ display: 'flex', justifyContent: 'center', py: 4 }}><CircularProgress size={24} /></Box>;
19
- return <Stack spacing={1} aria-label={t('MessagingConfig.LABEL')}><Typography variant="subtitle1">{t('MessagingConfig.TITLE')}</Typography>{error && <Alert severity="error" role="alert">{error}</Alert>}
20
- <FormControl fullWidth size="small" disabled={saving}><InputLabel>{t('MessagingConfig.DM_POLICY')}</InputLabel><Select label={t('MessagingConfig.DM_POLICY')} value={config.dm_policy || 'all'} onChange={(event) => update({ dm_policy: event.target.value })}><MenuItem value="all">{t('MessagingConfig.DM_ALL')}</MenuItem><MenuItem value="within_shared_groups">{t('MessagingConfig.DM_SHARED')}</MenuItem><MenuItem value="team_only">{t('MessagingConfig.DM_TEAM')}</MenuItem></Select></FormControl>
21
- <FormControlLabel control={<Switch checked={Boolean(config.group_chat_enabled)} disabled={saving} onChange={(event) => update({ group_chat_enabled: event.target.checked })} />} label={t('MessagingConfig.GROUP_ENABLED')} />
22
- <FormControlLabel control={<Switch checked={Boolean(config.everyone_can_post)} disabled={saving || !config.group_chat_enabled} onChange={(event) => update({ everyone_can_post: event.target.checked })} />} label={t('MessagingConfig.EVERYONE_POSTS')} />
23
- </Stack>;
24
- }
@@ -1,163 +0,0 @@
1
- import LockOutlinedIcon from '@mui/icons-material/LockOutlined';
2
- import { Alert, Button, Checkbox, Chip, FormControlLabel, LinearProgress, Paper, Radio, RadioGroup, Stack, Typography } from '@mui/material';
3
- import { useEffect, useRef, useState } from 'react';
4
- import { useTranslation } from 'react-i18next';
5
-
6
- import { extractApiErrorMessage, useMessaging } from './MessagingProvider';
7
-
8
- export const POLL_CARD_ROOT_SX = { p: 1.5, minWidth: 260 };
9
- export const POLL_CARD_FORM_CONTROL_SX = { width: '100%', m: 0, alignItems: 'flex-start' };
10
- export const POLL_CARD_CHECKBOX_SX = { pt: 0.25 };
11
-
12
- /**
13
- * Independently mountable live poll view. Server authorization remains authoritative.
14
- *
15
- * Tap-to-vote (MSG-6g): each option is its own control, cast immediately on tap — no
16
- * separate submit step. Single-choice uses a real `RadioGroup` (native "tap a different
17
- * option moves the vote, tap the same one is a no-op" semantics, plus the group's own
18
- * arrow-key navigation and screen-reader group announcement — a bare ungrouped `Radio`
19
- * per option, tried first, loses both); multi-select uses `Checkbox` (each tap
20
- * independently toggles that option). `FormControlLabel` wraps each control, matching
21
- * this repo's existing radio convention (`AuthFactorRequirementCard.jsx`) — clicking
22
- * anywhere in the label natively activates the control, no manual click-handling needed.
23
- * Every tap is optimistic (see `castPollVote` in `MessagingProvider`), dims while
24
- * in flight (matching `ReactionBar`'s `pending` convention) so an optimistic vote is
25
- * never visually indistinguishable from a confirmed one, and visibly reverts on a
26
- * rejected vote.
27
- */
28
- export function PollCard({ message, canClose: canCloseProp }) {
29
- const { t } = useTranslation();
30
- const { castPollVote, closeConversationPoll, currentUser } = useMessaging();
31
- const poll = message?.poll;
32
- const [selected, setSelected] = useState([]);
33
- const [error, setError] = useState(null);
34
- const [busy, setBusy] = useState(false);
35
- const [pending, setPending] = useState(() => new Set());
36
- // Guards a rejected vote's revert against a newer tap that has since
37
- // superseded it -- see the matching token in MessagingProvider.castPollVote.
38
- const voteTokenRef = useRef(null);
39
- // voted_option_ids is a view-level enrichment dcm adds ONLY to the
40
- // create/vote/close poll REST responses (serialize_poll itself, every
41
- // message-list/thread load, and every poll_updated realtime frame never
42
- // carry it) — so it's only ever present right after this viewer's own
43
- // vote/create/close action. When it's absent (a freshly loaded or
44
- // frame-updated poll), there's no way to know this viewer's vote from the
45
- // payload alone; default to no selection rather than guessing or carrying
46
- // over stale local state.
47
- useEffect(() => setSelected(poll?.voted_option_ids ? [...poll.voted_option_ids] : []), [poll]);
48
- if (!poll) return null;
49
- const closed = Boolean(poll.closed_at);
50
- const creatorId = poll.created_by_id ?? poll.created_by?.id ?? poll.created_by;
51
- const canClose = canCloseProp ?? poll.can_close ?? message?.can_close ?? message?.permissions?.can_close ?? (creatorId != null && creatorId === currentUser?.id);
52
- // Percentage denominator (MSG-6i): the number of distinct people who
53
- // answered this poll, not sum(vote_count) across options. For a
54
- // multi-select poll one person can vote for several options, so summing
55
- // vote_count can exceed the actual respondent count -- dividing by that
56
- // inflated sum understated everyone's percentage and the bars didn't sum
57
- // to a sensible 100%. dcm's serialize_poll always includes each option's
58
- // `voters` (a list of user ids, ungated -- unlike messaging read
59
- // receipts); the union across all options is exactly "everyone who
60
- // answered", computed client-side, no backend change. This deliberately
61
- // reverses MSG-6g's own explicit non-goal ("denominator = votes cast, not
62
- // participant count") -- an operator-confirmed correction, not a revert.
63
- const respondentCount = new Set((poll.options || []).flatMap((option) => option.voters || [])).size;
64
-
65
- const tap = async (id) => {
66
- if (closed) return;
67
- const previousSelected = selected;
68
- const nextSelected = poll.allow_multiple
69
- ? (selected.includes(id) ? selected.filter((value) => value !== id) : [...selected, id])
70
- : [id];
71
- // Belt-and-suspenders: native radios already don't fire a change event
72
- // when re-clicking the checked one, but this guards any caller shape.
73
- if (nextSelected.length === previousSelected.length && nextSelected.every((value) => previousSelected.includes(value))) return;
74
- const token = {};
75
- voteTokenRef.current = token;
76
- setSelected(nextSelected);
77
- setError(null);
78
- // Rapid re-taps are allowed and race deliberately (last write wins via
79
- // the token above) -- `pending` is a visual signal only, never gates
80
- // further taps, so it must not disable the control.
81
- setPending((current) => new Set(current).add(id));
82
- try {
83
- await castPollVote(message.id, poll, nextSelected);
84
- } catch (voteError) {
85
- // A later tap already moved the selection on; a stale failure must not
86
- // revert past it.
87
- if (voteTokenRef.current === token) {
88
- setSelected(previousSelected);
89
- setError(t('MessagingPoll.VOTE_ERROR', { message: extractApiErrorMessage(voteError) }));
90
- }
91
- } finally {
92
- setPending((current) => { const next = new Set(current); next.delete(id); return next; });
93
- }
94
- };
95
- const close = async () => {
96
- setBusy(true); setError(null);
97
- try { await closeConversationPoll(message.id, poll); } catch (closeError) { setError(t('MessagingPoll.CLOSE_ERROR', { message: extractApiErrorMessage(closeError) })); } finally { setBusy(false); }
98
- };
99
-
100
- const optionLabel = (option) => {
101
- // dcm's poll projection gives voter user ids only, never names — there
102
- // is no user-directory endpoint (same structural limit already
103
- // established for the DM candidate list).
104
- const voteCount = option.vote_count ?? option.voters?.length ?? 0;
105
- const percent = respondentCount > 0 ? Math.round((voteCount / respondentCount) * 100) : 0;
106
- const votedByMe = selected.includes(option.id);
107
- const resultText = t('MessagingPoll.OPTION_RESULT', { count: voteCount, percent });
108
- // The bar is decorative; count/percent live in the accessible name (via
109
- // aria-label on the control itself) as well as in adjacent visible text —
110
- // width alone must never be the only signal (WO risk note).
111
- const accessibleLabel = `${option.text || option.label}, ${resultText}${votedByMe ? `, ${t('MessagingPoll.YOU_VOTED')}` : ''}`;
112
- // MSG-6i scope B: "airier, not wider" (operator, after seeing a
113
- // screenshot of the checkbox/text/percent squeezed onto one tight line
114
- // with a thin bar close to the text) -- more internal spacing/a taller
115
- // bar, not a wider bubble (MessageBubble.jsx's maxWidth is untouched).
116
- const richLabel = <Stack sx={{ flex: 1, minWidth: 0, opacity: pending.has(option.id) ? 0.6 : 1 }} spacing={0.75}>
117
- {/* MSG-6j: `justifyContent: 'space-between'` only distributes LEFTOVER width -- but
118
- this row sits inside a `MessageBubble` sized `width: fit-content` around this exact
119
- content, so there is by construction no leftover width, and space-between alone
120
- reserved a zero-width gap (the reported bug: label text ran directly into the
121
- vote-count/percent text). `spacing` adds a real minimum gap via margin, independent
122
- of justify-content, so the two never touch regardless of available width. */}
123
- <Stack direction="row" justifyContent="space-between" spacing={1}>
124
- <Typography variant="body2" noWrap>{option.text || option.label}</Typography>
125
- <Typography variant="caption" color="text.secondary">{resultText}</Typography>
126
- </Stack>
127
- <LinearProgress variant="determinate" value={percent} sx={{ borderRadius: 1, height: 8 }} color={votedByMe ? 'primary' : 'inherit'} />
128
- </Stack>;
129
- return { accessibleLabel, richLabel };
130
- };
131
- // MSG-6j: a short question/option set could otherwise pull the whole `MessageBubble`
132
- // (`width: fit-content`) in tighter than comfortable to read. 260px stays under the
133
- // bubble's own `maxWidth: min(75%, 680px)` ceiling even at a 375px viewport (75% = 281px)
134
- // -- verified at that width, not just desktop.
135
- return <Paper variant="outlined" sx={POLL_CARD_ROOT_SX} aria-label={t('MessagingPoll.LABEL')}><Stack spacing={1.5}>
136
- <Typography variant="subtitle2">{poll.question}</Typography>
137
- {poll.allow_multiple
138
- ? (poll.options || []).map((option) => {
139
- const { accessibleLabel, richLabel } = optionLabel(option);
140
- return <FormControlLabel key={option.id} disabled={closed} sx={POLL_CARD_FORM_CONTROL_SX} label={richLabel}
141
- control={<Checkbox checked={selected.includes(option.id)} inputProps={{ 'aria-label': accessibleLabel }} onChange={() => tap(option.id)} sx={POLL_CARD_CHECKBOX_SX} />} />;
142
- })
143
- // No RadioGroup-level onChange: it would only ever hand back
144
- // `event.target.value`, a DOM string -- coercing a non-string option id
145
- // (dcm's are UUID strings today, but the id type isn't a guaranteed
146
- // contract). `value` alone still drives each Radio's `checked` via the
147
- // group's own comparison; each Radio's own `onChange` below fires
148
- // `tap` with the option's real, correctly-typed id, matching the
149
- // Checkbox branch above exactly.
150
- : <RadioGroup value={selected[0] ?? ''} name={`poll-${poll.id}-options`}>
151
- {(poll.options || []).map((option) => {
152
- const { accessibleLabel, richLabel } = optionLabel(option);
153
- return <FormControlLabel key={option.id} value={option.id} disabled={closed} sx={POLL_CARD_FORM_CONTROL_SX} label={richLabel}
154
- control={<Radio inputProps={{ 'aria-label': accessibleLabel }} onChange={() => tap(option.id)} sx={{ pt: 0.25 }} />} />;
155
- })}
156
- </RadioGroup>}
157
- {error && <Alert severity="error" role="alert">{error}</Alert>}
158
- <Stack direction="row" spacing={1} alignItems="center">
159
- {canClose && !closed && <Button size="small" color="warning" onClick={close} disabled={busy}>{t('MessagingPoll.CLOSE')}</Button>}
160
- {closed && <Chip size="small" icon={<LockOutlinedIcon fontSize="small" />} label={t('MessagingPoll.CLOSED')} />}
161
- </Stack>
162
- </Stack></Paper>;
163
- }
@@ -1,43 +0,0 @@
1
- import { Alert, Chip, Stack } from '@mui/material';
2
- import { useState } from 'react';
3
- import { useTranslation } from 'react-i18next';
4
-
5
- import { extractApiErrorMessage, useMessaging } from './MessagingProvider';
6
-
7
- export const QUICK_EMOJIS = ['👍', '❤️', '😂', '🎉', '👀'];
8
-
9
- /** Compact aggregate reactions; MessageBubble opens the quick picker from its action menu. */
10
- export function ReactionBar({ message, expanded = false, onExpandedChange, sx }) {
11
- const { t } = useTranslation();
12
- const { toggleReaction } = useMessaging();
13
- const [error, setError] = useState(null);
14
- // Tracks in-flight emoji toggles for this message so a rapid double-click
15
- // can't fire two concurrent requests for the same emoji — toggleReaction's
16
- // rollback-on-failure reverts to a pre-optimistic snapshot, which would
17
- // silently discard a second, already-succeeded change if both were in
18
- // flight. Disabling the chip while its own request is pending removes the
19
- // race instead of trying to make concurrent toggles safe.
20
- const [pending, setPending] = useState(() => new Set());
21
- const reactions = message?.reactions || [];
22
- const react = async (emoji, active = false) => {
23
- if (pending.has(emoji)) return;
24
- setError(null);
25
- setPending((current) => new Set(current).add(emoji));
26
- try { await toggleReaction(message.id, emoji, active); }
27
- catch (reactionError) { setError(t('MessagingReactions.ERROR', { message: extractApiErrorMessage(reactionError) })); }
28
- finally { setPending((current) => { const next = new Set(current); next.delete(emoji); return next; }); }
29
- };
30
- return <Stack spacing={0.5} aria-label={t('MessagingReactions.LABEL')} sx={sx}>
31
- {reactions.length > 0 && <Stack direction="row" spacing={0.5} flexWrap="wrap">
32
- {reactions.map((reaction) => <Chip key={reaction.emoji} size="small" disabled={pending.has(reaction.emoji)} color={reaction.reacted ? 'primary' : 'default'} label={`${reaction.emoji} ${reaction.count || 0}`} onClick={() => react(reaction.emoji, Boolean(reaction.reacted))} aria-label={t('MessagingReactions.TOGGLE', { emoji: reaction.emoji, count: reaction.count || 0 })} />)}
33
- </Stack>}
34
- {expanded && <Stack direction="row" spacing={0.25} flexWrap="wrap">{QUICK_EMOJIS.map((emoji) => {
35
- // A quick-emoji already reflected in the aggregate row must toggle it
36
- // off, not re-add it — otherwise clicking an already-reacted emoji here
37
- // optimistically double-increments the count before the API call.
38
- const existing = reactions.find((reaction) => reaction.emoji === emoji);
39
- return <Chip key={emoji} size="small" disabled={pending.has(emoji)} color={existing?.reacted ? 'primary' : 'default'} label={emoji} onClick={() => { react(emoji, Boolean(existing?.reacted)); onExpandedChange?.(false); }} />;
40
- })}</Stack>}
41
- {error && <Alert severity="error" role="alert">{error}</Alert>}
42
- </Stack>;
43
- }
@@ -1,82 +0,0 @@
1
- import DoneAllOutlinedIcon from '@mui/icons-material/DoneAllOutlined';
2
- import DoneOutlinedIcon from '@mui/icons-material/DoneOutlined';
3
- import { ButtonBase, List, ListItem, Popover, Tooltip, Typography } from '@mui/material';
4
- import { useEffect, useState } from 'react';
5
- import { useTranslation } from 'react-i18next';
6
-
7
- import { useMessaging } from './MessagingProvider';
8
-
9
- // Explicit tokens, not `inherit`/`primary` -- `inherit` inside the message
10
- // meta Stack resolved to `text.disabled`, which read too close to the "read"
11
- // state at the rendered 1rem icon size. The icon shape (Done vs DoneAll)
12
- // already differs, so the colour distinction is a second, independent signal
13
- // rather than the only one.
14
- const DM_SENT_COLOR = 'grey.500';
15
- const DM_READ_COLOR = 'primary.main';
16
-
17
- /**
18
- * Shape-driven, no client-side role/permission branching: dcm only ever
19
- * includes `read_count`/`recipient_count` inside the same `read_receipt_detail`-
20
- * gated block as `recipient_detail`, and never for a `direct` conversation
21
- * (the DM privacy carve-out). So "counts present" already means "team member,
22
- * non-direct" -- checking anything else here would re-implement a decision
23
- * dcm's response shape already makes.
24
- *
25
- * - counts present -> a read ratio ("18/40"), numeric, no icon ladder.
26
- * - no counts, `direct` -> a two-state tick (sent / read).
27
- * - no counts, non-direct -> no indicator at all (an ordinary participant in
28
- * a group; a permanently-grey tick here would be the "looks always
29
- * delivered" defect this component exists to remove).
30
- */
31
- export function ReadTicks({ messageId, conversation }) {
32
- const { t } = useTranslation();
33
- const { cache, getMessageReadStatus } = useMessaging();
34
- const [status, setStatus] = useState(null);
35
- const [anchorEl, setAnchorEl] = useState(null);
36
- useEffect(() => {
37
- let mounted = true;
38
- getMessageReadStatus(messageId).then((next) => { if (mounted) setStatus(next); }).catch(() => { if (mounted) setStatus(null); });
39
- return () => { mounted = false; };
40
- }, [getMessageReadStatus, messageId]);
41
- if (!status) return null;
42
-
43
- const recipientDetail = status.recipient_detail?.map((recipient) => ({ ...recipient, last_read_at: cache.receipts[`${conversation?.id}:${recipient.user_id}`]?.last_read_at ?? recipient.last_read_at })) || status.recipient_detail;
44
- const directReceipt = conversation?.kind === 'direct' && conversation?.other_user_id != null
45
- ? cache.receipts[`${conversation.id}:${conversation.other_user_id}`]
46
- : null;
47
- const allRead = status.all_read || Boolean(directReceipt?.last_read_at) || Boolean(recipientDetail?.length && recipientDetail.every((recipient) => recipient.last_read_at));
48
- const hasCounts = typeof status.read_count === 'number' && typeof status.recipient_count === 'number';
49
-
50
- if (!hasCounts && conversation?.kind !== 'direct') return null;
51
- if (hasCounts && status.recipient_count === 0) return null;
52
-
53
- // The server never returns DM detail; enforce the same carve-out defensively.
54
- const detail = conversation?.kind === 'direct' ? null : recipientDetail;
55
- const recipients = detail?.map((recipient) => recipient.display_name || recipient.username || recipient.user_id).filter(Boolean) || [];
56
-
57
- if (hasCounts) {
58
- // Read count/recipient_count exactly as dcm computed them -- do NOT
59
- // recompute from recipientDetail here. dcm thresholds each participant's
60
- // last_read_at against THIS message's created_at
61
- // (`last_read_at__gte=message.created_at`, services.py); recipientDetail
62
- // only carries each participant's raw, unthresholded last_read_at, and
63
- // ReadTicks has no access to the message's own created_at to reproduce
64
- // that comparison. Recomputing from recipientDetail (tried during
65
- // implementation, caught in review) silently counted anyone who had ever
66
- // read the conversation at any point as "read this message" -- in a real
67
- // group with history, that reads as close to N/N regardless of who
68
- // actually saw this specific message, the opposite of the WO's intent.
69
- // The trade-off: unlike the DM tick and the per-person popover below
70
- // (both viewer/timestamp-relative facts, not message-relative, so they
71
- // safely reuse cache.receipts), this numeric ratio only updates on the
72
- // next read-status fetch, not live from a read_state frame.
73
- const label = t('MessagingReadTicks.READ_RATIO', { read: status.read_count, total: status.recipient_count });
74
- const ratio = <Typography component="span" variant="caption" color="inherit">{status.read_count}/{status.recipient_count}</Typography>;
75
- if (!recipients.length) return <Tooltip title={label} describeChild><span role="img" aria-label={label}>{ratio}</span></Tooltip>;
76
- return <><Tooltip title={label} describeChild><ButtonBase aria-label={label} aria-haspopup="dialog" aria-expanded={Boolean(anchorEl)} onClick={(event) => setAnchorEl(event.currentTarget)} sx={{ display: 'inline-flex' }}>{ratio}</ButtonBase></Tooltip><Popover open={Boolean(anchorEl)} anchorEl={anchorEl} onClose={() => setAnchorEl(null)}><List aria-label={t('MessagingReadTicks.RECIPIENTS')}>{recipients.map((recipient) => <ListItem key={recipient}>{recipient}</ListItem>)}</List></Popover></>;
77
- }
78
-
79
- const label = allRead ? t('MessagingReadTicks.ALL_READ') : t('MessagingReadTicks.SENT');
80
- const StatusIcon = allRead ? DoneAllOutlinedIcon : DoneOutlinedIcon;
81
- return <StatusIcon role="img" aria-label={label} sx={{ color: allRead ? DM_READ_COLOR : DM_SENT_COLOR }} />;
82
- }