@remit/ui 0.0.233 → 0.0.234

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.
@@ -297,6 +297,7 @@ export const organiserSender = {
297
297
  summary: "This message was signed by northwind.example.",
298
298
  },
299
299
  category: { value: "personal" },
300
+ spamAction: "reportSpam",
300
301
  flags: { vip: true },
301
302
  };
302
303
  export const airlineSender = {
@@ -315,4 +316,5 @@ export const airlineSender = {
315
316
  summary: "This message was signed by klm.example.",
316
317
  },
317
318
  category: { value: "transactional" },
319
+ spamAction: "reportSpam",
318
320
  };
@@ -1,5 +1,6 @@
1
1
  import { type ThreadCategory } from "../category-presentation.js";
2
2
  import { type IntelligenceCalendarActions, type IntelligenceCalendarData } from "./intelligence-calendar.js";
3
+ import { type PlacementIntel } from "./intelligence-placement.js";
3
4
  export type SenderTrustLevel = "unknown" | "wellknown" | "vip";
4
5
  export interface SenderIntel {
5
6
  name: string;
@@ -66,16 +67,17 @@ export interface IntelligenceData {
66
67
  overridden?: boolean;
67
68
  };
68
69
  flags?: SenderFlagsIntel;
70
+ /** Where Remit placed this message and why. Absent when Remit recorded no verdict. */
71
+ placement?: PlacementIntel;
72
+ spamAction: SpamAction;
69
73
  }
