From a7335aa2632d136bdd8bf9dabafa1e7eb9bab62e Mon Sep 17 00:00:00 2001 From: Matt Toohey Date: Mon, 9 Nov 2026 16:15:03 +1100 Subject: [PATCH 1/5] fix(reminders): mark grouped messages, skip unsent ones, and confirm the due time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Split out of PR #2507 following tellaho's review: the launch UI freeze allows contained fixes without new surfaces or options, so this branch keeps only those repairs. The Snooze / Remind me again → Custom… dialog moves to broken-8-custom-snooze, stacked on this branch. - Grouped messages now show their "Reminder set" mark. MessageRow renders action markers inside the visible byline on leading rows, as before. Grouped rows have only a screen-reader byline, so they render the markers once, in a select-none caption line after it, which `.marks:empty` hides while every marker renders nothing. docs/plugin-architecture.md describes the placement. - Remind me is no longer offered on a message the relay never stored. `matches` uses the same delivery check as Reply, Report and Start Solo chat (no delivery, accepted or seen), so failed, sending and unknown rows have no menu entry and no mark. - The mark names the earliest pending due time ("Reminder set for …") in its label. model.ts derives pendingMessageDue in place of pendingMessageIds. The mark is a plain labelled image: no Tooltip and no title, which would repeat the label as a description. - Setting a reminder confirms with a "Reminder set for …" toast. - docs/buzz-help.md gains a Reminders entry. Tests: index.test.ts covers the delivery gate and the mark's label; model.test.ts covers pendingMessageDue; MessageRow.test.tsx covers the grouped-row mark and the hidden empty line; RemindDialog.test.tsx covers the toast. Signed-off-by: Matt Toohey Co-Authored-By: Claude Fable 5.1 Signed-off-by: Matt Toohey --- docs/buzz-help.md | 4 ++ docs/plugin-architecture.md | 6 +- src/bundled/reminders/RemindDialog.test.tsx | 33 +++++++++ src/bundled/reminders/RemindDialog.tsx | 3 + src/bundled/reminders/index.test.ts | 77 ++++++++++++++++++++- src/bundled/reminders/index.tsx | 29 +++++--- src/bundled/reminders/model.test.ts | 16 +++-- src/bundled/reminders/model.ts | 39 +++++++---- src/features/messages/MessageRow.test.tsx | 76 ++++++++++++++++++++ src/features/messages/MessageRow.tsx | 31 +++++---- src/features/messages/Messages.module.css | 3 + 11 files changed, 273 insertions(+), 44 deletions(-) diff --git a/docs/buzz-help.md b/docs/buzz-help.md index 1696b2c33f..8ed913b643 100644 --- a/docs/buzz-help.md +++ b/docs/buzz-help.md @@ -738,6 +738,10 @@ and are asked to sign in again in Buzz. is shortened with an ellipsis, hover over it or use the arrow keys to select it and see the full name in a tooltip. A chosen or picked emoji is followed by a space, unless one already follows, so you can keep typing. +- **Reminders**, in the desktop app when the plugin is on: choose **Remind me** + in a sent message's ⋯ menu. A confirmation names the due time, and the message + shows an alarm mark while the reminder is pending. A reminder's note can't be + edited once set. - **Reminder counts** show how many reminders are due in a small capsule on the app tile's corner. It shows `99+` above 99; its accessible label keeps the exact count. diff --git a/docs/plugin-architecture.md b/docs/plugin-architecture.md index bd529c3f90..26b00cac09 100644 --- a/docs/plugin-architecture.md +++ b/docs/plugin-architecture.md @@ -2748,8 +2748,10 @@ the entry appears; throwing matchers are skipped. `icon` renders beside the titl Choosing the entry mounts `component` with `{ message, session, close, canOpen, open }` inside the row, typically a dialog; it stays mounted until it calls `close()`. The optional `marker` receives `{ message, session }` and renders beside the timestamp, such as a -state mark. It renders only while `matches` passes, so hiding the menu entry also -hides its mark. The host owns the menu, focus restoration and row lifetime: a row +state mark. A grouped message shows no byline, so its marks get a caption line of +their own above the message, which takes no space while they render nothing; like +the hidden byline, copying the row leaves them out. It renders only while +`matches` passes, so hiding the menu entry also hides its mark. The host owns the menu, focus restoration and row lifetime: a row with an open action stays mounted while it scrolls out of view. Icon, component and marker failures each render nothing and leave the row and menu usable. The bundled Reminders plugin is the first consumer. diff --git a/src/bundled/reminders/RemindDialog.test.tsx b/src/bundled/reminders/RemindDialog.test.tsx index 285eca628d..d58253518c 100644 --- a/src/bundled/reminders/RemindDialog.test.tsx +++ b/src/bundled/reminders/RemindDialog.test.tsx @@ -6,6 +6,7 @@ import { fireEvent, render, screen, + waitFor, } from "@testing-library/react"; import { afterEach, assert, expect, it, vi } from "vitest"; import type { ChannelMessage } from "../../features/relay/contracts"; @@ -14,6 +15,8 @@ import { foldMessages } from "../../features/relay/fold"; import type { RelaySession } from "../../features/relay/session"; import { keypair, signed } from "../../features/relay/testing"; import userEvent from "@testing-library/user-event"; +import { ToastProvider } from "../../shared/design-system/ui/Toast"; +import { formatDue } from "./model"; import { RemindDialog } from "./RemindDialog"; afterEach(() => { @@ -287,6 +290,36 @@ it("reveals labelled custom fields and saves a future time with the note", async ); }); +it("confirms a saved reminder with its due time", async () => { + const create = vi.fn(async (..._args: unknown[]) => {}); + const close = vi.fn(); + render( + + + , + ); + await userEvent + .setup() + .click(screen.getByRole("button", { name: "Set reminder" })); + expect(close).toHaveBeenCalledOnce(); + const at = create.mock.calls[0]?.[1] as number; + // Sonner mounts a toast transparent, then fades it in. + await waitFor(() => + expect(screen.getByText(`Reminder set for ${formatDue(at)}`)).toBeVisible(), + ); +}); + it("stays open after a stray outside click", async () => { const close = vi.fn(); render( diff --git a/src/bundled/reminders/RemindDialog.tsx b/src/bundled/reminders/RemindDialog.tsx index dafa70f407..d75359e9c4 100644 --- a/src/bundled/reminders/RemindDialog.tsx +++ b/src/bundled/reminders/RemindDialog.tsx @@ -8,6 +8,7 @@ import { Field } from "../../shared/design-system/ui/Field"; import { Select } from "../../shared/design-system/ui/Select"; import { Input } from "../../shared/design-system/ui/Input"; import { Textarea } from "../../shared/design-system/ui/Textarea"; +import { useToastNotification } from "../../shared/design-system/ui/Toast"; import { TIME_PRESETS, formatDue, @@ -34,6 +35,7 @@ export function RemindDialog({ const [time, setTime] = useState("09:00"); const [pending, setPending] = useState(false); const [error, setError] = useState(); + const notify = useToastNotification(); const custom = parseCustomDateTime(date, time); const preset = TIME_PRESETS.find((item) => item.label === when); const submit = async (notBefore: number) => { @@ -52,6 +54,7 @@ export function RemindDialog({ notBefore, note, ); + notify(`Reminder set for ${formatDue(notBefore)}`, "success"); close(); } catch { setError("The reminder could not be saved. Try again."); diff --git a/src/bundled/reminders/index.test.ts b/src/bundled/reminders/index.test.ts index 1b4b0748a9..3595acc09a 100644 --- a/src/bundled/reminders/index.test.ts +++ b/src/bundled/reminders/index.test.ts @@ -1,5 +1,10 @@ +import { createElement } from "react"; +import { renderToStaticMarkup } from "react-dom/server"; import { afterEach, beforeEach, expect, it, vi } from "vitest"; +import type { ChannelMessage } from "../../features/relay/contracts"; +import type { MessageAction } from "../../features/conversation/contracts"; import type { RelayEvent } from "../../features/relay/events"; +import type { RelaySession } from "../../features/relay/session"; import type { LiveCallbacks } from "../../features/relay/live"; import { createReminders } from "../../features/relay/reminders"; import { Context } from "@deepseek-ai/cordis"; @@ -12,6 +17,7 @@ import { createNotificationPreferences } from "../../features/notifications/pref import type { NotificationPlatform } from "../../features/notifications/platform"; import type { Navigation } from "../../features/navigation/controller"; import { apply } from "./index"; +import { formatDue } from "./model"; const viewer = "a".repeat(64); const target = { @@ -97,6 +103,8 @@ function mount(notifications?: unknown) { effect: (body: () => () => void) => void stop.push(body()), }; apply(ctx as unknown as Parameters[0]); + const action = ctx.conversation.registerMessageAction.mock + .calls[0]?.[0] as MessageAction; const connect = (scope: string, reminders: unknown) => { snapshot = { status: "ready", @@ -109,7 +117,7 @@ function mount(notifications?: unknown) { const dispose = () => { for (const body of stop.splice(0)) body(); }; - return { submit, connect, dispose }; + return { submit, connect, dispose, action }; } const at = (seconds: number) => vi.setSystemTime(seconds * 1000); @@ -131,6 +139,73 @@ afterEach(() => { vi.unstubAllGlobals(); }); +it.each([ + [undefined, true], + ["accepted", true], + ["seen", true], + ["sending", false], + ["unknown", false], + ["failed", false], +] as const)("offers Remind me on a %s message: %s", (delivery, offered) => { + const { action } = mount(); + const message = { id: "m", ...(delivery ? { delivery } : {}) }; + expect( + action.matches( + message as ChannelMessage, + { + reminders: session(Promise.resolve([])).capability, + } as unknown as RelaySession, + ), + ).toBe(offered); + // Without the reminder store there is nothing to offer, delivered or not. + expect(action.matches(message as ChannelMessage, {} as RelaySession)).toBe( + false, + ); +}); + +it("labels a message's mark with its earliest pending due time", () => { + const { action } = mount(); + const Marker = action.marker; + if (!Marker) throw new Error("Remind me has no marker"); + const reminder = ( + id: string, + status: "pending" | "done", + notBefore?: number, + ) => ({ + id, + eventId: id, + createdAt: 1, + status, + ...(notBefore !== undefined ? { notBefore } : {}), + target, + }); + const markup = (reminders: unknown[]) => { + const state = { status: "ready", hydrated: true, reminders }; + return renderToStaticMarkup( + createElement(Marker, { + message: { id: target.eventId } as ChannelMessage, + session: { + reminders: { subscribe: () => () => {}, snapshot: () => state }, + } as unknown as RelaySession, + }), + ); + }; + const label = `Reminder set for ${formatDue(2_000_000_000)}`; + const marked = markup([ + reminder("later", "pending", 2_100_000_000), + reminder("done", "done", 1_900_000_000), + reminder("sooner", "pending", 2_000_000_000), + ]); + expect(marked).toContain(`aria-label="${label}"`); + // Announced once: a title or hint would repeat the label as a description. + expect(marked).not.toMatch(/title=|tooltip-trigger/); + // A due time Date cannot show still marks the message. + expect(markup([reminder("far", "pending", 8_640_000_000_001)])).toContain( + 'aria-label="Reminder set"', + ); + expect(markup([reminder("done", "done", 2_000_000_000)])).toBe(""); +}); + it("notifies a reminder from slow history even after a live update moved the clock", async () => { let resolveHistory: (events: RelayEvent[]) => void = () => {}; const model = session(new Promise((resolve) => (resolveHistory = resolve))); diff --git a/src/bundled/reminders/index.tsx b/src/bundled/reminders/index.tsx index 4d9466aaf7..2e2c0bd302 100644 --- a/src/bundled/reminders/index.tsx +++ b/src/bundled/reminders/index.tsx @@ -9,10 +9,12 @@ import { AlarmIcon } from "../../shared/design-system/icons/index"; import { countDue, dueSince, + formatDue, + isDisplayable, navigableTarget, nextDelay, nowSeconds, - pendingMessageIds, + pendingMessageDue, } from "./model"; import { RemindDialog } from "./RemindDialog"; import { RemindersPage } from "./RemindersPage"; @@ -265,23 +267,30 @@ export const apply: PluginModule["apply"] = (ctx) => { reminders?.snapshot ?? noState, reminders?.snapshot ?? noState, ); - return pendingMessageIds(state).has(message.id) ? ( - + const due = pendingMessageDue(state); + if (!due.has(message.id)) return null; + const at = due.get(message.id); + const label = + at !== undefined && isDisplayable(at) + ? `Reminder set for ${formatDue(at)}` + : "Reminder set"; + // Labelled only: a title would repeat the label as its description. + return ( + - ) : null; + ); } ctx.conversation.registerMessageAction({ id: "remind-me", title: "Remind me", icon: () =>