Skip to content

fix: keep orphaned linked memories visible in the timeline - #260

Merged
lindixu6-hash merged 1 commit into
tickernelz:mainfrom
petra-dot:fix/timeline-orphaned-memories
Aug 19, 2026
Merged

fix: keep orphaned linked memories visible in the timeline#260
lindixu6-hash merged 1 commit into
tickernelz:mainfrom
petra-dot:fix/timeline-orphaned-memories

Conversation

@petra-dot

Copy link
Copy Markdown
Contributor

Bug

handleListMemories (the Web UI timeline endpoint) grouped memory-prompt pairs by id and then dropped any pair missing one side. A memory whose linked prompt was deleted (DELETE /api/prompts/:id without cascade), expired, or never captured, vanished from /api/memories even though it still existed in the shard and was still reachable via /api/search. Same for prompts whose linked memory was gone.

Root cause

In handleListMemories:

const pairs = Array.from(linkedPairs.values())
  .filter((p) => p.memory && p.prompt)   // <- one-sided pairs discarded

Items that referenced a missing counterpart were neither in pairs nor added to standalone.

Fix

One-sided pairs now fall back to standalone, so orphaned linked memories/prompts still render, unlinked, in the timeline. Complete pairs still render together.

Tests

  • memory timeline listing > keeps memories whose linked prompt is missing from the timeline — reproduces the drop (fails before the fix, passes after)
  • memory timeline listing > renders linked memory-prompt pairs together in the timeline — guards the pairing path

Verification

  • tsc --noEmit clean
  • Full suite: 407 pass / 4 fail, identical failure set on clean main (pre-existing flakes: onnxruntime-resolve shim, plugin-loader contract timeout, turso-shard recreate timeout, config parallel). No new failures.
  • Prettier clean

handleListMemories grouped memory-prompt pairs by id and then dropped any pair missing one side. A memory whose linked prompt was deleted (or captured with prompts off) vanished from /api/memories even though it still existed in the shard and search. One-sided pairs now fall back to standalone items.

@lindixu6-hash lindixu6-hash left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed the timeline pairing path and the new regression coverage. The change preserves complete memory/prompt ordering and moves only one-sided pairs into the existing timestamp-sorted standalone list.

Local verification on c7b705fe6073517aa2611ea118f57d8dc1d1a232: targeted orphan/pair tests 2 pass, 0 fail; bun run typecheck passed; bun run format:check passed. The sandbox reported cleanup restrictions for temporary directories after the commands completed, so those restrictions did not affect the assertions or static checks.

@lindixu6-hash
lindixu6-hash merged commit 93cb1cf into tickernelz:main Aug 19, 2026
1 check passed
@lindixu6-hash

Copy link
Copy Markdown
Collaborator

Post-merge validation for exact merge commit 93cb1cf81049cbed785837507bc4b1a57445e5a9: Platform Package Smoke run 32276470861 passed all six jobs (Ubuntu, Windows, macOS 15/26 on Apple Silicon, and macOS 15/26 Intel). Each job completed dependency installation, typecheck, production build, the full test suite, package creation/install, and native/runtime smoke checks.

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