Skip to content

feat: SimView on the wasm engine - #37

Merged
Kinflou merged 1 commit into
masterfrom
feat/sim-view-on-wasm
Sep 3, 2026
Merged

feat: SimView on the wasm engine#37
Kinflou merged 1 commit into
masterfrom
feat/sim-view-on-wasm

Conversation

@Kinflou

@Kinflou Kinflou commented Sep 3, 2026

Copy link
Copy Markdown
Member

Stage 2 of the playground rewire. ui/view.ts (1148 lines) and ui/framelog.ts now drive the comline-simulator wasm instead of the TypeScript Wires / Session / Clock / Recorder.

How it maps

was now
Wires.get().call/setBehavior/tap/error/dead() sim.call() + advance + sim.result(), sim.set_behavior, sim.frames(), sim.connection_error/dead
model.ts ops sim.add_instance/add_connection/move_node/rename_node/remove_*/set_shape/resync_instance
SteppedClock / RealClock sim.step/advance/run/now/pending + a setInterval play loop in the view
Recorder / replayRecording sim.record_start/record_stop/load_replay (input capture is automatic in the facade)
encode/decodeSession new Sim(shape, link) / sim.link()
BEHAVIORS / BEHAVIOR_KINDS sim.behavior_catalog()
session-codec · faults · generic · framedecode folded into Sim

createSim mirrors sim.session_json() into a plain object for rendering and re-reads it after each mutation. The frame log polls sim.frames() / sim.describe_frame() after the clock advances (poll() appends the new rows) rather than subscribing to a Tap.

shape.ts and argsform.ts are untouched — pure form-building over the describe_project JSON. The SimView interface, DOM structure and CSS classes are unchanged; the app builds (editor wasm 932 KB + sim wasm 523 KB bundled).

Tests

44 green. Two view.test.ts cases rewritten for the discrete-event clock (both genuine wall-clock → virtual-clock shifts):

  • idle separator — now marks a gap in virtual time (driven by a delay behaviour), since in real mode virtual time only advances during a run() and wall-clock idle doesn't register.
  • stepped clock — steps once per event (request delivery, then the 300 ms-delayed response) instead of once, because the DES engine schedules even a zero-latency request delivery as an event.

Not yet

  • the script behaviour kind is filtered out of the picker until the scripted wasm is lazy-loaded (Stage 4)
  • the dead TS engine modules (engine.ts / generic.ts / transport.ts / model.ts / faults.ts / clock.ts / rng.ts / behavior.ts / session-codec.ts / record.ts / framedecode.ts) + runtime/ (vendored) + the drift-guard test are deleted in Stage 3

`ui/view.ts` and `ui/framelog.ts` now drive `comline-simulator` (Rust →
WASM) instead of the TypeScript `Wires` / `Session` / `Clock` /
`Recorder`.

- `createSim` holds a `Sim`, mirrors `sim.session_json()` for rendering,
  and drives it: a call is `sim.call()` → advance the clock (`run` in
  real mode, `step` / `advance` in stepped) → poll `sim.result()`.
- the frame log polls `sim.frames()` / `sim.describe_frame()` after each
  advance instead of subscribing to a `Tap`; `poll()` appends new rows.
- the play loop is a `setInterval` calling `sim.advance(32 × speed)`.
- record / replay: `sim.record_start` / `record_stop` / `load_replay`
  (input capture is automatic in the facade); `Recorder` gone from the
  view.
- behaviours: `sim.behavior_catalog()` for the picker; the `script` kind
  is filtered out until the scripted wasm is lazy-loaded.
- version-skew resync: `sim.resync_instance()`.

`shape.ts` and `argsform.ts` are unchanged — pure form-building over the
`describe_project` JSON. The `SimView` interface, DOM structure and CSS
classes are unchanged; the app builds, both wasms bundle (editor 932 KB
+ sim 523 KB).

Two `view.test.ts` cases rewritten for the discrete-event clock: "idle
separator" is now a *virtual*-time gap (a `delay` behaviour), and the
stepped-clock test steps per event (request delivery, then the delayed
response) rather than once. 44 tests green. The dead TS engine modules
+ their tests + the drift guard go in the next PR.
@Kinflou
Kinflou merged commit e7958d9 into master Sep 3, 2026
2 checks passed
@Kinflou
Kinflou deleted the feat/sim-view-on-wasm branch September 3, 2026 15:42
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