Enable memories for paginated threads (#34386)

## Why

Paginated threads keep metadata updates in SQLite, while their rollout retains the initial `memory_mode`. Reconciliation could therefore overwrite the current setting with a stale value, and memory processing excluded these threads entirely.

## What changed

- Include paginated threads in stage 1 memory job selection and global memory output lookup.
- Preserve the SQLite `memory_mode` when reconciling or backfilling an existing paginated thread, while continuing to seed missing rows and restore legacy threads from rollouts.
- Omit `memory_mode` alongside Git metadata when flushing resumed paginated history.

## Testing

Added coverage for preserving disabled memory mode during reconciliation and backfill, selecting eligible paginated threads, and omitting initial metadata on paginated resume.

GitOrigin-RevId: 2a6e16068e69680728757fbec27aeefae45b8110
This commit is contained in:
Owen Lin
2026-07-20 17:41:33 +00:00
committed by copyberry
parent 6f785632b0
commit 2793c826e8
6 changed files with 154 additions and 29 deletions
@@ -201,8 +201,9 @@ impl ThreadMetadataSync {
ThreadHistoryMode::Paginated
) {
// Paginated rollouts never append metadata-only SessionMeta updates. Do not reapply
// the initial Git tuple when resume history is flushed after the first append.
// initial metadata when resume history is flushed after the first append.
update.git_info = None;
update.memory_mode = None;
}
Some(update)
}
@@ -675,10 +676,11 @@ mod tests {
}
#[test]
fn paginated_resume_history_does_not_reapply_initial_git_info() {
fn paginated_resume_history_does_not_reapply_initial_metadata() {
let thread_id = ThreadId::new();
let mut meta = session_meta(thread_id);
meta.meta.history_mode = ThreadHistoryMode::Paginated;
meta.meta.memory_mode = Some("disabled".to_string());
meta.git = Some(GitInfo {
commit_hash: None,
branch: Some("stale-branch".to_string()),
@@ -694,6 +696,7 @@ mod tests {
let update = sync.take_pending_update().expect("pending metadata update");
assert_eq!(update.patch.git_info, None);
assert_eq!(update.patch.memory_mode, None);
assert_eq!(update.patch.preview.as_deref(), Some("hello metadata"));
}