mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Preserve TUI drafts after app-server disconnects (#41911)
## Why Losing an external app-server connection can leave a submission's outcome uncertain. The TUI must preserve local work without retrying it or allowing stale server events to trigger more actions. ## What changed - Enter an offline state when an external app-server transport disconnects during startup, event streaming, or submission. - Keep conversation drafts, queued input, expanded pastes, attachments, and agent-overview input editable while blocking submissions, remote actions, and automatic queue replay. - Show a connection-lost notice that directs users to copy their work and relaunch, while retaining `Ctrl-C` and an empty-composer `Ctrl-D` as quit shortcuts. - Cancel pending views and asynchronous work, and ignore stale completions after the disconnect. Embedded app-server behavior is unchanged. ## Testing Added unit, snapshot, and pseudo-terminal coverage for lost startup and mutation replies, offline draft editing, queued-input recovery, stale-event quarantine, agent-overview behavior, and end-to-end preservation without reconnection or resubmission. GitOrigin-RevId: 7219a95fad676dda447d625db9e465345b469d58
This commit is contained in:
1 parent
b51b07785b
commit
a7913390f7
35 files changed
+987
-38
No files matched your search
@@ -267,6 +267,29 @@ async fn manual_recap_bypasses_automatic_eligibility_and_reports_failure() -> Re
|
||||
"rendered error: {rendered:?}"
|
||||
);
|
||||
|
||||
// A completion quarantined during reconnect must not leave the next recap stuck as busy.
|
||||
app.app_server_target = AppServerTarget::Remote {
|
||||
endpoint: crate::RemoteAppServerEndpoint::WebSocket {
|
||||
websocket_url: "ws://127.0.0.1:1".into(),
|
||||
auth_token: None,
|
||||
},
|
||||
};
|
||||
app.request_recap(&app_server, thread_id, RecapTrigger::Manual);
|
||||
let stale = tokio::time::timeout(Duration::from_secs(/*secs*/ 5), app_event_rx.recv())
|
||||
.await?
|
||||
.expect("recap completion before disconnect");
|
||||
assert!(matches!(stale, AppEvent::RecapStarted { .. }));
|
||||
assert!(app.begin_reconnect());
|
||||
app.handle_event(&mut tui, &mut app_server, stale).await?;
|
||||
while app_event_rx.try_recv().is_ok() {}
|
||||
app.reconnect.offline = false;
|
||||
app.request_recap(&app_server, thread_id, RecapTrigger::Manual);
|
||||
let next = tokio::time::timeout(Duration::from_secs(/*secs*/ 5), app_event_rx.recv()).await?;
|
||||
assert!(
|
||||
matches!(next, Some(AppEvent::RecapStarted { .. })),
|
||||
"{next:?}"
|
||||
);
|
||||
|
||||
app_server.shutdown().await?;
|
||||
proxy.await??;
|
||||
Ok(())
|
||||
|
||||
Reference in new issue
Block a user