From 963084ca83bf1df9b1849dc1ec1c5c8c8f82f62d Mon Sep 17 00:00:00 2001 From: Kevin Longe <273747162+kvlonge@users.noreply.github.com> Date: Mon, 30 Nov 2026 14:53:35 +0000 Subject: [PATCH] fix(ui): nested folder boxes close inside a selected job, and folder cards count waiting nodes The canvas raises cards above edges by node type instead of the graph library's parent class, which is fixed when a node mounts, so a job card opened in place no longer covers the folder boxes inside it. Folder cards count a run's waiting nodes, falling back to dots and numbers when the counts don't fit. --- ui/e2e/group-run.spec.ts | 35 ++++++++++++++++++- ui/src/lib/components/graph/compact-title.ts | 3 ++ .../lib/components/graph/graph-canvas.svelte | 7 ++-- .../lib/components/lineage/folder-node.svelte | 27 ++++++++++---- ui/src/lib/lineage/catalog-graph.ts | 7 ++-- 5 files changed, 65 insertions(+), 14 deletions(-) diff --git a/ui/e2e/group-run.spec.ts b/ui/e2e/group-run.spec.ts index f222a75b8d..f70a371fad 100644 --- a/ui/e2e/group-run.spec.ts +++ b/ui/e2e/group-run.spec.ts @@ -1,4 +1,4 @@ -import { expect, test, type Page } from '@playwright/test'; +import { expect, test, type Locator, type Page } from '@playwright/test'; import { FakeControl, type FakeGroupRun } from './support/fake-control'; // A group run's page: one tree of its jobs, folders and nodes beside the timeline, the 40/60 split above @@ -541,6 +541,39 @@ test("jobs ticked beside a group run's graph are drawn as those jobs, closed, an await expect(members).toHaveCount(3); }); +test("an opened job's folder cards count its waiting nodes beside those done, and its folder boxes close one level at a time while the job is selected", async ({ page }) => { + const { fake, run } = server(['load_orders', 'stage_orders', 'orders_mart'], 160); + const job = run.members.find((m) => m.jobKey === 'load_orders')!; + job.nodes['model:load_orders_0'] = 'success'; + job.nodes['model:load_orders_1'] = 'running'; + await fake.install(page); + await page.setViewportSize({ width: 1600, height: 1000 }); + await page.goto(`/runs/${run.id}`); + await page.getByRole('tablist', { name: 'View' }).getByRole('tab', { name: 'Graph' }).click({ timeout: 20_000 }); + // Clicking the job selects it and opens it in place. + await page.locator('.svelte-flow__node-member').filter({ hasText: 'load_orders' }).click({ timeout: 20_000 }); + const folders = page.locator('.svelte-flow__node-folder'); + const boxes = page.locator('.svelte-flow__node-folderBox'); + await expect(folders).toHaveCount(1); + await expect(folders.locator('.status span')).toHaveText(['1 running', '1 ok', '158 waiting']); + + await folders.first().click(); + await expect(boxes).toHaveCount(1); + await folders.first().click(); + await expect(boxes).toHaveCount(2); + // A person clicks the header by its chevron: there, not under the selected job's box, the inner box closes. + const heads = boxes.locator('.folder-head'); + const press = async (head: Locator) => { + const at = (await head.boundingBox())!; + await page.mouse.click(at.x + 20, at.y + at.height / 2); + }; + await press(heads.last()); + await expect(boxes).toHaveCount(1); + await press(heads.first()); + await expect(boxes).toHaveCount(0); + await expect(folders).toHaveCount(1); +}); + test('a folder that shares its directory with another job ticks its own nodes, and ticks fully again after a node came back', async ({ page }) => { // Two jobs of 60 models each, both in sql/models/shared/part_0 and part_1: 30 of each job per folder. const { fake, run } = server(['load_orders', 'stage_orders'], 60); diff --git a/ui/src/lib/components/graph/compact-title.ts b/ui/src/lib/components/graph/compact-title.ts index e880941090..2a8916a314 100644 --- a/ui/src/lib/components/graph/compact-title.ts +++ b/ui/src/lib/components/graph/compact-title.ts @@ -140,5 +140,8 @@ const cardFamily = pageFamily('--font-mono', 'monospace'); /** The cards' name and status line font, as the status line measures it. */ export const measureText: Measure = measureIn(cardFamily, 0.62); +/** The folder cards' status line font, as the page sets `--font-sans` (Inter). */ +export const measureSans: Measure = measureIn(pageFamily('--font-sans', 'sans-serif'), 0.56); + /** The pills' name font: whatever the page sets `--font-node-compact` to. */ export const measureCompact: Measure = measureIn(pageFamily('--font-node-compact', 'sans-serif'), 0.66); diff --git a/ui/src/lib/components/graph/graph-canvas.svelte b/ui/src/lib/components/graph/graph-canvas.svelte index 1eeaed1ffd..2afcf6d0e8 100644 --- a/ui/src/lib/components/graph/graph-canvas.svelte +++ b/ui/src/lib/components/graph/graph-canvas.svelte @@ -192,9 +192,10 @@ /* Edges, plain, highlighted or selected, are drawn beneath every card, so they never take a card's click. The library raises edges from inside an open box to the box's contents' level, above the cards outside it; cards are put above every edge (and selected nodes are raised by at most about - 1000 per level of boxes). Open boxes (`parent`) keep the library's order, beneath the edges inside - them. An edge is hit only on its stroke. */ - .graph-canvas :global(.svelte-flow__node:not(.parent)) { + 1000 per level of boxes). Open boxes keep the library's order, beneath the edges inside them; they are + known by type, since the library's `parent` class is fixed when a node mounts, and a job card that + opens in place would stay raised above the folder boxes inside it. An edge is hit only on its stroke. */ + .graph-canvas :global(.svelte-flow__node:not(:is(.svelte-flow__node-memberBox, .svelte-flow__node-folderBox, .svelte-flow__node-job))) { z-index: 100000 !important; } .graph-canvas :global(.svelte-flow__edges svg) { diff --git a/ui/src/lib/components/lineage/folder-node.svelte b/ui/src/lib/components/lineage/folder-node.svelte index 46070f9085..d891c31aa0 100644 --- a/ui/src/lib/components/lineage/folder-node.svelte +++ b/ui/src/lib/components/lineage/folder-node.svelte @@ -5,15 +5,32 @@ import { Handle, Position, type NodeProps } from '@xyflow/svelte'; import type { GroupCard } from '$lib/lineage/catalog-graph'; import CompactFace from '$lib/components/graph/compact-face.svelte'; + import { measureSans } from '$lib/components/graph/compact-title'; + import { fonts } from '$lib/components/graph/fonts.svelte'; let { id, data }: NodeProps = $props(); const d = $derived(data as GroupCard); // Zoomed out, the folder's colour: anything running, as the run tree's rows do, then any failure, then any stale node, then ok. + // The status line's counts, most pressing first. When they don't fit in words, each keeps its dot and + // number; the card's title still names them all. + const counts = $derived( + [ + { n: d.running, word: 'running', mark: 'running' }, + { n: d.ok, word: 'ok', color: 'var(--sb-success)' }, + { n: d.stale, word: 'stale', color: 'var(--sb-stale)' }, + { n: d.failed, word: 'failed', color: 'var(--sb-error)' }, + { n: d.skipped, word: 'skipped', mark: 'skipped' }, + { n: d.waiting, word: 'waiting', mark: 'waiting' } + ].filter((c): c is typeof c & { n: number } => !!c.n) + ); + const said = $derived(counts.map((c) => `${c.n} ${c.word}`).join(', ')); + /** The card's 236 px less its border and the status line's padding; each count is a 6 px dot and a 5 px gap, 10 px apart. Measured again once the font has loaded. */ + const words = $derived((void fonts.ready, void fonts.version, counts.reduce((w, c) => w + 11 + measureSans(`${c.n} ${c.word}`, 11, 400), 10 * (counts.length - 1)) <= 236 - 2 - 32 - 10)); const tone = $derived(d.running ? 'var(--sb-running)' : d.failed ? 'var(--sb-error)' : d.stale ? 'var(--sb-stale)' : d.ok ? 'var(--sb-success)' : 'var(--sb-text-faint)'); -