Skip to content

Unify node-type accent colors to a single primary-based system - #2672

Merged
malibio merged 3 commits into
mainfrom
issue-2590-node-accent-colors
Sep 16, 2026
Merged

malibio merged 3 commits into
mainfrom
issue-2590-node-accent-colors

Conversation

@malibio

@malibio malibio commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

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.md is explicit that all node types share the single primary accent ("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:

# Location Problem
1 app.css Correct (teal), but repeated the literal value 16×
2 base-node-viewer.svelte Leftover "Subtle Tint System (Scheme 3)" blue-gray override
3 noderef.css Per-type rainbow hues + 4 hardcoded hex accents
4 registry.ts (not in issue) Blue-gray fallbacks; --node-project had no definition at all, so it always resolved to blue-gray
5 circle-icon.svelte (not in issue) Hardcoded hsl(200 40% 45%) on its circles, ignoring the color prop the registry passed in

noderef.css is imported after app.css in +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

  • Deleted the Scheme 3 override block in base-node-viewer.svelte
  • noderef.css no longer defines any --node-* variable — it only consumes them
  • Collapsed the four hardcoded per-document-type hex accents (#dc2626, #7c3aed, #ea580c, #0891b2) into one rule using the shared accent
  • Replaced the icon-registry blue-gray fallbacks with the matching --node-* vars; added the missing --node-project
  • circle-icon.svelte now honors its color prop

app.css is the single source of truth and derives each --node-* from var(--primary) rather than repeating the literal, so light/dark switching is automatic and the two cannot drift. This makes the .dark node-color block redundant, so it is removed.

Verification

  • Grep confirms no file outside app.css defines any --node-* variable, and no trace of 200 40% 45% / "Scheme 3" remains
  • Browser-verified that the var() indirection resolves correctly — including through hsl(var(--node-*) / alpha), the one case that could silently break — in both themes: light rgb(29,149,137), dark rgb(52,157,145)
  • Pre-push gate (test:all + cargo build + e2e) passed; frontend baseline was 246 files / 5078 tests
  • Design-token baseline ratcheted 251 → 247 for the removed hex literals

Note 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.md conversation rather than a silent flattening.

🤖 Generated with Claude Code

…#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]>
@malibio

malibio commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review: PR #2672 — Unify node-type accent colors

Review Type: Initial Review · Commit reviewed: 1559078d

Requirements Check

# Acceptance Criterion Status
1 "Scheme 3" block deleted from base-node-viewer.svelte ✅ (--node-indent correctly retained — spacing, not color)
2 noderef.css no longer defines --node-* ✅ Verified by grep
3 Hardcoded per-document-type hex accents removed ✅ All four collapsed into one rule
4 app.css is single source of truth ✅ Independently verified repo-wide, incl. packages/design-system/
5 All node types render the same primary-teal accent ⚠️ Partially — see Finding 2
6 No new Stylelint violations ✅ Baseline ratcheted 251→247, exactly the four removed literals
7 Passes quality:fix ✅
8 Tests pass ✅ 246 files / 5078 tests

Findings

🟢 Verified correct — the highest-risk claim holds

1. The .dark block deletion is safe — confirmed empirically.
📁 packages/desktop-app/src/app.css:562-573

There is a subtlety the commit message does not mention: --primary is declared inside @layer base, while the new --node-* block is unlayered. Reproducing that exact structure in a browser gives light rgb(29,149,137) / dark rgb(52,157,145), including through hsl(var(--node-*) / 0.1).

var() substitutes at computed-value time, per element. The :root block wins the cascade for --node-* (nothing else declares it), but its value resolves against whatever --primary computes to on that same element — and .dark lands on documentElement, which :root also matches. Source order and layer precedence are both irrelevant here because the two blocks set different properties and never compete.

🟡 Important

2. text, header, document icons render foreground color, not the unified accent.
📁 packages/desktop-app/src/lib/design/icons/registry.ts:77,86,95

These keep colorVar: 'currentColor'. color flows to the SVG at base-node.svelte:855; neither .node-icon (app.css:292) nor .node__indicator sets color, so it inherits hsl(var(--foreground)) — near-black light / near-white dark.

Previously circle-icon.svelte ignored the prop and hardcoded blue-gray, so this was invisible. Now that the prop is honored (correctly), these three diverge from the teal used by task/user/entity/date/project. text is the most common node type, so this is the default visual — and the one place AC #5 is unmet.

Principle: a type-color decision should read from the token system, not fall through to an unrelated inherited property.

3. circle-icon.svelte honoring its color prop is correct.
📁 circle-icon.svelte:31-38

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 CircleIcon imports are the unrelated Lucide icon.

4. A sixth definition of node colors was missed — dead, theme-broken.
📁 packages/desktop-app/src/lib/design/tokens.ts:18-60

nodeTypeColors / getNodeTypeColor hardcode the light-mode literal hsl(174 67% 35%) per type. The issue explicitly asked to check for "JS/TS logic that branches on node type to pick a color" — this is it. Zero consumers repo-wide. It is theme-broken by construction, violates DESIGN.md:347 ("don't use raw hsl() in component code"), and being .ts the Stylelint gate cannot see it. The same file carries getTokens()/getNodeTokens() marked "deprecated but kept for migration" — CLAUDE.md forbids both deprecation markers and migration scaffolding.

5. Nothing prevents recurrence — and #2589 does not cover it.
📁 packages/desktop-app/stylelint.config.js

Answering honestly: no. The gate catches a custom property assigned a raw literal, so re-adding --node-user: 200 100% 45% would be caught. But the failure mode here is redefinition — --node-user: var(--chart-3) in a second file passes every rule while re-fragmenting the system. Stylelint has no "this property may only be declared in this file" rule.

icon-registry.test.ts asserts only hasState/hasRingEffect/semanticClass, never colorVar — no test would have caught this bug or would catch its return.

🟢 Suggestions

6. --node-default is referenced but never defined.
📁 packages/desktop-app/src/lib/services/base-node-decoration.ts:480 — used bare with no fallback, resolves to nothing. Identical class of latent bug to --node-project.

7. Nit: new comments use British "colour" while the codebase uses American "color".

On the document-subtype flattening

Clearly 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.

Summary

A genuinely good change and a clear net improvement. The var(--primary) derivation makes drift structurally impossible; the .dark deletion is correct; the circle-icon fix repairs a component that ignored its own API.

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 tokens.ts (Finding 4), and three node types bypassing the token system (Finding 2).

Recommendation: REQUEST CHANGES — narrowly; every item is small and in-scope.

  1. Point text/header/document colorVar at the --node-* vars (closes AC Basic storage integration #5)
  2. Delete nodeTypeColors, getNodeTypeColor, getTokens, getNodeTokens
  3. Add --node-default: var(--primary)
  4. Add a test asserting single-definition + var(--primary), since Stylelint structurally cannot catch redefinition

🤖 Generated with Claude Code

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
@malibio

malibio commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator Author

Address Review Summary — commit 0bf8a3fd

✅ Addressed 5 of 5. Nothing skipped — every finding was small and in-scope.

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]>
@malibio

malibio commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator Author

Address Re-Review Summary — commit a76656e3

Re-review came back APPROVE with three 🟢 non-blocking findings. Took two, declined one.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unify node-type accent colors to a single primary-based system

1 participant