Skip to content

CODAP-1117: fix MobX constraint violations in DataSet extend block#2401

Draft
kswenson wants to merge 8 commits intomainfrom
CODAP-1117-dataset-mobx-compliance
Draft

CODAP-1117: fix MobX constraint violations in DataSet extend block#2401
kswenson wants to merge 8 commits intomainfrom
CODAP-1117-dataset-mobx-compliance

Conversation

@kswenson
Copy link
Member

@kswenson kswenson commented Feb 17, 2026

Summary

  • Replace 3 observable.box variables (_validationCount, _isValidCases, _isValidItemIds) in DataSet's .extend() block with plain variables + a single _caseValidationVersion observable counter (same pattern as Collection's _cacheVersion fix in PR CODAP-1117: fix MobX constraint violation in Collection.completeCaseGroups #2398)
  • Move invalidateCases() and invalidateItemIds() from views to actions, eliminating their runInAction() wrappers
  • Simplify _validateItemIds() by removing untracked() and runInAction() — plain variable check/set
  • Wrap self.selection.delete() in validateCases() with runInAction() since selection is an observable.set
  • Fix use-rows.ts reaction to always evaluate validationCount so MobX dependency tracking is maintained when isValidCases is no longer observable

Builds on PR #2398. Fixes CODAP-1117.

Test plan

  • TypeScript type check passes
  • All 259 test suites pass (2129 tests)
  • Manual smoke test: case table, graphs, hierarchical collections

🤖 Generated with Claude Code

kswenson and others added 8 commits February 14, 2026 23:58
Replace observable.map cache with observable version counters (per-key
and global) paired with a plain Map, so the getter never writes to an
observable. This follows the same pattern as observableCachedFnFactory
from PR #2377, avoiding the anti-pattern of modifying observables
during computed/view evaluation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Simplify cache-miss check (lint fix) and add note about running git
commands from the repo root to avoid v3/v3 path errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…roups

Replace 5 observable boxes with plain variables and a single version
counter to eliminate observable writes from within a computed/view.
Add invalidateCaseGroups() and invalidateCaseGroupsForNewCases() actions
so that the version counter is only incremented from action contexts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When undo restores deleted cases in multiple batches (insert + append),
the first batch triggers invalidateCases() but the second batch's
validateCasesForNewItems() would run completeCaseGroups() with incomplete
volatile state, signaling observers before data was fully rebuilt.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…Groups

When undoing "delete unselected cases", updateCaseGroups() can return an
empty newCaseIds array (because groupKeyCaseIds still has old mappings).
The APPEND path condition treated [] as truthy, appending nothing instead
of falling through to the REBUILD path. Check newCaseIds?.length instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The early return in validateCasesForNewItems (which skips additive
processing when a full rebuild is pending) means groupKeyCaseIds may
not be populated when prepareSnapshot() is called. Adding a
validateCases() call in prepareSnapshot() ensures caches are current.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…Cases

- Collection: test that invalidateCaseGroupsForNewCases([]) falls through
  to the REBUILD path instead of the APPEND path (which would append nothing)
- DataSet: test that addCases called while isValidCases is false (simulating
  undo of removeCases) correctly defers to full rebuild via validateCases()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace 3 observable boxes (_validationCount, _isValidCases, _isValidItemIds)
with plain variables and a single _caseValidationVersion observable counter,
following the same pattern used in the Collection fix. Move invalidateCases()
and invalidateItemIds() from views to actions, wrap selection cleanup in
runInAction(), and fix use-rows.ts reaction to maintain MobX dependency
tracking when isValidCases is no longer observable.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kswenson kswenson added the v3 CODAP v3 label Feb 17, 2026
@codecov
Copy link

codecov bot commented Feb 17, 2026

Codecov Report

❌ Patch coverage is 89.65517% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.18%. Comparing base (69dc918) to head (1483a07).

Files with missing lines Patch % Lines
v3/src/models/data/data-set.ts 88.46% 3 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (69dc918) and HEAD (1483a07). Click for more details.

HEAD has 16 uploads less than BASE
Flag BASE (69dc918) HEAD (1483a07)
cypress 16 0
Additional details and impacted files
@@                            Coverage Diff                             @@
##           CODAP-1117-collection-mobx-compliance    #2401       +/-   ##
==========================================================================
- Coverage                                  85.51%   57.18%   -28.33%     
==========================================================================
  Files                                        753      748        -5     
  Lines                                      41521    41443       -78     
  Branches                                   10247    10238        -9     
==========================================================================
- Hits                                       35507    23700    -11807     
- Misses                                      6001    17709    +11708     
- Partials                                      13       34       +21     
Flag Coverage Δ
cypress ?
jest 57.18% <89.65%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@kswenson kswenson force-pushed the CODAP-1117-collection-mobx-compliance branch from 69dc918 to 8f98f5c Compare February 25, 2026 20:33
Base automatically changed from CODAP-1117-collection-mobx-compliance to main February 25, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v3 CODAP v3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant