fix: close remaining Bugbot findings

Carry legacy project ownership through recovery, drop the redundant dashboard worker filter, and remove the now-unused orchestrator helper so the PR branch stays aligned with the shared per-project orchestration contract.
This commit is contained in:
Harsh 2026-03-12 01:58:55 +05:30
parent 9e1f58daa0
commit 58ad53e8a3
4 changed files with 25 additions and 20 deletions

View File

@ -126,6 +126,29 @@ describe("recoverSession", () => {
expect(metadata?.["recoveredAt"]).toBeUndefined();
});
it("preserves project ownership when legacy metadata omits the project field", async () => {
rootDir = join(tmpdir(), `ao-recovery-${randomUUID()}`);
mkdirSync(rootDir, { recursive: true });
mkdirSync(join(rootDir, "project"), { recursive: true });
writeFileSync(join(rootDir, "agent-orchestrator.yaml"), "projects: {}\n", "utf-8");
const config = makeConfig(rootDir);
const registry = makeRegistry();
const assessment = makeAssessment({
rawMetadata: {
branch: "feature/recover",
worktree: join(rootDir, "project"),
status: "needs_input",
},
});
const context = makeContext(rootDir);
const result = await recoverSession(assessment, config, registry, context);
expect(result.success).toBe(true);
expect(result.session?.projectId).toBe("app");
});
it("returns the max-attempt reason when recovery escalates", async () => {
rootDir = join(tmpdir(), `ao-recovery-${randomUUID()}`);
mkdirSync(rootDir, { recursive: true });

View File

@ -72,6 +72,7 @@ export async function recoverSession(
};
const session = sessionFromMetadata(sessionId, updatedMetadata, {
projectId: assessment.projectId,
status: preservedStatus,
runtimeHandle: assessment.runtimeHandle,
lastActivityAt: new Date(),

View File

@ -3,7 +3,6 @@ import type { Metadata } from "next";
export const dynamic = "force-dynamic";
import { Dashboard } from "@/components/Dashboard";
import type { DashboardSession } from "@/lib/types";
import { isOrchestratorSession } from "@composio/ao-core";
import { getServices, getSCM } from "@/lib/services";
import {
sessionToDashboard,
@ -60,9 +59,7 @@ export default async function Home(props: { searchParams: Promise<{ project?: st
orchestrators = listDashboardOrchestrators(visibleSessions, config.projects);
const coreSessions = filterWorkerSessions(allSessions, projectFilter, config.projects).filter(
(session) => !isOrchestratorSession(session),
);
const coreSessions = filterWorkerSessions(allSessions, projectFilter, config.projects);
sessions = coreSessions.map(sessionToDashboard);
const metaTimeout = new Promise<void>((resolve) => setTimeout(resolve, 3_000));

View File

@ -22,22 +22,6 @@ function matchesProject(
return false;
}
export function findOrchestratorSessionId<T extends SessionLike>(
sessions: T[],
projectFilter: string | null | undefined,
projects: Record<string, ProjectWithPrefix>,
): string | null {
if (projectFilter && projectFilter !== "all") {
const session = sessions.find(
(s) => isOrchestratorSession(s) && matchesProject(s, projectFilter, projects),
);
return session?.id ?? null;
}
const session = sessions.find((s) => isOrchestratorSession(s));
return session?.id ?? null;
}
export function filterWorkerSessions<T extends SessionLike>(
sessions: T[],
projectFilter: string | null | undefined,