mirror of
https://github.com/openai/codex.git
synced 2026-08-23 13:09:46 +00:00
Deliver gRPC code-mode notifications without truncation (#38645)
## What changed - Forward notification text to the session delegate without applying the previous 1,024-byte limit or appending a truncation suffix. - Update the gRPC host integration test to verify that oversized multibyte notification text is delivered unchanged. GitOrigin-RevId: 9a9e24b359a07540f70ec4e98b28524db3f7a4a0
This commit is contained in:
committed by
copyberry
parent
efa97f9bc6
commit
fe556c4b6c
@@ -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)?;
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user