Repository navigation
v3 Experiment Designer — v0.2 Editor (inspector edits, command CRUD, undo) - #63
Merged
Merged
Conversation
Sync with maDisplayTools origin/version3 (Lisa, 2026-05-26): - Pin reference SHA 00c8f95 → 649d7ef; defer to upstream yaml_protocol_documentation_v3.md as authoritative spec. - Add full_experiment_test_v3.yaml as a new round-trip fixture. Three syntactic typos in the upstream file fixed locally (missing `commands:` key on `start recording`, indent slip on a wait, unterminated `"controller` quote); upstream notification pending. - Note DAQThermometerPlugin, built-in `log` plugin, anchor-as- command_name, and pattern_ID auto-update in the spec doc. Phase 3 starter — inspector scalar editing: - New helpers docSet / nodeIsAliasAt / aliasNameAt in js/protocol-yaml-v3.js route edits through YAML.Document.setIn so anchors + comments survive every edit. - Inspector renders scalar command fields (wait.duration, controller fields, plugin params) as inline inputs with type coercion. - Anchor-bound scalars render as read-only `→ &name` chips with resolved values; full anchor binding UI deferred to Phase 5. - Dirty badge appears on first edit, cleared on import; banner and header reflect editor (not viewer) status; footer bumped to v0.2. Tests: 138/138 pass (Suite 8b adds 27 checks for Lisa's fixture; Suite 9 adds 14 checks covering docSet round-trip, alias detection, and comment-count preservation through edits). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Block selection in the Inspector now exposes editable controls for the four user-facing block fields: name (text), repetitions (number), randomize (checkbox), intertrial (dropdown from conditions + "(none)"). Edits flow through docSet / docDelete so the YAML.Document is mutated in place — anchors and comments survive every edit cycle. New js/protocol-yaml-v3.js helper docDelete(experiment, path) removes a key from both the YAML document (via .deleteIn) and the JS data model. Optional nullable block fields (name, intertrial) are restored to `null` in the JS model to match the parser's parse-time representation. Behavior: - Anchor-bound block properties (rare but allowed by the spec) render as read-only `→ &name` chips instead of inputs. - Clearing the name or intertrial removes the key from YAML entirely; setting randomize: false explicitly writes `false` (not delete) so user intent is preserved on round-trip. - Sequence card and timeline re-render on every commit so the randomize badge, reps label, intertrial row, and step count stay in sync with the Inspector. Tests: 154/154 pass (Suite 9 adds 16 checks covering reps/randomize round-trip, intertrial delete + reparse, name set/clear, and anchor + comment preservation through deletes). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds the missing pieces #6's "add command" UX will need so the editor can present a real plugin/command picker driven by Lisa's yaml_protocol_documentation_v3.md (2026-05-26), not free-text inputs. Registry additions: - BUILTIN_PLUGINS.thermometer — DAQThermometerPlugin (Lisa's daqPlugin branch, merged into version3). 4 commands: startContinuousLogging / stopContinuousLogging (added 2026-05-26 in dfbfd0b), get_temperature, log_temperature. Config fields: device_id, channels, thermocouple_type (default "K"), sample_rate (default 7 Hz), sample_duration (default 1.0 s), generate_plots. - LOG_PLUGIN — the always-available built-in `log` plugin (params: message required <=2000 chars; level: DEBUG/INFO/WARNING/ERROR, default INFO). Held separately from BUILTIN_PLUGINS because it's not declarable in a `plugins:` section. v3 lookup helpers (additive — v2 functions unchanged): - findPluginDefByClass(className) — locate registry entry by matlab.class instead of by plugin name, since v3 lets users name a plugin entry anything. - getCommandsForClass(className) — command schema map by class. - getV3PluginCommands(experiment, pluginName) — resolves pluginName → experiment.plugins[].name → .matlab.class → registry, with special "log" short-circuit. - listV3PluginNames(experiment) — ordered name list including "log". - getV3CommandParams(experiment, type, pluginName, commandName) — v3 equivalent of getCommandParams that routes through the experiment context. Tests: 183/183 v3, 137/137 v2 (no regression). Suite 10 adds 29 checks covering class lookup, custom plugin names resolving via class, "log"-always-available, controller / plugin / log param resolution. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Conditions are now buildable from scratch in the v3 editor. Each command card grows per-card actions (↑ move up, ↓ move down, ✕ delete); a "+ add" select at the bottom of the commands list appends a new wait, controller command, or plugin command with registry-driven default params. New helpers in js/protocol-yaml-v3.js: - docInsertCommand(exp, condIdx, atIdx, command) — splice into both the YAML.Document (via .createNode + items.splice) and the JS data model. Anchors and comments around the insertion point are preserved. - docMoveCommand(exp, condIdx, fromIdx, toIdx) — bounds-checked swap on both layers. No-op on equal indices or out-of-range values. Inspector additions: - Action buttons on each command card; ↑ disabled on first card, ↓ disabled on last, ✕ behind a confirm() until undo lands. - "+ add" picker with optgroups: Timing (wait) / Controller / Plugin: <name> per declared plugin / Plugin: log (always-available built-in). - buildCommandTemplate routes through plugin-registry.getV3CommandParams so a fresh plugin command starts with its required params (empty scalar fallback when the schema has no `default:`). Known follow-ups (not blocking): - level field for log.log renders as text input instead of a select (renderEditableField only switches between number/text — `select` schema entries need a third branch). - New YAML emitted by createNode uses bare scalars (type: plugin) rather than double-quoted strings (type: "plugin"); both parse identically. A stylistic-consistency pass can come later. Tests: 204/204 pass. Suite 11 adds 22 checks covering insert (middle + append), plugin command with nested params, move-to-end round-trip, command delete with anchor preservation, and bounds-checked move no-ops. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Each mutation (field edit, block property change, command add/move/delete) snapshots the YAML.Document text + current selection before applying. Ctrl+Z / Cmd+Z pops the latest snapshot and re-parses; the YAML.Document is the single source of truth so anchors, comments, and unknown keys all survive every undo/redo cycle. Ctrl+Y / Ctrl+Shift+Z redoes. Header gains ↶ Undo and ↷ Redo buttons (auto-enabled/disabled by stack state). Keyboard shortcuts skip when focus is inside an INPUT / TEXTAREA / SELECT so browser-native intra-field undo still works. Delete confirm() dialog removed — undo backs it up. Snapshot triggers: - Scalar field edits: on `change` event, only when value actually changes, snapshot pre-mutation state. (Originally tried snapshot-on- focus per the CLAUDE.md sketch; programmatic focus() doesn't reliably fire focus events in test environments and snapshot-on-change is cleaner anyway — no spurious snapshots from focus-without-change.) - Block property edits: on `change` when value changes. - Command add/move/delete: pushUndo() before the doc mutation. - Import: clears both stacks (no undo across imports). _restoring guard prevents focus events on re-rendered inputs from polluting the stacks during a restore. UNDO_LIMIT = 50 snapshots. Each snapshot is ~9KB for the canonical fixture; 50-deep is well under a megabyte and trivial in practice. Hooked up: - Undo/Redo buttons in header (left of the dirty badge) - Ctrl+Z / Cmd+Z / Ctrl+Y / Cmd+Y / Ctrl+Shift+Z keybinds - pushUndo() inserted before every docSet / docDelete / docInsertCommand / docMoveCommand call site Browser-verified end-to-end: edit/add/delete sequence with undo×3 walks back through all three pre-mutation states, redo×1 reapplies the top of the redoStack, export YAML reflects the live state with anchors and comments preserved. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Six fixes from the Codex diff review on the v3-rebuild branch.
Correctness
- extractSequenceEntry now rejects block `repetitions` that aren't
positive integers: `0`, negatives, and decimals (e.g., `1.5`) used
to be accepted silently and would either drop a whole block at
runtime or run a non-integer number of trials. Tests added for `0`,
`-1`, `1.5`, non-numeric strings, default-omit-to-1, and positive
integer accept.
- renderEditableField now rejects empty-string commits for numeric
fields. Previously `Number("")` === 0 (finite!) so clearing a field
and tabbing out silently committed zero. Now the field reverts.
UX safety
- `beforeunload` warning when `dirty` — protects against closing /
reloading with unsaved edits.
- Import-while-dirty triggers a confirm() before overwriting the
current experiment.
State coherence
- commitBlockEdit now also calls renderLibrary, so changing a block's
intertrial updates the library's usage counts immediately. Verified
in browser: clearing the training block's `intertrial: "baseline"`
drops `baseline` from 1× → 0× in the library badge.
Docs / pin consistency
- index.html v3 card: "Beta / Viewer" → "Beta / Editor (early)" and
description updated to reflect the v0.2 editor surface.
- docs/development/ROADMAP.md: pinned SHA 00c8f95 → 649d7ef (matching
v3-spec.md and the actual upstream HEAD as of 2026-05-26).
- tests/test-protocol-roundtrip-v3.js header: same SHA bump in the
module-level comment.
Tests: 210/210 v3 (+6 reps-validation checks); 137/137 v2; 10/10 arena
calc. All three suites still green.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR2 of the v3 designer plan: makes the inspector editable. Builds on the v0.1 viewer (#62) with five focused slices.
pattern/mode/duration/etc., waitduration, plugin params) are editable inline. Anchor-bound scalars render as read-only→ &namechips until the Variables editor lands (Phase 5).name,repetitions,randomize, andintertrial(dropdown from declared conditions).Ctrl+Z/Cmd+Z/Ctrl+Y/Ctrl+Shift+Zkeybinds. Anchors and comments survive every undo cycle.logplugin to the registry. New class-based lookup functions resolve plugin commands bymatlab.classrather than by name, so v3's user-named plugins work correctly.The editor mutates a
YAML.Documentin place, so anchors, comments, unknown future-compat keys, and pattern_ID values all survive any sequence of edits and round-trip exports.Pre-merge fixes from Codex review
Independent Codex review (standard + adversarial) plus Claude's own pass flagged a small batch of items, all addressed in the final commit:
repetitions(0 / negative / decimal / non-numeric) at parse time.beforeunloadwarning when there are unsaved edits.commitBlockEditre-renders the library so usage counts stay accurate after an intertrial change.index.html,ROADMAP.md, test file headers.Full reconciliation report kept at
.codex-review/report-20260527-105056.mdfor traceability (not committed — repo gitignores.codex-review/).Test plan
npm test— arena calc (10/10), v2 (137/137), v3 (210/210).v3_multi_block.yaml; editing one block's reps doesn't affect siblings.&def+*usein export.retry_on_fail,abort_if,max_retries_per_trialsurvive edit + undo + export.js/plugin-registry.jsis shared).Beta / Editor (early)label and updated description on the index card.Known follow-ups (post-merge)
selectschema fields render as text inputs, not<select>(affectsmode,gs_val,level).type: plugin) rather than quoted (type: "plugin"). Both parse identically; cosmetic only.plugin_name,command_name) and param add/remove not yet editable.yaml@2.9.0still loaded from jsDelivr CDN — vendor locally before lab/offline rollout.extractCommandrejects unknown commandtype:outright; forward-compat passthrough is a future improvement.🤖 Generated with Claude Code