@remit/web-client 0.0.347 → 0.0.349

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 (57) hide show
  1. package/dist/src/components/mail/BriefPane.js +3 -3
  2. package/dist/src/components/mail/CheckAgainProvider.d.ts +30 -0
  3. package/dist/src/components/mail/CheckAgainProvider.js +194 -0
  4. package/dist/src/components/mail/CollectionList.js +4 -2
  5. package/dist/src/components/mail/CollectionPane.js +3 -3
  6. package/dist/src/components/mail/ConversationView.d.ts +7 -8
  7. package/dist/src/components/mail/ConversationView.js +4 -4
  8. package/dist/src/components/mail/DailyBrief.js +11 -6
  9. package/dist/src/components/mail/IntelligencePane.d.ts +2 -2
  10. package/dist/src/components/mail/IntelligencePane.js +33 -4
  11. package/dist/src/components/mail/MailSidebarAdapter.js +17 -6
  12. package/dist/src/components/mail/MailboxPane.js +10 -12
  13. package/dist/src/components/mail/MessageActionMenu.d.ts +3 -1
  14. package/dist/src/components/mail/MessageActionMenu.js +3 -3
  15. package/dist/src/components/mail/MessageCard.js +9 -1
  16. package/dist/src/components/mail/MessageList.js +11 -2
  17. package/dist/src/components/mail/MessageListItem.d.ts +4 -2
  18. package/dist/src/components/mail/MessageListItem.js +4 -6
  19. package/dist/src/components/mail/SpamBannerSlot.d.ts +10 -0
  20. package/dist/src/components/mail/SpamBannerSlot.js +56 -0
  21. package/dist/src/components/mail/SwipeableMessageRow.d.ts +3 -2
  22. package/dist/src/components/mail/SwipeableMessageRow.js +6 -6
  23. package/dist/src/components/mail/ThreadListInteraction.d.ts +2 -0
  24. package/dist/src/components/mail/ThreadListInteraction.js +12 -2
  25. package/dist/src/components/settings/classification/FailureBanner.js +3 -4
  26. package/dist/src/components/settings/spam/SpamSettingsPanel.d.ts +6 -0
  27. package/dist/src/components/settings/spam/SpamSettingsPanel.js +176 -0
  28. package/dist/src/hooks/useIntelligenceData.d.ts +2 -4
  29. package/dist/src/hooks/useIntelligenceData.js +1 -127
  30. package/dist/src/hooks/useJunkMailboxIds.d.ts +2 -0
  31. package/dist/src/hooks/useJunkMailboxIds.js +17 -0
  32. package/dist/src/lib/brief.d.ts +1 -1
  33. package/dist/src/lib/brief.js +3 -3
  34. package/dist/src/lib/check-again.d.ts +33 -0
  35. package/dist/src/lib/check-again.js +66 -0
  36. package/dist/src/lib/conversation-target.d.ts +3 -2
  37. package/dist/src/lib/result-folder.js +7 -0
  38. package/dist/src/lib/spam-overview.d.ts +23 -0
  39. package/dist/src/lib/spam-overview.js +44 -0
  40. package/dist/src/lib/spam.d.ts +32 -0
  41. package/dist/src/lib/spam.js +38 -0
  42. package/dist/src/lib/thread-search-tokens.js +3 -1
  43. package/dist/src/routeTree.gen.d.ts +27 -5
  44. package/dist/src/routeTree.gen.js +7 -0
  45. package/dist/src/routes/__root.js +2 -1
  46. package/dist/src/routes/settings/filters.d.ts +6 -2
  47. package/dist/src/routes/settings/filters.js +10 -3
  48. package/dist/src/routes/settings/senders.d.ts +14 -2
  49. package/dist/src/routes/settings/senders.js +32 -15
  50. package/dist/src/routes/settings/spam.d.ts +1 -0
  51. package/dist/src/routes/settings/spam.js +15 -0
  52. package/dist/src/routes/settings.js +6 -1
  53. package/dist/src/routing/spam-link.d.ts +3 -0
  54. package/dist/src/routing/spam-link.js +12 -0
  55. package/package.json +2 -2
  56. package/dist/src/components/mail/AuthenticityBanner.d.ts +0 -14
  57. package/dist/src/components/mail/AuthenticityBanner.js +0 -18
@@ -73,7 +73,7 @@ function BriefPaneProvider({ thread, children }) {
73
73
  mailboxId: selectedThread?.mailboxId ?? "",
74
74
  subject: selectedThread?.subject,
75
75
  messageId: selectedMessageId,
76
- authenticity: selectedThread?.authenticity,
76
+ row: selectedThread,
77
77
  };
78
78
  }, [threadId, selectedThread, selectedMessageId]);
79
79
  const handleOpenThread = useCallback((target, options) => {
@@ -214,7 +214,7 @@ function BriefReading() {
214
214
  currentMailboxId: actions.mailboxId,
215
215
  onMove: actions.moveThread,
216
216
  }
217
- : undefined }), _jsx("div", { className: "min-h-0 flex-1 overflow-hidden", children: conversation ? (_jsx(ConversationView, { threadId: conversation.threadId, mailboxId: conversation.mailboxId, subject: conversation.subject, selectedMessageId: conversation.messageId, authenticity: conversation.authenticity, onOpenIntelligence: intelligence.open, listOnScreen: true })) : (_jsx(ReadingPaneEmpty, {})) })] }), _jsx(IntelligenceDrawer, { isOpen: intelligence.drawerOpen, onClose: intelligence.closeDrawer, thread: selectedThread, accountId: selectedThread?.accountId, onAfterOptimisticRemove: handleDeselectIfRemoved, onReplyWithText: replyWithText, onOpenThread: onOpenThread })] }));
217
+ : undefined }), _jsx("div", { className: "min-h-0 flex-1 overflow-hidden", children: conversation ? (_jsx(ConversationView, { threadId: conversation.threadId, mailboxId: conversation.mailboxId, subject: conversation.subject, selectedMessageId: conversation.messageId, spamRow: conversation.row, onOpenIntelligence: intelligence.open, listOnScreen: true })) : (_jsx(ReadingPaneEmpty, {})) })] }), _jsx(IntelligenceDrawer, { isOpen: intelligence.drawerOpen, onClose: intelligence.closeDrawer, thread: selectedThread, accountId: selectedThread?.accountId, onAfterOptimisticRemove: handleDeselectIfRemoved, onReplyWithText: replyWithText, onOpenThread: onOpenThread })] }));
218
218
  }
219
219
  /**
220
220
  * Intelligence pane: IntelligencePane for the thread open in the brief.
@@ -234,7 +234,7 @@ function BriefPhone() {
234
234
  const { selectedThread, conversation, onOpenThread, onCloseThread, nextThread, previousThread, handleDeselectIfRemoved, } = useBriefPane();
235
235
  const drawer = useIntelligenceDrawer(conversation?.threadId ?? null);
236
236
  if (conversation) {
237
- return (_jsxs(_Fragment, { children: [_jsx(ConversationView, { threadId: conversation.threadId, mailboxId: conversation.mailboxId, subject: conversation.subject, selectedMessageId: conversation.messageId, authenticity: conversation.authenticity, onBack: onCloseThread, onOpenIntelligence: drawer.toggle, onSwipeNext: nextThread ? () => onOpenThread(nextThread) : undefined, onSwipePrevious: previousThread ? () => onOpenThread(previousThread) : undefined, mobileIntelligenceOpen: drawer.isOpen }), _jsx(IntelligenceDrawer, { isOpen: drawer.isOpen, onClose: drawer.close, thread: selectedThread, accountId: selectedThread?.accountId, onAfterOptimisticRemove: handleDeselectIfRemoved, onReplyWithText: replyWithText, onOpenThread: onOpenThread })] }));
237
+ return (_jsxs(_Fragment, { children: [_jsx(ConversationView, { threadId: conversation.threadId, mailboxId: conversation.mailboxId, subject: conversation.subject, selectedMessageId: conversation.messageId, spamRow: conversation.row, onBack: onCloseThread, onOpenIntelligence: drawer.toggle, onSwipeNext: nextThread ? () => onOpenThread(nextThread) : undefined, onSwipePrevious: previousThread ? () => onOpenThread(previousThread) : undefined, mobileIntelligenceOpen: drawer.isOpen }), _jsx(IntelligenceDrawer, { isOpen: drawer.isOpen, onClose: drawer.close, thread: selectedThread, accountId: selectedThread?.accountId, onAfterOptimisticRemove: handleDeselectIfRemoved, onReplyWithText: replyWithText, onOpenThread: onOpenThread })] }));
238
238
  }
239
239
  // The same list slot the multi-pane layout mounts, so the phone brief wires
240
240
  // the bulk verbs and the selection bar through `DailyBrief` exactly as the
@@ -0,0 +1,30 @@
1
+ import type { RemitImapRescanFailureCode, RemitImapThreadMessageResponse } from "@remit/api-http-client/types.gen.ts";
2
+ import { type ThreadRowData } from "@remit/ui";
3
+ import { type ReactNode } from "react";
4
+ import { type CheckAgainTarget } from "../../lib/check-again";
5
+ export type CheckAgainRequest = CheckAgainTarget;
6
+ export interface CheckAgainContextValue {
7
+ /**
8
+ * Checks the messages again. A list shows the progress panel; a single
9
+ * message shows its new verdict in its own banner instead.
10
+ */
11
+ checkAgain: (requests: readonly CheckAgainRequest[], options: {
12
+ panel: boolean;
13
+ }) => void;
14
+ /** Ids in the batch in flight. */
15
+ pendingIds: ReadonlySet<string>;
16
+ /** Why the last run left a message unchecked. */
17
+ failures: ReadonlyMap<string, RemitImapRescanFailureCode>;
18
+ }
19
+ /** Absent outside the app shell, where nothing can run a check. */
20
+ export declare const useCheckAgain: () => CheckAgainContextValue | undefined;
21
+ /**
22
+ * Owns every Check again run: it sends ten ids per call, one call at a time,
23
+ * so the panel can count each batch as it lands and Stop can end the run after
24
+ * the batch in flight. The run lives in memory and ends with the page.
25
+ */
26
+ export declare function CheckAgainProvider({ children }: {
27
+ children: ReactNode;
28
+ }): import("react").JSX.Element;
29
+ export declare const checkAgainRequestOfThread: (thread: RemitImapThreadMessageResponse, junkMailboxIds: ReadonlySet<string>) => CheckAgainRequest;
30
+ export declare const checkAgainRequestOfRow: (row: ThreadRowData) => CheckAgainRequest | undefined;
@@ -0,0 +1,194 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { threadDetailOperationsListThreadMessagesQueryKey } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
3
+ import { accountMessageOperationsRescanMessages } from "@remit/api-http-client/sdk.gen.ts";
4
+ import { CHECK_AGAIN_FAILURE_SENTENCES, CheckAgainPanel, } from "@remit/ui";
5
+ import { useQueryClient } from "@tanstack/react-query";
6
+ import { createContext, useCallback, useContext, useMemo, useRef, useState, } from "react";
7
+ import { ApiError } from "../../lib/api";
8
+ import { applyRescanResult, EMPTY_SUMMARY, refusedBatch, rescanBatches, } from "../../lib/check-again";
9
+ import { escalate } from "../../lib/escalate";
10
+ import { reportSignedOut } from "../../lib/signed-out";
11
+ import { spamReportHref, spamRowMark } from "../../lib/spam";
12
+ import { invalidateThreadListQueries, threadListCacheKeys, } from "../../lib/thread-list-cache";
13
+ import { useErrorBanners } from "../ui/error-banner-context";
14
+ const CheckAgainContext = createContext(undefined);
15
+ /** Absent outside the app shell, where nothing can run a check. */
16
+ export const useCheckAgain = () => useContext(CheckAgainContext);
17
+ const sendBatch = async (batch) => {
18
+ const response = await accountMessageOperationsRescanMessages({
19
+ path: { accountId: batch.accountId },
20
+ body: { messageIds: batch.targets.map((target) => target.messageId) },
21
+ });
22
+ if (response.data)
23
+ return response.data;
24
+ if (!response.response)
25
+ throw response.error;
26
+ const status = response.response.status;
27
+ if (status === 401)
28
+ return "SignedOut";
29
+ if (status === 403)
30
+ return refusedBatch(batch, "NotPermitted");
31
+ if (status === 404)
32
+ return refusedBatch(batch, "NotFound");
33
+ throw new ApiError(`Check again failed with ${status}`, status, response.error);
34
+ };
35
+ /**
36
+ * Owns every Check again run: it sends ten ids per call, one call at a time,
37
+ * so the panel can count each batch as it lands and Stop can end the run after
38
+ * the batch in flight. The run lives in memory and ends with the page.
39
+ */
40
+ export function CheckAgainProvider({ children }) {
41
+ const queryClient = useQueryClient();
42
+ const { pushError } = useErrorBanners();
43
+ const [panel, setPanel] = useState(undefined);
44
+ const [pendingIds, setPendingIds] = useState(new Set());
45
+ const [failures, setFailures] = useState(new Map());
46
+ const runningRef = useRef(false);
47
+ const stopRef = useRef(false);
48
+ const settle = useCallback((targets) => {
49
+ invalidateThreadListQueries(queryClient, threadListCacheKeys(targets.map((target) => target.mailboxId)));
50
+ for (const threadId of new Set(targets.map((t) => t.threadId))) {
51
+ if (!threadId)
52
+ continue;
53
+ queryClient.invalidateQueries({
54
+ queryKey: threadDetailOperationsListThreadMessagesQueryKey({
55
+ path: { threadId },
56
+ }),
57
+ });
58
+ }
59
+ }, [queryClient]);
60
+ const run = useCallback(async (targets, showPanel) => {
61
+ const total = targets.length;
62
+ let outcome = {
63
+ summary: EMPTY_SUMMARY,
64
+ failures: [],
65
+ };
66
+ let checked = 0;
67
+ if (showPanel)
68
+ setPanel({ state: "Running", checked, total });
69
+ for (const batch of rescanBatches(targets)) {
70
+ if (stopRef.current)
71
+ break;
72
+ setPendingIds(new Set(batch.targets.map((t) => t.messageId)));
73
+ const result = await sendBatch(batch);
74
+ if (result === "SignedOut") {
75
+ reportSignedOut();
76
+ setPendingIds(new Set());
77
+ return;
78
+ }
79
+ outcome = applyRescanResult(outcome, batch, result);
80
+ checked += batch.targets.length;
81
+ setFailures((current) => {
82
+ const next = new Map(current);
83
+ for (const success of result.successful) {
84
+ next.delete(success.messageId);
85
+ }
86
+ for (const failure of result.failed) {
87
+ next.set(failure.messageId, failure.code);
88
+ }
89
+ return next;
90
+ });
91
+ if (showPanel)
92
+ setPanel({ state: "Running", checked, total });
93
+ }
94
+ setPendingIds(new Set());
95
+ settle(targets);
96
+ if (stopRef.current) {
97
+ setPanel(undefined);
98
+ return;
99
+ }
100
+ if (!showPanel) {
101
+ for (const failure of outcome.failures) {
102
+ pushError({
103
+ title: "Couldn't check this message again",
104
+ detail: `${failure.subject}: ${CHECK_AGAIN_FAILURE_SENTENCES[failure.code]}`,
105
+ });
106
+ }
107
+ return;
108
+ }
109
+ if (outcome.failures.length === 0) {
110
+ setPanel({ state: "Done", total, summary: outcome.summary });
111
+ return;
112
+ }
113
+ const retryIds = new Set(outcome.failures.filter((f) => f.retryable).map((f) => f.messageId));
114
+ setPanel({
115
+ state: "PartialFailure",
116
+ checked,
117
+ total,
118
+ failures: outcome.failures,
119
+ retry: targets.filter((target) => retryIds.has(target.messageId)),
120
+ });
121
+ }, [pushError, settle]);
122
+ const start = useCallback((targets, showPanel) => {
123
+ if (targets.length === 0)
124
+ return;
125
+ if (runningRef.current) {
126
+ pushError({
127
+ severity: "info",
128
+ title: "Check again is already running",
129
+ detail: "Wait for the run in progress to finish, or stop it.",
130
+ });
131
+ return;
132
+ }
133
+ runningRef.current = true;
134
+ stopRef.current = false;
135
+ void run(targets, showPanel)
136
+ .catch((error) => {
137
+ setPendingIds(new Set());
138
+ setPanel(undefined);
139
+ escalate(error);
140
+ })
141
+ .finally(() => {
142
+ runningRef.current = false;
143
+ });
144
+ }, [run, pushError]);
145
+ const checkAgain = useCallback((requests, options) => {
146
+ start([...requests], options.panel);
147
+ }, [start]);
148
+ const value = useMemo(() => ({ checkAgain, pendingIds, failures }), [checkAgain, pendingIds, failures]);
149
+ const panelProps = (() => {
150
+ if (!panel)
151
+ return undefined;
152
+ if (panel.state === "Running") {
153
+ return {
154
+ ...panel,
155
+ onStop: () => {
156
+ stopRef.current = true;
157
+ },
158
+ };
159
+ }
160
+ if (panel.state === "Done") {
161
+ return { ...panel, onDone: () => setPanel(undefined) };
162
+ }
163
+ return {
164
+ state: "PartialFailure",
165
+ checked: panel.checked,
166
+ total: panel.total,
167
+ failures: panel.failures,
168
+ reportIssueHref: spamReportHref("Check again left messages unchecked", panel.failures
169
+ .map((failure) => `${failure.messageId}: ${failure.code}`)
170
+ .join(", ")),
171
+ onRetry: () => start(panel.retry, true),
172
+ onClose: () => setPanel(undefined),
173
+ };
174
+ })();
175
+ return (_jsxs(CheckAgainContext.Provider, { value: value, children: [children, panelProps && (_jsx("div", { className: "pointer-events-none fixed inset-x-3 bottom-3 z-40 flex justify-center", children: _jsx("div", { className: "pointer-events-auto w-full max-w-md", children: _jsx(CheckAgainPanel, { ...panelProps }) }) }))] }));
176
+ }
177
+ export const checkAgainRequestOfThread = (thread, junkMailboxIds) => ({
178
+ messageId: thread.messageId,
179
+ accountId: thread.accountId,
180
+ mailboxId: thread.mailboxId,
181
+ threadId: thread.threadId,
182
+ subject: thread.subject ?? "(No subject)",
183
+ before: spamRowMark(thread, junkMailboxIds),
184
+ });
185
+ export const checkAgainRequestOfRow = (row) => row.mailboxId && row.accountId
186
+ ? {
187
+ messageId: row.id,
188
+ accountId: row.accountId,
189
+ mailboxId: row.mailboxId,
190
+ threadId: row.threadId,
191
+ subject: row.subject,
192
+ before: row.spam,
193
+ }
194
+ : undefined;
@@ -31,6 +31,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
31
31
  import { flaggedFilterConfig, formatErrorMessage, MessageListPane, } from "@remit/ui";
