@remit/web-client 0.0.93 → 0.0.95

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 (41) hide show
  1. package/package.json +1 -1
  2. package/src/components/mail/BriefPane.selection.test.ts +0 -1
  3. package/src/components/mail/BriefPane.tsx +7 -17
  4. package/src/components/mail/DailyBrief.selection.test.ts +21 -3
  5. package/src/components/mail/DailyBrief.tsx +37 -39
  6. package/src/components/mail/FlaggedList.tsx +55 -8
  7. package/src/components/mail/FlaggedPane.tsx +9 -23
  8. package/src/components/mail/MailListHeader.tsx +41 -39
  9. package/src/components/mail/MailboxPane.tsx +24 -11
  10. package/src/components/mail/MessageList.selection.test.ts +44 -30
  11. package/src/components/mail/MessageList.tsx +117 -339
  12. package/src/components/mail/SelectionWizardHost.tsx +265 -48
  13. package/src/components/mail/ThreadListInteraction.test.ts +74 -4
  14. package/src/components/mail/ThreadListInteraction.tsx +58 -50
  15. package/src/components/mail/make-filter-entry.test.ts +63 -0
  16. package/src/components/mail/selection-verbs.test.ts +278 -0
  17. package/src/components/ui/ConfirmDialog.stories.tsx +0 -15
  18. package/src/hooks/useEscalatedActions.ts +2 -2
  19. package/src/hooks/useMatchSample.ts +44 -3
  20. package/src/hooks/useRulePreview.ts +1 -2
  21. package/src/lib/bulk-action-copy.test.ts +0 -19
  22. package/src/lib/bulk-action-copy.ts +0 -8
  23. package/src/lib/bulk-actions.test.ts +0 -60
  24. package/src/lib/bulk-actions.ts +0 -26
  25. package/src/lib/format.test.ts +0 -27
  26. package/src/lib/format.ts +4 -14
  27. package/src/lib/list-header-chrome.ts +10 -0
  28. package/src/lib/organize/organize-model.ts +8 -2
  29. package/src/lib/organize/rule-model.ts +0 -4
  30. package/src/lib/wizard-history.test.ts +31 -0
  31. package/src/lib/wizard-history.ts +97 -9
  32. package/src/routes/mail.tsx +3 -1
  33. package/src/components/mail/organize/SearchFilterDialog.render.test.ts +0 -47
  34. package/src/components/mail/organize/SearchFilterDialog.tsx +0 -90
  35. package/src/components/mail/organize/SearchFilterEditor.render.test.ts +0 -260
  36. package/src/components/mail/organize/SearchFilterEditor.tsx +0 -140
  37. package/src/components/mail/organize/rule-editor-states.stories.tsx +0 -147
  38. package/src/components/mail/organize/rule-editor-states.tsx +0 -139
  39. package/src/hooks/useRuleEditorState.ts +0 -182
  40. package/src/hooks/useSearchFilterSeed.render.test.ts +0 -118
  41. package/src/hooks/useSearchFilterSeed.ts +0 -79
