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.

feat(chat): reorder providers on the model picker rail by drag or Alt+Arrow

rubenluetke10-beep2589ea919059
diff --git a/jarvis/ui/web/frontend/src/components/agentchat/ComposerBrainPicker.tsx b/jarvis/ui/web/frontend/src/components/agentchat/ComposerBrainPicker.tsx
index f40e08f24a..2ede595c33 100644
--- a/jarvis/ui/web/frontend/src/components/agentchat/ComposerBrainPicker.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentchat/ComposerBrainPicker.tsx
@@ -3,6 +3,7 @@ import { Star } from "lucide-react";
import { Combobox, type ComboboxGroup, type ComboboxOption } from "@/components/ui/combobox";
import { useT } from "@/i18n";
+import { orderBy, useProviderOrder } from "@/lib/providerOrder";
import { cn } from "@/lib/utils";
/**
@@ -100,6 +101,8 @@ export function ComposerBrainPicker({
const t = useT();
const [favorites, toggleFavorite] = useFavoriteModels();
const [section, setSection] = useState(currentSection);
+ const [providerOrder, moveProvider] = useProviderOrder();
+ const ordered = useMemo(() => orderBy(sections, (s) => s.id, providerOrder), [sections, providerOrder]);
// Every row carries its star; the favourites tab lists the starred rows in
// the order they were starred.
@@ -174,9 +177,17 @@ export function ComposerBrainPicker({
<Star className="h-4 w-4 fill-current" aria-hidden />
</RailButton>
<span className="mx-1 my-0.5 border-b border-border" aria-hidden />
- {sections.map((s) => (
+ {ordered.map((s, index) => (
<RailButton
key={s.id}
+ reorder={{
+ id: s.id,
+ onMove: (dragged, target) => moveProvider(ordered.map((o) => o.id), dragged, target),
+ onStep: (step) => {
+ const target = ordered[index + step];
+ if (target) moveProvider(ordered.map((o) => o.id), s.id, target.id);
+ },
+ }}
active={section === s.id}
label={s.label}
muted={s.muted}
@@ -219,12 +230,24 @@ export function ComposerBrainPicker({
);
}
+/** The drag payload a rail mark carries: the provider id it stands for. */
+const RAIL_DRAG = "application/x-jarvis-provider";
+
+export interface RailReorder {
+ id: string;
+ /** Drop `dragged` onto this mark's place. */
+ onMove: (dragged: string, target: string) => void;
+ /** Alt+Arrow: one place up (-1) or down (+1). */
+ onStep: (step: -1 | 1) => void;
+}
+
export function RailButton({
active,
label,
muted = false,
onSelect,
testId,
+ reorder,
children,
}: {
active: boolean;
@@ -232,8 +255,11 @@ export function RailButton({
muted?: boolean;
onSelect: () => void;
testId: string;
+ /** Lets the mark be dragged (or Alt+Arrowed) to another place on the rail. */
+ reorder?: RailReorder;
children: ReactNode;
}) {
+ const [dropTarget, setDropTarget] = useState(false);
return (
<button
type="button"
@@ -241,6 +267,32 @@ export function RailButton({
aria-pressed={active}
title={label}
data-testid={testId}
+ draggable={Boolean(reorder)}
+ onDragStart={(event) => {
+ if (!reorder) return;
+ event.dataTransfer.setData(RAIL_DRAG, reorder.id);
+ event.dataTransfer.effectAllowed = "move";
+ }}
+ onDragOver={(event) => {
+ if (!reorder || !event.dataTransfer.types.includes(RAIL_DRAG)) return;
+ event.preventDefault();
+ event.dataTransfer.dropEffect = "move";
+ setDropTarget(true);
+ }}
+ onDragLeave={() => setDropTarget(false)}
+ onDrop={(event) => {
+ setDropTarget(false);
+ const dragged = event.dataTransfer.getData(RAIL_DRAG);
+ if (!reorder || !dragged) return;
+ event.preventDefault();
+ reorder.onMove(dragged, reorder.id);
+ }}
+ onKeyDown={(event) => {
+ if (!reorder || !event.altKey || (event.key !== "ArrowUp" && event.key !== "ArrowDown")) return;
+ event.preventDefault();
+ event.stopPropagation();
+ reorder.onStep(event.key === "ArrowUp" ? -1 : 1);
+ }}
onClick={(event) => {
onSelect();
// Back to the search box, so typing right after a rail click searches.
@@ -253,6 +305,7 @@ export function RailButton({
"relative flex aspect-square w-full shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-sheen/[0.08] hover:text-foreground",
active && "bg-sheen/[0.06] text-foreground",
muted && "opacity-50",
+ dropTarget && "ring-1 ring-border-strong",
)}
>
{active && (
diff --git a/jarvis/ui/web/frontend/src/components/society/chat/AgentModelPicker.test.tsx b/jarvis/ui/web/frontend/src/components/society/chat/AgentModelPicker.test.tsx
index c273f88c6a..2d6119ccae 100644
--- a/jarvis/ui/web/frontend/src/components/society/chat/AgentModelPicker.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/chat/AgentModelPicker.test.tsx
@@ -388,3 +388,16 @@ test.each([
fireEvent.click(within(group).getByRole("menuitemradio", { name: /Default model/ }));
await waitFor(() => expect(posts[0]).toEqual({ provider: id, model: "", effort: "", account_id: "" }));
});
+
+test("rail marks move with Alt+Arrow and keep their place on reopen", async () => {
+ localStorage.removeItem("jarvis.chat.providerOrder");
+ mount(); const input = await open();
+ const railOrder = () => screen.getAllByTestId(/^agent-model-rail-(?!favorites)/).map((mark) => mark.getAttribute("data-testid"));
+ expect(railOrder()).toEqual(["agent-model-rail-gemini", "agent-model-rail-openai"]);
+ fireEvent.keyDown(screen.getByTestId("agent-model-rail-openai"), { key: "ArrowUp", altKey: true });
+ expect(railOrder()).toEqual(["agent-model-rail-openai", "agent-model-rail-gemini"]);
+ fireEvent.keyDown(input, { key: "Escape" });
+ await open();
+ expect(railOrder()).toEqual(["agent-model-rail-openai", "agent-model-rail-gemini"]);
+ localStorage.removeItem("jarvis.chat.providerOrder");
+});
diff --git a/jarvis/ui/web/frontend/src/components/society/chat/AgentModelPicker.tsx b/jarvis/ui/web/frontend/src/components/society/chat/AgentModelPicker.tsx
index c7ce751921..6c186f6c4d 100644
--- a/jarvis/ui/web/frontend/src/components/society/chat/AgentModelPicker.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/chat/AgentModelPicker.tsx
@@ -11,6 +11,7 @@ import { cn } from "@/lib/utils";
import { effortsFor, type BrainSeat } from "../create/brainPicker";
import { useUpdateAgentModel, type SocietyAgent } from "../data";
import { rankModels } from "@/lib/modelRanking";
+import { orderBy, useProviderOrder } from "@/lib/providerOrder";
import { collapsibleModels, matchesModel, modelEffort, modelGroupOrder, modelSeats, providerTitle, visibleModels } from "./modelChoices";
import { useModelMenuData } from "./useModelMenuData";
@@ -78,7 +79,9 @@ export function AgentModelPicker({ agent, busy, onSavingChange }: {
const activeSection = section === FAVORITES || groups.some((group) => group.seat.provider.id === section) ? section : groups[0]?.seat.provider.id ?? "";
const showFavorites = browsing && activeSection === FAVORITES;
const shownGroups = browsing ? groups.filter((group) => group.seat.provider.id === activeSection) : groups;
- const railSeats = groups.map((group) => group.seat);
+ const [providerOrder, moveProvider] = useProviderOrder();
+ const railSeats = orderBy(groups.map((group) => group.seat), (seat) => seat.provider.id, providerOrder);
+ const railIds = railSeats.map((seat) => seat.provider.id);
const starred = useMemo(() => favorites.flatMap((value) => {
for (const seat of seats) {
const model = seat.provider.curated_models.find((entry) => brainValue(seat.provider.id, entry.id) === value);
@@ -260,7 +263,9 @@ export function AgentModelPicker({ agent, busy, onSavingChange }: {
<Star className="h-4 w-4 fill-current" aria-hidden />
</RailButton>
<span className="mx-1 my-0.5 border-b border-border" aria-hidden />
- {railSeats.map((seat) => <RailButton key={seat.provider.id} active={browsing && activeSection === seat.provider.id} label={providerTitle(seat, t)}
+ {railSeats.map((seat, index) => <RailButton key={seat.provider.id} active={browsing && activeSection === seat.provider.id} label={providerTitle(seat, t)}
+ reorder={{ id: seat.provider.id, onMove: (dragged, target) => moveProvider(railIds, dragged, target),
+ onStep: (step) => { const target = railIds[index + step]; if (target) moveProvider(railIds, seat.provider.id, target); } }}
onSelect={() => pickSection(seat.provider.id)} testId={`agent-model-rail-${seat.provider.id}`}>
<span className="inline-flex scale-[1.3]"><ProviderLogo providerId={seat.provider.id} label={seat.provider.label} size="sm" /></span>
</RailButton>)}
diff --git a/jarvis/ui/web/frontend/src/lib/providerOrder.test.ts b/jarvis/ui/web/frontend/src/lib/providerOrder.test.ts
new file mode 100644
index 0000000000..1e0acbff2b
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/lib/providerOrder.test.ts
@@ -0,0 +1,15 @@
+import { describe, expect, it } from "vitest";
+
+import { moveId, orderBy } from "./providerOrder";
+
+describe("provider order", () => {
+ it("puts placed providers first and keeps the rest in catalog order", () => {
+ expect(orderBy(["a", "b", "c", "d"], (id) => id, ["c", "a"])).toEqual(["c", "a", "b", "d"]);
+ });
+
+ it("moves a provider onto another's place", () => {
+ expect(moveId(["a", "b", "c"], "c", "a")).toEqual(["c", "a", "b"]);
+ expect(moveId(["a", "b", "c"], "a", "b")).toEqual(["b", "a", "c"]);
+ expect(moveId(["a", "b"], "x", "a")).toEqual(["a", "b"]);
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/lib/providerOrder.ts b/jarvis/ui/web/frontend/src/lib/providerOrder.ts
new file mode 100644
index 0000000000..45c3fe7f17
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/lib/providerOrder.ts
@@ -0,0 +1,78 @@
+import { useCallback, useSyncExternalStore } from "react";
+
+/**
+ * The order a person dragged the providers into on a model picker's rail.
+ *
+ * One order for every picker (front page, threads, agent cards), kept in
+ * this browser only — a convenience, not a setting, so cleared storage just
+ * restores the catalog's own order. Providers never placed keep their
+ * catalog position relative to each other, after the placed ones.
+ */
+
+const KEY = "jarvis.chat.providerOrder";
+const listeners = new Set<() => void>();
+// useSyncExternalStore needs one stable array per stored value.
+let cached: { raw: string | null; ids: string[] } = { raw: null, ids: [] };
+
+function read(): string[] {
+ let raw: string | null = null;
+ try {
+ raw = window.localStorage.getItem(KEY);
+ } catch {
+ // Blocked storage: fall back to the catalog order.
+ }
+ if (raw === cached.raw) return cached.ids;
+ let ids: string[] = [];
+ try {
+ const parsed: unknown = JSON.parse(raw ?? "[]");
+ ids = Array.isArray(parsed) ? parsed.filter((v): v is string => typeof v === "string") : [];
+ } catch {
+ // Corrupt value: fall back to the catalog order.
+ }
+ cached = { raw, ids };
+ return ids;
+}
+
+function write(next: string[]): void {
+ try {
+ window.localStorage.setItem(KEY, JSON.stringify(next));
+ } catch {
+ // Storage refused the write: keep the order for this visit only.
+ cached = { raw: cached.raw, ids: next };
+ }
+ listeners.forEach((listener) => listener());
+}
+
+function subscribe(listener: () => void): () => void {
+ listeners.add(listener);
+ return () => listeners.delete(listener);
+}
+
+/** Sorts `items` by the saved order; unplaced items follow in their own order. */
+export function orderBy<T>(items: T[], idOf: (item: T) => string, saved: string[]): T[] {
+ const rank = new Map(saved.map((id, index) => [id, index]));
+ return items
+ .map((item, index) => ({ item, index, rank: rank.get(idOf(item)) ?? saved.length + index }))
+ .sort((a, b) => a.rank - b.rank)
+ .map((entry) => entry.item);
+}
+
+/** Moves `id` to `target`'s place within `ids` (the rail as it is shown now). */
+export function moveId(ids: string[], id: string, target: string): string[] {
+ const from = ids.indexOf(id);
+ const to = ids.indexOf(target);
+ if (from < 0 || to < 0 || from === to) return ids;
+ const next = ids.filter((entry) => entry !== id);
+ next.splice(to, 0, id);
+ return next;
+}
+
+export function useProviderOrder(): [string[], (shown: string[], id: string, target: string) => void] {
+ const saved = useSyncExternalStore(subscribe, read, () => []);
+ const move = useCallback((shown: string[], id: string, target: string) => {
+ const moved = moveId(shown, id, target);
+ // Keep the places of providers not on this rail (another picker's).
+ write([...moved, ...read().filter((entry) => !moved.includes(entry))]);
+ }, []);
+ return [saved, move];
+}