Optimize default and attached thread listings with targeted indexes (#61727)

## Why

Default thread listings should stay in timestamp order without scanning subagent threads. Attached-thread listings should use both parent and archive filters even without planner statistics.

## What changed

- Add partial indexes for visible interactive threads sorted by creation, update, or recency timestamps.
- Use literal source predicates for default interactive listings so SQLite can select the partial indexes.
- Extend the attached-parent index to include archive status.

## Testing

Add a query-plan test verifying that the default sidebar listing uses the interactive update-time index. Extend app-server coverage to include `chatgpt` custom-source threads in default interactive listings.

GitOrigin-RevId: 5844622b7af629cad71e15ec95a8960739d6d447
This commit is contained in:
Dmitriy Kovalenko
2026-11-16 02:53:45 +00:00
committed by copyberry
parent eff3036bf4
commit ca0bbbdf0c
3 changed files with 123 additions and 3 deletions
@@ -1820,6 +1820,15 @@ async fn thread_list_empty_source_kinds_defaults_to_interactive_only() -> Result
Some("mock_provider"),
/*git_info*/ None,
)?;
let desktop_id = create_fake_rollout_with_source(
codex_home.path(),
"2025-02-01T10-30-00",
"2025-02-01T10:30:00Z",
"Desktop",
Some("mock_provider"),
/*git_info*/ None,
CoreSessionSource::Custom("chatgpt".to_string()),
)?;
let exec_id = create_fake_rollout_with_source(
codex_home.path(),
"2025-02-01T11-00-00",
@@ -1846,9 +1855,9 @@ async fn thread_list_empty_source_kinds_defaults_to_interactive_only() -> Result
assert_eq!(next_cursor, None);
let ids: Vec<_> = data.iter().map(|thread| thread.id.as_str()).collect();
assert_eq!(ids, vec![cli_id.as_str()]);
assert_eq!(ids, vec![desktop_id.as_str(), cli_id.as_str()]);
assert_ne!(cli_id, exec_id);
assert_eq!(data[0].source, SessionSource::Cli);
assert_eq!(data[1].source, SessionSource::Cli);
Ok(())
}