Table of Contents

Preference Menu Dropdown

The Preference dropdown holds the application's display settings, and it is on the Main Panel. The server-backed ones are service-wide rather than per-account: one UserService singleton holds one UserConfig, saved to a single UserConfig.xml resolved against the process working directory, so every browser signed in to that service reads and writes the same values. The sign-in cookie carries a user-name claim that nothing outside the authentication endpoints reads, and no preference endpoint is keyed on an account.

The dropdown has two models: Language and Show Physics Options bind the appState store, hydrated from and written back through /api/preference/*, where the server keeps them on UserConfig; the CSV / CL Controller checkboxes bind the device-local useViewPrefs singleton, persisted in the browser's localStorage and never sent to the server.

Layout

  • Preference Menu Dropdown
    • Step Present Preference Button
      • Web application: the editor belongs to the Execution page's Step Info column, where a small icon button in the Step Properties panel header opens it as a modal next to the list it configures.
    • Graphic-Cache Dropdown
      • Web application: an entry of the Execution page's extended tool bar, under Meshed Geom ▾, which gathers the workpiece rendering-cache settings.
      • Its write is the one preference write that does not persist. POST /api/preference/graphic-cache clamps the requested size between the stored limits, assigns the three fields on the live UserConfig and returns, without calling UserService.SaveUserConfig(). The new value is service-wide and takes effect at once, but it reaches the file only when some later preference save writes the config out.
    • Language Selection SubMenu
      • The persisted value is UserConfig.LanguageCode; the web application reaches it through GET/POST /api/preference/language, whose response also names the language codes the server supports.
      • In the web application the parent row captions the current language and the sub-menu marks the active code. A successful switch flips the interface text at once, so the confirmation toast already reads in the just-picked language.
    • CSV Controller CheckBox
      • Web application only. The model is useViewPrefs().showCsvController — device-local, stored in the browser's localStorage, not in UserConfig. It is off by default.
      • Checking it adds the CSV Controller node to the General Setup page's Control Tree; unchecking removes it, moving the selection away first when that node is the selected one.
      • The caption under the box says whether the loaded project plays CSV — This project plays CSV, or Not used by this project — read from the referenced flag of GET /api/mech/csv-runner. Opening the dropdown fetches both runner snapshots in parallel, but the fetch is guarded on a loaded project: with none, neither request is made and both captions are cleared to blank. A snapshot that fails to arrive leaves its caption blank as well, so a blank caption states nothing about the project. The guard reaches the captions only — neither checkbox is disabled by it.
    • CL Controller CheckBox
      • The same, for useViewPrefs().showClController, the CL Controller Control Tree node and GET /api/mech/cl-runner.
    • Show Physics Options CheckBox
      • The model is UserConfig.ShowPhysicsOptions, reached in the web application through GET/POST /api/preference/show-physics-options.
      • The checkbox is disabled and unchecked if UserService.IsPhysicsLicensed is false: the GET returns the flag ANDed with the licence and the POST forces false without it.
    • Show Log Button
      • See Message Section.
      • It is not a Preference-dropdown entry: it sits on the menu bar's right side as an always-visible button that opens the Log Viewer page.

So the web application's Preference dropdown carries the Language submenu, the CSV Controller and CL Controller visibility checkboxes, and the Show Physics Options checkbox.

A server write that fails raises a negative toast and rolls the item back in appState, so the dropdown never shows a language or a physics flag the server did not take.

Source Code Path

See HiNC App Anatomy for git repository links.

  • wwwroot-src/src/components/AppMenuBar.vue — the Preference ▾ dropdown itself and the menu bar's Show Log button.
  • wwwroot-src/src/stores/appState.ts — the model of the two server-backed items, with the boot-time hydration and the write-back actions.
  • wwwroot-src/src/composables/useViewPrefs.ts — the device-local localStorage singleton behind the two controller checkboxes.
  • wwwroot-src/src/api/preference.ts — typed wrapper over /api/preference/language and /api/preference/show-physics-options.
  • wwwroot-src/src/api/csvRunner.ts, wwwroot-src/src/api/clRunner.ts — the referenced flag each controller caption reports.
  • wwwroot-src/src/components/controlTree/useControlTreeHost.ts — builds or omits the two controller nodes and rebuilds the tree when either checkbox flips.
  • wwwroot-src/src/i18n/en/menu.ts — the dropdown's labels and captions.
  • wwwroot-src/src/pages/LogViewerPage.vue — the page the Show Log button routes to.
  • Environments/PreferenceController.cs — the endpoints. The step-present, show-physics-options, language and execution-layout writes persist through UserService.SaveUserConfig(); the graphic-cache write is the exception, and returns without one.
  • Environments/UserConfig.cs — the persisted LanguageCode and ShowPhysicsOptions properties.
  • Environments/UserService.cs — owns the single UserConfig the service holds, writes it to UserConfigPath, and answers the physics licence check.
  • Program.cs — the one UserService registration behind every server-backed item here, and the configuration path it resolves against the process working directory.

See Also