Skip to content

feat(prepare): students make a prediction, shown in Analyze - #337

Merged
jdpigeon merged 3 commits into
mainfrom
content/predictions
Nov 20, 2026
Merged

jdpigeon merged 3 commits into
mainfrom
content/predictions

Conversation

@jdpigeon

Copy link
Copy Markdown
Contributor

Why

Spec section 2 (docs/superpowers/specs/2026-11-19-instructional-content-design.md): students never committed to a prediction, so Analyze turned into pattern-hunting. They now pick one before collecting, and it reappears beside the matching graph.

Change

  • params.prediction. A Prediction is the condition pair, the measure (rt / accuracy / erp) and a direction. It is saved with the workspace through SetParams and SaveWorkspace.
  • Built-ins. Each prepare.ts has a prediction block: question, condition pair, measure, 3 options and a "what to look for" sentence. Protocol shows a "Make a prediction" radio card after "What we compare and measure". It is optional and never blocks Preview or Collect.
  • Custom. CustomPredictionCard sits under "Form a hypothesis" in the Overview step:
    • the student picks two of their own conditions, a measure (brain response only when EEG is on) and a direction;
    • the option labels are built from their condition names, and the hypothesis is shown as "Why:";
    • if a condition is renamed or removed, the card says the prediction needs an update instead of showing stale text.
  • Analyze. A compact "Your prediction" section at the top of the existing left column, on the matching tab only (ERP for brain response, Behavior for response time and accuracy). It shows one line and a collapsed "What to look for". With no prediction, one muted line links back to Prepare. There is no automatic verdict. Imported experiments show nothing.
  • utils/prediction.ts holds the logic: the offer, option wording, and the none / stale / set states.

Verification

  • New tests:
    • every built-in's prediction conditions are real marker labels, with distinct directions;
    • picking dispatches SetParams;
    • SetState round-trip keeps params.prediction;
    • Custom options come from the student's conditions, and a renamed condition makes the prediction stale;
    • Analyze shows the section on the matching tab only.
  • Full suite: npm test passes, npx tsc --noEmit is clean, eslint has no errors.
  • Storybook at 1366×768, no page overflow:
    • Protocol with a pick (Stroop);
    • Custom picked, needs-update and EEG-off;
    • Analyze Behavior with a prediction and ERP without one.
  • Dev app on this branch: throwaway workspace zz_predictions_fh, picked "Face dips lower than House around 170 ms".
    • appState.json saved {"conditions":["Face","House"],"measure":"erp","direction":"a<b"}.
    • After Home and reopening, the same option was still selected.
    • The workspace was deleted afterwards.

Not done

  • Analyze with a prediction was not seen in the dev app (a throwaway workspace has no recordings); Storybook and the component tests cover it.
  • Most of this was implemented by a subagent that hit a rate limit before opening the PR; the integrator reviewed it, finished the stories and verification, and opened this PR.

Built-ins offer 2-3 authored answers on the Protocol step; Custom builds
one from its own conditions beside the hypothesis. Saved as
params.prediction and shown in the matching Analyze tab's rail.
SetParams now replaces params, so a new workspace never inherits the
previous one's prediction.
Protocol stories start with a saved pick; a CustomPrediction story file
covers picked, not picked, stale (renamed condition) and EEG-off; Analyze
stories show the left-column section with and without a prediction.
CustomPredictionCard copy uses <div>, not <p>, so the global p rule's
18px size does not apply.
@jdpigeon
jdpigeon merged commit 8af3fc4 into main Nov 20, 2026
15 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