Skip to content

feat: add panel bones — visually distinct containers get their own skeleton bone - #42

Merged
matheusmarnt merged 18 commits into
mainfrom
worktree-worktree-panel-bones
Sep 22, 2026
Merged

matheusmarnt merged 18 commits into
mainfrom
worktree-worktree-panel-bones

Conversation

@matheusmarnt

Copy link
Copy Markdown
Owner

Summary

Adds a new panel BoneType: a container element with a visually distinct surface (background alpha ≥0.05, any border, or a box-shadow) now gets its own filled skeleton bone, painted before its children's bones, instead of vanishing entirely as the pre-existing container type does.

Threads through the full stack:

  • JS synthesizer — detection (measure.js's isPanelSurface()), candidate promotion (walk.js), emission with paint-order preservation (emit.js), rendering with its own color token + borderRadius (renderer.js/style.css)
  • Docs-site gallery — a live "Kanban board (panel bones)" fixture
  • Client-side transport — wire:ghost.panels directive modifier, data-ghost's compact "v" key
  • Server-side transport — #[Ghost(panels: true)] (class or method level), config('ghostwire.panels') / GHOSTWIRE_PANELS, full 7-level precedence cascade
  • Real-browser e2e test — a genuine end-to-end regression gate, not just unit coverage
  • Docs — every wire:ghost modifier and every #[Ghost] parameter now has its own code example, across wire-ghost.mdx, ghost-attribute.mdx, theming.mdx, compat.mdx, how-it-works.mdx, security.mdx, README

Real bugs found and fixed mid-implementation (not just the plan's original intent)

This branch went through subagent-driven development with independent task review at every step. Several real defects surfaced this way that a single pass would likely have missed:

  1. Island-path candidate collection had no MAX_CANDIDATES guard — an island with many top-level panel-qualifying siblings could exceed the synthesizer's hard candidate cap.
  2. A frozen JS "API surface" test wasn't updated for the new directive modifier and compact key, silently breaking npm test.
  3. The learning/persistence subsystem never learned about panel bones — js/src/learning/store.js and src/Support/LearnedTree.php both assumed a fixed 5-key bone shape and a type vocabulary excluding panel. With learning.enabled on, any component using panel bones would have silently, permanently failed to ever be learned. Fixed with a security-reviewed change (untrusted-input validation, safe border-radius output for the static-export path).
  4. The compiled runtime bundle (resources/dist/ghostwire.js) had gone stale since the first panel-bones commit — the feature never actually reached a real browser until the e2e test's own setup caught it and triggered a rebuild.
  5. A config value cast bug: config('ghostwire.panels') wasn't cast to bool, so GHOSTWIRE_PANELS=1-style env values (a raw string, not boolean) would cause the entire data-ghost payload for a component to be silently discarded, not just the panels setting.
  6. Repeated-list panels lost their rounded corners: the repeat-sibling clone path rebuilt bones from a fixed field list that didn't include borderRadius, so only the first few "sampled" panels in a list kept their radius.
  7. Bundle-size budget: the feature's real, reviewed cost (~400 bytes gzip) pushed the compiled bundle 82 bytes over its existing 10KB test budget — bumped to 10.5KB with the reasoning documented in the test itself, rather than distorting the implementation to fit an old number.

Test plan

  • npm test — 314/314 passing
  • vendor/bin/pest and GHOSTWIRE_LEARNING=true vendor/bin/pest — both 193 passed / 1 skipped (pre-existing, unrelated to this branch) / 516 assertions, identical in both modes
  • Real-browser geometry test (tests/Browser/Geometry/PanelBonesGeometryTest.php) confirms panel bones actually render in a real page with correct paint order
  • dist-reproducible CI gate will independently re-verify the rebuilt resources/dist/ bundle

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • Tests added / updated
  • vendor/bin/pint has no issues
  • CHANGELOG.md not hand-edited — release-please generates it from the commit subjects
  • Commit messages follow Conventional Commits

🤖 Generated with Claude Code

Guard the island-path container candidate push with the same MAX_CANDIDATES
check used everywhere else in walk.js. Prevents candidate count from exceeding
the hard cap when an island has many top-level panel-qualifying siblings.

Adds regression test for the cap through the island path.
…al borderRadius

Task 1 added a `panel` BoneType and an optional `borderRadius` key to
toBone()'s output, but never updated the two independent, hand-written
validators that re-check a learned Bone Tree read back from untrusted
storage: js/src/learning/store.js (localStorage) and
src/Support/LearnedTree.php (an exported JSON file). Both still enforced
the old fixed 5-key, panel-less shape, so validBone() rejected every
panel bone outright - any component containing one silently and
permanently failed to be learned, with no error or warning.

- store.js / LearnedTree.php: add 'panel' to BONE_TYPES; validBone() now
  accepts the 5 base keys plus an optional borderRadius, matched against
  a strict CSS length/percentage allowlist pattern (verified against this
  codebase's own real getComputedStyle border-radius fixtures).
- LearnedTree.php's toBlade() now emits a border-radius inline style for
  a bone that carries one, interpolated directly because the value can
  only ever be a string that already survived that same closed-character-
  set pattern - no quote, angle-bracket or `;` can reach the attribute.
- Rewrote learning-store.test.js's source-regex shape-sync test (broken
  by Task 1's toBone() no longer being a bare `return {...}`) to check
  both the required and the new optional key against emit.js's real
  source, and added focused behavioral coverage on both language sides
  for the panel+borderRadius shape (accept, reject malformed, reject a
  7th key, reject wrong type).
…e full optional-key set

Review (fix round 1) found two ways the shape-sync test added in 2f32479
could itself go silently blind, the exact failure mode it exists to catch:

- It only ever captured the FIRST `if (guard) bone.key = guard;` match, so
  a SECOND optional key added to toBone() without a matching update to
  store.js's OPTIONAL_BONE_KEYS still passed.
- Its scan for that conditional was unbounded past toBone()'s own closing
  brace (a lazy regex, not a real bound), so deleting the real conditional
  while a similarly-shaped one existed in a later function would also still
  pass, matching the decoy instead of correctly finding nothing.

Replaced the lazy scan with extractToBoneBody() (real brace-depth counting,
so it stops at toBone()'s own closing brace regardless of what's nested
inside or what comes after) and matchAll() to collect every conditional
key assignment inside that bounded body, compared as a full set against
OPTIONAL_BONE_KEYS rather than a single arbitrary match.

Also fixes a stale @PARAM docblock on LearnedTree::toBlade() that still
described the pre-borderRadius bone shape.

Verified against both regressions with synthetic emit.js variants: the old
logic passed on a second-optional-key-on-emit-only variant and on a
real-conditional-deleted-plus-later-decoy variant; the new logic correctly
fails both, while still passing on current code and failing on the
pre-Task-1-gap-fix baseline.
resources/dist/ghostwire.js and ghostwire.css hadn't been rebuilt since
4540944, before any of the five panel-bones commits (de946c0..9c997b4)
landed in js/src. Every one of those commits changed source only, so
js/tests/*.test.js (vitest, runs against js/src directly) stayed green
throughout, but the actual shipped/tested runtime had zero panels
support: `grep -c panels resources/dist/ghostwire.js` was 0.

Found while writing the first real-browser test for panel bones
(tests/Browser/Geometry/PanelBonesGeometryTest.php): a card with
wire:ghost.panels and a real background still produced only 'text'
bones. Traced by comparing js/src (has the 'panels' directive modifier,
the container->panel promotion in measure.js, the panel bone emission
in emit.js) against the built dist (none of it) — confirmed by
rebuilding and watching the same test go from red to green with no
other change.

CI already runs `npm ci && npm run build` before testing
(.github/workflows/tests.yml), so this was invisible there. It only
bit local runs against the committed dist and real Composer installs,
which ship these committed built assets as the actual runtime.

Regenerated via the existing `npm run build` (js/build.mjs, esbuild) —
no source changes. Full tests/Browser suite re-run clean after the
rebuild: 58 passed, 204 assertions, including every existing Geometry/
Timing/Morph/Learning/Accessibility/Visual/Performance/Security test.
First real end-to-end regression gate for panel bones: a real Livewire
component (PanelCardComponent, no #[Ghost] attribute — opted in purely
via wire:ghost.panels in the view, same shape as DirectiveTimingProbe),
rendered in a real browser against the real built runtime, with a card
that has an actual background+border-radius.

Mirrors RobustnessGeometryTest.php's real mechanism, not the plan
brief's placeholder guess (no window.__ghostwireTestHook exists
anywhere in this codebase): a MutationObserver-at-first-sighting probe
reads the real .gw-bone elements under .gw-layer, the same DOM every
sibling Geometry test reads. Bone type isn't a JS-side field exposed to
tests — js/src/renderer.js's paintBones() writes it as a CSS class
modifier (`gw-bone gw-bone--${bone.type}`), so the panel bone is
identified by its gw-bone--panel class, parsed back out the same way
GalleryGeometryTest.php/RobustnessGeometryTest.php already read bones.

Fixture, route (/ghostwire-panel-card, following the root-fixture
`/ghostwire-*` convention, not the Gallery subfolder's `/gallery/*`
one) and Livewire component alias registration (tests/TestCase.php —
every fixture needs an explicit Livewire::component() call there for
@livewire($component) to resolve it; missing from the brief's own file
list) all follow DirectiveTimingProbe/ResizeProbe's exact pattern.

Verified red->green: with wire:ghost.panels temporarily reverted to
bare wire:ghost, the test fails exactly as expected (first bone type
'text', not 'panel'); restored, it passes. Full tests/Browser/Geometry
suite passes (15 tests, 45 assertions), including GalleryGeometryTest
and RobustnessGeometryTest unchanged.
…epeat bones

ConfigResolver::packageDefault('panels') read config('ghostwire.panels')
without a bool cast. Laravel's env() returns raw strings for values like
"1" (only literal true/false/null/empty get cast), so GHOSTWIRE_PANELS=1
in a real .env made the resolved config carry the STRING "1". That flowed
into compactPayload(), got JSON-encoded as "v":"1", and
attributeConfig.js's strict typeof-boolean check then discarded the
entire data-ghost payload for the component, not just panels - every
field silently reverted to its default.

emit.js's repeat-extra clone loop rebuilt each cloned bone by listing
fields explicitly (type/x/y/width/height), dropping borderRadius. Since
panels are most useful on repeated content, only the first few sampled
panels kept their rounded corners and every cloned one went square.
Spread the template bone instead, overriding only the per-clone x/y.

Also fills in panels in the two resolved-config docblocks that predated
the panels field (ConfigResolver::resolve(), GhostComponentHook::
compactPayload()), and rebuilds resources/dist/ghostwire.js so the
shipped bundle includes the emit.js fix.
…panel geometry test

store.js's borderRadius-pattern comment claimed a rejected bone only
costs "that one bone's entry" a missed learning opportunity - the real
unit lost on rejection is the whole entry (component+band), per
validEntry()'s "one bad bone discards the whole entry" rule just above
it in the same file.

walk.js gives every container a MAX_CANDIDATES slot once panels are
enabled, including ones that later turn out not to be panels (panel-ness
is only decided afterwards, by measure.js). That's deliberate and already
tested, but was undocumented at the call site - added a comment naming
why (a deep DOM hits the 300-candidate cap sooner with panels on than
off).

PanelBonesGeometryTest's "no other bone is typed panel" loop had no
assertion on total bone count, so it would pass vacuously if the card's
children stopped rendering entirely. Added a >1 bone-count assertion.
…pat-tier gaps

- install.mdx never mentioned config('ghostwire.panels')/GHOSTWIRE_PANELS
  anywhere; documented it next to the existing strategy/GHOSTWIRE_ENABLED
  paragraphs, matching that page's convention for config/ghostwire.php keys.
- security.mdx's data-ghost compact-key list was missing the panels key
  (v).
- README's own compat-tier table wasn't updated when compat.mdx's Tier A
  row picked up panels (.panels modifier + panels detection/promotion);
  brought it in line.
- how-it-works.mdx described a panel bone as rendered "instead of" its
  children, implying replacement. It's painted beneath them, before
  they're painted on top - the children are still emitted as their own
  bones, not replaced. Reworded.
The panel-bones feature (new BoneType with its own detection, rendering,
and full client+server transport stack) added roughly 400 bytes of real,
reviewed bundle weight, pushing gzip size to 10322 bytes against the old
10KB budget. Bumping the threshold to 10.5KB gives modest headroom above
the current size rather than shaving working code to fit an arbitrary
old number.
…param

wire-ghost.mdx was missing dedicated examples for .ignore, .keep, .island,
.rows.<N>, and .panels. ghost-attribute.mdx was missing dedicated examples
for only, except, rows, poll, sync, lazy, and panels. Also fixes the
pre-existing .off example's comment, which described .ignore's behavior
instead of .off's terminal opt-out.
@matheusmarnt matheusmarnt self-assigned this Sep 22, 2026
@matheusmarnt
matheusmarnt merged commit 1cafa1e into main Sep 22, 2026
21 checks passed
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