Lightweight coding agent that runs in your terminal
Rust
Deliver gRPC code-mode notifications without truncation (#38645)
Adam Perry @ OpenAIfe556c4b6cbc
diff --git a/codex-rs/code-mode-host/tests/grpc_notifications.rs b/codex-rs/code-mode-host/tests/grpc_notifications.rsindex 86a361fda6..c3590ef43b 100644--- a/codex-rs/code-mode-host/tests/grpc_notifications.rs+++ b/codex-rs/code-mode-host/tests/grpc_notifications.rs@@ -273,7 +273,7 @@ async fn termination_cancels_pending_notifications() -> Result<()> {}#[tokio::test]-async fn oversized_notification_text_is_truncated_at_a_utf8_boundary() -> Result<()> {+async fn oversized_notification_text_is_delivered_unchanged() -> Result<()> {let host = HostHarness::start("grpc://127.0.0.1:0").await?;let provider = GrpcCodeModeSessionProvider::new(host.endpoint);let delegate = Arc::new(RecordingDelegate::default());@@ -292,17 +292,13 @@ async fn oversized_notification_text_is_truncated_at_a_utf8_boundary() -> Result);timeout(TEST_TIMEOUT, delegate.notification_delivered.notified()).await- .context("truncated notification was not delivered")?;+ .context("oversized notification was not delivered")?;assert_eq!(*delegate.notifications.lock().unwrap_or_else(PoisonError::into_inner),- vec![(- "call-1".to_string(),- cell_id("1"),- format!("{}... [truncated]", "🦀".repeat(252)),- )]+ vec![("call-1".to_string(), cell_id("1"), "🦀".repeat(512),)]);session.shutdown().await.map_err(anyhow::Error::msg)?;diff --git a/codex-rs/code-mode/src/grpc_session/callbacks.rs b/codex-rs/code-mode/src/grpc_session/callbacks.rsindex daf5f09b06..27714a836a 100644--- a/codex-rs/code-mode/src/grpc_session/callbacks.rs+++ b/codex-rs/code-mode/src/grpc_session/callbacks.rs@@ -16,9 +16,6 @@ use super::conversion;use super::deadline;use super::state::CallbackAdmission;-const MAX_NOTIFICATION_BYTES: usize = 1_024;-const TRUNCATED_NOTIFICATION_SUFFIX: &str = "... [truncated]";-impl SessionInner {pub(super) fn spawn_session_events(self: &Arc<Self>,@@ -197,15 +194,8 @@ impl SessionInner {fn handle_notification(self: &Arc<Self>,- mut notification: grpc::Notification,+ notification: grpc::Notification,) -> Result<(), String> {- if notification.text.len() > MAX_NOTIFICATION_BYTES {- let boundary = notification- .text- .floor_char_boundary(MAX_NOTIFICATION_BYTES - TRUNCATED_NOTIFICATION_SUFFIX.len());- notification.text.truncate(boundary);- notification.text.push_str(TRUNCATED_NOTIFICATION_SUFFIX);- }let admission = self.state.lock()