Skip to content

Conversation

deluan
Copy link
Member

@deluan deluan commented May 29, 2025

Summary

  • Added the DevUIShowConfig flag to expose configuration options through the UI and set its default to true
  • Included the new flag in the UI configuration injection so the front end can display the config tab when enabled
  • Registered the /config route and implemented the handler to list all configuration values with admin-only access
  • Updated the front-end default config to respect devUIShowConfig and added translations for the new tab
  • Modified AboutDialog to include the new “Configuration” tab for admin users, fetching data from the new endpoint
  • Redact sensitive information (APIKeys, Secrets) server-side

Testing

  • make test PKG=./...
  • npm run lint
  • npm run check-formatting
  • npm run test
  • npm run type-check

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @deluan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

As gemini-code-assist, I've reviewed this pull request which aims to enhance the 'About' dialog in the UI by adding a new tab to display the server's current configuration. This involves creating a new API endpoint on the server to expose the configuration (only to admin users), flattening the potentially nested configuration structure for easier display, and updating the frontend About dialog to fetch and present this data in a dedicated 'Configuration' tab, dynamically adjusting the dialog's size.

Highlights

  • New API Endpoint for Configuration: A new native API endpoint /config has been added to expose the server's current configuration settings. This endpoint is protected and only accessible to admin users.
  • Configuration Flattening Logic: The server-side implementation includes a flatten function using reflection to traverse the nested configuration structure and present it as a flat list of key-value pairs, making it suitable for display in the UI.
  • UI Integration in About Dialog: The frontend 'About' dialog has been modified to include a new 'Configuration' tab. This tab fetches the data from the new /config endpoint (if the user is an admin and the feature is enabled) and displays the flattened configuration settings in a table.
  • Feature Toggle and UI Responsiveness: A new development configuration option, DevUIShowConfig, has been introduced to control the visibility of the 'Configuration' tab in the UI. The About dialog's width is also dynamically adjusted when switching between the 'About' and 'Configuration' tabs for a smoother user experience.

Changelog

