@rapidmx/web-client 0.9.0 → 0.11.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 (443) hide show
  1. package/README.md +373 -88
  2. package/apps/admin/_layout.tsx +8 -2
  3. package/apps/admin/index.tsx +7 -1
  4. package/apps/admin/ingest-queue/index.tsx +2 -1
  5. package/apps/admin/mailboxes/[uid].tsx +23 -10
  6. package/apps/admin/quarantine/index.tsx +2 -1
  7. package/apps/admin/signing-certificates/index.tsx +343 -0
  8. package/apps/escrow/_layout.tsx +8 -2
  9. package/apps/shared/appearance/AppearanceForm.tsx +392 -0
  10. package/apps/shared/appearance/AppearanceHead.tsx +49 -0
  11. package/apps/shared/appearance/AppearanceProvider.tsx +470 -0
  12. package/apps/shared/appearance/ColorField.tsx +107 -0
  13. package/apps/shared/appearance/appearanceCache.ts +106 -0
  14. package/apps/shared/appearance/appearanceContext.ts +77 -0
  15. package/apps/shared/appearance/bootScript.ts +35 -0
  16. package/apps/shared/appearance/color.ts +169 -0
  17. package/apps/shared/appearance/photo.ts +88 -0
  18. package/apps/shared/appearance/resolvedTheme.ts +67 -0
  19. package/apps/shared/appearance/theme.ts +355 -0
  20. package/apps/shared/auth/accountUrl.ts +9 -0
  21. package/apps/shared/auth/adminAccess.ts +99 -0
  22. package/apps/shared/components/admin/layout/AdminShell.tsx +22 -10
  23. package/apps/shared/components/admin/mailboxes/ShareAccessCard.tsx +107 -60
  24. package/apps/shared/components/admin/settings/BrandingForm.tsx +24 -0
  25. package/apps/shared/components/admin/settings/DomainDnsSetup.tsx +2 -1
  26. package/apps/shared/components/admin/settings/PluginsManager.tsx +228 -25
  27. package/apps/shared/components/admin/setup/SetupWizard.tsx +2 -1
  28. package/apps/shared/components/calendar/CalendarListSidebar.tsx +4 -5
  29. package/apps/shared/components/calendar/layout/CalendarShell.tsx +8 -2
  30. package/apps/shared/components/contacts/ContactForm.tsx +11 -5
  31. package/apps/shared/components/contacts/ContactsSidebar.tsx +5 -3
  32. package/apps/shared/components/contacts/ContactsToolbar.tsx +98 -115
  33. package/apps/shared/components/contacts/layout/ContactsShell.tsx +25 -8
  34. package/apps/shared/components/escrow/layout/EscrowShell.tsx +13 -6
  35. package/apps/shared/components/layout/AppShell.tsx +477 -288
  36. package/apps/shared/components/layout/BrandingChrome.tsx +200 -13
  37. package/apps/shared/components/layout/KeyEnrollmentGate.tsx +398 -389
  38. package/apps/shared/components/layout/MailboxProvisioning.tsx +168 -164
  39. package/apps/shared/components/layout/RailIcon.tsx +100 -0
  40. package/apps/shared/components/layout/ResponsiveToolbar.tsx +315 -0
  41. package/apps/shared/components/layout/ThemeSwitch.tsx +84 -0
  42. package/apps/shared/components/layout/UserMenu.tsx +372 -185
  43. package/apps/shared/components/mail/ConversationList.tsx +271 -262
  44. package/apps/shared/components/mail/ConversationThreadPane.tsx +147 -94
  45. package/apps/shared/components/mail/LazyReadingPane.tsx +113 -0
  46. package/apps/shared/components/mail/MailSelectionBar.tsx +227 -222
  47. package/apps/shared/components/mail/MessageDetailPane.tsx +1537 -1387
  48. package/apps/shared/components/mail/OutboxBadge.tsx +44 -0
  49. package/apps/shared/components/mail/OutboxRowStatus.tsx +31 -0
  50. package/apps/shared/components/mail/compose/ComposeContext.tsx +312 -160
  51. package/apps/shared/components/mail/compose/ComposeToolbar.tsx +422 -418
  52. package/apps/shared/components/mail/compose/ComposeWindow.tsx +1644 -1736
  53. package/apps/shared/components/mail/compose/ComposeWindowPlaceholder.tsx +111 -0
  54. package/apps/shared/components/mail/compose/RichTextEditor.tsx +147 -118
  55. package/apps/shared/components/mail/compose/composePerf.ts +46 -0
  56. package/apps/shared/components/mail/compose/encryptionRequirement.ts +86 -0
  57. package/apps/shared/components/mail/compose/quotedBody.ts +161 -100
  58. package/apps/shared/components/mail/layout/MailShell.tsx +490 -472
  59. package/apps/shared/components/mail/reading/EncryptedBody.tsx +65 -0
  60. package/apps/shared/components/mail/reading/EncryptedPreview.tsx +35 -0
  61. package/apps/shared/components/mail/reading/MessageBody.tsx +240 -0
  62. package/apps/shared/components/mail/reading/MessageCard.tsx +174 -0
  63. package/apps/shared/components/mail/reading/bodyContent.ts +100 -0
  64. package/apps/shared/components/mail/reading/bodyHtml.ts +298 -0
  65. package/apps/shared/components/mail/reading/color.ts +245 -0
  66. package/apps/shared/components/mail/reading/frameControl.ts +142 -0
  67. package/apps/shared/components/mail/reading/frameDocument.ts +123 -0
  68. package/apps/shared/components/mail/reading/safeDocument.ts +24 -0
  69. package/apps/shared/components/mail/reading/themeAdaptation.ts +221 -0
  70. package/apps/shared/components/mail/reading/themeSurface.ts +90 -0
  71. package/apps/shared/components/mail/reading/viewOriginal.ts +38 -0
  72. package/apps/shared/components/mail/unreadStyle.tsx +75 -0
  73. package/apps/shared/components/settings/SigningCertificateCard.tsx +344 -0
  74. package/apps/shared/components/settings/layout/SettingsShell.tsx +253 -240
  75. package/apps/shared/components/sharing/PrincipalPicker.tsx +145 -0
  76. package/apps/shared/components/tasks/TasksSidebar.tsx +5 -3
  77. package/apps/shared/components/tasks/layout/TasksShell.tsx +24 -8
  78. package/apps/shared/keyboard/GlobalShortcuts.tsx +51 -0
  79. package/apps/shared/keyboard/ShortcutProvider.tsx +62 -0
  80. package/apps/shared/keyboard/ShortcutsDialog.tsx +84 -0
  81. package/apps/shared/keyboard/dispatch.ts +124 -0
  82. package/apps/shared/keyboard/format.ts +89 -0
  83. package/apps/shared/keyboard/keymap.ts +114 -0
  84. package/apps/shared/keyboard/match.ts +44 -0
  85. package/apps/shared/keyboard/parse.ts +136 -0
  86. package/apps/shared/keyboard/platform.ts +34 -0
  87. package/apps/shared/keyboard/registry.ts +65 -0
  88. package/apps/shared/keyboard/targets.ts +79 -0
  89. package/apps/shared/keyboard/useShortcut.ts +50 -0
  90. package/apps/shared/keyboard/useShortcutProps.ts +17 -0
  91. package/apps/shared/mail/folderCounts.ts +308 -0
  92. package/apps/shared/mail/folderTree.ts +143 -0
  93. package/apps/shared/mail/listSnapshots.ts +87 -0
  94. package/apps/shared/mail/messageReadState.ts +85 -0
  95. package/apps/shared/mail/newMailNotifications.ts +183 -0
  96. package/apps/shared/mail/outbox/UnlockBridge.tsx +23 -0
  97. package/apps/shared/mail/outbox/composeBridge.ts +69 -0
  98. package/apps/shared/mail/outbox/outboxState.ts +88 -0
  99. package/apps/shared/mail/outbox/pendingSends.ts +146 -0
  100. package/apps/shared/mail/outbox/sendDecision.ts +157 -0
  101. package/apps/shared/mail/outbox/sendJob.ts +427 -0
  102. package/apps/shared/mail/outbox/sendOutcomes.ts +146 -0
  103. package/apps/shared/mail/outbox/sendState.ts +35 -0
  104. package/apps/shared/mail/outbox/useOutboxStatus.ts +61 -0
  105. package/apps/shared/mail/useMailConnection.ts +203 -0
  106. package/apps/shared/mail/useMailLiveUpdates.ts +277 -224
  107. package/apps/shared/mail/useMarkMessageRead.ts +47 -0
  108. package/apps/shared/mail/useNewMailNotifications.ts +178 -0
  109. package/apps/shared/mail/useUnreadTitle.ts +42 -0
  110. package/apps/shared/navigation/AppRouter.tsx +300 -0
  111. package/apps/shared/navigation/appHrefs.ts +23 -0
  112. package/apps/shared/navigation/frameContext.tsx +35 -0
  113. package/apps/shared/navigation/idle.ts +45 -0
  114. package/apps/shared/navigation/routerContext.tsx +83 -0
  115. package/apps/shared/navigation/routes.ts +72 -0
  116. package/apps/shared/notifications/NotificationCenter.tsx +215 -0
  117. package/apps/shared/notifications/NotificationHistoryDialog.tsx +90 -0
  118. package/apps/shared/notifications/apiErrors.ts +98 -0
  119. package/apps/shared/notifications/headerOffset.ts +35 -0
  120. package/apps/shared/notifications/pushStatus.ts +56 -0
  121. package/apps/shared/notifications/store.ts +549 -0
  122. package/apps/shared/notifications/systemErrors.ts +63 -0
  123. package/apps/shared/notifications/useNotifications.ts +41 -0
  124. package/apps/shared/search/LocalIndexLifecycle.tsx +114 -98
  125. package/apps/shared/signing/enrollmentStorage.ts +33 -0
  126. package/apps/shared/signing/enrollmentTracker.ts +385 -0
  127. package/apps/shared/signing/enrollmentView.ts +251 -0
  128. package/apps/shared/signing/signingInfo.ts +58 -0
  129. package/apps/shared/signing/useNow.ts +19 -0
  130. package/apps/shared/signing/useSigningEnrollmentWatcher.ts +90 -0
  131. package/apps/shared/styles/app.css +108 -10
  132. package/apps/www/_layout.tsx +8 -2
  133. package/apps/www/_routedPage.tsx +24 -0
  134. package/apps/www/_routes.ts +36 -0
  135. package/apps/www/calendar/index.tsx +64 -33
  136. package/apps/www/contacts/[uid].tsx +109 -107
  137. package/apps/www/contacts/index.tsx +62 -42
  138. package/apps/www/index.tsx +2291 -1917
  139. package/apps/www/messages/[uid].tsx +108 -101
  140. package/apps/www/settings/appearance/index.tsx +21 -0
  141. package/apps/www/settings/auto-reply/index.tsx +7 -8
  142. package/apps/www/settings/encryption/index.tsx +1287 -1249
  143. package/apps/www/settings/filters/[uid].tsx +7 -2
  144. package/apps/www/settings/filters/index.tsx +102 -99
  145. package/apps/www/settings/filters/new/index.tsx +140 -133
  146. package/apps/www/settings/labels/index.tsx +204 -201
  147. package/apps/www/settings/privacy/index.tsx +7 -9
  148. package/apps/www/settings/read-receipts/index.tsx +7 -8
  149. package/apps/www/settings/sharing/index.tsx +256 -274
  150. package/apps/www/settings/signatures/[uid].tsx +172 -167
  151. package/apps/www/settings/signatures/index.tsx +88 -85
  152. package/apps/www/settings/signatures/new/index.tsx +135 -129
  153. package/apps/www/tasks/index.tsx +29 -18
  154. package/dist/apps/admin/_layout.d.ts +5 -1
  155. package/dist/apps/admin/_layout.js +3 -2
  156. package/dist/apps/admin/index.js +3 -2
  157. package/dist/apps/admin/ingest-queue/index.js +2 -1
  158. package/dist/apps/admin/mailboxes/[uid].js +9 -6
  159. package/dist/apps/admin/quarantine/index.js +2 -1
  160. package/dist/apps/admin/signing-certificates/index.d.ts +3 -0
  161. package/dist/apps/admin/signing-certificates/index.js +161 -0
  162. package/dist/apps/escrow/_layout.d.ts +5 -1
  163. package/dist/apps/escrow/_layout.js +3 -2
  164. package/dist/apps/shared/appearance/AppearanceForm.d.ts +7 -0
  165. package/dist/apps/shared/appearance/AppearanceForm.js +131 -0
  166. package/dist/apps/shared/appearance/AppearanceHead.d.ts +15 -0
  167. package/dist/apps/shared/appearance/AppearanceHead.js +31 -0
  168. package/dist/apps/shared/appearance/AppearanceProvider.d.ts +32 -0
  169. package/dist/apps/shared/appearance/AppearanceProvider.js +390 -0
  170. package/dist/apps/shared/appearance/ColorField.d.ts +22 -0
  171. package/dist/apps/shared/appearance/ColorField.js +40 -0
  172. package/dist/apps/shared/appearance/appearanceCache.d.ts +45 -0
  173. package/dist/apps/shared/appearance/appearanceCache.js +80 -0
  174. package/dist/apps/shared/appearance/appearanceContext.d.ts +45 -0
  175. package/dist/apps/shared/appearance/appearanceContext.js +29 -0
  176. package/dist/apps/shared/appearance/bootScript.d.ts +16 -0
  177. package/dist/apps/shared/appearance/bootScript.js +33 -0
  178. package/dist/apps/shared/appearance/color.d.ts +65 -0
  179. package/dist/apps/shared/appearance/color.js +132 -0
  180. package/dist/apps/shared/appearance/photo.d.ts +17 -0
  181. package/dist/apps/shared/appearance/photo.js +79 -0
  182. package/dist/apps/shared/appearance/resolvedTheme.d.ts +21 -0
  183. package/dist/apps/shared/appearance/resolvedTheme.js +55 -0
  184. package/dist/apps/shared/appearance/theme.d.ts +111 -0
  185. package/dist/apps/shared/appearance/theme.js +251 -0
  186. package/dist/apps/shared/auth/accountUrl.d.ts +2 -0
  187. package/dist/apps/shared/auth/accountUrl.js +8 -0
  188. package/dist/apps/shared/auth/adminAccess.d.ts +30 -0
  189. package/dist/apps/shared/auth/adminAccess.js +89 -0
  190. package/dist/apps/shared/components/admin/layout/AdminShell.d.ts +1 -1
  191. package/dist/apps/shared/components/admin/layout/AdminShell.js +16 -6
  192. package/dist/apps/shared/components/admin/mailboxes/ShareAccessCard.d.ts +10 -5
  193. package/dist/apps/shared/components/admin/mailboxes/ShareAccessCard.js +49 -34
  194. package/dist/apps/shared/components/admin/settings/BrandingForm.d.ts +2 -0
  195. package/dist/apps/shared/components/admin/settings/BrandingForm.js +7 -1
  196. package/dist/apps/shared/components/admin/settings/DomainDnsSetup.js +1 -1
  197. package/dist/apps/shared/components/admin/settings/PluginsManager.js +106 -20
  198. package/dist/apps/shared/components/admin/setup/SetupWizard.js +2 -1
  199. package/dist/apps/shared/components/calendar/CalendarListSidebar.js +8 -8
  200. package/dist/apps/shared/components/calendar/layout/CalendarShell.d.ts +1 -1
  201. package/dist/apps/shared/components/calendar/layout/CalendarShell.js +8 -4
  202. package/dist/apps/shared/components/contacts/ContactForm.js +1 -1
  203. package/dist/apps/shared/components/contacts/ContactsSidebar.js +4 -2
  204. package/dist/apps/shared/components/contacts/ContactsToolbar.d.ts +6 -2
  205. package/dist/apps/shared/components/contacts/ContactsToolbar.js +28 -10
  206. package/dist/apps/shared/components/contacts/layout/ContactsShell.d.ts +1 -1
  207. package/dist/apps/shared/components/contacts/layout/ContactsShell.js +19 -6
  208. package/dist/apps/shared/components/escrow/layout/EscrowShell.js +7 -4
  209. package/dist/apps/shared/components/layout/AppShell.d.ts +34 -4
  210. package/dist/apps/shared/components/layout/AppShell.js +122 -17
  211. package/dist/apps/shared/components/layout/BrandingChrome.d.ts +69 -10
  212. package/dist/apps/shared/components/layout/BrandingChrome.js +140 -12
  213. package/dist/apps/shared/components/layout/KeyEnrollmentGate.js +10 -9
  214. package/dist/apps/shared/components/layout/MailboxProvisioning.js +3 -1
  215. package/dist/apps/shared/components/layout/RailIcon.d.ts +21 -0
  216. package/dist/apps/shared/components/layout/RailIcon.js +85 -0
  217. package/dist/apps/shared/components/layout/ResponsiveToolbar.d.ts +55 -0
  218. package/dist/apps/shared/components/layout/ResponsiveToolbar.js +199 -0
  219. package/dist/apps/shared/components/layout/ThemeSwitch.d.ts +9 -0
  220. package/dist/apps/shared/components/layout/ThemeSwitch.js +54 -0
  221. package/dist/apps/shared/components/layout/UserMenu.d.ts +25 -3
  222. package/dist/apps/shared/components/layout/UserMenu.js +88 -7
  223. package/dist/apps/shared/components/mail/ConversationList.js +5 -11
  224. package/dist/apps/shared/components/mail/ConversationThreadPane.d.ts +6 -2
  225. package/dist/apps/shared/components/mail/ConversationThreadPane.js +87 -40
  226. package/dist/apps/shared/components/mail/LazyReadingPane.d.ts +9 -0
  227. package/dist/apps/shared/components/mail/LazyReadingPane.js +83 -0
  228. package/dist/apps/shared/components/mail/MailSelectionBar.d.ts +6 -4
  229. package/dist/apps/shared/components/mail/MailSelectionBar.js +11 -4
  230. package/dist/apps/shared/components/mail/MessageDetailPane.d.ts +25 -8
  231. package/dist/apps/shared/components/mail/MessageDetailPane.js +167 -73
  232. package/dist/apps/shared/components/mail/OutboxBadge.d.ts +17 -0
  233. package/dist/apps/shared/components/mail/OutboxBadge.js +18 -0
  234. package/dist/apps/shared/components/mail/OutboxRowStatus.d.ts +10 -0
  235. package/dist/apps/shared/components/mail/OutboxRowStatus.js +19 -0
  236. package/dist/apps/shared/components/mail/compose/ComposeContext.d.ts +38 -0
  237. package/dist/apps/shared/components/mail/compose/ComposeContext.js +97 -6
  238. package/dist/apps/shared/components/mail/compose/ComposeToolbar.js +4 -3
  239. package/dist/apps/shared/components/mail/compose/ComposeWindow.d.ts +3 -2
  240. package/dist/apps/shared/components/mail/compose/ComposeWindow.js +316 -339
  241. package/dist/apps/shared/components/mail/compose/ComposeWindowPlaceholder.d.ts +19 -0
  242. package/dist/apps/shared/components/mail/compose/ComposeWindowPlaceholder.js +33 -0
  243. package/dist/apps/shared/components/mail/compose/RichTextEditor.d.ts +9 -1
  244. package/dist/apps/shared/components/mail/compose/RichTextEditor.js +20 -2
  245. package/dist/apps/shared/components/mail/compose/composePerf.d.ts +16 -0
  246. package/dist/apps/shared/components/mail/compose/composePerf.js +41 -0
  247. package/dist/apps/shared/components/mail/compose/encryptionRequirement.d.ts +49 -0
  248. package/dist/apps/shared/components/mail/compose/encryptionRequirement.js +35 -0
  249. package/dist/apps/shared/components/mail/compose/quotedBody.d.ts +13 -0
  250. package/dist/apps/shared/components/mail/compose/quotedBody.js +67 -11
  251. package/dist/apps/shared/components/mail/layout/MailShell.d.ts +14 -4
  252. package/dist/apps/shared/components/mail/layout/MailShell.js +90 -104
  253. package/dist/apps/shared/components/mail/reading/EncryptedBody.d.ts +21 -0
  254. package/dist/apps/shared/components/mail/reading/EncryptedBody.js +22 -0
  255. package/dist/apps/shared/components/mail/reading/EncryptedPreview.d.ts +18 -0
  256. package/dist/apps/shared/components/mail/reading/EncryptedPreview.js +22 -0
  257. package/dist/apps/shared/components/mail/reading/MessageBody.d.ts +32 -0
  258. package/dist/apps/shared/components/mail/reading/MessageBody.js +136 -0
  259. package/dist/apps/shared/components/mail/reading/MessageCard.d.ts +62 -0
  260. package/dist/apps/shared/components/mail/reading/MessageCard.js +58 -0
  261. package/dist/apps/shared/components/mail/reading/bodyContent.d.ts +38 -0
  262. package/dist/apps/shared/components/mail/reading/bodyContent.js +84 -0
  263. package/dist/apps/shared/components/mail/reading/bodyHtml.d.ts +47 -0
  264. package/dist/apps/shared/components/mail/reading/bodyHtml.js +267 -0
  265. package/dist/apps/shared/components/mail/reading/color.d.ts +63 -0
  266. package/dist/apps/shared/components/mail/reading/color.js +201 -0
  267. package/dist/apps/shared/components/mail/reading/frameControl.d.ts +33 -0
  268. package/dist/apps/shared/components/mail/reading/frameControl.js +120 -0
  269. package/dist/apps/shared/components/mail/reading/frameDocument.d.ts +52 -0
  270. package/dist/apps/shared/components/mail/reading/frameDocument.js +98 -0
  271. package/dist/apps/shared/components/mail/reading/safeDocument.d.ts +3 -0
  272. package/dist/apps/shared/components/mail/reading/safeDocument.js +12 -0
  273. package/dist/apps/shared/components/mail/reading/themeAdaptation.d.ts +56 -0
  274. package/dist/apps/shared/components/mail/reading/themeAdaptation.js +144 -0
  275. package/dist/apps/shared/components/mail/reading/themeSurface.d.ts +17 -0
  276. package/dist/apps/shared/components/mail/reading/themeSurface.js +83 -0
  277. package/dist/apps/shared/components/mail/reading/viewOriginal.d.ts +9 -0
  278. package/dist/apps/shared/components/mail/reading/viewOriginal.js +32 -0
  279. package/dist/apps/shared/components/mail/unreadStyle.d.ts +45 -0
  280. package/dist/apps/shared/components/mail/unreadStyle.js +61 -0
  281. package/dist/apps/shared/components/settings/SigningCertificateCard.d.ts +32 -0
  282. package/dist/apps/shared/components/settings/SigningCertificateCard.js +98 -0
  283. package/dist/apps/shared/components/settings/layout/SettingsShell.d.ts +1 -1
  284. package/dist/apps/shared/components/settings/layout/SettingsShell.js +16 -5
  285. package/dist/apps/shared/components/sharing/PrincipalPicker.d.ts +26 -0
  286. package/dist/apps/shared/components/sharing/PrincipalPicker.js +77 -0
  287. package/dist/apps/shared/components/tasks/TasksSidebar.js +4 -2
  288. package/dist/apps/shared/components/tasks/layout/TasksShell.d.ts +1 -1
  289. package/dist/apps/shared/components/tasks/layout/TasksShell.js +18 -6
  290. package/dist/apps/shared/keyboard/GlobalShortcuts.d.ts +14 -0
  291. package/dist/apps/shared/keyboard/GlobalShortcuts.js +37 -0
  292. package/dist/apps/shared/keyboard/ShortcutProvider.d.ts +20 -0
  293. package/dist/apps/shared/keyboard/ShortcutProvider.js +52 -0
  294. package/dist/apps/shared/keyboard/ShortcutsDialog.d.ts +14 -0
  295. package/dist/apps/shared/keyboard/ShortcutsDialog.js +42 -0
  296. package/dist/apps/shared/keyboard/dispatch.d.ts +16 -0
  297. package/dist/apps/shared/keyboard/dispatch.js +109 -0
  298. package/dist/apps/shared/keyboard/format.d.ts +12 -0
  299. package/dist/apps/shared/keyboard/format.js +74 -0
  300. package/dist/apps/shared/keyboard/keymap.d.ts +294 -0
  301. package/dist/apps/shared/keyboard/keymap.js +84 -0
  302. package/dist/apps/shared/keyboard/match.d.ts +20 -0
  303. package/dist/apps/shared/keyboard/match.js +31 -0
  304. package/dist/apps/shared/keyboard/parse.d.ts +31 -0
  305. package/dist/apps/shared/keyboard/parse.js +107 -0
  306. package/dist/apps/shared/keyboard/platform.d.ts +15 -0
  307. package/dist/apps/shared/keyboard/platform.js +22 -0
  308. package/dist/apps/shared/keyboard/registry.d.ts +39 -0
  309. package/dist/apps/shared/keyboard/registry.js +33 -0
  310. package/dist/apps/shared/keyboard/targets.d.ts +14 -0
  311. package/dist/apps/shared/keyboard/targets.js +67 -0
  312. package/dist/apps/shared/keyboard/useShortcut.d.ts +19 -0
  313. package/dist/apps/shared/keyboard/useShortcut.js +35 -0
  314. package/dist/apps/shared/keyboard/useShortcutProps.d.ts +10 -0
  315. package/dist/apps/shared/keyboard/useShortcutProps.js +15 -0
  316. package/dist/apps/shared/mail/folderCounts.d.ts +78 -0
  317. package/dist/apps/shared/mail/folderCounts.js +218 -0
  318. package/dist/apps/shared/mail/folderTree.d.ts +55 -0
  319. package/dist/apps/shared/mail/folderTree.js +116 -0
  320. package/dist/apps/shared/mail/listSnapshots.d.ts +46 -0
  321. package/dist/apps/shared/mail/listSnapshots.js +43 -0
  322. package/dist/apps/shared/mail/messageReadState.d.ts +32 -0
  323. package/dist/apps/shared/mail/messageReadState.js +63 -0
  324. package/dist/apps/shared/mail/newMailNotifications.d.ts +62 -0
  325. package/dist/apps/shared/mail/newMailNotifications.js +138 -0
  326. package/dist/apps/shared/mail/outbox/UnlockBridge.d.ts +5 -0
  327. package/dist/apps/shared/mail/outbox/UnlockBridge.js +18 -0
  328. package/dist/apps/shared/mail/outbox/composeBridge.d.ts +34 -0
  329. package/dist/apps/shared/mail/outbox/composeBridge.js +32 -0
  330. package/dist/apps/shared/mail/outbox/outboxState.d.ts +41 -0
  331. package/dist/apps/shared/mail/outbox/outboxState.js +42 -0
  332. package/dist/apps/shared/mail/outbox/pendingSends.d.ts +39 -0
  333. package/dist/apps/shared/mail/outbox/pendingSends.js +109 -0
  334. package/dist/apps/shared/mail/outbox/sendDecision.d.ts +80 -0
  335. package/dist/apps/shared/mail/outbox/sendDecision.js +94 -0
  336. package/dist/apps/shared/mail/outbox/sendJob.d.ts +68 -0
  337. package/dist/apps/shared/mail/outbox/sendJob.js +319 -0
  338. package/dist/apps/shared/mail/outbox/sendOutcomes.d.ts +3 -0
  339. package/dist/apps/shared/mail/outbox/sendOutcomes.js +141 -0
  340. package/dist/apps/shared/mail/outbox/sendState.d.ts +25 -0
  341. package/dist/apps/shared/mail/outbox/sendState.js +8 -0
  342. package/dist/apps/shared/mail/outbox/useOutboxStatus.d.ts +11 -0
  343. package/dist/apps/shared/mail/outbox/useOutboxStatus.js +49 -0
  344. package/dist/apps/shared/mail/useMailConnection.d.ts +56 -0
  345. package/dist/apps/shared/mail/useMailConnection.js +138 -0
  346. package/dist/apps/shared/mail/useMailLiveUpdates.d.ts +29 -9
  347. package/dist/apps/shared/mail/useMailLiveUpdates.js +60 -32
  348. package/dist/apps/shared/mail/useMarkMessageRead.d.ts +12 -0
  349. package/dist/apps/shared/mail/useMarkMessageRead.js +44 -0
  350. package/dist/apps/shared/mail/useNewMailNotifications.d.ts +35 -0
  351. package/dist/apps/shared/mail/useNewMailNotifications.js +130 -0
  352. package/dist/apps/shared/mail/useUnreadTitle.d.ts +18 -0
  353. package/dist/apps/shared/mail/useUnreadTitle.js +31 -0
  354. package/dist/apps/shared/navigation/AppRouter.d.ts +52 -0
  355. package/dist/apps/shared/navigation/AppRouter.js +242 -0
  356. package/dist/apps/shared/navigation/appHrefs.d.ts +14 -0
  357. package/dist/apps/shared/navigation/appHrefs.js +20 -0
  358. package/dist/apps/shared/navigation/frameContext.d.ts +19 -0
  359. package/dist/apps/shared/navigation/frameContext.js +24 -0
  360. package/dist/apps/shared/navigation/idle.d.ts +14 -0
  361. package/dist/apps/shared/navigation/idle.js +43 -0
  362. package/dist/apps/shared/navigation/routerContext.d.ts +37 -0
  363. package/dist/apps/shared/navigation/routerContext.js +56 -0
  364. package/dist/apps/shared/navigation/routes.d.ts +32 -0
  365. package/dist/apps/shared/navigation/routes.js +37 -0
  366. package/dist/apps/shared/notifications/NotificationCenter.d.ts +19 -0
  367. package/dist/apps/shared/notifications/NotificationCenter.js +90 -0
  368. package/dist/apps/shared/notifications/NotificationHistoryDialog.d.ts +10 -0
  369. package/dist/apps/shared/notifications/NotificationHistoryDialog.js +36 -0
  370. package/dist/apps/shared/notifications/apiErrors.d.ts +19 -0
  371. package/dist/apps/shared/notifications/apiErrors.js +86 -0
  372. package/dist/apps/shared/notifications/headerOffset.d.ts +8 -0
  373. package/dist/apps/shared/notifications/headerOffset.js +33 -0
  374. package/dist/apps/shared/notifications/pushStatus.d.ts +9 -0
  375. package/dist/apps/shared/notifications/pushStatus.js +54 -0
  376. package/dist/apps/shared/notifications/store.d.ts +136 -0
  377. package/dist/apps/shared/notifications/store.js +416 -0
  378. package/dist/apps/shared/notifications/systemErrors.d.ts +9 -0
  379. package/dist/apps/shared/notifications/systemErrors.js +58 -0
  380. package/dist/apps/shared/notifications/useNotifications.d.ts +17 -0
  381. package/dist/apps/shared/notifications/useNotifications.js +18 -0
  382. package/dist/apps/shared/search/LocalIndexLifecycle.js +17 -3
  383. package/dist/apps/shared/signing/enrollmentStorage.d.ts +10 -0
  384. package/dist/apps/shared/signing/enrollmentStorage.js +33 -0
  385. package/dist/apps/shared/signing/enrollmentTracker.d.ts +73 -0
  386. package/dist/apps/shared/signing/enrollmentTracker.js +307 -0
  387. package/dist/apps/shared/signing/enrollmentView.d.ts +57 -0
  388. package/dist/apps/shared/signing/enrollmentView.js +214 -0
  389. package/dist/apps/shared/signing/signingInfo.d.ts +11 -0
  390. package/dist/apps/shared/signing/signingInfo.js +48 -0
  391. package/dist/apps/shared/signing/useNow.d.ts +2 -0
  392. package/dist/apps/shared/signing/useNow.js +18 -0
  393. package/dist/apps/shared/signing/useSigningEnrollmentWatcher.d.ts +16 -0
  394. package/dist/apps/shared/signing/useSigningEnrollmentWatcher.js +87 -0
  395. package/dist/apps/shared/styles/app.css +108 -10
  396. package/dist/apps/www/_layout.d.ts +5 -1
  397. package/dist/apps/www/_layout.js +3 -2
  398. package/dist/apps/www/_routedPage.d.ts +12 -0
  399. package/dist/apps/www/_routedPage.js +19 -0
  400. package/dist/apps/www/_routes.d.ts +11 -0
  401. package/dist/apps/www/_routes.js +30 -0
  402. package/dist/apps/www/calendar/index.d.ts +2 -2
  403. package/dist/apps/www/calendar/index.js +41 -11
  404. package/dist/apps/www/contacts/[uid].d.ts +3 -9
  405. package/dist/apps/www/contacts/[uid].js +11 -9
  406. package/dist/apps/www/contacts/index.d.ts +2 -2
  407. package/dist/apps/www/contacts/index.js +30 -24
  408. package/dist/apps/www/index.d.ts +2 -2
  409. package/dist/apps/www/index.js +332 -48
  410. package/dist/apps/www/messages/[uid].d.ts +3 -7
  411. package/dist/apps/www/messages/[uid].js +10 -5
  412. package/dist/apps/www/settings/appearance/index.d.ts +4 -0
  413. package/dist/apps/www/settings/appearance/index.js +13 -0
  414. package/dist/apps/www/settings/auto-reply/index.d.ts +2 -2
  415. package/dist/apps/www/settings/auto-reply/index.js +6 -7
  416. package/dist/apps/www/settings/encryption/index.d.ts +2 -2
  417. package/dist/apps/www/settings/encryption/index.js +106 -96
  418. package/dist/apps/www/settings/filters/[uid].d.ts +2 -2
  419. package/dist/apps/www/settings/filters/[uid].js +6 -2
  420. package/dist/apps/www/settings/filters/index.d.ts +2 -2
  421. package/dist/apps/www/settings/filters/index.js +3 -1
  422. package/dist/apps/www/settings/filters/new/index.d.ts +2 -2
  423. package/dist/apps/www/settings/filters/new/index.js +9 -3
  424. package/dist/apps/www/settings/labels/index.d.ts +2 -2
  425. package/dist/apps/www/settings/labels/index.js +3 -1
  426. package/dist/apps/www/settings/privacy/index.d.ts +2 -2
  427. package/dist/apps/www/settings/privacy/index.js +8 -9
  428. package/dist/apps/www/settings/read-receipts/index.d.ts +2 -2
  429. package/dist/apps/www/settings/read-receipts/index.js +6 -7
  430. package/dist/apps/www/settings/sharing/index.d.ts +2 -2
  431. package/dist/apps/www/settings/sharing/index.js +22 -34
  432. package/dist/apps/www/settings/signatures/[uid].d.ts +2 -2
  433. package/dist/apps/www/settings/signatures/[uid].js +6 -2
  434. package/dist/apps/www/settings/signatures/index.d.ts +2 -2
  435. package/dist/apps/www/settings/signatures/index.js +3 -1
  436. package/dist/apps/www/settings/signatures/new/index.d.ts +2 -2
  437. package/dist/apps/www/settings/signatures/new/index.js +9 -4
  438. package/dist/apps/www/tasks/index.d.ts +2 -2
  439. package/dist/apps/www/tasks/index.js +22 -16
  440. package/package.json +2 -2
  441. package/apps/shared/components/mail/compose/SendFailureAlert.tsx +0 -48
  442. package/dist/apps/shared/components/mail/compose/SendFailureAlert.d.ts +0 -14
  443. package/dist/apps/shared/components/mail/compose/SendFailureAlert.js +0 -11
