mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-07 17:04:42 +00:00
* feat(plugin): expose stable sidebar entity data across hosts Collections return interned references and preserve their arrays when membership and order stay unchanged. Entity selectors share one hook with identity defaults for full snapshots and shallow defaults for selections. The app caches host projections and shares underlying store and host subscriptions. Browser render counts exercise the real session store and plugin provider without memoized rows. Terminal hooks consume the collection source port; daemon-wide terminal discovery is the separate terminal phase. * feat(plugin): let users select a sidebar view An exclusive view replaces the sidebar content while the host retains navigation, callouts, and footer. The device remembers the selection, unavailable views fall back to the default, and throwing views provide recovery. Device-scoped plugin settings persist locally with schema validation and revision conflicts. Web E2E and Android tablet QA cover selection, preserved chrome, disabled-view fallback, and error recovery. * feat(plugin): add sidebar view examples and ref actions Keep sidebar layout and gestures inside the plugin while routing entity handles to their owning hosts. Examples cover empty projects, pinned workspaces, task sections, nested agents and device-local label folders. * feat(plugin): observe terminals across connected hosts Share host-wide terminal observations across plugin surfaces and gate them on terminalCollection. Keep directory observations compatible, and carry creation time in worker v6 state so v5 terminals can drain with an unknown timestamp.
59 lines
2.6 KiB
TypeScript
59 lines
2.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { createCollectionQuery, type GroupKey } from "./query.js";
|
|
|
|
const first = Object.freeze({ key: "a" });
|
|
const second = Object.freeze({ key: "b" });
|
|
const work: GroupKey = "work";
|
|
const snapshots = [
|
|
{ ref: first, hostId: "one", title: "A", status: "running", labels: [work, work] },
|
|
{ ref: second, hostId: "two", title: "B", status: "idle", labels: ["home"] },
|
|
];
|
|
|
|
describe("collection query structural sharing", () => {
|
|
it("preserves collection identity when a row changes without changing membership", () => {
|
|
const project = createCollectionQuery<(typeof snapshots)[number]>();
|
|
const before = project(snapshots);
|
|
const after = project([{ ...snapshots[0]!, status: "waiting" }, snapshots[1]!]);
|
|
expect(after).toBe(before);
|
|
expect(after).toEqual([first, second]);
|
|
});
|
|
|
|
it("shares unaffected groups and deduplicates membership", () => {
|
|
const project = createCollectionQuery<(typeof snapshots)[number]>();
|
|
const query = { groupBy: (item: (typeof snapshots)[number]) => item.labels };
|
|
const before = project(snapshots, query);
|
|
const after = project([{ ...snapshots[0]!, labels: ["new"] }, snapshots[1]!], query);
|
|
expect(after[1]).toBe(before[1]);
|
|
expect(before[0]).toEqual({ key: "work", title: null, color: null, items: [first] });
|
|
expect(after[0]).toEqual({ key: "new", title: null, color: null, items: [first] });
|
|
expect(project([{ ...snapshots[0]!, labels: ["new"] }, snapshots[1]!], query)).toBe(after);
|
|
});
|
|
|
|
it("filters hosts and predicates before sorting", () => {
|
|
const project = createCollectionQuery<(typeof snapshots)[number]>();
|
|
expect(project(snapshots, { hosts: ["two"] })).toEqual([second]);
|
|
expect(project(snapshots, { where: (item) => item.status === "running" })).toEqual([first]);
|
|
expect(project(snapshots, { orderBy: ["title", "desc"] })).toEqual([second, first]);
|
|
expect(project(snapshots, { orderBy: (a, b) => a.title.localeCompare(b.title) })).toEqual([
|
|
first,
|
|
second,
|
|
]);
|
|
});
|
|
|
|
it("keeps nulls last in either direction and metadata from the first group", () => {
|
|
const project = createCollectionQuery<{
|
|
ref: typeof first;
|
|
hostId: string;
|
|
title: string | null;
|
|
}>();
|
|
const items = [
|
|
{ ref: first, hostId: "one", title: null },
|
|
{ ref: second, hostId: "one", title: "Z" },
|
|
];
|
|
expect(project(items, { orderBy: ["title", "desc"] })).toEqual([second, first]);
|
|
expect(
|
|
project(items, { groupBy: (item) => ({ key: "all", title: item.title ?? "First" }) }),
|
|
).toEqual([{ key: "all", title: "First", color: null, items: [first, second] }]);
|
|
});
|
|
});
|