Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
import { describe, expect, it } from "vitest";
import {
advanceRouteChainInteraction,
createRouteChainInteraction,
} from "./routeChainInteraction";
import type { RouteHop } from "./types";
const hops: RouteHop[] = [
{ source_id: "src_a", model_id: "model_a" },
{ source_id: "src_b", model_id: "model_b" },
{ source_id: "src_c", model_id: "model_c" },
];
describe("route chain interaction owner", () => {
it("moves focus and the grabbed identity together without replacing its snapshot", () => {
const grabbed = advanceRouteChainInteraction(
createRouteChainInteraction(hops),
{ type: "begin-grab", index: 1 },
);
const moved = advanceRouteChainInteraction(grabbed, {
type: "move-grab",
direction: -1,
});
expect(moved.focusIndex).toBe(0);
expect(moved.grab?.index).toBe(0);
expect(moved.draft.map((hop) => hop.source_id)).toEqual([
"src_b",
"src_a",
"src_c",
]);
expect(
advanceRouteChainInteraction(moved, { type: "cancel-grab" }).draft,
).toEqual(hops);
});
it("owns the focus result for removals and appends", () => {
const removed = advanceRouteChainInteraction(
createRouteChainInteraction(hops),
{ type: "remove", index: 1 },
);
expect(removed.focusIndex).toBe(1);
const appended = advanceRouteChainInteraction(removed, {
type: "append",
hop: hops[1],
});
expect(appended.focusIndex).toBe(2);
expect(appended.draft).toEqual([hops[0], hops[2], hops[1]]);
});
it("replaces one hop without changing its position", () => {
const replacement = { source_id: "src_d", model_id: "model_d" };
const replaced = advanceRouteChainInteraction(
createRouteChainInteraction(hops),
{ type: "replace", index: 1, hop: replacement },
);
expect(replaced.focusIndex).toBe(1);
expect(replaced.grab).toBeNull();
expect(replaced.draft).toEqual([hops[0], replacement, hops[2]]);
});
});