@remit/ui 0.0.238 → 0.0.240

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 (35) hide show
  1. package/dist/components/app-shell-types.d.ts +12 -2
  2. package/dist/components/button.d.ts +5 -0
  3. package/dist/components/button.js +2 -0
  4. package/dist/components/check-again-panel.d.ts +43 -0
  5. package/dist/components/check-again-panel.js +60 -0
  6. package/dist/components/failure-banner.d.ts +11 -0
  7. package/dist/components/failure-banner.js +7 -0
  8. package/dist/components/intelligence-calendar-fixtures.js +0 -12
  9. package/dist/components/intelligence-panel.d.ts +7 -26
  10. package/dist/components/intelligence-panel.js +4 -16
  11. package/dist/components/intelligence-section.d.ts +3 -1
  12. package/dist/components/intelligence-section.js +2 -2
  13. package/dist/components/message-row.js +13 -3
  14. package/dist/components/nav-sidebar.js +49 -16
  15. package/dist/components/search-result-row.d.ts +1 -1
  16. package/dist/components/search-result-row.js +4 -7
  17. package/dist/components/selection-top-bar.d.ts +3 -1
  18. package/dist/components/selection-top-bar.js +10 -2
  19. package/dist/components/spam-copy.d.ts +25 -0
  20. package/dist/components/spam-copy.js +100 -0
  21. package/dist/components/spam-daily-chart.d.ts +17 -0
  22. package/dist/components/spam-daily-chart.js +18 -0
  23. package/dist/components/spam-fixtures.d.ts +19 -0
  24. package/dist/components/spam-fixtures.js +143 -0
  25. package/dist/components/spam-row-marker.d.ts +12 -0
  26. package/dist/components/spam-row-marker.js +10 -0
  27. package/dist/components/spam-verdict-panel.d.ts +37 -0
  28. package/dist/components/spam-verdict-panel.js +74 -0
  29. package/dist/components/spam-warning-banner.d.ts +20 -0
  30. package/dist/components/spam-warning-banner.js +62 -0
  31. package/dist/index.d.ts +10 -3
  32. package/dist/index.js +8 -1
  33. package/dist/lib/folder-tree.d.ts +2 -1
  34. package/dist/lib/folder-tree.js +15 -9
  35. package/package.json +3 -2
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { ArrowLeft, FolderInput, LoaderCircle, MailOpen, ShieldAlert, Sparkles, Trash, } from "../icons.js";
2
+ import { ArrowLeft, FolderInput, LoaderCircle, MailOpen, RefreshCw, ShieldAlert, Sparkles, Trash, } from "../icons.js";
3
3
  import { Banner } from "./banner.js";
4
4
  import { Button } from "./button.js";
5
5
  import { Checkbox } from "./checkbox.js";
@@ -22,7 +22,7 @@ function SelectAllToggle({ selectAll, selecting, className, }) {
22
22
  * row one is a count and the verbs. A back arrow leaves selection at every
23
23
  * width, so a partial selection is always one press from being dropped.
24
24
  */
25
- export function SelectionTopBar({ title, count, onCancel, onDelete, onMove, onOrganize, onJunk, onMarkRead, navSlot, titleMeta, searchSlot, searchField, idleSlot, overflowSlot, isBusy = false, isCounting = false, selectAll, statusLabel, progress, notice, }) {
25
+ export function SelectionTopBar({ title, count, onCancel, onDelete, onMove, onOrganize, onJunk, onMarkRead, onCheckAgain, navSlot, titleMeta, searchSlot, searchField, idleSlot, overflowSlot, isBusy = false, isCounting = false, selectAll, statusLabel, progress, notice, }) {
26
26
  const selecting = count > 0 || isCounting;
27
27
  const defaultLabel = selectAll?.checked
28
28
  ? `All ${formatCount(count)} loaded selected`
@@ -44,5 +44,13 @@ export function SelectionTopBar({ title, count, onCancel, onDelete, onMove, onOr
44
44
  onSelect: onMarkRead,
45
45
  });
46
46
  }
47
+ if (onCheckAgain && !isBusy && !isCounting) {
48
+ overflowItems.push({
49
+ key: "check-again",
50
+ label: "Check again",
51
+ icon: _jsx(RefreshCw, { className: "size-4" }),
52
+ onSelect: onCheckAgain,
53
+ });
54
+ }
47
55
  return (_jsxs("header", { "data-selection-bar": "", className: "flex shrink-0 flex-col border-b border-line bg-surface-sunken", children: [_jsxs("div", { "data-selection-bar-row": "actions", className: "flex h-pane-header items-center gap-1 px-row-inset", children: [selecting ? (_jsx(Button, { variant: "ghost", size: "touch", icon: _jsx(ArrowLeft, { className: "size-5" }), onClick: onCancel, "aria-label": "Cancel selection", className: "-ml-2 shrink-0" })) : (navSlot), selectAll && (_jsx(SelectAllToggle, { selectAll: selectAll, selecting: selecting, className: "hidden shrink-0 pr-2 md:flex" })), selecting ? (_jsx("span", { "data-selection-count": "", className: "min-w-0 flex-1 truncate px-1 text-sm font-medium text-fg", role: "status", "aria-live": "polite", children: statusLabel ?? defaultLabel })) : searchField ? (_jsx("div", { className: "flex min-w-0 flex-1 items-center gap-1", children: searchField })) : (_jsxs(_Fragment, { children: [_jsx("h1", { className: "min-w-0 flex-1 truncate px-1 text-sm font-semibold text-fg", children: title }), titleMeta, searchSlot] })), selecting && !isCounting && (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "ghost", size: "touch", icon: isBusy ? (_jsx(LoaderCircle, { className: "size-5 animate-spin" })) : (_jsx(Trash, { className: "size-5 text-danger" })), onClick: isBusy ? undefined : onDelete, "aria-label": "Move selected messages to Trash", "aria-busy": isBusy || undefined, className: "shrink-0" }), !isBusy && onMove && (_jsx(Button, { variant: "ghost", size: "touch", icon: _jsx(FolderInput, { className: "size-5" }), onClick: onMove, "aria-label": "Move selected messages", className: "shrink-0" })), !isBusy && onOrganize && (_jsx(Button, { variant: "ghost", size: "touch", icon: _jsx(Sparkles, { className: "size-5" }), onClick: onOrganize, "aria-label": "Organize selected messages", className: "shrink-0" }))] })), selecting && (_jsx(PopoverMenu, { triggerLabel: "More actions", items: overflowItems, className: "shrink-0", children: !isBusy && !isCounting && overflowSlot }))] }), !selecting && idleSlot, selecting && selectAll && (_jsx("div", { "data-selection-bar-row": "select-all", className: "px-row-inset pb-2 md:hidden", children: _jsx(SelectAllToggle, { selectAll: selectAll, selecting: selecting, className: "w-full" }) })), progress && (_jsx("div", { className: "px-row-inset pb-2", children: _jsx(ProgressBar, { value: progress.value, max: progress.max, tone: progress.tone }) })), notice && (_jsx(Banner, { "data-selection-notice": "", tone: notice.tone, variant: "soft", role: "status", "aria-live": "polite", className: "mx-row-inset mb-2", children: _jsxs("div", { className: "flex items-center justify-between gap-2", children: [notice.text && _jsx("span", { children: notice.text }), notice.action && (_jsx(Button, { variant: "ghost", size: "md", onClick: notice.action.onClick, className: "-my-1 min-h-11 shrink-0", children: notice.action.label }))] }) }))] }));