32
32
  import { useCallback, useMemo, useState } from "react";
33
33
  import { useCollectionThreads, useCollectionUnreadCount, } from "../../hooks/useCollectionThreads";
34
+ import { useJunkMailboxIds } from "../../hooks/useJunkMailboxIds";
34
35
  import { useIsDesktop } from "../../hooks/useMediaQuery";
35
36
  import { useSearchTokenContext } from "../../hooks/useSearchTokenContext";
36
37
  import { matchesSearchTokens, toThreadRowData } from "../../lib/brief";
@@ -106,12 +107,13 @@ export function CollectionList({ collection, title, selectedMessageId, onOpenThr
106
107
  // beside it — which is what gives a search the same error state, the same
107
108
  // pagination and the same loading state as the unsearched list.
108
109
  const { threads, isLoading, isError, error, refetch, fetchNextPage, hasNextPage, isFetchingNextPage, } = useCollectionThreads(collection, textCriteria);
110
+ const junkMailboxIds = useJunkMailboxIds();
109
111
  const rows = useMemo(() =>
110
112
  // What is left is what no parameter can carry: `before:`, `after:`,
111
113
  // `in:`, `account:`, and a token the chips overruled.
112
114
  dedupeByThread(threads)
113
- .map(toThreadRowData)
114
- .filter((t) => matchesSearchTokens(t, residualTokens)), [threads, residualTokens]);
115
+ .map((thread) => toThreadRowData(thread, junkMailboxIds))
116
+ .filter((t) => matchesSearchTokens(t, residualTokens)), [threads, residualTokens, junkMailboxIds]);
115
117
  const openRow = useCallback((id, options) => {
116
118
  const threadId = rows.find((row) => row.id === id)?.threadId;
117
119
  if (!threadId)
@@ -53,7 +53,7 @@ function CollectionPaneProvider({ collection, title, thread, children, }) {
53
53
  mailboxId: selectedThread?.mailboxId ?? "",
54
54
  subject: selectedThread?.subject,
55
55
  messageId: selectedMessageId,
56
- authenticity: selectedThread?.authenticity,
56
+ row: selectedThread,
57
57
  };
58
58
  }, [threadId, selectedThread, selectedMessageId]);
59
59
  const handleOpenThread = useCallback((target, options) => {
@@ -193,7 +193,7 @@ function CollectionReading() {
193
193
  currentMailboxId: actions.mailboxId,
194
194
  onMove: actions.moveThread,
195
195
  }
196
- : undefined }), _jsx("div", { className: "min-h-0 flex-1 overflow-hidden", children: conversation ? (_jsx(ConversationView, { threadId: conversation.threadId, mailboxId: conversation.mailboxId, subject: conversation.subject, selectedMessageId: conversation.messageId, authenticity: conversation.authenticity, onOpenIntelligence: intelligence.open, listOnScreen: true })) : (_jsx(ReadingPaneEmpty, {})) })] }), _jsx(IntelligenceDrawer, { isOpen: intelligence.drawerOpen, onClose: intelligence.closeDrawer, thread: selectedThread, accountId: selectedThread?.accountId, onAfterOptimisticRemove: handleDeselectIfRemoved, onReplyWithText: replyWithText, onOpenThread: onOpenThread })] }));
196
+ : undefined }), _jsx("div", { className: "min-h-0 flex-1 overflow-hidden", children: conversation ? (_jsx(ConversationView, { threadId: conversation.threadId, mailboxId: conversation.mailboxId, subject: conversation.subject, selectedMessageId: conversation.messageId, spamRow: conversation.row, onOpenIntelligence: intelligence.open, listOnScreen: true })) : (_jsx(ReadingPaneEmpty, {})) })] }), _jsx(IntelligenceDrawer, { isOpen: intelligence.drawerOpen, onClose: intelligence.closeDrawer, thread: selectedThread, accountId: selectedThread?.accountId, onAfterOptimisticRemove: handleDeselectIfRemoved, onReplyWithText: replyWithText, onOpenThread: onOpenThread })] }));
197
197
  }
