mirror of
https://github.com/openai/codex.git
synced 2026-11-21 22:50:37 +00:00
Keep Cloud threads current in the Agents overview (#62858)
## Why The Agents overview can go stale when Cloud threads change from another client, especially when the TUI has no conversation stream attached. ## What changed - Use Cloud stream notifications to update thread status and refresh the thread list. Poll every 10 seconds while the overview is visible and no stream is attached. - Refresh the history already shown while preserving the `Show more` cursor. Use fresh list metadata for thread names, recency, and unread state, and restore rows when a refresh catches a missed unarchive. ## Testing Cover Cloud inventory notifications, polling while detached, pagination across refreshes, and recovery from a missed unarchive. GitOrigin-RevId: 63c98438b6ddd2e47dd2d1f419c2a676508c6d91
This commit is contained in:
committed by
copyberry
parent
941e1dcade
commit
beac2ef8fc
@@ -62,6 +62,7 @@ pub use items::ItemSummary;
|
||||
pub use prewarm::EnvironmentSelection;
|
||||
pub use prewarm::ProjectEnvironment;
|
||||
pub use transcript::FileUpdate;
|
||||
pub use transcript::InventoryChange;
|
||||
pub use transcript::ItemDelta;
|
||||
pub use transcript::PatchKind;
|
||||
pub use transcript::PatchUpdate;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Typed live transcript updates for the attached thread.
|
||||
//! Live transcript updates for the attached thread and account notifications on its stream.
|
||||
use crate::Error;
|
||||
use crate::Event;
|
||||
use crate::ThreadStatus;
|
||||
@@ -14,6 +14,13 @@ pub struct TranscriptEvent {
|
||||
pub update: TranscriptUpdate,
|
||||
}
|
||||
|
||||
/// Changes to the account's thread list reported over an attachment.
|
||||
pub enum InventoryChange {
|
||||
Archived(String),
|
||||
Unarchived(String),
|
||||
Refresh,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
pub enum TranscriptUpdate {
|
||||
ItemStarted(crate::ItemLifecycle),
|
||||
@@ -99,7 +106,11 @@ redacted_debug!(
|
||||
);
|
||||
|
||||
// Field numbers in the ASB Notification.value oneof.
|
||||
const THREAD_STARTED: u32 = 2;
|
||||
const THREAD_STATUS_CHANGED: u32 = 3;
|
||||
const THREAD_ARCHIVED: u32 = 4;
|
||||
const THREAD_UNARCHIVED: u32 = 6;
|
||||
const THREAD_NAME_UPDATED: u32 = 10;
|
||||
const TURN_STARTED: u32 = 21;
|
||||
const TURN_COMPLETED: u32 = 23;
|
||||
pub(super) const ITEM_STARTED: u32 = 27;
|
||||
@@ -124,6 +135,36 @@ pub(super) fn required<T>(value: Option<T>) -> Result<T, DecodeFailure> {
|
||||
value.ok_or(DecodeFailure::MissingField)
|
||||
}
|
||||
impl Event {
|
||||
/// Recognizes account updates carried alongside the attached thread's transcript.
|
||||
pub fn inventory_change(&self) -> Option<InventoryChange> {
|
||||
let Self::Notification(bytes) = self else {
|
||||
return None;
|
||||
};
|
||||
let (tag, values) = wire::notification(bytes).ok().flatten()?;
|
||||
match tag {
|
||||
THREAD_ARCHIVED | THREAD_UNARCHIVED => {
|
||||
let envelope =
|
||||
wire::merge_messages::<wire::Envelope<crate::wire::ThreadIdRequest>>(values)
|
||||
.ok()?;
|
||||
let id = envelope.params?.thread_id;
|
||||
if id.is_empty() {
|
||||
return None;
|
||||
}
|
||||
Some(if tag == THREAD_ARCHIVED {
|
||||
InventoryChange::Archived(id)
|
||||
} else {
|
||||
InventoryChange::Unarchived(id)
|
||||
})
|
||||
}
|
||||
THREAD_STARTED
|
||||
| THREAD_STATUS_CHANGED
|
||||
| THREAD_NAME_UPDATED
|
||||
| TURN_STARTED
|
||||
| TURN_COMPLETED => Some(InventoryChange::Refresh),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a supported status update for this thread from an Attach notification.
|
||||
pub fn thread_status_for(&self, thread_id: &str) -> Option<ThreadStatus> {
|
||||
let Self::Notification(bytes) = self else {
|
||||
|
||||
Reference in New Issue
Block a user