48
56
  }
@@ -0,0 +1,25 @@
1
+ import type { RemitImapRescanFailureCode, RemitImapSpamChecked, RemitImapSpamFailureKind, RemitImapSpamKind, RemitImapSpamModelOutcome, RemitImapSpamReason, RemitImapSpamSenderScreenRule, RemitImapSpamThresholds } from "@remit/api-http-client/types.gen.ts";
2
+ export declare const isModelReason: (reason: RemitImapSpamReason) => boolean;
3
+ export declare const UNKNOWN_REASON_SENTENCE = "Remit ran a check this version can't describe.";
4
+ export declare const CHECK_FAILED_HEADLINE = "Remit couldn't check this message";
5
+ export declare const BASIC_CHECKS_ONLY = "Only the basic checks ran";
6
+ /**
7
+ * The one sentence a reason reads as, wherever it shows. A backend symbol, or
8
+ * a name this version does not know, yields `undefined`: the caller shows the
9
+ * raw symbol and a report link instead of a guess.
10
+ */
11
+ export declare function spamReasonSentence(name: string): string | undefined;
12
+ export declare function topSpamReason(reasons: readonly RemitImapSpamReason[]): RemitImapSpamReason | undefined;
13
+ export declare function topSpamReasonSentence(reasons: readonly RemitImapSpamReason[]): string;
14
+ /** What the model said, quoted from its reason, when it answered. */
15
+ export declare function modelSaid(verdict: RemitImapSpamChecked): string | undefined;
16
+ export declare const MODEL_SKIP_CAUSES: Record<Exclude<RemitImapSpamModelOutcome, "Answered" | "OutOfBand">, string>;
17
+ /** Why the model did not weigh in on a message it would have helped with. */
18
+ export declare function modelSkipCause(verdict: RemitImapSpamChecked): string | undefined;
19
+ export declare const SPAM_FAILURE_SENTENCES: Record<RemitImapSpamFailureKind, string>;
20
+ export declare const CHECK_AGAIN_FAILURE_SENTENCES: Record<RemitImapRescanFailureCode, string>;
21
+ export declare const SPAM_SCREEN_SENTENCES: Record<Exclude<RemitImapSpamSenderScreenRule, "ReportedSender">, string>;
22
+ export declare const filterScreenSentence: (filterName: string) => string;
23
+ export declare const SPAM_WARN_HEADLINES: Record<RemitImapSpamKind, string>;
24
+ export declare const formatSpamScore: (score: number) => string;
25
+ export declare const spamScoreSentence: (score: number, thresholds: RemitImapSpamThresholds) => string;
@@ -0,0 +1,100 @@
1
+ const REASON_SENTENCES = {
2
+ DmarcFail: "It failed the sender domain's DMARC check.",
3
+ SignerMismatch: "It was signed by a different domain than its sender.",
4
+ ReplyToMismatch: "Replies would go to a different domain than the sender's.",
5
+ LinkTextMismatch: "A link's text shows one domain and opens another.",
6
+ LinkDomainDistant: "A link leads to a domain unrelated to the sender's.",
7
+ PunycodeDomain: "A domain in it is written in punycode, which can hide lookalike letters.",
8
+ MixedScriptDomain: "A domain in it mixes letters from different alphabets.",
9
+ ConfusableDomains: "Two different domains in it look the same.",
10
+ SingleOffDomainLink: "Its only link leads away from the sender's domain.",
11
+ GeneratedName: "The sender's address looks machine-generated.",
12
+ FirstContactDomain: "The sender's domain has sent you nothing before.",
13
+ RecentlyRegisteredDomain: "The sender's domain was registered recently.",
14
+ UnknownRegistrationDate: "The sender's domain has no public registration date.",
15
+ ClassifierSpam: "Remit's classifier rated it as likely spam.",
16
+ ClassifierPhishing: "Remit's classifier rated it as likely phishing.",
17
+ ProviderSpam: "Your provider marked it as spam.",
18
+ DisplayNameForeignAddress: "The display name spells out an address at another domain.",
19
+ DisplayNameLookalike: "The display name looks like a different domain's name.",
20
+ ModelImpersonation: "The model judged that it claims an organisation its sender does not belong to.",
21
+ ModelSpam: "The model judged it spam.",
22
+ ModelClean: "The model judged it legitimate.",
23
+ ListedPhishingLink: "A link in it is on a list of known phishing pages.",
24
+ };
25
+ const MODEL_REASONS = new Set([
26
+ "ModelImpersonation",
27
+ "ModelSpam",
28
+ "ModelClean",
29
+ ]);
30
+ export const isModelReason = (reason) => MODEL_REASONS.has(reason.name);
31
+ export const UNKNOWN_REASON_SENTENCE = "Remit ran a check this version can't describe.";
32
+ export const CHECK_FAILED_HEADLINE = "Remit couldn't check this message";
33
+ export const BASIC_CHECKS_ONLY = "Only the basic checks ran";
34
+ const isDescribedReason = (name) => Object.hasOwn(REASON_SENTENCES, name);
35
+ /**
36
+ * The one sentence a reason reads as, wherever it shows. A backend symbol, or
37
+ * a name this version does not know, yields `undefined`: the caller shows the
38
+ * raw symbol and a report link instead of a guess.
39
+ */
40
+ export function spamReasonSentence(name) {
41
+ return isDescribedReason(name) ? REASON_SENTENCES[name] : undefined;
42
+ }
43
+ export function topSpamReason(reasons) {
44
+ return reasons.reduce((top, reason) => (top && top.score >= reason.score ? top : reason), undefined);
45
+ }
46
+ export function topSpamReasonSentence(reasons) {
47
+ const top = topSpamReason(reasons);
48
+ if (!top)
49
+ return "";
50
+ return spamReasonSentence(top.name) ?? UNKNOWN_REASON_SENTENCE;
51
+ }
52
+ /** What the model said, quoted from its reason, when it answered. */
53
+ export function modelSaid(verdict) {
54
+ if (verdict.modelOutcome !== "Answered")
55
+ return undefined;
56
+ const reason = verdict.reasons.find(isModelReason);
57
+ if (!reason || reason.options.length === 0)
58
+ return undefined;
59
+ return reason.options.join(" ");
60
+ }
61
+ export const MODEL_SKIP_CAUSES = {
62
+ NotConfigured: "this account has no model set up.",
63
+ DailyLimit: "this account reached its daily model limit.",
64
+ RateLimited: "the model provider asked Remit to slow down.",
65
+ };
66
+ /** Why the model did not weigh in on a message it would have helped with. */
67
+ export function modelSkipCause(verdict) {
68
+ const outcome = verdict.modelOutcome;
69
+ if (outcome === "Answered" || outcome === "OutOfBand")
70
+ return undefined;
71
+ return MODEL_SKIP_CAUSES[outcome];
72
+ }
73
+ export const SPAM_FAILURE_SENTENCES = {
74
+ Unreachable: "the spam service could not be reached",
75
+ TimedOut: "the spam service did not answer in time",
76
+ ServiceError: "the spam service answered with an error",
77
+ Unparseable: "Remit could not read the spam service's answer",
78
+ };
79
+ export const CHECK_AGAIN_FAILURE_SENTENCES = {
80
+ RateLimited: "try again in a minute.",
81
+ DailyCap: "try again tomorrow (daily model limit).",
82
+ NotSettled: "a move is still settling. Remit will retry it once the move lands.",
83
+ NotFound: "the message is gone from the server. No retry for this one.",
84
+ NotPermitted: "the server refused access to this message. No retry for this one.",
85
+ };
86
+ export const SPAM_SCREEN_SENTENCES = {
87
+ NeverSpam: "You marked this sender Never in Spam.",
88
+ Vip: "This sender is a VIP.",
89
+ WellKnown: "You know this sender well.",
90
+ Newsletter: "It is a newsletter from a sender you already get mail from.",
91
+ };
92
+ export const filterScreenSentence = (filterName) => `Your filter "${filterName}" matched it.`;
93
+ export const SPAM_WARN_HEADLINES = {
94
+ Spam: "Remit suspects this is spam",
95
+ Phishing: "Remit suspects this message impersonates someone",
96
+ };
97
+ export const formatSpamScore = (score) => score.toFixed(2);
98
+ export const spamScoreSentence = (score, thresholds) => thresholds.state === "Set"
99
+ ? `Score ${formatSpamScore(score)}. Remit warns from ${formatSpamScore(thresholds.cleanBelow)} and moves to Spam from ${formatSpamScore(thresholds.spamAt)}.`
100
+ : `Score ${formatSpamScore(score)}. The spam service applies its own thresholds.`;
@@ -0,0 +1,17 @@
1
+ /** One day of verdicts: what reached the Spam threshold and what only warned. */
2
+ export interface SpamDay {
3
+ date: string;
4
+ moved: number;
5
+ warned: number;
6
+ }
7
+ export interface SpamDailyChartProps {
8
+ title: string;
9
+ tone: "warning" | "danger";
10
+ days: SpamDay[];
11
+ }
12
+ export declare const spamDayDescription: (day: SpamDay) => string;
13
+ /**
14
+ * One bar per day, moved stacked under warned. Each bar carries its own text
15
+ * alternative.
16
+ */
17
+ export declare function SpamDailyChart({ title, tone, days }: SpamDailyChartProps): import("react").JSX.Element;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn } from "../lib/cn.js";
3
+ const TONES = {
4
+ warning: { moved: "bg-warning", warned: "bg-warning/35" },
5
+ danger: { moved: "bg-danger", warned: "bg-danger/35" },
6
+ };
7
+ export const spamDayDescription = (day) => `${day.date}: ${day.moved} moved, ${day.warned} warned`;
8
+ /**
9
+ * One bar per day, moved stacked under warned. Each bar carries its own text
10
+ * alternative.
11
+ */
12
+ export function SpamDailyChart({ title, tone, days }) {
13
+ const peak = Math.max(1, ...days.map((day) => day.moved + day.warned));
14
+ const colours = TONES[tone];
15
+ const first = days[0];
16
+ const last = days[days.length - 1];
17
+ return (_jsxs("figure", { className: "min-w-0", children: [_jsx("figcaption", { className: "text-xs font-semibold text-fg", children: title }), _jsx("ul", { className: "mt-2 flex h-24 list-none items-end gap-px border-b border-line", children: days.map((day) => (_jsx("li", { className: "h-full min-w-0 flex-1", children: _jsxs("span", { role: "img", "aria-label": spamDayDescription(day), className: "flex h-full flex-col justify-end", children: [_jsx("span", { className: cn("w-full rounded-t-sm", colours.warned), style: { height: `${(day.warned / peak) * 100}%` } }), _jsx("span", { className: cn("w-full", colours.moved), style: { height: `${(day.moved / peak) * 100}%` } })] }) }, day.date))) }), first && last && (_jsxs("div", { "aria-hidden": "true", className: "mt-1 flex justify-between text-2xs text-fg-subtle tabular-nums", children: [_jsx("span", { children: first.date }), _jsx("span", { children: last.date })] }))] }));
18
+ }
@@ -0,0 +1,19 @@
1
+ import type { RemitImapSpamChecked, RemitImapSpamFailed, RemitImapSpamThresholdsSet } from "@remit/api-http-client/types.gen.ts";
2
+ import type { CheckAgainFailure } from "./check-again-panel.js";
3
+ import type { LabelChipData } from "./label-chip.js";
4
+ import type { SpamDay } from "./spam-daily-chart.js";
5
+ export declare const spamThresholdsFixture: RemitImapSpamThresholdsSet;
6
+ export declare const spamLabelFixture: LabelChipData;
7
+ export declare const phishingLabelFixture: LabelChipData;
8
+ export declare const warnSpamVerdict: RemitImapSpamChecked;
9
+ export declare const warnPhishingVerdict: RemitImapSpamChecked;
10
+ export declare const junkPhishingVerdict: RemitImapSpamChecked;
11
+ export declare const modelSkippedVerdict: RemitImapSpamChecked;
12
+ export declare const modelJudgedVerdict: RemitImapSpamChecked;
13
+ export declare const nowJunkVerdict: RemitImapSpamChecked;
14
+ export declare const warnOnlyAboveJunkVerdict: RemitImapSpamChecked;
15
+ export declare const unknownReasonVerdict: RemitImapSpamChecked;
16
+ export declare const failedVerdict: RemitImapSpamFailed;
17
+ export declare const checkAgainFailuresFixture: CheckAgainFailure[];
18
+ export declare const spamDaysFixture: SpamDay[];
19
+ export declare const phishingDaysFixture: SpamDay[];
@@ -0,0 +1,143 @@
1
+ export const spamThresholdsFixture = {
2
+ state: "Set",
3
+ cleanBelow: 0.4,
4
+ spamAt: 0.85,
5
+ };
6
+ export const spamLabelFixture = {
7
+ labelId: "label-spam",
8
+ name: "Spam",
9
+ color: "Orange",
10
+ };
11
+ export const phishingLabelFixture = {
12
+ labelId: "label-phishing",
13
+ name: "Phishing",
14
+ color: "Red",
15
+ };
16
+ const reason = (name, score, options = []) => ({ name, symbol: name, score, options });
17
+ export const warnSpamVerdict = {
18
+ state: "Checked",
19
+ score: 0.72,
20
+ action: "Warn",
21
+ kind: "Spam",
22
+ modelOutcome: "OutOfBand",
23
+ reasons: [
24
+ reason("LinkTextMismatch", 0.3, ["bank.example -> login-check.example"]),
25
+ reason("FirstContactDomain", 0.25, ["sender-domain.example"]),
26
+ reason("ProviderSpam", 0.17),
27
+ ],
28
+ };
29
+ export const warnPhishingVerdict = {
30
+ state: "Checked",
31
+ score: 0.68,
32
+ action: "Warn",
33
+ kind: "Phishing",
34
+ modelOutcome: "OutOfBand",
35
+ reasons: [
36
+ reason("DisplayNameForeignAddress", 0.4, [
37
+ '"support@bank.example" <x@other.example>',
38
+ ]),
39
+ reason("DmarcFail", 0.28),
40
+ ],
41
+ };
42
+ export const junkPhishingVerdict = {
43
+ ...warnPhishingVerdict,
44
+ score: 0.93,
45
+ action: "Junk",
46
+ };
47
+ export const modelSkippedVerdict = {
48
+ ...warnSpamVerdict,
49
+ modelOutcome: "DailyLimit",
50
+ };
51
+ export const modelJudgedVerdict = {
52
+ state: "Checked",
53
+ score: 0.61,
54
+ action: "Warn",
55
+ kind: "Spam",
56
+ modelOutcome: "Answered",
57
+ reasons: [
58
+ reason("RecentlyRegisteredDomain", 0.35, ["registered 2026-11-02"]),
59
+ reason("ModelSpam", 0.2, [
60
+ "It pushes a payment link from a domain registered last week.",
61
+ ]),
62
+ ],
63
+ };
64
+ export const nowJunkVerdict = {
65
+ ...warnSpamVerdict,
66
+ score: 0.88,
67
+ action: "Junk",
68
+ };
69
+ export const warnOnlyAboveJunkVerdict = {
70
+ state: "Checked",
71
+ score: 0.9,
72
+ action: "Warn",
73
+ kind: "Spam",
74
+ modelOutcome: "Answered",
75
+ reasons: [
76
+ reason("LinkTextMismatch", 0.5, ["bank.example -> login-check.example"]),
77
+ reason("FirstContactDomain", 0.4, ["sender-domain.example"]),
78
+ ],
79
+ };
80
+ export const unknownReasonVerdict = {
81
+ state: "Checked",
82
+ score: 0.55,
83
+ action: "Warn",
84
+ kind: "Spam",
85
+ modelOutcome: "Answered",
86
+ reasons: [
87
+ reason("ProviderSpam", 0.3),
88
+ {
89
+ name: "BackendSymbol",
90
+ symbol: "MIME_HTML_ONLY",
91
+ score: 0.25,
92
+ options: [],
93
+ },
94
+ ],
95
+ };
96
+ export const failedVerdict = {
97
+ state: "Failed",
98
+ kind: "TimedOut",
99
+ };
100
+ export const checkAgainFailuresFixture = [
101
+ {
102
+ messageId: "m-1",
103
+ subject: "Subject line",
104
+ code: "RateLimited",
105
+ retryable: true,
106
+ },
107
+ {
108
+ messageId: "m-2",
109
+ subject: "Subject line",
110
+ code: "RateLimited",
111
+ retryable: true,
112
+ },
113
+ {
114
+ messageId: "m-3",
115
+ subject: "Subject line",
116
+ code: "DailyCap",
117
+ retryable: true,
118
+ },
119
+ {
120
+ messageId: "m-4",
121
+ subject: "Subject line",
122
+ code: "NotFound",
123
+ retryable: false,
124
+ },
125
+ ];
126
+ const DAY_MS = 24 * 60 * 60 * 1000;
127
+ const LAST_DAY = Date.UTC(2026, 10, 13);
128
+ const isoDay = (offset) => new Date(LAST_DAY - offset * DAY_MS).toISOString().slice(0, 10);
129
+ const spamPattern = [3, 5, 2, 6, 4, 1, 0, 4, 7, 3, 5, 2, 3, 6, 4];
130
+ const phishingPattern = [0, 1, 0, 0, 2, 0, 1, 0, 0, 1, 0, 0, 2, 0, 1];
131
+ export const spamDaysFixture = Array.from({ length: 30 }, (_, i) => {
132
+ const n = spamPattern[i % spamPattern.length] ?? 0;
133
+ return {
134
+ date: isoDay(29 - i),
135
+ moved: n,
136
+ warned: Math.ceil(n / 2),
137
+ };
138
+ });
139
+ export const phishingDaysFixture = Array.from({ length: 30 }, (_, i) => ({
140
+ date: isoDay(29 - i),
141
+ moved: phishingPattern[i % phishingPattern.length] ?? 0,
142
+ warned: i % 7 === 3 ? 1 : 0,
143
+ }));
@@ -0,0 +1,12 @@
1
+ import { type LabelChipData } from "./label-chip.js";
2
+ export interface SpamRowMarkerProps {
3
+ label: LabelChipData;
4
+ /** The message still sits where it arrived, under the warning. */
5
+ suspected: boolean;
6
+ }
7
+ /**
8
+ * A thread row's one spam mark: the Remit label chip, then an outlined
9
+ * Suspected marker while the message sits outside Spam. A row in Spam shows
10
+ * the chip alone, because the folder already says it moved.
11
+ */
12
+ export declare function SpamRowMarker({ label, suspected }: SpamRowMarkerProps): import("react").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { LabelChip } from "./label-chip.js";
3
+ /**
4
+ * A thread row's one spam mark: the Remit label chip, then an outlined
5
+ * Suspected marker while the message sits outside Spam. A row in Spam shows
6
+ * the chip alone, because the folder already says it moved.
7
+ */
8
+ export function SpamRowMarker({ label, suspected }) {
9
+ return (_jsxs("span", { className: "inline-flex shrink-0 items-center gap-1", children: [_jsx("span", { className: "sr-only", children: suspected ? `${label.name}, suspected` : label.name }), _jsxs("span", { "aria-hidden": "true", className: "inline-flex items-center gap-1", children: [_jsx(LabelChip, { label: label, className: "max-w-20" }), suspected && (_jsx("span", { className: "rounded-full border border-warning/60 px-1.5 text-2xs font-medium leading-4 text-warning", children: "Suspected" }))] })] }));
10
+ }
@@ -0,0 +1,37 @@
1
+ import type { RemitImapSpamChecked, RemitImapSpamFailed, RemitImapSpamLabelPlacement, RemitImapSpamThresholds, RemitImapSpamVerdictScreenedOut } from "@remit/api-http-client/types.gen.ts";
2
+ import type { ReactElement, ReactNode } from "react";
3
+ import type { LabelChipData } from "./label-chip.js";
4
+ export declare const SPAM_CHECK_HEADING_ID = "spam-check-heading";
5
+ /** Where a link in the Spam check section goes; the host maps it to a route. */
6
+ export type SpamVerdictLinkTarget = {
7
+ kind: "SpamSettings";
8
+ } | {
9
+ kind: "NeverInSpamSenders";
10
+ } | {
11
+ kind: "Filter";
12
+ filterId: string;
13
+ };
14
+ export interface SpamVerdictLinkProps {
15
+ target: SpamVerdictLinkTarget;
16
+ className: string;
17
+ children: ReactNode;
18
+ }
19
+ /** Renders an in-app link, so following it is a navigation, not a reload. */
20
+ export type SpamVerdictLinkComponent = (props: SpamVerdictLinkProps) => ReactElement;
21
+ export interface SpamVerdictPanelProps {
22
+ verdict: RemitImapSpamChecked | RemitImapSpamFailed | RemitImapSpamVerdictScreenedOut;
23
+ /** The Remit label the message carries, when it carries one. */
24
+ label?: LabelChipData;
25
+ thresholds: RemitImapSpamThresholds;
26
+ placement: RemitImapSpamLabelPlacement;
27
+ filterName?: string;
28
+ linkComponent: SpamVerdictLinkComponent;
29
+ reportIssueHref: (symbol: string) => string;
30
+ onNotSpam: () => void;
31
+ }
32
+ /**
33
+ * The intelligence rail's Spam check section: what the check concluded, the
34
+ * score against the thresholds, and one sentence per reason. Why on the
35
+ * banner focuses its heading by {@link SPAM_CHECK_HEADING_ID}.
36
+ */
37
+ export declare function SpamVerdictPanel(props: SpamVerdictPanelProps): import("react").JSX.Element;
@@ -0,0 +1,74 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn } from "../lib/cn.js";
3
+ import { Button } from "./button.js";
4
+ import { IntelligenceSection } from "./intelligence-section.js";
5
+ import { BASIC_CHECKS_ONLY, CHECK_FAILED_HEADLINE, filterScreenSentence, formatSpamScore, isModelReason, modelSaid, modelSkipCause, SPAM_FAILURE_SENTENCES, SPAM_SCREEN_SENTENCES, SPAM_WARN_HEADLINES, spamReasonSentence, spamScoreSentence, UNKNOWN_REASON_SENTENCE, } from "./spam-copy.js";
6
+ import { SpamRowMarker } from "./spam-row-marker.js";
7
+ export const SPAM_CHECK_HEADING_ID = "spam-check-heading";
8
+ const LINK = "text-accent-2 hover:underline";
9
+ function Section({ children }) {
10
+ return (_jsx(IntelligenceSection, { label: "Spam check", headingId: SPAM_CHECK_HEADING_ID, children: _jsx("div", { className: "space-y-2 text-sm", children: children }) }));
11
+ }
12
+ function Headline({ children }) {
13
+ return _jsx("p", { className: "font-semibold text-fg", children: children });
14
+ }
15
+ function ScoreBar({ score, thresholds, }) {
16
+ const at = (value) => `${Math.min(100, Math.max(0, value * 100))}%`;
17
+ return (_jsxs("div", { "aria-hidden": "true", className: "pt-4 pb-1", children: [_jsxs("div", { className: "relative h-1.5 rounded-full bg-surface-sunken", children: [_jsx("div", { className: "absolute inset-y-0 rounded-r-full bg-warning/30", style: { left: at(thresholds.cleanBelow), right: 0 } }), _jsx("div", { className: "absolute inset-y-0 rounded-r-full bg-danger/30", style: { left: at(thresholds.spamAt), right: 0 } }), [
18
+ { key: "warn", value: thresholds.cleanBelow, text: "Warn" },
19
+ { key: "junk", value: thresholds.spamAt, text: "Spam" },
20
+ ].map((mark) => (_jsx("span", { className: "absolute -top-4 -translate-x-1/2 text-2xs text-fg-subtle tabular-nums", style: { left: at(mark.value) }, children: `${mark.text} ${formatSpamScore(mark.value)}` }, mark.key))), _jsx("span", { className: "absolute top-1/2 size-3 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-surface bg-fg", style: { left: at(score) } })] }), _jsxs("div", { className: "mt-1 flex justify-between text-2xs text-fg-subtle tabular-nums", children: [_jsx("span", { children: "0" }), _jsx("span", { children: "1" })] })] }));
21
+ }
22
+ function Finding({ text }) {
23
+ return (_jsx("code", { className: "mt-0.5 inline-block max-w-full break-all rounded bg-surface-sunken px-1.5 py-0.5 font-mono text-2xs text-fg-muted", children: text }));
24
+ }
25
+ function ReasonItem({ reason, reportIssueHref, }) {
26
+ const sentence = spamReasonSentence(reason.name);
27
+ if (!sentence) {
28
+ return (_jsxs("li", { children: [_jsx("p", { className: "text-fg", children: UNKNOWN_REASON_SENTENCE }), _jsx(Finding, { text: reason.symbol }), _jsx("a", { href: reportIssueHref(reason.symbol), target: "_blank", rel: "noopener noreferrer", className: cn("ml-2 text-xs", LINK), children: "Report an issue" })] }));
29
+ }
30
+ return (_jsxs("li", { children: [_jsx("p", { className: "text-fg", children: sentence }), reason.options.length > 0 && (_jsx(Finding, { text: reason.options.join(", ") }))] }));
31
+ }
32
+ function CheckedVerdict({ verdict, label, thresholds, placement, linkComponent: Link, reportIssueHref, }) {
33
+ const said = modelSaid(verdict);
34
+ const skipped = modelSkipCause(verdict);
35
+ const headline = verdict.action === "Junk"
36
+ ? "Remit moved this to Spam"
37
+ : verdict.action === "Warn"
38
+ ? SPAM_WARN_HEADLINES[verdict.kind]
39
+ : "Remit found too little to act on";
40
+ const keptByWarnOnly = verdict.action !== "None" &&
41
+ placement === "WarnOnly" &&
42
+ thresholds.state === "Set" &&
43
+ verdict.score >= thresholds.spamAt;
44
+ return (_jsxs(Section, { children: [_jsx(Headline, { children: headline }), label && verdict.action !== "None" && (_jsx(SpamRowMarker, { label: label, suspected: verdict.action === "Warn" })), _jsx("p", { className: "text-fg-muted", children: spamScoreSentence(verdict.score, thresholds) }), thresholds.state === "Set" && (_jsx(ScoreBar, { score: verdict.score, thresholds: thresholds })), _jsxs("div", { children: [_jsx("h4", { className: "text-xs font-semibold text-fg", children: "Why" }), _jsx("ul", { className: "mt-1 list-disc space-y-1.5 pl-4 marker:text-fg-subtle", children: verdict.reasons
45
+ .filter((reason) => !isModelReason(reason))
46
+ .map((reason) => (_jsx(ReasonItem, { reason: reason, reportIssueHref: reportIssueHref }, reason.symbol))) })] }), said !== undefined && (_jsxs("div", { className: "text-fg-muted", children: [_jsx("p", { children: "Remit asked the model. It said:" }), _jsx("blockquote", { className: "mt-0.5 border-l-2 border-line pl-2 italic", children: said })] })), skipped !== undefined && (_jsx("p", { className: "text-fg-muted", children: `${BASIC_CHECKS_ONLY}: ${skipped}` })), keptByWarnOnly && (_jsxs("p", { className: "text-fg-muted", children: ["The score reached your Spam threshold. Spam is set to Warn only, so it stays here.", " ", _jsx(Link, { target: { kind: "SpamSettings" }, className: LINK, children: "Change in Spam & phishing settings" })] }))] }));
47
+ }
48
+ function ScreenedOutVerdict({ verdict, label, filterName, linkComponent: Link, onNotSpam, }) {
49
+ const { screen } = verdict;
50
+ if (screen.rule === "ReportedSender") {
51
+ return (_jsxs(Section, { children: [_jsx(Headline, { children: "You reported this sender" }), label && _jsx(SpamRowMarker, { label: label, suspected: false }), _jsx("p", { className: "text-fg-muted", children: "Remit sent their mail to Spam without checking it." }), _jsx(Button, { variant: "secondary", size: "md", onClick: onNotSpam, children: "Not spam" })] }));
52
+ }
53
+ if (screen.rule === "Filter") {
54
+ return (_jsxs(Section, { children: [_jsx(Headline, { children: "Remit skipped the spam check" }), _jsx("p", { className: "text-fg-muted", children: filterName
55
+ ? filterScreenSentence(filterName)
56
+ : "One of your filters matched it." }), _jsx(Link, { target: { kind: "Filter", filterId: screen.filterId }, className: LINK, children: "Open the filter in Settings" })] }));
57
+ }
58
+ return (_jsxs(Section, { children: [_jsx(Headline, { children: "Remit skipped the spam check" }), _jsx("p", { className: "text-fg-muted", children: SPAM_SCREEN_SENTENCES[screen.rule] }), screen.rule === "NeverSpam" && (_jsx(Link, { target: { kind: "NeverInSpamSenders" }, className: LINK, children: "Manage in Senders & Rules" }))] }));
59
+ }
60
+ /**
61
+ * The intelligence rail's Spam check section: what the check concluded, the
62
+ * score against the thresholds, and one sentence per reason. Why on the
63
+ * banner focuses its heading by {@link SPAM_CHECK_HEADING_ID}.
64
+ */
65
+ export function SpamVerdictPanel(props) {
66
+ const { verdict } = props;
67
+ if (verdict.state === "ScreenedOut") {
68
+ return _jsx(ScreenedOutVerdict, { ...props, verdict: verdict });
69
+ }
70
+ if (verdict.state === "Failed") {
71
+ return (_jsxs(Section, { children: [_jsx(Headline, { children: CHECK_FAILED_HEADLINE }), _jsx("p", { className: "text-fg-muted", children: `The spam check failed: ${SPAM_FAILURE_SENTENCES[verdict.kind]}.` })] }));
72
+ }
73
+ return _jsx(CheckedVerdict, { ...props, verdict: verdict });
74
+ }
@@ -0,0 +1,20 @@
1
+ import type { RemitImapRescanFailureCode, RemitImapSpamChecked, RemitImapSpamFailed } from "@remit/api-http-client/types.gen.ts";
2
+ export type SpamWarningPending = "NotSpam" | "Report" | "Move" | "CheckAgain";
3
+ export interface SpamWarningBannerProps {
4
+ verdict: RemitImapSpamChecked | RemitImapSpamFailed;
5
+ inSpamFolder: boolean;
6
+ pending?: SpamWarningPending;
7
+ checkAgainFailure?: RemitImapRescanFailureCode;
8
+ onNotSpam: () => void;
9
+ onReport: () => void;
10
+ onMove: () => void;
11
+ onWhy: () => void;
12
+ onCheckAgain: () => void;
13
+ }
14
+ /**
15
+ * The message view's one banner slot, between the header and the body. The
16
+ * verdict decides what it says: a failed check, a Check again that now reaches
17
+ * Spam for a message outside it, or a warning. It has no close control; it
18
+ * goes when its verdict goes.
19
+ */
20
+ export declare function SpamWarningBanner({ verdict, inSpamFolder, pending, checkAgainFailure, onNotSpam, onReport, onMove, onWhy, onCheckAgain, }: SpamWarningBannerProps): import("react").JSX.Element | null;
@@ -0,0 +1,62 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { CircleQuestionMark, ShieldAlert, TriangleAlert } from "../icons.js";
3
+ import { cn } from "../lib/cn.js";
4
+ import { Banner } from "./banner.js";
5
+ import { Button } from "./button.js";
6
+ import { BASIC_CHECKS_ONLY, CHECK_AGAIN_FAILURE_SENTENCES, CHECK_FAILED_HEADLINE, formatSpamScore, modelSkipCause, SPAM_FAILURE_SENTENCES, SPAM_WARN_HEADLINES, topSpamReasonSentence, } from "./spam-copy.js";
7
+ const PENDING_LABELS = {
8
+ NotSpam: "Removing label...",
9
+ Report: "Reporting...",
10
+ Move: "Moving...",
11
+ CheckAgain: "Checking...",
12
+ };
13
+ const ACTION_BUTTON = "h-10";
14
+ function BannerAction({ label, pending, busy, onClick, variant = "secondary", disabled = false, }) {
15
+ const pressed = pending === busy;
16
+ const blocked = pending !== undefined || disabled;
17
+ return (_jsx(Button, { variant: variant, size: "md", className: cn(ACTION_BUTTON, blocked && "pointer-events-none opacity-60"), "aria-disabled": blocked || undefined, "aria-busy": pressed || undefined, onClick: blocked ? undefined : onClick, children: pressed ? PENDING_LABELS[busy] : label }));
18
+ }
19
+ function WhyButton({ onWhy }) {
20
+ return (_jsx(Button, { variant: "ghost", size: "md", className: ACTION_BUTTON, onClick: onWhy, children: "Why" }));
21
+ }
22
+ function BannerBody({ tone, icon, headline, lines, actions, role, }) {
23
+ return (_jsx(Banner, { tone: tone, variant: "soft", role: role, className: "rounded-none border-b border-line px-5 py-3", children: _jsxs("div", { className: "flex items-start gap-2", children: [_jsx("span", { className: "mt-0.5 shrink-0", "aria-hidden": "true", children: icon }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("p", { className: "font-semibold text-fg", children: headline }), lines.map((line) => (_jsx("p", { className: "mt-0.5 text-fg-muted", children: line }, line))), _jsx("div", { className: "mt-2 flex flex-wrap gap-2", children: actions })] })] }) }));
24
+ }
25
+ /**
26
+ * The message view's one banner slot, between the header and the body. The
27
+ * verdict decides what it says: a failed check, a Check again that now reaches
28
+ * Spam for a message outside it, or a warning. It has no close control; it
29
+ * goes when its verdict goes.
30
+ */
31
+ export function SpamWarningBanner({ verdict, inSpamFolder, pending, checkAgainFailure, onNotSpam, onReport, onMove, onWhy, onCheckAgain, }) {
32
+ if (verdict.state === "Failed") {
33
+ return (_jsx(BannerBody, { tone: "info", role: "status", icon: _jsx(CircleQuestionMark, { className: "size-4 text-accent-2" }), headline: CHECK_FAILED_HEADLINE, lines: [
34
+ `The spam check failed: ${SPAM_FAILURE_SENTENCES[verdict.kind]}. No label was added.`,
35
+ ...(checkAgainFailure
36
+ ? [
37
+ `Check again didn't finish: ${CHECK_AGAIN_FAILURE_SENTENCES[checkAgainFailure]}`,
38
+ ]
39
+ : []),
40
+ ], actions: _jsx(BannerAction, { label: "Check again", pending: pending, busy: "CheckAgain", disabled: checkAgainFailure === "DailyCap", onClick: onCheckAgain }) }));
41
+ }
42
+ if (verdict.action === "None")
43
+ return null;
44
+ if (verdict.action === "Junk" && inSpamFolder)
45
+ return null;
46
+ const phishing = verdict.kind === "Phishing";
47
+ const skipped = modelSkipCause(verdict);
48
+ const tone = phishing ? "danger" : "warning";
49
+ const role = phishing ? "alert" : "status";
50
+ const icon = phishing ? (_jsx(ShieldAlert, { className: "size-4 text-danger" })) : (_jsx(TriangleAlert, { className: "size-4 text-warning" }));
51
+ if (verdict.action === "Junk") {
52
+ return (_jsx(BannerBody, { tone: tone, role: role, icon: icon, headline: phishing
53
+ ? "Remit now judges this phishing"
54
+ : "Remit now judges this spam", lines: [
55
+ `Check again scored it ${formatSpamScore(verdict.score)}, past your Move to Spam threshold. It stays here until you move it.`,
56
+ ], actions: _jsxs(_Fragment, { children: [_jsx(BannerAction, { label: "Move to Spam", variant: "primary", pending: pending, busy: "Move", onClick: onMove }), _jsx(BannerAction, { label: "Not spam", pending: pending, busy: "NotSpam", onClick: onNotSpam }), _jsx(WhyButton, { onWhy: onWhy })] }) }));
57
+ }
58
+ return (_jsx(BannerBody, { tone: tone, role: role, icon: icon, headline: SPAM_WARN_HEADLINES[verdict.kind], lines: [
59
+ topSpamReasonSentence(verdict.reasons),
60
+ ...(skipped ? [`${BASIC_CHECKS_ONLY}: ${skipped}`] : []),
61
+ ], actions: _jsxs(_Fragment, { children: [_jsx(BannerAction, { label: "Not spam", pending: pending, busy: "NotSpam", onClick: onNotSpam }), _jsx(BannerAction, { label: "Report spam", pending: pending, busy: "Report", onClick: onReport }), _jsx(WhyButton, { onWhy: onWhy })] }) }));
62
+ }