fix(routines): test the copy, name what Yes agrees to, and true up the docs

Make it mine's copying was inline in App and untested; it is now a pure
function with a test, so a change to either store can't make the copy
silently arrive empty. The question's buttons now say what they answer
when heard out of context. The prefs block and the spec now match what
shipped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Lucas Winther
2026-10-13 14:19:16 +02:00
co-authored by Claude Opus 5.5
parent f7ba86e6e5
commit 1c7df637a4
7 changed files with 65 additions and 10 deletions
+20
View File
@@ -123,3 +123,23 @@ export function mineFrom(routine: Routine): {
from: routine.id,
};
}
/**
* What *Make it mine* hands the day log and the amounts store: the built-in's
* record, filed under the copy's id. Pure, and only ever merged in — the
* originals stay under the routine's id, so deleting the copy shows the
* built-in exactly as it was.
*/
export function copyRoutineState<L, A>(
logs: Readonly<Record<string, L>>,
amounts: Readonly<Record<string, A>>,
fromId: string,
toId: string,
): { daily: Record<string, L>; amounts: Record<string, A> } {
const log = logs[fromId];
const numbers = amounts[fromId];
return {
daily: log === undefined ? {} : { [toId]: log },
amounts: numbers === undefined ? {} : { [toId]: numbers },
};
}