Repository navigation
Add "Run in VS Code": model-check playground specs in a GitHub codespace - #23
Merged
Merged
Conversation
Open the repo in a codespace with the TLA+ VS Code extension, Java for TLC, every lesson exported as .tla/.cfg files and the tlaplus/Examples specifications, so learners can graduate from the in-page playground to the full tooling without installing anything. - scripts/export-lessons.mjs (npm run export-lessons): write each lesson's spec/cfg to lessons/<section>/<lesson>/<Module>.tla|.cfg, reusing src/lib/parse-lesson.ts via Node's type stripping (>= 22.18) - .devcontainer/devcontainer.json: Java 21, Node 24, tlaplus.vscode-ide; postCreate runs npm ci, exports the lessons and clones Examples/ - "Open in VS Code" navbar link on lesson and spec pages - README section and Navbar tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NEXT_PUBLIC_CODESPACES_REPO (default tlaplus/tla-by-example) and NEXT_PUBLIC_CODESPACES_REF let a fork or demo branch point the "Open in VS Code" button at its own devcontainer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the navbar's "Open in VS Code" link with a "Run in VS Code" button next to "Run TLC" (which still runs TLC in the browser). It copies the current spec, config and extra modules, including the learner's edits, as a one-line command and opens the codespace. Pasted into the codespace terminal, scripts/run-in-codespace.mjs writes the files to playground/<section>/<lesson>/, opens them in the editor and runs TLC with the extension's tla2tools.jar. The site and the codespace cannot talk to each other (codespaces.new links carry no data), so the files travel in the command as base64url JSON. File names follow the MODULE name, since TLC on disk requires it; folder and file names are validated before writing. The codespace now opens .devcontainer/WELCOME.md with these steps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The pasted command passed the spec as a program argument, which Linux caps at 128 KiB: SpecifyingSystems' command (~235 KB) failed in the codespace with "Argument list too long". Pipe the payload through the shell's builtin echo instead, which has no such limit, and read it from stdin as a stream (fs.readFileSync(0) fails with EAGAIN on large pipes on Linux). Also send only the extra modules the spec transitively EXTENDS or INSTANCEs, so the command stays short: the largest spec page goes from ~235 KB to ~62 KB. Add tests for the Playground button (copy, open, banner, dismiss) and for run-in-codespace.mjs: rejected folder/file names, bad payloads, and a 300 KB payload. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Ovidiu-Cristian Marcu <ovidiu@formalsystems.lu>
Collaborator
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.


What
Adds a Run in VS Code button next to Run TLC in every lesson and spec playground. It opens this repository in a GitHub codespace with the full TLA+ tooling and hands over the current spec and config, including the learner's edits.
.devcontainer/: Ubuntu with Java 21 (for TLC), Node 24, thetlaplus.vscode-ideextension, every lesson exported as.tla/.cfgfiles underlessons/, and a clone oftlaplus/Examples. A welcome page explains the flow.scripts/export-lessons.mjs(npm run export-lessons): writes each lesson's spec and config tolessons/<section>/<lesson>/<Module>.{tla,cfg}, reusingsrc/lib/parse-lesson.ts.echo <base64url payload> | node scripts/run-in-codespace.mjs. Pasted into the codespace terminal, it writes the files toplayground/<dir>/, opens them in the editor and runs TLC. Folder and file names from the payload are restricted to plain names, so a payload can't write outsideplayground/.NEXT_PUBLIC_CODESPACES_REPO/NEXT_PUBLIC_CODESPACES_REF, for testing from a fork. The default istlaplus/tla-by-example.Large specs
Linux caps a single program argument at 128 KiB, so the payload is piped in by bash's builtin
echoinstead of being passed as an argument, and the script reads it from stdin as a stream. Spec pages also send only the modules the spec transitivelyEXTENDS/INSTANCEs. The largest one, SpecifyingSystems, goes from about 235 KB to about 62 KB.Testing
npm test: 54 tests, including new suites for the handoff lib (module naming, sanitising, non-ASCII round-trip, module pruning), the Playground button (copy, open, banner, dismiss) andrun-in-codespace.mjs(rejected folder and file names, bad payloads, a 300 KB payload). Run on macOS and in anode:24-bookwormcontainer.tsc --noEmitandnpm run buildpass.Argument list too long.tla2tools.jar: a handed-over lesson spec model-checks with "No error has been found".🤖 Generated with Claude Code