Skip to content

Agent Zero AI framework

Fix mobile settings Save and simplify section navigation

Alessandro10e7d7c765ee
diff --git a/tests/test_settings_mobile.py b/tests/test_settings_mobile.py
new file mode 100644
index 000000000..71143fc9d
--- /dev/null
+++ b/tests/test_settings_mobile.py
@@ -0,0 +1,123 @@
+"""Exercise the settings shell with Alpine and touch input, without live user data."""
+
+import mimetypes
+from pathlib import Path
+from urllib.parse import urlparse
+
+import pytest
+
+playwright = pytest.importorskip("playwright.sync_api")
+WEBUI = Path(__file__).resolve().parents[1] / "webui"
+
+
+def test_mobile_navigation_and_save_without_file_browser_store():
+ body = (WEBUI / "components/settings/settings.html").read_text().split("<body>")[1].split("</body>")[0]
+ html = """<!doctype html><html><head>
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel="stylesheet" href="/index.css">
+ <link rel="stylesheet" href="/css/modals.css">
+ <link rel="stylesheet" href="/css/settings.css">
+ </head><body>
+ <div class="modal-inner settings-modal modal-with-footer">
+ <div class="modal-header">Settings</div>
+ <div class="modal-scroll"><div class="modal-bd">""" + body + """</div></div>
+ <div class="modal-footer-slot"></div>
+ </div>
+ <script type="module">
+ import { store } from '/components/settings/settings-store.js';
+ window.closeCount = 0;
+ window.closeModal = () => window.closeCount++;
+ await import('/vendor/alpine/alpine.min.js');
+ await new Promise(requestAnimationFrame);
+ for (const tab of store.navItems) {
+ const panel = document.querySelector(`[data-settings-tab="${tab.id}"]`);
+ panel.innerHTML = tab.sections.map(section =>
+ `<section class="section" id="${section.id}" style="height:500px">${section.label}</section>`
+ ).join('');
+ }
+ </script></body></html>"""
+ modules = {
+ "/components/canvas/right-canvas-store.js": "export const store = { surfaces: [] };",
+ "/components/sidebar/bottom/preferences/preferences-store.js": """
+ export const store = { uiVisibilitySnapshot: () => ({}), setUiVisibility() {} };
+ """,
+ "/components/notifications/notification-store.js": """
+ export const store = { notifications: [], addFrontendToastOnly() {} };
+ """,
+ "/js/api.js": """
+ window.saved = [];
+ export async function callJsonApi(endpoint, data) {
+ if (endpoint === 'settings_get') return { settings: { timezone: 'auto' } };
+ window.saved.push(data);
+ return new Promise(resolve => window.finishSave = () => resolve(data));
+ }
+ """,
+ }
+
+ def serve(route):
+ path = urlparse(route.request.url).path
+ if path == "/":
+ route.fulfill(content_type="text/html", body=html)
+ elif path in modules:
+ route.fulfill(content_type="text/javascript", body=modules[path])
+ else:
+ asset = WEBUI / path.lstrip("/")
+ if asset.is_file():
+ route.fulfill(path=asset, content_type=mimetypes.guess_type(asset)[0])
+ else:
+ route.abort()
+
+ with playwright.sync_playwright() as p:
+ try:
+ browser = p.chromium.launch()
+ except playwright.Error as error:
+ if "Executable doesn't exist" in str(error):
+ pytest.skip("An installed Playwright Chromium browser is required.")
+ raise
+ try:
+ page = browser.new_page(viewport={"width": 393, "height": 852}, is_mobile=True, has_touch=True)
+ page.route("**/*", serve)
+ errors = []
+ page.on("pageerror", lambda error: errors.append(str(error)))
+ page.goto("http://settings.test/")
+ save = page.get_by_role("button", name="Save", exact=True)
+ playwright.expect(save).to_be_visible()
+ page.evaluate("document.querySelector('.modal-footer-slot').append(document.querySelector('[data-modal-footer]'))")
+ assert page.evaluate("Alpine.store('fileBrowser') === undefined")
+ playwright.expect(save).to_be_enabled()
+ save.tap()
+ page.wait_for_function("window.saved.length === 1")
+ playwright.expect(save).to_be_disabled()
+ page.evaluate("window.finishSave()")
+ page.wait_for_function("window.closeCount === 1")
+ playwright.expect(save).to_be_enabled()
+
+ page.evaluate("Alpine.store('fileBrowser', { savingTextLimit: true })")
+ playwright.expect(save).to_be_disabled()
+ page.evaluate("Alpine.store('fileBrowser').savingTextLimit = false")
+ playwright.expect(save).to_be_enabled()
+ page.get_by_role("button", name="Cancel", exact=True).tap()
+ assert page.evaluate("window.closeCount") == 2
+
+ picker = page.get_by_role("combobox", name="Settings section")
+ playwright.expect(picker).to_have_value("section-agent-config")
+ picker.select_option("section-interface")
+ page.wait_for_function("Alpine.store('settings').activeSection === 'section-interface'")
+ picker.select_option("section-auth")
+ page.wait_for_function("Alpine.store('settings').activeTab === 'external'")
+ playwright.expect(picker).to_have_value("section-auth")
+ assert page.locator(".settings-tabs-container").bounding_box()["height"] < 80
+ assert save.bounding_box()["y"] + save.bounding_box()["height"] <= 852
+
+ page.set_viewport_size({"width": 1280, "height": 900})
+ playwright.expect(picker).to_be_hidden()
+ search = page.get_by_role("searchbox", name="Search settings")
+ search.fill("Locale")
+ page.get_by_role("link", name="Locale", exact=True).click()
+ page.wait_for_function("Alpine.store('settings').activeSection === 'section-locale'")
+ page.set_viewport_size({"width": 393, "height": 500})
+ playwright.expect(picker).to_have_value("section-locale")
+ assert save.bounding_box()["y"] + save.bounding_box()["height"] <= 500
+ assert not errors
+ finally:
+ browser.close()
diff --git a/webui/components/settings/AGENTS.md b/webui/components/settings/AGENTS.md
index 17e708bf9..ed5c831c5 100644
--- a/webui/components/settings/AGENTS.md
+++ b/webui/components/settings/AGENTS.md
@@ -18,6 +18,8 @@
- Settings tabs that expose plugin `settings_sections` must mount `settings/plugins/plugins-subsection.html` with matching `data-tab` and sidebar/nav section IDs.
- Do not store secrets in localStorage, URLs, or console output.
- Preserve Store Gating and modal footer conventions in settings components.
+- Mobile navigation uses a native section picker grouped by category; desktop keeps the searchable tree. Both use the same section list and scroll state.
+- Save's disabled binding must return a boolean even before the optional File Browser store loads; an undefined Alpine binding disables the button.
- Interface control visibility is edited as a Save/Cancel draft, persisted with instance settings, and applied through the shared frontend preference store after Settings saves successfully.
- Bundled controls contributed by plugins add their Interface row through
`interface-controls-end` and register visibility defaults with the shared
diff --git a/webui/components/settings/settings.html b/webui/components/settings/settings.html
index 8e7fc59d3..08b57835d 100644
--- a/webui/components/settings/settings.html
+++ b/webui/components/settings/settings.html
@@ -29,6 +29,19 @@
<div x-show="$store.settings.settings" class="settings-content">
<!-- Tab Navigation -->
<aside class="settings-tabs-container" aria-label="Settings categories">
+ <select class="settings-mobile-nav"
+ aria-label="Settings section"
+ @change="$store.settings.scrollToSection($event.target.value, null, 'instant')">
+ <template x-for="item in $store.settings.navItems" :key="item.id">
+ <optgroup :label="item.label">
+ <template x-for="section in item.sections" :key="section.id">
+ <option :value="section.id"
+ :selected="$store.settings.activeSection === section.id"
+ x-text="section.label"></option>
+ </template>
+ </optgroup>
+ </template>
+ </select>
<div class="settings-search" role="search">
<x-icon aria-hidden="true" name="search"></x-icon>
<input
@@ -138,7 +151,7 @@
<div class="modal-footer" data-modal-footer x-show="$store.settings.settings">
<button class="btn btn-ok"
@click="$store.settings.saveAndClose()"
- :disabled="$store.settings?.isLoading || $store.fileBrowser?.savingTextLimit">
+ :disabled="!!($store.settings?.isLoading || $store.fileBrowser?.savingTextLimit)">
Save
</button>
<button class="btn btn-cancel"
diff --git a/webui/css/AGENTS.md b/webui/css/AGENTS.md
index dc2d02254..b18f15754 100644
--- a/webui/css/AGENTS.md
+++ b/webui/css/AGENTS.md
@@ -23,6 +23,7 @@
- Use existing CSS variables and naming patterns before introducing new global tokens.
- Avoid broad selectors that unexpectedly restyle plugin UI or unrelated components.
- Keep layout rules responsive and verify text does not overflow fixed controls.
+- Settings replaces its sidebar tree with a compact native section picker at mobile widths and uses dynamic viewport height to keep its footer in view.
- Shared modal buttons use `btn btn-ok` for positive actions and `btn btn-cancel` for dismissive or negative actions.
- Shared compact text actions use `.text-button`; component-local styles may adjust layout or sizing but must not be the only definition of the primitive.
- Modal footer action order is positive action first, dismissive or negative action second.
diff --git a/webui/css/settings.css b/webui/css/settings.css
index ac7970d7b..801d6a158 100644
--- a/webui/css/settings.css
+++ b/webui/css/settings.css
@@ -201,6 +201,10 @@ select:disabled {
overflow: hidden;
}
+.settings-mobile-nav {
+ display: none;
+}
+
.settings-tabs-container {
position: sticky;
top: 0;
@@ -730,6 +734,8 @@ select:disabled {
width: calc(100vw - 16px);
height: calc(100vh - 16px);
max-height: calc(100vh - 16px);
+ height: calc(100dvh - 16px);
+ max-height: calc(100dvh - 16px);
}
.settings-content {
@@ -738,32 +744,26 @@ select:disabled {
}
.settings-tabs-container {
- position: sticky;
- top: 0;
- z-index: 3;
height: auto;
- max-height: min(42vh, 300px);
padding: 7px 8px;
- overflow: hidden;
border-right: 0;
border-bottom: 1px solid color-mix(in srgb, var(--color-border) 58%, transparent);
}
+ .settings-search,
.settings-tabs {
- flex-direction: column;
- width: 100%;
- min-width: 100%;
- overflow-y: auto;
+ display: none;
}
- .settings-tab {
- width: 100%;
+ .settings-mobile-nav {
+ display: block;
min-width: 0;
- padding: 0 9px;
+ min-height: 44px;
+ font-size: 16px;
}
- .settings-section-list {
- margin-left: 28px;
+ .modal-inner.settings-modal .modal-footer .btn {
+ min-height: 44px;
}
.settings-pane {