Skip to content

feat: the solve page shows the model as math beside its YAML, typeset by mathspec and following each edit - #12

Merged
FBumann merged 1 commit into
feat/spec-editorfrom
feat/math-preview
Oct 12, 2026
Merged

FBumann merged 1 commit into
feat/spec-editorfrom
feat/math-preview

Conversation

@FBumann

@FBumann FBumann commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Prompt: Can the yaml editor be better and prettier?

Prompt: both

Note

The following content was generated by AI.

Beside the YAML editor (#11), the Solve page now shows the model as math. mathspec's to_markdown typesets it in the worker, and KaTeX renders it. The preview follows each edit, and dims the last good math under mathspec's message when an edit breaks the spec.

What it does, and how

Worker. solve.py gains typeset(spec), which returns {'markdown': to_markdown(spec)} or the refusal. The worker now takes {kind: 'solve'} or {kind: 'typeset'} messages. solver.ts sends both through the same queue, as solve() and typeset().

Preview (src/MathPreview.tsx). Typesetting needs Python, so the preview never loads it on a visit alone:

  • before Python is loaded, it offers Show the math;
  • after a solve, or that button, it typesets the spec half a second after the last edit;
  • a spec mathspec refuses keeps the last math it typeset, dimmed, under the refusal.

Renderer (src/renderMath.ts). marked renders the Markdown. $`…`$ and ```math go through KaTeX. A spec's descriptions reach this text, and a published archive is someone else's file. So raw HTML shows as text, a link shows as its words, and an image shows as its alt text. The renderer is its own chunk, loaded with the first typeset.

Layout. The editor and the preview sit side by side above 1000 px, and stack below that.

Sizes, vite build, gzipped: the main bundle is 199.7 KB and the Solve page's chunk 215.8 KB, both unchanged from #11. The renderer chunk is 91.4 KB, and KaTeX's fonts load as the math needs them.

What was verified, and how

Headless Chromium against a local build and a local publish of the showcase's scenarios in the live layout. specsolve 0.9.0 came from PyPI.

check result
page opened, nothing asked the preview offers "Show the math"; no worker started
Show the math 14.1 s, almost all of it loading Python; 45 KaTeX nodes, 11 display equations; headings Sets, Parameters, Variables, Definitions, Objective, Subject to, Definitions, Variable domains
== load edited to == 2 * load balance re-typeset with 2⋅load
== lod Constraint 'balance': 'lod' not found. above the earlier math, dimmed
Undo my edits refusal and dimming gone
a description holding '<img src=x onerror=…>' no img element; the tag shows as text; the handler never ran
a fresh tab: Solve, then nothing else the preview typesets on its own after the solve
solve, table editor, download (the #9 tests) published costs; the cheap_solar edit matches; the downloaded zip reads back with specsolve 0.9.0 at the published cheap_solar costs exactly

npm run build passes.

Not done
  • No preview before Python. mathspec's typesetter is Python, so the preview needs Pyodide. Visiting the page does not start the 38 MB download.
  • The symbols are mathspec's defaults. mathspec's typeset takes a symbol table, but the page passes none.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AAz2z9GVsHSQypiTUZyrY9


Generated by Claude Code

… by mathspec and following each edit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AAz2z9GVsHSQypiTUZyrY9
@FBumann
FBumann added this pull request to stack #13 October 12, 2026 12:00
@FBumann
FBumann merged commit 9ae19da into main Oct 12, 2026
2 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.

2 participants