feat(collab): cross-app selection — eeschema symbol ⇄ pcbnew footprint ghost highlight (collab-presence 0006)
Selecting a symbol in eeschema ghost-highlights the linked footprint(s) in
every pcbnew tab of the project, and vice versa — across users AND one
user's own two tabs. Native KIWAY cross-probe is inert in WASM (one frame
per page); this rides the presence layer instead.
- cross-app.ts: project-wide awareness-only room (presenceRoomId), publishes
full PresenceState at selection rate (cursor always null); peers() = other-
TOOL clients incl. own user's other tabs; window.__pcbjamCrossApp test handle
- presence-kicad.ts: parseSelectionEmit (bare array | {uuids,fpPaths}),
xselFromPeerState (pcbnew paths → symbol uuids; eeschema uuids verbatim),
cross peers appended to the kicadCollabSetRemote snapshot as
{id "<user>#x<client>", name "<user> · sch|pcb", xsel}
- C++ (zero fork changes): pcbnew emits {uuids, fpPaths} (FOOTPRINT::GetPath)
and ghost-renders xsel via path-tail suffix scan; eeschema resolves xsel via
ResolveItem gated to the CURRENT sheet (xsel arrives project-wide, unlike
room-scoped selections); ghostStyle = alphas × xselAlphaScale (0.55, tuner-
patchable); new exports kicadCollabGetSelectionFull / TestGetCrossMapped /
TestSelectComponent (skips power symbols — PWR_FLAG has no footprint) +
merged-image dispatch
- tests: presence suites extended (payload shape, ghost render pixel tests,
13/13) + new two-tab tests/web/cross-probe.spec.ts (passing vs real
partykit); eeschema pixel compares now target the #glcanvas-* GAL panel
(the whole-window #canvas compare flaked on the auto-dismissing version
infobar — also fixes the long-known presence-eeschema restore flake);
cross-app + presence-kicad vitest suites
Spec: docs/features/collab-presence/0006 (closed repo).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lg5jwWuhFH5dL8hEcBDuP2
This commit is contained in:
parent
157d60f6b8
commit
3186986a0a
14 changed files with 1276 additions and 48 deletions
|
|
@ -34,6 +34,7 @@ type Mod = {
|
|||
kicadCollabSetRemote(j: string): void;
|
||||
kicadCollabGetViewport(): string;
|
||||
kicadCollabGetSelection(): string;
|
||||
kicadCollabTestGetCrossMapped(): string;
|
||||
kicadCollabTestSelectFirst(): string;
|
||||
kicadCollabTestClearSelection(): boolean;
|
||||
};
|
||||
|
|
@ -49,6 +50,28 @@ function hasAbort(l: { consoleLogs: string[]; errors: string[] }): boolean {
|
|||
return [...l.consoleLogs, ...l.errors].some((s) => s.includes("Aborted("));
|
||||
}
|
||||
|
||||
/**
|
||||
* The visible GAL draw panel — the pixel-compare target for overlay tests.
|
||||
* `#canvas` is the WHOLE wx window; its chrome is not pixel-stable across a
|
||||
* test (the "older KiCad version" infobar auto-dismisses, widget carets
|
||||
* blink), which made whole-window before/after equality flaky. The presence
|
||||
* overlay renders only into the GL panel, so compare exactly that.
|
||||
*/
|
||||
async function galPanel(page: Page) {
|
||||
const glId = await page.evaluate(() => {
|
||||
const visible = Array.from(document.querySelectorAll('[id^="glcanvas-"]'))
|
||||
.map((c) => c as HTMLCanvasElement)
|
||||
.find(
|
||||
(c) =>
|
||||
window.getComputedStyle(c).display !== "none" &&
|
||||
c.getBoundingClientRect().width > 0,
|
||||
);
|
||||
return visible?.id ?? null;
|
||||
});
|
||||
expect(glId, "no visible GAL panel found").toBeTruthy();
|
||||
return page.locator(`#${glId}`);
|
||||
}
|
||||
|
||||
async function bootAndOpen(page: Page): Promise<void> {
|
||||
await page.goto("/kicad/eeschema.html");
|
||||
await expect(page.locator("#canvas")).toBeVisible({ timeout: 90000 });
|
||||
|
|
@ -236,7 +259,7 @@ test("remote render paints the overlay without touching local selection", async
|
|||
}) => {
|
||||
await bootAndOpen(page);
|
||||
|
||||
const canvas = page.locator("#canvas");
|
||||
const canvas = await galPanel(page);
|
||||
const before = await canvas.screenshot();
|
||||
|
||||
await page.evaluate(
|
||||
|
|
@ -295,6 +318,108 @@ test("remote render paints the overlay without touching local selection", async
|
|||
expect(hasAbort(testLogger)).toBe(false);
|
||||
});
|
||||
|
||||
test("cross-app ghost render: a pcbnew peer's xsel uuid resolves on the current sheet (0006)", async ({
|
||||
page,
|
||||
testLogger,
|
||||
}) => {
|
||||
await bootAndOpen(page);
|
||||
|
||||
const canvas = await galPanel(page);
|
||||
const before = await canvas.screenshot();
|
||||
|
||||
// A pcbnew peer snapshot entry: xsel = the symbol uuid derived from the
|
||||
// footprint's path by the TS side. The fixture has no symbols, but the C++
|
||||
// resolve/draw path is uuid-kind-agnostic — a wire uuid exercises it fully.
|
||||
await page.evaluate(
|
||||
({ id }) => {
|
||||
const w = window as unknown as PresenceWindow;
|
||||
w.Module.kicadCollabSetRemote(
|
||||
JSON.stringify({
|
||||
peers: [
|
||||
{
|
||||
id: "alice#x3",
|
||||
name: "alice · pcb",
|
||||
color: "#3b82f6",
|
||||
cursor: null,
|
||||
selection: [],
|
||||
xsel: [id],
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
},
|
||||
{ id: WIRE1 },
|
||||
);
|
||||
|
||||
// Resolves onto the current sheet → probe reports it, ghost outline paints.
|
||||
await expect
|
||||
.poll(
|
||||
() =>
|
||||
page.evaluate(() =>
|
||||
JSON.parse(
|
||||
(window as unknown as PresenceWindow).Module.kicadCollabTestGetCrossMapped(),
|
||||
),
|
||||
),
|
||||
{ timeout: 10000 },
|
||||
)
|
||||
.toEqual([WIRE1]);
|
||||
await expect
|
||||
.poll(
|
||||
async () => !(await canvas.screenshot()).equals(before),
|
||||
{ timeout: 15000, intervals: [500] },
|
||||
)
|
||||
.toBe(true);
|
||||
|
||||
// No selection leak, unknown uuids map to nothing, clear restores pixels.
|
||||
const localSel = await page.evaluate(() =>
|
||||
JSON.parse((window as unknown as PresenceWindow).Module.kicadCollabGetSelection()),
|
||||
);
|
||||
expect(localSel).toEqual([]);
|
||||
|
||||
await page.evaluate(() => {
|
||||
const w = window as unknown as PresenceWindow;
|
||||
w.Module.kicadCollabSetRemote(
|
||||
JSON.stringify({
|
||||
peers: [
|
||||
{
|
||||
id: "alice#x3",
|
||||
name: "alice · pcb",
|
||||
color: "#3b82f6",
|
||||
cursor: null,
|
||||
selection: [],
|
||||
xsel: ["99999999-0000-0000-0000-000000000099"],
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
});
|
||||
await expect
|
||||
.poll(
|
||||
() =>
|
||||
page.evaluate(() =>
|
||||
JSON.parse(
|
||||
(window as unknown as PresenceWindow).Module.kicadCollabTestGetCrossMapped(),
|
||||
),
|
||||
),
|
||||
{ timeout: 10000 },
|
||||
)
|
||||
.toEqual([]);
|
||||
|
||||
await page.evaluate(() =>
|
||||
(window as unknown as PresenceWindow).Module.kicadCollabSetRemote(
|
||||
JSON.stringify({ peers: [] }),
|
||||
),
|
||||
);
|
||||
await expect
|
||||
.poll(
|
||||
async () => (await canvas.screenshot()).equals(before),
|
||||
{ timeout: 15000, intervals: [500] },
|
||||
)
|
||||
.toBe(true);
|
||||
|
||||
expect(hasAbort(testLogger)).toBe(false);
|
||||
});
|
||||
|
||||
test("viewport export returns a sane world↔screen transform", async ({ page, testLogger }) => {
|
||||
await bootAndOpen(page);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue