@remit/ui 0.0.200 → 0.0.202

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.
@@ -0,0 +1,237 @@
1
+ import "@remit/test-dom";
2
+ import assert from "node:assert/strict";
3
+ import { afterEach, beforeEach, describe, it } from "node:test";
4
+ import { act, createElement } from "react";
5
+ import { createRoot, type Root } from "react-dom/client";
6
+ import {
7
+ FolderMutationDialog,
8
+ type FolderMutationDialogProps,
9
+ type FolderMutationPhase,
10
+ } from "./folder-mutation-dialog.js";
11
+
12
+ let container: HTMLElement;
13
+ let root: Root;
14
+
15
+ beforeEach(() => {
16
+ container = document.createElement("div");
17
+ document.body.appendChild(container);
18
+ root = createRoot(container);
19
+ });
20
+
21
+ afterEach(() => {
22
+ act(() => root.unmount());
23
+ container.remove();
24
+ });
25
+
26
+ const render = (
27
+ props: Partial<FolderMutationDialogProps> & {
28
+ intent: "rename" | "delete";
29
+ phase: FolderMutationPhase;
30
+ },
31
+ handlers: {
32
+ onRetry?: () => void;
33
+ onRefresh?: () => void;
34
+ onClose?: () => void;
35
+ } = {},
36
+ ) => {
37
+ act(() => {
38
+ root.render(
39
+ createElement(FolderMutationDialog, {
40
+ open: true,
41
+ folderName: "Receipts",
42
+ targetName: "Q3 Receipts",
43
+ onRetry: handlers.onRetry ?? (() => undefined),
44
+ onRefresh: handlers.onRefresh ?? (() => undefined),
45
+ onClose: handlers.onClose ?? (() => undefined),
46
+ ...props,
47
+ }) as never,
48
+ );
49
+ });
50
+ };
51
+
52
+ const buttonByText = (re: RegExp): HTMLButtonElement | undefined =>
53
+ Array.from(container.querySelectorAll("button")).find((button) =>
54
+ re.test(button.textContent ?? ""),
55
+ );
56
+
57
+ const allButtonLabels = (): string[] =>
58
+ Array.from(container.querySelectorAll("button")).map(
59
+ (button) => button.getAttribute("aria-label") ?? button.textContent ?? "",
60
+ );
61
+
62
+ describe("FolderMutationDialog", () => {
63
+ it("renders nothing when closed", () => {
64
+ render({ open: false, intent: "rename", phase: { kind: "waiting" } });
65
+ assert.equal(container.textContent, "");
66
+ });
67
+
68
+ it("renders the rename waiting phase", () => {
69
+ render({ intent: "rename", phase: { kind: "waiting" } });
70
+ assert.match(container.textContent ?? "", /Renaming folder/);
71
+ assert.match(
72
+ container.textContent ?? "",
73
+ /Renaming “Receipts” to “Q3 Receipts” on the mail server…/,
74
+ );
75
+ });
76
+
77
+ it("renders the rename timed-out phase", () => {
78
+ render({ intent: "rename", phase: { kind: "timed-out" } });
79
+ assert.match(container.textContent ?? "", /Still renaming/);
80
+ assert.match(
81
+ container.textContent ?? "",
82
+ /“Receipts” is still being renamed\. It will finish on its own — you can close this and keep working\. The folder shows “Renaming…” until it does\./,
83
+ );
84
+ });
85
+
86
+ it("renders the rename failed phase", () => {
87
+ render({
88
+ intent: "rename",
89
+ phase: { kind: "failed", serverMessage: "Mailbox already exists" },
90
+ });
91
+ assert.match(container.textContent ?? "", /Rename failed/);
92
+ assert.match(
93
+ container.textContent ?? "",
94
+ /Couldn’t rename “Receipts”\. The mail server refused: Mailbox already exists\. The folder is unchanged\./,
95
+ );
96
+ });
97
+
98
+ it("renders the rename conflict phase", () => {
99
+ render({ intent: "rename", phase: { kind: "conflict" } });
100
+ assert.match(container.textContent ?? "", /Already in progress/);
101
+ assert.match(
102
+ container.textContent ?? "",
103
+ /Something else is already renaming or deleting “Receipts”\. Refresh to see where it got to\./,
104
+ );
105
+ });
106
+
107
+ it("renders the delete waiting phase", () => {
108
+ render({ intent: "delete", phase: { kind: "waiting" } });
109
+ assert.match(container.textContent ?? "", /Deleting folder/);
110
+ assert.match(
111
+ container.textContent ?? "",
112
+ /Deleting “Receipts” and everything in it from the mail server…/,
113
+ );
114
+ });
115
+
116
+ it("renders the delete timed-out phase", () => {
117
+ render({ intent: "delete", phase: { kind: "timed-out" } });
118
+ assert.match(container.textContent ?? "", /Still deleting/);
119
+ assert.match(
120
+ container.textContent ?? "",
121
+ /“Receipts” is still being deleted\. It will finish on its own — you can close this\. The folder shows “Deleting…” until it does\./,
122
+ );
123
+ });
124
+
125
+ it("renders the delete failed phase", () => {
126
+ render({
127
+ intent: "delete",
128
+ phase: { kind: "failed", serverMessage: "Mailbox has children" },
129
+ });
130
+ assert.match(container.textContent ?? "", /Delete failed/);
131
+ assert.match(
132
+ container.textContent ?? "",
133
+ /Couldn’t delete “Receipts”\. The mail server refused: Mailbox has children\. Nothing was deleted\./,
134
+ );
135
+ });
136
+
137
+ it("renders the delete conflict phase, with the order of intents swapped", () => {
138
+ render({ intent: "delete", phase: { kind: "conflict" } });
139
+ assert.match(container.textContent ?? "", /Already in progress/);
140
+ assert.match(
141
+ container.textContent ?? "",
142
+ /Something else is already deleting or renaming “Receipts”\. Refresh to see where it got to\./,
143
+ );
144
+ });
145
+
146
+ it("renders a server message verbatim, including characters that would need escaping", () => {
147
+ const serverMessage = "Refused: <INBOX/Sub> & \"quoted\" 'name'";
148
+ render({
149
+ intent: "rename",
150
+ phase: { kind: "failed", serverMessage },
151
+ });
152
+ const paragraph = container.querySelector("p");
153
+ assert.ok(paragraph, "the body paragraph is present");
154
+ assert.match(paragraph?.textContent ?? "", /Refused: <INBOX\/Sub>/);
155
+ assert.match(paragraph?.textContent ?? "", /& "quoted" 'name'/);
156
+ });
157
+
158
+ it("never renders a control labelled Cancel, across every phase and intent", () => {
159
+ const phases: FolderMutationPhase[] = [
160
+ { kind: "waiting" },
161
+ { kind: "timed-out" },
162
+ { kind: "failed", serverMessage: "The mail server refused." },
163
+ { kind: "conflict" },
164
+ ];
165
+ for (const intent of ["rename", "delete"] as const) {
166
+ for (const phase of phases) {
167
+ render({ intent, phase });
168
+ for (const label of allButtonLabels()) {
169
+ assert.doesNotMatch(label, /cancel/i);
170
+ }
171
+ }
172
+ }
173
+ });
174
+
175
+ it("fires onRetry from Try again, and Close does not fire onRetry", () => {
176
+ let retried = false;
177
+ let closed = false;
178
+ render(
179
+ {
180
+ intent: "rename",
181
+ phase: { kind: "failed", serverMessage: "The mail server refused." },
182
+ },
183
+ {
184
+ onRetry: () => {
185
+ retried = true;
186
+ },
187
+ onClose: () => {
188
+ closed = true;
189
+ },
190
+ },
191
+ );
192
+ act(() => buttonByText(/^Close$/)?.click());
193
+ assert.equal(closed, true, "Close fires onClose");
194
+ assert.equal(retried, false, "Close does not fire onRetry");
195
+
196
+ closed = false;
197
+ act(() => buttonByText(/^Try again$/)?.click());
198
+ assert.equal(retried, true, "Try again fires onRetry");
199
+ });
200
+
201
+ it("fires onRefresh from Refresh", () => {
202
+ let refreshed = false;
203
+ render(
204
+ { intent: "delete", phase: { kind: "conflict" } },
205
+ {
206
+ onRefresh: () => {
207
+ refreshed = true;
208
+ },
209
+ },
210
+ );
211
+ act(() => buttonByText(/^Refresh$/)?.click());
212
+ assert.equal(refreshed, true);
213
+ });
214
+
215
+ const footerLabels = (): string[] =>
216
+ allButtonLabels().filter((label) => label !== "Dismiss dialog");
217
+
218
+ it("offers Close alone while waiting, and fires onClose", () => {
219
+ let closed = false;
220
+ render(
221
+ { intent: "rename", phase: { kind: "waiting" } },
222
+ {
223
+ onClose: () => {
224
+ closed = true;
225
+ },
226
+ },
227
+ );
228
+ assert.deepEqual(footerLabels(), ["Close"]);
229
+ act(() => buttonByText(/^Close$/)?.click());
230
+ assert.equal(closed, true);
231
+ });
232
+
233
+ it("offers Refresh alone on conflict", () => {
234
+ render({ intent: "rename", phase: { kind: "conflict" } });
235
+ assert.deepEqual(footerLabels(), ["Refresh"]);
236
+ });
237
+ });
@@ -0,0 +1,72 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { FolderMutationDialog } from "./folder-mutation-dialog.js";
3
+
4
+ const meta: Meta<typeof FolderMutationDialog> = {
5
+ title: "Design System/Mail/FolderMutationDialog",
6
+ tags: ["proposed"],
7
+ component: FolderMutationDialog,
8
+ parameters: { layout: "fullscreen" },
9
+ args: {
10
+ open: true,
11
+ folderName: "Receipts",
12
+ targetName: "Q3 Receipts",
13
+ onRetry: () => undefined,
14
+ onRefresh: () => undefined,
15
+ onClose: () => undefined,
16
+ },
17
+ };
18
+ export default meta;
19
+
20
+ type Story = StoryObj<typeof FolderMutationDialog>;
21
+
22
+ export const RenameWaiting: Story = {
23
+ name: "Rename — waiting",
24
+ args: { intent: "rename", phase: { kind: "waiting" } },
25
+ };
26
+
27
+ export const RenameTimedOut: Story = {
28
+ name: "Rename — timed out",
29
+ args: { intent: "rename", phase: { kind: "timed-out" } },
30
+ };
31
+
32
+ export const RenameFailed: Story = {
33
+ name: "Rename — failed",
34
+ args: {
35
+ intent: "rename",
36
+ phase: {
37
+ kind: "failed",
38
+ serverMessage: "Mailbox already exists at that path.",
39
+ },
40
+ },
41
+ };
42
+
43
+ export const RenameConflict: Story = {
44
+ name: "Rename — conflict",
45
+ args: { intent: "rename", phase: { kind: "conflict" } },
46
+ };
47
+
48
+ export const DeleteWaiting: Story = {
49
+ name: "Delete — waiting",
50
+ args: { intent: "delete", phase: { kind: "waiting" } },
51
+ };
52
+
53
+ export const DeleteTimedOut: Story = {
54
+ name: "Delete — timed out",
55
+ args: { intent: "delete", phase: { kind: "timed-out" } },
56
+ };
57
+
58
+ export const DeleteFailed: Story = {
59
+ name: "Delete — failed",
60
+ args: {
61
+ intent: "delete",
62
+ phase: {
63
+ kind: "failed",
64
+ serverMessage: "The mailbox has folders inside it.",
65
+ },
66
+ },
67
+ };
68
+
69
+ export const DeleteConflict: Story = {
70
+ name: "Delete — conflict",
71
+ args: { intent: "delete", phase: { kind: "conflict" } },
72
+ };
@@ -0,0 +1,111 @@
1
+ import { AlertTriangle, Loader2 } from "lucide-react";
2
+ import { Button } from "./button.js";
3
+ import { Dialog } from "./dialog.js";
4
+
5
+ export type FolderMutationPhase =
6
+ | { kind: "waiting" }
7
+ | { kind: "timed-out" }
8
+ | { kind: "failed"; serverMessage: string }
9
+ | { kind: "conflict" };
10
+
11
+ export interface FolderMutationDialogProps {
12
+ open: boolean;
13
+ intent: "rename" | "delete";
14
+ folderName: string;
15
+ targetName?: string;
16
+ phase: FolderMutationPhase;
17
+ onRetry: () => void;
18
+ onRefresh: () => void;
19
+ onClose: () => void;
20
+ }
21
+
22
+ function dialogTitle(
23
+ intent: "rename" | "delete",
24
+ phase: FolderMutationPhase,
25
+ ): string {
26
+ if (phase.kind === "conflict") return "Already in progress";
27
+ if (intent === "rename") {
28
+ if (phase.kind === "waiting") return "Renaming folder";
29
+ if (phase.kind === "timed-out") return "Still renaming";
30
+ return "Rename failed";
31
+ }
32
+ if (phase.kind === "waiting") return "Deleting folder";
33
+ if (phase.kind === "timed-out") return "Still deleting";
34
+ return "Delete failed";
35
+ }
36
+
37
+ function dialogBody(
38
+ intent: "rename" | "delete",
39
+ folderName: string,
40
+ targetName: string | undefined,
41
+ phase: FolderMutationPhase,
42
+ ): string {
43
+ if (phase.kind === "waiting") {
44
+ return intent === "rename"
45
+ ? `Renaming “${folderName}” to “${targetName}” on the mail server…`
46
+ : `Deleting “${folderName}” and everything in it from the mail server…`;
47
+ }
48
+ if (phase.kind === "timed-out") {
49
+ return intent === "rename"
50
+ ? `“${folderName}” is still being renamed. It will finish on its own — you can close this and keep working. The folder shows “Renaming…” until it does.`
51
+ : `“${folderName}” is still being deleted. It will finish on its own — you can close this. The folder shows “Deleting…” until it does.`;
52
+ }
53
+ if (phase.kind === "failed") {
54
+ return intent === "rename"
55
+ ? `Couldn’t rename “${folderName}”. The mail server refused: ${phase.serverMessage}. The folder is unchanged.`
56
+ : `Couldn’t delete “${folderName}”. The mail server refused: ${phase.serverMessage}. Nothing was deleted.`;
57
+ }
58
+ return intent === "rename"
59
+ ? `Something else is already renaming or deleting “${folderName}”. Refresh to see where it got to.`
60
+ : `Something else is already deleting or renaming “${folderName}”. Refresh to see where it got to.`;
61
+ }
62
+
63
+ export function FolderMutationDialog({
64
+ open,
65
+ intent,
66
+ folderName,
67
+ targetName,
68
+ phase,
69
+ onRetry,
70
+ onRefresh,
71
+ onClose,
72
+ }: FolderMutationDialogProps) {
73
+ if (!open) return null;
74
+
75
+ const title = dialogTitle(intent, phase);
76
+ const body = dialogBody(intent, folderName, targetName, phase);
77
+ const icon =
78
+ phase.kind === "waiting" ? (
79
+ <Loader2 className="size-4 shrink-0 animate-spin text-accent-2" />
80
+ ) : phase.kind === "failed" || phase.kind === "conflict" ? (
81
+ <AlertTriangle className="size-4 shrink-0 text-danger" />
82
+ ) : null;
83
+
84
+ return (
85
+ <Dialog open={open} onClose={onClose} title={title}>
86
+ <header className="flex items-center gap-2 border-b border-line px-5 py-3">
87
+ {icon}
88
+ <span className="flex-1 text-sm font-semibold text-fg">{title}</span>
89
+ </header>
90
+ <div className="space-y-3 px-5 py-4 text-sm text-fg-muted">
91
+ <p>{body}</p>
92
+ </div>
93
+ <footer className="flex items-center justify-end gap-2 border-t border-line px-5 py-3">
94
+ {phase.kind === "failed" && (
95
+ <Button variant="secondary" size="sm" onClick={onRetry}>
96
+ Try again
97
+ </Button>
98
+ )}
99
+ {phase.kind === "conflict" ? (
100
+ <Button variant="primary" size="sm" onClick={onRefresh}>
101
+ Refresh
102
+ </Button>
103
+ ) : (
104
+ <Button variant="secondary" size="sm" onClick={onClose}>
105
+ Close
106
+ </Button>
107
+ )}
108
+ </footer>
109
+ </Dialog>
110
+ );
111
+ }
@@ -1,7 +1,9 @@
1
- import { CalendarDays } from "lucide-react";
2
- import { useState } from "react";
1
+ import { CalendarDays, Copy } from "lucide-react";
2
+ import { type ReactNode, useState } from "react";
3
3
  import { cn } from "../lib/cn.js";
