Merge branch 'code-branch-20251005-232038' into main

This commit is contained in:
James Peter
2025-10-06 09:58:40 +10:00
4 changed files with 100 additions and 90 deletions
+90 -21
View File
@@ -89,8 +89,7 @@ use self::auto_coordinator::{
use self::limits_overlay::{LimitsOverlay, LimitsOverlayContent, LimitsTab};
use self::rate_limit_refresh::start_rate_limit_refresh;
use self::history_render::{
explore_should_hold_title, CachedLayout, HistoryRenderState, RenderRequest, RenderRequestKind,
RenderSettings, VisibleCell,
CachedLayout, HistoryRenderState, RenderRequest, RenderRequestKind, RenderSettings, VisibleCell,
};
use code_core::parse_command::ParsedCommand;
use code_core::protocol::AgentMessageDeltaEvent;
@@ -2665,23 +2664,12 @@ impl ChatWidget<'_> {
}
}
for cell in &mut self.history_cells {
if let Some(explore_cell) = cell
.as_any_mut()
.downcast_mut::<history_cell::ExploreAggregationCell>()
{
let should_force =
explore_should_hold_title(&self.history_state, explore_cell.record().id);
if explore_cell.set_force_exploring_header(should_force) {
needs_invalidate = true;
}
}
}
if needs_invalidate {
self.invalidate_height_cache();
self.request_redraw();
}
self.refresh_explore_trailing_flags();
}
/// Handle streaming delta for both answer and reasoning
@@ -5975,10 +5963,7 @@ impl ChatWidget<'_> {
Some(Box::new(history_cell::PatchSummaryCell::from_record(state.clone())))
}
HistoryRecord::Explore(state) => {
let mut cell = history_cell::ExploreAggregationCell::from_record(state.clone());
let hold_title = explore_should_hold_title(&self.history_state, state.id);
cell.set_force_exploring_header(hold_title);
Some(Box::new(cell))
Some(Box::new(history_cell::ExploreAggregationCell::from_record(state.clone())))
}
HistoryRecord::RateLimits(state) => Some(Box::new(
history_cell::RateLimitsCell::from_record(state.clone()),
@@ -6591,7 +6576,83 @@ impl ChatWidget<'_> {
}
}
fn refresh_explore_trailing_flags(&mut self) {}
fn refresh_explore_trailing_flags(&mut self) -> bool {
let mut updated = false;
for idx in 0..self.history_cells.len() {
let is_explore = self.history_cells[idx]
.as_any()
.downcast_ref::<history_cell::ExploreAggregationCell>()
.is_some();
if !is_explore {
continue;
}
let hold_title = self.rendered_explore_should_hold(idx);
if let Some(explore_cell) = self.history_cells[idx]
.as_any_mut()
.downcast_mut::<history_cell::ExploreAggregationCell>()
{
if explore_cell.set_force_exploring_header(hold_title) {
updated = true;
if let Some(Some(id)) = self.history_cell_ids.get(idx) {
self.history_render.invalidate_history_id(*id);
}
}
}
}
if updated {
self.invalidate_height_cache();
self.request_redraw();
}
updated
}
fn rendered_explore_should_hold(&self, idx: usize) -> bool {
if idx >= self.history_cells.len() {
return true;
}
let mut next = idx + 1;
while next < self.history_cells.len() {
let cell = &self.history_cells[next];
if cell.should_remove() {
next += 1;
continue;
}
match cell.kind() {
history_cell::HistoryCellType::Reasoning
| history_cell::HistoryCellType::Loading
| history_cell::HistoryCellType::PlanUpdate => {
next += 1;
continue;
}
_ => {}
}
if cell
.as_any()
.downcast_ref::<history_cell::WaitStatusCell>()
.is_some()
{
next += 1;
continue;
}
if cell.display_lines_trimmed().is_empty() {
next += 1;
continue;
}
return false;
}
true
}
fn submit_user_message(&mut self, user_message: UserMessage) {
if self.layout.scroll_offset > 0 {
@@ -23100,7 +23161,15 @@ impl WidgetRef for &ChatWidget<'_> {
kind = RenderRequestKind::MergedExec { id: history_id };
}
HistoryRecord::Explore(_) => {
kind = RenderRequestKind::Explore { id: history_id };
let hold_header = if idx < self.history_cells.len() {
self.rendered_explore_should_hold(idx)
} else {
true
};
kind = RenderRequestKind::Explore {
id: history_id,
hold_header,
};
}
HistoryRecord::Diff(_) => {
kind = RenderRequestKind::Diff { id: history_id };
+3 -27
View File
@@ -473,10 +473,9 @@ impl<'a> RenderRequest<'a> {
}
}
if let RenderRequestKind::Explore { id } = self.kind {
if let RenderRequestKind::Explore { id, hold_header } = self.kind {
if let Some(HistoryRecord::Explore(record)) = history_state.record(id) {
let hold_title = explore_should_hold_title(history_state, id);
return explore_lines_from_record_with_force(record, hold_title);
return explore_lines_from_record_with_force(record, hold_header);
}
}
@@ -517,35 +516,12 @@ pub(crate) enum RenderRequestKind {
Legacy,
Exec { id: HistoryId },
MergedExec { id: HistoryId },
Explore { id: HistoryId },
Explore { id: HistoryId, hold_header: bool },
Diff { id: HistoryId },
Streaming { id: HistoryId },
Assistant { id: HistoryId },
}
pub(crate) fn explore_should_hold_title(history_state: &HistoryState, explore_id: HistoryId) -> bool {
if explore_id == HistoryId::ZERO {
return true;
}
let Some(mut idx) = history_state.index_of(explore_id) else {
return true;
};
idx += 1;
while let Some(record) = history_state.get(idx) {
match record {
HistoryRecord::Reasoning(_) => {
idx += 1;
continue;
}
_ => return false,
}
}
true
}
/// Output from `HistoryRenderState::visible_cells()`. Contains the resolved
/// layout (if any), plus the optional `HistoryCell` pointer so the caller can
/// reuse existing caches.
+6 -24
View File
@@ -487,14 +487,13 @@ impl ExecCell {
return None;
}
if let Some(run_duration) = state.run_duration {
if run_duration.is_zero() {
return None;
if run_duration >= Duration::from_secs(10) {
let text = format!("Ran for {}", format_duration(run_duration));
return Some(Line::styled(
text,
Style::default().fg(crate::colors::text_dim()),
));
}
let text = format!("Ran for {}", format_duration(run_duration));
return Some(Line::styled(
text,
Style::default().fg(crate::colors::text_dim()),
));
}
let total = state.total_wait?;
if total.is_zero() {
@@ -625,23 +624,6 @@ impl ExecCell {
out.splice(insert_at..insert_at, block);
}
if let Some(output) = self.output.as_ref() {
if output.exit_code == 0 {
if out
.last()
.map(|line| line.spans.iter().all(|span| span.content.as_ref().trim().is_empty()))
.unwrap_or(false)
{
out.pop();
}
out.push(Line::styled(
format!("Success (exit code {})", output.exit_code),
Style::default()
.fg(crate::colors::success())
.add_modifier(Modifier::BOLD),
));
}
}
}
(pre, out, if self.output.is_none() { status } else { None })
+1 -18
View File
@@ -4068,23 +4068,6 @@ fn new_exec_command_generic(
lines.extend(highlighted_cmd);
let mut preview_lines = output_lines(display_output, false, true);
if let Some(output) = output {
if output.exit_code == 0 {
if preview_lines
.last()
.map(|line| line.spans.iter().all(|span| span.content.as_ref().trim().is_empty()))
.unwrap_or(false)
{
preview_lines.pop();
}
preview_lines.push(Line::styled(
format!("Success (exit code {})", output.exit_code),
Style::default()
.fg(crate::colors::success())
.add_modifier(Modifier::BOLD),
));
}
}
if let Some(status_line) = running_status {
if let Some(last) = preview_lines.last() {
let is_blank = last
@@ -5700,7 +5683,7 @@ impl PatchSummaryCell {
let title = match record.patch_type {
HistoryPatchEventType::ApprovalRequest => "proposed patch".to_string(),
HistoryPatchEventType::ApplyBegin { .. } => "Updated".to_string(),
HistoryPatchEventType::ApplySuccess => "Patch applied".to_string(),
HistoryPatchEventType::ApplySuccess => "Updated".to_string(),
HistoryPatchEventType::ApplyFailure => "Patch failed".to_string(),
};
Self {