mirror of
https://github.com/openai/codex.git
synced 2026-11-28 07:32:19 +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
@@ -650,6 +650,16 @@ impl BottomPane {
|
||||
self.push_view(Box::new(modal));
|
||||
}
|
||||
|
||||
/// Edit the draft without invoking popups, submissions, or remote actions.
|
||||
pub(crate) fn handle_disconnected_key(&mut self, key: KeyEvent) {
|
||||
self.view_stack.clear();
|
||||
self.delayed_approval_requests.clear();
|
||||
self.composer
|
||||
.set_input_enabled(/*enabled*/ true, /*placeholder*/ None);
|
||||
self.composer.handle_disconnected_key(key);
|
||||
self.request_redraw();
|
||||
}
|
||||
|
||||
/// Forward a key event to the active view or the composer.
|
||||
pub fn handle_key_event(&mut self, key_event: KeyEvent) -> InputResult {
|
||||
// If a modal/view is active, handle it here; otherwise forward to composer.
|
||||
@@ -2374,6 +2384,11 @@ mod tests {
|
||||
assert_eq!(pane.composer_text(), "ya");
|
||||
assert!(pane.view_stack.is_empty());
|
||||
assert_eq!(pane.delayed_approval_requests.len(), 1);
|
||||
pane.handle_disconnected_key(KeyEvent::new(KeyCode::Null, KeyModifiers::NONE));
|
||||
pane.pre_draw_tick_at(Instant::now() + APPROVAL_PROMPT_TYPING_IDLE_DELAY);
|
||||
pane.handle_paste(" kept".into());
|
||||
assert_eq!(pane.composer_text(), "ya kept");
|
||||
assert!(pane.view_stack.is_empty());
|
||||
while let Ok(event) = rx.try_recv() {
|
||||
assert!(
|
||||
!matches!(event, AppEvent::SubmitThreadOp { .. }),
|
||||
|
||||
Reference in new issue
Block a user