@remit/ui 0.0.170 → 0.0.172

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.170",
3
+ "version": "0.0.172",
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 {
@@ -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,
@@ -913,6 +921,7 @@ export {
913
921
  groupOverlapping,
914
922
  isClearDay,
915
923
  isEmptyDay,
924
+ mergeBusySpans,
916
925
  minuteOfDay,
917
926
  monthLabel,
918
927
  type NextUp,