Skip to content

fix(ark-ui): keep numeric TOML fields typed when saving from the editor#100

Merged
dakejahl merged 1 commit into
mainfrom
fix/toml-editor-number-fields
Jul 15, 2026
Merged

fix(ark-ui): keep numeric TOML fields typed when saving from the editor#100
dakejahl merged 1 commit into
mainfrom
fix/toml-editor-number-fields

Conversation

@dakejahl

Copy link
Copy Markdown
Contributor

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 framerate and bitrate are the only numeric fields in any shipped config, so they are the only ones affected today.

Problem

TomlEditor picks the input widget from the live value's type. Vue's .number modifier passes non-numeric input straight through, so clearing a number field assigns the string "", which flips the v-if chain to the text-input branch. Every keystroke after that is a string and toml.dump quotes it, producing framerate = "30". toml++'s value_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. convertTypes resolved paths via getFullPath, which compares nodes of the JSON.parse(JSON.stringify(...)) clone against this.config by identity — that never matches, so it always returned null and no coercion happened.

The same failure hit port earlier 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 convertTypes so the numeric coercion actually runs, and reject a blank number field rather than saving Number('') as 0.

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.

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.
@dakejahl
dakejahl merged commit c3b99dc into main Jul 15, 2026
1 check passed
@dakejahl
dakejahl deleted the fix/toml-editor-number-fields branch July 15, 2026 18:53
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.

Type mismatch between config.toml and main.cpp parser when set value from Web UI

1 participant