Skip to content

Make WebSocket multiplexer configurable via Settings (experimental)#4527

Draft
aaryan359 wants to merge 3 commits intokubernetes-sigs:mainfrom
aaryan359:feature/websocket-multiplexer-setting
Draft

Make WebSocket multiplexer configurable via Settings (experimental)#4527
aaryan359 wants to merge 3 commits intokubernetes-sigs:mainfrom
aaryan359:feature/websocket-multiplexer-setting

Conversation

@aaryan359
Copy link
Contributor

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

  • Added an experimental setting to enable or disable the WebSocket multiplexer.
  • Persisted the user preference in application settings.
  • Updated WebSocket selection logic to respect user settings first, with fallback
    to the REACT_APP_ENABLE_WEBSOCKET_MULTIPLEXER environment variable.

Steps to Test

  • Toggled the WebSocket multiplexer setting on and off via the Settings page.
  • Verified that the user preference persists across page reloads.
  • Verified that when no user preference is set, the behavior falls back to the
    REACT_APP_ENABLE_WEBSOCKET_MULTIPLEXER environment variable.
  • Observed WebSocket behavior via browser developer tools to confirm the correct
    mode is used.

Screenshots (if applicable)

Screencast.from.2026-02-03.14-31-12.webm

Signed-off-by: aaryan359 <aaryanmeena96@gmail.com>
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 3, 2026
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: aaryan359
Once this PR has been reviewed and has the lgtm label, please assign sniok for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 3, 2026
@aaryan359
Copy link
Contributor Author

@illume, I implemented this. Can you please review the changes?

Copy link
Contributor

@illume illume left a comment

Choose a reason for hiding this comment

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

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 illume added this to the v0.41.0 milestone Feb 3, 2026
@aaryan359
Copy link
Contributor Author

@illume got it. I will update these changes shortly.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 3, 2026
aaryan359 and others added 2 commits February 4, 2026 02:24
Signed-off-by: aaryan359 <aaryanmeena96@gmail.com>
Signed-off-by: Aaryan meena <134821046+aaryan359@users.noreply.github.com>
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 3, 2026
@illume illume requested a review from Copilot February 4, 2026 11:24
Copy link
Contributor

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 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 enableWebsocketMultiplexer setting, persisted to localStorage.
  • Updated getWebsocketMultiplexerEnabled to 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.json metadata.

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;
}
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
}
}
// 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;
}
}

Copilot uses AI. Check for mistakes.
<Box>
<Switch
color="primary"
checked={enableWebsocketMultiplexer ?? true}
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
checked={enableWebsocketMultiplexer ?? true}
checked={enableWebsocketMultiplexer ?? false}

Copilot uses AI. Check for mistakes.
Comment on lines +59 to +61
* 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.
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
* 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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@illume illume left a comment

Choose a reason for hiding this comment

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

It looks like there’s some github checks failing.

Please take a look? Also at the open review comments?

@aaryan359
Copy link
Contributor Author

@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.

@illume illume marked this pull request as draft February 12, 2026 17:24
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 12, 2026
@illume
Copy link
Contributor

illume commented Feb 12, 2026

I converted this to draft. If you continue it, please take it off draft when it's ready to review again :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make websocket multiplexer a setting rather than just an environment variable

3 participants