feat(prefs): a game we add arrives switched off

Adding a source is our decision, not the reader's. Eleven lanes became
fourteen this week, and for someone who plays two that is not a feature
arriving — it is their calendar filling with events they will never open,
which is the thing the first-run picker exists to prevent.

`knownGames` records every lane a reader has been offered; a lane missing from
it is new to them, so it is recorded and hidden on sight. The games chips in
settings list every lane, on or off, which is where they take one up.

The case that had to be right is the reader who installed before any of this
existed: they have no `knownGames` at all, and reading that as "has been
offered nothing" would switch off every game they already read. Absent means
unrecorded — the first pass records what is already on their screen and
changes nothing else. Lanes they invented are recorded but never hidden;
typing a game in is asking for it.

The decision is a pure function so this is provable rather than watched for.
One real cost, stated in the PRD rather than hidden: a reader whose game
finally arrives is not told, which makes the colophon roadmap matter more.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
Lucas Winther
2026-08-18 04:05:23 +02:00
co-authored by Claude Opus 5
parent b3aea00cbb
commit d5dbe72e17
7 changed files with 188 additions and 11 deletions
+23 -3
View File
@@ -17,7 +17,7 @@ import { useAppUpdate } from "./state/useAppUpdate.ts";
import { useMarkSet } from "./state/useMarkSet.ts";
import { useProgress } from "./state/useProgress.ts";
import { useDailyLog, type DailyLogMap } from "./state/useDailyLog.ts";
import { usePrefs, type View } from "./state/usePrefs.ts";
import { adoptNewLanes, usePrefs, type View } from "./state/usePrefs.ts";
import { useCustom } from "./state/useCustom.ts";
import { compareRows, SORT_MODES, type Activity, type SortMode } from "./state/sort.ts";
import {
@@ -206,6 +206,26 @@ export function App() {
[allRows, custom.lanes],
);
/**
* A lane the reader has never been offered starts switched off.
*
* Adding a source is our decision, not theirs, and a reader who plays two
* games did not ask for the other twelve. So a lane that is new to *them*
* is recorded and hidden, and the games chips in settings are where they
* take it up — the one place that lists every lane, on or off.
*
* The seeding branch is the whole reason this is safe: an existing reader
* has no `knownGames` at all, and treating that as "has been offered
* nothing" would switch off every game they already read. Absent means
* unrecorded, so the first pass records what is already on their screen and
* changes nothing else.
*/
useEffect(() => {
if (state.status !== "ready") return;
const patch = adoptNewLanes(games, prefs.knownGames, prefs.hiddenGames);
if (patch !== null) update(patch);
}, [state.status, games, prefs.knownGames, prefs.hiddenGames, update]);
/** Games the reader plays, in feed order. The focus bar rotates through these. */
const enabled = useMemo(
() => games.filter((g) => !prefs.hiddenGames.includes(g)),
@@ -311,8 +331,8 @@ export function App() {
}
// First run: ask which games before showing a calendar full of ones they
// don't play. Stored as hiddenGames (the inverse) so a game added later shows
// up by default rather than staying invisible.
// don't play. Stored as hiddenGames (the inverse); what happens to a game
// added *later* is decided by `knownGames` above, not by this shape.
if (!prefs.onboarded) {
return (
<GameMetaProvider value={gameMeta}>
+3 -2
View File
@@ -135,8 +135,9 @@ export function Welcome({
</div>
<p className="mt-auto pt-10 text-xs leading-relaxed text-faint">
More games are coming as sources are added. Anything you switch on later
shows up automatically.
More games are coming as sources are added. A new one stays switched off
until you ask for it — you'll find it in settings, at the bottom of the
page.
</p>
</div>
);
+65 -2
View File
@@ -1,5 +1,5 @@
import { useCallback, useEffect, useState } from "react";
import type { LaneId } from "../../shared/custom.ts";
import { isCustomGameId, type LaneId } from "../../shared/custom.ts";
import type { Region } from "../../shared/schema.ts";
import { guessRegion } from "../../shared/time.ts";
import type { SortMode } from "./sort.ts";
@@ -17,8 +17,33 @@ export type View = "soon" | "timeline";
export interface Prefs {
region: Region;
/** Games the reader has switched off. Stored as hidden so a newly added game shows up by default. */
/**
* Games the reader has switched off.
*
* Still stored as the inverse, but no longer because a new game should
* appear by default — see `knownGames`, which is what decides that now. It
* stays the inverse because it is what every existing device has written
* down, and rewriting a live key space to say the same thing differently
* costs a migration and buys nothing.
*/
hiddenGames: LaneId[];
/**
* Every lane this reader has been offered.
*
* A game we add is a game they never asked for. Turning eleven lanes into
* fourteen under someone who plays two is not a feature arriving, it is
* their calendar filling with events they will never open — so a lane that
* is new *to them* arrives switched off, and the games chips in settings are
* where they take it up.
*
* Absent means "never recorded", which is not the same as "has been offered
* nothing": every existing reader is in that state, and seeding it from
* what is on screen is what stops this from switching their games off the
* first time they load a build that has it. Their own games (`mygame:`) are
* recorded here too but never auto-hidden — they asked for those by typing
* them in.
*/
knownGames?: LaneId[];
/**
* One game to look at right now, or null for all of them.
*
@@ -71,6 +96,44 @@ function defaults(): Prefs {
};
}
/**
* What to record and what to switch off when the set of lanes changes.
*
* Pure and separate from the hook because it decides whether a reader's games
* get switched off, which is the kind of thing that should be provable rather
* than watched for. Returns `null` when there is nothing to do, so the caller
* writes to storage only when something actually changed.
*
* Two cases it must not get wrong:
*
* - **`known` absent.** Every reader who installed before this existed is in
* that state, and it means "unrecorded", not "has been offered nothing".
* Seeding records what is already on their screen and switches nothing off.
* - **A lane they invented.** `mygame:` lanes are the reader asking for a game
* by typing it in, so they are recorded but never hidden. Only a lane that
* arrived because we added a source turns up switched off.
*/
export function adoptNewLanes(
lanes: readonly LaneId[],
known: readonly LaneId[] | undefined,
hidden: readonly LaneId[],
): Partial<Prefs> | null {
// An empty list is a feed that has not arrived, not a reader with no games.
if (lanes.length === 0) return null;
if (known === undefined) return { knownGames: [...lanes] };
const fresh = lanes.filter((lane) => !known.includes(lane));
if (fresh.length === 0) return null;
const unasked = fresh.filter(
(lane) => !isCustomGameId(lane) && !hidden.includes(lane),
);
return {
knownGames: [...known, ...fresh],
hiddenGames: [...hidden, ...unasked],
};
}
export function usePrefs() {
const [prefs, setPrefs] = useState<Prefs>(() => ({
...defaults(),