mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-10-23 05:35:27 +00:00
fix(memory-graph): stop painting expired memories as expiring
getMemoryBorderColor flagged a memory as "expiring" whenever forgetAfter - now was less than seven days. That comparison is also true when forgetAfter is already in the past, since msLeft goes negative, so a memory whose forget time has elapsed but has not yet been swept to isForgotten kept the expiring border indefinitely instead of reading as a normal or expired node. Require msLeft > 0 so only memories with time actually left are marked expiring; elapsed ones fall through to the recency/default logic. Adds a regression test for the elapsed-forgetAfter case.
This commit is contained in:
parent
90f709bf8d
commit
998092e7f1
2 changed files with 11 additions and 1 deletions
|
|
@ -65,6 +65,13 @@ describe("getMemoryBorderColor", () => {
|
|||
expect(getMemoryBorderColor(mem, colors)).toBe(colors.memBorderExpiring)
|
||||
})
|
||||
|
||||
it("does not treat an already-elapsed forgetAfter as expiring", () => {
|
||||
const past = new Date(Date.now() - 60 * 1000).toISOString()
|
||||
const old = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).toISOString()
|
||||
const mem = makeMemory({ forgetAfter: past, createdAt: old })
|
||||
expect(getMemoryBorderColor(mem, colors)).toBe(colors.memStrokeDefault)
|
||||
})
|
||||
|
||||
it("returns recent color for memories created within 24 hours", () => {
|
||||
const recent = new Date(Date.now() - 1000).toISOString()
|
||||
const mem = makeMemory({ createdAt: recent })
|
||||
|
|
|
|||
|
|
@ -47,7 +47,10 @@ export function getMemoryBorderColor(
|
|||
if (mem.isForgotten) return colors.memBorderForgotten
|
||||
if (mem.forgetAfter) {
|
||||
const msLeft = new Date(mem.forgetAfter).getTime() - Date.now()
|
||||
if (msLeft < SEVEN_DAYS_MS) return colors.memBorderExpiring
|
||||
// Only "expiring" while there is time left. A forgetAfter already in the
|
||||
// past leaves msLeft negative, which still satisfied `< SEVEN_DAYS_MS` and
|
||||
// painted the expiring border forever; let those fall through instead.
|
||||
if (msLeft > 0 && msLeft < SEVEN_DAYS_MS) return colors.memBorderExpiring
|
||||
}
|
||||
const age = Date.now() - new Date(mem.createdAt).getTime()
|
||||
if (age < ONE_DAY_MS) return colors.memBorderRecent
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue