mirror of
https://github.com/openai/codex.git
synced 2026-11-16 22:00:36 +00:00
Preserve the current Cloud task until navigation is ready (#61490)
## Why Opening another Cloud task can fail while loading its history. Keep the current chat, draft, and reply stream intact until the replacement is ready. ## What changed - Prepare Cloud resumes with a scoped history handle and commit the attachment only after initial history hydration succeeds. - Discard abandoned or failed preparations, reuse healthy existing attachments, and preserve buffered events through the handoff. - Route Command Center task selections through the owning backend, including tasks found only in history search. ## Testing Add regression coverage for failed history loading preserving the chat and draft, prepared stream handoffs and cancellation, backend routing, and history requests completing while a large reply stream remains unread. GitOrigin-RevId: 67aab50bad4e9ce9216716da459fd5447f133ae1
This commit is contained in:
committed by
copyberry
parent
048431dcbe
commit
d659419fe7
@@ -478,10 +478,21 @@ async fn attach_preserves_opaque_events_and_native_error_details() {
|
||||
secret.clone(),
|
||||
);
|
||||
let data = [frame(&[10, 3, 10, 1, b'n']), frame(&[18, 3, 10, 1, b'r'])].concat();
|
||||
let mut fixture = fixture(response(
|
||||
data.iter().map(|b| Bytes::from(vec![*b])).collect(),
|
||||
status,
|
||||
))
|
||||
let large = vec![b'x'; 256 * 1024];
|
||||
let burst = frame(
|
||||
&wire::AttachResponse {
|
||||
event: Some(wire::Payload::ServerRequest(large.clone().into())),
|
||||
}
|
||||
.encode_to_vec(),
|
||||
);
|
||||
let fragmented = data.iter().map(|b| Bytes::from(vec![*b]));
|
||||
let mut fixture = fixture_responses(vec![
|
||||
response(
|
||||
fragmented.chain(std::iter::repeat_n(burst, 16)).collect(),
|
||||
status,
|
||||
),
|
||||
response(vec![frame(&[0x0a, 0x00])], tonic::Status::ok("")),
|
||||
])
|
||||
.await;
|
||||
let mut events = fixture.client.attach("t").await.unwrap();
|
||||
assert_request(&mut fixture, "Attach", &[10, 1, b't']).await;
|
||||
@@ -495,6 +506,27 @@ async fn attach_preserves_opaque_events_and_native_error_details() {
|
||||
panic!("server request expected")
|
||||
};
|
||||
assert_eq!(bytes.as_ref(), &[10, 1, b'r']);
|
||||
// History completes with several megabytes still unread on the Attach body.
|
||||
let request = ListItemsRequest {
|
||||
thread_id: "t".into(),
|
||||
turn_id: None,
|
||||
page: HistoryQuery::default(),
|
||||
};
|
||||
let history = fixture.client.list_items(&request);
|
||||
assert!(
|
||||
tokio::time::timeout(Duration::from_secs(5), history)
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
.data
|
||||
.is_empty()
|
||||
);
|
||||
for _ in 0..16 {
|
||||
let Event::ServerRequest(bytes) = events.next().await.unwrap().unwrap() else {
|
||||
panic!("burst event expected")
|
||||
};
|
||||
assert_eq!(bytes.as_ref(), large.as_slice());
|
||||
}
|
||||
let error = events.next().await.unwrap().unwrap_err();
|
||||
assert!(!format!("{error:?} {error}").contains("private"));
|
||||
let Error::Rpc(status) = error else {
|
||||
|
||||
Reference in New Issue
Block a user