Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion broker-core/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3209,7 +3209,7 @@ function summarizeProjectRecords(activeLeases, pins, recentEvents, knownProjects
}

for (const event of recentEvents) {
const project = ensureProject(event.projectId ?? null, null, event.projectId ? (knownProjects.projects[event.projectId] ?? null) : null);
const project = event.projectId ? (byProject.get(event.projectId) ?? null) : null;
if (!project) {
continue;
}
Expand Down
19 changes: 19 additions & 0 deletions client/test/simbroker.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2521,9 +2521,26 @@ test("project validate can discover the project file from --repo-root", () => {

test("project forget removes an inactive registration and refreshes the local app snapshot", () => {
const fixture = makeFixture();
const leaseFilePath = path.join(fixture.root, "forgotten-project-lease.json");

assert.equal(runCli(fixture, "host", "init").status, 0);
assert.equal(runCli(fixture, "project", "validate", "--repo-root", fixture.repoRoot).status, 0);
const acquired = runCli(
fixture,
"lease",
"acquire",
"--repo-root",
fixture.repoRoot,
"--purpose",
"agent-ui-session",
"--owner-pid",
String(process.pid),
"--lease-file",
leaseFilePath,
);
assert.equal(acquired.status, 0, acquired.stderr);
const released = runCli(fixture, "lease", "release", "--lease-file", leaseFilePath);
assert.equal(released.status, 0, released.stderr);

const forgotten = runCli(fixture, "project", "forget", "--project-id", "cli-demo");
assert.equal(forgotten.status, 0);
Expand All @@ -2532,6 +2549,8 @@ test("project forget removes an inactive registration and refreshes the local ap
assert.equal(Object.hasOwn(readJson(path.join(fixture.stateRoot, "known-projects.json")).projects, "cli-demo"), false);
const snapshot = readJson(path.join(fixture.stateRoot, "app-snapshot.json"));
assert.equal(snapshot.projects.some((project) => project.projectId === "cli-demo"), false);
assert.equal(snapshot.recentEvents.some((event) => event.type === "lease.acquired" && event.projectId === "cli-demo"), true);
assert.equal(snapshot.recentEvents.some((event) => event.type === "lease.released" && event.projectId === "cli-demo"), true);

const repeated = runCli(fixture, "project", "forget", "--project-id", "cli-demo");
assert.equal(repeated.status, 0);
Expand Down