remove conversation history widget (#1727)

this widget is no longer used.
This commit is contained in:
Jeremy Rose
2025-07-30 10:05:40 -07:00
committed by GitHub
parent 3823b32b7a
commit 347c81ad00
13 changed files with 164 additions and 994 deletions

View File

@@ -1,5 +1,6 @@
use std::path::PathBuf;
use std::sync::Arc;
use std::time::Duration;
use codex_core::codex_wrapper::CodexConversation;
use codex_core::codex_wrapper::init_codex;
@@ -36,8 +37,9 @@ use crate::bottom_pane::BottomPane;
use crate::bottom_pane::BottomPaneParams;
use crate::bottom_pane::CancellationEvent;
use crate::bottom_pane::InputResult;
use crate::conversation_history_widget::ConversationHistoryWidget;
use crate::exec_command::strip_bash_lc_and_escape;
use crate::history_cell::CommandOutput;
use crate::history_cell::HistoryCell;
use crate::history_cell::PatchEventType;
use crate::user_approval_widget::ApprovalRequest;
use codex_file_search::FileMatch;
@@ -45,7 +47,6 @@ use codex_file_search::FileMatch;
pub(crate) struct ChatWidget<'a> {
app_event_tx: AppEventSender,
codex_op_tx: UnboundedSender<Op>,
conversation_history: ConversationHistoryWidget,
bottom_pane: BottomPane<'a>,
config: Config,
initial_user_message: Option<UserMessage>,
@@ -127,7 +128,6 @@ impl ChatWidget<'_> {
Self {
app_event_tx: app_event_tx.clone(),
codex_op_tx,
conversation_history: ConversationHistoryWidget::new(),
bottom_pane: BottomPane::new(BottomPaneParams {
app_event_tx,
has_input_focus: true,
@@ -158,11 +158,9 @@ impl ChatWidget<'_> {
self.bottom_pane.handle_paste(text);
}
/// Emits the last entry's plain lines from conversation_history, if any.
fn emit_last_history_entry(&mut self) {
if let Some(lines) = self.conversation_history.last_entry_plain_lines() {
self.app_event_tx.send(AppEvent::InsertHistory(lines));
}
fn add_to_history(&mut self, cell: HistoryCell) {
self.app_event_tx
.send(AppEvent::InsertHistory(cell.plain_lines()));
}
fn submit_user_message(&mut self, user_message: UserMessage) {
@@ -198,28 +196,18 @@ impl ChatWidget<'_> {
// Only show text portion in conversation history for now.
if !text.is_empty() {
self.conversation_history.add_user_message(text.clone());
self.emit_last_history_entry();
self.add_to_history(HistoryCell::new_user_prompt(text.clone()));
}
self.conversation_history.scroll_to_bottom();
}
pub(crate) fn handle_codex_event(&mut self, event: Event) {
let Event { id, msg } = event;
match msg {
EventMsg::SessionConfigured(event) => {
// Record session information at the top of the conversation.
self.conversation_history
.add_session_info(&self.config, event.clone());
// Immediately surface the session banner / settings summary in
// scrollback so the user can review configuration (model,
// sandbox, approvals, etc.) before interacting.
self.emit_last_history_entry();
// Forward history metadata to the bottom pane so the chat
// composer can navigate through past messages.
self.bottom_pane
.set_history_metadata(event.history_log_id, event.history_entry_count);
// Record session information at the top of the conversation.
self.add_to_history(HistoryCell::new_session_info(&self.config, event, true));
if let Some(user_message) = self.initial_user_message.take() {
// If the user provided an initial message, add it to the
@@ -241,9 +229,7 @@ impl ChatWidget<'_> {
message
};
if !full.is_empty() {
self.conversation_history
.add_agent_message(&self.config, full);
self.emit_last_history_entry();
self.add_to_history(HistoryCell::new_agent_message(&self.config, full));
}
self.request_redraw();
}
@@ -270,9 +256,7 @@ impl ChatWidget<'_> {
text
};
if !full.is_empty() {
self.conversation_history
.add_agent_reasoning(&self.config, full);
self.emit_last_history_entry();
self.add_to_history(HistoryCell::new_agent_reasoning(&self.config, full));
}
self.request_redraw();
}
@@ -293,8 +277,7 @@ impl ChatWidget<'_> {
.set_token_usage(self.token_usage.clone(), self.config.model_context_window);
}
EventMsg::Error(ErrorEvent { message }) => {
self.conversation_history.add_error(message.clone());
self.emit_last_history_entry();
self.add_to_history(HistoryCell::new_error_event(message.clone()));
self.bottom_pane.set_task_running(false);
}
EventMsg::ExecApprovalRequest(ExecApprovalRequestEvent {
@@ -313,9 +296,7 @@ impl ChatWidget<'_> {
.map(|r| format!("\n{r}"))
.unwrap_or_default()
);
self.conversation_history.add_background_event(text);
self.emit_last_history_entry();
self.conversation_history.scroll_to_bottom();
self.add_to_history(HistoryCell::new_background_event(text));
let request = ApprovalRequest::Exec {
id,
@@ -343,11 +324,10 @@ impl ChatWidget<'_> {
// prompt before they have seen *what* is being requested.
// ------------------------------------------------------------------
self.conversation_history
.add_patch_event(PatchEventType::ApprovalRequest, changes);
self.emit_last_history_entry();
self.conversation_history.scroll_to_bottom();
self.add_to_history(HistoryCell::new_patch_event(
PatchEventType::ApprovalRequest,
changes,
));
// Now surface the approval request in the BottomPane as before.
let request = ApprovalRequest::ApplyPatch {
@@ -359,13 +339,11 @@ impl ChatWidget<'_> {
self.request_redraw();
}
EventMsg::ExecCommandBegin(ExecCommandBeginEvent {
call_id,
call_id: _,
command,
cwd: _,
}) => {
self.conversation_history
.add_active_exec_command(call_id, command);
self.emit_last_history_entry();
self.add_to_history(HistoryCell::new_active_exec_command(command));
self.request_redraw();
}
EventMsg::PatchApplyBegin(PatchApplyBeginEvent {
@@ -375,12 +353,10 @@ impl ChatWidget<'_> {
}) => {
// Even when a patch is autoapproved we still display the
// summary so the user can follow along.
self.conversation_history
.add_patch_event(PatchEventType::ApplyBegin { auto_approved }, changes);
self.emit_last_history_entry();
if !auto_approved {
self.conversation_history.scroll_to_bottom();
}
self.add_to_history(HistoryCell::new_patch_event(
PatchEventType::ApplyBegin { auto_approved },
changes,
));
self.request_redraw();
}
EventMsg::ExecCommandEnd(ExecCommandEndEvent {
@@ -389,27 +365,39 @@ impl ChatWidget<'_> {
stdout,
stderr,
}) => {
self.conversation_history
.record_completed_exec_command(call_id, stdout, stderr, exit_code);
self.request_redraw();
self.add_to_history(HistoryCell::new_completed_exec_command(
call_id,
CommandOutput {
exit_code,
stdout,
stderr,
duration: Duration::from_secs(0),
},
));
}
EventMsg::McpToolCallBegin(McpToolCallBeginEvent {
call_id,
server,
tool,
arguments,
call_id: _,
invocation,
}) => {
self.conversation_history
.add_active_mcp_tool_call(call_id, server, tool, arguments);
self.emit_last_history_entry();
self.add_to_history(HistoryCell::new_active_mcp_tool_call(invocation));
self.request_redraw();
}
EventMsg::McpToolCallEnd(mcp_tool_call_end_event) => {
let success = mcp_tool_call_end_event.is_success();
let McpToolCallEndEvent { call_id, result } = mcp_tool_call_end_event;
self.conversation_history
.record_completed_mcp_tool_call(call_id, success, result);
self.request_redraw();
EventMsg::McpToolCallEnd(McpToolCallEndEvent {
call_id: _,
duration,
invocation,
result,
}) => {
self.add_to_history(HistoryCell::new_completed_mcp_tool_call(
80,
invocation,
duration,
result
.as_ref()
.map(|r| r.is_error.unwrap_or(false))
.unwrap_or(false),
result,
));
}
EventMsg::GetHistoryEntryResponse(event) => {
let codex_core::protocol::GetHistoryEntryResponseEvent {
@@ -426,9 +414,7 @@ impl ChatWidget<'_> {
self.app_event_tx.send(AppEvent::ExitRequest);
}
event => {
self.conversation_history
.add_background_event(format!("{event:?}"));
self.emit_last_history_entry();
self.add_to_history(HistoryCell::new_background_event(format!("{event:?}")));
self.request_redraw();
}
}
@@ -445,22 +431,7 @@ impl ChatWidget<'_> {
}
pub(crate) fn add_diff_output(&mut self, diff_output: String) {
self.conversation_history
.add_diff_output(diff_output.clone());
self.emit_last_history_entry();
self.request_redraw();
}
pub(crate) fn handle_scroll_delta(&mut self, scroll_delta: i32) {
// If the user is trying to scroll exactly one line, we let them, but
// otherwise we assume they are trying to scroll in larger increments.
let magnified_scroll_delta = if scroll_delta == 1 {
1
} else {
// Play with this: perhaps it should be non-linear?
scroll_delta * 2
};
self.conversation_history.scroll(magnified_scroll_delta);
self.add_to_history(HistoryCell::new_diff_output(diff_output.clone()));
self.request_redraw();
}