74
+ /** Which spam control the message offers: undo its spam report, move it out of Junk, or report it. */
75
+ export type SpamAction = "undoSpamReport" | "notSpam" | "reportSpam";
70
76
  export interface IntelligenceQuickActions {
71
77
  onToggleVip?: () => void;
72
78
  onToggleMute?: () => void;
73
79
  onReclassify?: () => void;
74
- /**
75
- * "Not spam": undo a spam report — clears the sender block and moves the
76
- * message back where it came from (issue #648). Wired only when the
77
- * message currently carries a spam report.
78
- */
80
+ /** "Not spam": wired only when `spamAction` is not "reportSpam". */
79
81
  onNotSpam?: () => void;
80
82
  /**
81
83
  * "Report spam": move the message into Junk and block the sender (the
@@ -7,6 +7,7 @@ import { Avatar } from "./avatar.js";
7
7
  import { Badge } from "./badge.js";
8
8
  import { Button } from "./button.js";
9
9
  import { IntelligenceCalendar, } from "./intelligence-calendar.js";
10
+ import { Placement } from "./intelligence-placement.js";
10
11
  import { IntelligenceSection } from "./intelligence-section.js";
11
12
  import { SegmentedControl } from "./segmented-control.js";
12
13
  const tabOptions = [
@@ -53,7 +54,8 @@ function QuickAction({ icon, label, active, danger, onClick, pending, }) {
53
54
  : "border-line text-fg-muted hover:border-line-strong hover:text-fg", danger && !active && "text-danger hover:bg-danger-soft", disabled && "cursor-not-allowed opacity-50 hover:border-line"), children: [icon, label] }));
54
55
  }
55
56
  export function IntelligencePanel({ data, onClose, actions, className, hideCloseButton = false, reportSpamPending = false, notSpamPending = false, calendar, tab, onTabChange, defaultTab = "sender", touch, }) {
56
- const { sender, authenticity, category, flags = {} } = data;
57
+ const { sender, authenticity, category, flags = {}, placement, spamAction, } = data;
58
+ const notSpamPendingLabel = spamAction === "undoSpamReport" ? "Undoing…" : "Moving…";
57
59
  const [ownTab, setOwnTab] = useState(defaultTab);
58
60
  const tabStripName = useId();
59
61
  const activeTab = tab ?? ownTab;
@@ -63,5 +65,5 @@ export function IntelligencePanel({ data, onClose, actions, className, hideClose
63
65
  setOwnTab(next);
64
66
  onTabChange?.(next);
65
67
  } }) })), calendarTab && (_jsx(IntelligenceCalendar, { data: calendarTab.data, actions: calendarTab.actions, selectedEventId: calendarTab.selectedEventId, touch: touch })), calendarTab === undefined && (_jsxs(_Fragment, { children: [_jsx(IntelligenceSection, { label: "Sender", children: _jsx(SenderCard, { sender: sender }) }), _jsx(IntelligenceSection, { label: "Authenticity", children: _jsx(Authenticity, { auth: authenticity }) }), _jsx(IntelligenceSection, { label: "Category", children: _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Badge, { tone: categoryTone[category.value], children: categoryLabels[category.value] }), category.overridden && (_jsx("span", { className: "text-2xs text-fg-subtle", children: "your override" })), _jsx("button", { type: "button", className: cn("ml-auto text-2xs text-accent hover:underline", !actions?.onReclassify &&
66
- "cursor-not-allowed opacity-50 hover:no-underline"), disabled: !actions?.onReclassify, onClick: actions?.onReclassify, children: "reclassify" })] }) }), _jsxs(IntelligenceSection, { label: "Quick actions", children: [_jsxs("div", { className: "flex flex-wrap gap-1.5", children: [_jsx(QuickAction, { icon: _jsx(Star, { className: "size-3.5" }), label: "VIP", active: flags.vip, onClick: actions?.onToggleVip }), _jsx(QuickAction, { icon: _jsx(BellOff, { className: "size-3.5" }), label: "Mute", active: flags.muted, onClick: actions?.onToggleMute }), actions?.onNotSpam && (_jsx(QuickAction, { icon: _jsx(MailCheck, { className: "size-3.5" }), label: notSpamPending ? "Undoing…" : "Not spam", active: true, onClick: actions.onNotSpam, pending: notSpamPending })), actions?.onReportSpam && (_jsx(QuickAction, { icon: _jsx(ShieldX, { className: "size-3.5" }), label: reportSpamPending ? "Reporting…" : "Report spam", danger: true, onClick: actions.onReportSpam, pending: reportSpamPending }))] }), actions?.onNotSpam && (_jsx("p", { className: "mt-1.5 text-2xs text-fg-subtle", children: "You reported this message as spam" }))] }), _jsx(IntelligenceSection, { label: "Coming soon", className: "border-b-0 opacity-70", children: _jsxs("div", { className: "space-y-2", children: [_jsxs("div", { className: "flex items-start gap-2 rounded-md border border-dashed border-line p-2", children: [_jsx(Sparkles, { className: "mt-0.5 size-3.5 shrink-0 text-fg-subtle" }), _jsxs("div", { children: [_jsx("div", { className: "text-xs font-medium text-fg-muted", children: "Suggested actions" }), _jsx("div", { className: "text-2xs text-fg-subtle", children: "\"Create a filter for messages like this\" \u2014 on-device model" })] })] }), _jsxs("div", { className: "flex items-start gap-2 rounded-md border border-dashed border-line p-2", children: [_jsx(Sparkles, { className: "mt-0.5 size-3.5 shrink-0 text-fg-subtle" }), _jsxs("div", { children: [_jsx("div", { className: "text-xs font-medium text-fg-muted", children: "Thread summary" }), _jsx("div", { className: "text-2xs text-fg-subtle", children: "One-paragraph digest \u2014 Bedrock" })] })] })] }) })] }))] }));
68
+ "cursor-not-allowed opacity-50 hover:no-underline"), disabled: !actions?.onReclassify, onClick: actions?.onReclassify, children: "reclassify" })] }) }), placement && (_jsx(IntelligenceSection, { label: "Placement", children: _jsx(Placement, { placement: placement }) })), _jsxs(IntelligenceSection, { label: "Quick actions", children: [_jsxs("div", { className: "flex flex-wrap gap-1.5", children: [_jsx(QuickAction, { icon: _jsx(Star, { className: "size-3.5" }), label: "VIP", active: flags.vip, onClick: actions?.onToggleVip }), _jsx(QuickAction, { icon: _jsx(BellOff, { className: "size-3.5" }), label: "Mute", active: flags.muted, onClick: actions?.onToggleMute }), actions?.onNotSpam && (_jsx(QuickAction, { icon: _jsx(MailCheck, { className: "size-3.5" }), label: notSpamPending ? notSpamPendingLabel : "Not spam", active: true, onClick: actions.onNotSpam, pending: notSpamPending })), actions?.onReportSpam && (_jsx(QuickAction, { icon: _jsx(ShieldX, { className: "size-3.5" }), label: reportSpamPending ? "Reporting…" : "Report spam", danger: true, onClick: actions.onReportSpam, pending: reportSpamPending }))] }), actions?.onNotSpam && spamAction === "undoSpamReport" && (_jsx("p", { className: "mt-1.5 text-2xs text-fg-subtle", children: "You reported this message as spam" }))] }), _jsx(IntelligenceSection, { label: "Coming soon", className: "border-b-0 opacity-70", children: _jsxs("div", { className: "space-y-2", children: [_jsxs("div", { className: "flex items-start gap-2 rounded-md border border-dashed border-line p-2", children: [_jsx(Sparkles, { className: "mt-0.5 size-3.5 shrink-0 text-fg-subtle" }), _jsxs("div", { children: [_jsx("div", { className: "text-xs font-medium text-fg-muted", children: "Suggested actions" }), _jsx("div", { className: "text-2xs text-fg-subtle", children: "\"Create a filter for messages like this\" \u2014 on-device model" })] })] }), _jsxs("div", { className: "flex items-start gap-2 rounded-md border border-dashed border-line p-2", children: [_jsx(Sparkles, { className: "mt-0.5 size-3.5 shrink-0 text-fg-subtle" }), _jsxs("div", { children: [_jsx("div", { className: "text-xs font-medium text-fg-muted", children: "Thread summary" }), _jsx("div", { className: "text-2xs text-fg-subtle", children: "One-paragraph digest \u2014 Bedrock" })] })] })] }) })] }))] }));
67
69
  }
@@ -0,0 +1,13 @@
1
+ import { PlacementAction, PlacementConfidence } from "@remit/domain-enums";
2
+ export interface PlacementIntel {
3
+ action: (typeof PlacementAction)[keyof typeof PlacementAction];
4
+ confidence: (typeof PlacementConfidence)[keyof typeof PlacementConfidence];
5
+ /** The folder the message sat in when Remit judged it: inbox, junk or other. */
6
+ fromPlacement: string;
7
+ /** Reason codes as the server wrote them. */
8
+ reasons: string[];
9
+ dryRun: boolean;
10
+ }
11
+ export declare function Placement({ placement }: {
12
+ placement: PlacementIntel;
13
+ }): import("react").JSX.Element;
@@ -0,0 +1,40 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { PlacementAction, PlacementConfidence } from "@remit/domain-enums";
3
+ import { Badge } from "./badge.js";
4
+ const reasonCopy = new Map(Object.entries({
5
+ "sender=blocked": "You blocked this sender.",
6
+ "sender=untrusted": "You have no history with this sender.",
7
+ "classifier=spam": "The classifier judged it spam.",
8
+ "dkim-mismatch": "It was signed by a different domain than its sender.",
9
+ "dmarc=fail": "It failed the sender domain's DMARC check.",
10
+ "dmarc=pass": "It passed the sender domain's DMARC check.",
11
+ "deferred-to-llm": "The signals were left for the classifier to judge.",
12
+ "no-confident-signal": "Nothing marked it as junk.",
13
+ "placed-in-junk": "It was already reported or moved to Junk.",
14
+ "already-moved-by-remit": "Remit had already moved it.",
15
+ "body-unreadable": "Its body could not be read.",
16
+ }));
17
+ function placementReasonCopy(code) {
18
+ return reasonCopy.get(code) ?? code;
19
+ }
20
+ function placementHeadline(placement) {
21
+ const fromJunk = placement.fromPlacement === "junk";
22
+ if (placement.action === PlacementAction.MoveToJunk && fromJunk) {
23
+ return "Remit kept this in Junk";
24
+ }
25
+ const verb = placement.dryRun ? "would move" : "moved";
26
+ if (placement.action === PlacementAction.MoveToInbox) {
27
+ return fromJunk
28
+ ? `Remit ${verb} this out of Junk`
29
+ : `Remit ${verb} this to the Inbox`;
30
+ }
31
+ return `Remit ${verb} this to Junk`;
32
+ }
33
+ const confidenceLabel = {
34
+ [PlacementConfidence.Confident]: { label: "Confident", tone: "positive" },
35
+ [PlacementConfidence.Unsure]: { label: "Unsure", tone: "warning" },
36
+ };
37
+ export function Placement({ placement }) {
38
+ const confidence = confidenceLabel[placement.confidence];
39
+ return (_jsxs("div", { children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "text-xs text-fg", children: placementHeadline(placement) }), _jsx(Badge, { tone: confidence.tone, dot: true, className: "ml-auto", children: confidence.label })] }), placement.reasons.length > 0 && (_jsx("ul", { className: "mt-2 list-disc space-y-0.5 pl-4 text-2xs text-fg-muted", children: placement.reasons.map((code) => (_jsx("li", { children: placementReasonCopy(code) }, code))) }))] }));
40
+ }
package/dist/index.d.ts CHANGED
@@ -98,7 +98,8 @@ export { FolderSyncBadge, type FolderSyncBadgeProps, type FolderSyncMailbox, typ
98
98
  export { type FolderTreeNode, FolderTreePicker, type FolderTreePickerLabels, type FolderTreePickerProps, type FolderTreeRow, } from "./components/folder-tree-picker.js";
99
99
  export { Input, type InputProps, type InputVariant, } from "./components/input.js";
100
100
  export { type CalendarDayEntry, type CalendarInviteIntel, type CalendarProseIntel, type CalendarSuggestionIntel, IntelligenceCalendar, type IntelligenceCalendarActions, type IntelligenceCalendarData, type IntelligenceCalendarProps, } from "./components/intelligence-calendar.js";
101
- export { type AuthenticityIntel, type IntelligenceCalendarSurface, type IntelligenceData, IntelligencePanel, type IntelligencePanelProps, type IntelligenceQuickActions, type IntelligenceTabId, type SenderFlagsIntel, type SenderIntel, type SenderTrustLevel, } from "./components/intelligence-panel.js";
101
+ export { type AuthenticityIntel, type IntelligenceCalendarSurface, type IntelligenceData, IntelligencePanel, type IntelligencePanelProps, type IntelligenceQuickActions, type IntelligenceTabId, type SenderFlagsIntel, type SenderIntel, type SenderTrustLevel, type SpamAction, } from "./components/intelligence-panel.js";
102
+ export type { PlacementIntel } from "./components/intelligence-placement.js";
102
103
  export { IntelligenceSection } from "./components/intelligence-section.js";
103
104
  export { IntelligenceToggle, type IntelligenceToggleProps, } from "./components/intelligence-toggle.js";
104
105
  export { IsolatedEmailFrame, type IsolatedEmailFrameProps, measureContentAxis, } from "./components/isolated-email-frame.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/ui",
3
- "version": "0.0.233",
3
+ "version": "0.0.234",
4
4
  "type": "module",
5
5
  "sideEffects": [
6
6
  "**/*.css",