fix(ark-ui): keep numeric TOML fields typed when saving from the editor#100
Merged
Conversation
TomlEditor chose the input widget from the live value's type. Vue's
.number modifier passes non-numeric input through unchanged, so clearing
a number field leaves "" behind, which flips the v-if chain to the text
input and turns every later keystroke into a string. Saving then quotes
the value (framerate = "30"), and the toml++ readers in the C++ services
silently fall back to their defaults on a type mismatch.
Render from the types captured when the config loaded, so a number field
stays a number field. The convertTypes safety net meant to catch this
never ran: getFullPath compared nodes of the JSON deep clone against
this.config by identity, which never matches, so it always returned null.
Thread the path through instead and drop getFullPath. Reject a blank
number field rather than silently saving Number('') as 0.
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.
Summary
fixes #99
Numeric fields edited in the service config editor could be saved as quoted strings, which the C++ TOML readers silently ignore. rtsp-server's
framerateandbitrateare the only numeric fields in any shipped config, so they are the only ones affected today.Problem
TomlEditorpicks the input widget from the live value's type. Vue's.numbermodifier passes non-numeric input straight through, so clearing a number field assigns the string"", which flips thev-ifchain to the text-input branch. Every keystroke after that is a string andtoml.dumpquotes it, producingframerate = "30". toml++'svalue_or<int>does not coerce a string node, so the service silently uses its hardcoded default. Hence the intermittency in the report: type over the value without emptying it first and it saves correctly.The safety net meant to prevent exactly this never ran.
convertTypesresolved paths viagetFullPath, which compares nodes of theJSON.parse(JSON.stringify(...))clone againstthis.configby identity — that never matches, so it always returnednulland no coercion happened.The same failure hit
portearlier and was patched in the rtsp-server parser (de5422d) without addressing the root cause here, so it resurfaced on the remaining numeric fields. The other managers' configs are strings and booleans only, neither of which can hit the type swap, but the editor is shared — any numeric field added to them would.Solution
Render each field from the type captured when the config loaded, so a number field stays a number field through a transient empty value. Thread the path through
convertTypesso the numeric coercion actually runs, and reject a blank number field rather than savingNumber('')as0.Parser-side hardening is ARK-Electronics/rtsp-server#14. It is needed independently: configs already written with quoted values are on devices, and this fix does not repair them. The submodule bump follows once that merges.