Make WebSocket multiplexer configurable via Settings (experimental)#4527
Make WebSocket multiplexer configurable via Settings (experimental)#4527aaryan359 wants to merge 3 commits intokubernetes-sigs:mainfrom
Conversation
Signed-off-by: aaryan359 <aaryanmeena96@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: aaryan359 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@illume, I implemented this. Can you please review the changes? |
There was a problem hiding this comment.
Great, thanks for this. I will take a deeper look in the following days.
Can you please check the commit message? It should follow the git commit guidelines in the contributing guide. See git log for examples. We don’t use signed-off-by in the messages in this repo.
Also please check the failing github check. The tests are failing, you can update the snapshots with
npm run test — -u
|
@illume got it. I will update these changes shortly. |
Signed-off-by: aaryan359 <aaryanmeena96@gmail.com>
Signed-off-by: Aaryan meena <134821046+aaryan359@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR introduces an experimental “WebSocket Multiplexer” toggle in the Headlamp settings, intended to let users enable/disable the multiplexer (with persistence) and fall back to the REACT_APP_ENABLE_WEBSOCKET_MULTIPLEXER environment variable when no user preference is set.
Changes:
- Extended the Redux config state to include an optional
enableWebsocketMultiplexersetting, persisted tolocalStorage. - Updated
getWebsocketMultiplexerEnabledto support a user-setting override and changed the environment-variable default semantics to treat anything other than'false'as enabled. - Added an “Experimental Features” section and “WebSocket Multiplexer” switch in the General Settings UI, updated related Storybook snapshot and mocks, and tweaked
package-lock.jsonmetadata.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
frontend/src/redux/configSlice.ts |
Adds the enableWebsocketMultiplexer setting to the configuration state and initial settings persisted from localStorage. |
frontend/src/lib/k8s/api/v2/useKubeObjectList.ts |
Extends getWebsocketMultiplexerEnabled to accept an optional user setting and adjusts env-var default behavior. |
frontend/src/i18n/locales/en/translation.json |
Introduces translation keys for the “Experimental Features” section and WebSocket multiplexer description. |
frontend/src/components/App/Settings/__snapshots__/Settings.General.stories.storyshot |
Updates the Storybook snapshot to include the new “Experimental Features / WebSocket Multiplexer” UI. |
frontend/src/components/App/Settings/Settings.tsx |
Wires the new enableWebsocketMultiplexer setting into the General Settings page and renders the experimental section with a toggle and caption. |
frontend/package-lock.json |
Marks various dependencies as "peer": true in the lockfile, likely reflecting a tooling/npm metadata update. |
frontend/.storybook/baseMocks.ts |
Changes the /wsMultiplexer mock to return a JSON response instead of an error for Storybook scenarios. |
Files not reviewed (1)
- frontend/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // If user has explicitly set the setting, use that | ||
| if (userSetting !== undefined) { | ||
| return userSetting; | ||
| } |
There was a problem hiding this comment.
getWebsocketMultiplexerEnabled now accepts an optional userSetting, but no call sites pass this parameter (searching the codebase shows only zero-argument calls), so the user-configured "WebSocket Multiplexer" setting is never actually consulted and the behavior still depends solely on REACT_APP_ENABLE_WEBSOCKET_MULTIPLEXER. To make the setting effective and match the function’s documentation, wire the stored enableWebsocketMultiplexer value through to this helper (or have this helper read it) so that an explicit user preference overrides the environment variable.
| } | |
| } | |
| // Next, try to read the stored user preference (if any) | |
| if (typeof window !== 'undefined' && window.localStorage) { | |
| const stored = window.localStorage.getItem('enableWebsocketMultiplexer'); | |
| if (stored === 'true') { | |
| return true; | |
| } | |
| if (stored === 'false') { | |
| return false; | |
| } | |
| } |
| <Box> | ||
| <Switch | ||
| color="primary" | ||
| checked={enableWebsocketMultiplexer ?? true} |
There was a problem hiding this comment.
When enableWebsocketMultiplexer is undefined (i.e., the user has never set a preference), the switch renders as checked due to checked={enableWebsocketMultiplexer ?? true}, which presents the UI as "on" even if the environment variable currently disables the multiplexer. To avoid this confusing mismatch and better align with the "use env var when no user preference is set" behavior, consider deriving the initial checked state from the same logic that determines the effective default (e.g., using the env var–based helper) rather than hard-coding true for the undefined case.
| checked={enableWebsocketMultiplexer ?? true} | |
| checked={enableWebsocketMultiplexer ?? false} |
| * enableWebsocketMultiplexer enables the websocket multiplexer for optimized resource watching. | ||
| * This is an experimental feature. If not explicitly set by the user, respects the | ||
| * REACT_APP_ENABLE_WEBSOCKET_MULTIPLEXER environment variable. |
There was a problem hiding this comment.
The comment here states that enableWebsocketMultiplexer "If not explicitly set by the user, respects the REACT_APP_ENABLE_WEBSOCKET_MULTIPLEXER environment variable", but the current implementation of the settings state does not incorporate the env var at all—initialState.settings.enableWebsocketMultiplexer is taken solely from storedSettings. To avoid misleading documentation, either update this comment to describe only what this field stores, or adjust the surrounding logic so that the effective value truly falls back to the environment variable when no user preference has been recorded.
| * enableWebsocketMultiplexer enables the websocket multiplexer for optimized resource watching. | |
| * This is an experimental feature. If not explicitly set by the user, respects the | |
| * REACT_APP_ENABLE_WEBSOCKET_MULTIPLEXER environment variable. | |
| * enableWebsocketMultiplexer stores the user preference for enabling the websocket | |
| * multiplexer for optimized resource watching. This is an experimental feature. |
illume
left a comment
There was a problem hiding this comment.
It looks like there’s some github checks failing.
Please take a look? Also at the open review comments?
|
@illume, after the latest merge, these issues came up. I didn’t get enough time to fix them, but I’ll complete it very soon. |
|
I converted this to draft. If you continue it, please take it off draft when it's ready to review again :) |
Summary
This PR makes the WebSocket multiplexer configurable via the Headlamp UI instead of
only through the REACT_APP_ENABLE_WEBSOCKET_MULTIPLEXER environment variable.
This allows users to enable or disable the multiplexer at runtime and makes it
easier to debug WebSocket-related issues.
Related Issue
Fixes #4505
Changes
to the REACT_APP_ENABLE_WEBSOCKET_MULTIPLEXER environment variable.
Steps to Test
REACT_APP_ENABLE_WEBSOCKET_MULTIPLEXER environment variable.
mode is used.
Screenshots (if applicable)
Screencast.from.2026-02-03.14-31-12.webm