Skip to content

Drop the unread assetStatuses field from AssetContext and document the provider contract - #3957

Draft
jeremywiebe wants to merge 7 commits into
mainfrom
jer/asset-context-cleanup
Draft

Drop the unread assetStatuses field from AssetContext and document the provider contract#3957
jeremywiebe wants to merge 7 commits into
mainfrom
jer/asset-context-cleanup

Conversation

@jeremywiebe

@jeremywiebe jeremywiebe commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Summary:

AssetContext carried an assetStatuses dictionary alongside setAssetStatus, and nothing ever read it (even in the original implementation). Every consumer in the codebase takes only setAssetStatus; the context isn't exported from the package, so there are no external readers either. Worse, publishing the record invited providers to keep statuses in React state — exactly the mistake that made the mechanism silently inert (fixed earlier in this stack).

The context is now report-only, and the bookkeeping contract that a provider has to implement is documented on it:

  • record the keys
  • treat "nothing registered" as settled
  • require every status to be true
  • keep statuses somewhere synchronously readabl
  • report completion at most once

The known gaps are documented there too — no way to unregister, and assets that register on a later pass.

No behaviour change. Also includes some renaming and rearranging in the same file for readability.

Both providers still hand-roll the same bookkeeping, with two different implementations of "settled". A follow-up will centralize that into a shared tracker owned by asset-context itself.

A future PR may re-work this so that the book-keeping is inside the AssetContext, where it should arguably be!

Issue: LEMS-4419

Test plan:

  • pnpm test
  • pnpm typecheck

@github-actions

Copy link
Copy Markdown
Contributor

npm Snapshot

Want to try this PR's changes before it merges? Comment /snapshot below and we'll publish an npm snapshot you can install right away.

@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Size Change: -29 B (-0.01%)

Total Size: 518 kB

📦 View Changed
Filename Size Change
packages/perseus/dist/es/index.js 202 kB -29 B (-0.01%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 20.6 kB
packages/keypad-context/dist/es/index.js 1 kB
packages/kmath/dist/es/index.js 6.31 kB
packages/math-input/dist/es/index.js 98.6 kB
packages/math-input/dist/es/strings.js 1.63 kB
packages/perseus-core/dist/es/index.item-splitting.js 13 kB
packages/perseus-core/dist/es/index.js 28 kB
packages/perseus-editor/dist/es/index.js 106 kB
packages/perseus-linter/dist/es/index.js 10.1 kB
packages/perseus-score/dist/es/index.js 9.86 kB
packages/perseus-utils/dist/es/index.js 403 B
packages/perseus/dist/es/strings.js 12.9 kB
packages/pure-markdown/dist/es/index.js 1.39 kB
packages/simple-markdown/dist/es/index.js 6.12 kB

compressed-size-action


const context: React.Context<Context> = React.createContext(defaultContext);
/**
* An internal React context for keeping track of whether a component is fully

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a pretty long comment, but it describes the full contract that was implied previously.

I think we should see if we can move most (all) of the book-keeping into this context, but I want to do that in a separate PR.

const AssetContext: React.Context<AssetContextValue> =
React.createContext(defaultAssetContext);

export default context;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming the object locally differently than what most imports name it causes confusion.

@jeremywiebe
jeremywiebe force-pushed the jer/zoomable-asset-context branch 2 times, most recently from a8a3482 to 5e3d787 Compare August 12, 2026 23:27
Base automatically changed from jer/zoomable-asset-context to main August 12, 2026 23:40
@jeremywiebe
jeremywiebe force-pushed the jer/asset-context-cleanup branch from a6dd669 to e9ebb6c Compare August 12, 2026 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant