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.
I tried to fix the mm/in problem in Grbl mode and mostly succeeded, after a lot of effort. The fundamental difficulty is that the units for Grbl's position reports depend on the $13 setting, and cncjs does not maintain up-to-date knowledge of that setting, nor does it synchronize that knowledge with its copy of that position state.
To make things work "mostly right", the pendant asks for the settings on startup and also tracks $13= commands that might be issued via the serial console. That works except in a rare circumstance. There is an additional complication that the pendant receives its initial state report prior to the settings response, which required some work to delay the handling of the initial state report.
There are still a couple of problems, which are related to one another:
One possible solution would be to disallow $13=1 when used with cncjs. That is a potential source of confusion for a user whose machine has that setting. It would be possible for cncjs to force the $13=0 setting, but that has its own problem in the case where you use both cncjs and other apps to drive the machine. But maybe that is okay considering how poorly most other Grbl senders handle units.
The best solution, from the standpoint of "just works", would be for the cncjs server app to keep track of $13 and synchronize its position state to the initial value of $13 and later changes.
Please feel free to reject this pull request if you think its too much of a can of worms. I'm submitting it as an example of the scope of the problem.