GeezerVison is showing github.com — id(web): isLightColor misclassifies 3-digit shorthand hex (#fff, #ff0) as dark — white label text on light cursor labels · Issue #846 · developing-today/code
id(web): isLightColor misclassifies 3-digit shorthand hex (#fff, #ff0) as dark — white label text on light cursor labels #846Labels app/idPackage/app: id (pkgs/ or apps/ in this repo)kind/bugSomething isn't working (prefixed form of the classic bug label) DescriptionProblem
isLightColor in pkgs/id/web/src/cursor-utils.ts:66-73 misclassifies CSS 3-digit shorthand hex colors as dark, no matter how light they are:
export function isLightColor(color: string): boolean {
const hex = color.replace("#", "");
const r = parseInt(hex.slice(0, 2), 16);
const g = parseInt(hex.slice(2, 4), 16);
const b = parseInt(hex.slice(4, 6), 16);
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
return luminance > 0.5;
}
For a 3-digit input the slices misalign: "fff" → r="ff"=255, g="f"=15, b=""=NaN, so the luminance is NaN and NaN > 0.5 is false.
Verified (verbatim function, node, on main 4f66baa)
isLightColor("#fff") → false (white — expected true)
isLightColor("#ff0") → false (yellow — expected true)
isLightColor("#000") → false (correct only by accident)
- Any non-hex input (e.g.
"red", "#gggggg", "") also silently yields NaN → false, with no distinction from a genuinely dark color.
Why it matters
isLightColor picks the label text color for remote cursors at pkgs/id/web/src/cursors.ts:352 and cursors.ts:431 (isLightColor(cursor.color) ? "#000" : "#fff"). A cursor color arrives from peers/server via cursor updates (cursors.ts:826, color: cursorUpdate.color) and is never validated to be 6-digit hex. A peer whose color is shorthand white/yellow gets white text on a white/yellow label background — the name label is illegible. The existing tests (cursor-utils.test.ts:162-203) cover only 6-digit forms (with and without #), so the gap is invisible to CI.
Acceptance criteria
isLightColor("#fff") === true, isLightColor("#ff0") === true, isLightColor("#000") === false — 3-digit shorthand is expanded per CSS rules (each digit doubled) before parsing.
- Malformed/non-hex input has a defined, tested behavior (e.g. treated as dark) instead of falling out of a
NaN comparison by accident.
- New cases added to
cursor-utils.test.ts; the existing cursor-utils suite still passes.
- Single-repo: the only copy of this helper is in developing-today/code
pkgs/id/web (checked the other three repos' clones — no other isLightColor).
Activitydeveloping-today-fleet commented on Nov 24, 2026
AUDIT-7 Lane 2 slice 3 — closing evidence. Verified against the issue body and merged implementation PR(s):
The issue had zero comments in the fresh pre-action read; this comment records the missing close evidence. added kind/bugSomething isn't working (prefixed form of the classic bug label) app/idPackage/app: id (pkgs/ or apps/ in this repo) on Nov 25, 2026
MetadataMetadataapp/idPackage/app: id (pkgs/ or apps/ in this repo)kind/bugSomething isn't working (prefixed form of the classic bug label) DevelopmentNo branches or pull requestsIssue actions
|