webapp: load a replay script from the file system - #6
Open
macabeus wants to merge 1 commit into
Open
Conversation
The recorder panel could record and replay a script but never open one, so a script saved to disk was write-only. This adds a Load button backed by a new script-parser: the exact inverse of the serializer, sharing its button vocabulary (BUTTON_NAMES / buttonsFromString derive from the same BIT_TO_BUTTON_NAME table, so a name can't exist in only one direction). Parsing is strict on purpose: an unsupported statement is a per-line error shown in the panel, not a silent skip — a replay that dropped a line would "work" and desync. Comments are blanked in place so error line numbers survive, and a round-trip property test pins serialize∘parse = identity. Save and the "From recording start" origin are disabled while no snapshot exists, since both are meaningless before recording begins. docs/examples/klonoa-hidden-minigame.mjs is a real script to load: it boots Klonoa: Empire of Dreams holding A+B+RIGHT+L+R(+UP) and plays a few dodges of the hidden boot-menu minigame. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
The recorder panel could record and replay a script but never open one, so a script saved to disk was write-only. This PR closes the loop.
What's in it
script-parser.ts— the exact inverse of the serializer. It shares the serializer's button vocabulary (BUTTON_NAMES/buttonsFromStringderive from the sameBIT_TO_BUTTON_NAMEtable), so a button name cannot exist in only one direction.parse(serialize(segments)) = segments.docs/examples/klonoa-hidden-minigame.mjs— a real script to load: it boots Klonoa: Empire of Dreams holding A+B+RIGHT+L+R(+UP) and plays a few dodges of the hidden boot-menu minigame.Verification
pnpm test(57),check-types,lint,check-depsall clean.🤖 Generated with Claude Code