NcCodeCommand Panel
The key model is NcCodeCommand.
The command carries two values: NcText, the NC program itself, and Title, the name that program runs under. Both are written into the project file — the command emits a title element and an NC-text element, and the project nests the whole command list into its own XML — so the program travels with the project instead of existing as a file beside it. That is the whole difference from Program File, which stores a path and leaves the program on disk. A mission can therefore carry a short program without producing an artifact of its own.
Title is not decoration. Run passes it to RunNc as the
program name the run log shows, which is why the model defaults it to the command's own name,
NC Code, rather than to an empty string. It is also the detail the mission row brackets: the row
reads NC Code while the title is empty or still that default, and NC Code [title] once it says
something else.
The panel renders on the command's own node under the Mission root of the Execution page's Control
Tree. The editor pane holds nothing but the editor: the command's move up / move down / duplicate /
delete buttons and its drag handle sit on its tree row, and the Add Command + sits on the row of
the list that holds it. A single-purpose kind like this one embeds its whole editor on that node
rather than growing section child nodes. Its tree checkbox only decides whether the run plays the
command; a disabled command is skipped during play — a caption above the title says so — and its
editor stays usable.
Layout
- NcCodeCommand Panel
- Title Field
- The model is Title.
- Labelled "Title (optional)". A newly added command arrives with the model's default name,
NC Code, already in the field; renaming it renames the program in the run log and in the mission row.
- NC Code Editor Area
- The model is NcText.
- A plain monospace text area: an 18-row field with a 360 px floor.
- No line-number gutter and no syntax highlighting. The rich editor in this folder is the Script command's — that command ships CodeMirror with a C# grammar, this one ships a text area.
- Stats and Actions Row
- Line count and character count, both recomputed as the text changes.
- Trim Blank Lines Button — trims every line and drops the ones left empty, then saves at once.
- Clear Button — confirms in a dialog before emptying the NC text.
- Both buttons stay disabled while the code is empty.
- Title Field
Saving
Typing in either field schedules one save 400 ms after the last keystroke, so a burst of typing costs one request instead of one per character. The title and the NC text share that timer, and the save carries every field edited since the last one. Trim Blank Lines and Clear save immediately rather than through that timer.
The write is a single patch endpoint carrying the NC text and the title. Each field is applied only when the body actually carries it, which is why the client sends the fields it edited and a null for the rest. The endpoint carries no content hash, so nothing on the server refuses a save that arrives late. After each save the tree relabels the command's node in place rather than rebuilding the branch, which would remount the editor mid-edit.
The panel snapshots its command path at mount, and every load and save targets that snapshot rather than the live selection. The path is an index-based entry path which every structural op re-points, so the panel hands the Control Tree host a switch gate that runs before the selection moves off the command and before every mission row op — move, duplicate, delete, drag, Add Command — wherever in the tree that op acts: the gate first lets a save already on the wire land, then sends the edit still waiting in the timer while the path is still the command's own. The gate is there because an op rebuilds the list it rewrites — a drag between two lists rebuilds the nearest list above both — and that rebuild re-mints the build stamp of every node under the rebuilt list. Only one command editor is ever mounted, the selected node's, and its mount key carries that stamp, so the editor remounts when its command sits inside the rebuilt list; the host does not ask whether it does before running the gate — an op in a list that does not hold this command leaves the editor mounted, and its staged edit is flushed all the same. A save that fails refuses the op, and the host drops it with a notice. Unmount cancels the timer instead of flushing it, so no save from a retired instance can land on whichever command has slid into its path. Selection and the tick checkboxes are read-only while a row op is in flight, and equally while a tick's own PUTs are on the wire: the host holds one busy gate for both, so an enable toggle refuses a selection change and ignores further ticks until its writes have landed, exactly as a row op does.
NC text is not validated while it is edited: there is no parse at edit time and no error surface on the panel — the server stores whatever string arrives. Errors surface when the mission plays the text.
Source Code Path
See HiNC App Anatomy for git repository links.
Web Application
HiNC-2025-webservice (Quasar CLI SPA):
wwwroot-src/src/components/mission/NcCodeCommandPanel.vue— this panel: the Title input, the 18-row monospace text area, the 400 ms debounced saves, the live line and character stats, Trim Blank Lines, and Clear behind a confirm dialog; the path snapshot taken at mount, the switch gate that waits for a save on the wire and then drains the timer, and the unmount that cancels rather than flushes.wwwroot-src/src/components/controlTree/MissionCommandSlavePanel.vue— the command node's slave panel: mounts this editor on the entry path, forwards its switch gate to the host, and shows the disabled caption above the title.wwwroot-src/src/components/controlTree/PrimarySlavePanel.vue— mounts the one editor pane, the selected node's, under a key that carries the node's build stamp; a rebuild that re-mints the stamp remounts it.wwwroot-src/src/components/controlTree/ControlTreePanel.vue— the tree rows: the drag handle and the move / duplicate / delete buttons on the command's row, and the Add Command+on the row of its list.wwwroot-src/src/components/controlTree/useControlTreeHost.ts— funnels every selection change and every mission row op through the active panel's switch gate; holds the one busy gate that keeps selection and the tick checkboxes read-only while a row op, or a tick's own PUTs, are in flight; a refused gate drops the op with a notice, and a save relabels the command's node in place.wwwroot-src/src/components/controlTree/missionItemTypes.ts— maps thenccodekind to this panel, and states the rule it belongs to: a single-purpose kind embeds its whole editor on the command node; mints the per-build stamp every command node under a rebuilt list carries.wwwroot-src/src/api/mission.ts—loadNcCodeandsetNcCode, and the command shape the panel edits (NC code plus title).wwwroot-src/src/i18n/en/mission.ts— the panel's wording: the NC Code label, the character count, Trim Blank Lines, and the line count it shares with the other panels.wwwroot-src/src/i18n/en/common.ts— the shared strings the panel borrows: the “Title (optional)” label on the Title Field and the Clear button's label.wwwroot-src/src/i18n/en/dialog.ts— the Clear confirmation's title and message.wwwroot-src/src/i18n/en/tree.ts— the disabled caption and the notice a refused gate raises on a row op.Missions/MissionController.cs— the single patch PUT for this command, whose NC-code and title fields are each applied when the body carries them, and the command-snapshot arm that returns both back to the panel.
HiAPI Engine
HiNc/SessionCommands/NcCodeCommand.cs— the model:NcText,Titledefaulting to the command's own display name, the Program-category catalog registration, the XML round-trip that puts the NC text into the project file,Runhanding text and title to the session shell, and the row-label rule that shows the bare name while the title is unset or still the default.HiNc/MachiningProcs/SessionShell.cs—RunNctakes the NC text plus an alternative file name, and that name is the title this command supplies for the log.HiNc/MachiningProcs/MachiningProject.cs— nests the command list into the project XML, which is how this command's NC text persists with the project.
See Also
- NcFileCommand Panel — the other NC program command among the three kinds the Program catalog category holds (Program File, NC Code, Script): a path to a file instead of text stored in the project
- Script Command Panel — the rich editor this folder does have, and why this command ships a plain text area instead
- Playing a Program — the task the two NC program commands, Program File and NC Code, serve; the Script command has its own manual page
- Mission — the rest of the command panels