@supersuit/suggest-a-change 0.1.12 → 0.1.13

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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # Changelog
2
2
 
3
- ## Unreleased
3
+ ## 0.1.13 (2026-10-21)
4
+
5
+ - **Old news is no longer toasted on every open.** The page load's one toast went to the newest move the person had not opened, however long ago it happened, so opening the app a day later replayed the same news each time. The phone now keeps what the last page load already had as news (`#view:noticed`, beside the seen record and cleared with it): only a move that is new since that load is toasted, and an older one keeps the dot and the New mark until it is opened. The first load on this release behaves as before. New in `seen.ts`: `fresh(store, id, moves)`.
6
+ - **A toast is a small pill at the bottom, not a bar over the top of the page.** `.sac-toasts` anchored to the top safe area and each `.sac-toast` spanned the width, so the suggestion news shown when an app opened sat over the host's own header and first row. Toasts now sit above the bottom safe area, as wide as their words (up to 24rem), in a smaller type, with a drawn × so they read as dismissable; a tap still dismisses. Styling only: no API or `Words` change. Test: package.test.mjs, red against the old stylesheet.
4
7
 
5
8
  ## 0.1.12 (2026-10-19)
6
9
 
package/README.md CHANGED
@@ -75,7 +75,7 @@ The four diagnostics are the app's version, the time, the screen size and the ph
75
75
 
76
76
  **Telling the person in the app, with no setup.** The entry asks `mine()` once when it mounts and compares each report's status with the one this account last opened (kept on the phone beside the cached views, per app and account, and cleared on sign-out). A report that has since been started or ended (`TOLD`) shows a dot on the entry, says New on its row in My suggestions, and the newest such move gets one toast per page load in the module's words (`words.text.movedToast`, given the status's own word and, on `not-now`, the reason: "Your suggestion: Done", "Your suggestion: Not now. too big for now"). Opening the report clears it. A report this phone sees for the first time is recorded silently, so an app taking this release does not announce every old report. The list's `not-now` rows carry their one-line `note` for this. Out of the app, the server's `tellSubmitter` does the telling (below).
77
77
 
78
- **When the entry sits in a menu.** A host that shows the entry inside a menu that stays closed (a three-dot menu, often remounting its rows on every open) would never show the dot, and the toast would be drawn inside the closed menu. Mount `<SuggestNews>` once at the app's root, always mounted: it asks `mine()` when it mounts, shows the page load's one toast with no entry on screen, and keeps the outbox moving. Put the dot on the menu's own trigger with `useSuggestNews(adapters)`, which returns `{ moved }`, and `<SuggestDot>`, which draws the entry's dot (nothing when `moved` is 0). The trigger needs `position: relative`; the class `sac-dot-host` does it. The toast is once per page load and account however many times the entry mounts, whichever of these asks first. The entry in the menu keeps its own dot.
78
+ **When the entry sits in a menu.** A host that shows the entry inside a menu that stays closed (a three-dot menu, often remounting its rows on every open) would never show the dot, and the toast would be drawn inside the closed menu. Mount `<SuggestNews>` once at the app's root, always mounted: it asks `mine()` when it mounts, shows the page load's one toast with no entry on screen, and keeps the outbox moving. Put the dot on the menu's own trigger with `useSuggestNews(adapters)`, which returns `{ moved }`, and `<SuggestDot>`, which draws the entry's dot (nothing when `moved` is 0). The trigger needs `position: relative`; the class `sac-dot-host` does it. The toast is once per page load and account however many times the entry mounts, whichever of these asks first, and only for a move the previous page load had not already seen: older news keeps the dot and the New mark without a toast. The entry in the menu keeps its own dot.
79
79
 
80
80
  ```tsx
81
81
  import { SuggestDot, SuggestEntry, SuggestNews, useSuggestNews } from "@supersuit/suggest-a-change/client";
@@ -5,7 +5,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
5
5
  // shows the sheet. `<ReportProblem>` is the same control for an error screen, already filled in.
6
6
  import { useEffect, useState } from 'react';
7
7
  import { useRuntime } from './runtime.js';
8
- import { firstToastThisOpen, moved, onSeen } from './seen.js';
8
+ import { firstToastThisOpen, fresh, moved, onSeen } from './seen.js';
9
9
  import { SuggestSheet } from './sheet.js';
10
10
  import { toast, Toasts } from './toast.js';
11
11
  import { useClearOnSignOut } from './view-cache.js';
@@ -17,7 +17,7 @@ export function KeepSending({ adapters }) {
17
17
  return null;
18
18
  }
19
19
  // THE NEWS: once per mount, asks the app for this person's reports and compares each with what they last opened. A move
20
- // since then is counted (the dot), and the newest one gets the page load's one toast, whichever of the entry or a
20
+ // since then is counted (the dot), and the newest one the last page load had not already seen gets the page load's one toast, whichever of the entry or a
21
21
  // root-mounted SuggestNews asks first (the guard is per page load and account, in seen.ts). Opening a report anywhere
22
22
  // recounts. `toasted` says this mount showed the toast, so a standalone entry knows to draw a toast host for it.
23
23
  function useNews(adapters, rt) {
@@ -56,10 +56,14 @@ function useNews(adapters, rt) {
56
56
  if (!live || !rows || !now || now.account !== rt.who.account)
57
57
  return;
58
58
  const m = await count();
59
- if (!live || !m?.length || !firstToastThisOpen(id))
59
+ if (!live || !m)
60
+ return;
61
+ // Only a move the last page load had not already seen is toasted; an older one keeps just the dot.
62
+ const f = await fresh(rt.store, id, m);
63
+ if (!f.length || !firstToastThisOpen(id))
60
64
  return;
61
65
  const at = (x) => rows.find((r) => r.id === x)?.at ?? 0;
62
- const top = [...m].sort((a, b) => at(b.id) - at(a.id))[0];
66
+ const top = [...f].sort((a, b) => at(b.id) - at(a.id))[0];
63
67
  const note = top.status === 'not-now' ? rows.find((r) => r.id === top.id)?.note : undefined;
64
68
  setToasted(true);
65
69
  toast({ id: `sac-moved-${top.id}`, text: S.movedToast(statusWords(top.status, adapters.words.owner), typeof note === 'string' && note ? note : undefined), ms: 6000 });
@@ -21,4 +21,16 @@ export declare function moved(store: Store, id: Id, rows: {
21
21
  status: string;
22
22
  }[]>;
23
23
  export declare function firstToastThisOpen(id: Id): boolean;
24
+ /** WHAT THE LAST PAGE LOAD ALREADY SAW. The moves (report and status) that were already news the last time the app was
25
+ * loaded, so a move the person was told about, or could have been, is not toasted again on the next load; it keeps
26
+ * only the dot and the New mark until they open it. Returns the moves in `m` that are new since then, and records `m`
27
+ * as what this load saw. With no record yet (the first load on this release) every move is fresh, as before. */
28
+ export declare const noticedKey: (id: Id) => string;
29
+ export declare function fresh(store: Store, id: Id, m: {
30
+ id: string;
31
+ status: string;
32
+ }[]): Promise<{
33
+ id: string;
34
+ status: string;
35
+ }[]>;
24
36
  export {};
@@ -70,3 +70,24 @@ export function firstToastThisOpen(id) {
70
70
  toasted.add(k);
71
71
  return true;
72
72
  }
73
+ /** WHAT THE LAST PAGE LOAD ALREADY SAW. The moves (report and status) that were already news the last time the app was
74
+ * loaded, so a move the person was told about, or could have been, is not toasted again on the next load; it keeps
75
+ * only the dot and the New mark until they open it. Returns the moves in `m` that are new since then, and records `m`
76
+ * as what this load saw. With no record yet (the first load on this release) every move is fresh, as before. */
77
+ export const noticedKey = (id) => `${draftKey(id)}#view:noticed`;
78
+ export function fresh(store, id, m) {
79
+ return serial(noticedKey(id), async () => {
80
+ const had = await readCache(store, noticedKey(id));
81
+ const before = had && typeof had === 'object' ? had : {};
82
+ const out = m.filter((r) => before[r.id] !== r.status);
83
+ const now = { ...before };
84
+ for (const r of m)
85
+ now[r.id] = r.status;
86
+ // A report no longer moved (opened, or gone) drops out, so the record stays the size of the dot.
87
+ for (const k of Object.keys(now))
88
+ if (!m.some((r) => r.id === k))
89
+ delete now[k];
90
+ await writeCache(store, noticedKey(id), now);
91
+ return out;
92
+ });
93
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supersuit/suggest-a-change",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "The report format and flow behind a Suggest a change button: what a report is, who acts at each step, the screens, and the check every app runs. The contract has zero dependencies.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -5,7 +5,7 @@
5
5
  import { useEffect, useState, type AriaRole, type ReactNode } from 'react'
6
6
  import type { Adapters } from './adapters.ts'
7
7
  import { useRuntime, type Runtime } from './runtime.ts'
8
- import { firstToastThisOpen, moved, onSeen } from './seen.ts'
8
+ import { firstToastThisOpen, fresh, moved, onSeen } from './seen.ts'
9
9
  import { SuggestSheet } from './sheet.tsx'
10
10
  import { toast, Toasts } from './toast.tsx'
11
11
  import { useClearOnSignOut } from './view-cache.ts'
@@ -19,7 +19,7 @@ export function KeepSending({ adapters }: { adapters: Adapters }) {
19
19
  }
20
20
 
21
21
  // THE NEWS: once per mount, asks the app for this person's reports and compares each with what they last opened. A move
22
- // since then is counted (the dot), and the newest one gets the page load's one toast, whichever of the entry or a
22
+ // since then is counted (the dot), and the newest one the last page load had not already seen gets the page load's one toast, whichever of the entry or a
23
23
  // root-mounted SuggestNews asks first (the guard is per page load and account, in seen.ts). Opening a report anywhere
24
24
  // recounts. `toasted` says this mount showed the toast, so a standalone entry knows to draw a toast host for it.
25
25
  function useNews(adapters: Adapters, rt: Runtime | null): { moved: number; toasted: boolean } {
@@ -44,9 +44,12 @@ function useNews(adapters: Adapters, rt: Runtime | null): { moved: number; toast
44
44
  try { now = await adapters.identity() } catch { now = null }
45
45
  if (!live || !rows || !now || now.account !== rt.who.account) return
46
46
  const m = await count()
47
- if (!live || !m?.length || !firstToastThisOpen(id)) return
47
+ if (!live || !m) return
48
+ // Only a move the last page load had not already seen is toasted; an older one keeps just the dot.
49
+ const f = await fresh(rt.store, id, m)
50
+ if (!f.length || !firstToastThisOpen(id)) return
48
51
  const at = (x: string) => rows!.find((r) => r.id === x)?.at ?? 0
49
- const top = [...m].sort((a, b) => at(b.id) - at(a.id))[0]
52
+ const top = [...f].sort((a, b) => at(b.id) - at(a.id))[0]
50
53
  const note = top.status === 'not-now' ? rows.find((r) => r.id === top.id)?.note : undefined
51
54
  setToasted(true)
52
55
  toast({ id: `sac-moved-${top.id}`, text: S.movedToast(statusWords(top.status, adapters.words.owner), typeof note === 'string' && note ? note : undefined), ms: 6000 })
@@ -70,3 +70,22 @@ export function firstToastThisOpen(id: Id): boolean {
70
70
  toasted.add(k)
71
71
  return true
72
72
  }
73
+
74
+ /** WHAT THE LAST PAGE LOAD ALREADY SAW. The moves (report and status) that were already news the last time the app was
75
+ * loaded, so a move the person was told about, or could have been, is not toasted again on the next load; it keeps
76
+ * only the dot and the New mark until they open it. Returns the moves in `m` that are new since then, and records `m`
77
+ * as what this load saw. With no record yet (the first load on this release) every move is fresh, as before. */
78
+ export const noticedKey = (id: Id) => `${draftKey(id)}#view:noticed`
79
+ export function fresh(store: Store, id: Id, m: { id: string; status: string }[]): Promise<{ id: string; status: string }[]> {
80
+ return serial(noticedKey(id), async () => {
81
+ const had = await readCache<Seen>(store, noticedKey(id))
82
+ const before = had && typeof had === 'object' ? had : {}
83
+ const out = m.filter((r) => before[r.id] !== r.status)
84
+ const now: Seen = { ...before }
85
+ for (const r of m) now[r.id] = r.status
86
+ // A report no longer moved (opened, or gone) drops out, so the record stays the size of the dot.
87
+ for (const k of Object.keys(now)) if (!m.some((r) => r.id === k)) delete now[k]
88
+ await writeCache(store, noticedKey(id), now)
89
+ return out
90
+ })
91
+ }
@@ -63,8 +63,12 @@
63
63
  .sac-step[data-state="now"] { border-color: var(--sac-accent); color: var(--sac-fg); font-weight: 600; }
64
64
  .sac-step-detail { display: block; font-weight: 400; font-size: 0.85rem; }
65
65
  .sac-words { white-space: pre-wrap; overflow-wrap: anywhere; }
66
- .sac-toasts { position: fixed; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 8px); z-index: calc(var(--sac-z) + 1); display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 16px; pointer-events: none; }
67
- .sac-toast { pointer-events: auto; font: inherit; width: 100%; max-width: 28rem; text-align: left; padding: 12px 16px; border-radius: var(--sac-radius); border: 1px solid var(--sac-border); background: var(--sac-bg); color: var(--sac-fg); }
66
+ /* Toasts sit small at the bottom edge, never over the top of the host's page: the top is where an app opens onto
67
+ its own content, and a full-width bar there reads as the app's header. Each is a pill as wide as its words, with a
68
+ drawn x so it reads as dismissable (the whole pill is the button). */
69
+ .sac-toasts { position: fixed; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 12px); z-index: calc(var(--sac-z) + 1); display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0 16px; pointer-events: none; }
70
+ .sac-toast { pointer-events: auto; font: inherit; font-size: 0.875rem; line-height: 1.3; width: auto; max-width: min(100%, 24rem); text-align: left; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--sac-border); background: var(--sac-bg); color: var(--sac-fg); display: inline-flex; align-items: center; gap: 8px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18); }
71
+ .sac-toast::after { content: "\00d7"; color: var(--sac-muted); font-size: 1rem; line-height: 1; }
68
72
  .sac-toast[data-tone="warn"] { background: var(--sac-fg); color: var(--sac-bg); }
69
73
  .sac-entry-why { margin-left: 8px; color: var(--sac-muted); font-size: 0.9rem; }
70
74
  .sac-sheet :focus-visible, .sac-entry:focus-visible, .sac-button:focus-visible, .sac-record:focus-visible, .sac-row-button:focus-visible { outline: 3px solid var(--sac-focus); outline-offset: 2px; }