@@ -1,260 +0,0 @@
1
- /**
2
- * The filter-from-search chip editor (RFC 038 D5) over the live preview/apply
3
- * endpoints. The contract these tests pin: the converted clauses open pre-filled,
4
- * the conversion states honestly what the search carried that the filter cannot,
5
- * and the count on screen is the literal set a commit acts on — the commit is
6
- * blocked until the count settles and carries exactly the previewed predicate.
7
- */
8
-
9
- import assert from "node:assert/strict";
10
- import { afterEach, describe, it } from "node:test";
11
- import { mailboxOperationsListMailboxesQueryKey } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
12
- import { createElement } from "react";
13
- import { convertSearchToRule } from "@/lib/organize/search-to-rule";
14
- import {
15
- parseSearchTokens,
16
- type SearchTokenContext,
17
- } from "@/lib/search-tokens";
18
- import { createDomHarness, type DomHarness } from "../../../test-support/dom";
19
- import { makeMailbox } from "../../../test-support/fixtures";
20
- import {
21
- type HttpCall,
22
- type HttpMock,
23
- mockFetch,
24
- } from "../../../test-support/http";
25
- import { SearchFilterEditor } from "./SearchFilterEditor";
26
-
27
- let harness: DomHarness | undefined;
28
- let http: HttpMock | undefined;
29
-
30
- afterEach(() => {
31
- harness?.close();
32
- harness = undefined;
33
- http?.restore();
34
- http = undefined;
35
- });
36
-
37
- const ACCOUNT_ID = "acc-1";
38
-
39
- const MAILBOXES = [
40
- makeMailbox({ mailboxId: "mbx-inbox", fullPath: "INBOX" }),
41
- makeMailbox({ mailboxId: "mbx-archive", fullPath: "Archive" }),
42
- ];
43
-
44
- const CONTEXT: SearchTokenContext = {
45
- mailboxesByName: new Map([["archive", "mbx-archive"]]),
46
- accountsByName: new Map(),
47
- };
48
-
49
- const conversion = (query: string, searchHadSemanticReach = false) =>
50
- convertSearchToRule(parseSearchTokens(query, CONTEXT), {
51
- searchHadSemanticReach,
52
- });
53
-
54
- type Responder = (call: HttpCall) => unknown;
55
-
56
- const previewCounts = (counts: number[]): Responder => {
57
- let index = 0;
58
- return (call) => {
59
- if (call.path.endsWith("/organize/preview")) {
60
- const count = counts[Math.min(index, counts.length - 1)];
61
- index += 1;
62
- return { matchedCount: count, messageIds: [] };
63
- }
64
- if (call.path.endsWith("/filters")) {
65
- return { filterId: "filter-1", name: "R", scope: "Standing" };
66
- }
67
- if (call.path.endsWith("/organize") && call.method === "POST") {
68
- return { organizeJobId: "job-1", state: "Running" };
69
- }
70
- if (call.path.endsWith("/organize/job-1")) {
71
- return {
72
- organizeJobId: "job-1",
73
- state: "Complete",
74
- matchedCount: 3,
75
- appliedCount: 3,
76
- failedCount: 0,
77
- };
78
- }
79
- return {};
80
- };
81
- };
82
-
83
- const mount = (
84
- query: string,
85
- responder: Responder = previewCounts([12]),
86
- searchHadSemanticReach = false,
87
- ): DomHarness => {
88
- http = mockFetch(responder);
89
- harness = createDomHarness();
90
- harness.queryClient.setQueryData(
91
- mailboxOperationsListMailboxesQueryKey({ path: { accountId: ACCOUNT_ID } }),
92
- { items: MAILBOXES },
93
- );
94
- harness.renderApp(
95
- createElement(SearchFilterEditor, {
96
- accountId: ACCOUNT_ID,
97
- conversion: conversion(query, searchHadSemanticReach),
98
- seedCount: 12,
99
- onClose: () => undefined,
100
- }),
101
- );
102
- return harness;
103
- };
104
-
105
- async function settlePreview(dom: DomHarness): Promise<void> {
106
- await dom.flush();
107
- await dom.wait(400);
108
- await dom.flush();
109
- await dom.flush();
110
- }
111
-
112
- const primaryButton = (dom: DomHarness, label: string): HTMLButtonElement =>
113
- dom.byText("button", label) as HTMLButtonElement;
114
-
115
- describe("SearchFilterEditor — pre-filled conversion", () => {
116
- it("opens on the converted clauses", () => {
117
- const dom = mount("from:alerts@github.com pull request");
118
- assert.match(dom.text(), /alerts@github\.com/);
119
- assert.match(dom.text(), /pull request/);
120
- });
121
-
122
- it("seeds the live count from the converted predicate", () => {
123
- const dom = mount("from:receipts@stripe.com");
124
- assert.match(dom.text(), /12 messages match/);
125
- });
126
-
127
- it("never asks the matcher to count a body-text rule it cannot evaluate", async () => {
128
- // A free-text search converts to a `HasWords` clause and carries no anchor,
129
- // so the vector-free matcher rejects it outright (organize.ts
130
- // `assertNoBodyContentClause`). The count is unavailable and says so; the
131
- // request is never sent.
132
- const dom = mount("receipts");
133
- await settlePreview(dom);
134
- assert.match(dom.text(), /can't count matches/i);
135
- assert.equal((http?.to("/organize/preview") ?? []).length, 0);
136
- });
137
-
138
- it("does not offer the semantic widen on a search-derived rule", () => {
139
- const dom = mount("receipts");
140
- assert.doesNotMatch(dom.text(), /and similar/i);
141
- });
142
- });
143
-
144
- describe("SearchFilterEditor — conversion honesty (RFC 038 D5)", () => {
145
- it("states a folder-scoped search is kept out of the filter", () => {
146
- const dom = mount("in:archive receipts");
147
- assert.match(dom.text(), /limited to archive/i);
148
- assert.match(dom.text(), /any folder/i);
149
- });
150
-
151
- it("names the dropped attribute facets", () => {
152
- const dom = mount("invoice has:attachment is:unread");
153
- assert.match(dom.text(), /Has attachment/);
154
- assert.match(dom.text(), /Unread/);
155
- assert.match(dom.text(), /left out/);
156
- });
157
-
158
- it("states the dropped semantic reach when the search surfaced similar mail", () => {
159
- const dom = mount("things like this", previewCounts([12]), true);
160
- assert.match(dom.text(), /matches these words literally/i);
161
- assert.match(dom.text(), /similar mail/i);
162
- // The widen chip is never offered on a search-derived rule.
163
- assert.doesNotMatch(dom.text(), /and anything similar/i);
164
- });
165
-
166
- it("says nothing about semantics when the search had no similar mail", () => {
167
- const dom = mount("things like this", previewCounts([12]), false);
168
- assert.doesNotMatch(dom.text(), /similar mail/i);
169
- });
170
- });
171
-
172
- describe("SearchFilterEditor — commit gate", () => {
173
- it("blocks the save until a folder and name are set, then commits the previewed predicate", async () => {
174
- const dom = mount("from:alerts@github.com receipts");
175
-
176
- // Standing is the default scope: it needs a folder and a name.
177
- assert.equal(primaryButton(dom, "Save rule").disabled, true);
178
- dom.select(dom.byLabel("Destination folder"), "mbx-archive");
179
- await dom.flush();
180
- dom.type(dom.byLabel("Rule name"), "GitHub receipts");
181
- await dom.flush();
182
- assert.equal(primaryButton(dom, "Save rule").disabled, false);
183
-
184
- dom.click(primaryButton(dom, "Save rule"));
185
- await dom.flush();
186
-
187
- const filters = http?.to("/filters") ?? [];
188
- assert.equal(filters.length, 1);
189
- assert.equal(filters[0].body?.scope, "Standing");
190
- assert.deepEqual(filters[0].body?.literalClauses, [
191
- { field: "From", value: "alerts@github.com" },
192
- { field: "HasWords", value: "receipts" },
193
- ]);
194
- assert.match(dom.text(), /Filter saved/);
195
- });
196
-
197
- it("stales the count on an edit and holds the save until it settles", async () => {
198
- // The seed count (12) is passed directly; the first network preview is the
199
- // re-count after the edit, so it returns 40.
200
- const dom = mount("from:receipts@stripe.com", previewCounts([40]));
201
- dom.select(dom.byLabel("Destination folder"), "mbx-archive");
202
- await dom.flush();
203
- dom.type(dom.byLabel("Rule name"), "Receipts");
204
- await dom.flush();
205
-
206
- dom.click(primaryButton(dom, "Add clause"));
207
- dom.select(dom.byLabel("Clause field"), "Subject");
208
- dom.type(dom.byLabel("Clause value"), "paid");
209
- dom.click(primaryButton(dom, "Add"));
210
- await dom.flush();
211
-
212
- // The count is stale and the save is blocked until the re-preview lands.
213
- assert.match(dom.text(), /recounting/i);
214
- assert.equal(primaryButton(dom, "Save rule").disabled, true);
215
-
216
- await settlePreview(dom);
217
- assert.match(dom.text(), /40 messages match/);
218
- assert.equal(primaryButton(dom, "Save rule").disabled, false);
219
- });
220
-
221
- it("runs a one-time apply as a back-apply job when the scope is 'just once'", async () => {
222
- const dom = mount("from:receipts@stripe.com");
223
- dom.select(dom.byLabel("Destination folder"), "mbx-archive");
224
- await dom.flush();
225
- const radio = dom.query('input[name="rule-scope"][value="once"]');
226
- if (!radio) throw new Error("no once scope option");
227
- dom.click(radio);
228
- await dom.flush();
229
-
230
- dom.click(primaryButton(dom, "Apply now"));
231
- await dom.flush();
232
- const jobs = (http?.to("/organize") ?? []).filter(
233
- (call) => call.method === "POST",
234
- );
235
- assert.equal(jobs.length, 1);
236
- });
237
-
238
- it("holds the one-time apply for a body-text rule, offering the saved rule instead", async () => {
239
- // The one-time apply runs the same vector-free matcher the count does. A
240
- // `HasWords` clause has no reader there, so the apply is held with the
241
- // reason stated — saved as a standing rule the same clause works, because
242
- // the index-time matcher reads the whole body.
243
- const dom = mount("receipts");
244
- dom.select(dom.byLabel("Destination folder"), "mbx-archive");
245
- await dom.flush();
246
- const radio = dom.query('input[name="rule-scope"][value="once"]');
247
- if (!radio) throw new Error("no once scope option");
248
- dom.click(radio);
249
- await dom.flush();
250
-
251
- assert.equal(primaryButton(dom, "Apply now").disabled, true);
252
- assert.match(dom.text(), /can't read message bodies/i);
253
- assert.equal(
254
- (http?.calls ?? []).filter(
255
- (call) => call.path.endsWith("/organize") && call.method === "POST",
256
- ).length,
257
- 0,
258
- );
259
- });
260
- });
@@ -1,140 +0,0 @@
1
- import { mailboxOperationsListMailboxesOptions } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
2
- import {
3
- buildSearchRule,
4
- type FilterRule,
5
- FilterRuleEditor,
6
- type FolderOption,
7
- type SearchConversion,
8
- SearchConversionNoticeView,
9
- } from "@remit/ui";
10
- import { useQuery } from "@tanstack/react-query";
11
- import { useMemo, useState } from "react";
12
- import { useCreateFilter } from "@/hooks/useFilters";
13
- import { useOrganizeJob } from "@/hooks/useOrganizeJob";
14
- import { useRuleEditorState } from "@/hooks/useRuleEditorState";
15
- import { useRulePreview } from "@/hooks/useRulePreview";
16
- import { getMailboxDisplayName } from "@/lib/folder-roles";
17
- import { buildMoveTargets } from "@/lib/move-targets";
18
- import {
19
- rulePredicate,
20
- ruleToDraft,
21
- SUPPORTED_CLAUSE_FIELDS,
22
- } from "@/lib/organize/rule-model";
23
- import {
24
- CommitError,
25
- FilterSaved,
26
- JobProgress,
27
- SavingState,
28
- } from "./rule-editor-states";
29
-
30
- interface SearchFilterEditorProps {
31
- /** The account the filter is created for (an `account:` facet, else the active account). */
32
- accountId: string;
33
- /** The converted search — its clauses seed the rule, its drops seed the notice. */
34
- conversion: SearchConversion;
35
- /**
36
- * The converted literal predicate's live count, seeding the editor without a
37
- * re-fetch. Absent when the predicate is one the vector-free matcher refuses —
38
- * a `HasWords` clause from the search's free text — in which case the count
39
- * region says so and the one-time apply is held; saving it as a standing rule
40
- * still works, since the index-time matcher does read message bodies.
41
- */
42
- seedCount?: number;
43
- onClose: () => void;
44
- }
45
-
46
- /**
47
- * The filter-from-search surface as the chip editor (RFC 038 D5). The current
48
- * search's literal terms and facets arrive already converted to clauses; this
49
- * opens the shared rule editor pre-filled on them, over the same preview/apply
50
- * endpoints as Organize. The conversion notice states what the search carried
51
- * that the filter cannot — a folder scope, non-clause facets, semantic reach.
52
- *
53
- * A search-derived rule has no message anchor, so the semantic widen chip is not
54
- * offered here (its loss, where the deployment could have served it, is the
55
- * notice's job). The commit gate is the same: the count on screen is the literal
56
- * set a commit acts on.
57
- */
58
- export function SearchFilterEditor({
59
- accountId,
60
- conversion,
61
- seedCount,
62
- onClose,
63
- }: SearchFilterEditorProps) {
64
- const [initialRule] = useState<FilterRule>(() => buildSearchRule(conversion));
65
- const { rule, handlers } = useRuleEditorState({ initialRule });
66
-
67
- const { data: mailboxesData } = useQuery({
68
- ...mailboxOperationsListMailboxesOptions({ path: { accountId } }),
69
- staleTime: Number.POSITIVE_INFINITY,
70
- });
71
-
72
- const folders: FolderOption[] = useMemo(
73
- () =>
74
- buildMoveTargets(mailboxesData?.items ?? []).map((mailbox) => ({
75
- id: mailbox.mailboxId,
76
- label: getMailboxDisplayName(mailbox.fullPath),
77
- })),
78
- [mailboxesData?.items],
79
- );
80
-
81
- const { count: preview } = useRulePreview(
82
- accountId,
83
- rulePredicate(rule),
84
- seedCount,
85
- );
86
-
87
- const organizeJob = useOrganizeJob(accountId);
88
- const createFilter = useCreateFilter(accountId);
89
-
90
- const commit = () => {
91
- const draft = ruleToDraft(rule);
92
- if (rule.scope === "once") {
93
- organizeJob.start(draft);
94
- return;
95
- }
96
- createFilter.createFilter(
97
- draft,
98
- rule.scope === "standing" ? "standing" : "temporary",
99
- (rule.name ?? "").trim(),
100
- );
101
- };
102
-
103
- if (organizeJob.isStarting || organizeJob.isRunning || organizeJob.isDone) {
104
- return (
105
- <JobProgress
106
- progress={organizeJob.progress}
107
- isDone={organizeJob.isDone}
108
- runningLabel="Organizing your mail…"
109
- onClose={onClose}
110
- />
111
- );
112
- }
113
-
114
- if (createFilter.isPending) return <SavingState />;
115
- if (createFilter.isSuccess) return <FilterSaved onClose={onClose} />;
116
- if (createFilter.isError)
117
- return <CommitError onRetry={createFilter.reset} onClose={onClose} />;
118
-
119
- return (
120
- <FilterRuleEditor
121
- rule={rule}
122
- folders={folders}
123
- preview={preview}
124
- notice={
125
- <SearchConversionNoticeView
126
- notice={{
127
- scopedOutFolder: conversion.scopedOut?.label,
128
- droppedFacets: conversion.droppedFacets.map((facet) => facet.label),
129
- droppedSemantic: conversion.droppedSemantic,
130
- }}
131
- />
132
- }
133
- semanticAvailable={false}
134
- clauseFields={SUPPORTED_CLAUSE_FIELDS}
135
- {...handlers}
136
- onCommit={commit}
137
- onCancel={onClose}
138
- />
139
- );
140
- }
@@ -1,147 +0,0 @@
1
- import { BottomSheet } from "@remit/ui";
2
- import type { Meta, StoryObj } from "@storybook/react-vite";
3
- import type { ReactNode } from "react";
4
- import {
5
- BackApplyError,
6
- CommitError,
7
- FilterSaved,
8
- JobProgress,
9
- SavingState,
10
- } from "./rule-editor-states";
11
-
12
- /**
13
- * `Flows/Smart Organize/Rule editor states` — the non-editing states the rule
14
- * editor lands in after a commit, rendered from the real components the Organize
15
- * surface mounts. Creating a standing filter now runs the retroactive back-apply,
16
- * so a standing save flows Saving → back-apply in flight → done, the same job
17
- * states the one-time apply reaches. Every state here is what ships, so the flow
18
- * cannot drift from the story.
19
- */
20
-
21
- function SheetStage({ children }: { children: ReactNode }) {
22
- return (
23
- <div className="relative mx-auto h-dvh w-full shrink-0 overflow-hidden bg-surface sm:my-6 sm:h-[520px] sm:w-[390px] sm:rounded-[2rem] sm:border sm:border-line sm:shadow-sm">
24
- <BottomSheet open onClose={() => undefined}>
25
- {children}
26
- </BottomSheet>
27
- </div>
28
- );
29
- }
30
-
31
- const meta: Meta = {
32
- title: "Flows/Smart Organize/Rule editor states",
33
- parameters: { layout: "fullscreen" },
34
- };
35
- export default meta;
36
-
37
- type Story = StoryObj;
38
-
39
- /** Saving the filter — held while the create request is in flight. */
40
- export const Saving: Story = {
41
- render: () => (
42
- <SheetStage>
43
- <SavingState />
44
- </SheetStage>
45
- ),
46
- };
47
-
48
- /**
49
- * The back-apply running after a standing filter is created — the pass that
50
- * reaches the mail already in the mailbox, not only the mail that arrives next.
51
- */
52
- export const BackApplyInFlight: Story = {
53
- name: "Back-apply in flight",
54
- render: () => (
55
- <SheetStage>
56
- <JobProgress
57
- progress={{
58
- state: "Running",
59
- matchedCount: 24,
60
- appliedCount: 0,
61
- failedCount: 0,
62
- errorMessage: "",
63
- }}
64
- isDone={false}
65
- runningLabel="Organizing mail from these senders…"
66
- onClose={() => undefined}
67
- />
68
- </SheetStage>
69
- ),
70
- };
71
-
72
- /** The back-apply finished — the count moved is stated plainly. */
73
- export const BackApplyDone: Story = {
74
- name: "Back-apply done",
75
- render: () => (
76
- <SheetStage>
77
- <JobProgress
78
- progress={{
79
- state: "Complete",
80
- matchedCount: 24,
81
- appliedCount: 24,
82
- failedCount: 0,
83
- errorMessage: "",
84
- }}
85
- isDone
86
- runningLabel="Organizing mail from these senders…"
87
- onClose={() => undefined}
88
- />
89
- </SheetStage>
90
- ),
91
- };
92
-
93
- /** The back-apply failed — the rule is still saved, the move is what did not run. */
94
- export const BackApplyFailed: Story = {
95
- name: "Back-apply failed",
96
- render: () => (
97
- <SheetStage>
98
- <JobProgress
99
- progress={{
100
- state: "Failed",
101
- matchedCount: 24,
102
- appliedCount: 6,
103
- failedCount: 18,
104
- errorMessage: "Could not reach the mail server. Please try again.",
105
- }}
106
- isDone
107
- runningLabel="Organizing mail from these senders…"
108
- onClose={() => undefined}
109
- />
110
- </SheetStage>
111
- ),
112
- };
113
-
114
- /**
115
- * The filter saved, but the back-apply's own request never got off the ground
116
- * (a 5xx or dropped connection on start). The rule is live for new mail; moving
117
- * the existing mail is what failed, and it is offered again — never swallowed
118
- * behind a plain "saved".
119
- */
120
- export const BackApplyStartFailed: Story = {
121
- name: "Back-apply start failed",
122
- render: () => (
123
- <SheetStage>
124
- <BackApplyError onRetry={() => undefined} onClose={() => undefined} />
125
- </SheetStage>
126
- ),
127
- };
128
-
129
- /** The filter saved with nothing to back-apply — the plain confirmation. */
130
- export const FilterSavedState: Story = {
131
- name: "Filter saved",
132
- render: () => (
133
- <SheetStage>
134
- <FilterSaved onClose={() => undefined} />
135
- </SheetStage>
136
- ),
137
- };
138
-
139
- /** The create failed — retry or dismiss. */
140
- export const CommitFailed: Story = {
141
- name: "Commit failed",
142
- render: () => (
143
- <SheetStage>
144
- <CommitError onRetry={() => undefined} onClose={() => undefined} />
145
- </SheetStage>
146
- ),
147
- };
@@ -1,139 +0,0 @@
1
- import { Button } from "@remit/ui";
2
- import { CheckCircle2, Loader2 } from "lucide-react";
3
- import type { useOrganizeJob } from "@/hooks/useOrganizeJob";
4
-
5
- /**
6
- * The non-editing states a filter-rule editor lands in after commit, shared by
7
- * the Organize and filter-from-search surfaces so a back-apply job, a saved
8
- * standing rule, and a commit failure read identically wherever the rule was
9
- * authored (RFC 038 D1).
10
- */
11
-
12
- export function JobProgress({
13
- progress,
14
- isDone,
15
- runningLabel,
16
- onClose,
17
- }: {
18
- progress: ReturnType<typeof useOrganizeJob>["progress"];
19
- isDone: boolean;
20
- /** In-flight copy — the caller names what it is organizing. */
21
- runningLabel: string;
22
- onClose: () => void;
23
- }) {
24
- const failed = progress.state === "Failed";
25
- return (
26
- <div className="flex flex-col items-center gap-3 px-5 py-8 text-center">
27
- {!isDone ? (
28
- <Loader2 className="size-8 animate-spin text-accent-2" />
29
- ) : failed ? (
30
- <span className="text-sm font-semibold text-danger">
31
- Organize failed
32
- </span>
33
- ) : (
34
- <CheckCircle2 className="size-8 text-positive" />
35
- )}
36
-
37
- {!isDone && <p className="text-sm font-medium text-fg">{runningLabel}</p>}
38
-
39
- {isDone && !failed && (
40
- <div className="text-sm text-fg">
41
- <p className="font-medium">Done</p>
42
- <p className="mt-1 text-xs text-fg-muted">
43
- {progress.appliedCount} of {progress.matchedCount} moved
44
- {progress.failedCount > 0
45
- ? ` · ${progress.failedCount} failed`
46
- : ""}
47
- .
48
- </p>
49
- </div>
50
- )}
51
-
52
- {isDone && failed && (
53
- <p className="max-w-xs text-xs text-fg-muted">
54
- {progress.errorMessage || "Something went wrong. Please try again."}
55
- </p>
56
- )}
57
-
58
- {isDone && (
59
- <Button variant="primary" onClick={onClose} className="mt-2">
60
- Done
61
- </Button>
62
- )}
63
- </div>
64
- );
65
- }
66
-
67
- export function SavingState() {
68
- return (
69
- <div className="flex flex-col items-center gap-3 px-5 py-10 text-center">
70
- <Loader2 className="size-8 animate-spin text-accent-2" />
71
- <p className="text-sm font-medium text-fg">Saving rule…</p>
72
- </div>
73
- );
74
- }
75
-
76
- export function FilterSaved({ onClose }: { onClose: () => void }) {
77
- return (
78
- <div className="flex flex-col items-center gap-3 px-5 py-8 text-center">
79
- <CheckCircle2 className="size-8 text-positive" />
80
- <p className="text-sm font-medium text-fg">Filter saved</p>
81
- <p className="max-w-xs text-xs text-fg-muted">
82
- You can see it, and when it expires, under Settings › Filters.
83
- </p>
84
- <Button variant="primary" onClick={onClose} className="mt-2">
85
- Done
86
- </Button>
87
- </div>
88
- );
89
- }
90
-
91
- export function BackApplyError({
92
- onRetry,
93
- onClose,
94
- }: {
95
- onRetry: () => void;
96
- onClose: () => void;
97
- }) {
98
- return (
99
- <div className="flex flex-col items-center gap-3 px-5 py-8 text-center">
100
- <CheckCircle2 className="size-8 text-positive" />
101
- <p className="text-sm font-medium text-fg">Rule saved</p>
102
- <p className="max-w-xs text-xs text-fg-muted">
103
- New mail follows it automatically. Moving the mail already in your
104
- mailbox didn't run — try again?
105
- </p>
106
- <div className="mt-2 flex gap-2">
107
- <Button variant="primary" onClick={onRetry}>
108
- Move existing mail
109
- </Button>
110
- <Button variant="ghost" onClick={onClose}>
111
- Not now
112
- </Button>
113
- </div>
114
- </div>
115
- );
116
- }
117
-
118
- export function CommitError({
119
- onRetry,
120
- onClose,
121
- }: {
122
- onRetry: () => void;
123
- onClose: () => void;
124
- }) {
125
- return (
126
- <div className="flex flex-col items-center gap-3 px-5 py-8 text-center">
127
- <p className="text-sm font-medium text-danger">Couldn't save the rule</p>
128
- <p className="max-w-xs text-xs text-fg-muted">Please try again.</p>
129
- <div className="mt-2 flex gap-2">
130
- <Button variant="primary" onClick={onRetry}>
131
- Try again
132
- </Button>
133
- <Button variant="ghost" onClick={onClose}>
134
- Not now
135
- </Button>
136
- </div>
137
- </div>
138
- );
139
- }