Skip to content

Agent Zero AI framework

Keep context window popover within bounds

Alessandrofd7eff864fce
diff --git a/plugins/_context_window/AGENTS.md b/plugins/_context_window/AGENTS.md
index b1aa0c1a2..7748c7463 100644
--- a/plugins/_context_window/AGENTS.md
+++ b/plugins/_context_window/AGENTS.md
@@ -54,7 +54,7 @@
- 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.
+ profile selectors, including its reserved footprint for short selector labels.
## 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 fa8150452..0d38c4c22 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
@@ -80,6 +80,9 @@
</div>
<style>
+ .model-switcher-container:has(.context-window-anchor) {
+ min-width: min(19rem, calc(100vw - 2rem));
+ }
.context-window-anchor {
position: static;
display: flex;
@@ -229,6 +232,9 @@
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;
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 4ad144caf..b97bba481 100644
--- a/plugins/_context_window/tests/test_context_window.py
+++ b/plugins/_context_window/tests/test_context_window.py
@@ -155,6 +155,8 @@ 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 "width: min(19rem, calc(100vw - 2rem))" in component
assert "right: 1.25rem" in component
assert "width: min(17rem, calc(100vw - 3rem))" in component