@remit/ui 0.0.21 → 0.0.23

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.
@@ -0,0 +1,212 @@
1
+ import type { Meta, StoryObj } from "@storybook/react-vite";
2
+ import { useState } from "react";
3
+ import {
4
+ demoLogsCommand,
5
+ demoRelease,
6
+ demoRunId,
7
+ type SelfUpdateState,
8
+ } from "./self-update.js";
9
+ import { SelfUpdateConfirmDialog } from "./self-update-confirm-dialog.js";
10
+ import { SelfUpdateSection } from "./self-update-section.js";
11
+
12
+ const NOW = Date.parse("2026-07-20T12:00:00.000Z");
13
+ const CURRENT = "0.9.3";
14
+
15
+ const meta: Meta<typeof SelfUpdateSection> = {
16
+ title: "Settings/Self-update",
17
+ component: SelfUpdateSection,
18
+ parameters: { layout: "padded" },
19
+ args: {
20
+ now: NOW,
21
+ onCheck: () => {},
22
+ onInstall: () => {},
23
+ onDismissResult: () => {},
24
+ },
25
+ decorators: [
26
+ (Story) => (
27
+ <div className="mx-auto max-w-2xl">
28
+ <Story />
29
+ </div>
30
+ ),
31
+ ],
32
+ };
33
+ export default meta;
34
+
35
+ type Story = StoryObj<typeof SelfUpdateSection>;
36
+
37
+ const withState = (state: SelfUpdateState) => ({ state });
38
+
39
+ /**
40
+ * The state this pane is in almost always. One line, no call to action, no
41
+ * colour — running the latest version is not news.
42
+ */
43
+ export const UpToDate: Story = {
44
+ args: withState({
45
+ status: "upToDate",
46
+ version: CURRENT,
47
+ checkedAt: NOW - 21 * 60_000,
48
+ }),
49
+ };
50
+
51
+ export const Checking: Story = {
52
+ args: withState({ status: "checking", version: CURRENT }),
53
+ };
54
+
55
+ /**
56
+ * An update exists. It is stated — version, date, one line of what changes, a
57
+ * link to the full notes — and then it waits. Nothing here follows the user
58
+ * back to their mail.
59
+ */
60
+ export const UpdateAvailable: Story = {
61
+ args: withState({
62
+ status: "available",
63
+ version: CURRENT,
64
+ release: demoRelease,
65
+ }),
66
+ };
67
+
68
+ /**
69
+ * Cannot reach the update source. This is not a failure of the running Remit
70
+ * and does not dress itself up as one: it names the cause, says the installed
71
+ * version keeps working, and offers the retry.
72
+ */
73
+ export const CheckFailedOffline: Story = {
74
+ args: withState({
75
+ status: "checkFailed",
76
+ version: CURRENT,
77
+ reason: "No route to github.com — the server has no outbound network.",
78
+ lastCheckedAt: NOW - 3 * 24 * 60 * 60_000,
79
+ }),
80
+ };
81
+
82
+ /**
83
+ * Back on a reachable server, on the new version. Dismissible, and gone for
84
+ * good once dismissed.
85
+ */
86
+ export const Succeeded: Story = {
87
+ args: withState({
88
+ status: "succeeded",
89
+ runId: demoRunId,
90
+ version: demoRelease.version,
91
+ previousVersion: CURRENT,
92
+ releaseNotesUrl: demoRelease.releaseNotesUrl,
93
+ }),
94
+ };
95
+
96
+ /**
97
+ * The new version did not start and Remit reports having put the old one back.
98
+ * The pane repeats that report and no more: a failed migration is exactly the
99
+ * case where something was changed on the way, so "nothing was lost" is not a
100
+ * claim this screen is in any position to make.
101
+ */
102
+ export const RolledBack: Story = {
103
+ args: withState({
104
+ status: "rolledBack",
105
+ runId: demoRunId,
106
+ version: CURRENT,
107
+ attemptedVersion: demoRelease.version,
108
+ reason:
109
+ 'migration 0042_add_thread_index failed: relation "threads" does not exist',
110
+ logsCommand: demoLogsCommand,
111
+ }),
112
+ };
113
+
114
+ /**
115
+ * An update is running. The blocking screen owns the window; the pane behind it
116
+ * still says what is going on rather than going blank.
117
+ */
118
+ export const ApplyingBehindTheOverlay: Story = {
119
+ args: withState({
120
+ status: "applying",
121
+ runId: demoRunId,
122
+ version: CURRENT,
123
+ target: demoRelease.version,
124
+ phase: "restarting",
125
+ elapsedSeconds: 30,
126
+ }),
127
+ };
128
+
129
+ /**
130
+ * The server answered again after a silence the client could not see into. It
131
+ * says exactly that, and points at the log rather than guessing.
132
+ */
133
+ export const RecoveredAfterUnreachable: Story = {
134
+ args: withState({
135
+ status: "unreachable",
136
+ runId: demoRunId,
137
+ previousVersion: CURRENT,
138
+ attemptedVersion: demoRelease.version,
139
+ elapsedSeconds: 420,
140
+ logsCommand: demoLogsCommand,
141
+ }),
142
+ };
143
+
144
+ /**
145
+ * Consent. Reflects the three things the user will actually feel — the pause,
146
+ * that mail is untouched, and the automatic way back — before anything is
147
+ * replaced. "Not now" is always the easiest button to hit.
148
+ */
149
+ export const ConfirmBeforeInstalling: Story = {
150
+ render: () => (
151
+ <SelfUpdateConfirmDialog
152
+ open
153
+ currentVersion={CURRENT}
154
+ release={demoRelease}
155
+ onClose={() => {}}
156
+ onConfirm={() => {}}
157
+ />
158
+ ),
159
+ };
160
+
161
+ /**
162
+ * Consent reached from the pane, and declined. The offer stays exactly where
163
+ * it was; declining costs nothing and is not asked about again.
164
+ */
165
+ export const ConsentFlow: Story = {
166
+ render: () => {
167
+ const [open, setOpen] = useState(false);
168
+ const [confirmed, setConfirmed] = useState(false);
169
+ return (
170
+ <>
171
+ <SelfUpdateSection
172
+ now={NOW}
173
+ state={{
174
+ status: "available",
175
+ version: CURRENT,
176
+ release: demoRelease,
177
+ }}
178
+ onCheck={() => {}}
179
+ onInstall={() => setOpen(true)}
180
+ onDismissResult={() => {}}
181
+ />
182
+ {confirmed && (
183
+ <p className="mt-3 text-xs text-fg-subtle">
184
+ Consent given — the app hands over to the blocking restart screen
185
+ here.
186
+ </p>
187
+ )}
188
+ <SelfUpdateConfirmDialog
189
+ open={open}
190
+ currentVersion={CURRENT}
191
+ release={demoRelease}
192
+ onClose={() => setOpen(false)}
193
+ onConfirm={() => {
194
+ setOpen(false);
195
+ setConfirmed(true);
196
+ }}
197
+ />
198
+ </>
199
+ );
200
+ },
201
+ };
202
+
203
+ /**
204
+ * Pressing "Check again" while a check is already running. The control is
205
+ * never disabled — it no-ops and says why, per the UX tenets.
206
+ */
207
+ export const PressingCheckWhileChecking: Story = {
208
+ args: withState({ status: "checking", version: CURRENT }),
209
+ play: async ({ canvasElement }) => {
210
+ canvasElement.querySelector<HTMLButtonElement>("button")?.click();
211
+ },
212
+ };
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Self-update state for a Remit you run yourself.
3
+ *
4
+ * The server is the thing being replaced, so the UI cannot assume it stays
5
+ * reachable across the operation. Every state here is one the client can be
6
+ * left holding on its own, and each names what the user can do next.
7
+ */
8
+
9
+ export interface ReleaseInfo {
10
+ version: string;
11
+ releasedAt: number;
12
+ releaseNotesUrl: string;
13
+ /** One line of plain language, not a changelog dump. */
14
+ summary: string;
15
+ }
16
+
17
+ /** Where the operation is between consent and a reachable server again. */
18
+ export type UpdatePhase = "preparing" | "restarting" | "reconnecting";
19
+
20
+ /**
21
+ * Identifies one update attempt. The client hands this back after the restart
22
+ * to ask what became of the run it started — its own memory of the operation
23
+ * does not survive the operation. Without it a reload mid-update cannot tell an
24
+ * update in flight from an ordinary server blip.
25
+ */
26
+ export type UpdateRunId = string;
27
+
28
+ export type SelfUpdateState =
29
+ | { status: "upToDate"; version: string; checkedAt: number }
30
+ | { status: "checking"; version: string }
31
+ | {
32
+ status: "checkFailed";
33
+ version: string;
34
+ /** Plain-language cause, e.g. "no route to github.com". */
35
+ reason: string;
36
+ lastCheckedAt?: number;
37
+ }
38
+ | { status: "available"; version: string; release: ReleaseInfo }
39
+ | {
40
+ status: "applying";
41
+ runId: UpdateRunId;
42
+ version: string;
43
+ target: string;
44
+ phase: UpdatePhase;
45
+ /** Seconds since the user consented, for honest "still working" copy. */
46
+ elapsedSeconds: number;
47
+ }
48
+ | {
49
+ status: "succeeded";
50
+ runId: UpdateRunId;
51
+ version: string;
52
+ previousVersion: string;
53
+ releaseNotesUrl: string;
54
+ }
55
+ | {
56
+ status: "rolledBack";
57
+ runId: UpdateRunId;
58
+ /** The version running now — the old one, restored. */
59
+ version: string;
60
+ attemptedVersion: string;
61
+ /** The server's own account of the failure, shown verbatim. */
62
+ reason: string;
63
+ logsCommand: string;
64
+ }
65
+ | {
66
+ status: "unreachable";
67
+ runId: UpdateRunId;
68
+ previousVersion: string;
69
+ attemptedVersion: string;
70
+ elapsedSeconds: number;
71
+ logsCommand: string;
72
+ };
73
+
74
+ export type SelfUpdateStatus = SelfUpdateState["status"];
75
+
76
+ const phaseLabels: Record<UpdatePhase, string> = {
77
+ preparing: "Getting the new version ready",
78
+ restarting: "Restarting Remit",
79
+ reconnecting: "Waiting for Remit to answer again",
80
+ };
81
+
82
+ export function updatePhaseLabel(phase: UpdatePhase): string {
83
+ return phaseLabels[phase];
84
+ }
85
+
86
+ /**
87
+ * The restart takes the server away, so silence is expected for a while. Say so
88
+ * before the wait feels like a hang, and stop promising once it does. Nothing
89
+ * here may describe what the server is doing — from a lost connection the
90
+ * client only knows how long it has been quiet.
91
+ */
92
+ export function updateWaitNote(elapsedSeconds: number): string {
93
+ if (elapsedSeconds < 90) return "This usually takes about a minute.";
94
+ if (elapsedSeconds < 240)
95
+ return "Longer than usual. Remit is still trying to reach the server.";
96
+ return "Still no answer. Remit keeps trying.";
97
+ }
98
+
99
+ export function formatRelativeCheck(
100
+ checkedAt: number,
101
+ now: number = Date.now(),
102
+ ): string {
103
+ const minutes = Math.floor((now - checkedAt) / 60_000);
104
+ if (minutes < 1) return "just now";
105
+ if (minutes < 60) return `${minutes}m ago`;
106
+ const hours = Math.floor(minutes / 60);
107
+ if (hours < 24) return `${hours}h ago`;
108
+ return `${Math.floor(hours / 24)}d ago`;
109
+ }
110
+
111
+ export function formatReleaseDate(epochMillis: number): string {
112
+ return new Date(epochMillis).toLocaleDateString(undefined, {
113
+ dateStyle: "medium",
114
+ });
115
+ }
116
+
117
+ export const demoRelease: ReleaseInfo = {
118
+ version: "0.9.4",
119
+ releasedAt: Date.parse("2026-07-14T09:00:00.000Z"),
120
+ releaseNotesUrl: "https://github.com/remit-mail/reader/releases/tag/v0.9.4",
121
+ summary:
122
+ "Faster first sync on large mailboxes, and search no longer misses mail moved between folders.",
123
+ };
124
+
125
+ export const demoLogsCommand = "remit logs --since 10m";
126
+
127
+ export const demoRunId = "upd_8f3c21a7";
@@ -286,7 +286,7 @@ export function SwipeableRow({
286
286
  e.stopPropagation();
287
287
  onLongPress();
288
288
  }}
