Skip to content

Add IndexedDB autosave backup for UI config and fix WebuiManager typing#722

Open
Niraj12chaudhary wants to merge 2 commits intobrowser-use:mainfrom
Niraj12chaudhary:fix/indexeddb-config-backup-721
Open

Add IndexedDB autosave backup for UI config and fix WebuiManager typing#722
Niraj12chaudhary wants to merge 2 commits intobrowser-use:mainfrom
Niraj12chaudhary:fix/indexeddb-config-backup-721

Conversation

@Niraj12chaudhary
Copy link

@Niraj12chaudhary Niraj12chaudhary commented Mar 8, 2026

Summary

This PR adds browser-side backup/restore for WebUI settings to prevent config loss on accidental tab close/refresh, and fixes typing issues in WebuiManager.

What was the bug

UI settings were only persisted via manual Save UI Settings (server JSON).
If users changed settings and refreshed/closed the tab before saving, config was lost.

What was fixed

1) Browser-side config backup/restore

  • Added autosave of UI control values to IndexedDB.
  • Added localStorage fallback when IndexedDB is unavailable.
  • Save triggers:
    • every 60 seconds
    • beforeunload
    • visibilitychange (when tab goes hidden)
  • Restore runs on load (multi-pass to handle dependent/late-rendered controls).

2) Stable component mapping

  • Auto-assigns missing elem_id in WebuiManager as:
    • webui-{tab}-{name}
  • Enables reliable mapping between UI components and persisted state.

3) Typing and config-load cleanup

  • save_config return type corrected to str.
  • load_config now has explicit typed generator return and uses gr.update(...).
  • Retains early-yield behavior for agent_settings.planner_llm_provider callback flow.

4) Security + robustness hardening (follow-up fix)

  • Excludes sensitive fields from autosave/restore:
    • password/api-key/token/secret related inputs
  • Wraps fallback JSON.parse in try/catch and clears corrupted local cache to avoid init failure.

Validation

  • python -m compileall src/webui/interface.py src/webui/webui_manager.py

Related

@CLAassistant
Copy link

CLAassistant commented Mar 8, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 2 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/webui/interface.py">

<violation number="1" location="src/webui/interface.py:119">
P1: Autosave persists sensitive UI fields (e.g., API key password inputs) to IndexedDB/localStorage because all `webui-*` controls are saved without exclusions.</violation>

<violation number="2" location="src/webui/interface.py:154">
P2: Unvalidated `JSON.parse` in localStorage fallback can throw and abort persistence initialization, preventing restore/autosave setup.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Local-storage backup for browser-based AI configs to prevent churn

2 participants