This commit is contained in:
Ahmed Ibrahim
2025-08-22 11:02:53 -07:00
parent 50e0db431f
commit 98e72d3dbf
4 changed files with 16 additions and 94 deletions

View File

@@ -56,10 +56,9 @@ impl App {
self.close_transcript_overlay(tui);
if let Some(base_id) = base
&& count > 0
&& let Err(e) = self.fork_and_render_backtrack(tui, base_id, count).await
{
if let Err(e) = self.fork_and_render_backtrack(tui, base_id, count).await {
tracing::error!("Backtrack confirm failed: {e:#}");
}
tracing::error!("Backtrack confirm failed: {e:#}");
}
// Reset backtrack state after confirming.
self.esc_backtrack_primed = false;
@@ -71,16 +70,16 @@ impl App {
}
}
// Forward to overlay if not handled
if !handled {
if let Some(overlay) = &mut self.transcript_overlay {
overlay.handle_event(tui, event)?;
if overlay.is_done {
self.close_transcript_overlay(tui);
if self.transcript_overlay_is_backtrack {
self.esc_backtrack_primed = false;
self.esc_backtrack_base = None;
self.esc_backtrack_count = 0;
}
if !handled
&& let Some(overlay) = &mut self.transcript_overlay
{
overlay.handle_event(tui, event)?;
if overlay.is_done {
self.close_transcript_overlay(tui);
if self.transcript_overlay_is_backtrack {
self.esc_backtrack_primed = false;
self.esc_backtrack_base = None;
self.esc_backtrack_count = 0;
}
}
}

View File

@@ -42,12 +42,7 @@ impl ChatComposerHistory {
}
}
/// Reset transient browsing state so the next navigation starts from the
/// most recent entry again.
pub fn reset_browsing(&mut self) {
self.history_cursor = None;
self.last_history_text = None;
}
// Removed unused reset_browsing; browsing state is reset by call sites as needed.
/// Update metadata when a new session is configured.
pub fn set_metadata(&mut self, log_id: u64, entry_count: usize) {

View File

@@ -859,79 +859,7 @@ impl ChatWidget {
}
}
/// Render a conversation history snapshot (e.g., restored items from a forked
/// conversation) into the UI history. Only user/assistant messages and
/// reasoning blocks are displayed; tool calls and other items are skipped.
pub(crate) fn render_conversation_history(&mut self, items: Vec<serde_json::Value>) {
let sink = AppEventHistorySink(self.app_event_tx.clone());
for item in items.into_iter() {
let item_type = item.get("type").and_then(|v| v.as_str()).unwrap_or("");
match item_type {
"message" => {
let role = item.get("role").and_then(|v| v.as_str()).unwrap_or("");
let mut text_parts: Vec<String> = Vec::new();
if let Some(contents) = item.get("content").and_then(|v| v.as_array()) {
for c in contents {
if let Some(ct) = c.get("type").and_then(|v| v.as_str())
&& (ct == "input_text" || ct == "output_text")
&& c.get("text").and_then(|t| t.as_str()).is_some()
{
if let Some(t) = c.get("text").and_then(|t| t.as_str()) {
text_parts.push(t.to_string());
}
}
}
}
let text = text_parts.join("\n");
if role == "user" {
if !text.is_empty() {
self.add_to_history(history_cell::new_user_prompt(text));
}
} else if role == "assistant" {
let _ = self.stream.apply_final_answer(&text, &sink);
}
}
"reasoning" => {
let mut buf = String::new();
if let Some(parts) = item.get("content").and_then(|v| v.as_array()) {
for p in parts {
if let Some(pt) = p.get("type").and_then(|v| v.as_str())
&& (pt == "reasoning_text" || pt == "text")
&& p.get("text").and_then(|t| t.as_str()).is_some()
{
if !buf.is_empty() {
buf.push('\n');
}
if let Some(t) = p.get("text").and_then(|t| t.as_str()) {
buf.push_str(t);
}
}
}
}
if buf.is_empty() {
if let Some(sum) = item.get("summary").and_then(|v| v.as_array()) {
for s in sum {
if s.get("type").and_then(|v| v.as_str()) == Some("summary_text")
&& s.get("text").and_then(|t| t.as_str()).is_some()
{
if !buf.is_empty() {
buf.push('\n');
}
if let Some(t) = s.get("text").and_then(|t| t.as_str()) {
buf.push_str(t);
}
}
}
}
}
if !buf.is_empty() {
self.add_to_history(history_cell::new_reasoning_block(buf, &self.config));
}
}
_ => {}
}
}
}
// Removed unused render_conversation_history (handled by existing streaming path).
fn request_redraw(&mut self) {
self.frame_requester.schedule_frame();

View File

@@ -81,9 +81,9 @@ impl TranscriptApp {
let mut spans = Vec::with_capacity(line.spans.len());
for (i, s) in line.spans.iter().enumerate() {
let mut style = s.style;
style.add_modifier = style.add_modifier | Modifier::REVERSED;
style.add_modifier |= Modifier::REVERSED;
if idx == start && i == 0 {
style.add_modifier = style.add_modifier | Modifier::BOLD;
style.add_modifier |= Modifier::BOLD;
}
spans.push(ratatui::text::Span {
style,