289
- className="inline-flex size-7 shrink-0 items-center justify-center rounded-full"
289
+ className="-m-2 inline-flex size-11 shrink-0 items-center justify-center rounded-full"
290
290
  >
291
291
  <Avatar name={thread.fromName} email={thread.fromEmail} size="sm" />
292
292
  </button>
package/src/index.ts CHANGED
@@ -379,6 +379,38 @@ export {
379
379
  type SelectionTopBarNoticeAction,
380
380
  type SelectionTopBarProps,
381
381
  } from "./components/selection-top-bar.js";
382
+ export {
383
+ demoLogsCommand,
384
+ demoRelease,
385
+ demoRunId,
386
+ formatRelativeCheck,
387
+ formatReleaseDate,
388
+ type ReleaseInfo,
389
+ type SelfUpdateState,
390
+ type SelfUpdateStatus,
391
+ type UpdatePhase,
392
+ type UpdateRunId,
393
+ updatePhaseLabel,
394
+ updateWaitNote,
395
+ } from "./components/self-update.js";
396
+ export {
397
+ SelfUpdateConfirmDialog,
398
+ type SelfUpdateConfirmDialogProps,
399
+ } from "./components/self-update-confirm-dialog.js";
400
+ export {
401
+ UpdateAvailableDot,
402
+ type UpdateAvailableDotProps,
403
+ } from "./components/self-update-dot.js";
404
+ export {
405
+ SelfUpdateProgressOverlay,
406
+ type SelfUpdateProgressOverlayProps,
407
+ SelfUpdateUnreachableScreen,
408
+ type SelfUpdateUnreachableScreenProps,
409
+ } from "./components/self-update-progress-overlay.js";
410
+ export {
411
+ SelfUpdateSection,
412
+ type SelfUpdateSectionProps,
413
+ } from "./components/self-update-section.js";
382
414
  export {
383
415
  type SenderGroupOption,
384
416
  SenderGroupSwitch,