fix: converge workbench session state projection

This commit is contained in:
lyon
2026-06-18 15:55:18 +08:00
parent b625ae2499
commit dd01f47951
12 changed files with 276 additions and 46 deletions
+29
View File
@@ -162,6 +162,10 @@ export async function handleCodeAgentSessionsHttp(request, response, url, option
await getManualCodeAgentSession(response, options, sessionId);
return;
}
if (request.method === "DELETE" && sessionId && !action) {
await archiveManualCodeAgentSession(response, options, sessionId);
return;
}
if (request.method === "POST" && sessionId && action === "select") {
await selectManualCodeAgentSession(request, response, options, sessionId);
return;
@@ -249,6 +253,31 @@ async function getManualCodeAgentSession(response, options, sessionId) {
});
}
async function archiveManualCodeAgentSession(response, options, sessionId) {
const session = await getVisibleManualAgentSession(options, sessionId);
if (!session) {
sendJson(response, 404, manualSessionErrorPayload({ code: "session_not_found", message: "Code Agent session is not visible to the current actor.", sessionId }));
return;
}
const result = await options.accessController?.store?.archiveAgentConversation?.({
ownerUserId: options.actor?.id,
actorRole: options.actor?.role,
ownerScoped: true,
sessionId,
conversationId: session.conversationId,
projectId: session.projectId
}) ?? { count: 0 };
sendJson(response, 200, {
ok: true,
status: "archived",
contractVersion: "code-agent-manual-session-v1",
archivedCount: result.count ?? 0,
session: publicManualAgentSession({ ...session, status: "archived", endedAt: session.endedAt ?? new Date().toISOString(), updatedAt: new Date().toISOString() }),
valuesRedacted: true,
secretMaterialStored: false
});
}
async function selectManualCodeAgentSession(request, response, options, sessionId) {
const body = await readJsonObjectBody(request, options.bodyLimitBytes);
if (!body.ok) {