Keep the notifications worth interrupting for

Splitting system messages out of the modal was right for payout receipts,
but it would have silenced two that a member genuinely loses money by
ignoring:

  - "@someone is trying to buy. Link your wallet so it pays you" — a sale
    is blocked right now, and the referral is lost permanently once it
    routes to someone else.
  - "You missed 43 POL on InstantAdPay" — a payout passed them by, and the
    message explains exactly how to stop the next one doing the same.

So the dividing line is not system-versus-human, it is "does this need you
to do something". Those two become kind 'alert' and still interrupt; the
receipts stay kind 'notice' and stay in the inbox.

The modal no longer credits an alert to a person either. It was saying "A
message from @martbost" over machine-generated text, because system mail
is sent by member 1 at ADMIN_EMAIL. Alerts now read "Action needed on your
account".

Also reclassified "X is now in your line for good" as a notice — it is
good news about a referral the member gained, with nothing at stake.

qa/messages-notice.mjs now covers both lanes: 14 checks, including that an
alert interrupts and a flood of 25 receipts does not.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-18 08:25:08 -05:00
parent a2c77d01d1
commit c5a846bd91
6 changed files with 55 additions and 24 deletions
+11 -2
View File
@@ -28,6 +28,7 @@ await messages.deliver(1, 'house@instantadpay.com', [ME], 'You missed 43.06 POL
const box = await messages.inbox(ME);
t('every message reaches the inbox', box.length === 3, String(box.length));
t('the inbox badge counts notices too', (await messages.unreadCount(ME)) === 3, String(await messages.unreadCount(ME)));
t('an unknown kind falls back to a human broadcast', (await messages.inbox(ME))[0] !== undefined);
// the whole point
const un = await messages.newestUnread(ME);
@@ -41,12 +42,20 @@ t('once acknowledged, nothing else pops', after === null, after && after.subject
t('but the notices are still unread in the inbox', (await messages.unreadCount(ME)) === 2,
String(await messages.unreadCount(ME)));
// an ALERT is system-generated too, but the member loses money by ignoring it — it interrupts
await messages.deliver(1, 'house@instantadpay.com', [ME], '@reyba is trying to buy. Link your wallet so it pays you', '<p>act</p>', 'alert');
const al = await messages.newestUnread(ME);
t('a money-at-stake alert does interrupt', al && /trying to buy/.test(al.subject), al && al.subject);
t('and it is labelled as an alert, not as a person', al && al.kind === 'alert', al && al.kind);
await messages.markRead(ME, al.id);
t('acknowledging the alert clears it', (await messages.newestUnread(ME)) === null);
// a flood of notices must never produce a single interruption
for (let i = 0; i < 25; i++) {
await messages.deliver(1, 'house@instantadpay.com', [ME], 'You just got paid ' + i + ' POL on InstantAdPay', '<p>x</p>', 'notice');
}
t('25 more payout notices still pop nothing', (await messages.newestUnread(ME)) === null);
t('and they all show up in the inbox', (await messages.inbox(ME)).length === 28,
t('and they all show up in the inbox', (await messages.inbox(ME)).length === 29,
String((await messages.inbox(ME)).length));
// an untagged deliver is still treated as a human broadcast (back-compat)
@@ -56,7 +65,7 @@ t('an untagged message still interrupts, as before', un2 && un2.subject === 'Tea
// chat never pops the modal and never lands in the inbox list
await messages.sendChat(36, 'sponsor@example.com', ME, 'you around?');
t('chat stays out of the inbox list', (await messages.inbox(ME)).length === 29,
t('chat stays out of the inbox list', (await messages.inbox(ME)).length === 30,
String((await messages.inbox(ME)).length));
t('chat is counted separately', (await messages.chatUnread(ME)) === 1, String(await messages.chatUnread(ME)));