From 420f4c8c23d56c4d6e11f99688e126d506dec86c Mon Sep 17 00:00:00 2001 From: Jason Date: Sun, 12 Apr 2026 22:37:09 +0800 Subject: [PATCH] fix(sessions): strip OpenClaw message_id suffix and allow 2-line titles OpenClaw gateway injects `[message_id: UUID]` metadata at the end of every message, wasting display space. Strip this suffix from both title and summary fields. Also change session title display from single-line truncate to line-clamp-2, so longer titles (e.g. OpenClaw's timestamp-prefixed messages) can show more meaningful content across two lines. --- .../src/session_manager/providers/openclaw.rs | 16 +++++++++++++--- src/components/sessions/SessionItem.tsx | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src-tauri/src/session_manager/providers/openclaw.rs b/src-tauri/src/session_manager/providers/openclaw.rs index 875a20ee4..25d1c851e 100644 --- a/src-tauri/src/session_manager/providers/openclaw.rs +++ b/src-tauri/src/session_manager/providers/openclaw.rs @@ -18,6 +18,15 @@ use super::utils::{ const PROVIDER_ID: &str = "openclaw"; +/// Strip trailing `\n[message_id: ...]` metadata injected by OpenClaw gateway. +fn strip_message_id_suffix(text: &str) -> &str { + if let Some(pos) = text.rfind("\n[message_id:") { + text[..pos].trim_end() + } else { + text + } +} + pub fn scan_sessions() -> Vec { let agents_dir = get_openclaw_dir().join("agents"); if !agents_dir.exists() { @@ -215,14 +224,15 @@ fn parse_session(path: &Path, display_names: Option<&HashMap>) - if event_type == "message" { if let Some(message) = value.get("message") { let text = message.get("content").map(extract_text).unwrap_or_default(); - if !text.trim().is_empty() { + let cleaned = strip_message_id_suffix(&text); + if !cleaned.trim().is_empty() { if first_user_message.is_none() && message.get("role").and_then(Value::as_str) == Some("user") { - first_user_message = Some(text.trim().to_string()); + first_user_message = Some(cleaned.trim().to_string()); } if summary.is_none() { - summary = Some(text); + summary = Some(cleaned.trim().to_string()); } } } diff --git a/src/components/sessions/SessionItem.tsx b/src/components/sessions/SessionItem.tsx index 1cacc1405..6cad46975 100644 --- a/src/components/sessions/SessionItem.tsx +++ b/src/components/sessions/SessionItem.tsx @@ -85,7 +85,7 @@ export function SessionItem({ {getProviderLabel(session.providerId, t)} - + {searchQuery ? highlightText(title, searchQuery) : title}