mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Preserve TUI question state and integrate history and queue navigation (#42903)
## What changed - Retain question drafts, selections, expanded state, and handled message IDs across thread input restoration and reconnects. Preserve buffered live questions during session refresh without replaying their message text. - Enable history recall and search in question answers, honoring updated key bindings and stripping image attachments and placeholders from recalled entries. Preserve Vim mode when an answer is not accepted. - Let forward navigation past the last question restore the latest queued message as an editable main composer draft. Keep working status and queued messages visible alongside questions. - Show a countdown for newly arrived collapsed questions and clear it when the question editor is opened or used. - Disable question submission and skipping while the thread is unavailable. ## Testing Add regression tests and snapshots for draft restoration and replay deduplication, history search and key bindings, queued-message editing, countdown rendering, and question layout with working status. GitOrigin-RevId: de016120a979db860fd0d4b8098b322b312b7d84
This commit is contained in:
1 parent
d05e6d5f46
commit
be2684ede0
35 files changed
+700
-87
No files matched your search
@@ -56,7 +56,19 @@ pub(super) struct ThreadEventStore {
|
||||
}
|
||||
|
||||
impl ThreadEventStore {
|
||||
pub(super) fn event_survives_session_refresh(event: &ThreadBufferedEvent) -> bool {
|
||||
pub(super) fn event_survives_session_refresh(event: &mut ThreadBufferedEvent) -> bool {
|
||||
if let ThreadBufferedEvent::Notification(notification) = event
|
||||
&& let ServerNotification::ItemCompleted(notification) = notification.as_mut()
|
||||
&& let ThreadItem::AgentMessage {
|
||||
questions: Some(_),
|
||||
text,
|
||||
..
|
||||
} = &mut notification.item
|
||||
{
|
||||
// Refreshed turns contain the text; retain only the live question state.
|
||||
text.clear();
|
||||
return true;
|
||||
}
|
||||
match event {
|
||||
ThreadBufferedEvent::Request(_) | ThreadBufferedEvent::FeedbackSubmission(_) => true,
|
||||
ThreadBufferedEvent::Notification(notification) => matches!(
|
||||
@@ -104,7 +116,7 @@ impl ThreadEventStore {
|
||||
}
|
||||
|
||||
pub(super) fn rebase_buffer_after_session_refresh(&mut self) {
|
||||
self.buffer.retain(Self::event_survives_session_refresh);
|
||||
self.buffer.retain_mut(Self::event_survives_session_refresh);
|
||||
self.buffered_agent_message_delta_bytes = 0;
|
||||
}
|
||||
|
||||
@@ -721,6 +733,28 @@ mod tests {
|
||||
assert_eq!(store.has_pending_thread_approvals(), false);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn refresh_retains_live_questions_without_replaying_their_text() {
|
||||
let mut expected = serde_json::json!({
|
||||
"method": "item/completed", "params": {
|
||||
"threadId": "thread", "turnId": "turn", "completedAtMs": 0,
|
||||
"item": {
|
||||
"type": "agentMessage", "id": "question", "text": "already in the snapshot",
|
||||
"phase": null, "memoryCitation": null, "delivery": null,
|
||||
"questions": [{"title": "Which way?", "options": null}]
|
||||
}
|
||||
}
|
||||
});
|
||||
let mut store = ThreadEventStore::new(/*capacity*/ 8);
|
||||
store.push_notification(serde_json::from_value(expected.clone()).unwrap());
|
||||
store.rebase_buffer_after_session_refresh();
|
||||
expected["params"]["item"]["text"] = serde_json::json!("");
|
||||
let ThreadBufferedEvent::Notification(actual) = &store.snapshot().events[0] else {
|
||||
panic!("missing live question");
|
||||
};
|
||||
assert_eq!(serde_json::to_value(actual).unwrap(), expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn thread_event_store_rebase_preserves_hook_notifications() {
|
||||
let thread_id = ThreadId::new();
|
||||
|
||||
@@ -1477,7 +1477,7 @@ impl App {
|
||||
snapshot.turns = turns;
|
||||
snapshot
|
||||
.events
|
||||
.retain(ThreadEventStore::event_survives_session_refresh);
|
||||
.retain_mut(ThreadEventStore::event_survives_session_refresh);
|
||||
}
|
||||
|
||||
/// Opens the `/subagents` picker after refreshing cached labels for known threads.
|
||||
|
||||
Reference in new issue
Block a user