198
198
  /**
199
199
  * Intelligence pane: IntelligencePane for the open thread.
@@ -211,7 +211,7 @@ function CollectionPhone() {
211
211
  const { selectedThread, conversation, onCloseThread, onOpenThread, nextThread, previousThread, handleDeselectIfRemoved, } = useCollectionPane();
212
212
  const drawer = useIntelligenceDrawer(conversation?.threadId ?? null);
213
213
  if (conversation) {
214
- return (_jsxs(_Fragment, { children: [_jsx(ConversationView, { threadId: conversation.threadId, mailboxId: conversation.mailboxId, subject: conversation.subject, selectedMessageId: conversation.messageId, authenticity: conversation.authenticity, onBack: onCloseThread, onOpenIntelligence: drawer.toggle, onSwipeNext: nextThread ? () => onOpenThread(nextThread) : undefined, onSwipePrevious: previousThread ? () => onOpenThread(previousThread) : undefined, mobileIntelligenceOpen: drawer.isOpen }), _jsx(IntelligenceDrawer, { isOpen: drawer.isOpen, onClose: drawer.close, thread: selectedThread, accountId: selectedThread?.accountId, onAfterOptimisticRemove: handleDeselectIfRemoved, onReplyWithText: replyWithText, onOpenThread: onOpenThread })] }));
214
+ return (_jsxs(_Fragment, { children: [_jsx(ConversationView, { threadId: conversation.threadId, mailboxId: conversation.mailboxId, subject: conversation.subject, selectedMessageId: conversation.messageId, spamRow: conversation.row, onBack: onCloseThread, onOpenIntelligence: drawer.toggle, onSwipeNext: nextThread ? () => onOpenThread(nextThread) : undefined, onSwipePrevious: previousThread ? () => onOpenThread(previousThread) : undefined, mobileIntelligenceOpen: drawer.isOpen }), _jsx(IntelligenceDrawer, { isOpen: drawer.isOpen, onClose: drawer.close, thread: selectedThread, accountId: selectedThread?.accountId, onAfterOptimisticRemove: handleDeselectIfRemoved, onReplyWithText: replyWithText, onOpenThread: onOpenThread })] }));
215
215
  }
216
216
  return (_jsx("div", { className: "h-full", children: _jsx(CollectionListSlot, {}) }));
217
217
  }
@@ -1,4 +1,4 @@
1
- import type { RemitImapMessageAuthenticity } from "@remit/api-http-client/types.gen.ts";
1
+ import type { RemitImapThreadMessageResponse } from "@remit/api-http-client/types.gen.ts";
2
2
  interface ConversationViewProps {
3
3
  threadId: string;
4
4
  mailboxId: string;
@@ -10,14 +10,13 @@ interface ConversationViewProps {
10
10
  */
