Skip to content

fix(preferences): reject duplicate dictionary keys before saving - #54

Merged
heoblitz merged 2 commits into
toss:mainfrom
hyxx-su:fix/preferences-duplicate-dictionary-keys
Nov 24, 2026
Merged

heoblitz merged 2 commits into
toss:mainfrom
hyxx-su:fix/preferences-duplicate-dictionary-keys

Conversation

@hyxx-su

@hyxx-su hyxx-su commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Summary

In the Preferences dictionary editor, rename accent to theme when a theme row already exists, then click Save. The first value is silently lost. The duplicate check used the return value of Set.add(), which is the set itself even when the key is already present. Object.fromEntries() then kept only the last row for that key.

Check for an existing key before adding it to the set. The panel now shows the existing warning and keeps both rows available to edit. Once the keys are distinct, Save sends the full dictionary.

Changelog

The Preferences editor warns about duplicate dictionary keys before saving.

Test Plan

  • Ran script/test web. All checks passed, including all seven Preferences model tests and the panel asset check.
  • Ran script/build and launched the resulting Mac app with an isolated home directory. It answered necto-cli device list --json. The build skipped ExampleApp because no simulator was booted.
  • Exercised the built panels in Chromium with a mock device bridge, in light and dark modes. On main, Save sent one preferences.set request with {"theme":"blue"}. With the fix it sent zero requests and displayed the duplicate key. Changing the second key back to accent and saving sent one request with {"theme":"light","accent":"blue"}. A connected device and USB were not tested.

The screenshots show the editor immediately after clicking Save with two rows named theme.

Before After
Before in light mode After in light mode
Before in dark mode After in dark mode

@heoblitz
heoblitz merged commit 73e26f5 into toss:main Nov 24, 2026
7 checks passed
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.

2 participants