4
+ import { Button } from "./button.js";
4
5
  import { CalendarEventChip } from "./calendar-event-chip.js";
6
+ import { CalendarFailureNote } from "./calendar-failure-note.js";
5
7
  import { CalendarInviteCard } from "./calendar-invite-card.js";
6
8
  import { CalendarSlotOffers } from "./calendar-slot-offers.js";
7
9
  import { CalendarSuggestionDeck } from "./calendar-suggestion-deck.js";
@@ -43,6 +45,18 @@ export interface CalendarInviteIntel {
43
45
  color: CalendarColorId;
44
46
  clashes: CalendarClash[];
45
47
  rsvp: RsvpState;
48
+ /** An answer is on its way to the server. */
49
+ busy?: boolean;
50
+ /** Why the last answer did not land. Empty when it did. */
51
+ failure?: string;
52
+ reportHref?: string;
53
+ /** Why nothing can be written to a calendar yet; holds Add and Remove. */
54
+ addBlocked?: ReactNode;
55
+ /**
56
+ * Who the mail came from, which is who muting stops — not always the
57
+ * organiser. Without it the card offers no mute.
58
+ */
59
+ sender?: string;
46
60
  }
47
61
 
48
62
  /** One reading off this thread that is not the invitation. */
@@ -68,6 +82,10 @@ export interface CalendarProseIntel {
68
82
  slots: CalendarSlotPick[];
69
83
  /** Start clocks already ticked into the reply. */
70
84
  picked: readonly string[];
85
+ /** What became of the last copy of the picked times. */
86
+ copy?: "idle" | "copied" | "failed";
87
+ /** The picked times as text, offered to select by hand when copying failed. */
88
+ copyText?: string;
71
89
  }
