mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
Fix tui_app_server ghost subagent entries in /agent (#16110)
Fixes #16092 The app-server-backed TUI could accumulate ghost subagent entries in `/agent` after resume/backfill flows. Some of those rows were no longer live according to the backend, but still appeared selectable in the picker and could open as blank threads. *Cause* Unlike the legacy tui behavior, tui_app_server was creating local picker/replay state for subagents discovered through metadata refresh and loaded-thread backfill, even when no real local session or transcript had been attached. That let stale ids survive in the picker as if they were replayable threads. *Fix* Stop creating empty local thread channels during subagent metadata hydration and loaded-thread backfill. When opening /agent, prune metadata-only entries that thread/read reports as terminally unavailable. When selecting a discovered subagent that is still live but not yet locally attached, materialize a real local session on demand from thread/read instead of falling back to an empty replay state.
This commit is contained in:
committed by
GitHub
Unverified
parent
54d3ad1ede
commit
38e648ca67
@@ -122,6 +122,16 @@ impl AgentNavigationState {
|
||||
self.order.clear();
|
||||
}
|
||||
|
||||
/// Removes a tracked thread entirely from picker metadata and traversal order.
|
||||
///
|
||||
/// This is reserved for entries that were only discovered opportunistically and never became
|
||||
/// replayable local threads. Keeping those around after the backend confirms they are gone
|
||||
/// would leave ghost rows in `/agent`.
|
||||
pub(crate) fn remove(&mut self, thread_id: ThreadId) {
|
||||
self.threads.remove(&thread_id);
|
||||
self.order.retain(|candidate| *candidate != thread_id);
|
||||
}
|
||||
|
||||
/// Returns whether there is at least one tracked thread other than the primary one.
|
||||
///
|
||||
/// `App` uses this to decide whether the picker should be available even when the collaboration
|
||||
@@ -145,6 +155,14 @@ impl AgentNavigationState {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Returns tracked thread ids in the same stable order used by the picker.
|
||||
pub(crate) fn tracked_thread_ids(&self) -> Vec<ThreadId> {
|
||||
self.ordered_threads()
|
||||
.into_iter()
|
||||
.map(|(thread_id, _)| thread_id)
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Returns the adjacent thread id for keyboard navigation in stable spawn order.
|
||||
///
|
||||
/// The caller must pass the thread whose transcript is actually being shown to the user, not
|
||||
|
||||
Reference in New Issue
Block a user