fix: converge workbench session state projection
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user