-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add configuration tab in About dialog #4142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 theconfigOptions
struct (line 115). - Set the default value for
devuishowconfig
totrue
(line 557).
- Added
- server/nativeapi/config.go
- Added a new file
config.go
to implement the/config
native API endpoint. - Defined
configEntry
andconfigResponse
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).
- Added a new file
- 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).
- Added a new file
- 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 theconf.Server.DevUIShowConfig
setting (lines 201-205).
- Added a call to
- server/serve_index.go
- Added
"devUIShowConfig": conf.Server.DevUIShowConfig
to theappConfig
map, exposing the setting to the frontend (line 68).
- Added
- server/serve_index_test.go
- Added a test case to verify that the
devUIShowConfig
setting is correctly included in the frontendappConfig
(lines 307-316).
- Added a test case to verify that the
- ui/src/config.js
- Added
devUIShowConfig: true
to thedefaultConfig
object, aligning with the backend default (line 33).
- Added
- ui/src/dialogs/AboutDialog.jsx
- Imported
Tabs
andTab
components from@material-ui/core
(line 15). - Added state variables
showConfigTab
,tab
,configData
, andexpanded
to manage tab visibility, selection, data fetching, and dialog width (lines 95-100). - Modified the
Dialog
component to usefullWidth
,maxWidth
, andstyle
props based on theexpanded
state to control dialog size (lines 129-135). - Added
Tabs
andTab
components to create the 'About' and 'Configuration' tabs, conditional onshowConfigTab
(lines 142-147). - Wrapped the existing 'About' content in a
div
with ahidden
prop controlled by the selected tab (lines 148-210). - Added a new
div
containing aTable
to display the configuration data (configData
), conditional onshowConfigTab
and the selected tab (lines 211-227). - Mapped the
configData?.config
array toTableRow
components to display each key-value pair (lines 215-223).
- Imported
- ui/src/i18n/en.json
- Added new translation keys
about.tabs.about
andabout.tabs.config
for the tab labels (lines 502-505).
- Added new translation keys
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
-
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. ↩
There was a problem hiding this 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 fromjson.Marshal
(when serializing complex config values) andjson.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.
There was a problem hiding this 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. |
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>
There was a problem hiding this 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, respectsdevUIShowConfig
, and successfully fetches and displays data.
const AboutDialog = ({ open, onClose }) => {
Signed-off-by: Deluan <deluan@navidrome.org>
Recommendations:
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). |
Signed-off-by: Deluan <deluan@navidrome.org>
Signed-off-by: Deluan <deluan@navidrome.org>
Signed-off-by: Deluan <deluan@navidrome.org>
fdf45ad
to
52bbfbe
Compare
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>
52bbfbe
to
0d4d005
Compare
There was a problem hiding this 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 (defaulttrue
) 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 insensitiveFieldsPartialMask
, 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>
Summary
DevUIShowConfig
flag to expose configuration options through the UI and set its default totrue
Testing
make test PKG=./...
npm run lint
npm run check-formatting
npm run test
npm run type-check