Skip to content

Commit 6003754

Browse files
committed
fix(tui): route startup background preludes through background tagging
1 parent 4a791d5 commit 6003754

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

code-rs/tui/src/chatwidget.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10865,7 +10865,17 @@ impl ChatWidget<'_> {
1086510865
/// Push a cell using a synthetic key at the TOP of the NEXT request.
1086610866
fn history_push_top_next_req(&mut self, cell: impl HistoryCell + 'static) {
1086710867
let key = self.next_req_key_top();
10868-
let _ = self.history_insert_with_key_global_tagged(Box::new(cell), key, "prelude", None);
10868+
let cell = Box::new(cell);
10869+
if matches!(cell.kind(), HistoryCellType::BackgroundEvent) {
10870+
let record = cell
10871+
.as_any()
10872+
.downcast_ref::<crate::history_cell::BackgroundEventCell>()
10873+
.map(|background| HistoryDomainRecord::BackgroundEvent(background.state().clone()));
10874+
let _ = self.history_insert_with_key_global_tagged(cell, key, "background", record);
10875+
return;
10876+
}
10877+
10878+
let _ = self.history_insert_with_key_global_tagged(cell, key, "prelude", None);
1086910879
}
1087010880
fn history_replace_with_record(
1087110881
&mut self,
@@ -35248,6 +35258,18 @@ use code_core::protocol::OrderMeta;
3524835258
);
3524935259
}
3525035260

35261+
#[test]
35262+
fn startup_background_prelude_uses_background_tagging() {
35263+
let mut harness = ChatWidgetHarness::new();
35264+
let chat = harness.chat();
35265+
reset_history(chat);
35266+
35267+
chat.history_push_top_next_req(history_cell::new_connecting_mcp_status());
35268+
35269+
assert_eq!(chat.history_cells.len(), 1);
35270+
assert_eq!(chat.history_cells[0].kind(), HistoryCellType::BackgroundEvent);
35271+
}
35272+
3525135273
#[test]
3525235274
fn ordering_tool_reasoning_explore_should_preserve_arrival_sequence() {
3525335275
let mut harness = ChatWidgetHarness::new();

0 commit comments

Comments
 (0)