Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

[feedback] Add source info into feedback metadata. (#7140)

Matthew Zengc31663d74579
diff --git a/codex-rs/app-server/src/codex_message_processor.rs b/codex-rs/app-server/src/codex_message_processor.rs
index 5815e57850..a9f56de115 100644
--- a/codex-rs/app-server/src/codex_message_processor.rs
+++ b/codex-rs/app-server/src/codex_message_processor.rs
@@ -2794,6 +2794,7 @@ impl CodexMessageProcessor {
} else {
None
};
+ let session_source = self.conversation_manager.session_source();
let upload_result = tokio::task::spawn_blocking(move || {
let rollout_path_ref = validated_rollout_path.as_deref();
@@ -2802,6 +2803,7 @@ impl CodexMessageProcessor {
reason.as_deref(),
include_logs,
rollout_path_ref,
+ Some(session_source),
)
})
.await;
diff --git a/codex-rs/core/src/conversation_manager.rs b/codex-rs/core/src/conversation_manager.rs
index 8ffefd5679..0f4577bf1e 100644
--- a/codex-rs/core/src/conversation_manager.rs
+++ b/codex-rs/core/src/conversation_manager.rs
@@ -56,6 +56,10 @@ impl ConversationManager {
)
}
+ pub fn session_source(&self) -> SessionSource {
+ self.session_source.clone()
+ }
+
pub async fn new_conversation(&self, config: Config) -> CodexResult<NewConversation> {
self.spawn_conversation(config, self.auth_manager.clone())
.await
diff --git a/codex-rs/feedback/src/lib.rs b/codex-rs/feedback/src/lib.rs
index e1ccc3aac9..eaa949717a 100644
--- a/codex-rs/feedback/src/lib.rs
+++ b/codex-rs/feedback/src/lib.rs
@@ -10,6 +10,7 @@ use std::time::Duration;
use anyhow::Result;
use anyhow::anyhow;
use codex_protocol::ConversationId;
+use codex_protocol::protocol::SessionSource;
use tracing_subscriber::fmt::writer::MakeWriter;
const DEFAULT_MAX_BYTES: usize = 4 * 1024 * 1024; // 4 MiB
@@ -174,6 +175,7 @@ impl CodexLogSnapshot {
reason: Option<&str>,
include_logs: bool,
rollout_path: Option<&std::path::Path>,
+ session_source: Option<SessionSource>,
) -> Result<()> {
use std::collections::BTreeMap;
use std::fs;
@@ -203,6 +205,9 @@ impl CodexLogSnapshot {
(String::from("classification"), classification.to_string()),
(String::from("cli_version"), cli_version.to_string()),
]);
+ if let Some(source) = session_source.as_ref() {
+ tags.insert(String::from("session_source"), source.to_string());
+ }
if let Some(r) = reason {
tags.insert(String::from("reason"), r.to_string());
}
diff --git a/codex-rs/protocol/src/protocol.rs b/codex-rs/protocol/src/protocol.rs
index 27267de439..e5dbb26b90 100644
--- a/codex-rs/protocol/src/protocol.rs
+++ b/codex-rs/protocol/src/protocol.rs
@@ -1131,6 +1131,29 @@ pub enum SubAgentSource {
Other(String),
}
+impl fmt::Display for SessionSource {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ match self {
+ SessionSource::Cli => f.write_str("cli"),
+ SessionSource::VSCode => f.write_str("vscode"),
+ SessionSource::Exec => f.write_str("exec"),
+ SessionSource::Mcp => f.write_str("mcp"),
+ SessionSource::SubAgent(sub_source) => write!(f, "subagent_{sub_source}"),
+ SessionSource::Unknown => f.write_str("unknown"),
+ }
+ }
+}
+
+impl fmt::Display for SubAgentSource {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ match self {
+ SubAgentSource::Review => f.write_str("review"),
+ SubAgentSource::Compact => f.write_str("compact"),
+ SubAgentSource::Other(other) => f.write_str(other),
+ }
+ }
+}
+
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, TS)]
pub struct SessionMeta {
pub id: ConversationId,
diff --git a/codex-rs/tui/src/bottom_pane/feedback_view.rs b/codex-rs/tui/src/bottom_pane/feedback_view.rs
index 8a42e563cd..c563ab8e90 100644
--- a/codex-rs/tui/src/bottom_pane/feedback_view.rs
+++ b/codex-rs/tui/src/bottom_pane/feedback_view.rs
@@ -19,6 +19,7 @@ use crate::app_event::FeedbackCategory;
use crate::app_event_sender::AppEventSender;
use crate::history_cell;
use crate::render::renderable::Renderable;
+use codex_core::protocol::SessionSource;
use super::CancellationEvent;
use super::bottom_pane_view::BottomPaneView;
@@ -85,6 +86,7 @@ impl FeedbackNoteView {
} else {
None
},
+ Some(SessionSource::Cli),
);
match result {