From d9e7420b31be172e767843da6905e5b2e7cd83b2 Mon Sep 17 00:00:00 2001 From: Castor Gemini Date: Fri, 22 Aug 2025 05:47:02 -0500 Subject: [PATCH] fix(playback): Improve formatting of code snippets - Refactor the 'printCodeSnippet' function to draw a complete, correctly padded box around the code. - Each line is now padded with spaces to ensure the right border aligns perfectly at the terminal width. --- prettyFormat.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/prettyFormat.go b/prettyFormat.go index e0405b3..513fe10 100644 --- a/prettyFormat.go +++ b/prettyFormat.go @@ -143,11 +143,23 @@ func printCodeSnippet(snippet *chatpb.CodeSnippet) { language := filepath.Base(snippet.GetFilename()) // Still useful for display fmt.Println() // Add extra line feed for spacing - fmt.Printf("┌─[ Code Snippet: %s ]──────────────────────────────────\n", language) + + // --- Top Border --- + topBorder := fmt.Sprintf("┌─[ Code Snippet: %s ]", language) + fmt.Printf("%s%s┐\n", topBorder, strings.Repeat("─", termWidth-len(topBorder)-1)) + + // --- Content Lines --- for _, line := range strings.Split(strings.TrimSpace(code), "\n") { - fmt.Printf("│ %s\n", line) + // Calculate padding: total width - borders/padding - text length + padding := termWidth - 4 - len(line) + if padding < 0 { + padding = 0 // Should not happen with wrapping, but as a safeguard + } + fmt.Printf("│ %s%s │\n", line, strings.Repeat(" ", padding)) } - fmt.Printf("└─────────────────────────────────────────────────────────\n\n") + + // --- Bottom Border --- + fmt.Printf("└%s┘\n\n", strings.Repeat("─", termWidth-2)) } func printToolCallBox(tc *chatpb.ToolCall) {