commit ce5bdc0eae5e1ae48c229f737c480b172df06dce
parent 24ad8d8dad2d904afaaa5596b123bf3633d2a7cb
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Fri, 6 Nov 2026 14:18:56 -0500
umtool: a diet tag keeps the date of the switch; its words lose the regime they repeat
Reviewing the proof stills: the KETO #6 tag read "Jul 20, 2026" at 11:13 --
the day the ledger's words changed to "5 carbs a day" -- where it had slammed
in at 7:25 as "Mar 24, 2026", and the streak counted from Mar 24. A change of
words alone replaces the newest tag in place (dietStates `replaced`); it now
keeps that tag's `since` (and the state's diet.since), so a tag dates the
SWITCH; a new diet still gets its own day (the diet docs say so). And the words line said the regime
twice ("Keto · 5 carbs a…", cut off): tagWords drops the regime the words open
with when a separator follows it ("5 carbs a day"; "Keto + IF + walking" stays
whole). The stamp form is unchanged. Tests: a words-only change keeps since, a
new diet has its own, the prefix dropped.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
5 files changed, 54 insertions(+), 6 deletions(-)
diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md
@@ -1778,7 +1778,7 @@ The diet he names as a rubber stamp in a corner of the footage box (`render.chro
| `deck.diet` | `true` · `false` · `{show, position, x, y, scale, hold, finale, colors, labels}` · default on with a measure slice | `umtool look <p> deck.diet=false` |
| `deck.diet.position`, `.x`/`.y`, `.scale` | an anchor in the footage box · design px · 0.5–2 · default `bottom-left`, unset, 1 | `umtool look <p> deck.diet.position=top-right` |
| `deck.diet.hold`, `.finale` | 0 (up from the first diet on) or 2–600 s · `hide` `show` · default 0, `hide` | `umtool look <p> deck.diet.hold=15` |
-| `deck.diet.form`, `.tags` | `stamp` · `tags`: the last `tags` diets as a row of dated tags -- each a small stamp with the regime's word in its ink, "DIET #n" and the ledger's words, and the day he named it (`state.diet.since`, "Mar 14, 2025"); at each change the new tag slams in at the left, the older slide right and dim, the one past `tags` falls off; a change of words alone fades the new tag over the old; a null diet is a grey "NO DIET" tag with its date · 1–4 · default `stamp` (`tags` on the shelf), 3 | `umtool look <p> deck.diet.form=tags deck.diet.tags=2` |
+| `deck.diet.form`, `.tags` | `stamp` · `tags`: the last `tags` diets as a row of dated tags -- each a small stamp with the regime's word in its ink, "DIET #n" and the ledger's words (less the regime they open with: "5 carbs a day"), and the day he switched to it (`state.diet.since`, "Mar 14, 2025"; new words for the same diet keep that day); at each change the new tag slams in at the left, the older slide right and dim, the one past `tags` falls off; a change of words alone fades the new tag over the old; a null diet is a grey "NO DIET" tag with its date · 1–4 · default `stamp` (`tags` on the shelf), 3 | `umtool look <p> deck.diet.form=tags deck.diet.tags=2` |
| `deck.diet.colors`, `.labels` | `{<regime>: #hex}` · `{<regime>: words ≤40}` · default the regimes' inks and names | `umtool look <p> deck.diet.labels='{"glp1":"Ozempic"}'` |
| `deck.diet.onPosts`, `.onChapters` | `dodge` `hide` `show` · default `dodge`: while a post item's card (its card, slot and strip as postLayout lays them: the schedule's `covers`) or a chapter band is up where it stands, it moves to a free anchor of the footage box -- a size down to half if it must, never onto another measure extra that is up -- and hides when none fits; `hide` hides, `show` stays over it | `umtool look <p> deck.diet.onPosts=hide` |
| `deck.diet.position=shelf` | in its own slot on the shelf (`deck.shelf`: under or over the footage), scaled to the shelf's height, left to right in `deck.shelf.items` order -- nothing covers it there, so it never dodges (`onPosts`, `onChapters`, `x`/`y`, `scale` and `avoid` do not apply), and it is over the finale as the shelf is (`deck.shelf.finale`) | `umtool look <p> deck.shelf=true deck.diet.position=shelf` |
diff --git a/umtool/report-to-video/chrome-measure-extras.mjs b/umtool/report-to-video/chrome-measure-extras.mjs
@@ -693,6 +693,23 @@ export function tagWordSize(label, room = DIET_TAG.width - 44) {
}
/**
+ * A tag's words without the regime they open with: the tag already says it in
+ * its ink, so "Keto · 5 carbs a day" is "5 carbs a day" (and fits) -- only
+ * where a separator follows it ("Keto + IF + walking" stays whole). Words
+ * that are only the regime are none.
+ */
+export function tagWords(detail, names) {
+ let w = String(detail ?? "").trim();
+ for (const name of names) {
+ const n = String(name ?? "").trim();
+ if (!n) continue;
+ const re = new RegExp(`^${n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?:\\s*[·:,;–—-]\\s*|$)`, "i");
+ if (re.test(w)) { w = w.replace(re, "").trim(); break; }
+ }
+ return w;
+}
+
+/**
* The diet as a row of DATED TAGS (`diet.form: "tags"`, the shelf's default):
* the last `tags` diets (dietStates' `tags`, newest first), each a small stamp
* -- the regime's word in its ink, "DIET #n" and the ledger's words when they
@@ -767,8 +784,9 @@ function dietTagsHtml(schedule, render, opts, cfg, states) {
const ink = d ? d.color : pal.muted;
const size = tagWordSize(label, room);
const date = t.since ? formatDeckDate(t.since) : "";
+ const words = d ? tagWords(d.detail, [d.label, d.regime]) : "";
const sub = d
- ? `<div class="sb"><span class="dn">Diet${d.n !== null ? ` #${d.n}` : ""}</span>${d.detail ? `<span class="dd">${esc(d.detail)}</span>` : ""}</div>`
+ ? `<div class="sb"><span class="dn">Diet${d.n !== null ? ` #${d.n}` : ""}</span>${words ? `<span class="dd">${esc(words)}</span>` : ""}</div>`
: `<div class="sb"><span class="dd">he says he is on none</span></div>`;
const html = `<div class="tg" data-k="${k}"><div class="dm" data-k="${k}.d"><div class="sw" data-k="${k}.w"><div class="sp${d ? "" : " off"}" data-k="${k}.s">` +
`<div class="ink" style="color:${ink};border-color:${ink}"><div class="lb" style="font-size:${px(size)}px;line-height:${px(Math.round(size * 1.02))}px">${esc(label)}</div>${sub}` +
diff --git a/umtool/report-to-video/measure-extras.mjs b/umtool/report-to-video/measure-extras.mjs
@@ -500,10 +500,13 @@ export function dietStates(schedule, render) {
let shown = [];
let id = 0;
return out.map(({ key: _k, since, ...st }, j) => {
- const tag = { id: id++, diet: st.diet, since };
const wordsOnly = j > 0 && !!st.diet && !st.slam && !!out[j - 1].diet;
+ // New words for the same diet keep the day he switched to it: the tag dates the SWITCH, not the words.
+ const kept = wordsOnly && shown[0] ? shown[0].since : since;
+ const diet = wordsOnly && st.diet ? { ...st.diet, since: kept } : st.diet;
+ const tag = { id: id++, diet, since: kept };
shown = wordsOnly ? [tag, ...shown.slice(1)] : [tag, ...shown].slice(0, n);
- return { ...st, tags: shown, replaced: wordsOnly };
+ return { ...st, diet, tags: shown, replaced: wordsOnly };
});
}
diff --git a/umtool/report-to-video/modules/diet.mjs b/umtool/report-to-video/modules/diet.mjs
@@ -30,7 +30,7 @@ export default measureExtraModule({
["`deck.diet`", "`true` · `false` · `{show, position, x, y, scale, hold, finale, colors, labels}` · default on with a measure slice", "`umtool look <p> deck.diet=false`"],
["`deck.diet.position`, `.x`/`.y`, `.scale`", "an anchor in the footage box · design px · 0.5–2 · default `bottom-left`, unset, 1", "`umtool look <p> deck.diet.position=top-right`"],
["`deck.diet.hold`, `.finale`", "0 (up from the first diet on) or 2–600 s · `hide` `show` · default 0, `hide`", "`umtool look <p> deck.diet.hold=15`"],
- ["`deck.diet.form`, `.tags`", "`stamp` · `tags`: the last `tags` diets as a row of dated tags -- each a small stamp with the regime's word in its ink, \"DIET #n\" and the ledger's words, and the day he named it (`state.diet.since`, \"Mar 14, 2025\"); at each change the new tag slams in at the left, the older slide right and dim, the one past `tags` falls off; a change of words alone fades the new tag over the old; a null diet is a grey \"NO DIET\" tag with its date · 1–4 · default `stamp` (`tags` on the shelf), 3", "`umtool look <p> deck.diet.form=tags deck.diet.tags=2`"],
+ ["`deck.diet.form`, `.tags`", "`stamp` · `tags`: the last `tags` diets as a row of dated tags -- each a small stamp with the regime's word in its ink, \"DIET #n\" and the ledger's words (less the regime they open with: \"5 carbs a day\"), and the day he switched to it (`state.diet.since`, \"Mar 14, 2025\"; new words for the same diet keep that day); at each change the new tag slams in at the left, the older slide right and dim, the one past `tags` falls off; a change of words alone fades the new tag over the old; a null diet is a grey \"NO DIET\" tag with its date · 1–4 · default `stamp` (`tags` on the shelf), 3", "`umtool look <p> deck.diet.form=tags deck.diet.tags=2`"],
["`deck.diet.colors`, `.labels`", "`{<regime>: #hex}` · `{<regime>: words ≤40}` · default the regimes' inks and names", "`umtool look <p> deck.diet.labels='{\"glp1\":\"Ozempic\"}'`"],
],
},
diff --git a/umtool/report-to-video/shelf.test.mjs b/umtool/report-to-video/shelf.test.mjs
@@ -10,7 +10,7 @@ import path from "node:path";
import test from "node:test";
import { fileURLToPath } from "node:url";
-import { dietHtml, tagWordSize } from "./chrome-measure-extras.mjs";
+import { dietHtml, tagWords, tagWordSize } from "./chrome-measure-extras.mjs";
import { shelfHtml, shelfNoteGeometry } from "./chrome-shelf.mjs";
import { deckGeometry, entryShelfNotes, estimateSchedule, instrumentsGeometry, parseShelfNote, validateChrome } from "./deck.mjs";
import { dietStates, measureExtraGeometry, measurePlacements, shelfLayout } from "./measure-extras.mjs";
@@ -145,6 +145,33 @@ test("the diet's tags: each change pushes a dated tag in at the front, the oldes
assert.equal(tagWordSize("Carnivore"), 31);
});
+test("a tag dates the SWITCH: new words for the same diet keep its since; a new diet gets its own; the words lose the regime they repeat", () => {
+ const r = renderOf(SHELF);
+ const m = clone(MEASURE);
+ // Keto #63 named on its day; later the ledger's words change ("5 carbs a day") with a since of their own.
+ const k = m.state.findIndex((s) => s.diet?.n === 63);
+ const keto = m.state[k].diet;
+ m.state[k + 1] = { ...m.state[k + 1], diet: { ...keto, display: "Keto · 2 carbs a day", since: "2026-08-02" } };
+ const s2 = dietStates(schedule({ measure: m }), r);
+ const j = s2.findIndex((s) => s.diet?.detail === "Keto · 2 carbs a day");
+ assert.equal(s2[j].replaced, true);
+ assert.notEqual(s2[j - 1].tags[0].since, "2026-08-02");
+ assert.equal(s2[j].tags[0].since, s2[j - 1].tags[0].since, "the words' day is not the switch's");
+ assert.equal(s2[j].diet.since, s2[j - 1].tags[0].since);
+ // A new diet (a slam) gets the day it was named.
+ const slam = s2.findIndex((s, i) => i > 0 && s.slam);
+ assert.equal(s2[slam].tags[0].since, s2[slam].diet.since);
+ assert.notEqual(s2[slam].tags[0].since, s2[slam - 1].tags[0].since);
+ // The words: the regime they open with dropped where a separator follows it.
+ assert.equal(tagWords("Keto · 5 carbs a day", ["Keto", "keto"]), "5 carbs a day");
+ assert.equal(tagWords("Keto + IF + walking", ["Keto", "keto"]), "Keto + IF + walking");
+ assert.equal(tagWords("Keto", ["Keto", "keto"]), "");
+ const { html } = dietHtml(schedule({ measure: m }), r, { fonts: {} });
+ assert.match(html, /<span class="dd">5 carbs a day<\/span>/);
+ assert.match(html, /<span class="dd">2 carbs a day<\/span>/);
+ assert.doesNotMatch(html, /Aug 2, 2026/);
+});
+
test("the shelf's note: an entry's shelfNote over its span, only with the shelf on; its own page in the slot left", () => {
assert.deepEqual(parseShelfNote(" Day 41 "), { value: "Day 41", error: null });
assert.equal(parseShelfNote("").value, null);