11
11
  selectedMessageId?: string;
12
12
  /**
13
- * Authenticity signal from the thread row (DKIM mismatch). When present
14
- * and `dkimMismatch` is true, a danger banner renders above the message
15
- * body with a "Why?" link that opens the intelligence sidebar.
13
+ * The row the reader opened. Its spam verdict decides the banner between
14
+ * the header and the body.
16
15
  */
17
- authenticity?: RemitImapMessageAuthenticity;
16
+ spamRow?: RemitImapThreadMessageResponse;
18
17
  /**
19
- * Callback for the "Why?" link in the authenticity banner — opens /
20
- * focuses the intelligence sidebar.
18
+ * Callback for Why on the spam banner — opens / focuses the intelligence
19
+ * sidebar.
21
20
  */
22
21
  onOpenIntelligence?: () => void;
23
22
  /**
@@ -48,5 +47,5 @@ interface ConversationViewProps {
48
47
  */
49
48
  listOnScreen?: boolean;
50
49
  }
51
- export declare const ConversationView: ({ threadId, mailboxId, subject, selectedMessageId, authenticity, onOpenIntelligence, onBack, onSwipeNext, onSwipePrevious, mobileIntelligenceOpen, listOnScreen, }: ConversationViewProps) => import("react").JSX.Element;
50
+ export declare const ConversationView: ({ threadId, mailboxId, subject, selectedMessageId, spamRow, onOpenIntelligence, onBack, onSwipeNext, onSwipePrevious, mobileIntelligenceOpen, listOnScreen, }: ConversationViewProps) => import("react").JSX.Element;
52
51
  export {};
@@ -10,12 +10,12 @@ import { useIsDesktop } from "../../hooks/useMediaQuery";
10
10
  import { useToggleStar } from "../../hooks/useToggleStar";
11
11
  import { useOpenReply, useReplySurface } from "../../routing";
12
12
  import { ConversationCompose } from "../compose/ConversationCompose";
13
- import { AuthenticityBanner } from "./AuthenticityBanner";
14
13
  import { MessageCard } from "./MessageCard";
14
+ import { SpamBannerSlot } from "./SpamBannerSlot";
15
15
  const LoadingSkeleton = () => (_jsxs("div", { className: "animate-pulse p-4", children: [_jsx("div", { className: "h-6 bg-surface-sunken rounded w-3/4 mb-5" }), _jsx("div", { className: "space-y-4", children: Array.from({ length: 2 }).map((_, i) => (
16
16
  // biome-ignore lint/suspicious/noArrayIndexKey: list is static, no stable id
17
17
  _jsxs("div", { className: "flex gap-3 py-3", children: [_jsx("div", { className: "size-10 bg-surface-sunken rounded-full shrink-0" }), _jsxs("div", { className: "flex-1", children: [_jsx("div", { className: "h-4 bg-surface-sunken rounded w-32 mb-2" }), _jsx("div", { className: "h-3 bg-surface-sunken rounded w-48" })] })] }, i))) })] }));
