From ba24efdac0ca6e111cce3a7cd20f511fb46dea64 Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Thu, 19 Nov 2026 14:11:16 +0100 Subject: [PATCH 1/8] test: a labelled lease shows its label in the Leases page (#1757) --- ui/src/screens/leases/leases.dom.test.tsx | 44 +++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/ui/src/screens/leases/leases.dom.test.tsx b/ui/src/screens/leases/leases.dom.test.tsx index 87cd4fde0..a4be12301 100644 --- a/ui/src/screens/leases/leases.dom.test.tsx +++ b/ui/src/screens/leases/leases.dom.test.tsx @@ -107,6 +107,50 @@ describe("the leases page", () => { expect(tableRow(/ci-runner-3/)).not.toHaveTextContent("tok_ci"); }); + it("a labelled lease shows its label in the Held by cell, the side list and the drawer, the page filter finds it, a long label is cut with the whole label in title, and an unlabelled lease reads as today", async () => { + const longLabel = "a-very-long-feature-label-that-would-not-fit-on-one-line-of-the-cell-x"; + const { user } = renderConsole({ + path: "/leases", + routes: { + ...hostWith([ + lease({ + id: "lse_labelled", + label: "feature-x", + requesterId: "agent-labelled", + ttlDeadline: NOW + 120_000, + }), + lease({ + deviceId: "dev_2", + id: "lse_long", + label: longLabel, + requesterId: "agent-long", + }), + lease({ deviceId: "dev_3", id: "lse_plain", requesterId: "agent-plain" }), + ]), + ...detailsOf(leaseDetails({ id: "lse_labelled" })), + }, + }); + expect(await screen.findByRole("link", { name: "agent-labelled" })).toBeVisible(); + + const labelled = tableRow(/agent-labelled/); + const cell = within(labelled).getByText("feature-x"); + expect(cell).toHaveAttribute("title", "feature-x"); + expect(cell.nextElementSibling).toHaveTextContent("agent-labelled"); + const long = within(tableRow(/agent-long/)).getByText(longLabel); + expect(long).toHaveAttribute("title", longLabel); + expect(long).toHaveClass("lease-ellipsis"); + expect(tableRow(/agent-plain/)).not.toHaveTextContent("feature-x"); + expect(within(leaseSummary()).getByText(/^feature-x · iPhone 16/)).toBeVisible(); + + await user.type(screen.getByRole("searchbox", { name: "Search leases" }), "feature-x"); + expect(screen.getAllByRole("row")).toHaveLength(1 + 1); + expect(tableRow(/agent-labelled/)).toBeVisible(); + + await user.click(tableRow(/agent-labelled/)); + expect(await within(leasePane()).findByText("lse_labelled")).toBeVisible(); + expect(fact(leasePane(), "Label")).toHaveTextContent("feature-x"); + }); + it("a lease row opens its inspector beside the table at the lease's address", async () => { const { user } = renderConsole({ path: "/leases", From d94950b2ddc26794f83414c6e038bb6d39560217 Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Thu, 19 Nov 2026 14:11:55 +0100 Subject: [PATCH 2/8] feat(console): the Leases page shows a lease's label (#1757) --- ui/src/model/leases.ts | 11 +++++++++-- ui/src/screens/leases/index.tsx | 13 ++++++++++--- ui/src/screens/leases/inspector.tsx | 3 +++ ui/src/screens/leases/leases.css | 11 +++++++++++ ui/src/screens/leases/leases.test.tsx | 1 + ui/src/screens/leases/summary.tsx | 4 ++-- 6 files changed, 36 insertions(+), 7 deletions(-) diff --git a/ui/src/model/leases.ts b/ui/src/model/leases.ts index 79d52480c..87b69d992 100644 --- a/ui/src/model/leases.ts +++ b/ui/src/model/leases.ts @@ -125,6 +125,9 @@ export interface LeaseRowView { readonly model: string; readonly worker?: string; readonly sub: string; + // why: the side list's second line leads with the label, the table's device title does not. + readonly listSub: string; + readonly label?: string; // why: the OS the device runs, as the table's second line names it ("iOS 18.4"). readonly runtime?: string; readonly platform?: string; @@ -164,8 +167,10 @@ export function leaseRows(input: { remaining: formatCountdown(lease.ttlDeadline - now), remainingMs: lease.ttlDeadline - now, renewedAgo: `${formatAgo(now - lease.lastRenewedAt)}`, + listSub: [lease.label, sub].filter((part) => part !== undefined).join(" · "), sub, to: leasePath(lease.id), + ...(lease.label === undefined ? {} : { label: lease.label }), ...(worker === undefined ? {} : { worker }), ...(device === undefined ? {} : { platform: device.spec.platform }), ...runtimeOf(device), @@ -199,7 +204,7 @@ export function searchLeaseRows( const wanted = query.toLowerCase(); if (wanted === "") return rows; return rows.filter((row) => - [row.holder, row.model, row.worker, row.id].some((field) => + [row.holder, row.label, row.model, row.worker, row.id].some((field) => field?.toLowerCase().includes(wanted), ), ); @@ -232,6 +237,7 @@ export interface LeaseInspection { readonly udid: string; }; readonly holder?: Holder; + readonly label?: string; readonly ownerId?: string; readonly requestId?: string; } @@ -303,13 +309,14 @@ function recordFacts( id: string, ): Pick< LeaseInspection, - "renewed" | "title" | "kind" | "percent" | "holder" | "ownerId" | "ttl" | "token" + "renewed" | "title" | "kind" | "percent" | "holder" | "label" | "ownerId" | "ttl" | "token" > { if (record === undefined) return { kind: "unknown", renewed: "—", title: id }; const holder = holderOf(record.requesterId, tokens); return { holder, kind: agentKind(record.requesterId), + ...(record.label === undefined ? {} : { label: record.label }), percent: percentLeft(deadline, now, record.ttlMs), token: record.ownerId, ttl: formatDuration(record.ttlMs), diff --git a/ui/src/screens/leases/index.tsx b/ui/src/screens/leases/index.tsx index 2824f16fc..64d10394d 100644 --- a/ui/src/screens/leases/index.tsx +++ b/ui/src/screens/leases/index.tsx @@ -92,9 +92,16 @@ const COLUMNS: readonly Column[] = [ cell: (row) => ( - - {row.holderDisplay} - + + {row.label === undefined ? null : ( + + {row.label} + + )} + + {row.holderDisplay} + + ), header: "Held by", diff --git a/ui/src/screens/leases/inspector.tsx b/ui/src/screens/leases/inspector.tsx index 145babd07..0edc08db9 100644 --- a/ui/src/screens/leases/inspector.tsx +++ b/ui/src/screens/leases/inspector.tsx @@ -149,6 +149,9 @@ export function LeaseFacts({ lease }: { readonly lease: LeaseInspection }) { ), }, { label: "Granted", value: `${lease.heldFor} ago · ${lease.granted}` }, + ...(lease.label === undefined + ? [] + : [{ label: "Label", value: {lease.label} }]), ...(lease.holder?.label === undefined ? [] : [{ label: "Holder", value: {lease.holder.id} }]), diff --git a/ui/src/screens/leases/leases.css b/ui/src/screens/leases/leases.css index aa9ca2f6a..a37641377 100644 --- a/ui/src/screens/leases/leases.css +++ b/ui/src/screens/leases/leases.css @@ -86,6 +86,17 @@ min-width: 0; } +.lease-holder-text { + display: flex; + flex-direction: column; + min-width: 0; +} + +.lease-label { + color: var(--text-muted); + font-size: 11.5px; +} + .lease-holder a { overflow: hidden; color: var(--text); diff --git a/ui/src/screens/leases/leases.test.tsx b/ui/src/screens/leases/leases.test.tsx index 624ca1d44..910836fe5 100644 --- a/ui/src/screens/leases/leases.test.tsx +++ b/ui/src/screens/leases/leases.test.tsx @@ -33,6 +33,7 @@ function row(overrides: Partial = {}): LeaseRowView { renewedAgo: "30 s ago", runtime: "iOS 18.4", worker: "mac-mini-1", + listSub: "iPhone 16 · mac-mini-1", sub: "iPhone 16 · mac-mini-1", to: "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/leases/lse_1/", ...overrides, diff --git a/ui/src/screens/leases/summary.tsx b/ui/src/screens/leases/summary.tsx index a879f7b36..d43f7cdf0 100644 --- a/ui/src/screens/leases/summary.tsx +++ b/ui/src/screens/leases/summary.tsx @@ -65,8 +65,8 @@ export function LeaseSummaryPane({ summary }: { readonly summary: LeaseSummary }
{row.holderDisplay}
-
- {row.sub} +
+ {row.listSub}
From 1e43d1a0ac36107063ee2b9f10cb47520c324b08 Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Thu, 19 Nov 2026 14:12:30 +0100 Subject: [PATCH 3/8] test: the dialog's lease result reads label, holder and model and is found by the label (#1757) --- ui/src/model/search.test.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ui/src/model/search.test.ts b/ui/src/model/search.test.ts index e187df401..d9c80fc85 100644 --- a/ui/src/model/search.test.ts +++ b/ui/src/model/search.test.ts @@ -107,6 +107,26 @@ describe("the search results", () => { }); }); +describe("a labelled lease in the search", () => { + it("reads `