Skip to content

Commit 372d648

Browse files
fix: Activity running counts stay at zero as work starts (#172907)
* fix: Activity running counts stay at zero as work starts Refresh whole-roster totals for unknown session events and keep running-badge visibility reactive. Cover unseen rows, zero transitions, and real Gateway lifecycle events. Co-authored-by: steipete <[email protected]> * test: decouple selected capacity proof from live inventory Reuse the independently reviewed planner-only repair from 478a40024202a8e44f371a89fca0f61d796d0942. Keep strict fixed-input parallelism and worker capacity proof while avoiding a full-inventory-dependent job count. Co-authored-by: VACInc <[email protected]> Co-authored-by: steipete <[email protected]> * test: supply timestamp in owner count fixture Co-authored-by: steipete <[email protected]> --------- Co-authored-by: steipete <[email protected]>
1 parent e41cb13 commit 372d648

7 files changed

Lines changed: 482 additions & 87 deletions

‎test/scripts/ci-node-test-plan.test.ts‎

Lines changed: 102 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -3250,8 +3250,11 @@ describe("scripts/lib/ci-node-test-plan.mts", () => {
32503250
expect(groups.flatMap((group) => group.includePatterns ?? []).toSorted()).toEqual(
32513251
targets.toSorted(),
32523252
);
3253-
expect(plan.filter((job) => job.planConcurrency === 2)).toHaveLength(1);
3253+
// Selection retains full-plan concurrency. Unrelated inventory may move these
3254+
// groups into serial Gateway templates; fixed-inventory coverage below proves
3255+
// parallel capacity is retained when the canonical templates permit it.
32543256
for (const job of plan) {
3257+
expect([1, 2]).toContain(job.planConcurrency);
32553258
expect(job.runner).toBe(
32563259
job.planConcurrency === 2
32573260
? "blacksmith-32vcpu-ubuntu-2404"
@@ -3486,71 +3489,105 @@ describe("scripts/lib/ci-node-test-plan.mts", () => {
34863489
}
34873490
});
34883491

3489-
it("retains the ordered wall budget when repacking selected files", async () => {
3490-
const config = "test/vitest/vitest.infra.config.ts";
3491-
const entries = [
3492-
["src/infra/env.test.ts", "core-runtime-infra-env-auth", 170],
3493-
["src/infra/os-summary.test.ts", "core-runtime-infra-misc-os", 170],
3494-
["src/infra/ports-probe.test.ts", "core-runtime-infra-system-runtime", 160],
3495-
["src/infra/provider-usage.test.ts", "core-runtime-infra-provider-push", 160],
3496-
["src/infra/channel-runtime-context.test.ts", "core-runtime-infra-channel-plugin", 150],
3497-
["src/infra/diagnostic-trace-context.test.ts", "core-runtime-infra-diagnostics-state", 150],
3498-
] as const;
3499-
const files = entries.map(([file]) => file);
3500-
const targets = files.slice(0, 3);
3501-
vi.resetModules();
3502-
vi.doMock("../vitest/vitest.test-shards.mjs", async (importOriginal) => ({
3503-
...(await importOriginal<typeof import("../vitest/vitest.test-shards.mjs")>()),
3504-
fullSuiteVitestShards: [{ name: "core-runtime", config, projects: [config] }],
3505-
}));
3506-
vi.doMock("../vitest/vitest.database-worker-core-paths.mjs", async (importOriginal) => ({
3507-
...(await importOriginal<typeof import("../vitest/vitest.database-worker-core-paths.mjs")>()),
3508-
databaseWorkerCoreTestFiles: [],
3509-
isDatabaseWorkerCoreTestFile: () => false,
3510-
}));
3511-
vi.doMock("../../scripts/lib/list-test-files.mts", async (importOriginal) => ({
3512-
...(await importOriginal<typeof import("../../scripts/lib/list-test-files.mts")>()),
3513-
listTrackedTestFiles: (root: string) => (root === "src/infra" ? files : []),
3514-
}));
3515-
vi.doMock("../../scripts/lib/ci-test-timings.mts", () => ({
3516-
...testTimings,
3517-
readCompactGroupTimings: () =>
3518-
Object.fromEntries(entries.map(([, owner, seconds]) => [owner, seconds])),
3519-
readRuntimePlacementTimings: () => [],
3520-
}));
3521-
vi.doMock("../../scripts/lib/vitest-build-prerequisites.mts", async (importOriginal) => ({
3522-
...(await importOriginal<
3523-
typeof import("../../scripts/lib/vitest-build-prerequisites.mts")
3524-
>()),
3525-
resolveVitestPretestBuildMode: () => undefined,
3526-
}));
3527-
try {
3528-
const { createSelectedNodeTestShardBundles: createSelected } =
3529-
await import("../../scripts/lib/ci-node-test-plan.mts");
3530-
const selected = expectDefined(
3531-
createSelected(targets, { runnerBackend: "blacksmith" }),
3532-
"selected infra plan",
3533-
);
3534-
// The selected 170/170/160 envelopes fit the aggregate limit but need 330 seconds together.
3535-
expect(selected).toHaveLength(2);
3536-
expect(selected.every((job) => job.planConcurrency === 2)).toBe(true);
3537-
expect(selected.every((job) => job.predictedTestSeconds! <= 300)).toBe(true);
3538-
expect(selected.map((job) => job.predictedTestSeconds!).toSorted((a, b) => a - b)).toEqual([
3539-
160, 170,
3540-
]);
3541-
expect(selected.reduce((sum, job) => sum + job.predictedSeconds!, 0)).toBe(500);
3542-
expect(
3543-
selected.flatMap((job) => job.groups.flatMap((group) => group.includePatterns!)).toSorted(),
3544-
).toEqual(targets.toSorted());
3545-
} finally {
3546-
vi.doUnmock("../../scripts/lib/vitest-build-prerequisites.mts");
3547-
vi.doUnmock("../../scripts/lib/ci-test-timings.mts");
3548-
vi.doUnmock("../../scripts/lib/list-test-files.mts");
3549-
vi.doUnmock("../vitest/vitest.database-worker-core-paths.mjs");
3550-
vi.doUnmock("../vitest/vitest.test-shards.mjs");
3492+
it.each(["blacksmith", "hybrid"])(
3493+
"retains parallel capacity and ordered wall budgets for selected %s files",
3494+
async (runnerBackend) => {
3495+
const config = "test/vitest/vitest.infra.config.ts";
3496+
const entries = [
3497+
["src/infra/env.test.ts", "core-runtime-infra-env-auth", 170],
3498+
["src/infra/os-summary.test.ts", "core-runtime-infra-misc-os", 170],
3499+
["src/infra/ports-probe.test.ts", "core-runtime-infra-system-runtime", 160],
3500+
["src/infra/provider-usage.test.ts", "core-runtime-infra-provider-push", 160],
3501+
["src/infra/channel-runtime-context.test.ts", "core-runtime-infra-channel-plugin", 150],
3502+
["src/infra/diagnostic-trace-context.test.ts", "core-runtime-infra-diagnostics-state", 150],
3503+
] as const;
3504+
const files = entries.map(([file]) => file);
3505+
const targets = files.slice(0, 3);
35513506
vi.resetModules();
3552-
}
3553-
});
3507+
vi.doMock("../vitest/vitest.test-shards.mjs", async (importOriginal) => ({
3508+
...(await importOriginal<typeof import("../vitest/vitest.test-shards.mjs")>()),
3509+
fullSuiteVitestShards: [{ name: "core-runtime", config, projects: [config] }],
3510+
}));
3511+
vi.doMock("../vitest/vitest.database-worker-core-paths.mjs", async (importOriginal) => ({
3512+
...(await importOriginal<
3513+
typeof import("../vitest/vitest.database-worker-core-paths.mjs")
3514+
>()),
3515+
databaseWorkerCoreTestFiles: [],
3516+
isDatabaseWorkerCoreTestFile: () => false,
3517+
}));
3518+
vi.doMock("../../scripts/lib/list-test-files.mts", async (importOriginal) => ({
3519+
...(await importOriginal<typeof import("../../scripts/lib/list-test-files.mts")>()),
3520+
listTrackedTestFiles: (root: string) => (root === "src/infra" ? files : []),
3521+
}));
3522+
vi.doMock("../../scripts/lib/ci-test-timings.mts", () => ({
3523+
...testTimings,
3524+
readCompactGroupTimings: () =>
3525+
Object.fromEntries(entries.map(([, owner, seconds]) => [owner, seconds])),
3526+
readRuntimePlacementTimings: () => [],
3527+
}));
3528+
vi.doMock("../../scripts/lib/vitest-build-prerequisites.mts", async (importOriginal) => ({
3529+
...(await importOriginal<
3530+
typeof import("../../scripts/lib/vitest-build-prerequisites.mts")
3531+
>()),
3532+
resolveVitestPretestBuildMode: () => undefined,
3533+
}));
3534+
try {
3535+
const {
3536+
createSelectedNodeTestShardBundles: createSelected,
3537+
createNodeTestShardBundles: createBundles,
3538+
} = await import("../../scripts/lib/ci-node-test-plan.mts");
3539+
const full = createBundles({
3540+
runnerBackend,
3541+
includeReleaseOnlyPluginShards: false,
3542+
includeProofTests: false,
3543+
changedPaths: targets,
3544+
compactMode: "pull-request",
3545+
});
3546+
const selected = expectDefined(
3547+
createSelected(targets, { runnerBackend }),
3548+
"selected infra plan",
3549+
);
3550+
// The selected 170/170/160 envelopes fit the aggregate limit but need 330 seconds together.
3551+
expect(selected).toHaveLength(2);
3552+
expect(selected.every((job) => job.planConcurrency === 2)).toBe(true);
3553+
for (const job of selected) {
3554+
expect(job.runner).toBe("blacksmith-32vcpu-ubuntu-2404");
3555+
for (const group of job.groups) {
3556+
const original = expectDefined(
3557+
full.find((owner) =>
3558+
owner.groups.some((entry) => entry.shard_name === group.shard_name),
3559+
),
3560+
"canonical template",
3561+
);
3562+
const owner = expectDefined(
3563+
original.groups.find((entry) => entry.shard_name === group.shard_name),
3564+
"canonical group",
3565+
);
3566+
expect(job.planConcurrency).toBe(original.planConcurrency);
3567+
expect(group.env).toEqual(owner.env);
3568+
expect(group.fallbackMaxWorkers).toBe(owner.fallbackMaxWorkers);
3569+
}
3570+
}
3571+
expect(selected.every((job) => job.predictedTestSeconds! <= 300)).toBe(true);
3572+
expect(selected.map((job) => job.predictedTestSeconds!).toSorted((a, b) => a - b)).toEqual([
3573+
160, 170,
3574+
]);
3575+
expect(selected.reduce((sum, job) => sum + job.predictedSeconds!, 0)).toBe(500);
3576+
expect(
3577+
selected
3578+
.flatMap((job) => job.groups.flatMap((group) => group.includePatterns!))
3579+
.toSorted(),
3580+
).toEqual(targets.toSorted());
3581+
} finally {
3582+
vi.doUnmock("../../scripts/lib/vitest-build-prerequisites.mts");
3583+
vi.doUnmock("../../scripts/lib/ci-test-timings.mts");
3584+
vi.doUnmock("../../scripts/lib/list-test-files.mts");
3585+
vi.doUnmock("../vitest/vitest.database-worker-core-paths.mjs");
3586+
vi.doUnmock("../vitest/vitest.test-shards.mjs");
3587+
vi.resetModules();
3588+
}
3589+
},
3590+
);
35543591

35553592
async function createToolingFixturePlan(params: {
35563593
files: string[];

‎test/vitest/vitest.ui-paths.mjs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ export const uiE2eRealGatewayTestFiles = [
144144
"ui/src/e2e/background-work.real-gateway.e2e.test.ts",
145145
"ui/src/e2e/activity-run-inspector.real-gateway.e2e.test.ts",
146146
"ui/src/e2e/session-roster-request-rate.real-gateway.e2e.test.ts",
147+
"ui/src/e2e/sidebar-running-counts.real-gateway.e2e.test.ts",
147148
"ui/src/e2e/quota-reset-status.real-gateway.e2e.test.ts",
148149
"ui/src/e2e/model-api-keys.real-gateway.e2e.test.ts",
149150
"ui/src/e2e/provider-browser-login.real-gateway.e2e.test.ts",

‎ui/src/components/app-sidebar-online.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,23 @@ describe("sidebar people workload", () => {
305305
},
306306
);
307307

308+
it("adds and removes a running badge without remounting the person", async () => {
309+
let running = 0;
310+
const { sidebar } = await mountWorkload(async () =>
311+
summary([{ profileId: "ada", open: 13, running }]),
312+
);
313+
const original = person(sidebar, "ada");
314+
expect(counts(sidebar, "ada")).toEqual(["13"]);
315+
for (const next of [12, 0]) {
316+
running = next;
317+
await sidebar.sessionData.ownerCounts.refresh();
318+
await settle(sidebar);
319+
expect(person(sidebar, "ada")).toBe(original);
320+
expect(original.getAttribute("aria-description")).toContain(`${next} running`);
321+
expect(counts(sidebar, "ada")).toEqual(next ? ["12", "13"] : ["13"]);
322+
}
323+
});
324+
308325
it("keeps a single deduplicated self visible when returning to Online", async () => {
309326
const { sidebar, gateway } = await mountWorkload();
310327
const self = presence()[0]!;

‎ui/src/components/app-sidebar-online.tsx‎

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { JSX } from "@solidjs/web";
22
import { Dynamic } from "@solidjs/web";
3-
import { createMemo, For } from "solid-js";
3+
import { createMemo, For, Show } from "solid-js";
44
import { presenceUserKey } from "../../../src/shared/presence-user.ts";
55
import type { ApplicationGateway } from "../app/gateway.ts";
66
import { isMobileNavLayout } from "../app/mobile-nav-layout.ts";
@@ -208,30 +208,28 @@ export function renderAppSidebarOnline(host: AppSidebarRenderHost): JSX.Element
208208
{workload() && (workload()!.open > 0 || workload()!.running > 0) ? (
209209
<span class="sidebar-online__counts" aria-hidden="true">
210210
<For each={["running", "open"] as const}>
211-
{(kind) =>
212-
workload()![kind] > 0 ? (
213-
<>
211+
{(kind) => (
212+
<Show when={workload()![kind] > 0}>
213+
<span
214+
class={`sidebar-online__${kind}`}
215+
data-session-count={kind}
216+
title={t(`presence.sessions.${kind}Count`, {
217+
count: String(workload()![kind]),
218+
})}
219+
>
214220
<span
215-
class={`sidebar-online__${kind}`}
216-
data-session-count={kind}
217-
title={t(`presence.sessions.${kind}Count`, {
218-
count: String(workload()![kind]),
219-
})}
221+
class={
222+
kind === "running"
223+
? "session-run-spinner"
224+
: "sidebar-online__open-icon"
225+
}
220226
>
221-
<span
222-
class={
223-
kind === "running"
224-
? "session-run-spinner"
225-
: "sidebar-online__open-icon"
226-
}
227-
>
228-
{kind === "running" ? undefined : <Icon name="messageCircle" />}
229-
</span>
230-
<span class="sidebar-online__count">{workload()![kind]}</span>
227+
{kind === "running" ? undefined : <Icon name="messageCircle" />}
231228
</span>
232-
</>
233-
) : undefined
234-
}
229+
<span class="sidebar-online__count">{workload()![kind]}</span>
230+
</span>
231+
</Show>
232+
)}
235233
</For>
236234
</span>
237235
) : undefined}

0 commit comments

Comments
 (0)