@@ -1,288 +1,477 @@
1
- ///////////////////////////////////////////////////////////////////////////////
2
- // Copyright (C) 2026 Jean-Philippe Steinmetz
3
- // SPDX-License-Identifier: MPL-2.0
4
- ///////////////////////////////////////////////////////////////////////////////
5
- import "../../styles/app.css";
6
- import React, { PropsWithChildren, useEffect, useRef, useState } from "react";
7
- import type { IconType } from "react-icons";
8
- import {
9
- HiOutlineCalendarDays,
10
- HiOutlineClipboardDocumentList,
11
- HiOutlineEnvelope,
12
- HiOutlinePuzzlePiece,
13
- HiOutlineUsers,
14
- } from "react-icons/hi2";
15
- import { useRedirectIfUnauthenticated } from "@rapidmx/react-shared/auth/session.js";
16
- import { getSetupStatus } from "@rapidmx/react-shared/admin/setupApi.js";
17
- import { stopImpersonating } from "@rapidmx/react-shared/mail/mailApi.js";
18
- import useBranding from "@rapidmx/react-shared/branding/useBranding.js";
19
- import { useIdleKeyTimeout } from "@rapidmx/react-shared/crypto/useIdleKeyTimeout.js";
20
- import ComposeProvider from "../mail/compose/ComposeContext.js";
21
- import { flushComposeDrafts, markSigningOut } from "../mail/compose/composeFlushRegistry.js";
22
- import BottomTabBar, { NavItem } from "@rapidmx/react-shared/components/navigation/BottomTabBar.js";
23
- import { BrandingFooter, BrandingHeader } from "./BrandingChrome.js";
24
- import UserMenu from "./UserMenu.js";
25
- import { UnlockPromptProvider } from "./UnlockPromptProvider.js";
26
- import { SIGN_OUT_CHANNEL, destroyAllLocalIndexes } from "../../search/localIndexRpcClient.js";
27
- import { authApiFetch } from "@rapidmx/react-shared/util/api.js";
28
- import { destroyUnlockedKeys } from "@rapidmx/react-shared/crypto/keySession.js";
29
- import { clearPinnedSignerCache } from "../mail/pinnedSigners.js";
30
- import { mergePluginNavItems, PluginNav, PluginNavProps } from "../../plugins/pluginNav.js";
31
-
32
- /** How long sign-out waits for auth-server's logout before navigating anyway. */
33
- export const LOGOUT_TIMEOUT_MS = 3_000;
34
-
35
- /**
36
- * Calls auth-server's logout (`POST /api/auth/logout`, cross-origin with credentials), which clears the auth
37
- * cookie and invalidates the session's refresh token. Bounded by `LOGOUT_TIMEOUT_MS` and never rejects - a
38
- * failure (unreachable server, CORS) must not keep the user from leaving.
39
- */
40
- async function logOutOfAuthServer(authServerUrl: string | undefined): Promise<void> {
41
- if (!authServerUrl) {
42
- return;
43
- }
44
- const controller = new AbortController();
45
- const timer = setTimeout(() => controller.abort(), LOGOUT_TIMEOUT_MS);
46
- try {
47
- await authApiFetch(authServerUrl, "/auth/logout", { method: "POST", signal: controller.signal });
48
- } catch {
49
- // Navigate anyway - see this function's doc comment.
50
- } finally {
51
- clearTimeout(timer);
52
- }
53
- }
54
-
55
- export type AppShellApp = "mail" | "calendar" | "contacts" | "tasks";
56
-
57
- /** `"settings"` is a valid `active` value but deliberately has no entry in `APPS` below — Settings is
58
- * reached via a `UserMenu` item, not a 5th rail icon (see `SettingsShell.tsx`), so it highlights no
59
- * rail/tab icon at all; only the header title needs to account for it. Any other string is a plugin's
60
- * `appRail` item id (see `PluginNav`). */
61
- export type AppShellActive = AppShellApp | "settings" | (string & {});
62
-
63
- export interface AppShellProps extends PluginNavProps {
64
- /** Which icon in the rail is highlighted as the current app — `"settings"` highlights none, and a plugin
65
- * app page passes its own `appRail` item id. */
66
- active: AppShellActive;
67
- /** Populated automatically by the framework from an authenticated request (e.g. a valid `jwt` cookie). */
68
- userUid?: string;
69
- /** auth-server's base URL, injected via the route's `fetchProps`. */
70
- authServerUrl?: string;
71
- /**
72
- * `true` when this session is an admin "log in as user" impersonation (a `jwt_impersonator` cookie is
73
- * present) — see `MailShell`'s original doc comment, unchanged now that this lives here. Drives the
74
- * "you are viewing as this user — stop impersonating" banner below.
75
- */
76
- impersonating?: boolean;
77
- /** Where `mailApi.ts`'s `stopImpersonating()` should call — see `MailShell`'s original doc comment. */
78
- impersonationBaseUrl?: string;
79
- /** `true` when the caller's JWT carries a trusted role — shows an "Admin" item in the user menu below. */
80
- trusted?: boolean;
81
- }
82
-
83
- export interface AppDef {
84
- id: AppShellApp;
85
- href: string;
86
- label: string;
87
- icon: IconType;
88
- }
89
-
90
- export const APPS: AppDef[] = [
91
- { id: "mail", href: "/", label: "Mail", icon: HiOutlineEnvelope },
92
- { id: "calendar", href: "/calendar", label: "Calendar", icon: HiOutlineCalendarDays },
93
- { id: "contacts", href: "/contacts", label: "Contacts", icon: HiOutlineUsers },
94
- { id: "tasks", href: "/tasks", label: "Tasks", icon: HiOutlineClipboardDocumentList },
95
- ];
96
-
97
- /** Ids plugin `appRail` items can't take besides `APPS`' own - `"settings"` has no rail icon but is still a
98
- * core `active` value. */
99
- const RESERVED_APP_IDS = ["settings"];
100
-
101
- /** `APPS` followed by the plugins' `appRail` items (generic icon), core ids winning - see `mergePluginNavItems`. */
102
- export function appRailItems(pluginNav?: PluginNav): NavItem[] {
103
- return mergePluginNavItems<NavItem>(
104
- APPS,
105
- pluginNav?.appRail,
106
- ({ id, href, label }) => ({ id, href, label, icon: HiOutlinePuzzlePiece }),
107
- RESERVED_APP_IDS,
108
- );
109
- }
110
-
111
- /**
112
- * The persistent chrome shared by every webmail app (Mail, Calendar, Contacts, Tasks): a left icon rail for
113
- * switching apps (full page loads — see `MailShell`'s original doc comment on this framework having no
114
- * client-side router), a header with the current app's name and `UserMenu`, and the impersonation banner.
115
- * Each app's own shell (e.g. `MailShell`) renders its own contextual sidebar + content as `children`, inside
116
- * the area to the right of the icon rail and below the header.
117
- */
118
- export default function AppShell({
119
- active,
120
- userUid,
121
- authServerUrl,
122
- impersonating,
123
- impersonationBaseUrl,
124
- trusted,
125
- pluginNav,
126
- children,
127
- }: PropsWithChildren<AppShellProps>) {
128
- const [stoppingImpersonation, setStoppingImpersonation] = useState(false);
129
- const signingOutRef = useRef(false);
130
- const { branding, iconSrc } = useBranding();
131
-
132
- useRedirectIfUnauthenticated(userUid, authServerUrl);
133
- // Mounted here, not scoped to Mail/Settings (the only shells that actually read unlocked keys),
134
- // specifically so activity in *any* app resets the idle clock - see that hook's own doc comment.
135
- useIdleKeyTimeout();
136
-
137
- // An administrator on a server that hasn't finished first-run setup is sent to the setup wizard. The status
138
- // check is admin-only, so it's only made for a trusted caller - everyone else would just get a 403 on every
139
- // page load. Any failure is ignored.
140
- useEffect(() => {
141
- if (!userUid || impersonating || !trusted) {
142
- return;
143
- }
144
- getSetupStatus()
145
- .then((status) => {
146
- if (status.required) {
147
- window.location.href = "/admin/setup";
148
- }
149
- })
150
- .catch(() => undefined);
151
- }, [userUid, impersonating, trusted]);
152
-
153
- // Another tab signing out (this app's `handleSignOut`, or the admin/escrow consoles' `signOutOfConsole()`)
154
- // ended this session too - its auth cookie is gone - so this tab destroys its own unlocked keys and every
155
- // local search index on the device, then leaves as well. The consoles have no local-index client of their
156
- // own, so this is what actually removes the indexes after a console sign-out (the console also records a
157
- // pending deletion, retried on the next mail load, in case no mail tab is open). `destroyAllLocalIndexes()`
158
- // announces the sign-out on this same channel, which this tab then hears itself, so the ref is set first:
159
- // each tab reacts once, and the tab that started the sign-out ignores its own announcement.
160
- useEffect(() => {
161
- if (!userUid || typeof BroadcastChannel === "undefined") {
162
- return;
163
- }
164
- const channel = new BroadcastChannel(SIGN_OUT_CHANNEL);
165
- channel.addEventListener("message", (event: MessageEvent<{ type?: string }>) => {
166
- if (event.data?.type !== "sign-out" || signingOutRef.current) {
167
- return;
168
- }
169
- signingOutRef.current = true;
170
- // Compose windows must not ask "Leave site?" - that would let this forced navigation be cancelled.
171
- markSigningOut();
172
- destroyUnlockedKeys();
173
- clearPinnedSignerCache();
174
- // Bounded by its own timeout and never rejects - awaited so navigating doesn't kill the Worker mid-delete.
175
- void destroyAllLocalIndexes().then(() => {
176
- window.location.href = authServerUrl ?? "/";
177
- });
178
- });
179
- return () => channel.close();
180
- }, [userUid, authServerUrl]);
181
-
182
- async function handleSignOut() {
183
- signingOutRef.current = true;
184
- // Before flushing and navigating: compose windows then skip their "Leave site?" prompt, which could
185
- // otherwise cancel the sign-out's own navigation.
186
- markSigningOut();
187
- // Unlocked private keys never outlive an explicit sign-out.
188
- destroyUnlockedKeys();
189
- // Trusted signer pins read from contacts don't outlive the session either.
190
- clearPinnedSignerCache();
191
- // Open compose windows save edits still waiting on their autosave debounce while the session is still
192
- // valid - logout invalidates it. Bounded the same way as logout itself, and never rejects.
193
- await flushComposeDrafts(LOGOUT_TIMEOUT_MS);
194
- // The Tier 2 local index MUST be destroyed on explicit logout, the same as unlocked keys themselves
195
- // (spec §11). Destroys every index on this device (not only mailboxes opened this page load) and is
196
- // awaited before navigating - a navigation tears down the Worker mid-delete otherwise.
197
- // destroyAllLocalIndexes() is bounded by its own timeout and never rejects, so sign-out can't hang.
198
- // In parallel, auth-server's logout clears the auth cookie and invalidates the session's refresh
199
- // token - without it, "Sign Out" would only navigate away from a still-valid session.
200
- await Promise.all([destroyAllLocalIndexes(), logOutOfAuthServer(authServerUrl)]);
201
- window.location.href = authServerUrl ?? "/";
202
- }
203
-
204
- async function handleStopImpersonating() {
205
- setStoppingImpersonation(true);
206
- try {
207
- await stopImpersonating(impersonationBaseUrl ?? "");
208
- } catch {
209
- // Navigate either way: a failed call leaves the impersonator cookie (and this banner) exactly as
210
- // they were, so there's nothing else useful to show — matching this app's other network-error
211
- // handling, which surfaces via a full reload rather than an inline retry affordance.
212
- } finally {
213
- window.location.href = "/admin";
214
- }
215
- }
216
-
217
- if (!userUid) {
218
- return <div className="min-h-screen" />;
219
- }
220
-
221
- const apps = appRailItems(pluginNav);
222
- // The header title: "settings" has no rail item, everything else is labelled by its own rail item.
223
- const activeLabel = active === "settings" ? "Settings" : apps.find((app) => app.id === active)?.label;
224
-
225
- return (
226
- // Mounted here, not scoped to Mail/Settings, for the same reason as useIdleKeyTimeout() above -
227
- // ComposeWindow's sign/encrypt toggles and MessageDetailPane's encrypted-message view (both Mail)
228
- // are today's only useUnlockPrompt() callers, but this needs to be available to any app shell.
229
- <UnlockPromptProvider>
230
- {/* An impersonating admin acts with the impersonated user's access, so their own trusted role
231
- mustn't skip the per-mailbox checks. */}
232
- <ComposeProvider userUid={userUid} trusted={!!trusted && !impersonating}>
233
- <div className="min-h-screen flex flex-col bg-surface-alt">
234
- <BrandingHeader branding={branding} />
235
- {impersonating && (
236
- <div className="h-10 shrink-0 bg-warning text-warning-contrast flex items-center justify-center gap-3 text-sm font-medium px-4">
237
- <span>
238
- You are viewing as <strong>{userUid}</strong>.
239
- </span>
240
- <button
241
- type="button"
242
- onClick={handleStopImpersonating}
243
- disabled={stoppingImpersonation}
244
- className="underline hover:no-underline disabled:opacity-60"
245
- >
246
- {stoppingImpersonation ? "Returning to admin…" : "Return to admin"}
247
- </button>
248
- </div>
249
- )}
250
- <div className="flex-1 flex min-h-0">
251
- <nav
252
- aria-label="Apps"
253
- className="hidden md:flex w-16 shrink-0 bg-surface border-r border-border flex-col items-center py-3 gap-1"
254
- >
255
- <img src={iconSrc} width="96" height="96" alt="" className="mb-3" />
256
- {apps.map(({ id, href, label, icon: Icon }) => (
257
- <a
258
- key={id}
259
- href={href}
260
- aria-label={label}
261
- aria-current={id === active ? "page" : undefined}
262
- title={label}
263
- className={[
264
- "w-10 h-10 flex items-center justify-center rounded-sm",
265
- id === active
266
- ? "bg-primary/10 text-primary-dark"
267
- : "text-text-muted hover:bg-surface-alt hover:text-text",
268
- ].join(" ")}
269
- >
270
- <Icon size={20} aria-hidden="true" />
271
- </a>
272
- ))}
273
- </nav>
274
- <BottomTabBar apps={apps} active={active} />
275
- <div className="flex-1 flex flex-col min-w-0">
276
- <header className="h-16 shrink-0 bg-surface border-b border-border flex items-center justify-between gap-4 px-6">
277
- <span className="font-display font-bold text-lg uppercase tracking-wide">{activeLabel}</span>
278
- <UserMenu userUid={userUid} authServerUrl={authServerUrl} onSignOut={handleSignOut} showAdminLink={trusted} showSettingsLink />
279
- </header>
280
- <div className="flex-1 flex min-h-0 pb-14 md:pb-0">{children}</div>
281
- </div>
282
- </div>
283
- <BrandingFooter branding={branding} />
284
- </div>
285
- </ComposeProvider>
286
- </UnlockPromptProvider>
287
- );
288
- }
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2026 Jean-Philippe Steinmetz
3
+ // SPDX-License-Identifier: MPL-2.0
4
+ ///////////////////////////////////////////////////////////////////////////////
5
+ import "../../styles/app.css";
6
+ import React, { PropsWithChildren, useEffect, useRef, useState } from "react";
7
+ import type { IconType } from "react-icons";
8
+ import {
9
+ HiOutlineCalendarDays,
10
+ HiOutlineClipboardDocumentList,
11
+ HiOutlineEnvelope,
12
+ HiOutlinePuzzlePiece,
13
+ HiOutlineUsers,
14
+ } from "react-icons/hi2";
15
+ import { useRedirectIfUnauthenticated } from "@rapidmx/react-shared/auth/session.js";
16
+ import { getSetupStatus } from "@rapidmx/react-shared/admin/setupApi.js";
17
+ import { stopImpersonating } from "@rapidmx/react-shared/mail/mailApi.js";
18
+ import useBranding from "@rapidmx/react-shared/branding/useBranding.js";
19
+ import { useIdleKeyTimeout } from "@rapidmx/react-shared/crypto/useIdleKeyTimeout.js";
20
+ import ComposeProvider from "../mail/compose/ComposeContext.js";
21
+ import { flushComposeDrafts, markSigningOut } from "../mail/compose/composeFlushRegistry.js";
22
+ import BottomTabBar, { NavItem } from "@rapidmx/react-shared/components/navigation/BottomTabBar.js";
23
+ import { FrameBrandingFooter, FrameBrandingHeader, useBrandingHtml } from "./BrandingChrome.js";
24
+ import RailIcon from "./RailIcon.js";
25
+ import AppearanceProvider from "../../appearance/AppearanceProvider.js";
26
+ import { clearAppearanceCache } from "../../appearance/appearanceCache.js";
27
+ import type { Branding } from "@rapidmx/react-shared/branding/brandingApi.js";
28
+ import UserMenu from "./UserMenu.js";
29
+ import { UnlockPromptProvider } from "./UnlockPromptProvider.js";
30
+ import { SIGN_OUT_CHANNEL, destroyAllLocalIndexes } from "../../search/localIndexRpcClient.js";
31
+ import { authApiFetch, setApiUnauthorizedObserver } from "@rapidmx/react-shared/util/api.js";
32
+ import { destroyUnlockedKeys } from "@rapidmx/react-shared/crypto/keySession.js";
33
+ import { clearPinnedSignerCache } from "../mail/pinnedSigners.js";
34
+ import { mergePluginNavItems, PluginNav, PluginNavProps } from "../../plugins/pluginNav.js";
35
+ import { useInAppFrame } from "../../navigation/frameContext.js";
36
+ import { APP_HREFS } from "../../navigation/appHrefs.js";
37
+ import { useNavigate } from "../../navigation/routerContext.js";
38
+ import { GlobalShortcuts } from "../../keyboard/GlobalShortcuts.js";
39
+ import { ShortcutProvider } from "../../keyboard/ShortcutProvider.js";
40
+ import ShortcutsDialog from "../../keyboard/ShortcutsDialog.js";
41
+ import { inboxUnreadTotal } from "../../mail/folderCounts.js";
42
+ import { MailConnectionContext, useMailConnection } from "../../mail/useMailConnection.js";
43
+ import { useUnreadTitle } from "../../mail/useUnreadTitle.js";
44
+ import UnlockBridge from "../../mail/outbox/UnlockBridge.js";
45
+ import NotificationCenter from "../../notifications/NotificationCenter.js";
46
+ import { useHeaderHeightRef } from "../../notifications/headerOffset.js";
47
+ import NotificationHistoryDialog from "../../notifications/NotificationHistoryDialog.js";
48
+ import { notifySessionExpired, setSignInUrl } from "../../notifications/apiErrors.js";
49
+ import { useUnseenErrorCount } from "../../notifications/useNotifications.js";
50
+ import { useSigningEnrollmentWatcher } from "../../signing/useSigningEnrollmentWatcher.js";
51
+
52
+ /** How long sign-out waits for auth-server's logout before navigating anyway. */
53
+ export const LOGOUT_TIMEOUT_MS = 3_000;
54
+
55
+ /**
56
+ * Calls auth-server's logout (`POST /api/auth/logout`, cross-origin with credentials), which clears the auth
57
+ * cookie and invalidates the session's refresh token. Bounded by `LOGOUT_TIMEOUT_MS` and never rejects - a
58
+ * failure (unreachable server, CORS) must not keep the user from leaving.
59
+ */
60
+ async function logOutOfAuthServer(authServerUrl: string | undefined): Promise<void> {
61
+ if (!authServerUrl) {
62
+ return;
63
+ }
64
+ const controller = new AbortController();
65
+ const timer = setTimeout(() => controller.abort(), LOGOUT_TIMEOUT_MS);
66
+ try {
67
+ await authApiFetch(authServerUrl, "/auth/logout", { method: "POST", signal: controller.signal });
68
+ } catch {
69
+ // Navigate anyway - see this function's doc comment.
70
+ } finally {
71
+ clearTimeout(timer);
72
+ }
73
+ }
74
+
75
+ export type AppShellApp = "mail" | "calendar" | "contacts" | "tasks";
76
+
77
+ /** `"settings"` is a valid `active` value but deliberately has no entry in `APPS` below — Settings is
78
+ * reached via a `UserMenu` item, not a 5th rail icon (see `SettingsShell.tsx`), so it highlights no
79
+ * rail/tab icon at all; only the header title needs to account for it. Any other string is a plugin's
80
+ * `appRail` item id (see `PluginNav`). */
81
+ export type AppShellActive = AppShellApp | "settings" | (string & {});
82
+
83
+ export interface AppShellProps extends PluginNavProps {
84
+ /** Which icon in the rail is highlighted as the current app — `"settings"` highlights none, and a plugin
85
+ * app page passes its own `appRail` item id. */
86
+ active: AppShellActive;
87
+ /** Populated automatically by the framework from an authenticated request (e.g. a valid `jwt` cookie). */
88
+ userUid?: string;
89
+ /** auth-server's base URL, injected via the route's `fetchProps`. */
90
+ authServerUrl?: string;
91
+ /**
92
+ * `true` when this session is an admin "log in as user" impersonation (a `jwt_impersonator` cookie is
93
+ * present) — see `MailShell`'s original doc comment, unchanged now that this lives here. Drives the
94
+ * "you are viewing as this user — stop impersonating" banner below.
95
+ */
96
+ impersonating?: boolean;
97
+ /** Where `mailApi.ts`'s `stopImpersonating()` should call — see `MailShell`'s original doc comment. */
98
+ impersonationBaseUrl?: string;
99
+ /** `true` when the caller's JWT carries a trusted role — shows an "Admin Console" item in the user menu below. A token
100
+ * only carries one once elevated, so a real administrator with an ordinary session is `false` here; the user menu
101
+ * asks auth-server about them separately (see `UserMenu`'s `detectAdmin`). */
102
+ trusted?: boolean;
103
+ /** The role names the server treats as trusted (its `trusted_roles` config, injected via the route's `fetchProps`) -
104
+ * what that lookup looks for. Absent means the server's own default, `["admin"]`. */
105
+ trustedRoles?: string[];
106
+ /** The deployment's branding as the server rendered the page (its `branding` prop). Used until the frame's own fetch answers, so a custom header is there from the first paint - and the frame knows to drop its own title bar - instead of appearing (and moving everything) once the request returns. */
107
+ branding?: Branding;
108
+ /** The signed-in user's stored appearance preferences as the server rendered the page (its `appearance` prop), so the first paint already wears the theme and background - see `AppearanceProvider`. */
109
+ appearance?: unknown;
110
+ }
111
+
112
+ export interface AppDef {
113
+ id: AppShellApp;
114
+ href: string;
115
+ label: string;
116
+ icon: IconType;
117
+ }
118
+
119
+ export const APPS: AppDef[] = [
120
+ { id: "mail", href: APP_HREFS.mail, label: "Mail", icon: HiOutlineEnvelope },
121
+ { id: "calendar", href: APP_HREFS.calendar, label: "Calendar", icon: HiOutlineCalendarDays },
122
+ { id: "contacts", href: APP_HREFS.contacts, label: "Contacts", icon: HiOutlineUsers },
123
+ { id: "tasks", href: APP_HREFS.tasks, label: "Tasks", icon: HiOutlineClipboardDocumentList },
124
+ ];
125
+
126
+ /** Ids plugin `appRail` items can't take besides `APPS`' own - `"settings"` has no rail icon but is still a
127
+ * core `active` value. */
128
+ const RESERVED_APP_IDS = ["settings"];
129
+
130
+ /** `APPS` followed by the plugins' `appRail` items (generic icon), core ids winning - see `mergePluginNavItems`. */
131
+ export function appRailItems(pluginNav?: PluginNav): NavItem[] {
132
+ return mergePluginNavItems<NavItem>(
133
+ APPS,
134
+ pluginNav?.appRail,
135
+ ({ id, href, label }) => ({ id, href, label, icon: HiOutlinePuzzlePiece }),
136
+ RESERVED_APP_IDS,
137
+ );
138
+ }
139
+
140
+ /** What only the persistent frame (`AppRouter`) passes to the chrome it keeps mounted. */
141
+ export interface AppChromeProps extends AppShellProps {
142
+ /** Changes whenever the router shows a different page: the chrome then moves focus to the content, scrolls to its top,
143
+ * sets the document title and announces the page. Absent outside the router, when nothing does. */
144
+ routeKey?: string;
145
+ /** The router is loading the next page's code - the content is `aria-busy`. */
146
+ busy?: boolean;
147
+ /** A screen that takes over the window (`FrameTakeover`) is showing: the rail, header, banner and footer are hidden - not
148
+ * unmounted, so what is inside them (and the page in the content region) keeps its state. */
149
+ hideChrome?: boolean;
150
+ }
151
+
152
+ /**
153
+ * The persistent chrome shared by every webmail app (Mail, Calendar, Contacts, Tasks): a left icon rail for
154
+ * switching apps, a header with the current app's name and `UserMenu`, and the impersonation banner.
155
+ * Each app's own shell (e.g. `MailShell`) renders its own contextual sidebar + content as `children`, inside
156
+ * the area to the right of the icon rail and below the header.
157
+ *
158
+ * Rendered by `AppRouter`, once, for the life of the page, so that moving between apps replaces only `children` - see
159
+ * `AppShell` below for what a page's own shell renders instead.
160
+ */
161
+ export function AppChrome({
162
+ active,
163
+ userUid,
164
+ authServerUrl,
165
+ impersonating,
166
+ impersonationBaseUrl,
167
+ trusted,
168
+ trustedRoles,
169
+ branding: initialBranding,
170
+ appearance,
171
+ pluginNav,
172
+ routeKey,
173
+ busy,
174
+ hideChrome,
175
+ children,
176
+ }: PropsWithChildren<AppChromeProps>) {
177
+ const [stoppingImpersonation, setStoppingImpersonation] = useState(false);
178
+ // The keyboard shortcuts dialog: opened by `?`/Ctrl+/ (`GlobalShortcuts`) and by the account menu's item.
179
+ const [shortcutsOpen, setShortcutsOpen] = useState(false);
180
+ // The pop-up history ("Recent notifications" in the account menu). The pop-ups themselves are drawn by `NotificationCenter`, below.
181
+ const [historyOpen, setHistoryOpen] = useState(false);
182
+ // Only the count is read, so the whole frame does not render again for every pop-up that comes and goes.
183
+ const unseenErrors = useUnseenErrorCount();
184
+ // The title bar's height for the pop-up stack, which sticks just below the header (a branding header publishes its own - `FrameBrandingHeader`).
185
+ const headerRef = useHeaderHeightRef();
186
+ const signingOutRef = useRef(false);
187
+ const { branding: fetchedBranding, iconSrc: fetchedIconSrc } = useBranding();
188
+ // The server's copy until the fetch answers, so the frame's shape (a custom header replaces the title bar) never changes after the first paint.
189
+ const branding = fetchedBranding ?? initialBranding ?? null;
190
+ const iconSrc = fetchedBranding ? fetchedIconSrc : initialBranding?.iconUrl || initialBranding?.logoUrl || fetchedIconSrc;
191
+ // The custom header and footer, sanitized and with their `{USER_MENU}` / `{APP_TITLE}` placeholders (`undefined` until parsed, `null` when there is none).
192
+ const header = useBrandingHtml(branding?.headerHtml);
193
+ const footer = useBrandingHtml(branding?.footerHtml);
194
+ // The mailboxes, their folders and the one push connection live here, in the frame that stays mounted as the router swaps pages - so
195
+ // new-mail pop-ups, the folder counters and the tab title's unread count work in Calendar, Contacts, Tasks and Settings too, and moving
196
+ // between apps never opens a second socket (the server allows ten per user). `MailShell` reads them from `MailConnectionContext`. Outside
197
+ // the router (`AppShell` rendered as a page's own chrome: tests, plugin pages) it stays off, and a Mail shell owns its connection itself.
198
+ const inFrame = useInAppFrame();
199
+ const navigate = useNavigate();
200
+ const mail = useMailConnection({ userUid, enabled: inFrame, open: navigate });
201
+ // A signing certificate the user asked for is announced when it is issued (or fails), on whichever page they are - see the hook.
202
+ useSigningEnrollmentWatcher({ userUid, mailboxes: mail.mailboxes, enabled: inFrame });
203
+
204
+ useRedirectIfUnauthenticated(userUid, authServerUrl);
205
+ // Any request this app makes that the server answers with a 401 - the session ended - raises one "Your session expired" pop-up with a
206
+ // Sign in action (see `notifySessionExpired()`), whichever request noticed first, a background refresh included.
207
+ useEffect(() => {
208
+ setSignInUrl(authServerUrl);
209
+ if (!userUid) {
210
+ return;
211
+ }
212
+ setApiUnauthorizedObserver(() => void notifySessionExpired());
213
+ return () => setApiUnauthorizedObserver(undefined);
214
+ }, [userUid, authServerUrl]);
215
+ // Mounted here, not scoped to Mail/Settings (the only shells that actually read unlocked keys),
216
+ // specifically so activity in *any* app resets the idle clock - see that hook's own doc comment.
217
+ useIdleKeyTimeout();
218
+
219
+ // An administrator on a server that hasn't finished first-run setup is sent to the setup wizard. The status
220
+ // check is admin-only, so it's only made for a trusted caller - everyone else would just get a 403 on every
221
+ // page load. Any failure is ignored.
222
+ useEffect(() => {
223
+ if (!userUid || impersonating || !trusted) {
224
+ return;
225
+ }
226
+ getSetupStatus()
227
+ .then((status) => {
228
+ if (status.required) {
229
+ window.location.href = "/admin/setup";
230
+ }
231
+ })
232
+ .catch(() => undefined);
233
+ }, [userUid, impersonating, trusted]);
234
+
235
+ // Another tab signing out (this app's `handleSignOut`, or the admin/escrow consoles' `signOutOfConsole()`)
236
+ // ended this session too - its auth cookie is gone - so this tab destroys its own unlocked keys and every
237
+ // local search index on the device, then leaves as well. The consoles have no local-index client of their
238
+ // own, so this is what actually removes the indexes after a console sign-out (the console also records a
239
+ // pending deletion, retried on the next mail load, in case no mail tab is open). `destroyAllLocalIndexes()`
240
+ // announces the sign-out on this same channel, which this tab then hears itself, so the ref is set first:
241
+ // each tab reacts once, and the tab that started the sign-out ignores its own announcement.
242
+ useEffect(() => {
243
+ if (!userUid || typeof BroadcastChannel === "undefined") {
244
+ return;
245
+ }
246
+ const channel = new BroadcastChannel(SIGN_OUT_CHANNEL);
247
+ channel.addEventListener("message", (event: MessageEvent<{ type?: string }>) => {
248
+ if (event.data?.type !== "sign-out" || signingOutRef.current) {
249
+ return;
250
+ }
251
+ signingOutRef.current = true;
252
+ // Compose windows must not ask "Leave site?" - that would let this forced navigation be cancelled.
253
+ markSigningOut();
254
+ destroyUnlockedKeys();
255
+ clearPinnedSignerCache();
256
+ clearAppearanceCache();
257
+ // Bounded by its own timeout and never rejects - awaited so navigating doesn't kill the Worker mid-delete.
258
+ void destroyAllLocalIndexes().then(() => {
259
+ window.location.href = authServerUrl ?? "/";
260
+ });
261
+ });
262
+ return () => channel.close();
263
+ }, [userUid, authServerUrl]);
264
+
265
+ async function handleSignOut() {
266
+ signingOutRef.current = true;
267
+ // Before flushing and navigating: compose windows then skip their "Leave site?" prompt, which could
268
+ // otherwise cancel the sign-out's own navigation.
269
+ markSigningOut();
270
+ // Unlocked private keys never outlive an explicit sign-out.
271
+ destroyUnlockedKeys();
272
+ // Trusted signer pins read from contacts don't outlive the session either.
273
+ clearPinnedSignerCache();
274
+ clearAppearanceCache();
275
+ // Open compose windows save edits still waiting on their autosave debounce while the session is still
276
+ // valid - logout invalidates it. Bounded the same way as logout itself, and never rejects.
277
+ await flushComposeDrafts(LOGOUT_TIMEOUT_MS);
278
+ // The Tier 2 local index MUST be destroyed on explicit logout, the same as unlocked keys themselves
279
+ // (spec §11). Destroys every index on this device (not only mailboxes opened this page load) and is
280
+ // awaited before navigating - a navigation tears down the Worker mid-delete otherwise.
281
+ // destroyAllLocalIndexes() is bounded by its own timeout and never rejects, so sign-out can't hang.
282
+ // In parallel, auth-server's logout clears the auth cookie and invalidates the session's refresh
283
+ // token - without it, "Sign Out" would only navigate away from a still-valid session.
284
+ await Promise.all([destroyAllLocalIndexes(), logOutOfAuthServer(authServerUrl)]);
285
+ window.location.href = authServerUrl ?? "/";
286
+ }
287
+
288
+ async function handleStopImpersonating() {
289
+ setStoppingImpersonation(true);
290
+ try {
291
+ await stopImpersonating(impersonationBaseUrl ?? "");
292
+ } catch {
293
+ // Navigate either way: a failed call leaves the impersonator cookie (and this banner) exactly as
294
+ // they were, so there's nothing else useful to show — matching this app's other network-error
295
+ // handling, which surfaces via a full reload rather than an inline retry affordance.
296
+ } finally {
297
+ window.location.href = "/admin";
298
+ }
299
+ }
300
+
301
+ // What the persistent frame (`AppRouter`) needs on top of a page that never changes: the document title follows the page, and
302
+ // after the router replaces the page the keyboard focus, the scroll position and a screen reader are told about it - a
303
+ // page load did all of that by itself. Nothing here runs for a page shown outside the router (`routeKey` is undefined).
304
+ const contentRef = useRef<HTMLDivElement>(null);
305
+ const [announcement, setAnnouncement] = useState("");
306
+ const firstRouteKeyRef = useRef(routeKey);
307
+ const pageLabel = active === "settings" ? "Settings" : appRailItems(pluginNav).find((app) => app.id === active)?.label;
308
+ useEffect(() => {
309
+ if (routeKey !== undefined) {
310
+ const brand = branding?.title || branding?.companyName || "RapidMX";
311
+ document.title = pageLabel ? `${brand}: ${pageLabel}` : brand;
312
+ }
313
+ }, [routeKey, pageLabel, branding]);
314
+ // After the title effect above, so a page change (which rewrites the title) is followed by the unread count going back in front of it.
315
+ useUnreadTitle(inboxUnreadTotal(mail.mailboxFolders, mail.folderCounts.counts), {
316
+ enabled: inFrame,
317
+ resetKey: `${routeKey}|${pageLabel}|${branding?.title}|${branding?.companyName}`,
318
+ });
319
+ useEffect(() => {
320
+ if (routeKey === undefined || routeKey === firstRouteKeyRef.current) {
321
+ return;
322
+ }
323
+ setAnnouncement(pageLabel ?? "");
324
+ contentRef.current?.focus({ preventScroll: true });
325
+ window.scrollTo(0, 0);
326
+ }, [routeKey]);
327
+
328
+ if (!userUid) {
329
+ return <div className="min-h-screen" />;
330
+ }
331
+
332
+ const apps = appRailItems(pluginNav);
333
+ // The header title: "settings" has no rail item, everything else is labelled by its own rail item.
334
+ const activeLabel = active === "settings" ? "Settings" : apps.find((app) => app.id === active)?.label;
335
+ // A custom header (`Branding.headerHtml`) replaces the app's own title bar and the icon at the top of the rail: it is the top of the app, and the
336
+ // account menu moves into it. While it is still being parsed it already counts, so the frame's shape doesn't change under the user.
337
+ const customHeader = header !== null;
338
+ // Where the one account menu lives: the header's `{USER_MENU}`, else the footer's, else a small cell at the header's right end - never lost.
339
+ const menuInHeader = !!header?.hasUserMenu;
340
+ const menuInFooter = customHeader && !!header && !menuInHeader && !!footer?.hasUserMenu;
341
+ const renderUserMenu = (placement: "down" | "up") => (
342
+ <UserMenu
343
+ userUid={userUid}
344
+ authServerUrl={authServerUrl}
345
+ onSignOut={handleSignOut}
346
+ // An impersonating administrator acts as the impersonated user, so the console link is hidden then.
347
+ showAdminLink={!!trusted && !impersonating}
348
+ detectAdmin={!trusted && !impersonating}
349
+ trustedRoles={trustedRoles}
350
+ showSettingsLink
351
+ showNotificationSettings
352
+ onShowShortcuts={() => setShortcutsOpen(true)}
353
+ onShowNotifications={() => setHistoryOpen(true)}
354
+ unseenErrors={unseenErrors}
355
+ placement={placement}
356
+ />
357
+ );
358
+
359
+ return (
360
+ // Mounted here, not scoped to Mail/Settings, for the same reason as useIdleKeyTimeout() above -
361
+ // ComposeWindow's sign/encrypt toggles and MessageDetailPane's encrypted-message view (both Mail)
362
+ // are today's only useUnlockPrompt() callers, but this needs to be available to any app shell.
363
+ // Asks the server for the user's appearance only in the persistent frame (every core page); a page that renders its own chrome (a plugin's) uses the
364
+ // `appearance` it was given and what this browser cached.
365
+ <AppearanceProvider userUid={userUid} initial={appearance} lookUp={inFrame}>
366
+ <ShortcutProvider>
367
+ <MailConnectionContext.Provider value={inFrame ? mail : null}>
368
+ <GlobalShortcuts authServerUrl={authServerUrl} onToggleHelp={() => setShortcutsOpen((open) => !open)} />
369
+ <ShortcutsDialog open={shortcutsOpen} onClose={() => setShortcutsOpen(false)} />
370
+ <UnlockPromptProvider>
371
+ <UnlockBridge />
372
+ {/* An impersonating admin acts with the impersonated user's access, so their own trusted role
373
+ mustn't skip the per-mailbox checks. */}
374
+ <ComposeProvider userUid={userUid} trusted={!!trusted && !impersonating}>
375
+ <div className="rr-frame-bg min-h-screen flex flex-col">
376
+ {!hideChrome && customHeader && (
377
+ <FrameBrandingHeader
378
+ parsed={header}
379
+ userMenu={menuInHeader ? renderUserMenu("down") : undefined}
380
+ fallbackMenu={header && !menuInHeader && !menuInFooter ? renderUserMenu("down") : undefined}
381
+ appTitle={activeLabel}
382
+ />
383
+ )}
384
+ {impersonating && !hideChrome && (
385
+ <div className="h-10 shrink-0 bg-warning text-warning-contrast flex items-center justify-center gap-3 text-sm font-medium px-4">
386
+ <span>
387
+ You are viewing as <strong>{userUid}</strong>.
388
+ </span>
389
+ <button
390
+ type="button"
391
+ onClick={handleStopImpersonating}
392
+ disabled={stoppingImpersonation}
393
+ className="underline hover:no-underline disabled:opacity-60"
394
+ >
395
+ {stoppingImpersonation ? "Returning to admin…" : "Return to admin"}
396
+ </button>
397
+ </div>
398
+ )}
399
+ <div className="flex-1 flex min-h-0">
400
+ {!hideChrome && (
401
+ <nav
402
+ aria-label="Apps"
403
+ className={[
404
+ "hidden md:flex w-16 shrink-0 bg-surface border-r border-border flex-col items-center gap-1",
405
+ // Under a custom header the rail starts with the app icons; without one its own icon is flush with the top of the window.
406
+ customHeader ? "py-3" : "pb-3",
407
+ ].join(" ")}
408
+ >
409
+ {!customHeader && (
410
+ <RailIcon src={iconSrc} />
411
+ )}
412
+ {apps.map(({ id, href, label, icon: Icon }) => (
413
+ <a
414
+ key={id}
415
+ href={href}
416
+ aria-label={label}
417
+ aria-current={id === active ? "page" : undefined}
418
+ title={label}
419
+ className={[
420
+ "w-10 h-10 flex items-center justify-center rounded-sm",
421
+ id === active
422
+ ? "bg-primary/10 text-primary-dark"
423
+ : "text-text-muted hover:bg-surface-alt hover:text-text",
424
+ ].join(" ")}
425
+ >
426
+ <Icon size={20} aria-hidden="true" />
427
+ </a>
428
+ ))}
429
+ </nav>
430
+ )}
431
+ {!hideChrome && <BottomTabBar apps={apps} active={active} />}
432
+ <div className="flex-1 flex flex-col min-w-0">
433
+ {!hideChrome && !customHeader && (
434
+ <header ref={headerRef} className="rr-solid sticky top-0 z-30 h-16 shrink-0 bg-surface border-b border-border flex items-center justify-between gap-4 px-6">
435
+ <span className="font-display font-bold text-lg uppercase tracking-wide">{activeLabel}</span>
436
+ {renderUserMenu("down")}
437
+ </header>
438
+ )}
439
+ {/* The one pop-up stack for the whole app: right under the header row, so it never covers the account menu. */}
440
+ <NotificationCenter />
441
+ <div
442
+ ref={contentRef}
443
+ id="app-content"
444
+ tabIndex={-1}
445
+ aria-busy={busy || undefined}
446
+ className={["flex-1 flex min-h-0 outline-none", hideChrome ? "" : "pb-14 md:pb-0"].join(" ")}
447
+ >
448
+ {children}
449
+ </div>
450
+ </div>
451
+ </div>
452
+ {routeKey !== undefined && (
453
+ <div role="status" aria-live="polite" className="sr-only">
454
+ {announcement}
455
+ </div>
456
+ )}
457
+ {!hideChrome && <FrameBrandingFooter parsed={footer} userMenu={menuInFooter ? renderUserMenu("up") : undefined} appTitle={activeLabel} />}
458
+ </div>
459
+ </ComposeProvider>
460
+ </UnlockPromptProvider>
461
+ <NotificationHistoryDialog open={historyOpen} onClose={() => setHistoryOpen(false)} />
462
+ </MailConnectionContext.Provider>
463
+ </ShortcutProvider>
464
+ </AppearanceProvider>
465
+ );
466
+ }
467
+
468
+ /**
469
+ * What a page's own shell (`MailShell`, `CalendarShell`, ...) renders around its content. Outside the client-side router it
470
+ * is the whole `AppChrome`, as it always was. Inside it (`AppRouter`) the chrome is already mounted above the page - and stays
471
+ * mounted as the page is replaced - so this is only its children; everything it would have been given comes from the router
472
+ * frame instead (the props are the same for every page, and `active` is the route's).
473
+ */
474
+ export default function AppShell(props: PropsWithChildren<AppShellProps>) {
475
+ const inFrame = useInAppFrame();
476
+ return inFrame ? <>{props.children}</> : <AppChrome {...props} />;
477
+ }