Skip to content

fix(memory-graph): stop painting expired memories as expiring#1335

Open
abhay-codes07 wants to merge 1 commit into
supermemoryai:mainfrom
abhay-codes07:fix/graph-expired-memory-border
Open

fix(memory-graph): stop painting expired memories as expiring#1335
abhay-codes07 wants to merge 1 commit into
supermemoryai:mainfrom
abhay-codes07:fix/graph-expired-memory-border

Conversation

@abhay-codes07

Copy link
Copy Markdown
Contributor

Problem

getMemoryBorderColor decides the expiring border from the time left until forgetAfter:

if (mem.forgetAfter) {
  const msLeft = new Date(mem.forgetAfter).getTime() - Date.now()
  if (msLeft < SEVEN_DAYS_MS) return colors.memBorderExpiring
}

msLeft < SEVEN_DAYS_MS is meant to catch "expires within the next week", but it is also true for every forgetAfter in the past, where msLeft is negative. So a memory whose forget time has already elapsed, but which the server has not yet swept to isForgotten, keeps the expiring border forever. It reads as "about to expire" indefinitely instead of as a normal or already-expired node, and the closer to the past it gets the more wrong the signal is.

Fix

Require that there is actually time left before marking a memory expiring:

if (msLeft > 0 && msLeft < SEVEN_DAYS_MS) return colors.memBorderExpiring

Elapsed memories fall through to the existing recency / default branch, which matches how an unremarkable node is drawn. The isForgotten early return above is unchanged, so anything already marked forgotten still gets the forgotten color first.

Test

Added a case to graph-data-utils.test.ts for a memory with a forgetAfter a minute in the past and an old createdAt: it now resolves to memStrokeDefault rather than memBorderExpiring. Full package suite passes and tsc --noEmit is clean.

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.
Copilot AI review requested due to automatic review settings July 22, 2026 11:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants