Make a stored id always name a row
Review found the new settings row opening nothing for a rule whose `until`
precedes its `startsAt`. That parses — nothing ties the two together — and
yields no occurrence at all, so nextOccurrences and the anchor fallback both
come back empty, nearestOccurrence returns null, and openRow cannot resolve
a bare rule id. It was the undeletable record this index exists to rescue,
now with a button that lies about it.
So resolution moves out of App into displayEventFor, with the rule itself as
the floor: a stored id always names something the reader can edit and
delete, whatever the rule does or does not generate. Exported because
nothing here can click and no test renders App, which is exactly how a dead
button shipped — the chain is now covered without a DOM.
Two of the caption tests could not fail, proven by mutation rather than
read: deleting the whole "starts" branch and removing the null-end guard
both left the suite green, because `not.toContain("ended")` was never
watching the branch at risk. They assert what the caption says now.
And a repeating series that has stopped said only how often it repeats — in
the one place whose job is explaining why an event is on no other surface. A
healthy cadence explains nothing; it says when it stopped.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5
parent
3a3b7d9c2f
commit
86ba2ccc1d
+8
-13
@@ -30,12 +30,12 @@ import {
|
||||
} from "./state/lens.ts";
|
||||
import { clockFor, formatRemaining } from "../shared/time.ts";
|
||||
import { dailySummary, isDaily, resolveDaily } from "../shared/daily.ts";
|
||||
import { nearestOccurrence, occurrenceForId, strandedOccurrences } from "../shared/recurrence.ts";
|
||||
import { strandedOccurrences } from "../shared/recurrence.ts";
|
||||
import { orderGames } from "./state/gameOrder.ts";
|
||||
import { GameMetaProvider, type MetaResolver } from "./state/gameMeta.tsx";
|
||||
import { metaOnTheme, useTheme } from "./state/theme.ts";
|
||||
import {
|
||||
asOccurrenceEvent,
|
||||
displayEventFor,
|
||||
recordFor,
|
||||
type CustomEvents,
|
||||
type CustomGames,
|
||||
@@ -369,11 +369,8 @@ export function App() {
|
||||
const openRow = (() => {
|
||||
const hit = allRows.find((r) => r.event.id === openId) ?? null;
|
||||
if (hit !== null || openId === null) return hit;
|
||||
const record = recordFor(custom.events, openId);
|
||||
if (record === undefined) return null;
|
||||
const occurrence = occurrenceForId(record, openId);
|
||||
if (occurrence === null) return null;
|
||||
const event = asOccurrenceEvent(record, occurrence);
|
||||
const event = displayEventFor(custom.events, openId, now);
|
||||
if (event === null) return null;
|
||||
return { event, clock: clockFor(event, prefs.region, now) };
|
||||
})();
|
||||
|
||||
@@ -654,12 +651,10 @@ export function App() {
|
||||
// The index lists rules; the sheet opens rows. A repeating rule's
|
||||
// own id is never a row — the lists hold its occurrences — so it is
|
||||
// resolved to whichever occurrence is nearest before opening.
|
||||
onOpen: (id) => {
|
||||
const record = custom.events[id];
|
||||
const occurrence =
|
||||
record === undefined ? null : nearestOccurrence(record, now);
|
||||
setOpenId(occurrence === null ? id : occurrence.id);
|
||||
},
|
||||
// The stored id is enough: `displayEventFor` resolves a rule to
|
||||
// whichever occurrence the sheet can show, and to the rule itself
|
||||
// when it has none.
|
||||
onOpen: setOpenId,
|
||||
}}
|
||||
onExport={() =>
|
||||
exportProgress(prog.progress, daily.logs, ignored.marks, prefs, {
|
||||
|
||||
Reference in New Issue
Block a user