@remit/ui 0.0.171 → 0.0.173

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/ui",
3
- "version": "0.0.171",
3
+ "version": "0.0.173",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src"
@@ -14,6 +14,7 @@ import type {
14
14
  } from "./intelligence-panel.js";
15
15
  import type { ResultCount } from "./list-result-header.js";
16
16
  import type { ListState } from "./message-list-state.js";
17
+ import type { RowSettlement } from "./message-settlement.js";
17
18
 
18
19
  /** Pane-count thresholds, aligned to Tailwind `lg`/`xl`. The whole shell reflows
19
20
  * by its own width: a single responsive surface, not per-device variants.
@@ -308,6 +309,13 @@ export interface ThreadRowData {
308
309
  suspicious?: boolean;
309
310
  /** Labels applied to this message (issue #26) — filter-, organize-, and manually-applied alike. */
310
311
  labels?: ThreadRowLabel[];
312
+ /**
313
+ * A mutation on this row provably gave up — today only a delete Remit
314
+ * abandoned before it reached the server (issue #1002). Absent is the
315
+ * ordinary case AND every case the two wire fields cannot tell apart, so
316
+ * absence never means "settled", only "nothing this row can state".
317
+ */
318
+ settlement?: RowSettlement;
311
319
  }
312
320
 
313
321
  export interface ThreadSection {
@@ -127,7 +127,7 @@ describe("MessageListPane", () => {
127
127
  isDesktop: true,
128
128
  listState: "empty",
129
129
  listFilter: {
130
- label: "Personal",
130
+ label: "Personal mail",
131
131
  reach: "whole-folder",
132
132
  onClear: () => undefined,
133
133
  },
@@ -354,7 +354,7 @@ export const FilteredEmptyState: Story = {
354
354
  listState: "empty",
355
355
  keyboard: noKeyboard,
356
356
  listFilter: {
357
- label: "Personal",
357
+ label: "Personal mail",
358
358
  reach: "whole-folder",
359
359
  onClear: () => undefined,
360
360
  },
@@ -20,7 +20,7 @@ function empty(props: MessageListEmptyProps = {}): string {
20
20
  }
21
21
 
22
22
  const personal: MessageListFilter = {
23
- label: "Personal",
23
+ label: "Personal mail",
24
24
  reach: "whole-folder",
25
25
  onClear: () => undefined,
26
26
  };
@@ -88,7 +88,7 @@ describe("MessageListEmpty under a filter", () => {
88
88
  { filter: personal, scopeLabel: "Inbox" },
89
89
  { filter: personal, searchQuery: "invoice" },
90
90
  { filter: personal, scopeLabel: "Inbox", searchQuery: "invoice" },
91
- { filter: { ...personal, label: "Unclassified" } },
91
+ { filter: { ...personal, label: "Unclassified mail" } },
92
92
  { filter: { ...personal, reach: "loaded-pages" } },
93
93
  { filter: { ...personal, reach: "loaded-pages" }, scopeLabel: "Inbox" },
94
94
  ];
@@ -130,6 +130,17 @@ describe("MessageListEmpty under a filter", () => {
130
130
  assert.match(html, new RegExp(COMPLETENESS));
131
131
  });
132
132
 
133
+ it("names a narrowing that is not a category at all (#1126)", () => {
134
+ const html = empty({
135
+ filter: { ...personal, label: "unread mail" },
136
+ scopeLabel: "Starred",
137
+ });
138
+ assert.match(html, /No unread mail in Starred/);
139
+ assert.match(html, new RegExp(COMPLETENESS));
140
+ assert.match(html, /Clear filter/);
141
+ assert.doesNotMatch(html, /No messages in Starred/);
142
+ });
143
+
133
144
  it("offers the way out of the filter", () => {
134
145
  assert.match(empty({ filter: personal }), /Clear filter/);
135
146
  });
@@ -152,7 +163,7 @@ describe("MessageListEmpty under a filter", () => {
152
163
 
153
164
  it("renders unclassified as itself, never as personal (#45)", () => {
154
165
  const unclassified = empty({
155
- filter: { ...personal, label: "Unclassified" },
166
+ filter: { ...personal, label: "Unclassified mail" },
156
167
  scopeLabel: "Inbox",
157
168
  });
158
169
  assert.match(unclassified, /No Unclassified mail in Inbox/);
@@ -44,7 +44,7 @@ const longRow: ThreadRowData = {
44
44
  };
45
45
 
46
46
  const personalFilter: MessageListFilter = {
47
- label: "Personal",
47
+ label: "Personal mail",
48
48
  reach: "whole-folder",
49
49
  onClear: () => undefined,
50
50
  };
@@ -185,6 +185,31 @@ export const FilteredEmpty: Story = {
185
185
  args: { filter: personalFilter, scopeLabel: "Inbox" },
186
186
  };
187
187
 
188
+ /**
189
+ * The narrowing is an attribute chip, or a token typed in the field, with no
190
+ * category chosen. The list is filtered exactly as much as it is under a
191
+ * category, and used to render as an empty collection instead (#1126).
192
+ */
193
+ export const FilteredEmptyAttributeOnly: Story = {
194
+ ...inFilteredPane,
195
+ args: {
196
+ filter: { ...personalFilter, label: "unread mail" },
197
+ scopeLabel: "Inbox",
198
+ },
199
+ };
200
+
201
+ /** Every dimension at once: category chip, attribute chip and typed token. */
202
+ export const FilteredEmptyEveryNarrowing: Story = {
203
+ ...inFilteredPane,
204
+ args: {
205
+ filter: {
206
+ ...personalFilter,
207
+ label: "Personal unread mail with an attachment",
208
+ },
209
+ scopeLabel: "Inbox",
210
+ },
211
+ };
212
+
188
213
  /** S2 with a search query on top of the filter — same completeness sentence. */
189
214
  export const FilteredEmptySearching: Story = {
190
215
  ...inFilteredPane,
@@ -216,7 +241,7 @@ export const FilteredEmptyBoundedReach: Story = {
216
241
  export const FilteredEmptyUnclassified: Story = {
217
242
  decorators: [paneFrame],
218
243
  args: {
219
- filter: { ...personalFilter, label: "Unclassified" },
244
+ filter: { ...personalFilter, label: "Unclassified mail" },
220
245
  scopeLabel: "Inbox",
221
246
  },
222
247
  render: (args) => (
@@ -230,7 +255,7 @@ export const FilteredEmptyUnclassified: Story = {
230
255
  export const FilteredEmptyLongLabels: Story = {
231
256
  ...inFilteredPane,
232
257
  args: {
233
- filter: { ...personalFilter, label: "Transactional" },
258
+ filter: { ...personalFilter, label: "Transactional mail" },
234
259
  scopeLabel: "Archive/2024/Suppliers/Netherlands Enterprise Agency",
235
260
  },
236
261
  };
@@ -49,20 +49,25 @@ export function MessageListLoading() {
49
49
  export type FilterReach = "whole-folder" | "loaded-pages";
50
50
 
51
51
  /**
52
- * The active category filter, the way out of it, and how far it reached. All
53
- * three together: the label cannot arrive without its escape, and the reach
54
- * cannot be left to a default, because it decides which completeness sentence
55
- * is true.
52
+ * What narrows the list, the way out of it, and how far it reached. All three
53
+ * together: the label cannot arrive without its escape, and the reach cannot be
54
+ * left to a default, because it decides which completeness sentence is true.
56
55
  */
57
56
  export interface MessageListFilter {
58
- /** Display label of the active category, e.g. "Personal". */
57
+ /**
58
+ * The narrowing as a noun phrase the headline reads "No " in front of:
59
+ * "Personal mail", "unread mail with an attachment". Whatever narrows the
60
+ * list belongs in it — a category chip, an attribute chip, a typed token —
61
+ * because this object's presence is what tells the reader the collection is
62
+ * filtered rather than empty (#1126).
63
+ */
59
64
  label: string;
60
65
  reach: FilterReach;
61
66
  onClear: () => void;
62
67
  }
63
68
 
64
69
  export interface MessageListEmptyProps {
65
- /** Absent when no category filter is active. */
70
+ /** Absent when nothing narrows the list. */
66
71
  filter?: MessageListFilter;
67
72
  /**
68
73
  * Name of the collection being listed, e.g. "Inbox". Absent for a plain
@@ -140,13 +145,13 @@ function unfilteredCopy(
140
145
 
141
146
  /** One string, not JSX, so the copy stays a single text node and reads whole. */
142
147
  function filteredHeadline(
143
- filterLabel: string,
148
+ narrowing: string,
144
149
  scopeLabel: string | undefined,
145
150
  query: string | undefined,
146
151
  ): string {
147
- if (query) return `No results for “${query}” in ${filterLabel}`;
148
- if (scopeLabel) return `No ${filterLabel} mail in ${scopeLabel}`;
149
- return `No ${filterLabel} mail`;
152
+ if (query) return `No results for “${query}” in ${narrowing}`;
153
+ if (scopeLabel) return `No ${narrowing} in ${scopeLabel}`;
154
+ return `No ${narrowing}`;
150
155
  }
151
156
 
152
157
  function EmptyFrame({ children }: { children: ReactNode }) {
@@ -146,6 +146,27 @@ const longLabelName: ThreadRowData = {
146
146
  ],
147
147
  };
148
148
 
149
+ const deleteFailed: ThreadRowData = {
150
+ id: "r-delete-failed",
151
+ accountId: "a1",
152
+ fromName: "Tomas Berg",
153
+ fromEmail: "tomas@example.com",
154
+ subject: "Signed lease, final version",
155
+ snippet: "Deleted here; Remit refused to finish it and the row came back.",
156
+ timeLabel: "Mon",
157
+ isRead: false,
158
+ settlement: "delete_failed",
159
+ };
160
+
161
+ const deleteFailedWithLabels: ThreadRowData = {
162
+ ...deleteFailed,
163
+ id: "r-delete-failed-labels",
164
+ category: "newsletter",
165
+ labels: [{ labelId: "l1", name: "Receipts", color: "Blue" }],
166
+ };
167
+
168
+ const unsettled = [deleteFailed, deleteFailedWithLabels, read];
169
+
149
170
  const labeled = [noLabel, oneLabel, twoLabels, severalLabels, longLabelName];
150
171
 
151
172
  const all = [read, unread, starred, suspicious, withAttachment, withCategory];
@@ -281,3 +302,46 @@ export const CompactLabelsDark: Story = {
281
302
  </List>
282
303
  ),
283
304
  };
305
+
306
+ /**
307
+ * A row whose delete Remit abandoned (issue #1002): it was removed here, then
308
+ * refused before it reached the server, so the message came back to the folder
309
+ * the server still has it in. The only unsettled state the wire can prove — a
310
+ * move that gave up leaves the same fields a move mid-retry leaves, so it gets
311
+ * no chip. The chip names the state; the open message carries the statement, a
312
+ * working Delete again, and the report link (`MessageSettlementNotice`).
313
+ */
314
+ export const DeleteFailed: Story = {
315
+ render: () => (
316
+ <List>
317
+ {unsettled.map((thread) => (
318
+ <ComfortableRow key={thread.id} thread={thread} />
319
+ ))}
320
+ </List>
321
+ ),
322
+ };
323
+
324
+ /** The same rows on the dark theme. */
325
+ export const DeleteFailedDark: Story = {
326
+ name: "Delete failed (dark)",
327
+ parameters: { theme: "dark" },
328
+ render: () => (
329
+ <List>
330
+ {unsettled.map((thread) => (
331
+ <ComfortableRow key={thread.id} thread={thread} />
332
+ ))}
333
+ </List>
334
+ ),
335
+ };
336
+
337
+ /** Compact density carries the same chip. */
338
+ export const DeleteFailedCompact: Story = {
339
+ name: "Delete failed (compact)",
340
+ render: () => (
341
+ <List>
342
+ {unsettled.map((thread) => (
343
+ <CompactRow key={thread.id} thread={thread} />
344
+ ))}
345
+ </List>
346
+ ),
347
+ };
@@ -12,6 +12,7 @@ import { categoryTone, type ThreadRowData } from "./app-shell-types.js";
12
12
  import { Avatar } from "./avatar.js";
13
13
  import { Badge } from "./badge.js";
14
14
  import { LabelChip } from "./label-chip.js";
15
+ import { MessageSettlementBadge } from "./message-settlement.js";
15
16
 
16
17
  /** Visible keyboard-focus ring for a row reached by the list's arrow-key cursor. */
17
18
  const ROW_FOCUS_RING =
@@ -104,6 +105,9 @@ export function CompactRowBody({ thread }: { thread: ThreadRowData }) {
104
105
  aria-label="Has an attachment"
105
106
  />
106
107
  )}
108
+ {thread.settlement && (
109
+ <MessageSettlementBadge settlement={thread.settlement} />
110
+ )}
107
111
  <span className="w-11 shrink-0 text-right text-2xs text-fg-subtle tabular-nums">
108
112
  {thread.timeLabel}
109
113
  </span>
@@ -215,6 +219,9 @@ export function ComfortableRowTextContent({
215
219
  {thread.labels?.map((label) => (
216
220
  <LabelChip key={label.labelId} label={label} className="max-w-20" />
217
221
  ))}
222
+ {thread.settlement && (
223
+ <MessageSettlementBadge settlement={thread.settlement} />
224
+ )}
218
225
  {badge}
219
226
  </span>
220
227
  </span>
@@ -0,0 +1,87 @@
1
+ import assert from "node:assert/strict";
2
+ import { describe, it } from "node:test";
3
+ import { createElement } from "react";
4
+ import { renderToString } from "react-dom/server";
5
+ import type { ThreadRowData } from "./app-shell-types.js";
6
+ import { ComfortableRow, CompactRow } from "./message-row.js";
7
+ import {
8
+ MessageSettlementNotice,
9
+ messageSettlementCopy,
10
+ type RowSettlement,
11
+ } from "./message-settlement.js";
12
+
13
+ const thread: ThreadRowData = {
14
+ id: "m1",
15
+ fromName: "Tomas Berg",
16
+ fromEmail: "tomas@example.com",
17
+ subject: "Signed lease, final version",
18
+ snippet: "The countersigned copy is attached.",
19
+ timeLabel: "Mon",
20
+ isRead: true,
21
+ };
22
+
23
+ const row = (settlement?: RowSettlement) =>
24
+ renderToString(
25
+ createElement(ComfortableRow, {
26
+ thread: settlement ? { ...thread, settlement } : thread,
27
+ }),
28
+ );
29
+
30
+ const compactRow = (settlement?: RowSettlement) =>
31
+ renderToString(
32
+ createElement(CompactRow, {
33
+ thread: settlement ? { ...thread, settlement } : thread,
34
+ }),
35
+ );
36
+
37
+ describe("a row whose delete gave up says so", () => {
38
+ it("marks the row", () => {
39
+ const html = row("delete_failed");
40
+ assert.match(html, /data-settlement="delete_failed"/);
41
+ assert.match(html, new RegExp(messageSettlementCopy.delete_failed.label));
42
+ });
43
+
44
+ it("carries the same mark in compact density", () => {
45
+ assert.match(
46
+ compactRow("delete_failed"),
47
+ /data-settlement="delete_failed"/,
48
+ );
49
+ });
50
+
51
+ it("leaves every other row exactly as it was", () => {
52
+ assert.doesNotMatch(row(), /data-settlement/);
53
+ assert.doesNotMatch(compactRow(), /data-settlement/);
54
+ });
55
+ });
56
+
57
+ describe("the reading-pane notice", () => {
58
+ it("states the failure and offers both ways out", () => {
59
+ const html = renderToString(
60
+ createElement(MessageSettlementNotice, {
61
+ settlement: "delete_failed",
62
+ onRetry: () => undefined,
63
+ reportHref: "https://example.test/new-issue",
64
+ }),
65
+ );
66
+ assert.match(html, /role="alert"/);
67
+ assert.match(html, new RegExp(messageSettlementCopy.delete_failed.title));
68
+ assert.match(
69
+ html,
70
+ new RegExp(messageSettlementCopy.delete_failed.retryLabel),
71
+ );
72
+ assert.match(html, /Report an issue/);
73
+ assert.match(html, /https:\/\/example\.test\/new-issue/);
74
+ });
75
+
76
+ it("disables the retry while one is in flight rather than dropping it", () => {
77
+ const html = renderToString(
78
+ createElement(MessageSettlementNotice, {
79
+ settlement: "delete_failed",
80
+ onRetry: () => undefined,
81
+ retryPending: true,
82
+ }),
83
+ );
84
+ assert.match(html, /disabled/);
85
+ assert.match(html, /Deleting/);
86
+ });
87
+ });
@@ -0,0 +1,69 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import {
3
+ MessageSettlementBadge,
4
+ MessageSettlementNotice,
5
+ } from "./message-settlement.js";
6
+
7
+ const meta: Meta = {
8
+ title: "Mail/MessageSettlement",
9
+ parameters: { layout: "padded" },
10
+ };
11
+ export default meta;
12
+
13
+ type Story = StoryObj;
14
+
15
+ const reportHref =
16
+ "https://github.com/remit-mail/reader/issues/new?title=This+message+was+not+deleted";
17
+
18
+ /**
19
+ * The one unsettled state the wire can prove (issue #1002): a delete Remit
20
+ * abandoned before it reached the server — most often because the Trash folder
21
+ * the event named is gone — which handed the row back to the folder the server
22
+ * still holds the message in.
23
+ *
24
+ * It gets a real Retry, not a report-only dead end: abandoning puts `status`
25
+ * back to `active`, so the ordinary delete endpoint accepts the row and
26
+ * re-drives it. A move that gave up leaves exactly the fields a move mid-retry
27
+ * leaves, so it gets no treatment at all — no chip, no notice, no promise.
28
+ */
29
+ export const Notice: Story = {
30
+ render: () => (
31
+ <div className="flex w-xl flex-col gap-3">
32
+ <MessageSettlementNotice
33
+ settlement="delete_failed"
34
+ onRetry={() => undefined}
35
+ reportHref={reportHref}
36
+ />
37
+ <MessageSettlementNotice
38
+ settlement="delete_failed"
39
+ onRetry={() => undefined}
40
+ retryPending
41
+ reportHref={reportHref}
42
+ />
43
+ </div>
44
+ ),
45
+ };
46
+
47
+ /** The same notice on the dark theme. */
48
+ export const NoticeDark: Story = {
49
+ name: "Notice (dark)",
50
+ parameters: { theme: "dark" },
51
+ render: () => (
52
+ <div className="flex w-xl flex-col gap-3">
53
+ <MessageSettlementNotice
54
+ settlement="delete_failed"
55
+ onRetry={() => undefined}
56
+ reportHref={reportHref}
57
+ />
58
+ </div>
59
+ ),
60
+ };
61
+
62
+ /** The list-row chip, which carries the label alone — a row may nest no action. */
63
+ export const Badge: Story = {
64
+ render: () => (
65
+ <div className="flex items-center gap-2">
66
+ <MessageSettlementBadge settlement="delete_failed" />
67
+ </div>
68
+ ),
69
+ };
@@ -0,0 +1,122 @@
1
+ import { CloudOff } from "lucide-react";
2
+ import { cn } from "../lib/cn.js";
3
+ import { Badge } from "./badge.js";
4
+
5
+ /**
6
+ * The one unsettled state a message row can prove from the wire: a delete Remit
7
+ * abandoned before running it, which handed the row back to the folder the mail
8
+ * server still holds the message in (`hasAbandonedDelete` in @remit/data-ports,
9
+ * which enumerates what this can and cannot see).
10
+ *
11
+ * A one-member union on purpose. A move that gave up leaves exactly the state a
12
+ * move mid-retry leaves, so it is not derivable and gets no treatment here —
13
+ * saying "Remit stopped retrying" over a push about to succeed would be a
14
+ * louder lie than the silence this replaces. Adding a member is what a new
15
+ * persisted signal would earn.
16
+ */
17
+ export type RowSettlement = "delete_failed";
18
+
19
+ export const messageSettlementCopy = {
20
+ delete_failed: {
21
+ label: "Not deleted",
22
+ title: "This message was not deleted",
23
+ detail:
24
+ "Remit removed it here first, then refused to finish the delete on the mail server — most often because the Trash folder it was headed for is not there any more. The message is back in this folder because that is where the server still has it.",
25
+ retryLabel: "Delete again",
26
+ },
27
+ } as const;
28
+
29
+ export interface MessageSettlementBadgeProps {
30
+ settlement: RowSettlement;
31
+ className?: string;
32
+ }
33
+
34
+ /**
35
+ * List-row chip. Carries no action — a row is a link or a button and may not
36
+ * nest one. The statement and the way out live on the open message, in
37
+ * {@link MessageSettlementNotice}.
38
+ */
39
+ export function MessageSettlementBadge({
40
+ settlement,
41
+ className,
42
+ }: MessageSettlementBadgeProps) {
43
+ const copy = messageSettlementCopy[settlement];
44
+ return (
45
+ <Badge
46
+ tone="danger"
47
+ className={cn("shrink-0", className)}
48
+ title={copy.title}
49
+ data-settlement={settlement}
50
+ >
51
+ <CloudOff className="size-3 shrink-0" aria-hidden />
52
+ <span>{copy.label}</span>
53
+ </Badge>
54
+ );
55
+ }
56
+
57
+ export interface MessageSettlementNoticeProps {
58
+ settlement: RowSettlement;
59
+ /**
60
+ * Re-drives the delete through the ordinary delete endpoint, which accepts
61
+ * this row: the give-up put `status` back to `active`, so the placement
62
+ * guard passes it through. Omit only where no delete action is available.
63
+ */
64
+ onRetry?: () => void;
65
+ retryPending?: boolean;
66
+ /** Prefilled issue link, for a retry that keeps failing. */
67
+ reportHref?: string;
68
+ className?: string;
69
+ }
70
+
71
+ /**
72
+ * Reading-pane notice for a delete that gave up: what failed, where the message
73
+ * actually is, and the two ways out — delete it again, or report it.
74
+ */
75
+ export function MessageSettlementNotice({
76
+ settlement,
77
+ onRetry,
78
+ retryPending,
79
+ reportHref,
80
+ className,
81
+ }: MessageSettlementNoticeProps) {
82
+ const copy = messageSettlementCopy[settlement];
83
+ return (
84
+ <div
85
+ role="alert"
86
+ data-testid="message-settlement-notice"
87
+ data-settlement={settlement}
88
+ className={cn(
89
+ "flex items-start gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm",
90
+ className,
91
+ )}
92
+ >
93
+ <CloudOff className="mt-0.5 size-4 shrink-0 text-danger" aria-hidden />
94
+ <div className="min-w-0 flex-1">
95
+ <p className="font-medium text-danger">{copy.title}</p>
96
+ <p className="mt-1 break-words text-fg-muted">{copy.detail}</p>
97
+ <div className="mt-1 flex flex-wrap items-center gap-3">
98
+ {onRetry && (
99
+ <button
100
+ type="button"
101
+ onClick={onRetry}
102
+ disabled={retryPending}
103
+ className="font-medium text-accent hover:underline disabled:opacity-50"
104
+ >
105
+ {retryPending ? "Deleting…" : copy.retryLabel}
106
+ </button>
107
+ )}
108
+ {reportHref && (
109
+ <a
110
+ href={reportHref}
111
+ target="_blank"
112
+ rel="noreferrer"
113
+ className="font-medium text-accent hover:underline"
114
+ >
115
+ Report an issue
116
+ </a>
117
+ )}
118
+ </div>
119
+ </div>
120
+ </div>
121
+ );
122
+ }
package/src/index.ts CHANGED
@@ -536,6 +536,14 @@ export {
536
536
  type RowSelection,
537
537
  type RowToggleEvent,
538
538
  } from "./components/message-row.js";
539
+ export {
540
+ MessageSettlementBadge,
541
+ type MessageSettlementBadgeProps,
542
+ MessageSettlementNotice,
543
+ type MessageSettlementNoticeProps,
544
+ messageSettlementCopy,
545
+ type RowSettlement,
546
+ } from "./components/message-settlement.js";
539
547
  export {
540
548
  type MobileMessageAction,
541
549
  MobileMessageActionBar,