fix(chat): translate session replay cursors
Memind CI / Test, build, and release guards (pull_request) Successful in 2m55s
Memind CI / Test, build, and release guards (pull_request) Successful in 2m55s
This commit is contained in:
@@ -15,6 +15,26 @@ export function parseSessionStreamLastEventId(value) {
|
||||
return id || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Portal replay ids are local database cursors and are not necessarily valid
|
||||
* Goose SSE ids. Resume Goose from the newest persisted upstream cursor we
|
||||
* actually know about. If none exists, return null so the caller omits
|
||||
* Last-Event-ID and lets Goose replay the authoritative stream from the start.
|
||||
*
|
||||
* @param {Array<{ upstreamEventId?: string | null }>} events
|
||||
* @param {{ upstreamEventId?: string | null } | null} cursorEvent
|
||||
* @returns {string | null}
|
||||
*/
|
||||
export function resolveUpstreamResumeEventId(events, cursorEvent = null) {
|
||||
const candidates = Array.isArray(events) ? [...events].reverse() : [];
|
||||
if (cursorEvent) candidates.push(cursorEvent);
|
||||
for (const event of candidates) {
|
||||
const id = String(event?.upstreamEventId ?? '').trim();
|
||||
if (id) return id;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function isTerminalSessionEvent(event) {
|
||||
const type = String(event?.type ?? '').trim();
|
||||
return SESSION_STREAM_TERMINAL_TYPES.has(type);
|
||||
|
||||
Reference in New Issue
Block a user