mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Delay automatic recaps and compact their TUI layout (#45089)
## What changed - Increase the automatic recap delay from 3 to 30 minutes. - Replace the recap heading and divider with an italic `↳ Recap:` layout, hanging indentation, and right padding. Preserve explicit line breaks and Unicode, splitting URLs only when they exceed the available text column. - Use Tokio's clock for automatic recap eligibility and create the timer before spawning its task. - Remove the `token_budget.use_history_notes_extension` override from temporary structured requests. ## Testing Add coverage for the 30-minute deadline, recap styling, narrow terminals, Unicode, and URL wrapping. Update recap generation and reconnect tests to advance Tokio's clock instead of relying on host uptime. GitOrigin-RevId: 79a9bca779020b59a409207163b02944b30c1a20
This commit is contained in:
1 parent
ee6814bfa4
commit
f16c2237a5
7 files changed
+193
-62
No files matched your search
@@ -2950,7 +2950,9 @@ impl App {
|
|||||||
AppEvent::CheckRecap { thread_id } => {
|
AppEvent::CheckRecap { thread_id } => {
|
||||||
if self.current_displayed_thread_id() == Some(thread_id)
|
if self.current_displayed_thread_id() == Some(thread_id)
|
||||||
&& !self.chat_widget.is_user_turn_pending_or_running()
|
&& !self.chat_widget.is_user_turn_pending_or_running()
|
||||||
&& self.recap.should_generate(std::time::Instant::now())
|
&& self
|
||||||
|
.recap
|
||||||
|
.should_generate(tokio::time::Instant::now().into_std())
|
||||||
{
|
{
|
||||||
self.request_recap(app_server, thread_id, RecapTrigger::Automatic);
|
self.request_recap(app_server, thread_id, RecapTrigger::Automatic);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ use uuid::Uuid;
|
|||||||
|
|
||||||
const MIN_COMPLETED_TURNS: usize = 3;
|
const MIN_COMPLETED_TURNS: usize = 3;
|
||||||
const MIN_TURNS_BETWEEN_RECAPS: usize = 2;
|
const MIN_TURNS_BETWEEN_RECAPS: usize = 2;
|
||||||
pub(super) const RECAP_DELAY: Duration = Duration::from_secs(/*secs*/ 3 * 60);
|
pub(super) const RECAP_DELAY: Duration = Duration::from_secs(/*secs*/ 30 * 60);
|
||||||
const RECAP_HISTORY_MAX_TURNS: usize = 8;
|
const RECAP_HISTORY_MAX_TURNS: usize = 8;
|
||||||
const RECAP_MAX_CHARS: usize = 320;
|
const RECAP_MAX_CHARS: usize = 320;
|
||||||
const RECAP_RETRY_DELAY: Duration = Duration::from_secs(/*secs*/ 30);
|
const RECAP_RETRY_DELAY: Duration = Duration::from_secs(/*secs*/ 30);
|
||||||
@@ -196,10 +196,11 @@ impl App {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let delay = deadline.saturating_duration_since(now);
|
let delay = deadline.saturating_duration_since(now);
|
||||||
|
let sleep = tokio::time::sleep(delay);
|
||||||
let app_event_tx = self.app_event_tx.clone();
|
let app_event_tx = self.app_event_tx.clone();
|
||||||
|
|
||||||
self.recap.scheduled_check = Some(tokio::spawn(async move {
|
self.recap.scheduled_check = Some(tokio::spawn(async move {
|
||||||
tokio::time::sleep(delay).await;
|
sleep.await;
|
||||||
app_event_tx.send(AppEvent::CheckRecap { thread_id });
|
app_event_tx.send(AppEvent::CheckRecap { thread_id });
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@@ -357,7 +358,9 @@ impl App {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let trigger_is_eligible = match trigger {
|
let trigger_is_eligible = match trigger {
|
||||||
RecapTrigger::Automatic => self.recap.should_generate(Instant::now()),
|
RecapTrigger::Automatic => self
|
||||||
|
.recap
|
||||||
|
.should_generate(tokio::time::Instant::now().into_std()),
|
||||||
RecapTrigger::Manual => true,
|
RecapTrigger::Manual => true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,13 @@ use crate::history_cell::PlainHistoryCell;
|
|||||||
use crate::history_cell::ThreadRecapHistoryCell;
|
use crate::history_cell::ThreadRecapHistoryCell;
|
||||||
use crate::history_cell::ThreadRecapLoadingCell;
|
use crate::history_cell::ThreadRecapLoadingCell;
|
||||||
use crate::history_cell::UserHistoryCell;
|
use crate::history_cell::UserHistoryCell;
|
||||||
|
use crate::line_truncation::line_width;
|
||||||
use codex_app_server_protocol::Turn;
|
use codex_app_server_protocol::Turn;
|
||||||
use codex_app_server_protocol::TurnStatus;
|
use codex_app_server_protocol::TurnStatus;
|
||||||
use codex_protocol::ThreadId;
|
use codex_protocol::ThreadId;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
use ratatui::style::Modifier;
|
||||||
|
use ratatui::style::Stylize;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
@@ -316,7 +319,7 @@ fn regaining_focus_preserves_only_manual_in_flight_request() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "current_thread", start_paused = true)]
|
#[tokio::test(flavor = "current_thread", start_paused = true)]
|
||||||
async fn scheduled_check_fires_at_recap_deadline() {
|
async fn scheduled_check_fires_after_thirty_minutes() {
|
||||||
let thread_id = ThreadId::new();
|
let thread_id = ThreadId::new();
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
let mut app = make_test_app().await;
|
let mut app = make_test_app().await;
|
||||||
@@ -330,7 +333,7 @@ async fn scheduled_check_fires_at_recap_deadline() {
|
|||||||
app.schedule_recap_check(thread_id, now);
|
app.schedule_recap_check(thread_id, now);
|
||||||
tokio::task::yield_now().await;
|
tokio::task::yield_now().await;
|
||||||
|
|
||||||
tokio::time::advance(RECAP_DELAY - Duration::from_secs(/*secs*/ 1)).await;
|
tokio::time::advance(Duration::from_secs(/*secs*/ 30 * 60 - 1)).await;
|
||||||
tokio::task::yield_now().await;
|
tokio::task::yield_now().await;
|
||||||
assert!(matches!(event_rx.try_recv(), Err(TryRecvError::Empty)));
|
assert!(matches!(event_rx.try_recv(), Err(TryRecvError::Empty)));
|
||||||
|
|
||||||
@@ -518,20 +521,28 @@ fn restored_history_never_reduces_observed_completed_turns() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn recap_history_cell_uses_labeled_checkpoint_layout() {
|
fn recap_history_cell_uses_hanging_indent_and_right_padding() {
|
||||||
let cell =
|
let cell =
|
||||||
ThreadRecapHistoryCell::new("Automatic recaps stay compact on wide terminals.".to_string());
|
ThreadRecapHistoryCell::new("Automatic recaps stay compact on wide terminals.".to_string());
|
||||||
let rendered = cell
|
let lines = cell.display_lines(/*width*/ 56);
|
||||||
.display_lines(/*width*/ 64)
|
assert!(
|
||||||
|
lines
|
||||||
|
.iter()
|
||||||
|
.all(|line| line.style.add_modifier.contains(Modifier::ITALIC))
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
&lines[0].spans[..3],
|
||||||
|
&[" ".into(), "↳ ".dim(), "Recap: ".bold()],
|
||||||
|
);
|
||||||
|
let rendered = lines
|
||||||
.iter()
|
.iter()
|
||||||
.map(ToString::to_string)
|
.map(ToString::to_string)
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join("\n");
|
.join("\n");
|
||||||
|
|
||||||
insta::assert_snapshot!(rendered, @r"
|
insta::assert_snapshot!(rendered, @r"
|
||||||
─ Conversation recap ───────────────────────────────────────────
|
↳ Recap: Automatic recaps stay compact on wide
|
||||||
|
terminals.
|
||||||
Automatic recaps stay compact on wide terminals.
|
|
||||||
");
|
");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -548,13 +559,119 @@ fn recap_history_cell_wraps_in_narrow_terminals() {
|
|||||||
.join("\n");
|
.join("\n");
|
||||||
|
|
||||||
insta::assert_snapshot!(rendered, @r"
|
insta::assert_snapshot!(rendered, @r"
|
||||||
─ Conversation recap ───────────
|
↳ Recap: Keep conversation
|
||||||
|
recaps readable in
|
||||||
Keep conversation recaps
|
narrow terminals.
|
||||||
readable in narrow terminals.
|
|
||||||
");
|
");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn recap_history_cell_preserves_unicode_and_url_tokens() {
|
||||||
|
let cell = ThreadRecapHistoryCell::new(
|
||||||
|
"Résumé ready. See https://example.com/review/42 日本語 details.".to_string(),
|
||||||
|
);
|
||||||
|
let rendered = cell
|
||||||
|
.display_lines(/*width*/ 48)
|
||||||
|
.iter()
|
||||||
|
.map(ToString::to_string)
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join("\n");
|
||||||
|
|
||||||
|
insta::assert_snapshot!(rendered, @r"
|
||||||
|
↳ Recap: Résumé ready. See
|
||||||
|
https://example.com/review/42
|
||||||
|
日本語 details.
|
||||||
|
");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn recap_history_cell_wraps_long_urls_in_narrow_terminals() {
|
||||||
|
let cell = ThreadRecapHistoryCell::new(
|
||||||
|
"The café review is paused with the draft ready at https://example.com/review/42. 日本語"
|
||||||
|
.to_string(),
|
||||||
|
);
|
||||||
|
let lines = cell.display_lines(/*width*/ 32);
|
||||||
|
assert!(lines.iter().all(|line| line_width(line) <= 30));
|
||||||
|
assert!(
|
||||||
|
lines
|
||||||
|
.iter()
|
||||||
|
.skip(/*n*/ 1)
|
||||||
|
.all(|line| line.to_string().starts_with(" "))
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
lines
|
||||||
|
.iter()
|
||||||
|
.all(|line| line.style.add_modifier.contains(Modifier::ITALIC))
|
||||||
|
);
|
||||||
|
let rendered = lines
|
||||||
|
.iter()
|
||||||
|
.map(ToString::to_string)
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join("\n");
|
||||||
|
|
||||||
|
insta::assert_snapshot!(rendered, @"
|
||||||
|
↳ Recap: The café review is
|
||||||
|
paused with the
|
||||||
|
draft ready at
|
||||||
|
https://example.com
|
||||||
|
/review/42. 日本語
|
||||||
|
");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn recap_history_cell_splits_only_urls_wider_than_the_text_column() {
|
||||||
|
for (url, expected) in [
|
||||||
|
(
|
||||||
|
"https://example.com",
|
||||||
|
vec![" ↳ Recap: https://example.com"],
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"https://example.com/",
|
||||||
|
vec![" ↳ Recap: https://example.com", " /"],
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"https://a.co/ガガガガガガ",
|
||||||
|
vec![" ↳ Recap: https://a.co/ガガガ", " ガガガ"],
|
||||||
|
),
|
||||||
|
] {
|
||||||
|
let cell = ThreadRecapHistoryCell::new(url.to_string());
|
||||||
|
let lines = cell.display_lines(/*width*/ 32);
|
||||||
|
assert!(lines.iter().all(|line| line_width(line) <= 30));
|
||||||
|
assert_eq!(
|
||||||
|
lines.iter().map(ToString::to_string).collect::<Vec<_>>(),
|
||||||
|
expected
|
||||||
|
);
|
||||||
|
let displayed_url = lines
|
||||||
|
.iter()
|
||||||
|
.map(|line| line.to_string().chars().skip(/*n*/ 11).collect::<String>())
|
||||||
|
.collect::<String>();
|
||||||
|
assert_eq!(displayed_url, url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn recap_history_cell_uses_available_space_below_indent_width() {
|
||||||
|
let cell = ThreadRecapHistoryCell::new(
|
||||||
|
"Resume this task.\nhttps://example.com/review/42.".to_string(),
|
||||||
|
);
|
||||||
|
let rendered = cell
|
||||||
|
.display_lines(/*width*/ 12)
|
||||||
|
.iter()
|
||||||
|
.map(ToString::to_string)
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join("\n");
|
||||||
|
|
||||||
|
insta::assert_snapshot!(rendered, @r"
|
||||||
|
↳ Recap:
|
||||||
|
Resume
|
||||||
|
this task.
|
||||||
|
https://ex
|
||||||
|
ample.com/
|
||||||
|
review/42.
|
||||||
|
");
|
||||||
|
assert_eq!(cell.display_lines(/*width*/ 0), Vec::new());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn recap_history_cell_preserves_heading_in_raw_history() {
|
fn recap_history_cell_preserves_heading_in_raw_history() {
|
||||||
let cell = ThreadRecapHistoryCell::new("Resume this task.".to_string());
|
let cell = ThreadRecapHistoryCell::new("Resume this task.".to_string());
|
||||||
@@ -590,10 +707,8 @@ fn recap_history_cell_preserves_explicit_line_breaks() {
|
|||||||
.join("\n");
|
.join("\n");
|
||||||
|
|
||||||
insta::assert_snapshot!(displayed, @r"
|
insta::assert_snapshot!(displayed, @r"
|
||||||
─ Conversation recap ───────────────────────────
|
↳ Recap: Finished the parser.
|
||||||
|
Next: run the focused tests.
|
||||||
Finished the parser.
|
|
||||||
Next: run the focused tests.
|
|
||||||
");
|
");
|
||||||
insta::assert_snapshot!(raw, @r"
|
insta::assert_snapshot!(raw, @r"
|
||||||
Conversation recap
|
Conversation recap
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ async fn reconnect_restores_history_permissions_and_keeps_old_input_paused() ->
|
|||||||
&mut app.rate_limit_hard_stop_generation,
|
&mut app.rate_limit_hard_stop_generation,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let before_disconnect = Instant::now() - Duration::from_secs(/*secs*/ 300);
|
let before_disconnect = Instant::now();
|
||||||
app.recap.note_focus_lost(before_disconnect);
|
app.recap.note_focus_lost(before_disconnect);
|
||||||
for _ in 0..3 {
|
for _ in 0..3 {
|
||||||
app.recap
|
app.recap
|
||||||
@@ -273,6 +273,10 @@ async fn reconnect_restores_history_permissions_and_keeps_old_input_paused() ->
|
|||||||
!app.agent_navigation
|
!app.agent_navigation
|
||||||
.finish_picker_refresh(id, stale_picker_refresh)
|
.finish_picker_refresh(id, stale_picker_refresh)
|
||||||
);
|
);
|
||||||
|
// Let the rebound timer become due without depending on machine uptime.
|
||||||
|
tokio::time::pause();
|
||||||
|
tokio::time::advance(recap::RECAP_DELAY).await;
|
||||||
|
tokio::time::resume();
|
||||||
let mut deferred = Vec::new();
|
let mut deferred = Vec::new();
|
||||||
tokio::time::timeout(Duration::from_secs(/*secs*/ 5), async {
|
tokio::time::timeout(Duration::from_secs(/*secs*/ 5), async {
|
||||||
loop {
|
loop {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ fn render_chat_widget(app: &App) -> String {
|
|||||||
.join("\n")
|
.join("\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_eligible_recap(app: &mut App, thread_id: ThreadId) {
|
async fn prepare_eligible_recap(app: &mut App, thread_id: ThreadId) {
|
||||||
app.active_thread_id = Some(thread_id);
|
app.active_thread_id = Some(thread_id);
|
||||||
app.transcript_cells
|
app.transcript_cells
|
||||||
.push(Arc::new(crate::history_cell::UserHistoryCell {
|
.push(Arc::new(crate::history_cell::UserHistoryCell {
|
||||||
@@ -44,15 +44,19 @@ fn prepare_eligible_recap(app: &mut App, thread_id: ThreadId) {
|
|||||||
local_image_paths: Vec::new(),
|
local_image_paths: Vec::new(),
|
||||||
remote_image_urls: Vec::new(),
|
remote_image_urls: Vec::new(),
|
||||||
}));
|
}));
|
||||||
let ready_at = Instant::now() - recap::RECAP_DELAY;
|
let ready_at = Instant::now();
|
||||||
app.recap.note_focus_lost(ready_at);
|
app.recap.note_focus_lost(ready_at);
|
||||||
for _ in 0..3 {
|
for _ in 0..3 {
|
||||||
app.recap
|
app.recap
|
||||||
.note_turn_finished(&TurnStatus::Completed, ready_at);
|
.note_turn_finished(&TurnStatus::Completed, ready_at);
|
||||||
}
|
}
|
||||||
|
// Advance the scheduler's clock instead of subtracting from the host's uptime.
|
||||||
|
tokio::time::pause();
|
||||||
|
tokio::time::advance(recap::RECAP_DELAY).await;
|
||||||
|
tokio::time::resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::test]
|
||||||
async fn recap_generation_uses_bounded_structured_request_and_inserts_result() -> Result<()> {
|
async fn recap_generation_uses_bounded_structured_request_and_inserts_result() -> Result<()> {
|
||||||
let chunks = [
|
let chunks = [
|
||||||
ev_response_created("recap-response"),
|
ev_response_created("recap-response"),
|
||||||
@@ -113,7 +117,7 @@ stream_max_retries = 0
|
|||||||
.await?;
|
.await?;
|
||||||
while app_event_rx.try_recv().is_ok() {}
|
while app_event_rx.try_recv().is_ok() {}
|
||||||
|
|
||||||
prepare_eligible_recap(&mut app, thread_id);
|
prepare_eligible_recap(&mut app, thread_id).await;
|
||||||
|
|
||||||
app.handle_event(
|
app.handle_event(
|
||||||
&mut tui,
|
&mut tui,
|
||||||
@@ -305,7 +309,7 @@ async fn manual_recap_works_when_auto_recap_disabled() -> Result<()> {
|
|||||||
async fn auto_recap_opt_out_blocks_requests_and_cleans_up_pending_start() -> Result<()> {
|
async fn auto_recap_opt_out_blocks_requests_and_cleans_up_pending_start() -> Result<()> {
|
||||||
let (mut app, mut app_event_rx, _op_rx) = make_test_app_with_channels().await;
|
let (mut app, mut app_event_rx, _op_rx) = make_test_app_with_channels().await;
|
||||||
let thread_id = ThreadId::new();
|
let thread_id = ThreadId::new();
|
||||||
prepare_eligible_recap(&mut app, thread_id);
|
prepare_eligible_recap(&mut app, thread_id).await;
|
||||||
let (mut app_server, requests, proxy) = start_recording_remote_app_server(&app.config).await?;
|
let (mut app_server, requests, proxy) = start_recording_remote_app_server(&app.config).await?;
|
||||||
let mut tui = crate::tui::test_support::make_test_tui()?;
|
let mut tui = crate::tui::test_support::make_test_tui()?;
|
||||||
app.local_settings.tui.auto_recap = false;
|
app.local_settings.tui.auto_recap = false;
|
||||||
@@ -453,7 +457,7 @@ async fn temporary_recap_threads_disable_memories_and_remote_mcp_servers() -> Re
|
|||||||
async fn recap_check_rejects_a_non_displayed_thread() -> Result<()> {
|
async fn recap_check_rejects_a_non_displayed_thread() -> Result<()> {
|
||||||
let (mut app, mut app_event_rx, _op_rx) = make_test_app_with_channels().await;
|
let (mut app, mut app_event_rx, _op_rx) = make_test_app_with_channels().await;
|
||||||
let displayed_thread_id = ThreadId::new();
|
let displayed_thread_id = ThreadId::new();
|
||||||
prepare_eligible_recap(&mut app, displayed_thread_id);
|
prepare_eligible_recap(&mut app, displayed_thread_id).await;
|
||||||
while app_event_rx.try_recv().is_ok() {}
|
while app_event_rx.try_recv().is_ok() {}
|
||||||
let (mut app_server, requests, proxy) = start_recording_remote_app_server(&app.config).await?;
|
let (mut app_server, requests, proxy) = start_recording_remote_app_server(&app.config).await?;
|
||||||
let mut tui = crate::tui::test_support::make_test_tui()?;
|
let mut tui = crate::tui::test_support::make_test_tui()?;
|
||||||
@@ -483,7 +487,7 @@ async fn recap_check_rejects_a_non_displayed_thread() -> Result<()> {
|
|||||||
async fn recap_check_rejects_a_running_turn() -> Result<()> {
|
async fn recap_check_rejects_a_running_turn() -> Result<()> {
|
||||||
let (mut app, mut app_event_rx, _op_rx) = make_test_app_with_channels().await;
|
let (mut app, mut app_event_rx, _op_rx) = make_test_app_with_channels().await;
|
||||||
let thread_id = ThreadId::new();
|
let thread_id = ThreadId::new();
|
||||||
prepare_eligible_recap(&mut app, thread_id);
|
prepare_eligible_recap(&mut app, thread_id).await;
|
||||||
app.chat_widget
|
app.chat_widget
|
||||||
.handle_thread_session(test_thread_session(thread_id, app.config.cwd.to_path_buf()));
|
.handle_thread_session(test_thread_session(thread_id, app.config.cwd.to_path_buf()));
|
||||||
app.chat_widget.handle_server_notification(
|
app.chat_widget.handle_server_notification(
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
//! Informational, warning, update, and policy notice history cells.
|
//! Informational, warning, update, and policy notice history cells.
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::line_truncation::line_width;
|
||||||
|
use crate::wrapping::url_preserving_wrap_options;
|
||||||
|
use crate::wrapping::word_wrap_line;
|
||||||
|
|
||||||
#[cfg_attr(not(test), allow(dead_code))]
|
#[cfg_attr(not(test), allow(dead_code))]
|
||||||
const RECAP_HEADING: &str = "Conversation recap";
|
const RECAP_HEADING: &str = "Conversation recap";
|
||||||
@@ -325,39 +328,43 @@ impl ThreadRecapHistoryCell {
|
|||||||
|
|
||||||
impl HistoryCell for ThreadRecapHistoryCell {
|
impl HistoryCell for ThreadRecapHistoryCell {
|
||||||
fn display_lines(&self, width: u16) -> Vec<Line<'static>> {
|
fn display_lines(&self, width: u16) -> Vec<Line<'static>> {
|
||||||
let width = usize::from(width);
|
if width == 0 {
|
||||||
let mut remaining_width = width;
|
return Vec::new();
|
||||||
let mut heading = Vec::new();
|
|
||||||
|
|
||||||
if remaining_width > 0 {
|
|
||||||
heading.push("─".dim());
|
|
||||||
remaining_width -= 1;
|
|
||||||
}
|
|
||||||
if remaining_width > 0 {
|
|
||||||
heading.push(" ".dim());
|
|
||||||
remaining_width -= 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let (visible_heading, _suffix, heading_width) =
|
let wrap_width = usize::from(width.saturating_sub(/*rhs*/ 2).max(/*other*/ 1));
|
||||||
take_prefix_by_width(RECAP_HEADING, remaining_width);
|
let mut body = raw_lines_from_source(&self.recap)
|
||||||
if !visible_heading.is_empty() {
|
.into_iter()
|
||||||
heading.push(visible_heading.bold());
|
.map(Line::italic)
|
||||||
remaining_width -= heading_width;
|
.collect::<Vec<_>>();
|
||||||
|
let prefix = Line::from(vec![" ".into(), "↳ ".dim(), "Recap: ".bold()]).italic();
|
||||||
|
let mut options = if wrap_width <= prefix.width() {
|
||||||
|
// Keep the text readable when the terminal cannot fit the hanging indent.
|
||||||
|
body.insert(
|
||||||
|
/*index*/ 0,
|
||||||
|
Line::from(vec!["↳ ".dim(), "Recap:".bold()]).italic(),
|
||||||
|
);
|
||||||
|
RtOptions::new(wrap_width)
|
||||||
|
} else {
|
||||||
|
RtOptions::new(wrap_width)
|
||||||
|
.subsequent_indent(" ".repeat(prefix.width()).into())
|
||||||
|
.initial_indent(prefix)
|
||||||
|
};
|
||||||
|
let mut lines = Vec::new();
|
||||||
|
for line in body {
|
||||||
|
let mut wrapped = adaptive_wrap_line(&line, options.clone());
|
||||||
|
if wrapped.iter().any(|line| line_width(line) > wrap_width) {
|
||||||
|
// Terminal autowrap loses the hanging indent. Rewrap the source line so only
|
||||||
|
// oversized tokens split, without applying the recap prefix a second time.
|
||||||
|
wrapped = word_wrap_line(
|
||||||
|
&line,
|
||||||
|
url_preserving_wrap_options(options.clone())
|
||||||
|
.break_words(/*break_words*/ true),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
push_owned_lines(&wrapped, &mut lines);
|
||||||
|
options.initial_indent = options.subsequent_indent.clone();
|
||||||
}
|
}
|
||||||
if remaining_width > 0 {
|
|
||||||
heading.push(" ".dim());
|
|
||||||
remaining_width -= 1;
|
|
||||||
}
|
|
||||||
if remaining_width > 0 {
|
|
||||||
heading.push("─".repeat(remaining_width).dim());
|
|
||||||
}
|
|
||||||
|
|
||||||
let wrap_width = width.saturating_sub(2).max(1);
|
|
||||||
let body = raw_lines_from_source(&self.recap);
|
|
||||||
let wrapped = adaptive_wrap_lines(body, RtOptions::new(wrap_width));
|
|
||||||
let mut lines = vec![heading.into(), Line::default()];
|
|
||||||
lines.extend(prefix_lines(wrapped, " ".into(), " ".into()));
|
|
||||||
|
|
||||||
lines
|
lines
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,10 +84,6 @@ pub(crate) async fn start_temporary_thread(
|
|||||||
("features.view_image".to_string(), false.into()),
|
("features.view_image".to_string(), false.into()),
|
||||||
("orchestrator.skills.enabled".to_string(), false.into()),
|
("orchestrator.skills.enabled".to_string(), false.into()),
|
||||||
("skills.include_instructions".to_string(), false.into()),
|
("skills.include_instructions".to_string(), false.into()),
|
||||||
(
|
|
||||||
"token_budget.use_history_notes_extension".to_string(),
|
|
||||||
false.into(),
|
|
||||||
),
|
|
||||||
(
|
(
|
||||||
"tools.experimental_request_user_input.enabled".to_string(),
|
"tools.experimental_request_user_input.enabled".to_string(),
|
||||||
false.into(),
|
false.into(),
|
||||||
|
|||||||
Reference in new issue
Block a user