Watch
0
0
Fork
You've already forked hyperhive
0

swarm ui: the header's tabs can be dragged onto each other to reorder them

Group tabs now show the grip and drag like agent tabs, and every tab in the strip takes the place of the tab another one is dropped on; the order is kept with the open tabs. An agent's tab keeps its other drag, onto a terminal to split it. moveTab is a pure function with tests.
This commit is contained in:
iris 2026-11-20 18:32:23 +01:00
commit f4421b216f

View file

@ -0,0 +1,26 @@
// The order of the header's dynamic tabs. Run by `npm test`.
import assert from "node:assert/strict";
import { test } from "node:test";
import { moveTab } from "../src/shell/tab-order.ts";
const tabs = ["a", "b", "c", "d"].map((href) => ({ href }));
const order = (list) => list.map((t) => t.href).join("");
test("a tab moved right takes the place of the tab it lands on", () => {
assert.equal(order(moveTab(tabs, "a", "c")), "bcad");
});
test("a tab moved left lands before the tab it is dropped on", () => {
assert.equal(order(moveTab(tabs, "d", "b")), "adbc");
});
test("dropping a tab on itself, or naming a tab that is gone, changes nothing", () => {
assert.equal(moveTab(tabs, "b", "b"), tabs);
assert.equal(moveTab(tabs, "x", "b"), tabs);
assert.equal(moveTab(tabs, "b", "x"), tabs);
});
test("the list it was given is left as it was", () => {
moveTab(tabs, "a", "d");
assert.equal(order(tabs), "abcd");
});