Files
paseo/packages/app/e2e/helpers/project-status-badge.ts
T
Kevin AspesiGitHubpaseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com>
429155b536 Add collapsed-project status badge to the sidebar (#2340)
* Add collapsed-project status badge to the sidebar

Collapsed project rows now surface the most urgent hidden workspace's
status as a corner badge on the project icon, instead of giving no
signal at all: a loader for running, an alert for needs_input, a dot
for attention/failed, nothing for done. Priority order (needs_input >
failed > running > attention > done) means a working project keeps
its loader even if another workspace is also awaiting review.

Every surfaced status shares one badge shell (size, ring, offset) so
the loader, alert, and dot never draw a differently-sized circle -
previously the loader/alert used a 12pt ring while the dot used a
7-9pt one with a different corner offset. The running loader is also
nudged half a point left so its visual center lands on the circle's
center rather than reading as shifted right.

Adds an e2e capture spec (run on demand, not part of CI) that seeds
every state and edge case through the mock provider and dumps DOM
geometry, for re-verifying the badge shell stays uniform.

* Add PR review gallery images for the status badge PR

Temporary evidence assets for pull request review, embedded via blob
URLs in the PR description. Safe to delete after merge.

* Swap misleading before/after PR images for clean per-state stills

This feature never shipped on main, so there is no real "before" to
compare against for a reviewer — the earlier before/after images were
an artifact of local dev iteration, not a regression fix. Replaced
with one clean still per status.

* Fatten needs-input alert and dot to fill the shared badge shell

Lucide's circle-alert only paints ~83% of its nominal size, so the
prior 10pt glyph read as smaller than the loader inside the same
14pt shell. Sized both up so all three glyphs draw the same visual
footprint against the shared ring.

* Address review: extract pure badge-content selection, drop JSDOM tests

Greptile flagged getStatusDotColorStyle's needs_input/running cases as
dead (unreachable — shouldRenderSyncedStatusLoader and an explicit
check already intercept those buckets earlier). Extracting the
selection logic into a plain-TS descriptor function
(getProjectStatusBadgeContent) makes that structural: the "dot"
variant is typed to failed|attention only, so there's no switch left
with unreachable branches.

That extraction also resolves the JSDOM component test Greptile
flagged (project-leading-visual.test.tsx used vi.hoisted/vi.mock/
createRoot mounting, all banned by docs/testing.md's two test
categories) — the pure selector is now tested directly with a plain
vitest file, no mounting needed. Dropped that test file and
use-sidebar-project-status-bucket.test.tsx (same banned pattern); the
real coverage was already redundant with sidebar-workspaces-view-model
.test.ts's existing priority-order assertions and the e2e capture
spec's real-app gating checks.

Also split a conditional branch in the e2e capture spec's assertion
loop into two deterministic loops (badge-expected vs no-badge cases)
per Greptile's third note.

* Size status-badge glyphs even so they center in the shell

The badge shell's interior is 12pt (14pt minus the 1pt ring on each
side). A centered glyph of size N sits at a (12 - N) / 2 offset, which
is fractional for odd N and gets snapped to a device-pixel boundary,
rendering visibly off-center (~1.5 device px at 3x). Drop the dot to 8pt
and the alert to 10pt so both divide the interior into whole pixels and
land dead center; Lucide's circle-alert paints ~83% of nominal, so 10pt
draws a ~8.3pt disc that matches the 8pt dot.

Also extends the on-demand capture spec to cover the failed bucket, the
priority aggregation cases, dark mode, hover, a compact viewport, and a
recorded running-to-expand transition, dumping DOM geometry that proves
every shell shares one size/offset and every even glyph centers at 0px.

* Refresh status-badge PR assets for the even-glyph sizing

Recaptures every state at the approved 8pt-dot / 10pt-alert sizing,
adds the failed bucket to the per-status set, a crosshair sizing/
centering proof, dark-mode and compact-form-factor shots, and replaces
the soft upscaled spinner GIF with a crisp one assembled from native
3x-scale frames. Drops the stale pre-sizing images.

