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(ui): make the create-agent Runs-on list actually pickable

rubenluetke10-beepbcfadc78fec7
diff --git a/jarvis/ui/web/frontend/src/components/society/create/CreateAgentDialog.tsx b/jarvis/ui/web/frontend/src/components/society/create/CreateAgentDialog.tsx
index a2c582d3c8..279938bb2f 100644
--- a/jarvis/ui/web/frontend/src/components/society/create/CreateAgentDialog.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/create/CreateAgentDialog.tsx
@@ -32,7 +32,7 @@ import { effortLabel } from "@/components/agentchat/AgentComposer";
import { AgentMark } from "@/components/agentic/AgentMark";
import { ProviderLogo } from "@/components/providers/ProviderLogo";
import { Button } from "@/components/ui/button";
-import { Combobox, type ComboboxGroup } from "@/components/ui/combobox";
+import { Combobox, isComboboxPanelEvent, type ComboboxGroup } from "@/components/ui/combobox";
import { ScrollArea } from "@/components/ui/scroll-area";
import { useT } from "@/i18n";
import {
@@ -374,9 +374,18 @@ export function CreateAgentDialog({ open, onClose, onCreated }: CreateAgentDialo
<Dialog.Overlay className="fixed inset-0 z-40 bg-scrim/60 backdrop-blur-sm data-[state=open]:animate-in data-[state=open]:fade-in-0 motion-reduce:animate-none" />
<Dialog.Content
data-testid="create-agent-dialog"
- className="fixed inset-4 z-50 flex flex-col overflow-hidden rounded-lg border border-border bg-card shadow-float focus:outline-none data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 motion-reduce:animate-none lg:inset-y-8 lg:inset-x-16"
+ className="fixed inset-4 z-50 flex flex-col rounded-lg border border-border bg-card shadow-float focus:outline-none data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 motion-reduce:animate-none lg:inset-y-8 lg:inset-x-16"
+ onPointerDownOutside={(event) => {
+ if (isComboboxPanelEvent(event)) event.preventDefault();
+ }}
+ onFocusOutside={(event) => {
+ if (isComboboxPanelEvent(event)) event.preventDefault();
+ }}
+ onInteractOutside={(event) => {
+ if (isComboboxPanelEvent(event)) event.preventDefault();
+ }}
>
- <header className="flex shrink-0 items-center gap-3 border-b border-border px-5 py-3">
+ <header className="flex shrink-0 items-center gap-3 overflow-hidden rounded-t-lg border-b border-border px-5 py-3">
<div className="min-w-0 flex-1">
<Dialog.Title className="font-display text-base font-semibold tracking-tight text-foreground">
{t("society.create.title")}
@@ -393,7 +402,7 @@ export function CreateAgentDialog({ open, onClose, onCreated }: CreateAgentDialo
</Dialog.Close>
</header>
- <div className="grid min-h-0 flex-1 grid-cols-[minmax(320px,1fr)_minmax(360px,1.1fr)]">
+ <div className="grid min-h-0 flex-1 overflow-hidden rounded-b-lg grid-cols-[minmax(320px,1fr)_minmax(360px,1.1fr)]">
{/* ---- left: the three fields + Advanced ---- */}
<ScrollArea className="min-h-0 border-r border-border">
<form
@@ -463,6 +472,7 @@ export function CreateAgentDialog({ open, onClose, onCreated }: CreateAgentDialo
groups={seatGroups(seats, t)}
onChange={(id) => pickSeat(seats.find((s) => s.provider.id === id) ?? null)}
ariaLabel={t("society.create.brain")}
+ testId="society-create-provider"
/>
{accounts.length > 0 ? (
<div>
diff --git a/jarvis/ui/web/frontend/src/components/ui/combobox.test.tsx b/jarvis/ui/web/frontend/src/components/ui/combobox.test.tsx
index c2e810284f..34b504d3b7 100644
--- a/jarvis/ui/web/frontend/src/components/ui/combobox.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/ui/combobox.test.tsx
@@ -1,7 +1,9 @@
+import * as Dialog from "@radix-ui/react-dialog";
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
+import { useState } from "react";
import { afterEach, describe, expect, it, vi } from "vitest";
-import { Combobox } from "@/components/ui/combobox";
+import { Combobox, isComboboxPanelEvent } from "@/components/ui/combobox";
const GROUPS = [
{
@@ -143,3 +145,90 @@ describe("Combobox panel placement", () => {
expect(parseInt(panel.style.maxHeight, 10)).toBeGreaterThanOrEqual(160);
});
});
+
+describe("Combobox inside a modal dialog", () => {
+ it("marks the panel so a dialog can treat it as inside, and keeps pointer events", async () => {
+ render(<Combobox value="alpha" groups={GROUPS} onChange={() => {}} ariaLabel="Pick" testId="pick" />);
+ fireEvent.click(screen.getByTestId("pick"));
+ const panel = await screen.findByTestId("pick-panel");
+ expect(panel.getAttribute("data-combobox-panel")).toBe("");
+ expect(panel.className).toContain("pointer-events-auto");
+ });
+
+ it("mounts the list inside the nearest dialog so a modal can click it", async () => {
+ render(
+ <div role="dialog" data-testid="host-dialog">
+ <Combobox value="alpha" groups={GROUPS} onChange={() => {}} ariaLabel="Pick" testId="inside" />
+ </div>,
+ );
+ fireEvent.click(screen.getByTestId("inside"));
+ const panel = await screen.findByTestId("inside-panel");
+ expect(screen.getByTestId("host-dialog").contains(panel)).toBe(true);
+ expect(panel.parentElement).not.toBe(document.body);
+ });
+
+ it("lets a pick land without dismissing the wrapping Radix dialog", async () => {
+ const onChange = vi.fn();
+ function App() {
+ const [open, setOpen] = useState(true);
+ const [value, setValue] = useState("alpha");
+ return (
+ <Dialog.Root open={open} onOpenChange={setOpen}>
+ <Dialog.Portal>
+ <Dialog.Overlay />
+ <Dialog.Content
+ aria-describedby={undefined}
+ onPointerDownOutside={(event) => {
+ if (isComboboxPanelEvent(event)) event.preventDefault();
+ }}
+ onFocusOutside={(event) => {
+ if (isComboboxPanelEvent(event)) event.preventDefault();
+ }}
+ onInteractOutside={(event) => {
+ if (isComboboxPanelEvent(event)) event.preventDefault();
+ }}
+ >
+ <Dialog.Title>Create</Dialog.Title>
+ <Combobox
+ value={value}
+ groups={GROUPS}
+ onChange={(next) => {
+ setValue(next);
+ onChange(next);
+ }}
+ ariaLabel="Pick"
+ testId="modal-pick"
+ />
+ </Dialog.Content>
+ </Dialog.Portal>
+ </Dialog.Root>
+ );
+ }
+ render(<App />);
+ fireEvent.click(screen.getByTestId("modal-pick"));
+ const option = await screen.findByRole("option", { name: "Charlie" });
+ fireEvent.pointerDown(option);
+ fireEvent.click(option);
+ expect(onChange).toHaveBeenCalledWith("charlie");
+ expect(screen.getByText("Create")).toBeTruthy();
+ expect(screen.getByTestId("modal-pick").getAttribute("data-value")).toBe("charlie");
+ });
+});
+
+describe("isComboboxPanelEvent", () => {
+ it("reads the original click target, not the node the custom event is dispatched on", () => {
+ const panel = document.createElement("div");
+ panel.setAttribute("data-combobox-panel", "");
+ const option = document.createElement("div");
+ panel.appendChild(option);
+ const original = new Event("pointerdown");
+ Object.defineProperty(original, "target", { value: option });
+ expect(
+ isComboboxPanelEvent({
+ target: document.createElement("div"),
+ detail: { originalEvent: original },
+ }),
+ ).toBe(true);
+ expect(isComboboxPanelEvent({ target: document.createElement("div") })).toBe(false);
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/components/ui/combobox.tsx b/jarvis/ui/web/frontend/src/components/ui/combobox.tsx
index 707894af00..1322d302b0 100644
--- a/jarvis/ui/web/frontend/src/components/ui/combobox.tsx
+++ b/jarvis/ui/web/frontend/src/components/ui/combobox.tsx
@@ -30,9 +30,13 @@ import { cn } from "@/lib/utils";
* which dissolves the group order this control is built around. The list here
* filters and never reorders, so "the third entry" stays the third entry.
*
- * The panel is portalled to `document.body` and positioned fixed, because every
- * screen that uses it sits inside an `overflow-y-auto` column that would
- * otherwise clip it.
+ * The panel is positioned fixed and portalled out of the trigger's overflow
+ * column (every screen that uses this sits in one, and a native parent clip
+ * would cut the list off). A modal dialog sets `pointer-events: none` on
+ * `document.body` and only restores it on its own layer, so a panel dumped
+ * onto `body` paints on top of the dialog and receives no clicks — every
+ * option visible, none selectable. When the trigger lives in a dialog the
+ * panel lands inside that layer instead.
*/
export interface ComboboxOption {
@@ -87,6 +91,31 @@ const MAX_PANEL_HEIGHT = 340;
const MIN_PANEL_WIDTH = 288;
const VIEWPORT_MARGIN = 8;
+/** Marks the portalled list so a wrapping dialog can treat it as inside. */
+export const COMBOBOX_PANEL_ATTR = "data-combobox-panel";
+
+/**
+ * True when a Dialog outside-event originated on a Combobox panel (the
+ * original click target, not the dialog node the custom event is dispatched
+ * on). Used by dialogs that host a Combobox so picking an option does not
+ * count as "click outside" and close the sheet.
+ */
+export function isComboboxPanelEvent(event: {
+ target?: EventTarget | null;
+ detail?: { originalEvent?: Event };
+}): boolean {
+ const node = event.detail?.originalEvent?.target ?? event.target;
+ return node instanceof Element && node.closest(`[${COMBOBOX_PANEL_ATTR}]`) !== null;
+}
+
+/**
+ * Where the list mounts. A modal dialog is the clickable layer; `body` is
+ * not, while the dialog is open.
+ */
+function panelHost(trigger: HTMLElement | null): HTMLElement {
+ return trigger?.closest<HTMLElement>('[role="dialog"]') ?? document.body;
+}
+
function fold(value: string): string {
return value
.toLocaleLowerCase()
@@ -435,6 +464,7 @@ export function Combobox({
<div
ref={panelRef}
data-testid={testId ? `${testId}-panel` : undefined}
+ data-combobox-panel=""
style={{
left: position.left,
top: position.top,
@@ -446,7 +476,9 @@ export function Combobox({
// The one place a real shadow is allowed: this layer leaves the
// plane. Opaque --popover rather than a blurred translucent wash,
// so the list has a predictable ground whatever it covers.
- className="fixed z-[70] flex flex-col overflow-hidden rounded-lg border border-border-strong bg-popover shadow-float"
+ // pointer-events-auto: a modal dialog sets none on body, and this
+ // panel must still take the click even if it fell back to body.
+ className="pointer-events-auto fixed z-[70] flex flex-col overflow-hidden rounded-lg border border-border-strong bg-popover shadow-float"
>
{searchable && (
<div className="flex items-center gap-2 border-b border-border px-3 py-2">
@@ -567,7 +599,7 @@ export function Combobox({
))}
</div>
</div>,
- document.body,
+ panelHost(triggerRef.current),
)}
</>
);