Skip to content

Agent Zero AI framework

Add reusable overflow menus for chat controls

Alessandro9ffa0fa8f581
diff --git a/plugins/_context_window/AGENTS.md b/plugins/_context_window/AGENTS.md
index 60ad6529f..0ef7c027e 100644
--- a/plugins/_context_window/AGENTS.md
+++ b/plugins/_context_window/AGENTS.md
@@ -57,8 +57,7 @@
- Keep prompt accounting out of rendered-text heuristics.
- Keep provider-reported usage separate from the six estimated context buckets.
- Keep the API response limited to counts needed by the UI.
-- Preserve the upward, right-aligned popover geometry used beside the model and
- profile selectors, including its reserved footprint for short selector labels.
+- Preserve the upward, right-aligned popover beside the model/profile selectors. Its minimum strip footprint is bounded by the available width; shared `x-overflow` positions the same popover when the indicator enters the overflow menu. `data-overflow-label` names the entry; `data-overflow-icon` retains its live percentage ring.
## Verification
diff --git a/plugins/_context_window/extensions/webui/model-context-strip-end/context-window.html b/plugins/_context_window/extensions/webui/model-context-strip-end/context-window.html
index 0d38c4c22..6f2406d99 100644
--- a/plugins/_context_window/extensions/webui/model-context-strip-end/context-window.html
+++ b/plugins/_context_window/extensions/webui/model-context-strip-end/context-window.html
@@ -11,6 +11,8 @@
@keydown.escape.window="$store.contextWindow.open = false">
<button type="button"
class="context-window-button"
+ data-overflow-icon
+ data-overflow-label="Context window"
:aria-expanded="$store.contextWindow.open"
:aria-label="$store.contextWindow.usage.ariaLabel"
@click="$store.contextWindow.toggle()">
@@ -80,8 +82,8 @@
</div>
<style>
- .model-switcher-container:has(.context-window-anchor) {
- min-width: min(19rem, calc(100vw - 2rem));
+ .model-context-strip:has(.context-window-anchor) {
+ min-width: min(19rem, 100%);
}
.context-window-anchor {
position: static;
@@ -232,11 +234,8 @@
color: color-mix(in srgb, var(--color-text) 62%, transparent);
}
@media (max-width: 25rem) {
- .model-switcher-container:has(.context-window-anchor) {
- min-width: min(calc(17rem + 1.25rem), calc(100vw - 2.5rem));
- }
.context-window-popover {
- right: 1.25rem;
+ right: 0;
width: min(17rem, calc(100vw - 3rem));
}
}
diff --git a/plugins/_context_window/tests/test_context_window.py b/plugins/_context_window/tests/test_context_window.py
index a8d9ca3be..37bf6744d 100644
--- a/plugins/_context_window/tests/test_context_window.py
+++ b/plugins/_context_window/tests/test_context_window.py
@@ -158,10 +158,10 @@ def test_webui_and_accounting_are_plugin_owned():
assert "contextUsage" not in model_store
assert "Context window" in component
assert "position: static" in component
- assert "min-width: min(19rem, calc(100vw - 2rem))" in component
- assert "min-width: min(calc(17rem + 1.25rem), calc(100vw - 2.5rem))" in component
+ assert 'class="model-context-strip" x-overflow' in model_switcher
+ assert 'data-overflow-label="Context window"' in component
assert "width: min(19rem, calc(100vw - 2rem))" in component
- assert "right: 1.25rem" in component
+ assert "min-width: min(19rem, 100%)" in component
assert "width: min(17rem, calc(100vw - 3rem))" in component
assert 'label: "Free space"' in context_store
assert "Last model call" not in component
diff --git a/plugins/_model_config/AGENTS.md b/plugins/_model_config/AGENTS.md
index 02b695ce0..08ddc554c 100644
--- a/plugins/_model_config/AGENTS.md
+++ b/plugins/_model_config/AGENTS.md
@@ -38,6 +38,7 @@
- The compact chat selector label combines the effective preset with only the leaf name of its main model; utility and provider text stay out of the closed selector.
- The compact selector strip exposes `model-context-strip-end` after the agent
profile selector so adjacent bundled controls can stay plugin-owned.
+- The selector strip uses the shared `x-overflow` directive for built-in and plugin controls. Its root must remain shrinkable; overflow entries open the original selector panels and retain their Alpine state. The profile avatar uses `data-overflow-icon` so its color, initials, or image also appear in overflow.
- The adjacent agent-profile selector reads the always-enabled Agent Editor list
endpoint directly so the active profile shows its effective title and avatar,
and omits profiles disabled in the chat's current scope plus the exact
diff --git a/plugins/_model_config/extensions/webui/chat-input-progress-start/model-switcher.html b/plugins/_model_config/extensions/webui/chat-input-progress-start/model-switcher.html
index 0940d547f..da6db099c 100644
--- a/plugins/_model_config/extensions/webui/chat-input-progress-start/model-switcher.html
+++ b/plugins/_model_config/extensions/webui/chat-input-progress-start/model-switcher.html
@@ -5,7 +5,7 @@
<div x-data>
<template x-if="$store.modelConfig">
-<div x-data="{ showDropdown: false, showProfileDropdown: false }"
+<div class="model-switcher-root" x-data="{ showDropdown: false, showProfileDropdown: false }"
x-init="
await Promise.all([
$store.modelConfig.refreshSwitcher($store.chats?.selected || ''),
@@ -15,7 +15,7 @@
">
<template x-if="($store.modelConfig.switcherAllowed && !$store.modelConfig.switcherLoading) || $store.chats?.selectedContext?.agent_profile">
<div class="model-switcher-container">
- <div class="model-context-strip">
+ <div class="model-context-strip" x-overflow>
<template x-if="$store.modelConfig.switcherAllowed && !$store.modelConfig.switcherLoading">
<div class="model-switcher-anchor" @click.outside="showDropdown = false">
<button class="btn-icon-action model-switcher-btn"
@@ -120,7 +120,7 @@
<button class="btn-icon-action agent-profile-btn"
title="Active agent profile"
@click="showProfileDropdown = !showProfileDropdown; showDropdown = false">
- <span class="agent-profile-avatar"
+ <span class="agent-profile-avatar" aria-hidden="true" data-overflow-icon
:style="`background:${$store.modelConfig.getAgentProfileVisual($store.chats.selectedContext.agent_profile, $store.chats.selectedContext.agent_profile_label).color}`">
<img x-show="$store.modelConfig.getAgentProfileVisual($store.chats.selectedContext.agent_profile, $store.chats.selectedContext.agent_profile_label).url"
:src="$store.modelConfig.getAgentProfileVisual($store.chats.selectedContext.agent_profile, $store.chats.selectedContext.agent_profile_label).url"
@@ -197,12 +197,18 @@
</div>
<style>
+ .model-switcher-root {
+ flex: 1;
+ min-width: 0;
+ }
.model-switcher-container {
position: relative;
z-index: 10;
}
.model-context-strip {
display: flex;
+ width: fit-content;
+ max-width: 100%;
align-items: center;
gap: 8px;
min-width: 0;
diff --git a/tests/test_webui_overflow.py b/tests/test_webui_overflow.py
new file mode 100644
index 000000000..7e179562e
--- /dev/null
+++ b/tests/test_webui_overflow.py
@@ -0,0 +1,325 @@
+"""Exercise x-overflow with real Alpine scopes, layout, and plugin-style insertion."""
+
+import mimetypes
+from pathlib import Path
+import tempfile
+from urllib.parse import urlparse
+
+import pytest
+
+playwright = pytest.importorskip("playwright.sync_api")
+ROOT = Path(__file__).resolve().parents[1]
+
+
+def serve_page(page, html):
+ def serve(route):
+ path = urlparse(route.request.url).path
+ if path == "/":
+ route.fulfill(content_type="text/html", body=html)
+ else:
+ asset = ROOT / "webui" / path.lstrip("/")
+ route.fulfill(path=asset, content_type=mimetypes.guess_type(asset)[0])
+
+ page.route("**/*", serve)
+
+
+def test_overflow_preserves_original_controls_and_plugin_menus():
+ html = """<!doctype html><html><head>
+ <link rel="stylesheet" href="/index.css">
+ <link rel="stylesheet" href="/vendor/google/google-icons.css">
+ <link rel="stylesheet" href="/css/buttons.css">
+ <link rel="stylesheet" href="/css/overflow.css">
+ <style>
+ body { padding: 20px; }
+ #row { display: flex; gap: 8px; width: 600px; margin-top: 400px; }
+ .control { position: relative; }
+ .control > button { width: 130.125px; height: 32px; }
+ .panel { position: absolute; bottom: 100%; width: 240px; padding: 12px;
+ background: var(--color-panel); border: 1px solid gray; }
+ .test-avatar { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; }
+ .test-avatar img { width: 100%; height: 100%; }
+ .test-ring { position: relative; display: inline-grid; place-items: center; }
+ .test-ring svg { position: absolute; inset: 0; width: 100%; height: 100%; fill: none; stroke: blue; }
+ .test-ring > span { font-size: 8px; }
+ .plugin, x-extension, x-component { display: contents; }
+ </style>
+ <script type="module">
+ import { registerOverflow } from '/js/overflow.js';
+ document.addEventListener('alpine:init', () => registerOverflow(Alpine));
+ await import('/vendor/alpine/alpine.min.js');
+ </script>
+ </head><body x-data="{ mounted: true, chosen: '', initials: 'D', avatarColor: 'blue', avatarImage: null, usage: '19%', ring: '19 100' }">
+ <button id="outside">Outside</button>
+ <template x-if="mounted">
+ <div id="row" x-overflow x-data="{ model: false, agent: false, context: false }">
+ <div class="control" @click.outside="model = false">
+ <button id="model" @click="model = !model">Model</button>
+ <div id="model-panel" class="panel" x-show="model" style="display:none">
+ <button @click="chosen = 'Model'; model = false">Default preset</button>
+ </div>
+ </div>
+ <div class="control" @click.outside="agent = false">
+ <button id="agent" @click="agent = !agent">
+ <span class="test-avatar" data-overflow-icon aria-hidden="true"
+ x-init="window.avatarMounts = (window.avatarMounts || 0) + 1"
+ :style="`background:${avatarColor}`">
+ <img x-show="avatarImage" :src="avatarImage" alt="">
+ <span x-show="!avatarImage" x-text="initials"></span>
+ </span>
+ Agent
+ </button>
+ <div id="agent-panel" class="panel" x-show="agent" style="display:none">
+ <button @click="chosen = 'Agent'; agent = false">Default agent</button>
+ </div>
+ </div>
+ <x-extension><x-component class="plugin-slot"></x-component></x-extension>
+ <div class="control" @click.outside="context = false">
+ <button id="usage" class="test-ring" style="width:28px;height:28px" data-overflow-icon
+ data-overflow-label="Context window" @click="context = !context">
+ <svg viewBox="0 0 36 36" aria-hidden="true"><circle cx="18" cy="18" r="15" :stroke-dasharray="ring"></circle></svg>
+ <span x-text="usage"></span>
+ </button>
+ <div class="panel" x-show="context" style="display:none">Context details</div>
+ </div>
+ </div>
+ </template>
+ </body></html>"""
+
+ 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
+ page = browser.new_page(viewport={"width": 900, "height": 700}, has_touch=True)
+ serve_page(page, html)
+ errors = []
+ page.on("pageerror", lambda error: errors.append(str(error)))
+ page.goto("http://overflow.test/")
+ page.wait_for_selector("#model")
+ page.evaluate("""() => {
+ document.querySelector('.plugin-slot').innerHTML = `
+ <div class="plugin" x-data="{ open: false, custom: '' }">
+ <div class="control" @click.outside="open = false">
+ <button id="effort" @click="open = !open"><span class="material-symbols-outlined" aria-hidden="true">psychology</span>Reasoning effort</button>
+ <div id="effort-panel" class="panel" x-show="open" style="display:none">
+ <button @click="chosen = 'Auto'; open = false">Auto</button>
+ <button @click="chosen = 'High'; open = false">High</button>
+ <input x-model="custom" aria-label="Custom effort">
+ </div>
+ </div>
+ </div>`;
+ window.originalEffort = document.getElementById('effort');
+ }""")
+ page.wait_for_selector("#effort")
+ more = page.get_by_role("button", name="More controls", exact=True)
+ playwright.expect(more).to_be_hidden()
+ page.evaluate("document.getElementById('row').style.width = '220px'")
+ playwright.expect(more).to_be_visible()
+ assert more.evaluate("el => getComputedStyle(el).borderTopWidth") == "0px"
+ more.hover()
+ assert more.evaluate("el => getComputedStyle(el).boxShadow") == "none"
+ assert more.locator("x-icon").evaluate("el => parseFloat(getComputedStyle(el).fontSize)") == 24
+ more.click()
+ menu = page.get_by_role("menu", name="More controls")
+ playwright.expect(menu.locator(".overflow-label")).to_have_text(["Agent", "Reasoning effort", "Context window"])
+ avatar = menu.locator(".test-avatar")
+ ring = menu.locator(".test-ring")
+ playwright.expect(avatar).to_have_text("D")
+ playwright.expect(ring).to_have_text("19%")
+ assert avatar.evaluate("el => getComputedStyle(el).backgroundColor") == "rgb(0, 0, 255)"
+ assert menu.locator(".overflow-icon button, [id=agent], [id=usage], [x-init]").count() == 0
+ assert menu.locator('.overflow-icon x-icon[name="psychology"]').count() == 1
+ page.evaluate("""() => {
+ Object.assign(Alpine.$data(document.body), {initials:'R', avatarColor:'red', usage:'42%', ring:'42 100'});
+ }""")
+ playwright.expect(avatar).to_have_text("R")
+ playwright.expect(ring).to_have_text("42%")
+ playwright.expect(ring.locator("circle")).to_have_attribute("stroke-dasharray", "42 100")
+ assert avatar.evaluate("el => getComputedStyle(el).backgroundColor") == "rgb(255, 0, 0)"
+ page.evaluate("Alpine.$data(document.body).avatarImage = 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs='")
+ playwright.expect(avatar.locator("img")).to_be_visible()
+ playwright.expect(avatar.locator("span")).to_be_hidden()
+ assert page.evaluate("window.avatarMounts") == 1
+ effort = menu.get_by_role("menuitem", name="Reasoning effort")
+ effort.hover()
+ playwright.expect(page.get_by_label("Custom effort")).to_be_visible()
+ effort.click()
+ playwright.expect(page.get_by_label("Custom effort")).to_be_hidden()
+ effort.dispatch_event("pointermove", {"pointerType": "mouse"})
+ playwright.expect(effort).to_have_attribute("aria-expanded", "false")
+ page.mouse.move(0, 0)
+ effort.hover()
+ playwright.expect(page.get_by_label("Custom effort")).to_be_visible()
+ effort.click()
+ playwright.expect(page.get_by_label("Custom effort")).to_be_hidden()
+ effort.tap()
+ playwright.expect(page.get_by_label("Custom effort")).to_be_visible()
+ effort.tap()
+ playwright.expect(page.get_by_label("Custom effort")).to_be_hidden()
+ effort.press("Enter")
+ playwright.expect(page.get_by_label("Custom effort")).to_be_visible()
+ page.get_by_label("Custom effort").fill("custom-value")
+ page.get_by_label("Custom effort").press("ArrowLeft")
+ playwright.expect(page.get_by_label("Custom effort")).to_be_focused()
+ page.get_by_label("Custom effort").press("Escape")
+ playwright.expect(menu).to_be_visible()
+ playwright.expect(effort).to_be_focused()
+ effort.press("Enter")
+ playwright.expect(page.get_by_label("Custom effort")).to_be_visible()
+ playwright.expect(page.get_by_label("Custom effort")).to_have_value("custom-value")
+ page.get_by_role("button", name="High", exact=True).click()
+ playwright.expect(menu).to_be_hidden()
+ assert page.evaluate("Alpine.$data(document.body).chosen") == "High"
+ assert page.evaluate("document.getElementById('effort') === window.originalEffort")
+
+ # Both built-in and plugin actions keep their original scoped handlers.
+ more.press("ArrowDown")
+ agent = menu.get_by_role("menuitem", name="Agent", exact=True)
+ playwright.expect(agent).to_be_focused()
+ agent.press("ArrowRight")
+ option = page.get_by_role("button", name="Default agent", exact=True)
+ playwright.expect(option).to_be_focused()
+ option.click()
+ assert page.evaluate("Alpine.$data(document.body).chosen") == "Agent"
+ playwright.expect(menu).to_be_hidden()
+
+ # Attribute/text changes and controls inserted after mount are observed.
+ page.evaluate("document.getElementById('effort').disabled = true")
+ more.click()
+ playwright.expect(effort).to_be_disabled()
+ page.evaluate("document.getElementById('effort').disabled = false; document.getElementById('effort').textContent = 'Effort: High'")
+ effort = menu.get_by_role("menuitem", name="Effort: High")
+ playwright.expect(effort).to_be_enabled()
+ effort.press("Enter")
+ page.get_by_role("button", name="Outside").click()
+ playwright.expect(menu).to_be_hidden()
+ playwright.expect(page.get_by_label("Custom effort")).to_be_hidden()
+
+ # Closing before Alpine has displayed a submenu must cancel the pending open.
+ page.evaluate("""() => {
+ document.querySelector('.overflow-trigger').click();
+ document.querySelector('.overflow-menu button:last-child').click();
+ document.querySelector('.overflow-trigger').click();
+ }""")
+ playwright.expect(menu).to_be_hidden()
+
+ # Resizing restores the same nodes and removes the overflow affordance.
+ page.evaluate("document.getElementById('row').style.width = '600px'")
+ playwright.expect(more).to_be_hidden()
+ page.locator("#effort").click()
+ playwright.expect(page.get_by_label("Custom effort")).to_have_value("custom-value")
+ assert page.locator("#effort-panel").get_attribute("popover") is None
+ page.get_by_role("button", name="Outside").click()
+
+ # A shrink-wrapped row must also notice its parent gaining space.
+ page.evaluate("""() => {
+ document.getElementById('row').style.cssText = 'width:fit-content;max-width:100%';
+ document.body.style.width = '220px';
+ }""")
+ playwright.expect(more).to_be_visible()
+ page.evaluate("document.body.style.width = '900px'")
+ playwright.expect(more).to_be_hidden()
+ page.evaluate("document.body.style.width = ''")
+
+ # At phone widths every menu, including the first control, stays on screen.
+ page.set_viewport_size({"width": 320, "height": 600})
+ page.evaluate("document.getElementById('row').style.width = '120px'")
+ more.click()
+ model = menu.get_by_role("menuitem", name="Model", exact=True)
+ playwright.expect(model.locator(".overflow-icon")).to_be_hidden()
+ assert model.evaluate("""el => {
+ const label = el.querySelector('.overflow-label');
+ return Math.abs(label.getBoundingClientRect().left - el.getBoundingClientRect().left - parseFloat(getComputedStyle(el).paddingLeft)) < 1;
+ }""")
+ model.hover()
+ page.wait_for_selector("#model-panel:popover-open")
+ for selector in [".overflow-menu", ".overflow-panel"]:
+ bounds = page.locator(selector).bounding_box()
+ assert bounds and bounds["x"] >= 0 and bounds["x"] + bounds["width"] <= 320
+ assert bounds["y"] >= 0 and bounds["y"] + bounds["height"] <= 600
+ page.get_by_role("button", name="Default preset", exact=True).click()
+ assert page.evaluate("Alpine.$data(document.body).chosen") == "Model"
+
+ more.click()
+ effort.hover()
+ page.wait_for_selector("#effort-panel:popover-open")
+ effort.click()
+ playwright.expect(page.get_by_label("Custom effort")).to_be_hidden()
+ page.evaluate("""() => {
+ document.getElementById('row').style.overflow = 'hidden';
+ const panel = document.getElementById('effort-panel');
+ panel.style.width = '600px';
+ panel.insertAdjacentHTML('beforeend', '<div style="height:800px"></div><button id="last-option">Last option</button>');
+ }""")
+ effort.press("Enter")
+ page.wait_for_selector("#effort-panel:popover-open")
+ for width, height in [(420, 575), (320, 360), (390, 664), (844, 390)]:
+ page.set_viewport_size({"width": width, "height": height})
+ page.wait_for_function("""() => {
+ const r = document.querySelector('.overflow-panel').getBoundingClientRect();
+ return r.left >= 8 && r.right <= innerWidth - 8 && r.top >= 8 && r.bottom <= innerHeight - 8;
+ }""")
+ page.locator("#last-option").scroll_into_view_if_needed()
+ assert page.locator("#last-option").evaluate("""el => {
+ const r = el.getBoundingClientRect();
+ return document.elementFromPoint(r.x + r.width / 2, r.y + r.height / 2) === el;
+ }""")
+ assert effort.evaluate("""el => {
+ const r = el.getBoundingClientRect();
+ return el.contains(document.elementFromPoint(r.x + r.width / 2, r.y + r.height / 2));
+ }""")
+ effort.click()
+ playwright.expect(page.get_by_label("Custom effort")).to_be_hidden()
+ effort.press("Enter")
+ page.wait_for_selector("#effort-panel:popover-open")
+ page.evaluate("document.querySelector('.plugin-slot').replaceChildren()")
+ playwright.expect(menu.locator(".overflow-label")).to_have_text(["Model", "Agent", "Context window"])
+ page.evaluate("Alpine.$data(document.body).mounted = false")
+ playwright.expect(page.locator(".overflow-trigger, .overflow-panel, .overflow-menu")).to_have_count(0)
+ assert errors == []
+ browser.close()
+
+
+def test_browser_zoom_does_not_create_false_overflow():
+ html = """<!doctype html><html><head>
+ <link rel="stylesheet" href="/index.css">
+ <link rel="stylesheet" href="/css/buttons.css">
+ <link rel="stylesheet" href="/css/overflow.css">
+ <style>
+ #host { width: 600px; }
+ #row { display:flex; width:fit-content; max-width:100%; gap:8px; }
+ #row > button:not(.overflow-trigger) { width:130.125px; }
+ </style>
+ <script type="module">
+ import { registerOverflow } from '/js/overflow.js';
+ document.addEventListener('alpine:init', () => registerOverflow(Alpine));
+ await import('/vendor/alpine/alpine.min.js');
+ </script>
+ </head><body x-data><div id="host"><div id="row" x-overflow>
+ <button>Model</button><button>Reasoning effort</button><button>Agent</button><button>Context</button>
+ </div></div></body></html>"""
+
+ # Browser zoom requires a full Chromium and an isolated persistent profile.
+ with tempfile.TemporaryDirectory(prefix="overflow-zoom-") as profile, playwright.sync_playwright() as p:
+ if not Path(p.chromium.executable_path).is_file():
+ pytest.skip("Full Playwright Chromium is required for browser zoom.")
+ with p.chromium.launch_persistent_context(profile, executable_path=p.chromium.executable_path, headless=True) as context:
+ settings = context.new_page()
+ settings.goto("chrome://settings/appearance")
+ page = context.new_page()
+ serve_page(page, html)
+ page.goto("http://overflow.test/")
+ page.wait_for_selector(".overflow-trigger", state="attached")
+ more = page.get_by_role("button", name="More controls", exact=True)
+ for zoom in [1, 1.1, 1.5, 1.75, 1]:
+ settings.evaluate("zoom => new Promise(r => chrome.settingsPrivate.setDefaultZoom(zoom, r))", zoom)
+ page.wait_for_function("zoom => Math.abs(devicePixelRatio - zoom) < .01", arg=zoom)
+ page.evaluate("() => new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r)))")
+ playwright.expect(more).to_be_hidden()
+ playwright.expect(page.locator(".overflow-hidden")).to_have_count(0)
+ page.evaluate("document.getElementById('host').style.width = '220px'")
+ playwright.expect(more).to_be_visible()
+ page.evaluate("document.getElementById('host').style.width = '600px'")
+ playwright.expect(more).to_be_hidden()
diff --git a/tests/test_webui_startup_assets.py b/tests/test_webui_startup_assets.py
index 644f682e3..84ccc7e40 100644
--- a/tests/test_webui_startup_assets.py
+++ b/tests/test_webui_startup_assets.py
@@ -108,8 +108,8 @@ def test_only_the_icon_guard_stylesheet_blocks_application_paint() -> None:
assert index_html.count('<link rel="stylesheet"') == 1
assert '<link rel="stylesheet" href="vendor/google/google-icons.css">' in index_html
assert '<script type="module" src="/js/icons.js"></script>' in index_html
- assert index_html.count('rel="preload" as="style"') == 19
- assert index_html.count("onload=\"this.onload=null;this.rel='stylesheet'\"") == 19
+ assert index_html.count('rel="preload" as="style"') == 20
+ assert index_html.count("onload=\"this.onload=null;this.rel='stylesheet'\"") == 20
assert 'id="startup-splash"' not in index_html
assert 'document.addEventListener("webui-bundle-loaded"' not in index_html
diff --git a/webui/components/chat/AGENTS.md b/webui/components/chat/AGENTS.md
index dd759d07c..a05559d1e 100644
--- a/webui/components/chat/AGENTS.md
+++ b/webui/components/chat/AGENTS.md
@@ -35,6 +35,7 @@
## Work Guidance
- Keep composer and attachment changes responsive across desktop and mobile.
+- The selector strip injected into `input/progress.html` uses shared `x-overflow` behavior; controls that do not fit stay reachable through the ellipsis menu, including late plugin additions. Preserve the separate full-width goal strip and speech-stop action.
- Coordinate payload changes with backend chat, upload, and WebSocket handlers.
## Verification
diff --git a/webui/css/AGENTS.md b/webui/css/AGENTS.md
index abbc82c35..dc2d02254 100644
--- a/webui/css/AGENTS.md
+++ b/webui/css/AGENTS.md
@@ -9,6 +9,8 @@
- Each CSS file owns a named surface or primitive family such as buttons, messages, modals, notifications, scheduler, settings, surfaces, tables, or toast.
- `loading-indicators.css` owns reusable loading visuals; `messages.css` owns chat-history paging placement, the context-switch splash surface, and lazy message-preview states in addition to message presentation.
+- `overflow.css` owns the globally loaded `x-overflow` row, borderless ellipsis button, and popover styles constrained by both viewport and available submenu space; original plugin panel styling remains in its owner.
+- Overflow entry visuals retain their owner styles inside a non-interactive `.overflow-icon` slot. Empty slots must not reserve space.
- Component-specific styles should usually stay inside the component HTML unless they are intentionally shared.
- `modals.css` owns the shared stacked modal shell, backdrop, scroll area, footer slot, modal button classes, floating/no-backdrop modal behavior, and shared modal section primitives.
- `surfaces.css` owns surface modal switchers, action rails, draggable header affordances, focus-button state, and right-canvas surface primitives. Files, Editor, and Browser opt into `surface-workspace` for the lighter panel palette, common toolbar chrome, flat `surface-control` buttons, and group separators. Surface modal headers share a 48px border-box height with centered titles and controls; component styles must not override their sizing. Surface modal header controls are borderless in normal, hover, and active states; preserve group separators and keyboard focus outlines. Tab bars and toolbars share a 48px baseline with vertically centered controls. File trees use `--color-background` to contrast with the lighter `--color-panel` workspace. Keep these styles opt-in and preserve viewer/content themes; primary empty-state actions such as Open Browser retain their existing button styling.
diff --git a/webui/css/overflow.css b/webui/css/overflow.css
new file mode 100644
index 000000000..b390c09bf
--- /dev/null
+++ b/webui/css/overflow.css
@@ -0,0 +1,80 @@
+.overflow-row {
+ position: relative;
+ flex-wrap: nowrap !important;
+ min-width: 0;
+}
+.overflow-item, .overflow-trigger {
+ flex-shrink: 0;
+}
+.overflow-trigger {
+ width: 1.8rem;
+ height: 1.8rem;
+ padding: 0;
+ border: 0;
+}
+.overflow-trigger:hover {
+ box-shadow: none;
+}
+.btn-icon-action.overflow-trigger > x-icon {
+ font-size: 1.5rem;
+}
+.overflow-trigger[hidden], .overflow-menu[hidden] {
+ display: none !important;
+}
+.overflow-hidden {
+ position: absolute !important;
+ visibility: hidden !important;
+ pointer-events: none;
+}
+.overflow-menu, .overflow-panel {
+ position: fixed !important;
+ inset: auto !important;
+ left: var(--overflow-left, 0px) !important;
+ top: var(--overflow-top, 0px) !important;
+ max-width: calc(100vw - 16px) !important;
+ max-height: min(var(--overflow-max-height, 70vh), var(--overflow-available-height, 100dvh), calc(100dvh - 16px)) !important;
+ box-sizing: border-box;
+ color: var(--color-text);
+ margin: 0;
+ overflow-y: auto;
+ z-index: 1010;
+}
+.overflow-menu {
+ width: max-content;
+ min-width: min(180px, calc(100vw - 16px));
+}
+.overflow-menu .dropdown-item {
+ display: flex;
+ min-height: 2.25rem;
+}
+.overflow-icon {
+ display: inline-grid;
+ place-items: center;
+ flex: 0 0 1.8rem;
+ pointer-events: none;
+}
+.overflow-icon:empty {
+ display: none;
+}
+.overflow-icon > * {
+ max-width: 100%;
+ max-height: 1.8rem;
+}
+.overflow-label {
+ flex: 1;
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+.overflow-panel {
+ visibility: visible !important;
+ pointer-events: auto;
+ width: var(--overflow-width) !important;
+ min-width: 0 !important;
+ overflow-y: auto !important;
+ z-index: 1011 !important;
+}
+.overflow-menu button:focus-visible, .overflow-trigger:focus-visible {
+ outline: 2px solid var(--color-text);
+ outline-offset: -2px;
+}
diff --git a/webui/index.html b/webui/index.html
index e39af6a0d..c4fb7da90 100644
--- a/webui/index.html
+++ b/webui/index.html
@@ -124,6 +124,7 @@
<link rel="preload" as="style" href="css/scheduler.css" onload="this.onload=null;this.rel='stylesheet'">
<link rel="preload" as="style" href="css/notification.css" onload="this.onload=null;this.rel='stylesheet'">
<link rel="preload" as="style" href="css/buttons.css" onload="this.onload=null;this.rel='stylesheet'">
+ <link rel="preload" as="style" href="css/overflow.css" onload="this.onload=null;this.rel='stylesheet'">
<link rel="preload" as="style" href="css/tables.css" onload="this.onload=null;this.rel='stylesheet'">
<link rel="preload" as="style" href="components/canvas/right-canvas.css" onload="this.onload=null;this.rel='stylesheet'">
diff --git a/webui/js/AGENTS.md b/webui/js/AGENTS.md
index 05651e658..7b1214948 100644
--- a/webui/js/AGENTS.md
+++ b/webui/js/AGENTS.md
@@ -15,6 +15,7 @@
- `modals.js` owns the stacked modal shell, `openModal`, `closeModal`, `scrollModal`, footer relocation, backdrop, and modal z-index behavior.
- `surfaces.js` owns shared surface registration, right-canvas/modal mode routing, surface modal action rails, and reusable draggable/focus modal chrome.
- `initFw.js` owns Alpine bootstrap and custom lifecycle directives such as `x-create`, `x-destroy`, and periodic `x-every-*` hooks.
+- `overflow.js` owns the reusable `x-overflow` directive for constrained flex rows. It observes layout and late plugin content, collapses trailing controls behind `more_horiz`, and opens their original panels without moving or reinitializing Alpine nodes.
- `icons.js` owns `<x-icon>`, icon-name validation, the name property/attribute bridge, and helpers that read or update both the first-party custom element and legacy plugin ligature spans.
- `messages.js` owns native message/process-step rendering, safe Markdown and HTML conversion, and KaTeX delimiter handling.
- `messages.js` routes unhandled log types through `drawMessageTool`, preserving generic tool-step presentation. Before raw-log grouping it resolves unregistered types from cached and incoming records through `getMessageHandler`; types selecting `drawMessageTool` join the process-step set. Explicit custom standalone handlers remain standalone. Keep the legacy `drawMessageDefault` export for plugin compatibility.
@@ -29,6 +30,10 @@
## Local Contracts
- Use ES modules and browser-compatible JavaScript.
+- `x-overflow` follows `display: contents` wrappers to find flex items. Each collapsible item is a button or contains a trigger; its sibling `[x-show]`, `[role=menu]`, `[role=dialog]`, or `[data-overflow-panel]` is reused as the submenu. `data-overflow-label` on the trigger may override its rendered label. Keep the row's containing flex item shrinkable (`min-width: 0`); non-control content stays inline. Native manual popovers preserve DOM scope while avoiding clipping and stacking conflicts. Resize/mutation observers and document listeners must be removed on unmount.
+- Overflow labels open submenus on hover and toggle them on click; a click-closed submenu stays closed until pointer exit or another click. When neither side has room, use the larger space above/below the first menu and scroll the submenu, keeping its label reachable.
+- Mark a compound visual with `data-overflow-icon` on the trigger or a child (for example, an avatar or percentage ring). Overflow entries mirror its rendered markup and updates without cloning Alpine bindings or interactive buttons; font icons, SVGs, and images are detected by default. Controls without a visual reserve no icon space.
+- Overflow measurements allow half a CSS pixel of rounding tolerance: browser zoom can make summed item rectangles and CSS gaps slightly exceed a shrink-wrapped row even when every control fits. Verify both fitting and genuinely constrained rows at native browser zoom levels.
- Create dynamic Material Symbols with `document.createElement("x-icon")` and assign `.name`; generated HTML uses an empty `<x-icon name="..."></x-icon>`. Shared helpers that can receive third-party plugin DOM must continue accepting legacy `.material-symbols-outlined` and `.material-icons-outlined` spans.
- Route JSON and fetch calls through `api.js` unless a caller has a specific nonstandard transport contract.
- `callJsonApi()` is for JSON request/response flows and must preserve CSRF/auth behavior.
diff --git a/webui/js/initFw.js b/webui/js/initFw.js
index 1df2dc281..8ebc95534 100644
--- a/webui/js/initFw.js
+++ b/webui/js/initFw.js
@@ -4,6 +4,7 @@ import "./surfaces.js";
import * as _components from "./components.js";
import * as extensions from "./extensions.js";
import { registerAlpineMagic } from "./confirmClick.js";
+import { registerOverflow } from "./overflow.js";
// process extensions
await extensions.callJsExtensions("initFw_start")
@@ -19,6 +20,7 @@ const Alpine = globalThis.Alpine;
// register $confirmClick magic helper for inline button confirmations
registerAlpineMagic();
+registerOverflow(Alpine);
// add x-destroy directive to alpine
Alpine.directive(
diff --git a/webui/js/overflow.js b/webui/js/overflow.js
new file mode 100644
index 000000000..cf8b672ee
--- /dev/null
+++ b/webui/js/overflow.js
@@ -0,0 +1,350 @@
+import { ICON_SELECTOR, getIconName } from "./icons.js";
+
+// Keep original controls in their Alpine scopes; overflow entries only forward actions.
+export function registerOverflow(Alpine) {
+ Alpine.directive("overflow", (row, _directive, { cleanup }) => {
+ cleanup(mountOverflow(row));
+ });
+}
+
+let nextId = 0;
+
+function flexItems(parent) {
+ return [...parent.children].flatMap(element => {
+ const display = getComputedStyle(element).display;
+ if (display === "none" || element.matches(".overflow-trigger, .overflow-menu")) return [];
+ return display === "contents" ? flexItems(element) : [element];
+ });
+}
+
+function icon(name) {
+ const element = document.createElement("x-icon");
+ element.setAttribute("name", name);
+ return element;
+}
+
+function controlVisual(button) {
+ const custom = button.matches("[data-overflow-icon]") ? button : button.querySelector("[data-overflow-icon]");
+ const source = custom || [...button.querySelectorAll(`${ICON_SELECTOR}, svg, img`)].find(element =>
+ !element.matches(ICON_SELECTOR) || !/^(expand_more|expand_less|arrow_drop_down)$/.test(getIconName(element)));
+ if (!source) return null;
+ if (!custom && source.matches(ICON_SELECTOR)) return icon(getIconName(source));
+
+ // Copy rendered visuals, never their Alpine bindings or interactive behavior.
+ let copy = source.cloneNode(true);
+ if (copy.matches("button")) {
+ const span = document.createElement("span");
+ span.className = copy.className;
+ span.style.cssText = copy.style.cssText;
+ span.append(...copy.childNodes);
+ copy = span;
+ }
+ copy.querySelectorAll("template, script").forEach(element => element.remove());
+ for (const element of [copy, ...copy.querySelectorAll("*")]) {
+ for (const attribute of [...element.attributes]) {
+ if (/^(x-|:|@|on)/.test(attribute.name) || ["id", "tabindex", "data-overflow-icon"].includes(attribute.name)) {
+ element.removeAttribute(attribute.name);
+ }
+ }
+ }
+ return copy;
+}
+
+function mountOverflow(row) {
+ const more = document.createElement("button");
+ more.type = "button";
+ more.className = "btn-icon-action overflow-trigger";
+ more.setAttribute("aria-label", "More controls");
+ more.setAttribute("aria-haspopup", "menu");
+ more.setAttribute("aria-expanded", "false");
+ more.append(icon("more_horiz"));
+
+ const menu = document.createElement("div");
+ menu.className = "dropdown-menu overflow-menu";
+ menu.setAttribute("popover", "manual");
+ menu.id = `overflow-menu-${++nextId}`;
+ menu.setAttribute("role", "menu");
+ menu.setAttribute("aria-label", "More controls");
+ more.setAttribute("aria-controls", menu.id);
+ more.hidden = menu.hidden = true;
+ row.classList.add("overflow-row");
+ row.append(more, menu);
+
+ const records = new Map();
+ let active = null;
+ let frame = 0;
+ let destroyed = false;
+ const events = new AbortController();
+ const listen = (element, event, handler, options = {}) =>
+ element.addEventListener(event, handler, { ...options, signal: events.signal });
+ const isOpen = record => record.panel && getComputedStyle(record.panel).display !== "none";
+ const schedule = () => {
+ if (!destroyed && !frame) frame = requestAnimationFrame(update);
+ };
+
+ function closePanel() {
+ if (!active) return;
+ const previous = active;
+ active = null;
+ // Dispatch also when an async action has temporarily disabled the trigger.
+ if (isOpen(previous) || previous.opening) previous.button.dispatchEvent(new MouseEvent("click", { bubbles: true }));
+ previous.closed = true;
+ if (previous.panel.classList.contains("overflow-panel")) {
+ previous.panel.hidePopover();
+ if (previous.popover === null) previous.panel.removeAttribute("popover");
+ else previous.panel.setAttribute("popover", previous.popover);
+ }
+ previous.panel.classList.remove("overflow-panel");
+ previous.entry.setAttribute("aria-expanded", "false");
+ }
+
+ function close(focus = false) {
+ closePanel();
+ menu.hidePopover();
+ menu.hidden = true;
+ more.setAttribute("aria-expanded", "false");
+ if (focus) more.focus();
+ }
+
+ function place(element, left, top) {
+ const rect = element.getBoundingClientRect();
+ element.style.setProperty("--overflow-left", `${Math.max(8, Math.min(left, innerWidth - rect.width - 8))}px`);
+ element.style.setProperty("--overflow-top", `${Math.max(8, Math.min(top, innerHeight - rect.height - 8))}px`);
+ }
+
+ function position() {
+ const trigger = more.getBoundingClientRect();
+ const bounds = menu.getBoundingClientRect();
+ place(menu, trigger.right - bounds.width,
+ trigger.top >= bounds.height + 8 ? trigger.top - bounds.height - 4 : trigger.bottom + 4);
+ if (!active || !isOpen(active)) return;
+ const parent = menu.getBoundingClientRect();
+ const entry = active.entry.getBoundingClientRect();
+ const panel = active.panel.getBoundingClientRect();
+ let left = parent.right;
+ let top = entry.top;
+ let height = innerHeight - 16;
+ let above = false;
+ if (left + panel.width > innerWidth - 8) {
+ left = parent.left - panel.width;
+ if (left < 8) {
+ left = parent.left;
+ const roomAbove = parent.top - 8;
+ const roomBelow = innerHeight - parent.bottom - 8;
+ above = roomAbove >= roomBelow;
+ height = Math.max(roomAbove, roomBelow);
+ top = above ? parent.top : parent.bottom;
+ }
+ }
+ active.panel.style.setProperty("--overflow-available-height", `${Math.max(0, height)}px`);
+ if (above) top -= active.panel.getBoundingClientRect().height;
+ place(active.panel, left, top);
+ }
+
+ function openPanel(record, focus = false) {
+ if (record.button.disabled || !record.panel) return;
+ if (active !== record) {
+ closePanel();
+ active = record;
+ record.opening = true;
+ // A close click updates Alpine before x-show finishes hiding the panel.
+ if (record.closed || !isOpen(record)) record.button.click();
+ record.closed = false;
+ }
+ record.focusPanel = focus;
+ schedule();
+ }
+
+ function createRecord(item, button) {
+ const panel = [...button.parentElement.children].find(element =>
+ element !== button && element.matches("[x-show], [role=menu], [role=dialog], [data-overflow-panel]"));
+ const entry = document.createElement("button");
+ entry.type = "button";
+ entry.className = "dropdown-item";
+ entry.setAttribute("role", "menuitem");
+ const label = document.createElement("span");
+ label.className = "overflow-label";
+ const visual = document.createElement("span");
+ visual.className = "overflow-icon";
+ visual.setAttribute("aria-hidden", "true");
+ visual.setAttribute("x-ignore", "");
+ entry.append(visual, label);
+ if (panel) {
+ if (!panel.id) panel.id = `overflow-panel-${++nextId}`;
+ entry.setAttribute("aria-controls", panel.id);
+ entry.setAttribute("aria-haspopup", panel.getAttribute("role") === "dialog" ? "dialog" : "menu");
+ entry.setAttribute("aria-expanded", "false");
+ entry.append(icon("chevron_right"));
+ }
+ const record = { item, button, panel, entry, label, visual, popover: panel?.getAttribute("popover") };
+ entry.addEventListener("pointermove", event => {
+ if (event.pointerType === "mouse" && active !== record && !record.hoverClosed) panel ? openPanel(record) : closePanel();
+ });
+ entry.addEventListener("pointerleave", () => { record.hoverClosed = false; });
+ entry.addEventListener("click", event => {
+ // The original Alpine click-outside handlers must see only the forwarded click.
+ event.stopPropagation();
+ if (panel) {
+ record.hoverClosed = active === record && isOpen(record);
+ if (record.hoverClosed) closePanel();
+ else openPanel(record);
+ }
+ else { button.click(); close(true); }
+ });
+ return record;
+ }
+
+ function update() {
+ frame = 0;
+ if (!row.isConnected) return;
+ mutations.disconnect();
+ const items = flexItems(row);
+ for (const [item, record] of records) {
+ if (!items.includes(item)) {
+ if (active === record) closePanel();
+ record.entry.remove();
+ item.classList.remove("overflow-item", "overflow-hidden");
+ resize.unobserve(item);
+ records.delete(item);
+ }
+ }
+ for (const item of items) {
+ item.classList.add("overflow-item");
+ item.classList.remove("overflow-hidden");
+ if (!records.has(item)) {
+ const button = item.matches("button, [role=button]") ? item : item.querySelector("button, [role=button]");
+ if (button) records.set(item, createRecord(item, button));
+ resize.observe(item);
+ }
+ }
+ more.hidden = true;
+ const style = getComputedStyle(row);
+ const gap = parseFloat(style.columnGap) || 0;
+ // Browser zoom rounds item rectangles and CSS gaps slightly differently.
+ const available = row.getBoundingClientRect().width - parseFloat(style.paddingLeft) - parseFloat(style.paddingRight)
+ - parseFloat(style.borderLeftWidth) - parseFloat(style.borderRightWidth) + 0.5;
+ let used = items.reduce((sum, item) => {
+ const css = getComputedStyle(item);
+ return sum + item.getBoundingClientRect().width + (parseFloat(css.marginLeft) || 0) + (parseFloat(css.marginRight) || 0);
+ }, gap * Math.max(0, items.length - 1));
+ more.hidden = used <= available;
+ if (!more.hidden) used += more.getBoundingClientRect().width + gap;
+ const overflowed = [];
+ for (const item of [...items].reverse()) {
+ if (used <= available) break;
+ const record = records.get(item);
+ if (!record) continue;
+ const css = getComputedStyle(item);
+ used -= item.getBoundingClientRect().width + (parseFloat(css.marginLeft) || 0) + (parseFloat(css.marginRight) || 0) + gap;
+ overflowed.unshift(record);
+ item.classList.add("overflow-hidden");
+ }
+ for (const record of records.values()) {
+ if (!overflowed.includes(record)) record.entry.remove();
+ }
+ for (const [index, record] of overflowed.entries()) {
+ const visual = controlVisual(record.button);
+ const visualMarkup = visual?.outerHTML || "";
+ if (record.visualMarkup !== visualMarkup) {
+ record.visual.replaceChildren(...(visual ? [visual] : []));
+ record.visualMarkup = visualMarkup;
+ }
+ const copy = record.button.cloneNode(true);
+ copy.querySelectorAll(`${ICON_SELECTOR}, svg, img, template, [aria-hidden=true], [data-overflow-icon]`).forEach(node => node.remove());
+ const label = record.button.dataset.overflowLabel || copy.textContent.trim().replace(/\s+/g, " ") || record.button.getAttribute("aria-label") || record.button.title;
+ if (record.label.textContent !== label) record.label.textContent = label;
+ record.entry.disabled = record.button.disabled || record.button.getAttribute("aria-disabled") === "true";
+ if (menu.children[index] !== record.entry) menu.insertBefore(record.entry, menu.children[index] || null);
+ }
+ if (!overflowed.length) { more.hidden = true; close(); }
+ else if (active && !overflowed.includes(active)) closePanel();
+ else if (active && !active.opening && !isOpen(active)) close(true);
+ if (active && isOpen(active)) {
+ // x-show can wait for a frame/transition after Alpine's nextTick.
+ if (active.opening) {
+ active.opening = false;
+ const maxHeight = getComputedStyle(active.panel).maxHeight;
+ active.panel.style.setProperty("--overflow-max-height", maxHeight === "none" ? "100dvh" : maxHeight);
+ active.panel.style.setProperty("--overflow-width", `${active.panel.getBoundingClientRect().width}px`);
+ active.panel.classList.add("overflow-panel");
+ active.panel.setAttribute("popover", "manual");
+ active.panel.showPopover();
+ active.entry.setAttribute("aria-expanded", "true");
+ }
+ if (active.focusPanel) {
+ active.panel.querySelector("button:not(:disabled), input:not(:disabled), [tabindex]")?.focus();
+ active.focusPanel = false;
+ }
+ }
+ if (!menu.hidden) position();
+ mutations.observe(row, { childList: true, subtree: true, characterData: true, attributes: true });
+ }
+
+ const resize = new ResizeObserver(schedule);
+ const mutations = new MutationObserver(changes => {
+ if (changes.some(change => !menu.contains(change.target) && !more.contains(change.target))) schedule();
+ });
+ resize.observe(row);
+ if (row.parentElement) resize.observe(row.parentElement);
+ listen(more, "click", event => {
+ event.stopPropagation();
+ if (!menu.hidden) return close();
+ menu.hidden = false;
+ menu.showPopover();
+ more.setAttribute("aria-expanded", "true");
+ position();
+ });
+ listen(document, "click", event => {
+ if (!row.contains(event.target)) close();
+ });
+ listen(document, "focusin", event => {
+ if (!row.contains(event.target)) close();
+ });
+ listen(row, "keydown", event => {
+ if (menu.hidden) {
+ if (event.target === more && ["ArrowDown", "ArrowUp"].includes(event.key)) {
+ more.click();
+ menu.querySelector("button:not(:disabled)")?.focus();
+ event.preventDefault();
+ }
+ return;
+ }
+ const editing = event.target.matches("input, textarea, select, [contenteditable]");
+ if (event.key === "Escape" || (active?.panel.contains(event.target) && event.key === "ArrowLeft" && !editing)) {
+ event.preventDefault();
+ event.stopPropagation();
+ if (active) { const entry = active.entry; closePanel(); entry.focus(); }
+ else close(true);
+ return;
+ }
+ if (!menu.contains(event.target) && event.target !== more) return;
+ const entries = [...menu.querySelectorAll("button:not(:disabled)")];
+ const index = entries.indexOf(document.activeElement);
+ if (["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) {
+ event.preventDefault();
+ closePanel();
+ const next = event.key === "Home" ? 0 : event.key === "End" ? entries.length - 1 :
+ (index + (event.key === "ArrowDown" ? 1 : -1) + entries.length) % entries.length;
+ entries[next]?.focus();
+ } else if (event.key === "ArrowRight") {
+ const record = [...records.values()].find(record => record.entry === event.target);
+ if (record?.panel) { event.preventDefault(); openPanel(record, true); }
+ }
+ });
+ listen(window, "resize", schedule);
+ listen(document, "scroll", () => { if (!menu.hidden) position(); }, { capture: true, passive: true });
+ schedule();
+
+ return () => {
+ destroyed = true;
+ cancelAnimationFrame(frame);
+ resize.disconnect();
+ mutations.disconnect();
+ events.abort();
+ closePanel();
+ row.querySelectorAll(".overflow-item").forEach(item => item.classList.remove("overflow-item", "overflow-hidden"));
+ row.classList.remove("overflow-row");
+ more.remove();
+ menu.remove();
+ };
+}