Files
openchamber/packages/ui/src/sync/session-event-freshness.ts
T
d5745aaac9 fix(sync): keep session renames stable (#2043)
* fix(sync): keep session renames stable

* fix(sync): clarify rename mirror flow

* fix(sync): clarify archive comment

---------

Co-authored-by: bashrusakh <bashrusakh@users.noreply.github.com>
Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
2026-07-11 15:19:24 +03:00

16 lines
637 B
TypeScript

import type { Session } from "@opencode-ai/sdk/v2"
const getSessionRecencyTimestamp = (session: Session): number => {
const updatedAt = session.time?.updated
if (typeof updatedAt === "number" && Number.isFinite(updatedAt)) {
return updatedAt
}
const createdAt = session.time?.created
return typeof createdAt === "number" && Number.isFinite(createdAt) ? createdAt : 0
}
export const shouldSkipStaleSessionEvent = (currentSession: Session | null, incomingSession: Session): boolean => {
if (!currentSession) return false
return getSessionRecencyTimestamp(incomingSession) < getSessionRecencyTimestamp(currentSession)
}