72
90
 
73
91
  export interface IntelligenceCalendarData {
@@ -79,21 +97,37 @@ export interface IntelligenceCalendarData {
79
97
  day: CalendarDayEntry[];
80
98
  /** The day those entries sit on, in words. */
81
99
  dayLabel: string;
100
+ /** An answer to the top reading is on its way to the server. */
101
+ suggestionsBusy?: boolean;
102
+ /** What the tab could not read. Empty when it read everything. */
103
+ failure?: string;
104
+ /** Why the last answer to a reading did not land, stated beside the deck. */
105
+ suggestionsFailure?: string;
106
+ /** A prefilled issue report for either failure above. */
107
+ reportHref?: string;
108
+ /** Why no reading can be added yet; holds the deck's Add. */
109
+ addBlocked?: ReactNode;
82
110
  }
83
111
 
112
+ /**
113
+ * What the tab can do. An optional action is one a host may have no way to
114
+ * carry out, and the control behind it is left off rather than drawn dead.
115
+ */
84
116
  export interface IntelligenceCalendarActions {
85
117
  onAddInvite: () => void;
86
- onTentativeInvite: () => void;
118
+ onTentativeInvite?: () => void;
87
119
  onDeclineInvite: () => void;
88
- onReopenInvite: () => void;
120
+ onReopenInvite?: () => void;
121
+ onMuteInvite?: () => void;
89
122
  onOfferOtherTimes: () => void;
90
- onRemoveInvite: () => void;
91
- onOpenNewerInvite: () => void;
123
+ onRemoveInvite?: () => void;
124
+ onOpenNewerInvite?: () => void;
92
125
  onToggleSlot: (slot: CalendarSlotPick) => void;
126
+ onCopySlots?: () => void;
93
127
  onAddSuggestion: (suggestionId: string, timeZone: string) => void;
94
- onReviewSuggestion: (suggestionId: string, timeZone: string) => void;
128
+ onReviewSuggestion?: (suggestionId: string, timeZone: string) => void;
95
129
  onDismissSuggestion: (suggestionId: string) => void;
96
- onOpenThread: (threadId: string) => void;
130
+ onOpenThread?: (threadId: string) => void;
97
131
  onSelectEvent: (eventId: string) => void;
98
132
  }
99
133
 
@@ -113,7 +147,19 @@ export function IntelligenceCalendar({
113
147
  touch,
114
148
  className,
115
149
  }: IntelligenceCalendarProps) {
116
- const { invite, prose, suggestions, day, dayLabel } = data;
150
+ const {
151
+ invite,
152
+ prose,
153
+ suggestions,
154
+ day,
155
+ dayLabel,
156
+ suggestionsBusy = false,
157
+ failure = "",
158
+ suggestionsFailure = "",
159
+ reportHref,
160
+ addBlocked,
161
+ } = data;
162
+ const { onReviewSuggestion, onOpenThread } = actions;
117
163
  const [zoneChoices, setZoneChoices] = useState<Record<string, string>>({});
118
164
  const top = suggestions[0];
119
165
  const topChoice =
@@ -122,6 +168,7 @@ export function IntelligenceCalendar({
122
168
  top === undefined ? undefined : settleZone(top.suggestion, topChoice);
123
169
  const picked = new Set(prose?.picked ?? []);
124
170
  const nothingToSay =
171
+ failure === "" &&
125
172
  invite === undefined &&
126
173
  prose === undefined &&
127
174
  suggestions.length === 0 &&
@@ -148,6 +195,14 @@ export function IntelligenceCalendar({
148
195
 
149
196
  return (
150
197
  <div className={cn("flex flex-col", className)}>
198
+ {failure !== "" && (
199
+ <CalendarFailureNote
200
+ text={failure}
201
+ reportHref={reportHref}
202
+ className="mx-row-inset mt-3"
203
+ />
204
+ )}
205
+
151
206
  {invite && (
152
207
  <IntelligenceSection label="Invitation">
153
208
  <CalendarInviteCard
@@ -157,6 +212,15 @@ export function IntelligenceCalendar({
157
212
  color={invite.color}
158
213
  clashes={invite.clashes}
159
214
  rsvp={invite.rsvp}
215
+ busy={invite.busy}
216
+ failure={invite.failure}
217
+ reportHref={invite.reportHref}
218
+ addBlocked={invite.addBlocked}
219
+ mute={
220
+ actions.onMuteInvite && invite.sender
221
+ ? { sender: invite.sender, onMute: actions.onMuteInvite }
222
+ : undefined
223
+ }
160
224
  onAdd={actions.onAddInvite}
161
225
  onTentative={actions.onTentativeInvite}
162
226
  onDecline={actions.onDeclineInvite}
@@ -170,8 +234,19 @@ export function IntelligenceCalendar({
170
234
  )}
171
235
 
172
236
  {prose && (
173
- <IntelligenceSection label={`Times named · ${prose.dayLabel}`}>
174
- <ul className="flex flex-col gap-1">
237
+ <IntelligenceSection
238
+ label={
239
+ prose.proposals.length > 0
240
+ ? `Times named · ${prose.dayLabel}`
241
+ : `Other times · ${prose.dayLabel}`
242
+ }
243
+ >
244
+ <ul
245
+ className={cn(
246
+ "flex flex-col gap-1",
247
+ prose.proposals.length === 0 && "hidden",
248
+ )}
249
+ >
175
250
  {prose.proposals.map((proposal) => (
176
251
  <li
177
252
  key={proposal.id}
@@ -202,9 +277,48 @@ export function IntelligenceCalendar({
202
277
  touch={touch}
203
278
  scroll
204
279
  />
205
- <p className="mt-1.5 text-2xs text-fg-subtle">
206
- Picked slots go into the reply as plain text. Nothing is booked.
207
- </p>
280
+ {actions.onCopySlots ? (
281
+ <div className="mt-2 flex flex-col gap-1.5">
282
+ <Button
283
+ variant="secondary"
284
+ size={touch ? "md" : "sm"}
285
+ icon={<Copy className="size-3.5" />}
286
+ onClick={actions.onCopySlots}
287
+ disabled={picked.size === 0}
288
+ className={cn("self-start", touch && "min-h-11")}
289
+ >
290
+ Copy picked times
291
+ </Button>
292
+ {prose.copy === "copied" && (
293
+ <p role="status" className="text-2xs text-positive">
294
+ Copied. Paste them into your reply.
295
+ </p>
296
+ )}
297
+ {prose.copy === "failed" && (
298
+ <div role="alert" className="flex flex-col gap-1">
299
+ <p className="text-2xs text-danger">
300
+ This page can't copy for you. Select the times below and
301
+ copy them yourself.
302
+ </p>
303
+ <textarea
304
+ readOnly
305
+ aria-label="Picked times"
306
+ value={prose.copyText ?? ""}
307
+ onFocus={(event) => event.currentTarget.select()}
308
+ rows={2}
309
+ className="w-full resize-none rounded-md border border-line bg-surface p-1.5 text-xs text-fg"
310
+ />
311
+ </div>
312
+ )}
313
+ <p className="text-2xs text-fg-subtle">
314
+ Picked slots are copied as plain text. Nothing is booked.
315
+ </p>
316
+ </div>
317
+ ) : (
318
+ <p className="mt-1.5 text-2xs text-fg-subtle">
319
+ Picked slots go into the reply as plain text. Nothing is booked.
320
+ </p>
321
+ )}
208
322
  </IntelligenceSection>
209
323
  )}
210
324
 
@@ -216,7 +330,7 @@ export function IntelligenceCalendar({
216
330
  blocked={topSettlement !== undefined && !topSettlement.settled}
217
331
  blockedReason={ZONE_UNSETTLED_REASON}
218
332
  onConfirm={() => {
219
- if (top && topSettlement?.settled)
333
+ if (top && topSettlement?.settled && addBlocked === undefined)
220
334
  actions.onAddSuggestion(
221
335
  top.suggestion.id,
222
336
  topSettlement.timeZone,
@@ -241,17 +355,34 @@ export function IntelligenceCalendar({
241
355
  onAdd={(timeZone) =>
242
356
  actions.onAddSuggestion(top.suggestion.id, timeZone)
243
357
  }
244
- onReview={(timeZone) =>
245
- actions.onReviewSuggestion(top.suggestion.id, timeZone)
358
+ onReview={
359
+ onReviewSuggestion &&
360
+ ((timeZone) =>
361
+ onReviewSuggestion(top.suggestion.id, timeZone))
246
362
  }
247
363
  onDismiss={() => actions.onDismissSuggestion(top.suggestion.id)}
248
- onOpenThread={() =>
249
- actions.onOpenThread(top.suggestion.threadId)
364
+ onOpenThread={
365
+ onOpenThread && (() => onOpenThread(top.suggestion.threadId))
250
366
  }
367
+ busy={suggestionsBusy}
368
+ addBlocked={addBlocked !== undefined}
251
369
  touch={touch}
252
370
  />
253
371
  )}
254
372
  </CalendarSuggestionDeck>
373
+ {addBlocked !== undefined && (
374
+ <div className="mt-2 rounded-md border border-warning/40 bg-warning-soft p-2 text-xs text-fg">
375
+ {addBlocked}
376
+ </div>
377
+ )}
378
+ {suggestionsFailure !== "" && (
379
+ <CalendarFailureNote
380
+ text={suggestionsFailure}
381
+ reportHref={reportHref}
382
+ className="mt-2"
383
+ />
384
+ )}
385
+
255
386
  <p className="mt-2 text-2xs text-fg-subtle">
256
387
  None of this is on your calendar, and none of it will be until you
257
388
  say so.