Skip to content

Add scoped data groups#511

Open
titouanmathis wants to merge 3 commits into
mainfrom
feature/data-scope
Open

Add scoped data groups#511
titouanmathis wants to merge 3 commits into
mainfrom
feature/data-scope

Conversation

@titouanmathis

Copy link
Copy Markdown
Contributor

Summary

  • add a DataScope component with inherited, isolated Data groups
  • support multiple keyed DataModel values inside a scope and expose frozen $data snapshots to computed/effect callbacks
  • coordinate immediate keyed hydration before notifying subscribers
  • limit Action targets to their nearest DataScope
  • document the new API and cover scope isolation, nesting, keyed updates, hydration, lifecycle cleanup, exports, and Action behavior

This implements the scoped/keyed foundation proposed in #510. Virtual data-bind:* multi-bindings, mutation helpers, transitions, and dynamic movement/group/key changes are intentionally deferred to follow-up work.

Validation

  • npm run test — 47 files passed, 300 tests passed, 3 skipped, 1 todo
  • npm run lint — passed with 15 pre-existing warnings and no errors
  • npm run build — passed
  • npm run docs:build — playground prebuild passed; the VitePress phase was stopped because it was too resource-intensive for the development server and was not rerun

Part of #510.
Related to #296.

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

Export Size

@studiometa/ui

Name Size Diff
DataBind 1.48 kB +783 B (+112.34%) 🔺
DataScope 683 B +683 B (+100.00%) 🔺
DataModel 1.55 kB +773 B (+99.10%) 🔺
DataEffect 1.61 kB +772 B (+92.23%) 🔺
DataComputed 1.63 kB +772 B (+90.19%) 🔺
Action 1.69 kB +577 B (+51.80%) 🔺
Unchanged

@studiometa/ui

Name Size Diff
AbstractFrameTrigger 1.74 kB -
AbstractPrefetch 366 B -
AbstractScrollAnimation 3.87 kB -
AbstractSliderChild 702 B -
Accordion 1.78 kB -
AccordionItem 1.66 kB -
AnchorNav 3.88 kB -
AnchorNavLink 3.77 kB -
AnchorNavTarget 125 B -
AnchorScrollTo 2.56 kB -
animationScrollWithEase 763 B -
CircularMarquee 506 B -
Cursor 650 B -
Draggable 1.61 kB -
Fetch 2.34 kB -
Figure 1.72 kB -
FigureShopify 1.98 kB -
FigureTwicpics 2.26 kB -
FigureVideo 1.87 kB -
FigureVideoTwicpics 2.44 kB -
Frame 3.47 kB -
FrameAnchor 1.84 kB -
FrameForm 1.92 kB -
FrameLoader 1.45 kB -
FrameTarget 1.75 kB -
FrameTriggerLoader 1.46 kB -
Hoverable 904 B -
LargeText 678 B -
LazyInclude 322 B -
Menu 2.33 kB -
MenuBtn 140 B -
MenuList 1.9 kB -
Modal 1.99 kB -
ModalWithTransition 2.09 kB -
Panel 2.38 kB -
PrefetchWhenOver 408 B -
PrefetchWhenVisible 417 B -
ScrollAnimation 4 kB -
ScrollAnimationChild 4.12 kB -
ScrollAnimationChildWithEase 4.72 kB -
ScrollAnimationParent 4.18 kB -
ScrollAnimationTarget 4.06 kB -
ScrollAnimationTimeline 4.12 kB -
ScrollAnimationWithEase 4.6 kB -
ScrollReveal 1.63 kB -
Sentinel 129 B -
Slider 3.65 kB -
SliderBtn 928 B -
SliderCount 753 B -
SliderDots 1.97 kB -
SliderDrag 269 B -
SliderItem 958 B -
SliderProgress 1.06 kB -
Sticky 771 B -
Tabs 1.38 kB -
Target 86 B -
Track 1.64 kB -
TrackContext 340 B -
TrackShopify 1.72 kB -
Transition 1.41 kB -
withDeprecation 166 B -
withScrollAnimationDebug 2.03 kB -
withTransition 1.39 kB -

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.79412% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.45%. Comparing base (bdbc84f) to head (7d58c48).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
packages/ui/Data/DataBind.ts 96.42% 2 Missing ⚠️
packages/ui/Data/DataScope.ts 98.52% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #511      +/-   ##
============================================
+ Coverage     77.46%   79.45%   +1.99%     
  Complexity      145      145              