Click here to see the changelog
  • conf/configuration.go
    • Added DevUIShowConfig boolean field to the configOptions struct (line 115).
    • Set the default value for devuishowconfig to true (line 557).
  • server/nativeapi/config.go
    • Added a new file config.go to implement the /config native API endpoint.
    • Defined configEntry and configResponse structs for the API response format (lines 15-23).
    • Implemented a flatten function using reflection to convert the nested server configuration struct into a flat list of key-value pairs (lines 25-48).
    • Implemented the getConfig HTTP handler to fetch the server configuration, flatten it, sort the entries by key, and return it as JSON (lines 50-71).
    • Added admin user check to restrict access to the /config endpoint (lines 52-56).
  • server/nativeapi/config_test.go
    • Added a new file config_test.go for testing the /config endpoint.
    • Added a test to verify that non-admin users are rejected with StatusUnauthorized (lines 16-22).
    • Added a test to verify that admin users receive a StatusOK response and the configuration entries are sorted by key (lines 24-38).
    • Added a test to verify that flattened nested struct fields are included in the response (lines 40-57).
  • server/nativeapi/native_api.go
    • Added a call to n.addConfigRoute(r) to register the new configuration endpoint (line 64).
    • Added the addConfigRoute function which registers the /config/* GET route, conditional on the conf.Server.DevUIShowConfig setting (lines 201-205).
  • server/serve_index.go
    • Added "devUIShowConfig": conf.Server.DevUIShowConfig to the appConfig map, exposing the setting to the frontend (line 68).
  • server/serve_index_test.go
    • Added a test case to verify that the devUIShowConfig setting is correctly included in the frontend appConfig (lines 307-316).
  • ui/src/config.js
    • Added devUIShowConfig: true to the defaultConfig object, aligning with the backend default (line 33).
  • ui/src/dialogs/AboutDialog.jsx
    • Imported Tabs and Tab components from @material-ui/core (line 15).
    • Added state variables showConfigTab, tab, configData, and expanded to manage tab visibility, selection, data fetching, and dialog width (lines 95-100).
    • Modified the Dialog component to use fullWidth, maxWidth, and style props based on the expanded state to control dialog size (lines 129-135).
    • Added Tabs and Tab components to create the 'About' and 'Configuration' tabs, conditional on showConfigTab (lines 142-147).
    • Wrapped the existing 'About' content in a div with a hidden prop controlled by the selected tab (lines 148-210).
    • Added a new div containing a Table to display the configuration data (configData), conditional on showConfigTab and the selected tab (lines 211-227).
    • Mapped the configData?.config array to TableRow components to display each key-value pair (lines 215-223).
  • ui/src/i18n/en.json
    • Added new translation keys about.tabs.about and about.tabs.config for the tab labels (lines 502-505).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


Config flies unseen,
Now a tab, a list appears,
Settings brought to light.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request successfully introduces a new configuration tab in the About dialog, which is a valuable addition for administrators to inspect server settings. The backend work includes a new /config endpoint that flattens the server configuration using reflection, and the frontend integrates this data into a new tab with a smooth UI transition for dialog width.

Overall, the implementation is solid, with good test coverage for the new backend endpoint and appropriate UI updates. I've identified a couple of areas in the backend error handling that could be improved for robustness. No explicit style guide was provided, so feedback is based on common Go and React/JavaScript best practices.

Summary of Findings

  • Error Handling in server/nativeapi/config.go: Errors from json.Marshal (when serializing complex config values) and json.NewEncoder().Encode() (when sending the HTTP response) are currently ignored. This could mask issues and make debugging more difficult. It's recommended to log these errors.

Merge Readiness

The pull request is well-structured and the new feature is implemented effectively. However, there are a couple of medium-severity issues related to error handling in the new server/nativeapi/config.go file that should be addressed to improve robustness and debuggability. Once these are considered, the PR should be in good shape for merging. As a reviewer, I am not authorized to approve pull requests; please ensure further review and approval by authorized team members.

@deluan deluan requested a review from Copilot May 29, 2025 19:50
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a configuration tab in the About dialog while also flattening and exposing the server configuration via the /config endpoint. Key changes include updates to the UI translations and dialogs, additions to the server configuration and endpoints, and new tests ensuring that configuration properties (including the new DevUIShowConfig flag) are correctly exposed.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
ui/src/i18n/en.json Added new translation keys for "about" and "config" tabs.
ui/src/dialogs/AboutDialog.jsx Integrated a tabbed view in the About dialog for config.
ui/src/config.js Added the DevUIShowConfig property to the default config.
server/serve_index_test.go Added tests to verify the new config flag is propagated.
server/serve_index.go Updated the app config to include the new DevUIShowConfig.
server/nativeapi/native_api.go Registered the new /config endpoint for admin users.
server/nativeapi/config_test.go Added tests for admin/non-admin access and sorted config.
server/nativeapi/config.go Introduced a new endpoint for retrieving flattened config.
conf/configuration.go Updated defaults with a new configuration key for UI config.

deluan added 5 commits May 29, 2025 18:33
Signed-off-by: Deluan <deluan@navidrome.org>
Signed-off-by: Deluan <deluan@navidrome.org>
Signed-off-by: Deluan <deluan@navidrome.org>
Signed-off-by: Deluan <deluan@navidrome.org>
Signed-off-by: Deluan <deluan@navidrome.org>
@deluan deluan requested a review from Copilot May 29, 2025 23:31
@deluan deluan marked this pull request as ready for review May 29, 2025 23:32
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new “Configuration” tab in the About dialog for admin users, driven by a new devUIShowConfig flag, and implements a secured /config endpoint to expose application settings with redaction.

  • Add devUIShowConfig flag in server and UI defaults and expose it in the injected app config
  • Implement a native API getConfig handler with flattening, sorting, redaction, and comprehensive tests
  • Update the AboutDialog UI to support tabs (About + Configuration), fetch config data, and include new translations

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
ui/src/i18n/en.json Add English translations for the new “tabs” and “config” keys
resources/i18n/pt-br.json Add Portuguese translations for the new “tabs” and “config” keys
ui/src/config.js Enable devUIShowConfig default in UI configuration
conf/configuration.go Add DevUIShowConfig option and set its Viper default
server/serve_index.go Expose devUIShowConfig in the injected index.html appConfig
server/serve_index_test.go Add test to verify devUIShowConfig is included in index injection
server/nativeapi/native_api.go Register the /config route conditionally based on DevUIShowConfig
server/nativeapi/config.go Implement getConfig handler with flattening, sorting, and redaction
server/nativeapi/config_test.go Comprehensive unit tests for the config endpoint and redactValue
ui/src/dialogs/AboutDialog.jsx Refactor AboutDialog into tabs, add ConfigTabContent, fetch config
ui/src/common/SongInfo.jsx Minor strict-equality correction (=====)
ui/src/App.jsx Register config resource in React Admin for the new endpoint
Comments suppressed due to low confidence (1)

ui/src/dialogs/AboutDialog.jsx:297

  • The new Configuration tab UI in AboutDialog lacks dedicated unit or integration tests. Add tests to verify that the config tab renders correctly, respects devUIShowConfig, and successfully fetches and displays data.
const AboutDialog = ({ open, onClose }) => {

Signed-off-by: Deluan <deluan@navidrome.org>
@kgarner7
Copy link
Contributor

kgarner7 commented May 30, 2025

Recommendations:

  • Add DevAutoCreateAdminPassword and Prometheus.Password to sensitiveFieldsFullMask (these are passwords)
  • Put Dev* flags after the main tags (sorted)
  • Maybe add a way to just copy all the settings (for debug, or exporting to a file?)
  • Maybe gate the <Resource name="config" />, with admin?

Oh, and for dev, might be worth noting (it should be clear from the name, but may not) that these flags are subject for change/removal).

deluan added 5 commits May 30, 2025 19:37
Signed-off-by: Deluan <deluan@navidrome.org>
Signed-off-by: Deluan <deluan@navidrome.org>
Signed-off-by: Deluan <deluan@navidrome.org>
Signed-off-by: Deluan <deluan@navidrome.org>
Signed-off-by: Deluan <deluan@navidrome.org>
@deluan deluan force-pushed the uf7dcw-codex/add-config-tab-in-about-dialog branch from fdf45ad to 52bbfbe Compare May 31, 2025 00:05
@deluan deluan requested a review from Copilot May 31, 2025 00:06
Updated the formatTomlValue function to properly escape backslashes in addition to quotes. Added new test cases to ensure correct handling of strings containing both backslashes and quotes.

Signed-off-by: Deluan <deluan@navidrome.org>
@deluan deluan force-pushed the uf7dcw-codex/add-config-tab-in-about-dialog branch from 52bbfbe to 0d4d005 Compare May 31, 2025 00:07
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a new “Configuration” tab in the About dialog, backed by a server‐side /config endpoint with admin‐only access and redacted sensitive values, and allows exporting the current config as TOML.

  • Introduce devUIShowConfig feature flag (default true) throughout server and client
  • Register new /config API route and implement handler to return flattened, redacted config
  • Build a React tab in AboutDialog (admin only) showing config values, with TOML export and translations

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
ui/src/utils/toml.js Utilities to format and section config values into TOML
ui/src/utils/toml.test.js Extensive tests for TOML formatting and sorting
ui/src/i18n/en.json New translation entries for the Configuration tab
ui/src/i18n/pt-br.json Portuguese translations for the Configuration tab
ui/src/dialogs/AboutDialog.jsx New tabs, styling, and data fetching for config export
ui/src/config.js Default devUIShowConfig flag
ui/src/App.jsx Conditional registration of the config resource
ui/src/common/SongInfo.jsx Strict equality fix
server/serve_index.go & serve_index_test.go Inject devUIShowConfig into UI config & test
server/nativeapi/native_api.go Hook up the new config route alongside keepalive/insights
server/nativeapi/config.go & config_test.go Endpoint implementation, redaction logic & tests
conf/configuration.go Add and default DevUIShowConfig in viper settings
Comments suppressed due to low confidence (1)

server/nativeapi/config.go:24

  • [nitpick] The Prometheus.MetricsPath field is included in sensitiveFieldsPartialMask, but this may not be sensitive. Verify whether this field should be redacted or removed from the mask list.
"Prometheus.MetricsPath",

Signed-off-by: Deluan <deluan@navidrome.org>
@deluan deluan merged commit 6dd98e0 into master May 31, 2025
35 checks passed
@deluan deluan deleted the uf7dcw-codex/add-config-tab-in-about-dialog branch May 31, 2025 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants