fix: archive session behavior

This commit is contained in:
clawdbot 2026-03-15 17:23:32 +00:00
parent 5d0dbd3823
commit 5449b3b46a
3 changed files with 13 additions and 9 deletions

View File

@ -442,7 +442,7 @@ export async function initSessionState(params: {
archivedAt: baseEntry?.archivedAt,
};
if (typeof sessionEntry.archivedAt === "number") {
delete sessionEntry.archivedAt;
sessionEntry.archivedAt = null;
}
const metaPatch = deriveSessionMetaPatch({
ctx: sessionCtxForState,

View File

@ -217,14 +217,16 @@ export const sessionsHandlers: GatewayRequestHandlers = {
const wasArchived = typeof applied.previous?.archivedAt === "number";
const isArchived = typeof applied.entry.archivedAt === "number";
if (!wasArchived && isArchived) {
void writeSessionArchiveSummary({
cfg,
key: target.canonicalKey ?? key,
entry: applied.entry,
storePath,
archivedAt: applied.entry.archivedAt ?? undefined,
}).catch((err) => {
console.warn(`sessions.patch archive summary failed: ${String(err)}`);
setImmediate(() => {
void writeSessionArchiveSummary({
cfg,
key: target.canonicalKey ?? key,
entry: applied.entry,
storePath,
archivedAt: applied.entry.archivedAt ?? undefined,
}).catch((err) => {
console.warn(`sessions.patch archive summary failed: ${String(err)}`);
});
});
}

View File

@ -75,6 +75,7 @@ export async function resolveSessionKeyFromResolveParams(params: {
opts: {
includeGlobal: p.includeGlobal === true,
includeUnknown: p.includeUnknown === true,
includeArchived: true,
spawnedBy: p.spawnedBy,
agentId: p.agentId,
search: sessionId,
@ -119,6 +120,7 @@ export async function resolveSessionKeyFromResolveParams(params: {
opts: {
includeGlobal: p.includeGlobal === true,
includeUnknown: p.includeUnknown === true,
includeArchived: true,
label: parsedLabel.label,
agentId: p.agentId,
spawnedBy: p.spawnedBy,