* Add capture spec proving workspace statuses roll up to the project badge

Seeds three collapsed projects, each with several same-directory
workspaces in different buckets, so each resolves to a different
highest-priority winner (needs_input / failed / running). Films the
collapse and expand so the aggregation is provable as motion, not a
single frame.

* Add propagation recording showing statuses resolving to the project badge

* Add higher-quality mp4 of the status propagation recording

* Refactor project status badge coverage

---------

Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com>
2026-08-02 00:37:22 +08:00

107 lines
3.4 KiB
TypeScript

import { expect, type Page } from "@playwright/test";
import { gotoAppShell } from "./app";
import { seedWorkspace, type SeededWorkspace } from "./seed-client";
import { waitForSidebarHydration } from "./workspace-ui";
export interface StatusProject {
seed: SeededWorkspace;
needsInputWorkspaceId: string;
}
export async function seedStatusProject(): Promise<StatusProject> {
const seed = await seedWorkspace({
repoPrefix: "project-status-badge-",
title: "Working workspace",
});
const created = await seed.client.createWorkspace({
source: { kind: "directory", path: seed.repoPath, projectId: seed.projectId },
title: "Needs input workspace",
});
if (!created.workspace) {
await seed.cleanup();
throw new Error(created.error ?? "Failed to create the needs-input workspace");
}
return { seed, needsInputWorkspaceId: created.workspace.id };
}
export async function openAndCollapseStatusProject(
page: Page,
project: StatusProject,
): Promise<void> {
await gotoAppShell(page);
await waitForSidebarHydration(page);
await projectRow(page, project).click();
await page.mouse.move(1200, 850);
await expect(workspaceRow(page, "Working workspace")).toHaveCount(0);
}
export async function expandStatusProject(page: Page, project: StatusProject): Promise<void> {
await projectRow(page, project).click();
await expect(workspaceRow(page, "Working workspace")).toBeVisible();
}
export async function startWorkingWorkspace(project: StatusProject): Promise<void> {
await project.seed.client.createAgent({
provider: "mock",
cwd: project.seed.repoPath,
workspaceId: project.seed.workspaceId,
title: "Working agent",
modeId: "load-test",
model: "thirty-minute-stream",
initialPrompt: "keep streaming for the test",
});
}
export async function startNeedsInputWorkspace(project: StatusProject): Promise<void> {
await project.seed.client.createAgent({
provider: "mock",
cwd: project.seed.repoPath,
workspaceId: project.needsInputWorkspaceId,
title: "Needs input agent",
modeId: "load-test",
model: "thirty-minute-stream",
initialPrompt: "emit a synthetic plan approval",
});
}
export async function expectCollapsedProjectStatus(
page: Page,
project: StatusProject,
status: "Working" | "Needs input",
): Promise<void> {
await expect(projectRow(page, project).getByRole("status", { name: status })).toBeVisible({
timeout: 60_000,
});
}
export async function expectProjectStatusHidden(page: Page, project: StatusProject): Promise<void> {
await expect(projectRow(page, project).getByRole("status")).toHaveCount(0, {
timeout: 60_000,
});
}
export async function expectWorkspaceStatus(
page: Page,
workspaceName: string,
status: "running" | "needs_input",
): Promise<void> {
await expect(
workspaceRow(page, workspaceName).getByTestId(`workspace-status-indicator-${status}`),
).toBeVisible({ timeout: 60_000 });
}
function projectGroup(page: Page, project: StatusProject) {
return page.getByRole("group", { name: project.seed.projectDisplayName, exact: true });
}
function projectRow(page: Page, project: StatusProject) {
return projectGroup(page, project)
.getByRole("button")
.filter({ hasText: project.seed.projectDisplayName })
.first();
}
function workspaceRow(page: Page, workspaceName: string) {
return page.getByRole("button", { name: workspaceName, exact: true });
}