Skip to content

Commit 4df2ce9

Browse files
committed
fix: error message dont hide on unpause, incorrect formatting asisstant messages
1 parent 3bb3b10 commit 4df2ce9

File tree

3 files changed

+32
-19
lines changed

3 files changed

+32
-19
lines changed

src/tui/app.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,10 +411,12 @@ impl App<'_> {
411411
{
412412
self.agent_sender.send(AgentControlEvent::NewTask).unwrap()
413413
}
414-
KeyCode::Char('p') if key_event.modifiers == KeyModifiers::CONTROL => self
415-
.agent_sender
416-
.send(AgentControlEvent::CancelTask)
417-
.unwrap(),
414+
KeyCode::Char('p') if key_event.modifiers == KeyModifiers::CONTROL => {
415+
self.model.last_error = None;
416+
self.agent_sender
417+
.send(AgentControlEvent::CancelTask)
418+
.unwrap()
419+
}
418420
KeyCode::BackTab => {
419421
let mut focus = self.ui.focus.clone() as u8;
420422
if focus == 0 {

src/tui/mod.rs

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,24 @@ pub(crate) fn split_think_tags(text: &str) -> Vec<(String, bool)> {
1919
if ch == '<' {
2020
is_tag_content = true;
2121
if !tag_name.is_empty()
22-
&& tag_name != "think"
23-
&& tag_name != "thinking"
24-
&& tag_name != "/think"
25-
&& tag_name != "/thinking"
22+
&& tag_name != "<think>"
23+
&& tag_name != "<thinking>"
24+
&& tag_name != "</think>"
25+
&& tag_name != "</thinking>"
2626
{
27-
current_string.push_str(&format!("<{}", tag_name));
27+
current_string.push_str(&tag_name);
2828
}
2929
tag_name.clear();
30+
tag_name.push(ch);
3031
} else if ch == '>' && is_tag_content {
3132
is_tag_content = false;
33+
tag_name.push(ch);
3234
// start think tag
33-
if (tag_name == "think" || tag_name == "thinking") && !current_string.is_empty() {
35+
if (tag_name == "<think>" || tag_name == "<thinking>") && !current_string.is_empty() {
3436
result.push((current_string.clone(), false));
3537
current_string.clear();
3638
}
37-
if tag_name == "/think" || tag_name == "/thinking" && !current_string.is_empty() {
39+
if tag_name == "</think>" || tag_name == "</thinking>" && !current_string.is_empty() {
3840
result.push((current_string.clone(), true));
3941
current_string.clear();
4042
}
@@ -44,19 +46,19 @@ pub(crate) fn split_think_tags(text: &str) -> Vec<(String, bool)> {
4446
current_string.push(ch);
4547
}
4648
}
47-
if tag_name != "think"
48-
&& tag_name != "thinking"
49-
&& tag_name != "/think"
50-
&& tag_name != "/thinking"
49+
if tag_name != "<think>"
50+
&& tag_name != "<thinking>"
51+
&& tag_name != "</think>"
52+
&& tag_name != "</thinking>"
5153
{
52-
current_string.push_str(&format!("<{}", tag_name));
54+
current_string.push_str(&tag_name);
5355
tag_name.clear();
5456
}
5557

5658
if !current_string.is_empty() {
5759
result.push((
5860
current_string.clone(),
59-
tag_name == "think" || tag_name == "thinking",
61+
tag_name == "<think>" || tag_name == "<thinking>",
6062
));
6163
}
6264
result
@@ -83,4 +85,11 @@ mod tests {
8385
]
8486
);
8587
}
88+
89+
#[test]
90+
fn test_split_think_no_tags() {
91+
let text = "test message.";
92+
let pairs = split_think_tags(text);
93+
assert_eq!(pairs, vec![("test message.".to_string(), false),]);
94+
}
8695
}

src/tui/widgets/message.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,11 @@ impl<'a> MessageWidget<'a> {
176176
.enumerate()
177177
.map(|(i, s)| {
178178
if i == 0 {
179-
s.clone().content(s.content.trim().to_string())
179+
s.clone()
180+
.style(self.theme.text_style())
181+
.content(s.content.trim().to_string())
180182
} else {
181-
s
183+
s.style(self.theme.text_style())
182184
}
183185
})
184186
.collect::<Vec<_>>();

0 commit comments

Comments
 (0)