Repository navigation
Unify node-type accent colors to a single primary-based system - #2672
Conversation
…#2590) Four disagreeing definitions of the node-type accent colors coexisted, so which color a user saw depended on which component tree rendered the node. DESIGN.md is explicit that all node types share the single primary accent. - Delete the "Subtle Tint System (Scheme 3)" blue-gray override block in base-node-viewer.svelte (leftover experiment) - Stop noderef.css redefining --node-user/--node-date/--node-document with per-type hues; it now only consumes the vars. Since it is imported after app.css, its definitions previously won the cascade app-wide - Collapse the four hardcoded per-document-type hex accents (#dc2626, #7c3aed, #ea580c, #0891b2) into one rule using the shared node accent - Replace the blue-gray fallbacks in the icon registry with the matching --node-* vars. --node-project had no definition at all, so it always resolved to the blue-gray fallback; it is now defined in app.css - circle-icon.svelte hardcoded hsl(200 40% 45%) on its circles, ignoring the color prop the registry passed in; it now honors that prop app.css is the single source of truth and derives each --node-* from var(--primary) rather than repeating its literal value, so light/dark switching is automatic and the two cannot drift. This makes the .dark node-color block redundant, so it is removed. Verified in-browser that hsl(var(--node-*) / alpha) resolves through the indirection in both themes: teal rgb(29,149,137) light, rgb(52,157,145) dark. Design-token baseline ratcheted 251 -> 247 for the removed hex literals. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Code Review: PR #2672 — Unify node-type accent colorsReview Type: Initial Review · Commit reviewed: Requirements Check
Findings🟢 Verified correct — the highest-risk claim holds1. The There is a subtlety the commit message does not mention:
🟡 Important2. These keep Previously Principle: a type-color decision should read from the token system, not fall through to an unrelated inherited property. 3. A component that accepts a prop then ignores it is a latent bug (Principle of Least Astonishment). Blast radius is exactly the registry entries — the other 4. A sixth definition of node colors was missed — dead, theme-broken.
5. Nothing prevents recurrence — and #2589 does not cover it. Answering honestly: no. The gate catches a custom property assigned a raw literal, so re-adding
🟢 Suggestions6. 7. Nit: new comments use British "colour" while the codebase uses American "color". On the document-subtype flatteningClearly correct per spec, not a judgment call. DESIGN.md:225 and :345 are explicit. These were subtypes of one node type — an even weaker case for divergence. The distinction moves to icon and label, which is the better channel anyway: color-only encoding fails for colorblind users. If anyone wants it back, the path is a DESIGN.md amendment, not code that quietly diverges. SummaryA genuinely good change and a clear net improvement. The The findings are about completeness rather than correctness — nothing is broken or unsafe. But two things stand between this and its stated "single source of truth" goal: a dead theme-broken color map in Recommendation: REQUEST CHANGES — narrowly; every item is small and in-scope.
🤖 Generated with Claude Code |
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: REQUEST CHANGES (posted as a comment — GitHub blocks requesting changes on your own PR). Full findings in the review comment above.
- registry.ts: text/header/document used colorVar 'currentColor', which inherited --foreground (near-black light / near-white dark) rather than the shared accent. This was masked while circle-icon.svelte ignored its color prop; honoring that prop surfaced it. They now use --node-text / --node-document, so every registry entry resolves through the tokens and AC #5 ("all node types render the same accent") is actually met. - tokens.ts: delete nodeTypeColors / getNodeTypeColor. This was a sixth definition of node colors and the "JS/TS logic that branches on node type to pick a color" the issue asked to check for. It hardcoded the LIGHT-mode literal per type, so it was theme-broken by construction and invisible to the Stylelint gate (.ts, not .css). Zero consumers repo-wide. Also delete the getTokens/getNodeTokens stubs marked "deprecated but kept for migration" (CLAUDE.md forbids both), and the now-unused NodeType re-export and logger. Theme/getResolvedTheme are live and kept. - app.css: add --node-default. base-node-decoration.ts:480 referenced it bare with no fallback and nothing defined it, so it resolved to nothing — the same latent bug --node-project had. - Add src/tests/design/node-accent-colors.test.ts. Stylelint cannot catch a recurrence: it rejects a custom property assigned a raw literal, but `--node-user: var(--chart-3)` in a second file passes every rule while re-fragmenting the system. Verified the guard by reintroducing exactly that line and watching it fail, then reverting. - Fix British "colour" -> "color" in the two new comments. Tests: 247 files / 5081 passed (baseline 246 / 5078, +1 file +3 tests). quality:fix clean, no new design-token violations. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Address Review Summary — commit
|
| Finding | Action |
|---|---|
🟡 #2 currentColor bypass |
text/header/document now use --node-text / --node-document. Closes AC #5 |
🟡 #4 dead tokens.ts map |
Deleted nodeTypeColors, getNodeTypeColor, getTokens, getNodeTokens |
| 🟡 #5 no regression guard | Added src/tests/design/node-accent-colors.test.ts (3 tests) |
🟢 #6 --node-default undefined |
Added to the app.css block |
| 🟢 #7 "colour" → "color" | Fixed in both new comments |
Notes
The new test is verified to actually fail. I reintroduced --node-user: var(--chart-3) into noderef.css, confirmed the guard caught it, then reverted:
× declares every --node-* color variable only in app.css
+ "src/lib/styles/noderef.css declares --node-user: var(--chart-3)"
That is precisely the case Stylelint passes clean — it rejects raw literals but not a var() redefinition, which re-fragments the system just as badly. A guard I hadn't watched fail wouldn't be worth much. The test also asserts every --node-* derives from var(--primary), and that every var the icon registry references is actually defined (the --node-project / --node-default bug class).
On Finding 4 — the most valuable catch. tokens.ts was a sixth definition that neither the issue nor my original pass found, and the worst of them: it hardcoded only the light-mode literal hsl(174 67% 35%) per type, so it was theme-broken by construction, and being .ts it sits outside the Stylelint gate entirely. Zero consumers. I kept Theme and getResolvedTheme (live, used by theme.ts and display-settings.svelte) and removed the orphaned NodeType re-export and logger.
Verification
- Tests: 247 files / 5081 passed (baseline 246 / 5078 — exactly +1 file, +3 tests)
- quality:fix: clean, 0 errors / 0 warnings, no new design-token violations
- Pre-push gate: passed (full pyramid incl. Rust + e2e)
⚠️ One item for human judgment
text node bullets now render teal instead of near-black. This follows from DESIGN.md and is what closes AC #5, but it changes the most common visual in the app. If the near-black bullet was intentional, the right fix is to state that explicitly in the token system rather than leave it to currentColor inheritance — flagging rather than deciding unilaterally.
🤖 Generated with Claude Code
The guard only matched declarations at a line start with a lowercase name,
so five forms slipped past it. The reachable one: an inline
`style="--node-user: red"` attribute, which is house style in seven icon
components and so a realistic way to set a node color.
Anchor to `{`, `;` or a quote as well as a line start, allow digits and
uppercase in the name, and stop the value at `}` so the last declaration in
a block matches without a trailing semicolon. Verified all 12 cases: the
five previously-missed forms (same-line brace, two-per-line, inline style
attr, uppercase, digit) now match, and var() references — with and without
fallbacks — still do not.
Re-verified the guard fails on a real regression by injecting
`--node-user: red` into table-icon.svelte's style attribute (the form it
previously missed) and watching it break, then reverting.
Also document NON_COLOR_NODE_VARS: anything --node-* is a color unless
listed, so a future non-color var gets added or renamed deliberately rather
than silently failing the derivation assertion.
Prettier-formatted the test file (Prettier is outside quality:fix, which is
eslint + design-tokens + svelte-check, so it was not caught earlier).
Not doing here: renaming --node-indent to --node-spacing-* and deduping its
identical declaration in app.css and base-node-viewer.svelte. It is spacing,
not color, renaming touches call sites, and it is out of this PR's scope.
Tests: 247 files / 5081 passed. quality:fix clean.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Address Re-Review Summary — commit
|
| Finding | Action |
|---|---|
| 🟢 Regex blind spots | Fixed |
| 🟢 Prettier formatting | Fixed |
🟢 Rename --node-indent + dedupe |
Declined — see below |
Regex hardening
The reviewer was right that this was a real hole. The guard only matched declarations at a line start with a lowercase name, so five forms slipped past — and one is genuinely reachable: an inline style="--node-user: red" attribute, which is house style in seven icon components.
Now anchored to {, ; or a quote as well as a line start, allows digits/uppercase, and stops the value at } so a final declaration without a trailing semicolon still matches. Verified all 12 cases:
PASS SHOULD CATCH same-line brace / two per line / inline style attr
PASS SHOULD CATCH uppercase / digit in name
PASS SHOULD CATCH in .dark block / in media query / last decl no semicolon
PASS should IGNORE var() reference / var() w/ fallback / --node-indent / registry TS ref
ALL PASS
Then re-verified the guard actually fails, using the form it previously missed — injected --node-user: red into table-icon.svelte's style attribute:
× declares every --node-* color variable only in app.css
+ "src/lib/design/icons/components/table-icon.svelte declares --node-user: red"
Reverted after.
Also documented NON_COLOR_NODE_VARS so the maintenance answer is explicit: anything --node-* is a color unless listed, so a future non-color var gets added or renamed deliberately rather than silently failing the derivation assertion.
On the Prettier nit
Confirmed the reviewer's read: quality:fix is eslint --fix && quality:design-tokens && svelte-check — Prettier is in neither it nor the pre-push gate, so the earlier "quality:fix clean" claim was accurate and this was invisible drift. Formatted.
Declined: renaming --node-indent
It is spacing, not color; renaming touches call sites; and it is outside a color PR's scope. The reviewer's own framing — "arguably its own small issue rather than this PR's work" — matches. The duplicate is real though (app.css:237 and base-node-viewer.svelte:1503, identical values), and it is the same fragmentation pattern in a non-color var, so it is worth filing separately.
Verification
- Tests: 247 files / 5081 passed
- quality:fix: clean — 0 errors, 0 warnings, no new design-token violations
- Pre-push gate: passed (third consecutive clean run)
This round changed only test-internal regex and a comment — no production code, no logic — so no further re-review is needed. The substantive work was approved in the previous round.
Still open for human judgment
text node bullets now render teal instead of near-black. DESIGN.md:225/:345 say that is correct and it is what closes AC #5, but it is the most-seen visual in the app, so it deserves an eye before merge rather than my say-so.
🤖 Generated with Claude Code
Closes #2590.
Problem
Node-type accent colors had five disagreeing definitions, so the color a user saw depended on which component tree rendered the node.
DESIGN.mdis explicit that all node types share the singleprimaryaccent ("all types share a single accent intentionally").The issue listed three sources; two more turned up during the fix, and they were the most visually prominent:
app.cssbase-node-viewer.sveltenoderef.cssregistry.ts(not in issue)--node-projecthad no definition at all, so it always resolved to blue-graycircle-icon.svelte(not in issue)hsl(200 40% 45%)on its circles, ignoring thecolorprop the registry passed innoderef.cssis imported afterapp.cssin+layout.svelte, so its off-spec hues won the cascade app-wide — this was live in production, not dead code. And #5 is the node bullet in the tree, so it rendered blue-gray everywhere regardless of any variable.Changes
base-node-viewer.sveltenoderef.cssno longer defines any--node-*variable — it only consumes them#dc2626,#7c3aed,#ea580c,#0891b2) into one rule using the shared accent--node-*vars; added the missing--node-projectcircle-icon.sveltenow honors itscolorpropapp.cssis the single source of truth and derives each--node-*fromvar(--primary)rather than repeating the literal, so light/dark switching is automatic and the two cannot drift. This makes the.darknode-color block redundant, so it is removed.Verification
app.cssdefines any--node-*variable, and no trace of200 40% 45%/ "Scheme 3" remainsvar()indirection resolves correctly — including throughhsl(var(--node-*) / alpha), the one case that could silently break — in both themes: lightrgb(29,149,137), darkrgb(52,157,145)test:all+cargo build+ e2e) passed; frontend baseline was 246 files / 5078 testsNote for review
The four document subtypes (PDF/image/video/audio) previously had distinct left-border colors and now share one accent, so file type is conveyed by icon and label only. This is what the acceptance criteria asked for, but it does remove an at-a-glance distinction — flagging in case that warrants a
DESIGN.mdconversation rather than a silent flattening.🤖 Generated with Claude Code