============================================
  Files            93      100       +7     
  Lines          2698     3008     +310     
  Branches        454      532      +78     
============================================
+ Hits           2090     2390     +300     
- Misses          532      542      +10     
  Partials         76       76              
Flag Coverage Δ
unittests 79.45% <97.79%> (+1.99%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/eslint-plugin-ui/src/utils/ast.ts 74.57% <ø> (ø)
packages/ui/Action/ActionEvent.ts 100.00% <100.00%> (ø)
packages/ui/Data/DataComputed.ts 100.00% <100.00%> (ø)
packages/ui/Data/DataEffect.ts 100.00% <100.00%> (ø)
packages/ui/Data/DataModel.ts 100.00% <100.00%> (ø)
packages/ui/Data/utils.ts 100.00% <100.00%> (ø)
packages/ui/Data/DataScope.ts 98.52% <98.52%> (ø)
packages/ui/Data/DataBind.ts 98.30% <96.42%> (-1.70%) ⬇️

... and 13 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

Code Review

Risk: Low — no blocking issues; safe to merge aside from nits.

Adds a new DataScope boundary for inherited/isolated data groups, keyed scoped snapshots passed into computed/effect callbacks, and Action target resolution constrained to the nearest scope. The MR also updates docs and tests around nesting, hydration, teardown, exports, and Action behavior, but the scoped teardown path currently treats keyed subscribers as if they were keyed value sources.

Still open from earlier reviews (2 findings):

  • packages/ui/Data/DataScope.ts:104issue: Destroying a keyed source leaves stale data
  • packages/ui/Data/DataScope.ts:80issue: Freeze nested scoped values before exposing $data

Review usage: 241,368 in (183,808 cached) / 11,225 out tokens — $0.3582 (cloudflare-ai-gateway/gpt-5.4, thinking: medium)

Reviewed by @weareikko/code-review v0.8.2 for commit 7d58c48.

Previous review runs

Previous run archived 2026-07-15T14:58:31Z

Code Review

Risk: Medium — issues that should be addressed before merge.

Adds the new DataScope boundary for scoped/keyed Data groups, wires $data snapshots into computed/effect callbacks, and restricts Action target resolution to the nearest scope. The tests and docs cover the new scope behavior well, but two state-consistency bugs remain in DataScope's snapshot lifecycle.

1 issue found:

  • issuepackages/ui/Data/DataScope.ts:80 — Freeze nested scoped values before exposing $data

Still open from earlier reviews (1 finding):

  • packages/ui/Data/DataScope.ts:78issue: Destroying a keyed source leaves stale data

Review usage: 292,660 in (232,960 cached) / 13,232 out tokens — $0.4060 (cloudflare-ai-gateway/gpt-5.4, thinking: medium)

Reviewed by @weareikko/code-review v0.8.2 for commit 029cb32.

Previous run archived 2026-07-15T14:52:28Z

Code Review

Risk: Medium — issues that should be addressed before merge.

This MR introduces DataScope, adds keyed scoped propagation for the Data components, and restricts Action target resolution to the nearest scope. The added tests cover inheritance, nesting, hydration, and target scoping well. The lifecycle-cleanup part of the stated scope is still incomplete because destroyed keyed members can leave stale data behind in $data.

1 issue found:

  • issuepackages/ui/Data/DataScope.ts:78 — Destroying a keyed source leaves stale data

Review usage: 347,151 in (252,928 cached) / 14,587 out tokens — $0.5176 (cloudflare-ai-gateway/gpt-5.4, thinking: medium)

Reviewed by @weareikko/code-review v0.8.2 for commit 357a7f9.

Comment thread packages/ui/Data/DataScope.ts
Comment thread packages/ui/Data/DataScope.ts Outdated
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