Test thread archiving before the first turn (#51193)

Extend the app-server thread metadata test to archive a thread after pinning
and unpinning it, before any turn starts. Assert that the thread appears in
`thread/list` results with `archived: true` and `use_state_db_only: true`.

GitOrigin-RevId: dde58e892b28843870bc3f678134fc86b93cd79c
This commit is contained in:
Brent Traut
2026-10-05 22:42:17 +00:00
committed by copyberry
parent 0d3868a30c
commit b4e3726d73
@@ -5,10 +5,13 @@ use app_test_support::create_fake_rollout;
use app_test_support::create_mock_responses_server_repeating_assistant;
use app_test_support::rollout_path;
use app_test_support::to_response;
use codex_app_server_protocol::ClientRequest;
use codex_app_server_protocol::GitInfo;
use codex_app_server_protocol::JSONRPCError;
use codex_app_server_protocol::JSONRPCResponse;
use codex_app_server_protocol::RequestId;
use codex_app_server_protocol::ThreadArchiveParams;
use codex_app_server_protocol::ThreadArchiveResponse;
use codex_app_server_protocol::ThreadHistoryMode;
use codex_app_server_protocol::ThreadListParams;
use codex_app_server_protocol::ThreadListResponse;
@@ -53,7 +56,7 @@ const DEFAULT_READ_TIMEOUT: std::time::Duration = std::time::Duration::from_secs
const INVALID_REQUEST_ERROR_CODE: i64 = -32600;
#[tokio::test]
async fn thread_section_move_pins_before_first_turn() -> Result<()> {
async fn thread_section_move_pins_and_archives_before_first_turn() -> Result<()> {
let server = create_mock_responses_server_repeating_assistant("Done").await;
let codex_home = TempDir::new()?;
mock_responses_config(&server.uri()).write(codex_home.path())?;
@@ -122,7 +125,7 @@ async fn thread_section_move_pins_before_first_turn() -> Result<()> {
let move_id = mcp
.send_thread_section_move_request(ThreadSectionMoveParams {
thread_id,
thread_id: thread_id.clone(),
section_id: None,
before_thread_id: None,
})
@@ -132,12 +135,39 @@ async fn thread_section_move_pins_before_first_turn() -> Result<()> {
let list_id = mcp
.send_thread_list_request(ThreadListParams {
section_id: None,
..list_params
..list_params.clone()
})
.await?;
let listed: ThreadListResponse =
timeout(DEFAULT_READ_TIMEOUT, mcp.read_response(list_id)).await??;
assert_eq!(listed.data, vec![]);
let _: ThreadArchiveResponse = mcp
.request(|request_id| ClientRequest::ThreadArchive {
request_id,
params: ThreadArchiveParams {
thread_id: thread_id.clone(),
},
})
.await?;
let archived: ThreadListResponse = mcp
.request(|request_id| ClientRequest::ThreadList {
request_id,
params: ThreadListParams {
archived: Some(true),
section_id: None,
..list_params
},
})
.await?;
assert_eq!(
archived
.data
.iter()
.map(|thread| thread.id.as_str())
.collect::<Vec<_>>(),
vec![thread_id.as_str()]
);
Ok(())
}