Repository navigation
feat(dialogs): redesign the state and transition editors, and merge dense edge labels - #139
Merged
Merged
Conversation
…ense edge labels The two editors become one vocabulary, drawn with the canvas's own code. Transition dialog - From → To is one row at the top, the edge itself; To used to sit at the far end of the dialog with every field between them. - Spaced by gaps: `.modal-row:last-of-type` zeroed the last row of each section, so Move sat flush against To. - Reserved symbols say what they mean in the Read menu (Σ — any symbol, ⊔ — blank cell); the value stays the bare symbol. - Move is a strip of arrows (← • →) with arrow-key navigation; the select stays the field the form reads. - A multi-tape rule is a table, one row per tape (read, write, move), with a key for the reserved symbols, instead of three stacked rows per tape. - A two-way head's Move sits under "Head"; Output gets its own heading after a Stack or Head section. The rule picker says "Copy from" when adding. - Focus starts on Read. State dialog - Titled Edit State, matching Edit Transition; the canvas context menu leads with Edit State (it said Rename, Configure on Moore/Mealy). - Start and Accepting are toggle chips; hiding Accepting no longer leaves the word "Accept" behind. - A Mealy state's outgoing outputs are a table (read, to, output). Previews (js/edit-preview.js) - Both dialogs end in a live drawing of what they will make, built from geometry.js's shapes, render.js's label writers and canvas.css's classes, so theme, label style, name wrapping, bends, badges and loops follow the diagram. The transition preview shows every rule on the edge with the one being edited marked, and the reverse edge that bends it. - labelRestPoint() shares placeLabel's first candidate rather than copying it. Dense edges - A label line is no longer one rule. edgeLabelLines() merges rules that differ only in the symbol read (`b, f, j → q3`; braced when a comma follows), wraps long lists evenly, and caps a label at four lines with `+k more`. Decided per edge at any machine size: four states over a 36-symbol alphabet drew every edge as a tower of characters, and the large-machine profile (a whole-machine performance line) never fires. - The canvas, the layout's label sizes, the preview and the label editor all read it. Double-click on a one-rule line edits in place; on a merged line or `+k more` it opens the dialog with exactly those rules. Fixes - 2DFA/2NFA/2DFT: saving a rule unchanged (dialog or label editor) added a `write` the machine does not have. - Moore and Mealy: an output missing from the menu was replaced by the first option on an untouched save. - mtm-classic.json: one rule carried a stray `symbol: "ε"`. Tests: tests/edit-dialogs.test.js saves every rule and state of every example through the dialogs unchanged and requires them back identical; tests/dense-edges.test.js pins the merge, wrap, cap and the readers' agreement.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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 state and transition dialogs become one vocabulary, end in a live preview drawn by the canvas's own code, and an edge carrying many rules stops drawing as a tower of single characters.
Transition dialog
.modal-row:last-of-typezeroed the last row of each section).Σ — any symbol,⊔ — blank cell).State dialog
Previews
Both dialogs draw what they will make with
geometry.js's shapes,render.js's label writers andcanvas.css's classes (newjs/edit-preview.js), so theme, label style, name wrapping, bends, accepting rings, Moore outputs and parity badges follow the diagram. The transition preview shows every rule on the edge, marks the one being edited, and draws the reverse edge that bends it.Dense edges
edgeLabelLines()decides what a label draws, per edge, at any machine size: rules differing only in the symbol read share a row (b, f, j → q3, braced when a comma follows), long lists wrap evenly, and past four lines the label ends in+k more. Four states over a 36-symbol alphabet (144 rules) never trips the large-machine profile, and drew every edge as a column of characters. The canvas, the layout's label sizes, the preview and the label editor all read it; double-clicking a merged line or+k moreopens the dialog with exactly those rules.Fixes
writefield these heads don't have (dialog and label editor alike).mtm-classic.json: one rule carried a straysymbol: "ε".Verification
npm test: 2890 pass. Newtests/edit-dialogs.test.jssaves every rule and state of every example through the dialogs unchanged and requires them back identical;tests/dense-edges.test.jspins merge, wrap, cap and that every reader agrees.npm run bench: no change beyond this machine's run-to-run noise (the untouched code showed the same spread).