[PR #23759] fix(ui): prevent showControls cross-tab state leak via localStorage #66214

Open
opened 2026-05-06 12:26:59 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/23759
Author: @AKIB473
Created: 4/15/2026
Status: 🔄 Open

Base: devHead: fix/show-controls-cross-tab-leak-dev


📝 Commits (1)

  • 75e5c59 fix(ui): prevent showControls cross-tab state leak via localStorage

📊 Changes

2 files changed (+6 additions, -6 deletions)

View changed files

📝 src/lib/components/chat/Navbar.svelte (+3 -1)
📝 src/routes/(app)/+layout.svelte (+3 -5)

📄 Description

Pull Request Checklist

  • Target branch: This PR targets the dev branch.
  • Description: Concise description provided below.
  • Changelog: Changelog entry included below.
  • Documentation: No user-facing docs change needed — this is an internal UI state bug.
  • Dependencies: No new or changed dependencies.
  • Testing: Manually verified — steps to reproduce the issue and confirm the fix are included below.
  • Agentic AI Code: This PR was written and reviewed by me. I traced the bug, understood the root cause, and made the minimal surgical change.
  • Code review: Self-reviewed.
  • Design & Architecture: No new settings introduced. Ephemeral UI state (Artifacts, Citations) no longer bleeds into localStorage.
  • Git Hygiene: Single logical change, rebased on dev.
  • Title Prefix: fix prefix applied.

Description

Fixes #23232.

Opening an Artifacts preview in one tab silently set localStorage.showControls = 'true'. Any new tab navigating to Home would then read that value on mount and auto-expand the Controls panel without any user interaction.

Root cause

(app)/+layout.svelte subscribed to the showControls Svelte store unconditionally:

showControls.subscribe((value) => {
    localStorage.showControls = value ? 'true' : 'false';
});

This persisted every mutation — including programmatic showControls.set(false) calls from Artifacts.svelte and showControls.set(true) from Citations.svelte / ContentRenderer.svelte. Those writes propagated to every other tab via shared localStorage.

Fix

Remove the unconditional subscriber from the layout. The layout still reads localStorage.showControls once on mount to restore the user's preference. Persistence is now written only in Navbar.svelte, inside the Controls button's on:click handler — so localStorage only reflects deliberate user toggles.

Files changed

  • src/routes/(app)/+layout.svelte — removed showControls.subscribe() that was writing to localStorage
  • src/lib/components/chat/Navbar.svelte — added explicit localStorage.showControls write on user click

Steps to reproduce (before fix)

  1. Open Open WebUI in Tab A
  2. Start a chat and trigger an Artifacts preview (any code/HTML artifact)
  3. Open Tab B → navigate to Home
  4. Observe: Controls/Advanced Settings panel auto-expands in Tab B with no user action

After fix

Tab B opens with Controls panel collapsed, regardless of what Tab A did programmatically.


Changelog Entry

Fixed

  • Fixed cross-tab UI state leak where opening an Artifacts preview in one tab would cause the Controls/Advanced Settings panel to auto-expand in other tabs. showControls is now only persisted to localStorage on explicit user interaction, not on programmatic store mutations from Artifacts or Citations components.

Additional Information

  • Related to the general principle noted in the PR template: ephemeral UI logic should use local state, not shared storage.

Screenshots or Videos

N/A — the fix is a state management correction with no visual change to the Controls panel itself.

Contributor License Agreement


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/23759 **Author:** [@AKIB473](https://github.com/AKIB473) **Created:** 4/15/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `fix/show-controls-cross-tab-leak-dev` --- ### 📝 Commits (1) - [`75e5c59`](https://github.com/open-webui/open-webui/commit/75e5c594f1d0bcb7f1c1ee29c23379ac533067b5) fix(ui): prevent showControls cross-tab state leak via localStorage ### 📊 Changes **2 files changed** (+6 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `src/lib/components/chat/Navbar.svelte` (+3 -1) 📝 `src/routes/(app)/+layout.svelte` (+3 -5) </details> ### 📄 Description <!-- ⚠️ CRITICAL CHECKS FOR CONTRIBUTORS (READ, DON'T DELETE) ⚠️ 1. Target the `dev` branch. PRs targeting `main` will be automatically closed. 2. Do NOT delete the CLA section at the bottom. It is required for the bot to accept your PR. --> # Pull Request Checklist - [x] **Target branch:** This PR targets the `dev` branch. - [x] **Description:** Concise description provided below. - [x] **Changelog:** Changelog entry included below. - [ ] **Documentation:** No user-facing docs change needed — this is an internal UI state bug. - [x] **Dependencies:** No new or changed dependencies. - [x] **Testing:** Manually verified — steps to reproduce the issue and confirm the fix are included below. - [x] **Agentic AI Code:** This PR was written and reviewed by me. I traced the bug, understood the root cause, and made the minimal surgical change. - [x] **Code review:** Self-reviewed. - [x] **Design & Architecture:** No new settings introduced. Ephemeral UI state (Artifacts, Citations) no longer bleeds into localStorage. - [x] **Git Hygiene:** Single logical change, rebased on `dev`. - [x] **Title Prefix:** `fix` prefix applied. --- ## Description Fixes #23232. Opening an Artifacts preview in one tab silently set `localStorage.showControls = 'true'`. Any new tab navigating to Home would then read that value on mount and auto-expand the Controls panel without any user interaction. ### Root cause `(app)/+layout.svelte` subscribed to the `showControls` Svelte store unconditionally: ```ts showControls.subscribe((value) => { localStorage.showControls = value ? 'true' : 'false'; }); ``` This persisted **every** mutation — including programmatic `showControls.set(false)` calls from `Artifacts.svelte` and `showControls.set(true)` from `Citations.svelte` / `ContentRenderer.svelte`. Those writes propagated to every other tab via shared localStorage. ### Fix Remove the unconditional subscriber from the layout. The layout still reads `localStorage.showControls` once on mount to restore the user's preference. Persistence is now written only in `Navbar.svelte`, inside the Controls button's `on:click` handler — so localStorage only reflects deliberate user toggles. ### Files changed - `src/routes/(app)/+layout.svelte` — removed `showControls.subscribe()` that was writing to localStorage - `src/lib/components/chat/Navbar.svelte` — added explicit `localStorage.showControls` write on user click ### Steps to reproduce (before fix) 1. Open Open WebUI in Tab A 2. Start a chat and trigger an Artifacts preview (any code/HTML artifact) 3. Open Tab B → navigate to Home 4. **Observe:** Controls/Advanced Settings panel auto-expands in Tab B with no user action ### After fix Tab B opens with Controls panel collapsed, regardless of what Tab A did programmatically. --- # Changelog Entry ### Fixed - Fixed cross-tab UI state leak where opening an Artifacts preview in one tab would cause the Controls/Advanced Settings panel to auto-expand in other tabs. `showControls` is now only persisted to `localStorage` on explicit user interaction, not on programmatic store mutations from Artifacts or Citations components. --- ### Additional Information - Related to the general principle noted in the PR template: ephemeral UI logic should use local state, not shared storage. ### Screenshots or Videos N/A — the fix is a state management correction with no visual change to the Controls panel itself. ### Contributor License Agreement - [x] By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-06 12:26:59 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#66214