From e0e2cb0724826ccf83d035ac0451984d1ab07aa1 Mon Sep 17 00:00:00 2001 From: mingmxren Date: Thu, 5 Mar 2026 22:10:46 +0800 Subject: [PATCH] fix(commands): truncate session label by rune count, not byte count Prevents splitting multi-byte UTF-8 characters (CJK, emoji) when truncating session preview text in /session list output. Co-Authored-By: Claude Opus 4.6 --- pkg/commands/cmd_session.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/commands/cmd_session.go b/pkg/commands/cmd_session.go index ece190a57..21e7e13f0 100644 --- a/pkg/commands/cmd_session.go +++ b/pkg/commands/cmd_session.go @@ -109,10 +109,11 @@ func sessionLabel(summary, preview string, maxLen int) string { return "(empty)" } text = strings.ReplaceAll(text, "\n", " ") - if len(text) <= maxLen { + runes := []rune(text) + if len(runes) <= maxLen { return text } - return text[:maxLen] + "..." + return string(runes[:maxLen]) + "..." } // extractSessionTag returns the "#N" suffix from a session key, or "#1" for