mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Harden paginated history handling in the TUI (#36951)
## What changed - Keep paginated resume, transcript, and fork workflows on bounded turn and item page requests, while preserving the legacy full-history fallback. - Refill underfilled terminal scrollback from older pages and show a transcript shortcut when earlier history is unloaded or truncated by the row cap. - Preserve a successfully created fork if its initial history hydration fails, keep side forks bounded, and retain the correct history boundary for nested forks and subagents. ## Testing - Add coverage for scrollback refill and truncation notices, bounded paginated requests, fork hydration failures, nested forks, and inherited subagent history filtering. GitOrigin-RevId: 10ba952ffb2f69717fbc71aa03cac7685f7dcf78
This commit is contained in:
1 parent
dbcd837c20
commit
449f099f1c
11 files changed
+894
-22
No files matched your search
@@ -11,6 +11,7 @@ use codex_app_server_protocol::JSONRPCMessage;
|
||||
use codex_app_server_protocol::JSONRPCRequest;
|
||||
use codex_app_server_protocol::JSONRPCResponse;
|
||||
use codex_app_server_protocol::SortDirection;
|
||||
use codex_app_server_protocol::ThreadHistoryMode;
|
||||
use codex_app_server_protocol::ThreadItemsListParams;
|
||||
use codex_app_server_protocol::ThreadItemsListResponse;
|
||||
use codex_app_server_protocol::ThreadStatus;
|
||||
@@ -43,6 +44,7 @@ enum HistoryCapabilities {
|
||||
Current,
|
||||
LegacyOnly,
|
||||
LegacyOnlyUnsupportedVariant,
|
||||
ForkHydrationFails,
|
||||
}
|
||||
|
||||
/// Returns and resets `(thread/loaded/list, thread/read)` request counts.
|
||||
@@ -144,6 +146,14 @@ async fn start_recording_app_server_with_history(
|
||||
"thread/turns/list" | "thread/items/list" => true,
|
||||
_ => false,
|
||||
};
|
||||
let reject_fork_hydration = history_capabilities
|
||||
== HistoryCapabilities::ForkHydrationFails
|
||||
&& request.method == "thread/items/list"
|
||||
&& request_sink
|
||||
.lock()
|
||||
.expect("request recorder lock")
|
||||
.iter()
|
||||
.any(|recorded| recorded.method == "thread/fork");
|
||||
let response = if matches!(
|
||||
history_capabilities,
|
||||
HistoryCapabilities::LegacyOnly
|
||||
@@ -166,6 +176,15 @@ async fn start_recording_app_server_with_history(
|
||||
message: message.to_string(),
|
||||
},
|
||||
})
|
||||
} else if reject_fork_hydration {
|
||||
JSONRPCMessage::Error(JSONRPCError {
|
||||
id: request_id,
|
||||
error: JSONRPCErrorError {
|
||||
code: -32603,
|
||||
data: None,
|
||||
message: "fork history hydration failed".to_string(),
|
||||
},
|
||||
})
|
||||
} else {
|
||||
let request = serde_json::from_value::<ClientRequest>(
|
||||
serde_json::to_value(request)?,
|
||||
@@ -240,12 +259,20 @@ async fn start_recording_app_server_with_history(
|
||||
))
|
||||
}
|
||||
|
||||
fn create_legacy_history_rollout(config: &Config) -> Result<ThreadId> {
|
||||
let thread_id = create_fake_rollout(
|
||||
fn create_history_rollout(
|
||||
config: &Config,
|
||||
history_mode: ThreadHistoryMode,
|
||||
preview: &str,
|
||||
) -> Result<ThreadId> {
|
||||
let create_rollout = match history_mode {
|
||||
ThreadHistoryMode::Legacy => create_fake_rollout,
|
||||
ThreadHistoryMode::Paginated => create_fake_paginated_rollout,
|
||||
};
|
||||
let thread_id = create_rollout(
|
||||
config.codex_home.as_path(),
|
||||
"2026-01-02T00-00-00",
|
||||
"2026-01-02T00:00:00Z",
|
||||
"legacy history",
|
||||
preview,
|
||||
Some(config.model_provider_id.as_str()),
|
||||
/*git_info*/ None,
|
||||
)
|
||||
@@ -606,7 +633,8 @@ async fn transcript_home_loads_every_older_history_page() -> Result<()> {
|
||||
#[tokio::test]
|
||||
async fn remote_legacy_history_start_negotiates_once_for_resume_and_fork() -> Result<()> {
|
||||
let (app, _codex_home) = make_history_test_app().await?;
|
||||
let legacy_thread_id = create_legacy_history_rollout(&app.config)?;
|
||||
let legacy_thread_id =
|
||||
create_history_rollout(&app.config, ThreadHistoryMode::Legacy, "legacy history")?;
|
||||
let (mut app_server, requests, proxy) = start_recording_app_server_with_history(
|
||||
&app.config,
|
||||
HistoryCapabilities::LegacyOnly,
|
||||
@@ -679,7 +707,8 @@ enum LegacyHistoryRequest {
|
||||
|
||||
async fn assert_remote_legacy_history_retry(request: LegacyHistoryRequest) -> Result<()> {
|
||||
let (app, _codex_home) = make_history_test_app().await?;
|
||||
let legacy_thread_id = create_legacy_history_rollout(&app.config)?;
|
||||
let legacy_thread_id =
|
||||
create_history_rollout(&app.config, ThreadHistoryMode::Legacy, "legacy history")?;
|
||||
let (mut app_server, requests, proxy) = start_recording_app_server_with_history(
|
||||
&app.config,
|
||||
HistoryCapabilities::LegacyOnly,
|
||||
@@ -736,6 +765,489 @@ async fn remote_legacy_history_resume_retries_generic_method_not_found() -> Resu
|
||||
async fn remote_legacy_history_fork_avoids_unsupported_fields() -> Result<()> {
|
||||
assert_remote_legacy_history_retry(LegacyHistoryRequest::Fork).await
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn paginated_fork_survives_post_response_hydration_failure() -> Result<()> {
|
||||
let (app, _codex_home) = make_history_test_app().await?;
|
||||
let parent_thread_id = create_history_rollout(
|
||||
&app.config,
|
||||
ThreadHistoryMode::Paginated,
|
||||
"paginated fork parent",
|
||||
)?;
|
||||
let (mut app_server, requests, proxy) = start_recording_app_server_with_history(
|
||||
&app.config,
|
||||
HistoryCapabilities::ForkHydrationFails,
|
||||
/*blocked_thread_list*/ None,
|
||||
/*failed_thread_name*/ None,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let started = app_server
|
||||
.resume_thread(
|
||||
app.config.clone(),
|
||||
parent_thread_id,
|
||||
crate::app_server_session::ResumeModelSettings::RestoreFromThread,
|
||||
)
|
||||
.await?;
|
||||
assert_eq!(started.session.thread_id, parent_thread_id);
|
||||
|
||||
let forked = app_server
|
||||
.fork_thread(app.config.clone(), parent_thread_id)
|
||||
.await?;
|
||||
|
||||
assert_ne!(forked.session.thread_id, parent_thread_id);
|
||||
assert_eq!(recorded_params(&requests, "thread/fork").len(), 1);
|
||||
|
||||
app_server.shutdown().await?;
|
||||
proxy.await??;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn underfilled_scrollback_fetches_older_pages_without_opening_the_transcript() -> Result<()> {
|
||||
let (mut app, mut app_event_rx, _op_rx) = make_test_app_with_channels().await;
|
||||
let codex_home = tempdir()?;
|
||||
app.config.codex_home = codex_home.path().to_path_buf().abs();
|
||||
app.config.sqlite = SqliteConfig::new_for_testing(codex_home.path().abs());
|
||||
app.config.terminal_resize_reflow.max_rows = TerminalResizeReflowMaxRows::Limit(8);
|
||||
let thread_id = create_history_rollout(
|
||||
&app.config,
|
||||
ThreadHistoryMode::Paginated,
|
||||
"scrollback pagination",
|
||||
)?;
|
||||
let path = rollout_path(
|
||||
codex_home.path(),
|
||||
"2026-01-02T00-00-00",
|
||||
&thread_id.to_string(),
|
||||
);
|
||||
let mut records = std::fs::read_to_string(&path)?
|
||||
.lines()
|
||||
.map(serde_json::from_str::<serde_json::Value>)
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
let events = std::iter::once(EventMsg::TurnStarted(TurnStartedEvent {
|
||||
turn_id: "scrollback-pagination-turn".to_string(),
|
||||
trace_id: None,
|
||||
started_at: None,
|
||||
model_context_window: None,
|
||||
collaboration_mode_kind: Default::default(),
|
||||
}))
|
||||
.chain((0..120).map(|index| {
|
||||
EventMsg::ItemCompleted(ItemCompletedEvent {
|
||||
thread_id,
|
||||
turn_id: "scrollback-pagination-turn".to_string(),
|
||||
item: TurnItem::AgentMessage(AgentMessageItem {
|
||||
id: format!("scrollback-item-{index}"),
|
||||
content: vec![AgentMessageContent::Text {
|
||||
text: format!("scrollback output {index}"),
|
||||
}],
|
||||
phase: None,
|
||||
memory_citation: None,
|
||||
}),
|
||||
started_at_ms: None,
|
||||
completed_at_ms: 0,
|
||||
})
|
||||
}));
|
||||
for event in events {
|
||||
records.push(serde_json::json!({
|
||||
"timestamp": "2026-01-02T00:00:00Z",
|
||||
"ordinal": records.len(),
|
||||
"type": "event_msg",
|
||||
"payload": serde_json::to_value(event)?,
|
||||
}));
|
||||
}
|
||||
let records = records
|
||||
.into_iter()
|
||||
.map(|record| record.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
std::fs::write(path, format!("{records}\n"))?;
|
||||
|
||||
let (mut app_server, requests, proxy) = start_recording_app_server(
|
||||
&app.config,
|
||||
/*blocked_thread_list*/ None,
|
||||
/*failed_thread_name*/ None,
|
||||
)
|
||||
.await?;
|
||||
let started = app_server
|
||||
.resume_thread(
|
||||
app.config.clone(),
|
||||
thread_id,
|
||||
crate::app_server_session::ResumeModelSettings::RestoreFromThread,
|
||||
)
|
||||
.await?;
|
||||
let mut initial_cells = crate::thread_transcript::thread_items_to_transcript_cells(
|
||||
Some(thread_id),
|
||||
&app.config.cwd,
|
||||
started.turns.iter().flat_map(|turn| turn.items.clone()),
|
||||
crate::thread_transcript::RawReasoningVisibility::Hidden,
|
||||
Some(app.config.codex_home.as_path()),
|
||||
);
|
||||
initial_cells.insert(
|
||||
/*index*/ 0,
|
||||
Arc::new(crate::history_cell::new_session_info(
|
||||
&app.config,
|
||||
started.session.model.as_str(),
|
||||
&started.session,
|
||||
/*is_first_event*/ false,
|
||||
Some("This is a test announcement".to_string()),
|
||||
/*auth_plan*/ None,
|
||||
/*show_fast_status*/ false,
|
||||
)),
|
||||
);
|
||||
app.enqueue_primary_thread_session(started.session, started.turns)
|
||||
.await?;
|
||||
app.transcript_cells = initial_cells;
|
||||
app.scrollback_has_older_history = app_server.has_older_history(thread_id);
|
||||
app.config.terminal_resize_reflow.max_rows = TerminalResizeReflowMaxRows::Limit(32);
|
||||
let initial_cell_count = app.transcript_cells.len();
|
||||
let initial_page_requests = recorded_params(&requests, "thread/items/list").len();
|
||||
let mut tui = crate::tui::test_support::make_test_tui()?;
|
||||
|
||||
app.scrollback_has_older_history = false;
|
||||
app.handle_key_event(
|
||||
&mut tui,
|
||||
&mut app_server,
|
||||
KeyEvent::new(KeyCode::Char('t'), KeyModifiers::CONTROL),
|
||||
)
|
||||
.await;
|
||||
assert!(app.scrollback_has_older_history);
|
||||
if let Some(Overlay::Transcript(overlay)) = app.overlay.as_mut() {
|
||||
overlay.handle_event(
|
||||
&mut tui,
|
||||
TuiEvent::Key(KeyEvent::new(KeyCode::Home, KeyModifiers::NONE)),
|
||||
)?;
|
||||
let area = Rect::new(
|
||||
/*x*/ 0, /*y*/ 0, /*width*/ 100, /*height*/ 16,
|
||||
);
|
||||
let render_overlay = |overlay: &mut crate::pager_overlay::TranscriptOverlay| {
|
||||
let mut buffer = Buffer::empty(area);
|
||||
overlay.render(area, &mut buffer);
|
||||
(area.y..area.bottom())
|
||||
.map(|y| {
|
||||
(area.x..area.right())
|
||||
.map(|x| buffer[(x, y)].symbol())
|
||||
.collect::<String>()
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n")
|
||||
};
|
||||
let partial = render_overlay(overlay);
|
||||
assert!(partial.contains("Earlier messages are available — scroll up to load them"));
|
||||
assert!(!partial.contains("OpenAI Codex"));
|
||||
assert!(!partial.contains("This is a test announcement"));
|
||||
assert!(!partial.contains('%'));
|
||||
|
||||
overlay.set_history_state(crate::pager_overlay::TranscriptHistoryState::LoadingOlder);
|
||||
let loading = render_overlay(overlay);
|
||||
assert!(loading.contains("Loading earlier messages..."));
|
||||
assert!(!loading.contains("OpenAI Codex"));
|
||||
assert!(!loading.contains('%'));
|
||||
} else {
|
||||
panic!("expected transcript overlay");
|
||||
}
|
||||
app.close_transcript_overlay(&mut tui);
|
||||
|
||||
let terminal_width = tui.terminal.last_known_screen_size.into();
|
||||
app.reflow_transcript_now(&mut tui, terminal_width)?;
|
||||
let request = loop {
|
||||
match app_event_rx.recv().await {
|
||||
Some(event @ AppEvent::RequestOlderScrollbackHistory { .. }) => break event,
|
||||
Some(_) => {}
|
||||
None => panic!("scrollback refill request channel closed"),
|
||||
}
|
||||
};
|
||||
app.handle_event(&mut tui, &mut app_server, request).await?;
|
||||
let loaded = loop {
|
||||
match app_event_rx.recv().await {
|
||||
Some(event @ AppEvent::OlderThreadHistoryLoaded { .. }) => break event,
|
||||
Some(_) => {}
|
||||
None => panic!("older history page channel closed"),
|
||||
}
|
||||
};
|
||||
app.handle_event(&mut tui, &mut app_server, loaded).await?;
|
||||
|
||||
assert!(app.overlay.is_none());
|
||||
assert!(app.transcript_cells.len() > initial_cell_count);
|
||||
assert_eq!(
|
||||
recorded_params(&requests, "thread/items/list").len(),
|
||||
initial_page_requests + 1
|
||||
);
|
||||
assert_eq!(
|
||||
app.render_transcript_lines_for_reflow(/*width*/ 80)
|
||||
.lines
|
||||
.len(),
|
||||
32
|
||||
);
|
||||
|
||||
app_server.shutdown().await?;
|
||||
proxy.await??;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn paginated_workflows_never_request_full_thread_history() -> Result<()> {
|
||||
let (app, _codex_home) = make_history_test_app().await?;
|
||||
let paginated_thread_id = create_history_rollout(
|
||||
&app.config,
|
||||
ThreadHistoryMode::Paginated,
|
||||
"paginated visible history",
|
||||
)?;
|
||||
let legacy_thread_id = create_history_rollout(
|
||||
&app.config,
|
||||
ThreadHistoryMode::Legacy,
|
||||
"legacy visible history",
|
||||
)?;
|
||||
let (mut app_server, requests, proxy) = start_recording_app_server(
|
||||
&app.config,
|
||||
/*blocked_thread_list*/ None,
|
||||
/*failed_thread_name*/ None,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let resumed = app_server
|
||||
.resume_thread(
|
||||
app.config.clone(),
|
||||
paginated_thread_id,
|
||||
crate::app_server_session::ResumeModelSettings::RestoreFromThread,
|
||||
)
|
||||
.await?;
|
||||
assert_eq!(resumed.session.thread_id, paginated_thread_id);
|
||||
let cells = crate::thread_transcript::load_session_transcript(
|
||||
&mut app_server,
|
||||
paginated_thread_id,
|
||||
crate::thread_transcript::RawReasoningVisibility::Hidden,
|
||||
Some(app.config.codex_home.as_path()),
|
||||
)
|
||||
.await?;
|
||||
assert!(!cells.is_empty());
|
||||
app_server
|
||||
.fork_thread(app.config.clone(), paginated_thread_id)
|
||||
.await?;
|
||||
let mut side_config = app.config.clone();
|
||||
side_config.ephemeral = true;
|
||||
app_server
|
||||
.fork_side_thread(side_config, paginated_thread_id)
|
||||
.await?;
|
||||
|
||||
let paginated_reads = recorded_params(&requests, "thread/read");
|
||||
assert!(!paginated_reads.is_empty());
|
||||
assert!(
|
||||
paginated_reads
|
||||
.iter()
|
||||
.all(|params| params["includeTurns"] != true),
|
||||
"paginated workflows requested full history: {paginated_reads:?}"
|
||||
);
|
||||
assert!(!recorded_params(&requests, "thread/turns/list").is_empty());
|
||||
assert!(!recorded_params(&requests, "thread/items/list").is_empty());
|
||||
|
||||
let previous_read_count = paginated_reads.len();
|
||||
crate::thread_transcript::load_session_transcript(
|
||||
&mut app_server,
|
||||
legacy_thread_id,
|
||||
crate::thread_transcript::RawReasoningVisibility::Hidden,
|
||||
Some(app.config.codex_home.as_path()),
|
||||
)
|
||||
.await?;
|
||||
let legacy_reads = recorded_params(&requests, "thread/read");
|
||||
let legacy_include_turns = legacy_reads[previous_read_count..]
|
||||
.iter()
|
||||
.map(|params| params["includeTurns"].as_bool().unwrap_or(false))
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(legacy_include_turns, vec![false, true]);
|
||||
|
||||
app_server.shutdown().await?;
|
||||
proxy.await??;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn cold_paginated_subagent_transcript_excludes_inherited_parent_history() -> Result<()> {
|
||||
let (app, codex_home) = make_history_test_app().await?;
|
||||
let parent_thread_id = create_history_rollout(
|
||||
&app.config,
|
||||
ThreadHistoryMode::Paginated,
|
||||
"parent-only paginated history",
|
||||
)?;
|
||||
let child_timestamp = "2026-01-02T00-00-01";
|
||||
let child_thread_id = ThreadId::from_string(
|
||||
&create_fake_parented_rollout_with_source(
|
||||
codex_home.path(),
|
||||
child_timestamp,
|
||||
"2026-01-02T00:00:01Z",
|
||||
"child-only paginated history",
|
||||
Some(app.config.model_provider_id.as_str()),
|
||||
/*git_info*/ None,
|
||||
RolloutSessionSource::SubAgent(SubAgentSource::ThreadSpawn {
|
||||
parent_thread_id,
|
||||
depth: 1,
|
||||
agent_path: Some(
|
||||
AgentPath::try_from("/root/worker").map_err(color_eyre::eyre::Report::msg)?,
|
||||
),
|
||||
agent_nickname: Some("worker".to_string()),
|
||||
agent_role: Some("worker".to_string()),
|
||||
}),
|
||||
parent_thread_id.into(),
|
||||
parent_thread_id,
|
||||
)
|
||||
.map_err(|err| color_eyre::eyre::eyre!("failed to create subagent rollout: {err}"))?,
|
||||
)?;
|
||||
let child_rollout_path = rollout_path(
|
||||
codex_home.path(),
|
||||
child_timestamp,
|
||||
&child_thread_id.to_string(),
|
||||
);
|
||||
let mut child_lines = std::fs::read_to_string(&child_rollout_path)?
|
||||
.lines()
|
||||
.map(serde_json::from_str::<serde_json::Value>)
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
let mut meta = child_lines.remove(/*index*/ 0);
|
||||
meta["payload"]["history_mode"] = serde_json::json!("paginated");
|
||||
meta["payload"]["subagent_history_start_ordinal"] = serde_json::json!(3);
|
||||
meta["ordinal"] = serde_json::json!(0);
|
||||
for (index, line) in child_lines.iter_mut().enumerate() {
|
||||
line["ordinal"] = serde_json::json!(index + 3);
|
||||
}
|
||||
let rollout_record = |ordinal: usize, kind: &str, payload: serde_json::Value| {
|
||||
serde_json::json!({
|
||||
"timestamp": "2026-01-02T00:00:01Z",
|
||||
"ordinal": ordinal,
|
||||
"type": kind,
|
||||
"payload": payload,
|
||||
})
|
||||
};
|
||||
let inherited_response = rollout_record(
|
||||
/*ordinal*/ 1,
|
||||
"response_item",
|
||||
serde_json::json!({
|
||||
"type": "message",
|
||||
"role": "user",
|
||||
"content": [{
|
||||
"type": "input_text",
|
||||
"text": "parent-only paginated history",
|
||||
}],
|
||||
}),
|
||||
);
|
||||
let inherited_event = rollout_record(
|
||||
/*ordinal*/ 2,
|
||||
"event_msg",
|
||||
serde_json::json!({
|
||||
"type": "user_message",
|
||||
"message": "parent-only paginated history",
|
||||
"kind": "plain",
|
||||
}),
|
||||
);
|
||||
let lines = std::iter::once(meta)
|
||||
.chain([inherited_response, inherited_event])
|
||||
.chain(child_lines)
|
||||
.chain([
|
||||
rollout_record(
|
||||
/*ordinal*/ 5,
|
||||
"event_msg",
|
||||
serde_json::json!({
|
||||
"type": "task_started",
|
||||
"turn_id": "child-visible-turn",
|
||||
"model_context_window": null,
|
||||
}),
|
||||
),
|
||||
rollout_record(
|
||||
/*ordinal*/ 6,
|
||||
"event_msg",
|
||||
serde_json::json!({
|
||||
"type": "item_completed",
|
||||
"thread_id": child_thread_id,
|
||||
"turn_id": "child-visible-turn",
|
||||
"item": {
|
||||
"type": "UserMessage",
|
||||
"id": "child-visible-user",
|
||||
"content": [{
|
||||
"type": "text",
|
||||
"text": "child-only paginated history",
|
||||
}],
|
||||
},
|
||||
}),
|
||||
),
|
||||
])
|
||||
.map(|line| line.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
std::fs::write(child_rollout_path, format!("{lines}\n"))?;
|
||||
let (mut app_server, requests, proxy) = start_recording_app_server(
|
||||
&app.config,
|
||||
/*blocked_thread_list*/ None,
|
||||
/*failed_thread_name*/ None,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let resumed = app_server
|
||||
.resume_thread(
|
||||
app.config.clone(),
|
||||
child_thread_id,
|
||||
crate::app_server_session::ResumeModelSettings::RestoreFromThread,
|
||||
)
|
||||
.await?;
|
||||
let child_turn_page = app_server
|
||||
.thread_turns_page(child_thread_id, /*cursor*/ None)
|
||||
.await?;
|
||||
let child_item_page = app_server
|
||||
.thread_items_page(
|
||||
child_thread_id,
|
||||
/*turn_id*/ None,
|
||||
/*cursor*/ None,
|
||||
/*limit*/ 16,
|
||||
)
|
||||
.await?;
|
||||
let [child_turn] = child_turn_page.data.as_slice() else {
|
||||
panic!("paginated subagent should expose exactly one child turn");
|
||||
};
|
||||
let [child_entry] = child_item_page.data.as_slice() else {
|
||||
panic!("paginated subagent should expose exactly one child message");
|
||||
};
|
||||
let ThreadItem::UserMessage { content, .. } = &child_entry.item else {
|
||||
panic!("paginated subagent should expose its child user message");
|
||||
};
|
||||
assert_eq!(resumed.session.thread_id, child_thread_id);
|
||||
assert_eq!(child_entry.turn_id, child_turn.id);
|
||||
assert_eq!(
|
||||
content,
|
||||
&[UserInput::Text {
|
||||
text: "child-only paginated history".to_string(),
|
||||
text_elements: Vec::new(),
|
||||
}],
|
||||
);
|
||||
assert_eq!(
|
||||
resumed
|
||||
.turns
|
||||
.iter()
|
||||
.flat_map(|turn| turn.items.iter())
|
||||
.collect::<Vec<_>>(),
|
||||
vec![&child_entry.item],
|
||||
);
|
||||
|
||||
let cells = crate::thread_transcript::load_session_transcript(
|
||||
&mut app_server,
|
||||
child_thread_id,
|
||||
crate::thread_transcript::RawReasoningVisibility::Hidden,
|
||||
Some(app.config.codex_home.as_path()),
|
||||
)
|
||||
.await?;
|
||||
let visible_history = cells
|
||||
.iter()
|
||||
.map(|cell| lines_to_single_string(&cell.display_lines(/*width*/ 80)))
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
assert!(visible_history.contains("child-only paginated history"));
|
||||
assert!(!visible_history.contains("parent-only paginated history"));
|
||||
assert!(
|
||||
recorded_params(&requests, "thread/read")
|
||||
.iter()
|
||||
.all(|params| params["includeTurns"] != true)
|
||||
);
|
||||
|
||||
app_server.shutdown().await?;
|
||||
proxy.await??;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fresh_session_applies_requested_name() -> Result<()> {
|
||||
const TEST_STACK_SIZE_BYTES: usize = 8 * 1024 * 1024;
|
||||
|
||||
Reference in new issue
Block a user