← Back to PRs

#11749: fix(memory): prioritize full reindex over session-start skip in shouldSyncSessions

by QDenka open 2026-02-08 07:57 View on GitHub →
stale
## Summary When the memory search SQLite database is deleted and the gateway restarts, the sync is triggered with `reason: 'session-start'`. Previously, `shouldSyncSessions` would short-circuit and return `false` for `session-start` before checking `needsFullReindex`, causing all historical session files to remain unindexed. ## Fix Move the `needsFullReindex` check **before** the reason guard in `shouldSyncSessions`, so that a full reindex always includes session files regardless of the trigger reason. This is a minimal, single-line-reorder fix with no behavioral change for normal (non-reindex) syncs. Fixes #11728 <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adjusts the ordering of checks inside `shouldSyncSessions` so that `needsFullReindex` is evaluated before the `reason === 'session-start'` early return. This ensures that when the memory-search SQLite DB is missing/deleted and the gateway restarts (triggering a sync with `reason: 'session-start'`), the system still performs a full reindex and includes historical session files, instead of incorrectly skipping indexing them. The change is localized to `src/memory/manager.ts` and aligns the sync decision logic with the intended semantics: a full reindex request should override “skip on session start” guards, while normal session-start sync behavior remains unchanged when a full reindex is not required. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk. - The change is a targeted reordering inside a single decision function to ensure `needsFullReindex` takes precedence over a session-start early return. This directly addresses the described bug (unindexed historical sessions after DB deletion) and does not materially affect non-reindex syncs. - No files require special attention <!-- greptile_other_comments_section --> <sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) - Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13)) <!-- /greptile_comment -->

Most Similar PRs