@open-workspace/email 0.3.0 → 0.4.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 (221) hide show
  1. package/README.md +22 -22
  2. package/alchemy/index.ts +273 -0
  3. package/drizzle/mailbox/0000_puzzling_dracula.sql +149 -0
  4. package/drizzle/mailbox/0001_mute_jack_flag.sql +12 -0
  5. package/drizzle/mailbox/meta/0000_snapshot.json +1002 -0
  6. package/drizzle/mailbox/meta/0001_snapshot.json +1002 -0
  7. package/drizzle/mailbox/meta/_journal.json +20 -0
  8. package/drizzle/mailbox/migrations.js +12 -0
  9. package/index.ts +3 -1
  10. package/migrations/{0000_email.sql → 0000_dry_moon_knight.sql} +26 -20
  11. package/migrations/meta/0000_snapshot.json +125 -109
  12. package/migrations/meta/_journal.json +2 -2
  13. package/package.json +74 -68
  14. package/shared/attachment-preview.ts +37 -27
  15. package/shared/folder-order.ts +106 -0
  16. package/shared/mail-authentication.ts +8 -3
  17. package/shared/mail-feedback.ts +18 -25
  18. package/shared/mail-headers.ts +114 -39
  19. package/shared/mail-import.ts +38 -0
  20. package/shared/mail-path.ts +42 -0
  21. package/shared/mail-received.ts +174 -31
  22. package/shared/mail-remote.ts +59 -2
  23. package/shared/mail-sender-intel.ts +22 -4
  24. package/shared/mail.ts +77 -28
  25. package/shared/module.ts +33 -0
  26. package/shared/office-preview.ts +14 -2
  27. package/shared/pdfjs-assets.ts +35 -0
  28. package/shared/permissions.ts +73 -0
  29. package/shared/webhooks.ts +41 -0
  30. package/src/admin/blocked-senders.tsx +189 -0
  31. package/src/client.tsx +97 -0
  32. package/src/lib/mail-api.ts +9 -0
  33. package/src/mail/attachment-preview-dialog.tsx +161 -0
  34. package/src/mail/blocked-senders.tsx +138 -0
  35. package/src/mail/compose-window-chrome.tsx +194 -0
  36. package/src/mail/compose-window.tsx +486 -0
  37. package/src/mail/composer-asset-bookmarks.ts +409 -0
  38. package/src/mail/composer-asset.tsx +229 -0
  39. package/src/mail/composer-attachment-list.tsx +138 -0
  40. package/src/mail/composer-editor-document.ts +65 -0
  41. package/src/mail/composer-editor.tsx +284 -0
  42. package/src/mail/composer-linked-attachment-text.ts +12 -0
  43. package/src/mail/composer-recipient-fields.tsx +165 -0
  44. package/src/mail/composer-recipients.ts +208 -0
  45. package/src/mail/composer-session.ts +562 -0
  46. package/src/mail/composer-toolbar.tsx +303 -0
  47. package/src/mail/composer-upload-client.ts +105 -0
  48. package/src/mail/composer-upload-progress.ts +53 -0
  49. package/src/mail/conversation-list.tsx +550 -0
  50. package/src/mail/conversation-loading-skeleton.tsx +119 -0
  51. package/src/mail/conversation-message.tsx +346 -0
  52. package/src/mail/conversation-reply.tsx +470 -0
  53. package/src/mail/conversation-selection-toolbar.tsx +322 -0
  54. package/src/mail/conversation-view.tsx +437 -0
  55. package/src/mail/delivery-indicator.tsx +272 -0
  56. package/src/mail/email-html-body.tsx +203 -0
  57. package/src/mail/folder-glyph.tsx +46 -0
  58. package/src/mail/folder-manager.tsx +532 -0
  59. package/src/mail/format-bytes.ts +7 -0
  60. package/src/mail/mail-app-bar.tsx +253 -0
  61. package/src/mail/mail-background.tsx +12 -0
  62. package/src/mail/mail-dock.tsx +137 -0
  63. package/src/mail/mail-folders.ts +44 -0
  64. package/src/mail/mail-layout.css +236 -0
  65. package/src/mail/mail-location.ts +73 -0
  66. package/src/mail/mail-mailbox-sheet.tsx +275 -0
  67. package/src/mail/mail-nav-rail.tsx +129 -0
  68. package/src/mail/mail-nav.tsx +324 -0
  69. package/src/mail/mail-prefetch.ts +59 -0
  70. package/src/mail/mail-primitives.tsx +66 -0
  71. package/src/mail/mail-queries.ts +209 -0
  72. package/src/mail/mail-query-cache.ts +486 -0
  73. package/src/mail/mail-seed.ts +47 -0
  74. package/src/mail/mail-shell.tsx +126 -0
  75. package/src/mail/mailbox-ai-settings.tsx +185 -0
  76. package/src/mail/mailbox-realtime.tsx +251 -0
  77. package/src/mail/mailbox-route.tsx +15 -0
  78. package/src/mail/message-actions.tsx +353 -0
  79. package/src/mail/message-attachments.tsx +200 -0
  80. package/src/mail/message-format.ts +75 -0
  81. package/src/mail/message-header.tsx +260 -0
  82. package/src/mail/message-translation.tsx +225 -0
  83. package/src/mail/original-message-sheet.tsx +619 -0
  84. package/src/mail/original-message.ts +191 -0
  85. package/src/mail/outbound-notification.ts +53 -0
  86. package/src/mail/pane-splitter.tsx +117 -0
  87. package/src/mail/pdf-preview-toolbar.tsx +152 -0
  88. package/src/mail/pdf-preview.css +44 -0
  89. package/src/mail/pdf-preview.tsx +156 -0
  90. package/src/mail/pdf-translation-layout.ts +95 -0
  91. package/src/mail/print-message.ts +92 -0
  92. package/src/mail/reader-pane.tsx +535 -0
  93. package/src/mail/recipient-combobox.tsx +335 -0
  94. package/src/mail/recipient-field-row.tsx +34 -0
  95. package/src/mail/reply-to-warning.tsx +50 -0
  96. package/src/mail/sanitize-email-html.ts +430 -0
  97. package/src/mail/sender-actions.tsx +149 -0
  98. package/src/mail/sender-authentication.tsx +485 -0
  99. package/src/mail/sender-dialogs.tsx +384 -0
  100. package/src/mail/sender-security.tsx +545 -0
  101. package/src/mail/toolbar-tooltip.tsx +29 -0
  102. package/src/mail/translation-html.ts +49 -0
  103. package/src/mail/translation-language.ts +21 -0
  104. package/src/mail/types.ts +53 -0
  105. package/src/mail/unread-document-indicator.tsx +60 -0
  106. package/src/mail/use-compose-submission.ts +208 -0
  107. package/src/mail/use-composer-attachment-preflight.ts +184 -0
  108. package/src/mail/use-composer-submission.ts +117 -0
  109. package/src/mail/use-conversation-selection.ts +186 -0
  110. package/src/mail/use-mail-controller.ts +427 -0
  111. package/src/mail/use-mail-data.ts +279 -0
  112. package/src/mail/use-mail-safety.ts +155 -0
  113. package/src/mail/use-mail-send.ts +142 -0
  114. package/src/mail/use-pdf-translation-overlay.ts +156 -0
  115. package/src/mail/use-pdf-translation.ts +100 -0
  116. package/src/mail/use-pdf-viewer.ts +215 -0
  117. package/src/mail/use-reply-submission.ts +114 -0
  118. package/src/mail/use-sanitized-email-html.ts +20 -0
  119. package/src/mail/use-visible-message-read.ts +138 -0
  120. package/src/pwa/push-subscription.ts +151 -0
  121. package/src/settings/mail-apps-page.tsx +235 -0
  122. package/src/settings/notifications-page.tsx +291 -0
  123. package/worker/admin/blocked-sender-routes.ts +166 -0
  124. package/worker/admin/schemas.ts +11 -0
  125. package/worker/bindings.d.ts +14 -10
  126. package/worker/db/schema.ts +63 -40
  127. package/worker/jmap/eventsource.ts +84 -16
  128. package/worker/jmap/methods.ts +1630 -524
  129. package/worker/jmap/push-types.ts +27 -0
  130. package/worker/jmap/push.ts +140 -56
  131. package/worker/jmap/routes.ts +366 -105
  132. package/worker/mail/access.ts +258 -21
  133. package/worker/mail/ai-classification.ts +36 -20
  134. package/worker/mail/ai-translation.ts +13 -6
  135. package/worker/mail/auth-headers.ts +395 -137
  136. package/worker/mail/bimi.ts +200 -73
  137. package/worker/mail/bootstrap.ts +79 -0
  138. package/worker/mail/capped-body.ts +36 -0
  139. package/worker/mail/classification-signals.ts +35 -25
  140. package/worker/mail/conversation-cursor.ts +30 -19
  141. package/worker/mail/delivery-events.ts +88 -62
  142. package/worker/mail/delivery-facts.ts +46 -10
  143. package/worker/mail/demo-routes.ts +34 -10
  144. package/worker/mail/doh.ts +62 -23
  145. package/worker/mail/downloads.ts +75 -40
  146. package/worker/mail/edge-cache.ts +155 -0
  147. package/worker/mail/header-metadata.ts +88 -22
  148. package/worker/mail/impersonation.ts +160 -38
  149. package/worker/mail/import-routes.ts +313 -0
  150. package/worker/mail/inbound-delivery.ts +19 -9
  151. package/worker/mail/inbound-threading.ts +18 -8
  152. package/worker/mail/inbound.ts +82 -40
  153. package/worker/mail/ip-intel.ts +110 -27
  154. package/worker/mail/isolate-cache.ts +35 -0
  155. package/worker/mail/link-domains.ts +29 -7
  156. package/worker/mail/mailbox-deletion.ts +10 -4
  157. package/worker/mail/mailbox-directory.ts +16 -6
  158. package/worker/mail/mailing-list.ts +94 -39
  159. package/worker/mail/message-security.ts +90 -15
  160. package/worker/mail/message-view.ts +18 -6
  161. package/worker/mail/office-conversion.ts +31 -9
  162. package/worker/mail/office-preview-container.ts +40 -13
  163. package/worker/mail/office-preview-queue.ts +76 -32
  164. package/worker/mail/org-domain.ts +8 -1
  165. package/worker/mail/outbound-content.ts +71 -26
  166. package/worker/mail/outbound-delivery.ts +31 -17
  167. package/worker/mail/outbound-service.ts +48 -30
  168. package/worker/mail/outbound-threading.ts +30 -17
  169. package/worker/mail/outbound.ts +97 -70
  170. package/worker/mail/outgoing-context.ts +25 -15
  171. package/worker/mail/participants.ts +44 -29
  172. package/worker/mail/push-notifications.ts +271 -173
  173. package/worker/mail/quote-parser.ts +21 -10
  174. package/worker/mail/r2-presigned-urls.ts +31 -25
  175. package/worker/mail/receive.ts +23 -11
  176. package/worker/mail/recipients.ts +6 -1
  177. package/worker/mail/remote-proxy.ts +187 -31
  178. package/worker/mail/remote-routes.ts +87 -0
  179. package/worker/mail/remote-token.ts +104 -0
  180. package/worker/mail/repeat.ts +19 -0
  181. package/worker/mail/reply-plan.ts +62 -33
  182. package/worker/mail/rfc.ts +32 -7
  183. package/worker/mail/routes.ts +870 -541
  184. package/worker/mail/safety-routes.ts +328 -200
  185. package/worker/mail/schemas.ts +84 -105
  186. package/worker/mail/search.ts +1 -0
  187. package/worker/mail/security-settings.ts +41 -9
  188. package/worker/mail/sender-intel.ts +206 -51
  189. package/worker/mail/spamhaus.ts +92 -45
  190. package/worker/mail/unsubscribe.ts +76 -18
  191. package/worker/mail/uploads.ts +126 -93
  192. package/worker/mail/webhook-source.ts +35 -12
  193. package/worker/mail/workspace-safety.ts +97 -38
  194. package/worker/mailbox/demo-html.ts +7 -7
  195. package/worker/mailbox/demo-seed.ts +10 -44
  196. package/worker/mailbox/demo.ts +595 -225
  197. package/worker/mailbox/email-index.ts +53 -0
  198. package/worker/mailbox/folder-model.ts +53 -17
  199. package/worker/mailbox/import-placement.ts +88 -0
  200. package/worker/mailbox/inbox-counts.ts +106 -0
  201. package/worker/mailbox/index.ts +1734 -721
  202. package/worker/mailbox/jmap-store.ts +139 -35
  203. package/worker/mailbox/model.ts +8 -6
  204. package/worker/mailbox/office-preview-jobs.ts +56 -25
  205. package/worker/mailbox/schema.ts +87 -66
  206. package/worker/mailbox/senders.ts +176 -70
  207. package/worker/mcp/mail-action-tools.ts +128 -87
  208. package/worker/mcp/mail-compose-tools.ts +133 -82
  209. package/worker/mcp/mail-query-tools.ts +120 -71
  210. package/worker/mcp/mail-safety-tools.ts +321 -248
  211. package/worker/mcp/schemas.ts +43 -0
  212. package/worker/mcp/tools.ts +13 -10
  213. package/worker/module.ts +43 -18
  214. package/worker/sql.d.ts +8 -0
  215. package/alchemy.ts +0 -142
  216. package/containers/office-preview/Dockerfile +0 -10
  217. package/shared/mail-rules.ts +0 -156
  218. package/worker/admin/report-routes.ts +0 -164
  219. package/worker/mail/reported-messages.ts +0 -68
  220. package/worker/mailbox/migrations.ts +0 -10
  221. package/worker/mailbox/rules.ts +0 -110
@@ -0,0 +1,346 @@
1
+ import { Button, cn } from "@open-workspace/core/ui";
2
+ import { ChevronDown, Ellipsis, Eye, Paperclip, RotateCw } from "lucide-react";
3
+ import { useState } from "react";
4
+
5
+ import { DeliveryIndicator } from "./delivery-indicator";
6
+ import { canRetry, MessageActions } from "./message-actions";
7
+ import type { MessageHandlers } from "./message-actions";
8
+ import { MessageAttachments } from "./message-attachments";
9
+ import {
10
+ compactDate,
11
+ fullDate,
12
+ isOwnAddress,
13
+ listFormat,
14
+ recipientSummary,
15
+ senderName,
16
+ shortDate,
17
+ } from "./message-format";
18
+ import { MessageDetails, SenderLine } from "./message-header";
19
+ import {
20
+ MessageBody,
21
+ TranslationBar,
22
+ useMessageTranslation,
23
+ } from "./message-translation";
24
+ import {
25
+ SenderAvatar,
26
+ SenderSecurityBanner,
27
+ SenderStatusNotice,
28
+ SubscriptionAction,
29
+ } from "./sender-security";
30
+ import type { Mailbox, MessageDetail } from "./types";
31
+ import { useVisibleMessageRead } from "./use-visible-message-read";
32
+
33
+ /**
34
+ * One message in the conversation stack: a one-line summary while collapsed,
35
+ * a full header, body, attachments and actions while expanded.
36
+ */
37
+ export function ConversationMessage({
38
+ message,
39
+ mailbox,
40
+ defaultExpanded,
41
+ collapsible,
42
+ showViewedBy,
43
+ resendPending,
44
+ handlers,
45
+ }: {
46
+ message: MessageDetail;
47
+ mailbox?: Mailbox;
48
+ defaultExpanded: boolean;
49
+ collapsible: boolean;
50
+ showViewedBy: boolean;
51
+ resendPending: boolean;
52
+ handlers: MessageHandlers;
53
+ }) {
54
+ const [expanded, setExpanded] = useState(defaultExpanded);
55
+ const shown = expanded || !collapsible;
56
+ const outgoing = message.direction === "outgoing";
57
+
58
+ const visibilityRef = useVisibleMessageRead({
59
+ enabled: !message.isRead && (!outgoing || showViewedBy),
60
+ messageId: message.id,
61
+ onVisible: handlers.onViewed,
62
+ });
63
+
64
+ return (
65
+ <section
66
+ ref={visibilityRef}
67
+ data-message-id={message.id}
68
+ data-expanded={shown || undefined}
69
+ className="group/message border-border relative border-t first:border-t-0"
70
+ >
71
+ {outgoing && (
72
+ <span
73
+ aria-hidden="true"
74
+ className="bg-primary/55 absolute inset-y-0 left-0 w-0.5"
75
+ />
76
+ )}
77
+ {shown ? (
78
+ <ExpandedMessage
79
+ message={message}
80
+ mailbox={mailbox}
81
+ showViewedBy={showViewedBy}
82
+ resendPending={resendPending}
83
+ handlers={handlers}
84
+ onCollapse={collapsible ? () => setExpanded(false) : undefined}
85
+ />
86
+ ) : (
87
+ <CollapsedMessage
88
+ message={message}
89
+ mailbox={mailbox}
90
+ onExpand={() => setExpanded(true)}
91
+ />
92
+ )}
93
+ </section>
94
+ );
95
+ }
96
+
97
+ function CollapsedMessage({
98
+ message,
99
+ mailbox,
100
+ onExpand,
101
+ }: {
102
+ message: MessageDetail;
103
+ mailbox?: Mailbox;
104
+ onExpand: () => void;
105
+ }) {
106
+ const sender = senderName(message);
107
+ const own = isOwnAddress(message.fromAddress, mailbox);
108
+
109
+ return (
110
+ <button
111
+ type="button"
112
+ aria-expanded="false"
113
+ aria-label={`Show message from ${sender}, ${shortDate(message.timelineAt)}`}
114
+ onClick={onExpand}
115
+ className="focus-visible:ring-ring flex w-full items-center gap-3 px-4 py-2.5 text-left transition-colors outline-none hover:bg-(--row-hover) focus-visible:bg-(--row-hover) focus-visible:ring-2 focus-visible:ring-inset sm:px-6"
116
+ >
117
+ <SenderAvatar
118
+ name={sender}
119
+ logoUrl={message.senderLogoUrl}
120
+ className="size-7 rounded-full text-[10.5px]"
121
+ />
122
+ <span className="flex max-w-[45%] shrink-0 items-baseline gap-1.5 truncate">
123
+ <span className="truncate text-[13px] font-semibold">{sender}</span>
124
+ {own && (
125
+ <span className="text-muted-foreground text-[11px] font-medium">
126
+ You
127
+ </span>
128
+ )}
129
+ </span>
130
+ <span className="text-muted-foreground min-w-0 flex-1 truncate text-[13px]">
131
+ {message.preview || message.bodyText || "No text body"}
132
+ </span>
133
+ {message.attachments.length > 0 && (
134
+ <Paperclip
135
+ aria-label="Has attachments"
136
+ className="text-muted-foreground size-3.5 shrink-0"
137
+ />
138
+ )}
139
+ <time
140
+ dateTime={new Date(message.timelineAt).toISOString()}
141
+ className="text-muted-foreground shrink-0 text-xs tabular-nums"
142
+ >
143
+ {compactDate(message.timelineAt)}
144
+ </time>
145
+ </button>
146
+ );
147
+ }
148
+
149
+ function ExpandedMessage({
150
+ message,
151
+ mailbox,
152
+ showViewedBy,
153
+ resendPending,
154
+ handlers,
155
+ onCollapse,
156
+ }: {
157
+ message: MessageDetail;
158
+ mailbox?: Mailbox;
159
+ showViewedBy: boolean;
160
+ resendPending: boolean;
161
+ handlers: MessageHandlers;
162
+ onCollapse?: () => void;
163
+ }) {
164
+ const [detailsOpen, setDetailsOpen] = useState(false);
165
+ const translation = useMessageTranslation(message, mailbox?.id);
166
+ const sender = senderName(message);
167
+ const own = isOwnAddress(message.fromAddress, mailbox);
168
+ const outgoing = message.direction === "outgoing";
169
+
170
+ const viewedBy = showViewedBy
171
+ ? message.viewedBy.map((viewer) => viewer.name)
172
+ : [];
173
+
174
+ return (
175
+ <div className="animate-fade-in px-4 pt-4 pb-5 sm:px-6">
176
+ <header className="flex items-start gap-3">
177
+ <SenderAvatar
178
+ name={sender}
179
+ logoUrl={message.senderLogoUrl}
180
+ className="mt-0.5 size-9 rounded-full text-[12px]"
181
+ />
182
+ <div className="min-w-0 flex-1">
183
+ <div className="flex min-h-7 items-center gap-2">
184
+ <div className="flex min-w-0 flex-1 items-center gap-2">
185
+ <SenderLine
186
+ message={message}
187
+ sender={sender}
188
+ own={own}
189
+ onCollapse={onCollapse}
190
+ />
191
+ <SubscriptionAction
192
+ message={message}
193
+ onUnsubscribe={handlers.sender?.onUnsubscribe}
194
+ />
195
+ </div>
196
+ <span className="text-muted-foreground flex shrink-0 items-center gap-2.5 text-xs">
197
+ {outgoing && <DeliveryIndicator message={message} />}
198
+ <time
199
+ dateTime={new Date(message.timelineAt).toISOString()}
200
+ title={fullDate(message.timelineAt)}
201
+ className="tabular-nums"
202
+ >
203
+ {shortDate(message.timelineAt)}
204
+ </time>
205
+ </span>
206
+ <MessageActions
207
+ message={message}
208
+ canForward={Boolean(mailbox?.canSend)}
209
+ mailboxId={mailbox?.id}
210
+ translation={translation}
211
+ resendPending={resendPending}
212
+ handlers={handlers}
213
+ />
214
+ </div>
215
+ <button
216
+ type="button"
217
+ aria-expanded={detailsOpen}
218
+ onClick={() => setDetailsOpen((open) => !open)}
219
+ className="text-muted-foreground hover:text-foreground focus-visible:ring-ring -mt-0.5 flex max-w-full min-w-0 items-center gap-1 rounded-sm text-left text-xs outline-none focus-visible:ring-2"
220
+ >
221
+ <span className="truncate">
222
+ {recipientSummary(message, mailbox)}
223
+ </span>
224
+ <ChevronDown
225
+ className={cn(
226
+ "size-3 shrink-0 transition-transform",
227
+ detailsOpen && "rotate-180"
228
+ )}
229
+ />
230
+ <span className="sr-only">
231
+ {detailsOpen ? "Hide message details" : "Show message details"}
232
+ </span>
233
+ </button>
234
+ </div>
235
+ </header>
236
+
237
+ {detailsOpen && (
238
+ <MessageDetails
239
+ message={message}
240
+ onShowOriginal={handlers.onShowOriginal}
241
+ />
242
+ )}
243
+
244
+ <SenderStatusNotice
245
+ message={message}
246
+ onUnblock={handlers.sender?.onUnblock}
247
+ />
248
+ <SenderSecurityBanner
249
+ message={message}
250
+ onShowOriginal={handlers.onShowOriginal}
251
+ onTrust={handlers.sender?.onTrust}
252
+ />
253
+
254
+ {canRetry(message) && (
255
+ <RetryNotice
256
+ message={message}
257
+ pending={resendPending}
258
+ onResend={handlers.onResend}
259
+ />
260
+ )}
261
+
262
+ <div className="mt-4 min-w-0 @lg/reader:pl-12">
263
+ <TranslationBar translation={translation} />
264
+ <MessageBody
265
+ message={message}
266
+ mailboxId={mailbox?.id}
267
+ translation={translation}
268
+ />
269
+ {message.quotedText && <QuotedText text={message.quotedText} />}
270
+ <MessageAttachments
271
+ messageId={message.id}
272
+ mailboxId={mailbox?.id}
273
+ attachments={message.attachments}
274
+ />
275
+ {viewedBy.length > 0 && (
276
+ <p className="text-muted-foreground mt-4 flex items-center gap-1.5 text-xs">
277
+ <Eye className="size-3.5" />
278
+ <span>Viewed by {listFormat(viewedBy)}</span>
279
+ </p>
280
+ )}
281
+ </div>
282
+ </div>
283
+ );
284
+ }
285
+
286
+ function RetryNotice({
287
+ message,
288
+ pending,
289
+ onResend,
290
+ }: {
291
+ message: MessageDetail;
292
+ pending: boolean;
293
+ onResend: () => void;
294
+ }) {
295
+ const failed = message.transportState === "failed";
296
+
297
+ return (
298
+ <div
299
+ className={cn(
300
+ "mt-3 flex items-center gap-3 rounded-md px-3 py-2 text-xs @lg/reader:ml-12",
301
+ failed
302
+ ? "bg-destructive/8 text-destructive"
303
+ : "bg-warning/12 text-amber-800 dark:text-amber-300"
304
+ )}
305
+ >
306
+ <span className="min-w-0 flex-1">
307
+ {failed
308
+ ? message.transportError || "This message could not be sent."
309
+ : "Submission was not confirmed. Sending again may deliver a duplicate."}
310
+ </span>
311
+ <Button
312
+ type="button"
313
+ size="xs"
314
+ variant="outline"
315
+ disabled={pending}
316
+ onClick={onResend}
317
+ >
318
+ <RotateCw className={cn(pending && "animate-spin")} />
319
+ {failed ? "Retry" : "Send again"}
320
+ </Button>
321
+ </div>
322
+ );
323
+ }
324
+
325
+ function QuotedText({ text }: { text: string }) {
326
+ const [open, setOpen] = useState(false);
327
+
328
+ return (
329
+ <div className="mt-3">
330
+ <button
331
+ type="button"
332
+ aria-expanded={open}
333
+ onClick={() => setOpen((value) => !value)}
334
+ className="bg-muted text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:ring-ring inline-flex h-5 items-center gap-1 rounded-full px-2 text-[11px] font-medium transition-colors outline-none focus-visible:ring-2"
335
+ >
336
+ <Ellipsis className="size-3.5" />
337
+ {open ? "Hide quoted text" : "Show quoted text"}
338
+ </button>
339
+ {open && (
340
+ <blockquote className="border-border text-muted-foreground mt-2 max-h-80 max-w-[72ch] overflow-auto border-l-2 pl-3 text-[13px] leading-[1.6] whitespace-pre-wrap">
341
+ {text}
342
+ </blockquote>
343
+ )}
344
+ </div>
345
+ );
346
+ }