diff --git a/dist/src/taskState.js b/dist/src/taskState.js index 904e7f4..0506021 100644 --- a/dist/src/taskState.js +++ b/dist/src/taskState.js @@ -77,6 +77,10 @@ export async function upsertXWorkmateSessionMapping(api, input) { let mapping; await patchSessionEntry({ sessionKey: input.openclawSessionKey, + fallbackEntry: { + sessionId: input.openclawSessionKey, + updatedAt: Date.now(), + }, preserveActivity: true, update: (entry) => { const existing = readMappingFromEntry(entry); diff --git a/src/taskState.test.ts b/src/taskState.test.ts index 31e0e4b..c202c23 100644 --- a/src/taskState.test.ts +++ b/src/taskState.test.ts @@ -25,12 +25,17 @@ function createApiFixture(tasks: Record = {}) { })), patchSessionEntry: async ({ sessionKey, + fallbackEntry, update, }: { sessionKey: string; + fallbackEntry?: any; update: (entry: any) => Partial | null; }) => { - const current = sessions.get(sessionKey) ?? { sessionId: sessionKey, updatedAt: 0 }; + const current = sessions.get(sessionKey) ?? fallbackEntry; + if (!current) { + return null; + } const patch = update(current); if (patch) { sessions.set(sessionKey, { ...current, ...patch }); diff --git a/src/taskState.ts b/src/taskState.ts index 2e7011b..88b4c6c 100644 --- a/src/taskState.ts +++ b/src/taskState.ts @@ -49,6 +49,7 @@ type SessionEntry = Record & { type PatchSessionEntry = (params: { sessionKey: string; + fallbackEntry?: SessionEntry; preserveActivity?: boolean; update: (entry: SessionEntry) => Partial | null; }) => Promise | SessionEntry | null; @@ -159,6 +160,10 @@ export async function upsertXWorkmateSessionMapping( let mapping: XWorkmateSessionMappingV1 | undefined; await patchSessionEntry({ sessionKey: input.openclawSessionKey, + fallbackEntry: { + sessionId: input.openclawSessionKey, + updatedAt: Date.now(), + }, preserveActivity: true, update: (entry) => { const existing = readMappingFromEntry(entry);