From 4260880672fc572ea9b562c39931caaf7b386b9c Mon Sep 17 00:00:00 2001
From: Claude
Date: Sat, 21 Nov 2026 04:55:44 +0000
Subject: [PATCH 01/13] List shared phrases once in the combined Phrase Bank,
Quick Lookup and search
A stock line that several cards share (e.g. "That sounds like it mattered")
now appears once in the all-cards views, under its first card, with a note
that it is on other cards. Each card's own phrase bank is unchanged, and a
line saved from any of its cards still shows as saved.
Co-Authored-By: Claude Opus 5.5
Claude-Session: https://claude.ai/code/session_01GxPPxjfPnzopEHAJKSC3rp
---
.../src/components/quick-mode-overlay.tsx | 63 +++++++++++++++----
.../tc-reference/src/lib/phrase-filters.ts | 10 +--
.../tc-reference/src/lib/phrases-data.ts | 53 +++++++++++++++-
.../tc-reference/src/lib/search-index.ts | 10 ++-
artifacts/tc-reference/src/pages/phrases.tsx | 34 +++++++---
.../src/test/phrase-filters.test.ts | 53 +++++++++++++++-
.../src/test/phrases-filters-page.test.tsx | 38 +++++++++++
.../src/test/quick-mode-windowing.test.tsx | 49 +++++++++++++++
.../src/test/search-index.test.ts | 14 ++++-
.../src/test/search-real-corpus.test.ts | 31 +++++++++
10 files changed, 322 insertions(+), 33 deletions(-)
diff --git a/artifacts/tc-reference/src/components/quick-mode-overlay.tsx b/artifacts/tc-reference/src/components/quick-mode-overlay.tsx
index 2ad0294..0e1d6b9 100644
--- a/artifacts/tc-reference/src/components/quick-mode-overlay.tsx
+++ b/artifacts/tc-reference/src/components/quick-mode-overlay.tsx
@@ -4,6 +4,7 @@ import { X, Check, Copy, Heart } from "lucide-react";
import { LIBRARY_CATEGORIES } from "@/lib/data";
import { isSpeakablePhrase } from "@/lib/card-types";
import { loadCardTextIndex, type CardTextIndex } from "@/lib/card-text-index";
+import { phraseDedupeKey } from "@/lib/phrases-data";
import { useQuickMode } from "@/lib/quick-mode";
import { useFavourites } from "@/lib/favourites-context";
import { useFocusTrap } from "@/hooks/use-focus-trap";
@@ -16,6 +17,15 @@ interface QuickPhrase {
cardTitle: string;
/** Every card that lists this line in this group (it is shown once). */
cardIds: string[];
+ /** Each listing card's own wording, so favourites match the card. */
+ textByCard: Record;
+ /**
+ * The first listing of this line across every group. The all-cards view
+ * shows only these, so a stock line shared by several cards appears once.
+ */
+ primary: boolean;
+ /** Every card, in any group, that lists the line (shared with duplicates). */
+ allTextByCard: Record;
}
interface QuickGroup {
@@ -35,6 +45,8 @@ function buildQuickGroups(cards: CardTextIndex): QuickGroup[] {
// Many cards share stock lines ("What was that like?"). Keep one row per
// line per group and remember every card it came from.
const seen = new Map();
+ // Across groups too: the all-cards view lists each line once.
+ const seenAnywhere = new Map>();
for (const [cardId, card] of Object.entries(cards)) {
const cardMeta = Object.values(LIBRARY_CATEGORIES)
@@ -54,10 +66,21 @@ function buildQuickGroups(cards: CardTextIndex): QuickGroup[] {
const targetGroup = groupsMap.get(group.id)!;
for (const phraseText of group.phrases) {
if (!isSpeakablePhrase(phraseText)) continue;
- const key = `${group.id}\u0000${phraseText.trim().toLowerCase()}`;
+ const lineKey = phraseDedupeKey(phraseText);
+ let allTextByCard = seenAnywhere.get(lineKey);
+ const primary = !allTextByCard;
+ if (!allTextByCard) {
+ allTextByCard = {};
+ seenAnywhere.set(lineKey, allTextByCard);
+ }
+ allTextByCard[cardId] ??= phraseText;
+ const key = `${group.id}\u0000${lineKey}`;
const existing = seen.get(key);
if (existing) {
- if (!existing.cardIds.includes(cardId)) existing.cardIds.push(cardId);
+ if (!existing.cardIds.includes(cardId)) {
+ existing.cardIds.push(cardId);
+ existing.textByCard[cardId] = phraseText;
+ }
continue;
}
const entry: QuickPhrase = {
@@ -65,6 +88,9 @@ function buildQuickGroups(cards: CardTextIndex): QuickGroup[] {
cardId,
cardTitle: cardMeta.title,
cardIds: [cardId],
+ textByCard: { [cardId]: phraseText },
+ primary,
+ allTextByCard,
};
seen.set(key, entry);
targetGroup.phrases.push(entry);
@@ -176,12 +202,16 @@ function QuickModeContent() {
// Attribute to the open card so favourites file under it
.map((p) => ({
...p,
+ text: p.textByCard[contextCardId] ?? p.text,
cardId: contextCardId,
cardTitle: CARD_TITLE_MAP_QM[contextCardId],
+ allTextByCard: { [contextCardId]: p.textByCard[contextCardId] },
})),
}))
.filter((g) => g.phrases.length > 0)
- : (quickGroups ?? []);
+ : (quickGroups ?? [])
+ .map((g) => ({ ...g, phrases: g.phrases.filter((p) => p.primary) }))
+ .filter((g) => g.phrases.length > 0);
const filteredGroups = quickFilter
? allQuickGroups.filter((g) => g.id === quickFilter)
: allQuickGroups;
@@ -400,7 +430,11 @@ function QuickModeContent() {
}}
>
{group.phrases.map((phrase, i) => {
- const isFav = isPhrasesFav(phrase.cardId, phrase.text);
+ // A shared line counts as saved from any card that lists it.
+ const savedFrom = Object.entries(phrase.allTextByCard).filter(
+ ([cardId, text]) => isPhrasesFav(cardId, text),
+ );
+ const isFav = savedFrom.length > 0;
return (
@@ -406,7 +417,7 @@ interface PhraseGroupProps {
phrases: AggregatedPhrase[];
copied: string | null;
onCopy: (text: string) => void;
- isFav: (cardId: string, text: string) => boolean;
+ isFav: (phrase: AggregatedPhrase) => boolean;
onFav: (phrase: AggregatedPhrase) => void;
}
@@ -457,7 +468,7 @@ function PhraseGroup({
key={`${phrase.groupId}-${i}-${phrase.text}`}
phrase={phrase}
copied={copied === phrase.text}
- faved={isFav(phrase.cardId, phrase.text)}
+ faved={isFav(phrase)}
onCopy={() => onCopy(phrase.text)}
onFav={() => onFav(phrase)}
/>
@@ -507,6 +518,9 @@ function PhraseRow({ phrase, copied, faved, onCopy, onFav }: PhraseRowProps) {
style={{ color: "var(--fg-55)" }}
>
{copied ? "Copied" : phrase.groupLabel}
+ {!copied && phrase.alsoOn?.length
+ ? ` · also on ${phrase.alsoOn.length} more ${phrase.alsoOn.length === 1 ? "card" : "cards"}`
+ : ""}
{
expect(lengthTotal).toBe(all.length);
});
});
+
+describe("the combined Phrase Bank lists each line once", () => {
+ it("has no repeated lines, ignoring case and punctuation", async () => {
+ const all = await loadAllAggregatedPhrases();
+ const keys = all.map((p) => phraseDedupeKey(p.text));
+ expect(new Set(keys).size).toBe(keys.length);
+ });
+
+ it("keeps a shared line under its first card and notes the others", async () => {
+ const all = await loadAllAggregatedPhrases();
+ const key = phraseDedupeKey("That sounds like it mattered");
+ const shared = all.filter((p) => phraseDedupeKey(p.text) === key);
+ expect(shared).toHaveLength(1);
+ expect(shared[0].cardId).toBe("TC001");
+ const others = (shared[0].alsoOn ?? []).map((s) => s.cardId);
+ expect(others).toEqual(expect.arrayContaining(["TC012", "TC082"]));
+ expect(others).not.toContain("TC001");
+ });
+
+ it("loses no line: every card's speakable phrase is in the bank or noted", async () => {
+ const cards = await loadAllCards();
+ const all = await loadAllAggregatedPhrases();
+ const covered = new Set();
+ for (const p of all)
+ for (const s of [p, ...(p.alsoOn ?? [])])
+ covered.add(`${s.cardId}|${phraseDedupeKey(s.text)}`);
+ for (const [cardId, card] of Object.entries(cards))
+ for (const group of card.phraseBank)
+ for (const text of group.phrases)
+ if (isSpeakablePhrase(text))
+ expect(covered.has(`${cardId}|${phraseDedupeKey(text)}`)).toBe(
+ true,
+ );
+ });
+
+ it("finds a shared line by any card it is on", () => {
+ const shared = phrase("A shared line", {
+ alsoOn: [
+ { cardId: "TC082", cardTitle: "Other card", text: "a shared line" },
+ ],
+ });
+ expect(filterPhrases([shared], { ...NO_FILTER, query: "TC082" })).toEqual([
+ shared,
+ ]);
+ expect(
+ filterPhrases([shared], { ...NO_FILTER, query: "other card" }),
+ ).toEqual([shared]);
+ });
+});
diff --git a/artifacts/tc-reference/src/test/phrases-filters-page.test.tsx b/artifacts/tc-reference/src/test/phrases-filters-page.test.tsx
index d77eba4..08c86db 100644
--- a/artifacts/tc-reference/src/test/phrases-filters-page.test.tsx
+++ b/artifacts/tc-reference/src/test/phrases-filters-page.test.tsx
@@ -79,3 +79,41 @@ describe("Phrase Bank tone and length filters", () => {
expect(count).toHaveTextContent(countText(all.length));
});
});
+
+describe("Phrase Bank saved state for shared lines", () => {
+ it("shows a line saved from another card as saved", async () => {
+ const all = await loadAllAggregatedPhrases();
+ const shared = all.find((p) => (p.alsoOn?.length ?? 0) > 0)!;
+ const other = shared.alsoOn![0];
+ localStorage.setItem(
+ "tc_favourites",
+ JSON.stringify({
+ cardIds: [],
+ phrases: [
+ {
+ cardId: other.cardId,
+ cardTitle: other.cardTitle,
+ groupLabel: "Saved earlier",
+ text: other.text,
+ },
+ ],
+ }),
+ );
+ await renderPhrases();
+ fireEvent.change(screen.getByTestId("phrases-search-input"), {
+ target: { value: shared.text },
+ });
+ const row = screen
+ .getAllByRole("button", { name: `Copy: ${shared.text}` })[0]
+ .closest("li")!;
+ const fav = within(row).getByTestId("phrase-fav-btn");
+ expect(fav).toHaveAttribute("aria-pressed", "true");
+ expect(row).toHaveTextContent(/also on \d+ more card/);
+
+ // Unsaving removes the copy saved from the other card
+ fireEvent.click(fav);
+ expect(fav).toHaveAttribute("aria-pressed", "false");
+ const stored = JSON.parse(localStorage.getItem("tc_favourites")!);
+ expect(stored.phrases).toHaveLength(0);
+ });
+});
diff --git a/artifacts/tc-reference/src/test/quick-mode-windowing.test.tsx b/artifacts/tc-reference/src/test/quick-mode-windowing.test.tsx
index 59df7df..318e150 100644
--- a/artifacts/tc-reference/src/test/quick-mode-windowing.test.tsx
+++ b/artifacts/tc-reference/src/test/quick-mode-windowing.test.tsx
@@ -163,3 +163,52 @@ describe("Quick Lookup de-duplication and card scope", () => {
window.history.replaceState(null, "", "/");
});
});
+
+describe("Quick Lookup lists a line once across situations", () => {
+ it("shows a line from two situations once in the all-cards view", async () => {
+ vi.resetModules();
+ const loader = await import("../lib/card-loader");
+ vi.mocked(loader.loadAllCards).mockResolvedValue({
+ TC001: {
+ phraseBank: [
+ {
+ id: "openers",
+ label: "Openers",
+ tag: "Quick",
+ phrases: ["Say more?"],
+ },
+ ],
+ } as CardData,
+ TC002: {
+ phraseBank: [
+ {
+ id: "repair",
+ label: "Repair",
+ tag: "Repair",
+ phrases: ["say more", "Only in two"],
+ },
+ ],
+ } as CardData,
+ });
+ const { QuickModeOverlay: Overlay } =
+ await import("../components/quick-mode-overlay");
+ const quick = await import("../lib/quick-mode");
+ const favs = await import("../lib/favourites-context");
+ function Open() {
+ const { setIsOpen } = quick.useQuickMode();
+ return ;
+ }
+ window.history.replaceState(null, "", "/");
+ render(
+
+
+
+
+
+ ,
+ );
+ fireEvent.click(screen.getByRole("button", { name: "Open Quick" }));
+ await screen.findByText("Only in two");
+ expect(screen.getAllByText(/^say more/i)).toHaveLength(1);
+ });
+});
diff --git a/artifacts/tc-reference/src/test/search-index.test.ts b/artifacts/tc-reference/src/test/search-index.test.ts
index 48970b7..5e487b5 100644
--- a/artifacts/tc-reference/src/test/search-index.test.ts
+++ b/artifacts/tc-reference/src/test/search-index.test.ts
@@ -274,12 +274,20 @@ describe("searchAll", () => {
});
expect(results.techniques).toHaveLength(3);
expect(results.totals.techniques).toBeGreaterThanOrEqual(15);
- const plain = await searchAll("plain line", {
+ // "general" is every phrase group's tag
+ const general = await searchAll("general", {
...NO_BOOSTS,
limits: { phrases: 2 },
});
- expect(plain.phrases).toHaveLength(2);
- expect(plain.totals.phrases).toBeGreaterThan(2);
+ expect(general.phrases).toHaveLength(2);
+ expect(general.totals.phrases).toBeGreaterThan(2);
+ });
+
+ it("lists a line shared by several cards once", async () => {
+ // Twenty fixture cards share "Plain line."
+ const plain = await searchAll("plain line", NO_BOOSTS);
+ expect(plain.phrases.map((p) => p.text)).toEqual(["Plain line."]);
+ expect(plain.totals.phrases).toBe(1);
});
it("gives the same technique results as searchCards", async () => {
diff --git a/artifacts/tc-reference/src/test/search-real-corpus.test.ts b/artifacts/tc-reference/src/test/search-real-corpus.test.ts
index 9b8bac6..6c680c4 100644
--- a/artifacts/tc-reference/src/test/search-real-corpus.test.ts
+++ b/artifacts/tc-reference/src/test/search-real-corpus.test.ts
@@ -33,6 +33,37 @@ beforeAll(async () => {
});
describe("smart search on the real catalogue", () => {
+ it("lists a line shared by several cards once", async () => {
+ const results = await searchAll("That sounds like it mattered", {
+ ...NO_BOOSTS,
+ limits: { phrases: 1000 },
+ });
+ const keys = results.phrases.map((p) =>
+ p.text
+ .toLowerCase()
+ .replace(/[^a-z0-9]+/g, " ")
+ .trim(),
+ );
+ expect(keys).toContain("that sounds like it mattered");
+ expect(new Set(keys).size).toBe(keys.length);
+ expect(results.totals.phrases).toBe(results.phrases.length);
+ });
+
+ it("lists the saved copy of a shared line", async () => {
+ const results = await searchAll("That sounds like it mattered", {
+ boosts: {
+ ...NO_BOOSTS.boosts,
+ savedPhrases: [
+ { cardId: "TC082", text: "That sounds like it mattered" },
+ ],
+ },
+ });
+ const hit = results.phrases.find(
+ (p) => p.text.replace(/[.!?]$/, "") === "That sounds like it mattered",
+ );
+ expect(hit?.cardId).toBe("TC082");
+ });
+
it('"sil" already shows Strategic silence', async () => {
expect((await searchCards("sil", NO_BOOSTS))[0]?.title).toBe(
"Strategic silence",
From 052814a610acd0f202018f0291f7a436d81414b9 Mon Sep 17 00:00:00 2001
From: Claude
Date: Sat, 21 Nov 2026 04:59:41 +0000
Subject: [PATCH 02/13] Refresh README features and routes
Adds Start here, Help me right now, Saved naming, Settings and the /search,
/help and /start routes, and leaves marked spots for features landing in
parallel work.
Co-Authored-By: Claude Opus 5.5
Claude-Session: https://claude.ai/code/session_01GxPPxjfPnzopEHAJKSC3rp
---
README.md | 54 +++++++++++++++++++++++++++++++++++++++---------------
1 file changed, 39 insertions(+), 15 deletions(-)
diff --git a/README.md b/README.md
index 0d46acf..51e1b46 100644
--- a/README.md
+++ b/README.md
@@ -8,16 +8,23 @@ A mobile-first reference app for 107 communication techniques. It runs entirely
- 107 technique cards (voice/presence, influence/framing, clarity/direction, connection/warmth, resilience/recovery)
- Library with category, impact and difficulty filters, sort controls and a live result count
-- Phrase Bank (4,000+ phrases, filterable by tone and full-text searchable)
+- **Start here**: a guided path through the 15 core cards, with progress kept on the device
+- **Help me right now**: pick what is happening (eight common situations) and get one move, three lines to say, what to do next and one thing to avoid, without loading a full card
+- Phrase Bank (about 4,500 lines, filterable by tone and length and searchable); a line that several cards share is listed once, under its first card
- Daily drill: pick a track (Core 15, one category, a playbook or everything) and a pace, rate each technique Not yet, Getting there or Confident, and review it again when it comes due; streak tracking and undo included
-- Playbooks: chain techniques into your own step-by-step guides
-- Favourites for cards and phrases via localStorage persistence
+- Playbooks: chain techniques into your own step-by-step guides, or start from a template
+- Saved: keep cards and phrases (a line saved from any card that lists it shows as saved everywhere)
- Quick Lookup overlay for fast in-conversation phrase recall, scoped to the open card with one tap to widen to all cards
-- Full-screen search at `/search` (the search button, or `Cmd+K` / `Ctrl+K`) across techniques, phrases and playbooks: it matches as you type, keeps the search in the address so Back returns to your results, forgives typos and word forms, and maps everyday words to card vocabulary through a hand-kept synonym list (`artifacts/tc-reference/src/lib/search-synonyms.ts`), and left/right arrow keys to step between cards
-- Light/dark theme persistence
-- Back up and restore your data: export favourites, drill progress, playbooks and settings to a JSON file from the Favourites page, and import it on any device
+- Full-screen search at `/search` (the search button, or `Cmd+K` / `Ctrl+K`) across techniques, phrases and playbooks: it matches as you type, keeps the search in the address so Back returns to your results, forgives typos and word forms, and maps everyday words to card vocabulary through a hand-kept synonym list (`artifacts/tc-reference/src/lib/search-synonyms.ts`); left/right arrow keys step between cards
+- Settings (from the Saved page): light/dark theme, larger phrase text, drill track, offline status and backup
+- Back up and restore your data: export saved items, drill progress, playbooks and settings to a JSON file, and import it on any device
- Mobile-first navigation with a bottom tab bar, 44px touch targets and safe-area (notch) support
-- Installable PWA: the app shell, global search, the Phrase Bank and Quick Lookup work offline after the first visit (a slim card text index is precached); full card pages and downloads work offline once they have been opened while online, and **Save all cards for offline** on the Favourites page saves every card (about 4 MB) in one step; downloads stay on demand
+- Installable PWA: the app shell, global search, the Phrase Bank and Quick Lookup work offline after the first visit (a slim card text index is precached); full card pages and downloads work offline once they have been opened while online, and **Save all cards for offline** in Settings saves every card (about 4 MB) in one step; downloads stay on demand
+
+
---
@@ -122,6 +129,11 @@ node --test scripts/code-reviewer.test.mjs scripts/local-process-identity.test.m
pnpm --filter @workspace/tc-reference test
```
+
+
Before installing dependencies, run agent instruction and skill packaging checks directly:
```bash
@@ -182,14 +194,26 @@ This is what Railway runs. For a quick local check, `serve` still runs
## Routes
-| Path | Screen |
-| --------------- | ---------------------------------------- |
-| `/` | Library |
+| Path | Screen |
+| --------------- | ----------------------------------------------------- |
+| `/` | Library |
+| `/start` | Start here: the core cards in order |
+| `/help` | Help me right now: pick a situation |
+| `/help/:id` | One situation's move and lines |
+| `/card/:cardId` | Full technique card (e.g. `/card/TC001`) |
+| `/phrases` | Phrase Bank |
+| `/drill` | Daily drill |
+| `/playbooks` | Your playbooks and templates |
+| `/favourites` | Saved cards and phrases (tab label "Saved"), Settings |
+| `/search` | Full-screen search (`?q=` keeps the query) |
+
+--------------- | ---------------------------------------- |
+| `/` | Library |
| `/card/:cardId` | Full technique card (e.g. `/card/TC001`) |
-| `/phrases` | Phrase browser |
-| `/drill` | Daily drill screen |
-| `/favourites` | Saved cards and phrases |
-| `/playbooks` | Your saved technique playbooks |
+| `/phrases` | Phrase browser |
+| `/drill` | Daily drill screen |
+| `/favourites` | Saved cards and phrases |
+| `/playbooks` | Your saved technique playbooks |
---
@@ -198,5 +222,5 @@ This is what Railway runs. For a quick local check, `serve` still runs
TC Reference is a fully client-side SPA with no backend:
- Core card, phrase and drill data lives in `artifacts/tc-reference/src/lib`
-- User state uses `localStorage` (favourites, drill progress, playbooks under `tc_playbooks`, theme)
+- User state uses `localStorage` (saved items under `tc_favourites`, drill progress, playbooks under `tc_playbooks`, preferences under `tc_preferences`, theme)
- No backend or credentials are required
From b7547fe7b8bdccbd799b057546b7c37910f1ea15 Mon Sep 17 00:00:00 2001
From: Claude
Date: Sat, 21 Nov 2026 05:02:08 +0000
Subject: [PATCH 03/13] Protect saved data on iPhone and tidy PWA phone details
Ask the browser to keep storage persistent, show a one-time Add to Home
Screen hint on iPhone/iPad Safari, and a calm monthly backup reminder.
Record the last backup export time, show it in Settings, add Help me
right now and Search manifest shortcuts, and pad the PDF sheet for
landscape notches.
Co-Authored-By: Claude Opus 5.5
Claude-Session: https://claude.ai/code/session_01GxPPxjfPnzopEHAJKSC3rp
---
artifacts/tc-reference/src/App.tsx | 2 +
.../src/components/backup-section.tsx | 50 +++-
.../src/components/data-safety-nudge.tsx | 193 ++++++++++++
artifacts/tc-reference/src/index.css | 22 +-
artifacts/tc-reference/src/lib/backup.ts | 22 ++
artifacts/tc-reference/src/lib/data-safety.ts | 235 +++++++++++++++
.../src/test/data-safety.test.tsx | 278 ++++++++++++++++++
artifacts/tc-reference/vite.config.ts | 22 +-
8 files changed, 808 insertions(+), 16 deletions(-)
create mode 100644 artifacts/tc-reference/src/components/data-safety-nudge.tsx
create mode 100644 artifacts/tc-reference/src/lib/data-safety.ts
create mode 100644 artifacts/tc-reference/src/test/data-safety.test.tsx
diff --git a/artifacts/tc-reference/src/App.tsx b/artifacts/tc-reference/src/App.tsx
index ae3c7bb..4dea4c9 100644
--- a/artifacts/tc-reference/src/App.tsx
+++ b/artifacts/tc-reference/src/App.tsx
@@ -21,6 +21,7 @@ import { PdfProvider } from "@/lib/pdf-context";
import { AppLayout } from "@/components/app-layout";
import { AppErrorBoundary } from "@/components/app-error-boundary";
import { UpdateToast } from "@/components/update-toast";
+import { DataSafetyNudge } from "@/components/data-safety-nudge";
import { PreferencesSync } from "@/lib/preferences";
function RouteFallback() {
@@ -89,6 +90,7 @@ function App() {
+
diff --git a/artifacts/tc-reference/src/components/backup-section.tsx b/artifacts/tc-reference/src/components/backup-section.tsx
index 65cbbf5..8fdddbb 100644
--- a/artifacts/tc-reference/src/components/backup-section.tsx
+++ b/artifacts/tc-reference/src/components/backup-section.tsx
@@ -3,11 +3,23 @@ import { Download, Upload } from "lucide-react";
import { Button } from "@/components/ui/button";
import {
BackupError,
- backupFileName,
- exportBackup,
+ downloadBackup,
importBackup,
parseBackup,
} from "@/lib/backup";
+import {
+ hasUserData,
+ isBackupReminderDue,
+ loadDataSafety,
+} from "@/lib/data-safety";
+
+function formatBackupDate(ms: number): string {
+ return new Date(ms).toLocaleDateString("en-AU", {
+ day: "numeric",
+ month: "short",
+ year: "numeric",
+ });
+}
function errorMessage(err: unknown): string {
return err instanceof BackupError
@@ -22,21 +34,18 @@ export function BackupSection() {
null,
);
const [error, setError] = useState(null);
+ // Read on mount (the sheet unmounts when closed) and after each export.
+ const [safety, setSafety] = useState(() => ({
+ state: loadDataSafety(),
+ hasData: hasUserData(),
+ }));
+ const lastBackupAt = safety.state.lastBackupAt;
+ const reminderDue = isBackupReminderDue(safety.state, safety.hasData);
const handleExport = () => {
setError(null);
- const blob = new Blob([JSON.stringify(exportBackup(), null, 2)], {
- type: "application/json",
- });
- const url = URL.createObjectURL(blob);
- const a = document.createElement("a");
- a.href = url;
- a.download = backupFileName();
- document.body.appendChild(a);
- a.click();
- a.remove();
- // Revoke on the next tick so the download has started first.
- setTimeout(() => URL.revokeObjectURL(url), 0);
+ downloadBackup();
+ setSafety({ state: loadDataSafety(), hasData: hasUserData() });
};
const handleFile = async (e: React.ChangeEvent) => {
@@ -82,6 +91,19 @@ export function BackupSection() {
device. Export a backup file to keep them safe or move them to another
device.
+
+ {lastBackupAt !== null
+ ? `Last backup on this device: ${formatBackupDate(lastBackupAt)}.`
+ : "No backup exported from this device yet."}
+ {reminderDue &&
+ (lastBackupAt !== null
+ ? " It's been a while, so a fresh one is a good idea."
+ : " Exporting one now keeps your progress safe.")}
+
);
}
diff --git a/artifacts/tc-reference/src/components/drill-track-sheet.tsx b/artifacts/tc-reference/src/components/drill-track-sheet.tsx
index 47dc3a0..38343a0 100644
--- a/artifacts/tc-reference/src/components/drill-track-sheet.tsx
+++ b/artifacts/tc-reference/src/components/drill-track-sheet.tsx
@@ -133,6 +133,8 @@ interface DrillTrackSheetProps {
dueCount: number;
/** Open on Core at three days each: the short way in for a new reader. */
suggestCore?: boolean;
+ /** Open on this library category (from a progress row). */
+ initialCategory?: string;
onApply: (track: DrillTrack, pace: DrillPace) => void;
onClose: () => void;
}
@@ -147,6 +149,7 @@ export function DrillTrackSheet({
state,
dueCount,
suggestCore = false,
+ initialCategory,
onApply,
onClose,
}: DrillTrackSheetProps) {
@@ -187,11 +190,16 @@ export function DrillTrackSheet({
return { options, savedCount };
}, [playbooks, current]);
+ const startCategory =
+ initialCategory && CATEGORY_NAMES.includes(initialCategory)
+ ? initialCategory
+ : undefined;
const [kind, setKind] = useState(
- suggestCore ? "core" : current.kind,
+ startCategory ? "category" : suggestCore ? "core" : current.kind,
);
const [category, setCategory] = useState(
- current.kind === "category" ? current.category : CATEGORY_NAMES[0],
+ startCategory ??
+ (current.kind === "category" ? current.category : CATEGORY_NAMES[0]),
);
const [playbookId, setPlaybookId] = useState(
current.kind === "playbook"
diff --git a/artifacts/tc-reference/src/lib/drill-state.ts b/artifacts/tc-reference/src/lib/drill-state.ts
index 8a927a9..41750ee 100644
--- a/artifacts/tc-reference/src/lib/drill-state.ts
+++ b/artifacts/tc-reference/src/lib/drill-state.ts
@@ -417,6 +417,9 @@ export interface CardSRS {
repetition: number;
efactor: number;
nextReviewDate: string;
+ /** The latest rating. Absent on reviews saved before it was kept; see
+ srsStatus for how those read. */
+ rating?: DrillRating;
}
export const SRS_STORAGE_KEY = "tc_srs_reviews";
@@ -424,7 +427,9 @@ export const SRS_STORAGE_KEY = "tc_srs_reviews";
/** SM-2 never lets the ease factor drop below this. */
export const MIN_EFACTOR = 1.3;
-function isValidSRSEntry(value: unknown): value is Omit {
+function isValidSRSEntry(
+ value: unknown,
+): value is Omit & { rating?: unknown } {
return (
isRecord(value) &&
isIntegerInRange(value.interval, 0, Number.MAX_SAFE_INTEGER) &&
@@ -453,6 +458,7 @@ export function sanitiseSRSMap(value: unknown): Record {
repetition: entry.repetition,
efactor: entry.efactor,
nextReviewDate: entry.nextReviewDate,
+ ...(isOneOf(entry.rating, DRILL_RATINGS) ? { rating: entry.rating } : {}),
};
}
return out;
@@ -497,12 +503,27 @@ export const RATING_QUALITY: Record = {
easy: 5,
};
+/**
+ * Days until a card first comes back after a rating of quality q: tomorrow
+ * for a miss, three days for a pass with difficulty, a week for a clean one.
+ */
+export function firstInterval(quality: number): number {
+ const q = Math.min(5, Math.max(0, Math.round(quality)));
+ if (q < 3) return 1;
+ return q >= 5 ? 7 : 3;
+}
+
/**
* One SM-2 step for a response of quality q (0-5; 3+ counts as recalled).
- * A pass advances the interval 1 -> 6 -> round(interval x efactor); a fail
- * resets repetition and schedules the card for tomorrow. The ease factor is
- * adjusted on every response and floored at MIN_EFACTOR. The next review date
- * is a local calendar date, matching getTodayISO() used for due counts.
+ * The first pass in a run sets the interval to firstInterval(q): 3 days for
+ * Getting there, 7 for Confident. Each later pass grows it by the ease
+ * factor (from before this response), never dropping below that first gap.
+ * A pass with difficulty (q = 3, Getting there) grows it by only half the
+ * ease's growth, so it always comes back sooner than a clean pass would.
+ * A fail resets repetition and schedules the card for tomorrow. The ease
+ * factor is adjusted on every response and floored at MIN_EFACTOR. The next
+ * review date is a local calendar date, matching getTodayISO() used for due
+ * counts.
*/
export function applySM2(
current: CardSRS,
@@ -516,13 +537,10 @@ export function applySM2(
let nextEfactor = current.efactor;
if (q >= 3) {
- if (nextRep === 0) {
- nextInterval = 1;
- } else if (nextRep === 1) {
- nextInterval = 6;
- } else {
- nextInterval = Math.round(nextInterval * nextEfactor);
- }
+ const base = firstInterval(q);
+ const growth = q === 3 ? 1 + (nextEfactor - 1) / 2 : nextEfactor;
+ nextInterval =
+ nextRep === 0 ? base : Math.max(base, Math.round(nextInterval * growth));
nextRep += 1;
} else {
nextRep = 0;
@@ -544,6 +562,16 @@ export function applySM2(
};
}
+/** The drill rating an older Hard / Good / Easy rating stands for. */
+const AS_DRILL_RATING: Record = {
+ "not-yet": "not-yet",
+ "getting-there": "getting-there",
+ confident: "confident",
+ hard: "not-yet",
+ good: "getting-there",
+ easy: "confident",
+};
+
export function updateSRS(cardId: string, rating: SRSRating): CardSRS {
const srsMap = loadSRSMap();
@@ -555,7 +583,10 @@ export function updateSRS(cardId: string, rating: SRSRating): CardSRS {
nextReviewDate: getTodayISO(),
};
- const updated = applySM2(current, RATING_QUALITY[rating] ?? 4);
+ const updated: CardSRS = {
+ ...applySM2(current, RATING_QUALITY[rating] ?? 4),
+ rating: AS_DRILL_RATING[rating] ?? "getting-there",
+ };
srsMap[cardId] = updated;
// Same best-effort persistence as saveDrillState.
diff --git a/artifacts/tc-reference/src/lib/drill-view.ts b/artifacts/tc-reference/src/lib/drill-view.ts
index 04376fa..d4085af 100644
--- a/artifacts/tc-reference/src/lib/drill-view.ts
+++ b/artifacts/tc-reference/src/lib/drill-view.ts
@@ -124,16 +124,35 @@ export function daysLeft(state: DrillState, pace: DrillPace = state.pace) {
return Math.max(1, cards * pace - Math.min(state.dayIndex, pace - 1));
}
-/** "Back tomorrow" / "Back in 6 days" for a review gap in days. */
+/**
+ * When a review comes back, in everyday words: "tomorrow", "in 3 days",
+ * "in a week", "in 2 weeks", then rounded to weeks, months or years.
+ */
+export function returnWords(interval: number): string {
+ const d = Math.max(1, Math.round(interval));
+ if (d === 1) return "tomorrow";
+ if (d === 7) return "in a week";
+ if (d < 14) return `in ${d} days`;
+ if (d < 56) {
+ const weeks = Math.round(d / 7);
+ return `in ${d % 7 === 0 ? "" : "about "}${weeks} weeks`;
+ }
+ if (d < 335) {
+ const months = Math.round(d / 30.4);
+ return `in about ${months} months`;
+ }
+ const years = Math.round(d / 365);
+ return years === 1 ? "in about a year" : `in about ${years} years`;
+}
+
+/** "Back tomorrow" / "Back in 3 days" / "Back in a week" for a review gap. */
export function gapLabel(interval: number): string {
- return interval <= 1 ? "Back tomorrow" : `Back in ${interval} days`;
+ return `Back ${returnWords(interval)}`;
}
-/** As a clause: "comes back tomorrow" / "comes back in 6 days". */
+/** As a clause: "comes back tomorrow" / "comes back in a week". */
export function gapClause(interval: number): string {
- return interval <= 1
- ? "comes back tomorrow"
- : `comes back in ${interval} days`;
+ return `comes back ${returnWords(interval)}`;
}
/**
@@ -222,3 +241,86 @@ export function weekStrip(
return { letter, state: daysAgo === 0 ? "today" : "done" };
});
}
+
+/** Where a technique stands: its latest rating, or not drilled yet. */
+export type TechniqueStatus = DrillRating | "not-started";
+
+export const STATUS_ORDER: readonly TechniqueStatus[] = [
+ "confident",
+ "getting-there",
+ "not-yet",
+ "not-started",
+];
+
+export const STATUS_LABELS: Record = {
+ ...RATING_LABELS,
+ "not-started": "Not started",
+};
+
+/**
+ * A technique's status from its review record. Reviews saved before the
+ * rating was kept read from the schedule: a reset run is Not yet, a high
+ * ease (only clean passes raise it) is Confident, anything else Getting
+ * there.
+ */
+export function srsStatus(entry: CardSRS | undefined): TechniqueStatus {
+ if (!entry) return "not-started";
+ if (entry.rating) return entry.rating;
+ if (entry.repetition === 0) return "not-yet";
+ return entry.efactor >= 2.5 ? "confident" : "getting-there";
+}
+
+export interface ProgressCounts {
+ total: number;
+ /** Reviews due today or earlier (also counted under their status). */
+ due: number;
+ byStatus: Record;
+}
+
+export interface CategoryProgress extends ProgressCounts {
+ category: string;
+}
+
+function emptyCounts(): ProgressCounts {
+ return {
+ total: 0,
+ due: 0,
+ byStatus: {
+ confident: 0,
+ "getting-there": 0,
+ "not-yet": 0,
+ "not-started": 0,
+ },
+ };
+}
+
+/**
+ * Every technique counted by status, overall and per library category (in
+ * library order), from the review records.
+ */
+export function drillProgress(
+ srsMap: Readonly>,
+ today: string = getTodayISO(),
+): { overall: ProgressCounts; categories: CategoryProgress[] } {
+ const overall = emptyCounts();
+ const categories: CategoryProgress[] = Object.entries(LIBRARY_CATEGORIES).map(
+ ([category, cards]) => {
+ const counts = emptyCounts();
+ const seen = new Set();
+ for (const card of cards) {
+ if (seen.has(card.id)) continue;
+ seen.add(card.id);
+ const entry = srsMap[card.id];
+ const status = srsStatus(entry);
+ const due = entry !== undefined && entry.nextReviewDate <= today;
+ for (const c of [counts, overall]) {
+ c.total += 1;
+ c.byStatus[status] += 1;
+ if (due) c.due += 1;
+ }
+ }
+ return { category, ...counts };
+ },
+ );
+ return { overall, categories };
+}
diff --git a/artifacts/tc-reference/src/pages/drill.tsx b/artifacts/tc-reference/src/pages/drill.tsx
index 239dbd3..b606bd3 100644
--- a/artifacts/tc-reference/src/pages/drill.tsx
+++ b/artifacts/tc-reference/src/pages/drill.tsx
@@ -6,6 +6,7 @@ import { Button } from "@/components/ui/button";
import { Chip } from "@/components/ui/chip";
import { DockBar } from "@/components/ui/dock-bar";
import { DrillDone } from "@/components/drill-done";
+import { DrillProgress } from "@/components/drill-progress";
import { DrillRating } from "@/components/drill-rating";
import { DrillReviewSheet } from "@/components/drill-review-sheet";
import { DrillReviews } from "@/components/drill-reviews";
@@ -52,10 +53,12 @@ import {
CORE_TRACK_NAME,
DRILL_CARD_META,
drillCardTitle,
+ drillProgress,
durationLabel,
gapClause,
previewGaps,
RATING_LABELS,
+ returnWords,
sameTrack,
trackName,
weekStrip,
@@ -108,6 +111,8 @@ export default function Drill() {
const [trackSheet, setTrackSheet] = useState<"closed" | "open" | "suggest">(
"closed",
);
+ // The category a progress row asked the track sheet to open on.
+ const [trackCategory, setTrackCategory] = useState();
const [reviewId, setReviewId] = useState(null);
const [announcement, setAnnouncement] = useState("");
@@ -245,6 +250,7 @@ export default function Drill() {
setState(next);
}
setTrackSheet("closed");
+ setTrackCategory(undefined);
};
const rateReview = (cardId: string, rating: Rating) => {
@@ -256,6 +262,18 @@ export default function Drill() {
);
};
+ const progress = useMemo(() => drillProgress(srsMap), [srsMap]);
+ const progressSection = (
+ {
+ setTrackCategory(category);
+ setTrackSheet("open");
+ }}
+ />
+ );
+
const retryLoad = () => {
setLoadFailed(false);
setLoadAttempt((n) => n + 1);
@@ -301,8 +319,12 @@ export default function Drill() {
state={state}
dueCount={due.length}
suggestCore={trackSheet === "suggest"}
+ initialCategory={trackCategory}
onApply={applyTrack}
- onClose={() => setTrackSheet("closed")}
+ onClose={() => {
+ setTrackSheet("closed");
+ setTrackCategory(undefined);
+ }}
/>
)}
{reviewId && (
@@ -337,6 +359,9 @@ export default function Drill() {
state.cardIndex === 0 &&
state.prevCardIndex === cardCount - 1;
const prevTitle = prevId ? drillCardTitle(prevId) : "";
+ // The finished technique's review: its rating and when it comes back.
+ const prevReview = prevId ? srsMap[prevId] : undefined;
+ const prevRating = undo?.rating ?? prevReview?.rating;
let milestone: ReactNode;
if (finishedTrack) {
@@ -355,7 +380,11 @@ export default function Drill() {
>
);
} else if (finishedCard && state.pace > 1) {
- milestone = `You have finished ${prevTitle}. It will come back for review. Next up: ${nextTitle}.`;
+ milestone = `You have finished ${prevTitle}. It ${
+ prevReview
+ ? `comes back for review ${returnWords(prevReview.interval)}`
+ : "will come back for review"
+ }. Next up: ${nextTitle}.`;
}
return (
@@ -370,7 +399,13 @@ export default function Drill() {
}
detail={
prevId
- ? `${prevTitle}${undo ? ` · rated ${RATING_LABELS[undo.rating]}` : ""}`
+ ? [
+ prevTitle,
+ prevRating && `rated ${RATING_LABELS[prevRating]}`,
+ prevReview && `back ${returnWords(prevReview.interval)}`,
+ ]
+ .filter(Boolean)
+ .join(" · ")
: undefined
}
onUndo={undo ? handleUndo : undefined}
@@ -388,6 +423,7 @@ export default function Drill() {
>
+ {progressSection}
+ {progressSection}
+
{
expect(ratingButton(/^Not yet/)).toHaveAccessibleName(
"Not yet: back tomorrow",
);
+ // 6 x (1 + 1.5 / 2) = 10.5 -> 11; 6 x 2.5 = 15
+ expect(ratingButton(/^Getting there/)).toHaveAccessibleName(
+ "Getting there: back in 11 days",
+ );
expect(ratingButton(/^Confident/)).toHaveAccessibleName(
- "Confident: back in 15 days",
+ "Confident: back in about 2 weeks",
);
});
- it("says once when a first rating comes back, as every choice is the same", async () => {
+ it("says a first rating comes back tomorrow, in 3 days or in a week", async () => {
await renderDrill();
- expect(screen.getByTestId("drill-rating-note")).toHaveTextContent(
- "Back tomorrow either way. Your rating sets the gaps after that.",
+ expect(ratingButton(/^Not yet/)).toHaveAccessibleName(
+ "Not yet: back tomorrow",
+ );
+ expect(ratingButton(/^Getting there/)).toHaveAccessibleName(
+ "Getting there: back in 3 days",
+ );
+ expect(ratingButton(/^Confident/)).toHaveAccessibleName(
+ "Confident: back in a week",
);
- expect(ratingButton(/^Not yet/)).toHaveAccessibleName("Not yet");
});
it.each([
- [/^Not yet/, "Not yet"],
- [/^Getting there/, "Getting there"],
- [/^Confident/, "Confident"],
+ [/^Not yet/, "Not yet", "2026-03-11", "back tomorrow"],
+ [/^Getting there/, "Getting there", "2026-03-13", "back in 3 days"],
+ [/^Confident/, "Confident", "2026-03-17", "back in a week"],
])(
"rating %s finishes the drill and schedules a review",
- async (name, label) => {
+ async (name, label, date, back) => {
await renderDrill();
await rateAndFinish(name);
const done = screen.getByTestId("drill-done");
expect(done).toHaveTextContent("Day 1 done");
- expect(done).toHaveTextContent(`rated ${label}`);
+ expect(done).toHaveTextContent(`rated ${label} · ${back}`);
expect(screen.getByText("1 day streak")).toBeInTheDocument();
expect(loadDrillState()).toMatchObject({
streak: 1,
dayIndex: 1,
lastCompletionDate: "2026-03-10",
});
- expect(loadSRSMap()[FIRST].nextReviewDate).toBe("2026-03-11");
+ expect(loadSRSMap()[FIRST].nextReviewDate).toBe(date);
expect(screen.queryByTestId("drill-rating")).toBeNull();
},
);
@@ -362,9 +371,10 @@ describe("Drill page: reviews due", () => {
);
expect(screen.queryByTestId("drill-review-sheet")).toBeNull();
expect(screen.queryByTestId("drill-reviews")).toBeNull();
- expect(loadSRSMap().TC003.nextReviewDate).toBe("2026-03-16");
+ // Seeded as an old 1-day review: Getting there still waits 3 days
+ expect(loadSRSMap().TC003.nextReviewDate).toBe("2026-03-13");
expect(screen.getByTestId("drill-announce")).toHaveTextContent(
- `${drillCardTitle("TC003")} comes back in 6 days.`,
+ `${drillCardTitle("TC003")} comes back in 3 days.`,
);
expect(loadDrillState().lastCompletionDate).toBeNull();
});
@@ -444,7 +454,11 @@ describe("Drill page: track and pace", () => {
fireEvent.click(screen.getByTestId("drill-change-track"));
fireEvent.click(screen.getByTestId("drill-track-category"));
expect(screen.getByTestId("drill-track-restart-note")).toBeInTheDocument();
- fireEvent.click(screen.getByRole("button", { name: /^Resilience/ }));
+ fireEvent.click(
+ within(screen.getByRole("dialog")).getByRole("button", {
+ name: /^Resilience/,
+ }),
+ );
await act(async () => {
fireEvent.click(screen.getByTestId("drill-track-apply"));
});
@@ -502,3 +516,41 @@ describe("Drill page: track and pace", () => {
expect(loadDrillState()).toEqual(before);
});
});
+
+describe("Drill page: progress", () => {
+ it("counts techniques by status, with words as well as bars", async () => {
+ seedReview("TC003", "2026-03-05");
+ await renderDrill();
+ const progress = screen.getByTestId("drill-progress");
+ expect(
+ within(progress).getByRole("heading", { name: "Your progress" }),
+ ).toBeInTheDocument();
+ expect(progress).toHaveTextContent("1 of 107 techniques started");
+ const overall = within(progress).getByTestId("drill-progress-overall");
+ // An old review without a rating, at ease 2.5, reads as Confident
+ expect(overall).toHaveTextContent("Confident1");
+ expect(overall).toHaveTextContent("Due for review1");
+ });
+
+ it("updates after a rating", async () => {
+ await renderDrill();
+ await rateAndFinish(/^Getting there/);
+ const progress = screen.getByTestId("drill-progress");
+ expect(progress).toHaveTextContent("Getting there1");
+ });
+
+ it("opens the track picker on a category from its row", async () => {
+ await renderDrill();
+ const row = screen.getByTestId("drill-progress-Resilience / Recovery");
+ fireEvent.click(within(row).getByRole("button"));
+ const dialog = await screen.findByRole("dialog");
+ expect(within(dialog).getByTestId("drill-track-category")).toBeChecked();
+ await act(async () => {
+ fireEvent.click(within(dialog).getByTestId("drill-track-apply"));
+ });
+ expect(loadDrillState().track).toEqual({
+ kind: "category",
+ category: "Resilience / Recovery",
+ });
+ });
+});
diff --git a/artifacts/tc-reference/src/test/drill-state.test.ts b/artifacts/tc-reference/src/test/drill-state.test.ts
index bffb617..4ad59b2 100644
--- a/artifacts/tc-reference/src/test/drill-state.test.ts
+++ b/artifacts/tc-reference/src/test/drill-state.test.ts
@@ -14,6 +14,8 @@ import {
loadSRSMap,
MIN_EFACTOR,
saveDrillState,
+ firstInterval,
+ RATING_QUALITY,
updateSRS,
type CardSRS,
type DrillState,
@@ -72,9 +74,9 @@ describe("applySM2 (SM-2 update)", () => {
[0, 0, 1, 1.7],
[1, 0, 1, 1.96],
[2, 0, 1, 2.18],
- [3, 1, 1, 2.36],
- [4, 1, 1, 2.5],
- [5, 1, 1, 2.6],
+ [3, 1, 3, 2.36],
+ [4, 1, 3, 2.5],
+ [5, 1, 7, 2.6],
])(
"quality %i from a fresh card -> repetition %i, interval %i, efactor %f",
(q, repetition, interval, efactor) => {
@@ -86,26 +88,54 @@ describe("applySM2 (SM-2 update)", () => {
},
);
- it("progresses the interval 1, 6, then round(interval x efactor)", () => {
+ it("first gaps are 1, 3 and 7 days for Not yet, Getting there, Confident", () => {
+ expect(firstInterval(RATING_QUALITY["not-yet"])).toBe(1);
+ expect(firstInterval(RATING_QUALITY["getting-there"])).toBe(3);
+ expect(firstInterval(RATING_QUALITY.confident)).toBe(7);
+ });
+
+ it("grows a clean pass by the ease from before the response", () => {
let card = fresh();
const intervals: number[] = [];
- for (let i = 0; i < 5; i++) {
- card = applySM2(card, 4); // quality 4 keeps efactor at 2.5
+ for (let i = 0; i < 4; i++) {
+ card = applySM2(card, 5);
intervals.push(card.interval);
}
- // 6 * 2.5 = 15; 15 * 2.5 = 37.5 -> 38; 38 * 2.5 = 95
- expect(intervals).toEqual([1, 6, 15, 38, 95]);
- expect(card.repetition).toBe(5);
- expect(card.efactor).toBeCloseTo(2.5, 10);
+ // 7; 7 x 2.6 = 18.2 -> 18; 18 x 2.7 = 48.6 -> 49; 49 x 2.8 = 137.2 -> 137
+ expect(intervals).toEqual([7, 18, 49, 137]);
+ expect(card.repetition).toBe(4);
+ expect(card.efactor).toBeCloseTo(2.9, 10);
});
- it("uses the efactor from before the current response when scaling", () => {
+ it("grows a pass with difficulty by half the ease's growth", () => {
let card = fresh();
- card = applySM2(card, 5); // i=1, ef 2.6
- card = applySM2(card, 5); // i=6, ef 2.7
- card = applySM2(card, 5); // i=round(6 * 2.7)=16, ef 2.8
- expect(card.interval).toBe(16);
- expect(card.efactor).toBeCloseTo(2.8, 10);
+ const intervals: number[] = [];
+ for (let i = 0; i < 4; i++) {
+ card = applySM2(card, 3);
+ intervals.push(card.interval);
+ }
+ // 3; 3 x (1 + 1.36/2) = 5.04 -> 5; 5 x 1.61 = 8.05 -> 8; 8 x 1.54 -> 12
+ expect(intervals).toEqual([3, 5, 8, 12]);
+ });
+
+ it("never brings a pass back sooner than its first gap", () => {
+ // A review saved by the old 1-day ladder still gets at least 3 / 7 days
+ const old = fresh({ repetition: 1, interval: 1, efactor: 1.3 });
+ expect(applySM2(old, 3).interval).toBe(3);
+ expect(applySM2(old, 5).interval).toBe(7);
+ });
+
+ it("Getting there always comes back sooner than Confident from the same card", () => {
+ for (const from of [
+ fresh(),
+ fresh({ repetition: 1, interval: 7, efactor: 2.6 }),
+ fresh({ repetition: 3, interval: 49, efactor: 2.8 }),
+ fresh({ repetition: 2, interval: 5, efactor: 1.3 }),
+ ]) {
+ expect(applySM2(from, 3).interval).toBeLessThan(
+ applySM2(from, 5).interval,
+ );
+ }
});
it("resets repetition and interval on a failed recall (quality < 3)", () => {
@@ -114,8 +144,9 @@ describe("applySM2 (SM-2 update)", () => {
expect(next.repetition).toBe(0);
expect(next.interval).toBe(1);
expect(next.efactor).toBeCloseTo(2.18, 10);
- // The next pass restarts the 1, 6, ... ladder
- expect(applySM2(next, 4).interval).toBe(1);
+ // The next pass restarts from the first gaps
+ expect(applySM2(next, 3).interval).toBe(3);
+ expect(applySM2(next, 5).interval).toBe(7);
});
it("floors the efactor at 1.3", () => {
@@ -142,14 +173,14 @@ describe("applySM2 (SM-2 update)", () => {
// Just after local midnight and just before the next one: the review date
// must follow the local day, not the UTC day.
vi.setSystemTime(new Date(2026, 2, 10, 0, 30));
- expect(applySM2(fresh(), 4).nextReviewDate).toBe("2026-03-11");
+ expect(applySM2(fresh(), 2).nextReviewDate).toBe("2026-03-11");
vi.setSystemTime(new Date(2026, 2, 10, 23, 30));
- expect(applySM2(fresh(), 4).nextReviewDate).toBe("2026-03-11");
+ expect(applySM2(fresh(), 2).nextReviewDate).toBe("2026-03-11");
// Month and year boundaries
- vi.setSystemTime(new Date(2026, 11, 31, 9, 0));
- expect(applySM2(fresh({ repetition: 1, interval: 1 }), 4)).toMatchObject({
- interval: 6,
- nextReviewDate: "2027-01-06",
+ vi.setSystemTime(new Date(2026, 11, 29, 9, 0));
+ expect(applySM2(fresh(), 5)).toMatchObject({
+ interval: 7,
+ nextReviewDate: "2027-01-05",
});
});
});
@@ -160,22 +191,39 @@ describe("updateSRS", () => {
expect(easy).toMatchObject({
cardId: "TC001",
repetition: 1,
- interval: 1,
- nextReviewDate: "2026-03-11",
+ interval: 7,
+ nextReviewDate: "2026-03-17",
+ rating: "confident",
});
expect(easy.efactor).toBeCloseTo(2.6, 10);
const good = updateSRS("TC001", "good");
- expect(good).toMatchObject({ repetition: 2, interval: 6 });
- expect(good.nextReviewDate).toBe("2026-03-16");
+ // round(7 x 2.6) = 18
+ expect(good).toMatchObject({
+ repetition: 2,
+ interval: 18,
+ rating: "getting-there",
+ });
+ expect(good.nextReviewDate).toBe("2026-03-28");
const hard = updateSRS("TC001", "hard");
- expect(hard).toMatchObject({ repetition: 0, interval: 1 });
+ expect(hard).toMatchObject({
+ repetition: 0,
+ interval: 1,
+ rating: "not-yet",
+ });
expect(hard.efactor).toBeCloseTo(2.28, 10);
expect(storedSRS()).toEqual({ TC001: hard });
});
+ it("keeps the latest drill rating with the review", () => {
+ expect(updateSRS("TC001", "getting-there").rating).toBe("getting-there");
+ expect(loadSRSMap().TC001.rating).toBe("getting-there");
+ expect(updateSRS("TC001", "confident").rating).toBe("confident");
+ expect(loadSRSMap().TC001.rating).toBe("confident");
+ });
+
it("keeps other cards' entries untouched", () => {
const other = fresh({
cardId: "TC002",
@@ -197,7 +245,7 @@ describe("updateSRS", () => {
])("starts fresh when the stored map is %s", (_label, raw) => {
localStorage.setItem(SRS_KEY, raw);
const next = updateSRS("TC001", "good");
- expect(next).toMatchObject({ repetition: 1, interval: 1, efactor: 2.5 });
+ expect(next).toMatchObject({ repetition: 1, interval: 3, efactor: 2.5 });
expect(Object.keys(storedSRS())).toEqual(["TC001"]);
});
@@ -209,7 +257,7 @@ describe("updateSRS", () => {
}),
);
const next = updateSRS("TC001", "good");
- expect(next.interval).toBe(1);
+ expect(next.interval).toBe(3);
expect(Number.isNaN(next.efactor)).toBe(false);
expect(next.nextReviewDate).toMatch(/^\d{4}-\d{2}-\d{2}$/);
});
@@ -218,7 +266,7 @@ describe("updateSRS", () => {
vi.spyOn(Storage.prototype, "setItem").mockImplementation(() => {
throw new Error("QuotaExceededError");
});
- expect(updateSRS("TC001", "good").interval).toBe(1);
+ expect(updateSRS("TC001", "not-yet").interval).toBe(1);
});
});
@@ -275,6 +323,16 @@ describe("getDueCardsCount / loadSRSMap", () => {
expect(Object.keys(loadSRSMap())).toEqual(["TC001"]);
});
+ it("drops an unknown rating but keeps the review", () => {
+ localStorage.setItem(
+ SRS_KEY,
+ JSON.stringify({ TC001: { ...entry("2026-03-01"), rating: "great" } }),
+ );
+ expect(loadSRSMap()).toEqual({
+ TC001: { cardId: "TC001", ...entry("2026-03-01") },
+ });
+ });
+
it("drops malformed entries and keeps valid ones", () => {
localStorage.setItem(
SRS_KEY,
@@ -297,10 +355,11 @@ describe("getDueCardsCount / loadSRSMap", () => {
});
});
- it("round-trips valid data unchanged", () => {
+ it("round-trips valid data unchanged, with or without a rating", () => {
const map = {
TC001: fresh({ repetition: 3, interval: 15, efactor: 2.36 }),
TC050: fresh({ cardId: "TC050", efactor: 1.3 }),
+ TC002: fresh({ cardId: "TC002", rating: "getting-there" }),
};
localStorage.setItem(SRS_KEY, JSON.stringify(map));
expect(loadSRSMap()).toEqual(map);
diff --git a/artifacts/tc-reference/src/test/drill-tracks.test.ts b/artifacts/tc-reference/src/test/drill-tracks.test.ts
index e273cde..89e875d 100644
--- a/artifacts/tc-reference/src/test/drill-tracks.test.ts
+++ b/artifacts/tc-reference/src/test/drill-tracks.test.ts
@@ -393,9 +393,12 @@ describe("ratings feed SM-2", () => {
it("persists the review so it shows as due when its date comes", () => {
updateSRS("TC004", "getting-there");
updateSRS("TC006", "confident");
- expect(loadSRSMap().TC004.nextReviewDate).toBe("2026-03-11");
+ expect(loadSRSMap().TC004.nextReviewDate).toBe("2026-03-13");
+ expect(loadSRSMap().TC006.nextReviewDate).toBe("2026-03-17");
expect(getDueCardsCount()).toBe(0);
- vi.setSystemTime(new Date(2026, 2, 11, 12));
+ vi.setSystemTime(new Date(2026, 2, 13, 12));
+ expect(getDueCardIds()).toEqual(["TC004"]);
+ vi.setSystemTime(new Date(2026, 2, 17, 12));
expect(getDueCardIds()).toEqual(["TC004", "TC006"]);
});
diff --git a/artifacts/tc-reference/src/test/drill-view.test.ts b/artifacts/tc-reference/src/test/drill-view.test.ts
index 8aae281..3715387 100644
--- a/artifacts/tc-reference/src/test/drill-view.test.ts
+++ b/artifacts/tc-reference/src/test/drill-view.test.ts
@@ -1,4 +1,5 @@
import { describe, expect, it } from "vitest";
+import { LIBRARY_CATEGORIES } from "../lib/data";
import {
applySM2,
RATING_QUALITY,
@@ -10,13 +11,16 @@ import {
CORE_TRACK_NAME,
daysBetween,
daysLeft,
+ drillProgress,
dueLabel,
durationLabel,
gapClause,
gapLabel,
+ returnWords,
leftLabel,
previewGaps,
sameTrack,
+ srsStatus,
takesLabel,
trackName,
weekStrip,
@@ -102,11 +106,19 @@ describe("how long a track takes", () => {
});
describe("review gaps", () => {
- it("words a gap of one day as tomorrow", () => {
+ it("words a gap in everyday terms", () => {
expect(gapLabel(1)).toBe("Back tomorrow");
- expect(gapLabel(6)).toBe("Back in 6 days");
+ expect(gapLabel(3)).toBe("Back in 3 days");
+ expect(gapLabel(7)).toBe("Back in a week");
+ expect(gapLabel(13)).toBe("Back in 13 days");
+ expect(gapLabel(14)).toBe("Back in 2 weeks");
+ expect(gapLabel(18)).toBe("Back in about 3 weeks");
+ expect(gapLabel(49)).toBe("Back in 7 weeks");
+ expect(gapLabel(90)).toBe("Back in about 3 months");
+ expect(gapLabel(400)).toBe("Back in about a year");
expect(gapClause(1)).toBe("comes back tomorrow");
- expect(gapClause(16)).toBe("comes back in 16 days");
+ expect(gapClause(7)).toBe("comes back in a week");
+ expect(returnWords(3)).toBe("in 3 days");
});
it("previews exactly the gap the real save would set", () => {
@@ -127,11 +139,11 @@ describe("review gaps", () => {
expect(gaps.confident).toBeGreaterThan(1);
});
- it("previews a first rating as back tomorrow, whatever the rating", () => {
+ it("previews a first rating as 1, 3 and 7 days", () => {
expect(previewGaps("TC001", undefined)).toEqual({
"not-yet": 1,
- "getting-there": 1,
- confident: 1,
+ "getting-there": 3,
+ confident: 7,
});
});
@@ -220,3 +232,75 @@ describe("this week's strip", () => {
]);
});
});
+
+describe("progress", () => {
+ const review = (patch: Partial & { cardId: string }): CardSRS => ({
+ interval: 3,
+ repetition: 1,
+ efactor: 2.36,
+ nextReviewDate: "2026-03-20",
+ ...patch,
+ });
+
+ it("reads a technique's status from its latest rating", () => {
+ expect(srsStatus(undefined)).toBe("not-started");
+ expect(srsStatus(review({ cardId: "TC001", rating: "confident" }))).toBe(
+ "confident",
+ );
+ expect(srsStatus(review({ cardId: "TC001", rating: "not-yet" }))).toBe(
+ "not-yet",
+ );
+ });
+
+ it("reads reviews saved before ratings were kept from their schedule", () => {
+ expect(srsStatus(review({ cardId: "TC001", repetition: 0 }))).toBe(
+ "not-yet",
+ );
+ expect(srsStatus(review({ cardId: "TC001", efactor: 2.6 }))).toBe(
+ "confident",
+ );
+ expect(srsStatus(review({ cardId: "TC001", efactor: 2.36 }))).toBe(
+ "getting-there",
+ );
+ });
+
+ it("counts every technique overall and per category", () => {
+ const [firstCategory, cards] = Object.entries(LIBRARY_CATEGORIES)[0];
+ const [a, b, c] = cards.map((card) => card.id);
+ const map = {
+ [a]: review({ cardId: a, rating: "confident" }),
+ [b]: review({
+ cardId: b,
+ rating: "getting-there",
+ nextReviewDate: "2026-03-09",
+ }),
+ [c]: review({
+ cardId: c,
+ rating: "not-yet",
+ nextReviewDate: "2026-03-10",
+ }),
+ };
+ const { overall, categories } = drillProgress(map, "2026-03-10");
+ const total = Object.values(LIBRARY_CATEGORIES).flat().length;
+ expect(overall).toEqual({
+ total,
+ due: 2,
+ byStatus: {
+ confident: 1,
+ "getting-there": 1,
+ "not-yet": 1,
+ "not-started": total - 3,
+ },
+ });
+ expect(categories.map((x) => x.category)).toEqual(
+ Object.keys(LIBRARY_CATEGORIES),
+ );
+ expect(categories[0]).toMatchObject({
+ category: firstCategory,
+ total: cards.length,
+ due: 2,
+ byStatus: { confident: 1, "not-started": cards.length - 3 },
+ });
+ expect(categories[1].byStatus["not-started"]).toBe(categories[1].total);
+ });
+});
From f1267e09eb37bfd22aeed0caa25c0062f936b706 Mon Sep 17 00:00:00 2001
From: Claude
Date: Sat, 21 Nov 2026 05:04:24 +0000
Subject: [PATCH 05/13] Give dead ends a way forward and tidy card navigation
on phones
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- Add a shared EmptyState (components/ui) and use it for the 404 page,
unknown and coming-soon cards, the Help "situation not found" page
and Saved's empty list.
- A card that fails to load now explains why (offline or not) and offers
Try again and Back to Library instead of a bare sentence.
- 404 page names itself in the header, drops the "404:" prefix and offers
search and Help me right now alongside the Library.
- Use it now ends with up to three "Pairs well with" techniques before
previous/next, so related cards are reachable without switching tabs.
- Library rows spell out "High impact" and "Easy to medium", so difficulty
and impact no longer read as "Medium · Medium".
Co-Authored-By: Claude Opus 5.5
Claude-Session: https://claude.ai/code/session_01GxPPxjfPnzopEHAJKSC3rp
---
.../src/components/app-header.tsx | 3 +-
.../components/card-detail/card-header.tsx | 14 +-
.../components/card-detail/card-status.tsx | 164 +++++++++--------
.../card-detail/related-section.tsx | 15 +-
.../src/components/library/card-row.tsx | 18 +-
.../src/components/ui/empty-state.tsx | 90 ++++++++++
.../tc-reference/src/lib/design-tokens.ts | 8 +
.../tc-reference/src/pages/card-detail.tsx | 24 ++-
.../tc-reference/src/pages/favourites.tsx | 53 ++----
artifacts/tc-reference/src/pages/help.tsx | 21 ++-
.../tc-reference/src/pages/not-found.tsx | 81 ++++-----
.../src/test/app-routing-history.test.tsx | 2 +-
.../src/test/design-polish.test.tsx | 168 ++++++++++++++++++
13 files changed, 476 insertions(+), 185 deletions(-)
create mode 100644 artifacts/tc-reference/src/components/ui/empty-state.tsx
create mode 100644 artifacts/tc-reference/src/test/design-polish.test.tsx
diff --git a/artifacts/tc-reference/src/components/app-header.tsx b/artifacts/tc-reference/src/components/app-header.tsx
index ed1dfb2..c209f30 100644
--- a/artifacts/tc-reference/src/components/app-header.tsx
+++ b/artifacts/tc-reference/src/components/app-header.tsx
@@ -42,6 +42,7 @@ const PAGE_TITLES: Record = {
"/favourites": "Saved",
"/playbooks": "Playbooks",
"/start": "Start here",
+ "/search": "Search",
};
// Header actions share one quiet style. "brand" tints the icon amber for the
@@ -154,7 +155,7 @@ export function AppHeader() {
const isLibraryRoute = location === "/";
const pageTitle =
- PAGE_TITLES[location.replace(/^\/help\/.*/, "/help")] ?? "Library";
+ PAGE_TITLES[location.replace(/^\/help\/.*/, "/help")] ?? "Page not found";
const searchButton = (testId: string) => (
0
- ? `${first} to ${rest.join(" to ").toLowerCase()}`
- : first;
-}
-
function Tag({
children,
color,
diff --git a/artifacts/tc-reference/src/components/card-detail/card-status.tsx b/artifacts/tc-reference/src/components/card-detail/card-status.tsx
index 51fc447..d3dbb75 100644
--- a/artifacts/tc-reference/src/components/card-detail/card-status.tsx
+++ b/artifacts/tc-reference/src/components/card-detail/card-status.tsx
@@ -1,4 +1,10 @@
-import { ChevronLeft } from "lucide-react";
+import { Link } from "wouter";
+import { Clock, CloudOff, SearchX } from "lucide-react";
+import { Button, buttonClass } from "@/components/ui/button";
+import { EmptyState } from "@/components/ui/empty-state";
+import { SEARCH_ENTRY_STATE, searchHref } from "@/components/search/search-nav";
+
+const WRAP = "w-full max-w-2xl mx-auto min-h-[60vh] flex items-center px-4";
// ── Unknown card ID — not in the library at all ──
export function CardNotFound({
@@ -9,45 +15,36 @@ export function CardNotFound({
setLocation: (to: string) => void;
}) {
return (
-
-
-
- ?
-
-
-
- Card not found
-
-
+
+
+ Search techniques
+
+ setLocation("/")}>
+ Back to Library
+
+ >
+ }
>
- No technique card with ID{" "}
- {cardId || "unknown"}{" "}
- exists in the library.
-
- setLocation("/")}
- className="flex items-center gap-2 text-[14px] font-semibold px-5 rounded-full transition-all active:scale-95 min-h-11"
- style={{
- background: "color-mix(in srgb, var(--brand) 12%, transparent)",
- border: "1px solid color-mix(in srgb, var(--brand) 22%, transparent)",
- color: "var(--brand-text)",
- }}
- >
-
- Back to Library
-
+ There's no technique card{" "}
+
+ {cardId || "with that ID"}
+
+ . Search for the one you meant, or browse the Library.
+
+ setLocation("/")}>
+ Back to Library
+
+ }
>
- Full content for this card is being prepared. Browse the library to find
- a fully loaded card.
-
- setLocation("/")}
- className="flex items-center gap-2 text-[14px] font-semibold px-5 rounded-full transition-all active:scale-95 min-h-11"
- style={{
- background: "color-mix(in srgb, var(--brand) 12%, transparent)",
- border: "1px solid color-mix(in srgb, var(--brand) 22%, transparent)",
- color: "var(--brand-text)",
- }}
- >
-
- Back to Library
-
+ Full content for {cardId} is still being written. Browse the Library for
+ cards that are ready to use.
+
);
}
+
+// ── A known card whose content could not be fetched ──
+export function CardLoadFailed({
+ onRetry,
+ setLocation,
+}: {
+ onRetry: () => void;
+ setLocation: (to: string) => void;
+}) {
+ const offline =
+ typeof navigator !== "undefined" && navigator.onLine === false;
+ return (
+
+
+ Try again
+
+ setLocation("/")}>
+ Back to Library
+
+ >
+ }
+ >
+ {offline
+ ? "You're offline and this card isn't saved on this device yet. Reconnect, or turn on Offline cards in Settings next time you're online."
+ : "Something went wrong fetching it. Check your connection and try again."}
+
+ );
+}
diff --git a/artifacts/tc-reference/src/components/card-detail/related-section.tsx b/artifacts/tc-reference/src/components/card-detail/related-section.tsx
index d14448b..5f59935 100644
--- a/artifacts/tc-reference/src/components/card-detail/related-section.tsx
+++ b/artifacts/tc-reference/src/components/card-detail/related-section.tsx
@@ -7,14 +7,18 @@ import { CARD_TITLE_MAP } from "./card-sections";
export function RelatedSection({
cardData,
setLocation,
+ limit,
}: {
cardData: CardData;
setLocation: (to: string) => void;
+ /** Show only the first few, e.g. as a "where next" at the end of Use it. */
+ limit?: number;
}) {
+ const related = cardData.relatedTechniques!.slice(0, limit);
return (
- {cardData.relatedTechniques!.map((rt) => (
+ {related.map((rt) => (
{CARD_TITLE_MAP[rt.id] ?? rt.id}
- {rt.reason}
+
+ {/* Shortened where it is a quick "where next" */}
+ {limit ? (
+ {rt.reason}
+ ) : (
+ rt.reason
+ )}
+
)}
·
- {card.difficulty}
+ {difficultyLabel(card.difficulty)}
+ {/* Named in full, so "Medium · Medium impact" never reads as a
+ repeated word; matches the tags on the card itself. */}
- {badge.label}
- {/* The visible text is the accessible name (WCAG 2.5.3
- label-in-name); this just says what the badge means. */}
- impact
+ {badge.label} impact
diff --git a/artifacts/tc-reference/src/components/ui/empty-state.tsx b/artifacts/tc-reference/src/components/ui/empty-state.tsx
new file mode 100644
index 0000000..81d15a6
--- /dev/null
+++ b/artifacts/tc-reference/src/components/ui/empty-state.tsx
@@ -0,0 +1,90 @@
+import type { ComponentType, ReactNode } from "react";
+import { cn } from "@/lib/utils";
+
+type Tone = "brand" | "neutral" | "danger";
+
+const TONE: Record = {
+ brand: {
+ tile: "color-mix(in srgb, var(--brand) 10%, transparent)",
+ icon: "var(--brand-text)",
+ },
+ neutral: { tile: "var(--fg-05)", icon: "var(--fg-60)" },
+ danger: {
+ tile: "color-mix(in srgb, var(--accent-red) 10%, transparent)",
+ icon: "var(--accent-red)",
+ },
+};
+
+interface EmptyStateProps {
+ icon: ComponentType<{
+ className?: string;
+ style?: React.CSSProperties;
+ "aria-hidden"?: boolean | "true";
+ }>;
+ tone?: Tone;
+ title: string;
+ /** The page's own heading when nothing else on screen is one. */
+ titleAs?: "h1" | "h2" | "p";
+ children?: ReactNode;
+ /** Buttons or links, stacked full width and main action first. */
+ actions?: ReactNode;
+ className?: string;
+ "data-testid"?: string;
+}
+
+/**
+ * The one look for a screen with nothing to show: empty lists, missing
+ * pages and failed loads. An icon tile, a plain heading, one or two
+ * sentences and the next useful step, so no screen is a dead end.
+ */
+export function EmptyState({
+ icon: Icon,
+ tone = "brand",
+ title,
+ titleAs: Title = "h2",
+ children,
+ actions,
+ className,
+ "data-testid": testId,
+}: EmptyStateProps) {
+ const t = TONE[tone];
+ return (
+
+
+
+
+
+ {title}
+
+ {children && (
+
+ {children}
+
+ )}
+ {actions && (
+
+ {actions}
+
+ )}
+
+ );
+}
diff --git a/artifacts/tc-reference/src/lib/design-tokens.ts b/artifacts/tc-reference/src/lib/design-tokens.ts
index f1a9b58..1198586 100644
--- a/artifacts/tc-reference/src/lib/design-tokens.ts
+++ b/artifacts/tc-reference/src/lib/design-tokens.ts
@@ -33,6 +33,14 @@ export function impactStyleFor(impact: string) {
return IMPACT_STYLES[impact.toLowerCase() as CardImpact] ?? IMPACT_STYLES.low;
}
+/** "Easy-Medium" in the data reads as "Easy to medium" wherever it is shown. */
+export function difficultyLabel(difficulty: string): string {
+ const [first, ...rest] = difficulty.split("-");
+ return rest.length > 0
+ ? `${first} to ${rest.join(" to ").toLowerCase()}`
+ : first;
+}
+
/**
* One colour per Library category, for the category dot and label. Values
* live in index.css as `--cat-*` (dark defaults, light overrides). Keys match
diff --git a/artifacts/tc-reference/src/pages/card-detail.tsx b/artifacts/tc-reference/src/pages/card-detail.tsx
index cf5249e..32a2a69 100644
--- a/artifacts/tc-reference/src/pages/card-detail.tsx
+++ b/artifacts/tc-reference/src/pages/card-detail.tsx
@@ -31,6 +31,7 @@ import { CardCopyProvider } from "@/components/card-detail/card-ui";
import {
CardNotFound,
CardComingSoon,
+ CardLoadFailed,
} from "@/components/card-detail/card-status";
import { CardHeader } from "@/components/card-detail/card-header";
import { CardTabsBar } from "@/components/card-detail/card-tabs-bar";
@@ -202,6 +203,15 @@ function CardView({
>
Next: learn why it works
+ {/* Most people stay on Use it, so the way on to neighbouring
+ techniques sits here too, not only on Practise it. */}
+ {available("related") && (
+
+ )}
{prevNext}
)}
@@ -297,6 +307,8 @@ export default function CardDetail() {
data: CardData | null;
} | null>(null);
const [loadFailedCardId, setLoadFailedCardId] = useState(null);
+ // Bumped by "Try again" to rerun the load; the loader drops failed attempts.
+ const [loadAttempt, setLoadAttempt] = useState(0);
// A new card starts a fresh load: clear any earlier failure during render.
const [prevCardId, setPrevCardId] = useState(cardId);
if (cardId !== prevCardId) {
@@ -334,7 +346,7 @@ export default function CardDetail() {
return () => {
active = false;
};
- }, [cardId, isKnownCard, isLoaded]);
+ }, [cardId, isKnownCard, isLoaded, loadAttempt]);
// Prev/next navigation follows LIBRARY_CATEGORIES order
const loadedCardIdx = LOADED_CARDS_NAV.findIndex((c) => c.id === cardId);
@@ -408,9 +420,13 @@ export default function CardDetail() {
aria-busy={loadFailedCardId !== cardId}
>
{loadFailedCardId === cardId ? (
-
- Card content is unavailable right now.
-
+ {
+ setLoadFailedCardId(null);
+ setLoadAttempt((n) => n + 1);
+ }}
+ />
) : (
<>
{/* Skeleton in the card's own shape so the page doesn't jump */}
diff --git a/artifacts/tc-reference/src/pages/favourites.tsx b/artifacts/tc-reference/src/pages/favourites.tsx
index cf0a457..10f920d 100644
--- a/artifacts/tc-reference/src/pages/favourites.tsx
+++ b/artifacts/tc-reference/src/pages/favourites.tsx
@@ -18,6 +18,7 @@ import { categoryStyleFor } from "@/lib/design-tokens";
import { SegmentedTabs } from "@/components/ui/segmented-tabs";
import { ListRow } from "@/components/ui/list-row";
import { Button } from "@/components/ui/button";
+import { EmptyState } from "@/components/ui/empty-state";
import { SettingsSheet } from "@/components/settings-sheet";
import { ShareSheet } from "@/components/share-sheet";
import type { ShareItem } from "@/components/share-sheet";
@@ -158,41 +159,23 @@ export default function Favourites() {
{totalSaved === 0 ? (
-
-
-
-
-
- Nothing saved yet
-
-
- Tap the heart on any technique or phrase to keep it here for quick
- access.
-
-
- setLocation("/")}>
- Browse the Library
-
- setLocation("/phrases")}>
- Open the Phrase Bank
-
-
-
+
+ setLocation("/")}>
+ Browse the Library
+
+ setLocation("/phrases")}>
+ Open the Phrase Bank
+
+ >
+ }
+ >
+ Tap the heart on any technique or phrase to keep it here for quick
+ access.
+
) : (
<>
diff --git a/artifacts/tc-reference/src/pages/help.tsx b/artifacts/tc-reference/src/pages/help.tsx
index f285267..5bdb42f 100644
--- a/artifacts/tc-reference/src/pages/help.tsx
+++ b/artifacts/tc-reference/src/pages/help.tsx
@@ -3,6 +3,7 @@ import {
ArrowLeft,
Check,
ChevronRight,
+ Compass,
Copy,
Search,
X,
@@ -15,6 +16,7 @@ import { useNav } from "@/lib/nav-context";
import { useCopyFeedback } from "@/hooks/use-copy-feedback";
import { quoted } from "@/lib/utils";
import { buttonClass } from "@/components/ui/button";
+import { EmptyState } from "@/components/ui/empty-state";
// Help me right now: pick what is happening, then get one move, three lines
// to say, what to do next and one thing to avoid. Built only from the light
@@ -338,15 +340,20 @@ function HelpNotFound() {
return (
-
+ See all situations
+
+ }
>
- Situation not found
-
-
That link may be out of date. Pick what is happening from the list.
-
+
);
}
diff --git a/artifacts/tc-reference/src/pages/not-found.tsx b/artifacts/tc-reference/src/pages/not-found.tsx
index 65ef462..c563608 100644
--- a/artifacts/tc-reference/src/pages/not-found.tsx
+++ b/artifacts/tc-reference/src/pages/not-found.tsx
@@ -1,53 +1,46 @@
-import { useLocation } from "wouter";
-import { AlertCircle, ChevronLeft } from "lucide-react";
+import { Link, useLocation } from "wouter";
+import { Compass } from "lucide-react";
+import { Button, buttonClass } from "@/components/ui/button";
+import { EmptyState } from "@/components/ui/empty-state";
+import { SEARCH_ENTRY_STATE, searchHref } from "@/components/search/search-nav";
export default function NotFound() {
const [, setLocation] = useLocation();
return (
-
-
+
+ setLocation("/")}>
+ Back to Library
+
+
+ Search techniques
+
+
+ Help me right now
+
+ >
+ }
>
-
-
-
-
- 404: Page not found
-
-
- This page doesn't exist. Head back to the library to keep exploring.
-