Pulse: pages with no `quality` still render a score (`/10`, `Q`, `0% quality`), and the `/docs` list treats the field as a 0-1 fraction
Version
LifeOS 7.40.4 / Pulse (Observability). The two source files below hash the same on current main as in the release.
What is broken
Pulse renders a quality score for pages that have no quality in their frontmatter. The indexer types the field as number | null and stores null when the frontmatter has no quality, but every UI reader types it as quality?: number and guards only against undefined, so null passes the guard: the page panel prints a value of /10 in the error colour, the /system list prints a bare Q, and the /docs list prints 0% quality. The /docs list also treats the value as a 0-1 fraction (Math.round(quality * 100)), so a note with quality: 5 prints 500% quality there while the same page prints 5/10 in the panel: two readers, two scales. Related: #2244 reports the same kind of scale disagreement on /synapse.
Where (file:line)
The writer and the readers disagree.
LifeOS/install/LIFEOS/PULSE/modules/wiki.ts:70declaresquality: number | null;:315storestypeof fm.quality === "number" ? fm.quality : null. The index route (handleIndex,:815) returns those page objects asrecentChanges, so the list carries"quality": null. The doc route (handleDoc,:824) emits the field for knowledge categories (:833, includesisa,idea,research,wisdom,lesson) at:853, and omits it entirely for every other category at:865.LifeOS/install/LIFEOS/PULSE/Observability/src/components/wiki/WikiMeta.tsx:28(quality?: number),:159(quality !== undefined),:166({quality}/10),:48(qualityColor, wherenullfalls through both comparisons to the error branch).LifeOS/install/LIFEOS/PULSE/Observability/src/app/system/page.tsx:139and:141(page.quality !== undefined,Q{page.quality}).LifeOS/install/LIFEOS/PULSE/Observability/src/app/docs/page.tsx:79(qualityLabel:undefinedgivesquality n/a, anything else givesMath.round(quality * 100)).
Repro on a clean tree
# LifeOS 7.40.4 with Pulse on :31337
# 1. the list route carries the field for every page, null when the frontmatter has no quality
curl -s localhost:31337/api/wiki | jq -c '.recentChanges[] | select(.quality == null) | {slug, category}' | head
# 2. open http://localhost:31337/docs and read the pill on those cards: it reads "0% quality"
# 3. open one of those pages and look at the panel aside:
# a knowledge-category page (isa, idea, research, ...) shows a Quality row whose value is only "/10"
# a system-doc page shows no Quality row at all, because the doc route omits the field
curl -s localhost:31337/api/wiki/doc/<slug-without-quality> | jq -c '{category, quality}'Negative control
On unpatched 7.40.4, with no patch and no local config: curl -s localhost:31337/api/wiki | jq '.recentChanges[0].quality' prints null for a page whose frontmatter has no quality, and the same card in /docs prints 0% quality rather than quality n/a, because the null never reaches the === undefined branch. The panel for a knowledge-category page prints /10 with the error colour class. For contrast, a page whose frontmatter has quality: 5 prints 5/10 in the panel and 500% quality in the list, so the second defect shows even when the value exists. The check is red before any fix.
Suggested fix
Untested; three small guards, no data changes.
--- a/LIFEOS/PULSE/Observability/src/components/wiki/WikiMeta.tsx
- quality?: number;
+ quality?: number | null;
@@
- {quality !== undefined && (
+ {typeof quality === "number" && (--- a/LIFEOS/PULSE/Observability/src/app/system/page.tsx
- {page.quality !== undefined && (
+ {typeof page.quality === "number" && (--- a/LIFEOS/PULSE/Observability/src/app/docs/page.tsx
-function qualityLabel(quality: number | undefined): string {
- if (quality === undefined) return "quality n/a";
- return `${Math.round(quality * 100)}% quality`;
-}
+function qualityLabel(quality: number | null | undefined): string {
+ if (typeof quality !== "number") return "quality n/a";
+ return `${quality}/10`;
+}If the /docs list is meant to show a 0-1 fraction, then the panel is the wrong one and the guard belongs there instead; the scale question is the one worth settling first.
Before submitting
- I searched open and closed issues for this defect.
- The repro runs against a clean tree of the version above, not against my modified install.
- I removed personal data from the pasted output: real names, absolute home paths, tokens, my own content.
Source: danielmiessler/LifeOS