Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions code-rs/core/src/agent_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,8 @@ fn agent_info_for_status(agent: &Agent, now: DateTime<Utc>) -> AgentInfo {
_ => None,
},
source_kind: agent.source_kind.clone(),
owner_session_id: agent.owner_session_id.map(|id| id.to_string()),
worktree_base: agent.worktree_base.clone(),
}
}

Expand Down
4 changes: 4 additions & 0 deletions code-rs/core/src/codex/streaming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11786,6 +11786,8 @@ mod agent_completion_wake_tests {
last_activity_at: None,
seconds_since_last_activity: None,
source_kind,
owner_session_id: None,
worktree_base: None,
}
}

Expand Down Expand Up @@ -11970,6 +11972,8 @@ async fn send_agent_status_update(sess: &Session) {
.max(0) as u64
}),
source_kind: agent.source_kind,
owner_session_id: agent.owner_session_id.map(|id| id.to_string()),
worktree_base: agent.worktree_base,
}
})
.collect();
Expand Down
11 changes: 11 additions & 0 deletions code-rs/core/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1644,6 +1644,17 @@ pub struct AgentInfo {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
pub source_kind: Option<AgentSourceKind>,

/// Session that launched this agent. Used to avoid applying background
/// automation results to the wrong live session.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
pub owner_session_id: Option<String>,

/// Git snapshot/base the agent worktree was created from, when available.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
pub worktree_base: Option<String>,
}

/// User's decision in response to an ExecApprovalRequest.
Expand Down
13 changes: 10 additions & 3 deletions code-rs/tui/src/app/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1847,12 +1847,18 @@ impl App<'_> {
);
}
}
AppEvent::BackgroundReviewStarted { worktree_path, branch, agent_id, snapshot } => {
AppEvent::BackgroundReviewStarted { worktree_path, branch, agent_id, snapshot, owner_session_id } => {
if let AppState::Chat { widget } = &mut self.app_state {
widget.on_background_review_started(worktree_path, branch, agent_id, snapshot);
widget.on_background_review_started(
worktree_path,
branch,
agent_id,
snapshot,
owner_session_id,
);
}
}
AppEvent::BackgroundReviewFinished { worktree_path, branch, has_findings, findings, summary, error, agent_id, snapshot } => {
AppEvent::BackgroundReviewFinished { worktree_path, branch, has_findings, findings, summary, error, agent_id, snapshot, owner_session_id } => {
if let AppState::Chat { widget } = &mut self.app_state {
widget.on_background_review_finished(
worktree_path,
Expand All @@ -1863,6 +1869,7 @@ impl App<'_> {
error.clone(),
agent_id.clone(),
snapshot.clone(),
owner_session_id,
);
}
}
Expand Down
2 changes: 2 additions & 0 deletions code-rs/tui/src/app_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ pub(crate) enum AppEvent {
branch: String,
agent_id: Option<String>,
snapshot: Option<String>,
owner_session_id: Option<Uuid>,
},
BackgroundReviewFinished {
worktree_path: PathBuf,
Expand All @@ -495,6 +496,7 @@ pub(crate) enum AppEvent {
error: Option<String>,
agent_id: Option<String>,
snapshot: Option<String>,
owner_session_id: Option<Uuid>,
},

/// Run the review command with the given argument string (mirrors `/review <args>`)
Expand Down
Loading