From b525498770a09327eecaf9c448630068c53501dc Mon Sep 17 00:00:00 2001 From: Mika Kuns Date: Tue, 21 Apr 2026 15:03:29 +0200 Subject: [PATCH] feat(ui): format system init message in StreamLineFormatter --- .../Helpers/StreamLineFormatter.cs | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/ClaudeDo.Ui/Helpers/StreamLineFormatter.cs b/src/ClaudeDo.Ui/Helpers/StreamLineFormatter.cs index 3c2fdb6..aec50f7 100644 --- a/src/ClaudeDo.Ui/Helpers/StreamLineFormatter.cs +++ b/src/ClaudeDo.Ui/Helpers/StreamLineFormatter.cs @@ -43,11 +43,30 @@ public class StreamLineFormatter { if (!root.TryGetProperty("subtype", out var subtypeProp)) return null; - return subtypeProp.GetString() switch + + var subtype = subtypeProp.GetString(); + switch (subtype) { - "api_retry" => "[Retrying API call...]\n", - _ => null, - }; + case "api_retry": + return "[Retrying API call...]\n"; + + case "init": + { + var sessionId = root.TryGetProperty("session_id", out var sid) + ? sid.GetString() : null; + var model = root.TryGetProperty("model", out var m) + ? m.GetString() : null; + + var shortId = sessionId is { Length: >= 8 } + ? sessionId[..8] + : sessionId ?? "?"; + var modelPart = string.IsNullOrEmpty(model) ? "" : $" ยท {model}"; + return $"[session {shortId}{modelPart}]\n"; + } + + default: + return null; + } } private static string? FormatAssistant(JsonElement root) => null;