18
- export const ConversationView = ({ threadId, mailboxId, subject, selectedMessageId, authenticity, onOpenIntelligence, onBack, onSwipeNext, onSwipePrevious, mobileIntelligenceOpen, listOnScreen = false, }) => {
18
+ export const ConversationView = ({ threadId, mailboxId, subject, selectedMessageId, spamRow, onOpenIntelligence, onBack, onSwipeNext, onSwipePrevious, mobileIntelligenceOpen, listOnScreen = false, }) => {
19
19
  const isDesktop = useIsDesktop();
20
20
  const { accountId: mailboxAccountId } = useMailboxAccount(mailboxId);
21
21
  const { data: messagesResponse, isLoading, isError, error, refetch, } = useQuery({
@@ -273,7 +273,7 @@ export const ConversationView = ({ threadId, mailboxId, subject, selectedMessage
273
273
  // drawer). Each expanded card owns its per-message action bar; there is no
274
274
  // thread-level reply footer. The phishing warning leads the scroll content.
275
275
  if (!isDesktop) {
276
- return (_jsxs(MobileReadingPane, { thread: { subject: displaySubject, messages: [] }, onBack: onBack ?? (() => undefined), intelligenceOpen: mobileIntelligenceOpen, onToggleIntelligence: onOpenIntelligence, onSwipeNext: onSwipeNext, onSwipePrevious: onSwipePrevious, children: [authenticity?.dkimMismatch && (_jsx(AuthenticityBanner, { authenticity: authenticity, onOpenIntelligence: onOpenIntelligence })), compose, renderMessages(true)] }));
276
+ return (_jsxs(MobileReadingPane, { thread: { subject: displaySubject, messages: [] }, onBack: onBack ?? (() => undefined), intelligenceOpen: mobileIntelligenceOpen, onToggleIntelligence: onOpenIntelligence, onSwipeNext: onSwipeNext, onSwipePrevious: onSwipePrevious, children: [spamRow && (_jsx(SpamBannerSlot, { row: spamRow, onOpenIntelligence: onOpenIntelligence })), compose, renderMessages(true)] }));
277
277
  }
278
- return (_jsxs("article", { className: "h-full flex flex-col", children: [header, authenticity?.dkimMismatch && (_jsx(AuthenticityBanner, { authenticity: authenticity, onOpenIntelligence: onOpenIntelligence })), _jsxs("div", { className: "min-h-0 flex-1 overflow-auto", children: [compose, renderMessages(false)] })] }));
278
+ return (_jsxs("article", { className: "h-full flex flex-col", children: [header, spamRow && (_jsx(SpamBannerSlot, { row: spamRow, onOpenIntelligence: onOpenIntelligence })), _jsxs("div", { className: "min-h-0 flex-1 overflow-auto", children: [compose, renderMessages(false)] })] }));
279
279
  };
@@ -64,6 +64,7 @@ import { useCallback, useMemo, useState, } from "react";
64
64
  import { useJunkMailbox } from "../../hooks/useArchiveMailbox";
65
65
  import { useBriefSearchRows, useBriefSections, } from "../../hooks/useBriefSections";
66
66
  import { isSyncingPhase, useInitialSyncProgress, } from "../../hooks/useInitialSyncProgress";
67
+ import { useJunkMailboxIds } from "../../hooks/useJunkMailboxIds";
67
68
  import { useLabelList } from "../../hooks/useLabels";
68
69
  import { useLayoutTier } from "../../hooks/useLayoutTier";
69
70
  import { useIsDesktop } from "../../hooks/useMediaQuery";
@@ -78,7 +79,7 @@ import { junkDestination } from "../../lib/junk-destination";
78
79
  import { useMailContext } from "../../lib/mail-context";
79
80
  import { useMailFreshness } from "../../lib/mail-freshness";
80
81
  import { shouldRequestResultCount } from "../../lib/result-count";
81
- import { junkMailboxIds } from "../../lib/result-folder";
82
+ import { junkMailboxIds, resolveResultFolder } from "../../lib/result-folder";
82
83
  import { rowToSearchResult } from "../../lib/search-result";
83
84
  import { showInlineSearchResults } from "../../lib/search-surface";
84
85
  import { parseSearchTokens } from "../../lib/search-tokens";
@@ -151,7 +152,7 @@ export const resolveBriefSelectionScope = (rows, selectedIds) => {
151
152
  * `ThreadListInteraction`, so the brief and the mailbox list run one model.
152
153
  */
153
154
  function BriefSelectionChrome({ header, rows, wizard, children, }) {
154
- const { selectedIds, selectedCount, exitSelection, orderedIds, allSelected, toggleAllLoaded, } = useThreadListSelection();
155
+ const { selectedIds, selectedCount, exitSelection, orderedIds, allSelected, toggleAllLoaded, checkAgainSelection, } = useThreadListSelection();
155
156
  const scope = useMemo(() => resolveBriefSelectionScope(rows, selectedIds), [rows, selectedIds]);
156
157
  const { junkMailboxId } = useJunkMailbox(scope.accountId);
157
158
  const { labels } = useLabelList(scope.accountId);
@@ -175,7 +176,7 @@ function BriefSelectionChrome({ header, rows, wizard, children, }) {
175
176
  const notice = scope.moveDisabledHint
176
177
  ? { tone: "warning", text: scope.moveDisabledHint }
177
178
  : undefined;
178
- const selectionBar = (chrome) => (_jsx(SelectionTopBar, { title: chrome.title, navSlot: chrome.navSlot, titleMeta: chrome.titleMeta, searchSlot: chrome.searchSlot, searchField: chrome.searchField, idleSlot: chrome.makeFilterSlot, count: selectedCount, onCancel: exitSelection, onDelete: () => wizard.start("delete"), onMove: () => wizard.start("move"), onOrganize: () => wizard.start("organize"), onJunk: junkDestinationId ? () => wizard.start("junk") : undefined, onMarkRead: () => wizard.start("markRead"), overflowSlot: scope.accountId &&
179
+ const selectionBar = (chrome) => (_jsx(SelectionTopBar, { title: chrome.title, navSlot: chrome.navSlot, titleMeta: chrome.titleMeta, searchSlot: chrome.searchSlot, searchField: chrome.searchField, idleSlot: chrome.makeFilterSlot, count: selectedCount, onCancel: exitSelection, onDelete: () => wizard.start("delete"), onMove: () => wizard.start("move"), onOrganize: () => wizard.start("organize"), onJunk: junkDestinationId ? () => wizard.start("junk") : undefined, onMarkRead: () => wizard.start("markRead"), onCheckAgain: checkAgainSelection, overflowSlot: scope.accountId &&
179
180
  scope.mailboxId &&
180
181
  selectedCount > 0 &&
181
182
  labels.length > 0 ? (_jsx(LabelApplyTrigger, { accountId: scope.accountId, mailboxId: scope.mailboxId, messageIds: selectedMessageIds })) : undefined, selectAll: selectAll, notice: notice }));
@@ -357,6 +358,7 @@ export function DailyBrief({ accounts, selectedMessageId, onOpenThread, commands
357
358
  // pill, mute, the free text, `from:` and `subject:` — was answered over the
358
359
  // whole scope by the request itself, and the order the rows arrived in is
359
360
  // kept: narrowing never re-sorts.
361
+ const spamFolderIds = useJunkMailboxIds();
360
362
  const clientOnlyFilters = useMemo(() => briefClientOnlyFilters(requestFilters), [requestFilters]);
361
363
  const narrowRows = useCallback((rows) =>
362
364
  // One row per conversation, because that is what the server counted:
@@ -364,9 +366,9 @@ export function DailyBrief({ accounts, selectedMessageId, onOpenThread, commands
364
366
  // rows under a header reading one. Collapsed before anything reads a
365
367
  // length, so the rows and the number are the same unit.
366
368
  dedupeByThread(rows)
367
- .map(toThreadRowData)
369
+ .map((thread) => toThreadRowData(thread, spamFolderIds))
368
370
  .filter((t) => matchesBriefFilters(t, clientOnlyFilters) &&
369
- matchesSearchTokens(t, residualTokens)), [clientOnlyFilters, residualTokens]);
371
+ matchesSearchTokens(t, residualTokens)), [clientOnlyFilters, residualTokens, spamFolderIds]);
370
372
  const briefRows = useMemo(() => sectionRows.map((section) => ({
371
373
  category: section.category,
372
374
  total: section.total,
@@ -375,7 +377,10 @@ export function DailyBrief({ accounts, selectedMessageId, onOpenThread, commands
375
377
  failed: section.failed,
376
378
  rows: narrowRows(section.rows),
377
379
  })), [sectionRows, narrowRows]);
378
- const matchRows = useMemo(() => narrowRows(searchRows), [searchRows, narrowRows]);
380
+ const matchRows = useMemo(() => narrowRows(searchRows).map((row) => {
381
+ const { folder } = resolveResultFolder(resultFolderIndex, row.mailboxId ? [row.mailboxId] : []);
382
+ return folder ? { ...row, folder } : row;
383
+ }), [searchRows, narrowRows, resultFolderIndex]);
379
384
  // Each section answers for itself, so a retry is that section's own request.
380
385
  const retrySection = useCallback((sectionId) => {
381
386
  sectionRows.find((section) => section.category === sectionId)?.retry();
@@ -1,5 +1,5 @@
1
1
  import type { RemitImapThreadMessageResponse } from "@remit/api-http-client/types.gen.ts";
2
- import { type SpamAction } from "@remit/ui";
2
+ import { type SpamQuickAction } from "@remit/ui";
3
3
  import type { OpenThreadTarget } from "../../routing";
4
4
  import type { ReplyWithText } from "../compose/reply-with-times";
5
5
  export interface IntelligencePaneProps {
@@ -45,7 +45,7 @@ export interface IntelligencePaneProps {
45
45
  */
46
46
  export declare const resolveSpamAction: (thread: {
47
47
  spamReport?: unknown;
48
- }, inJunk: boolean) => SpamAction;
48
+ }, inJunk: boolean) => SpamQuickAction;
49
49
  /**
50
50
  * Pane 4 of the 4-pane shell: the intelligence sidebar. Wired to real data via
51
51
  * `useIntelligenceData`; renders the `IntelligencePanel` from `@remit/ui`.
@@ -1,17 +1,21 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { threadDetailOperationsListThreadMessagesOptions } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
3
- import { CATEGORY_PRESENTATION, categoryLabels, DialogBackdrop, IntelligencePanel, useModalFocus, } from "@remit/ui";
2
+ import { threadDetailOperationsListThreadMessagesOptions, userSettingsOperationsGetUserSettingsOptions, } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
3
+ import { CATEGORY_PRESENTATION, categoryLabels, DialogBackdrop, IntelligencePanel, SpamVerdictPanel, useModalFocus, } from "@remit/ui";
4
4
  import { Sparkles } from "@remit/ui/icons";
5
- import { useQueryClient } from "@tanstack/react-query";
5
+ import { useQuery, useQueryClient } from "@tanstack/react-query";
6
6
  import { useCallback, useMemo, useRef, useState } from "react";
7
7
  import { useJunkMailbox } from "../../hooks/useArchiveMailbox";
8
+ import { useFilterList } from "../../hooks/useFilters";
8
9
  import { useIntelligenceCalendar } from "../../hooks/useIntelligenceCalendar";
9
10
  import { useIntelligenceData } from "../../hooks/useIntelligenceData";
10
11
  import { useReportSpam } from "../../hooks/useReportSpam";
11
12
  import { useUpdateAddressFlags } from "../../hooks/useUpdateAddressFlags";
13
+ import { softErrorStatuses } from "../../lib/error-classifier";
12
14
  import { isRescueCandidate } from "../../lib/rescue-candidates";
13
15
  import { recordRescueSentToJunk } from "../../lib/rescue-telemetry";
16
+ import { remitSpamLabel, unknownReasonReportHref } from "../../lib/spam";
14
17
  import { useTelemetry } from "../../lib/telemetry-context";
18
+ import { SpamVerdictLink } from "../../routing/spam-link";
15
19
  const isCategoryOverride = (category) => category !== "uncategorized";
16
20
  const CATEGORY_OVERRIDES = CATEGORY_PRESENTATION.map((entry) => entry.category).filter(isCategoryOverride);
17
21
  /**
@@ -50,6 +54,31 @@ function ReclassifyDialog({ isOpen, current, hasOverride, onSelect, onClear, onC
50
54
  return null;
51
55
  return (_jsxs("div", { className: "fixed inset-0 z-50 flex items-center justify-center", children: [_jsx(DialogBackdrop, { label: "Dismiss reclassify sender", onDismiss: onCancel, className: "backdrop-blur-sm" }), _jsxs("div", { ref: dialogRef, role: "dialog", "aria-modal": "true", "aria-label": "Reclassify sender", tabIndex: -1, className: "relative z-10 w-full max-w-sm rounded-sm border border-line bg-surface p-6 shadow-lg", children: [_jsx("h2", { className: "text-lg font-semibold", children: "Reclassify this sender" }), _jsx("p", { className: "mt-2 text-sm text-fg-muted", children: "Set a category override for future messages from this sender." }), _jsxs("div", { className: "mt-4 flex flex-col gap-1", children: [CATEGORY_OVERRIDES.map((cat) => (_jsxs("button", { type: "button", onClick: () => onSelect(cat), className: `flex min-h-11 items-center justify-between rounded px-3 text-left text-sm transition-colors hover:bg-surface-raised ${cat === current ? "font-semibold text-accent" : "text-fg"}`, children: [categoryLabels[cat], cat === current && (_jsx("span", { className: "text-2xs text-fg-subtle", children: "current" }))] }, cat))), hasOverride && (_jsx("button", { type: "button", onClick: onClear, className: "mt-1 flex min-h-11 items-center rounded border-t border-line px-3 text-left text-sm text-fg transition-colors hover:bg-surface-raised", children: "Remove override \u2014 classify automatically again" }))] }), _jsx("div", { className: "mt-6 flex justify-end", children: _jsx("button", { type: "button", onClick: onCancel, className: "inline-flex min-h-11 items-center justify-center rounded border border-line px-4 text-sm font-medium transition-colors hover:bg-surface-raised", children: "Cancel" }) })] })] }));
52
56
  }
57
+ /**
58
+ * The rail's Spam check section: the verdict the message carries, or the
59
+ * one a Check again just returned, against the thresholds in effect.
60
+ */
61
+ function SpamCheckSection({ thread, accountId, onNotSpam, }) {
62
+ const verdict = thread.spamVerdict;
63
+ if (verdict.state === "NotChecked")
64
+ return null;
65
+ return (_jsx(SpamVerdictSection, { thread: thread, verdict: verdict, accountId: accountId, onNotSpam: onNotSpam }));
66
+ }
67
+ function SpamVerdictSection({ thread, verdict, accountId, onNotSpam, }) {
68
+ const settings = useQuery({
69
+ ...userSettingsOperationsGetUserSettingsOptions(),
70
+ meta: softErrorStatuses(403),
71
+ });
72
+ const filterId = verdict.state === "ScreenedOut" && verdict.screen.rule === "Filter"
73
+ ? verdict.screen.filterId
74
+ : undefined;
75
+ const { filters } = useFilterList(filterId ? accountId : undefined);
76
+ if (!settings.data)
77
+ return null;
78
+ const { spam } = settings.data;
79
+ const kind = verdict.state === "Checked" ? verdict.kind : "Spam";
80
+ return (_jsx(SpamVerdictPanel, { verdict: verdict, label: remitSpamLabel(thread.labels), thresholds: spam.thresholds, placement: kind === "Phishing" ? spam.phishingPlacement : spam.spamPlacement, filterName: filters.find((filter) => filter.filterId === filterId)?.name, linkComponent: SpamVerdictLink, reportIssueHref: unknownReasonReportHref, onNotSpam: onNotSpam }));
81
+ }
53
82
  /**
54
83
  * Inner panel that resolves intelligence data and wires quick-action mutations.
55
84
  */
@@ -138,7 +167,7 @@ function WiredPanel({ thread, onClose, accountId, hideCloseButton, onAfterOptimi
138
167
  if (!data) {
139
168
  return _jsx(IntelligenceSkeleton, {});
140
169
  }
141
- return (_jsxs(_Fragment, { children: [_jsx(IntelligencePanel, { data: data, calendar: calendar.surface, tab: calendar.tab, onTabChange: calendar.onTabChange, onClose: onClose, hideCloseButton: hideCloseButton, actions: actions, reportSpamPending: isReporting, notSpamPending: isRestoring,
170
+ return (_jsxs(_Fragment, { children: [_jsx(IntelligencePanel, { data: data, calendar: calendar.surface, tab: calendar.tab, onTabChange: calendar.onTabChange, onClose: onClose, hideCloseButton: hideCloseButton, actions: actions, reportSpamPending: isReporting, notSpamPending: isRestoring, spamCheck: _jsx(SpamCheckSection, { thread: thread, accountId: accountId, onNotSpam: handleNotSpam }),
142
171
  // No left border: the ResizableHandle to our left already draws the
143
172
  // hairline seam. The remit-ui IntelligencePanel default `border-l`
144
173
  // would double it to 2px.
@@ -85,17 +85,27 @@ export function MailSidebarAdapter({ accounts, onMailboxSelect, variant = "deskt
85
85
  // before its label is known. A failed label list leaves the tree whole.
86
86
  const { labels, isPending: labelsPending, isError: labelsFailed, } = useLabelList(accounts[0]?.accountId);
87
87
  const labelsSettled = !labelsPending || labelsFailed;
88
- const navLabels = useMemo(() => labels.map((label) => ({
89
- id: labelNavId(label.labelId),
90
- name: label.name,
91
- color: label.color,
92
- })), [labels]);
88
+ const navLabels = useMemo(() => {
89
+ const unseenByMailbox = new Map(mailboxQueries.flatMap((query) => (query.data?.items ?? []).map((mb) => [mb.mailboxId, mb.unseenCount])));
90
+ return labels.map((label) => {
91
+ const unseen = label.folders.reduce((sum, folder) => folder.state === "Missing"
92
+ ? sum
93
+ : sum + (unseenByMailbox.get(folder.mailboxId) ?? 0), 0);
94
+ return {
95
+ id: labelNavId(label.labelId),
96
+ name: label.name,
97
+ color: label.color,
98
+ unseen: unseen > 0 ? unseen : undefined,
99
+ };
100
+ });
101
+ }, [labels, mailboxQueries]);
93
102
  const { data: outboxResponse } = useQuery(outboxOperationsListOutboxMessagesOptions());
94
103
  const outboxPendingCount = useMemo(() => (outboxResponse?.items ?? []).filter((item) => isOutboxListRow(item.status)).length, [outboxResponse?.items]);
95
104
  const navAccounts = useMemo(() => {
96
105
  return accounts.map((account, i) => {
97
106
  const query = mailboxQueries[i];
98
- const mailboxes = withoutLabelFolders(query?.data?.items ?? [], labels);
107
+ const allMailboxes = query?.data?.items ?? [];
108
+ const mailboxes = withoutLabelFolders(allMailboxes, labels);
99
109
  const roleMap = buildMailboxRoleMap(account.folderAppointments);
100
110
  const { system, labels: folders } = sortMailboxes(mailboxes, roleMap, translator);
101
111
  const status = query?.isError
@@ -107,6 +117,7 @@ export function MailSidebarAdapter({ accounts, onMailboxSelect, variant = "deskt
107
117
  id: account.accountId,
108
118
  label: account.email,
109
119
  email: account.email,
120
+ hierarchyDelimiter: allMailboxes[0]?.hierarchyDelimiter ?? "",
110
121
  muted: Boolean(account.muted),
111
122
  // Outbox is a shared singleton shown inside each account's section,
112
123
  // matching existing sidebar behaviour.