Skip to content

Add: experimental adaptive placeholder palette (light/dark per ancestor sample)#229

Merged
twschiller merged 3 commits into
mainfrom
worktree-cheeky-tickling-stroustrup
Jun 9, 2026
Merged

Add: experimental adaptive placeholder palette (light/dark per ancestor sample)#229
twschiller merged 3 commits into
mainfrom
worktree-cheeky-tickling-stroustrup

Conversation

@twschiller

@twschiller twschiller commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Sample each placeholder's ancestor backgrounds at insert time and pick a light or dark stripe palette so redactions on dark-themed pages (e.g. dark-mode GitHub) don't flare against the page chrome.
  • Gated behind a toggle in the Placeholder display section of the Options page; default off. Inline copy on the switch flags it as experimental (defaults/storage key may change). Also accepted as a placeholderAdaptivePalette reserved key in the build-time defaults file alongside optionsButton / runOnInactiveTabs / debugTrace.
  • PLACEHOLDER_STYLES now exposes its colors as CSS variables; placeholders sampled dark are stamped with data-abs-placeholder-palette="dark" and a single override block redefines the variables — no per-element inline styles.

How it picks the palette

pickPaletteFromAncestor walks up from the element being replaced, reads getComputedStyle().backgroundColor, skips backgrounds with alpha < 0.5 ("no info, keep walking"), and classifies the first opaque background by perceived brightness (Rec. 601, 0.5 threshold). Defaults to "light" when every ancestor is transparent.

Classification is cached via a module-local boolean in placeholder-adaptive-palette.ts so placeholder creation can read the toggle synchronously without a chrome.storage round-trip per redaction. rule-engine.start() primes the cache from storage and subscribes for updates.

Test plan

  • bun run check — clean
  • bun run test — 1919/1919 (10 new in placeholder-adaptive-palette.test.ts covering classifier + block + inline stamping; 3 new in load-default-overrides.test.ts for the reserved key)
  • bun run build — succeeds; background-purity guard still passes
  • Manual check: toggle on, load a dark-themed page (e.g. GitHub PR list in dark mode) — placeholders render with the dark palette
  • Manual check: toggle off — placeholders unchanged from current behavior

🤖 Generated with Claude Code

…or sample)

Sample each placeholder's ancestor backgrounds at insert time and pick a
light or dark stripe palette so redactions on dark-themed pages (e.g.
dark-mode GitHub) don't flare against the page chrome. Default off and
marked experimental in the Options page; also accepted as a
`placeholderAdaptivePalette` reserved key in the build-time defaults
file alongside `optionsButton` / `runOnInactiveTabs` / `debugTrace`.

PLACEHOLDER_STYLES now exposes its colors as CSS variables; placeholders
sampled as dark are stamped with `data-abs-placeholder-palette="dark"`
and a single override block redefines the variables — no per-element
inline styles.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agent-browser-shield-demo-site Ready Ready Preview, Comment Jun 9, 2026 2:37pm

Request Review

…pecs

- docs/install.md and install SKILL.md gain the new reserved key entry
  alongside optionsButton / runOnInactiveTabs / debugTrace.
- spec 0010 (Extension UI) FR-10 lists the new Experimental section and
  the adaptive-palette toggle.
- spec 0011 (Build-time customization) FR-3 adds placeholderAdaptivePalette
  to the reserved-key inventory and points at placeholder-adaptive-palette.ts
  under current implementation.
- defaults-overrides.example.json reflects the new key.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…tion

The toggle previously lived in a standalone Experimental section. Folding
it next to the existing Placeholder display radio group keeps related
placeholder controls together and drops a one-item section. Inline copy
on the switch retains the "experimental — defaults/storage key may
change" caveat so the disclaimer isn't lost.

Specs 0010/0011 and install.md now point readers to *Placeholder
display* as the toggle's location.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@twschiller twschiller merged commit e57004e into main Jun 9, 2026
7 checks passed
@twschiller twschiller deleted the worktree-cheeky-tickling-stroustrup branch June 9, 2026 14:43
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.

1 participant