Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(agentic): the split menu opens at the button, not at the top of the window

rubenluetke10-beep3db591bd48d0
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgentPicker.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgentPicker.test.tsx
index 432a8d4dbd..05edcaf80b 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgentPicker.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgentPicker.test.tsx
@@ -158,10 +158,32 @@ describe("AgentPickerMenu anchored outside its caller", () => {
render(<AnchoredHarness rect={{ top: 700, bottom: 730, right: 700 }} />);
const menu = screen.getByTestId("picker");
- expect(parseFloat(menu.style.top)).toBeLessThan(700);
+ // Anchored by its BOTTOM edge, and by nothing else: a `top` computed from
+ // the room above would drop a short list at the start of that room, which
+ // is the window's top edge rather than the button it belongs to.
+ expect(menu.style.top).toBe("");
+ expect(parseFloat(menu.style.bottom)).toBe(VIEWPORT.height - 700 + 4);
expect(parseFloat(menu.style.maxHeight)).toBeGreaterThan(0);
});
+ /*
+ * The pane sat in the lower half of a tall window with 640px of clear space
+ * under its header — room enough for the whole list — and the menu still
+ * went up, because the old rule only compared the two gaps and "above" won
+ * by 50px. Combined with the top-anchored flip, the menu landed against the
+ * window's top edge, half a screen from the split button that opened it
+ * (maintainer report 2026-08-24).
+ */
+ it("stays under the anchor when the room below holds the list, however low the pane sits", () => {
+ window.innerWidth = 2560;
+ window.innerHeight = 1370;
+ render(<AnchoredHarness rect={{ top: 703, bottom: 717, right: 838 }} />);
+
+ const menu = screen.getByTestId("picker");
+ expect(menu.style.bottom).toBe("");
+ expect(parseFloat(menu.style.top)).toBe(717 + 4);
+ });
+
it("keeps a menu opened near the right edge inside the window", () => {
window.innerWidth = VIEWPORT.width;
window.innerHeight = VIEWPORT.height;
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgentPicker.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgentPicker.tsx
index 159d084edd..9298030c3a 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgentPicker.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgentPicker.tsx
@@ -87,31 +87,52 @@ const MENU_WIDTH_PX = 272;
const MENU_GAP_PX = 4;
/** Never hang closer than this to a window edge. */
const VIEWPORT_MARGIN_PX = 8;
+/**
+ * The least room below the anchor still worth dropping into.
+ *
+ * Under the button is where a menu belongs and where the eye already is, so
+ * flipping it above is a last resort rather than the winner of a contest
+ * between two numbers. The old `below >= above` rule flipped a pane sitting
+ * anywhere past the middle of a tall window — with 640px of clear space under
+ * the header, more than the whole list needs, the menu still went up.
+ */
+const MENU_ROOM_PX = 220;
-type FixedPlacement = { left: number; top: number; maxHeight: number };
+/** One of `top` and `bottom` is set: the menu hangs below the anchor, or above it. */
+type FixedPlacement = { left: number; maxHeight: number; top?: number; bottom?: number };
/**
* Where a detached menu hangs, measured from the element it belongs to.
*
* Right-aligned with the anchor, because that is where the buttons that open
- * it sit, and flipped above it when the space below is the shorter of the two.
- * Both numbers are clamped into the window: a pane in the last column would
- * otherwise put half the menu past the right edge, where it is unreachable.
+ * it sit, and flipped above it only when the room below cannot hold a usable
+ * list. Both numbers are clamped into the window: a pane in the last column
+ * would otherwise put half the menu past the right edge, where it is
+ * unreachable.
+ *
+ * The upward flip anchors the menu's BOTTOM edge, never its top. A top
+ * computed as "anchor minus the available room" places a short menu at the
+ * start of that room — which is the window's top edge, half a screen away
+ * from the button that opened it (maintainer report 2026-08-24). The space
+ * available and the space used are different numbers; only `bottom` keeps the
+ * menu against the anchor whatever its height turns out to be.
*/
function placeMenu(rect: DOMRect, viewport: { width: number; height: number }): FixedPlacement {
const below = viewport.height - rect.bottom - MENU_GAP_PX - VIEWPORT_MARGIN_PX;
const above = rect.top - MENU_GAP_PX - VIEWPORT_MARGIN_PX;
- const dropsDown = below >= above;
+ const dropsDown = below >= MENU_ROOM_PX || below >= above;
const maxHeight = Math.max(96, Math.min(dropsDown ? below : above, viewport.height * 0.7));
const left = Math.max(
VIEWPORT_MARGIN_PX,
Math.min(rect.right - MENU_WIDTH_PX, viewport.width - MENU_WIDTH_PX - VIEWPORT_MARGIN_PX),
);
- return {
- left,
- top: dropsDown ? rect.bottom + MENU_GAP_PX : Math.max(VIEWPORT_MARGIN_PX, rect.top - MENU_GAP_PX - maxHeight),
- maxHeight,
- };
+ return dropsDown
+ ? { left, top: rect.bottom + MENU_GAP_PX, maxHeight }
+ : {
+ left,
+ bottom: Math.max(VIEWPORT_MARGIN_PX, viewport.height - rect.top + MENU_GAP_PX),
+ maxHeight,
+ };
}
export function AgentPickerMenu({
@@ -207,7 +228,11 @@ export function AgentPickerMenu({
? {
position: "fixed",
left: placement.left,
+ // Exactly one of the two carries a number; the other stays `auto`, so
+ // a menu flipped above the anchor grows upwards from its own bottom
+ // edge instead of hanging from a top the list may never reach.
top: placement.top,
+ bottom: placement.bottom,
width: MENU_WIDTH_PX,
maxHeight: placement.maxHeight,
}