fix: Briefing-Summary bereinigt HTML/Thinking-Blocks [appimage]
All checks were successful
Build AppImage / build (push) Successful in 6m42s

Session-Nachrichten im Briefing werden jetzt von HTML-Tags gestrippt
(Thinking-Blocks, div, span). Mehrfache Leerzeichen/Umbrueche werden
zusammengefasst. Ergebnis ist sauberer Plaintext.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Eddy 2026-05-02 23:30:55 +02:00
parent a6bdcd5c1d
commit 93a97b44b0

View file

@ -602,6 +602,48 @@ pub struct Briefing {
pub sections: Vec<String>,
}
/// Bereinigt Message-Content fuer das Briefing:
/// - Entfernt HTML-Tags (Thinking-Blocks, div, span etc.)
/// - Entfernt mehrfache Leerzeichen/Zeilenumbrueche
fn strip_html_for_briefing(content: &str) -> String {
let mut result = String::with_capacity(content.len());
let mut in_tag = false;
let mut last_was_space = false;
for ch in content.chars() {
match ch {
'<' => in_tag = true,
'>' => {
in_tag = false;
// Nach einem Tag ein Leerzeichen einfuegen (statt nichts)
if !last_was_space {
result.push(' ');
last_was_space = true;
}
}
_ if in_tag => {} // Innerhalb eines Tags: ignorieren
'\n' | '\r' => {
if !last_was_space {
result.push(' ');
last_was_space = true;
}
}
' ' | '\t' => {
if !last_was_space {
result.push(' ');
last_was_space = true;
}
}
_ => {
result.push(ch);
last_was_space = false;
}
}
}
result.trim().to_string()
}
/// Generiert ein Projekt-Briefing aus allen verfügbaren Quellen:
/// - Sticky Context (Schicht 1)
/// - Projekt-Kontext / Archiv (Schicht 2)
@ -687,16 +729,18 @@ pub async fn generate_briefing(
"system" => "⚙️",
_ => "?",
};
// Content kürzen auf 300 Zeichen
let content = if msg.content.len() > 300 {
let end = msg.content.char_indices()
// Content bereinigen: HTML-Tags und Thinking-Blocks strippen
let cleaned = strip_html_for_briefing(&msg.content);
// Auf 300 Zeichen kuerzen
let content = if cleaned.len() > 300 {
let end = cleaned.char_indices()
.take_while(|(i, _)| *i < 300)
.last()
.map(|(i, c)| i + c.len_utf8())
.unwrap_or(300.min(msg.content.len()));
format!("{}", &msg.content[..end])
.unwrap_or(300.min(cleaned.len()));
format!("{}...", &cleaned[..end])
} else {
msg.content.clone()
cleaned
};
summary_parts.push(format!("{} {}", role_label, content));
}