From 9983018158d9b3f98cc5a448a6508d3aa5a9f7b2 Mon Sep 17 00:00:00 2001 From: Chris Collins Date: Wed, 19 Nov 2025 11:06:42 -1000 Subject: [PATCH] Implement text wrapping in incident view MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Long lines in the incident view now wrap to fit within the viewport width instead of extending off the right edge of the screen. Changes: - Modified renderIncidentMarkdown to accept a width parameter - Pass viewport width from renderIncident to glamour renderer - Configure glamour with adjusted width to account for internal padding - Added minimum width safeguard (40 characters) The glamour markdown renderer adds its own internal padding/margins, so we subtract 4 characters from the viewport width to ensure content wraps properly without extending beyond the viewport boundaries. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- pkg/tui/commands.go | 2 +- pkg/tui/views.go | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/tui/commands.go b/pkg/tui/commands.go index b4b0df4..48ebaa4 100644 --- a/pkg/tui/commands.go +++ b/pkg/tui/commands.go @@ -215,7 +215,7 @@ func renderIncident(m *model) tea.Cmd { return errMsg{err} } - content, err := renderIncidentMarkdown(t) + content, err := renderIncidentMarkdown(t, m.incidentViewer.Width) if err != nil { return errMsg{err} } diff --git a/pkg/tui/views.go b/pkg/tui/views.go index 434c9f2..8d77398 100644 --- a/pkg/tui/views.go +++ b/pkg/tui/views.go @@ -494,10 +494,17 @@ Details : {{ end }} ` -func renderIncidentMarkdown(content string) (string, error) { +func renderIncidentMarkdown(content string, width int) (string, error) { + // Glamour adds its own padding/margins, so we need to subtract some space + // to prevent content from extending beyond the viewport + adjustedWidth := width - 4 + if adjustedWidth < 40 { + adjustedWidth = 40 // Minimum reasonable width + } + renderer, err := glamour.NewTermRenderer( glamour.WithAutoStyle(), - glamour.WithWordWrap(0), + glamour.WithWordWrap(adjustedWidth), ) if err != nil { return "", err