Files
codex/codex-rs/state/migrations/0050_threads_section_empty_preview_indexes.sql
joeytrasatti-openai 1b450c7912 Persist thread section moves before the first turn (#39523)
## Why

New non-ephemeral threads have no persisted rollout or preview until their first
turn, so moving them into a section could leave them absent from section-filtered
thread lists.

## What changed

- Materialize and flush a non-ephemeral thread before applying an explicit
  section move.
- Include explicitly sectioned threads with empty previews in section-filtered
  queries, and update the partial indexes to cover them.

## Testing

- Add an app-server test that moves a newly started thread into and out of the
  pinned section before its first turn.
- Cover empty-preview threads in recency and section-position query tests.

GitOrigin-RevId: aa3c4daf9890f06c08b93cd60f146099cbc6cfb2
2026-08-19 17:57:40 +00:00

11 lines
407 B
SQL

DROP INDEX idx_threads_section_recency_at_ms;
DROP INDEX idx_threads_section_position;
CREATE INDEX idx_threads_section_recency_at_ms
ON threads(archived, thread_section_id, recency_at_ms DESC, id DESC)
WHERE thread_section_id IS NOT NULL;
CREATE INDEX idx_threads_section_position
ON threads(archived, thread_section_id, section_position ASC, id ASC)
WHERE thread_section_id IS NOT NULL;