Add persisted manual ordering for thread sections (#36007)

## What changed

- Add `thread/section/move` to atomically move a thread into, within, or out of a section. Threads can be inserted before an existing member or appended, and moves within a section preserve `sectionEnteredAt`.
- Add `section_position` sorting to `thread/list`, with ascending order as its default, and expose `sectionEnteredAt` in thread responses.
- Persist section positions and entry times in SQLite, including migration of existing section members into recency order. Section membership is no longer updated through `thread/metadata/update`.

## Testing

- Cover section moves, reordering, pagination, persistence across restarts and rollout reconciliation, concurrent updates, and rank renumbering.

GitOrigin-RevId: aec6d7ddedca5277029b5caf5c074975397e956c
This commit is contained in:
joeytrasatti-openai authored and copyberry committed 2026-07-29 18:37:22 +00:00
1 parent c41a38dd10
commit ad6fc66b6d
75 files changed
+2879 -543

No files matched your search

+1
View File
@@ -143,6 +143,7 @@ mod tests {
preview: String::new(),
ephemeral: false,
section: None,
section_entered_at: None,
history_mode: Default::default(),
model_provider: "openai".to_string(),
created_at: 0,
+3
View File
@@ -3462,6 +3462,7 @@ async fn inactive_thread_started_notification_initializes_replay_session() -> Re
preview: "agent thread".to_string(),
ephemeral: false,
section: None,
section_entered_at: None,
history_mode: Default::default(),
model_provider: "agent-provider".to_string(),
created_at: 1,
@@ -3559,6 +3560,7 @@ async fn inactive_thread_started_notification_preserves_primary_model_when_path_
preview: "agent thread".to_string(),
ephemeral: false,
section: None,
section_entered_at: None,
history_mode: Default::default(),
model_provider: "agent-provider".to_string(),
created_at: 1,
@@ -3623,6 +3625,7 @@ async fn thread_read_session_state_does_not_reuse_primary_permission_profile() {
preview: "read thread".to_string(),
ephemeral: false,
section: None,
section_entered_at: None,
history_mode: Default::default(),
model_provider: "read-provider".to_string(),
created_at: 1,
@@ -418,6 +418,7 @@ mod tests {
preview: "read thread".to_string(),
ephemeral: false,
section: None,
section_entered_at: None,
history_mode: Default::default(),
model_provider: "read-provider".to_string(),
created_at: 1,