|
1 | 1 | use super::*; |
| 2 | +use pretty_assertions::assert_eq; |
2 | 3 |
|
3 | 4 | /// ACP agents may stream reasoning before producing their final answer. |
4 | 5 | /// This test verifies reasoning + answer rendering from an ACP agent. |
@@ -895,3 +896,43 @@ fn exec_end_not_deferred_during_streaming() { |
895 | 896 | done_pos.unwrap(), |
896 | 897 | ); |
897 | 898 | } |
| 899 | + |
| 900 | +#[test] |
| 901 | +fn repeated_agent_messages_after_tool_use_share_one_separator() { |
| 902 | + let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(); |
| 903 | + |
| 904 | + chat.handle_codex_event(Event { |
| 905 | + id: "turn-1".into(), |
| 906 | + msg: EventMsg::TaskStarted(TaskStartedEvent { |
| 907 | + model_context_window: None, |
| 908 | + }), |
| 909 | + }); |
| 910 | + drain_insert_history(&mut rx); |
| 911 | + |
| 912 | + let begin_ev = begin_exec(&mut chat, "call-1", "cargo test"); |
| 913 | + end_exec(&mut chat, begin_ev, "ok\n", "", 0); |
| 914 | + |
| 915 | + for message in ["The", "suite is", "now in the ACP backend"] { |
| 916 | + chat.handle_codex_event(Event { |
| 917 | + id: "turn-1".into(), |
| 918 | + msg: EventMsg::AgentMessage(AgentMessageEvent { |
| 919 | + message: message.to_string(), |
| 920 | + }), |
| 921 | + }); |
| 922 | + } |
| 923 | + |
| 924 | + chat.handle_codex_event(Event { |
| 925 | + id: "turn-1".into(), |
| 926 | + msg: EventMsg::TaskComplete(TaskCompleteEvent { |
| 927 | + last_agent_message: None, |
| 928 | + }), |
| 929 | + }); |
| 930 | + |
| 931 | + let rendered = drain_insert_history(&mut rx) |
| 932 | + .into_iter() |
| 933 | + .map(|lines| lines_to_single_string(&lines)) |
| 934 | + .collect::<Vec<_>>() |
| 935 | + .join(""); |
| 936 | + |
| 937 | + assert_eq!(rendered.matches("Worked for").count(), 1, "{rendered}"); |
| 938 | +} |
0 commit comments