Skip to content

Report mixed DoenetML versions to the containing page - #43

Merged
dqnykamp merged 3 commits into
Doenet:mainfrom
dqnykamp:mixed-version-warning
Jul 13, 2026
Merged

Report mixed DoenetML versions to the containing page#43
dqnykamp merged 3 commits into
Doenet:mainfrom
dqnykamp:mixed-version-warning

Conversation

@dqnykamp

@dqnykamp dqnykamp commented Jul 12, 2026

Copy link
Copy Markdown
Member

Implements #39.

Each document in an assignment carries its own DoenetML version, and every embedded viewer downloads and parses the multi-MB standalone bundle for its document's version — an assignment mixing versions multiplies that cost by the number of distinct versions on the page.

Two deliberate non-choices, per discussion on the issue:

  • No automatic normalization — rendering old documents with a newer DoenetML version could change their behavior; that stays the consumer's explicit choice (normalize version in the source; saved student state survives, as its hash deliberately ignores version).
  • Not just a console warning — invisible to the site's visitors. The condition is reported to the containing page through a new typed callback prop, and the page decides how (and whether) to display it:
<ActivityViewer
    source={source}
    reportWarningsCallback={(warnings) => {
        // warnings: ActivityViewerWarning[] — first member:
        // { type: "mixedDoenetmlVersions", versions: string[] }
    }}
/>

Reported once per distinct source analysis — not per render, not on callback-identity churn, and not repeatedly even when the host passes a fresh (new-but-equal) source object each render (deduped on the serialized warning content, the same sameness pattern propSetKey already relies on). A console.warn is still emitted for developers, and the README documents the cost and the normalization path.

Tests: vitest for the version collector (single doc / uniform collapse / mixed nested select in first-appearance order / empty container yields none); cypress component tests asserting the callback fires exactly once with the version list for a mixed assignment, still only once when the host re-renders with a fresh source object each render, and stays silent for a uniform one.

🤖 Generated with Claude Code

dqnykamp and others added 3 commits July 12, 2026 22:54
Implements Doenet#39.

Each document carries its own DoenetML `version`, and every embedded
viewer downloads and parses the multi-MB standalone bundle for its
document's version — an assignment mixing versions multiplies that cost
by the number of distinct versions. The viewer does not normalize
versions itself (that would change how older documents behave), and a
console warning alone is invisible to the site's visitors, so the
condition is reported to the containing page through a new
`reportWarningsCallback` prop (typed `ActivityViewerWarning[]`, fired
once per source analysis); the page decides how to display it. A
console.warn is still emitted for developers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The report effect keyed on the `warnings` memo's array identity, which is
rebuilt whenever a consumer passes a fresh (new-but-equal) `source` object
each render — the pattern `propSetKey` already tolerates. That re-fired the
`console.warn` and `reportWarningsCallback` on every render, breaking the
"once per source analysis" contract. Dedupe on the serialized warning
content via a ref so each distinct condition is reported at most once.

Add a vitest case for an empty container (no versions) and a cypress case
asserting the callback still fires exactly once when the host re-renders
with a fresh source object each render.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Align the public prop JSDoc with the actual behavior: dedup is on the
serialized warning content, so the callback fires once per distinct set
of warnings — not "once per source analysis" (equal-warning sources do
not re-fire).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dqnykamp
dqnykamp force-pushed the mixed-version-warning branch from 9a088f8 to eab70fc Compare July 13, 2026 03:55
@dqnykamp
dqnykamp merged commit a4a5853 into Doenet:main Jul 13, 2026
4 checks passed
@dqnykamp
dqnykamp deleted the mixed-version-warning branch July 13, 2026 04:00
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