From e6af1a6208ddae351141a6986eb31f98716ac3b2 Mon Sep 17 00:00:00 2001 From: Mortdecai Date: Tue, 7 Apr 2026 21:48:37 -0400 Subject: [PATCH] fix(composite): recover from sixel encoder panics, clean up debug logging The go-sixel library panics on certain image dimensions during Resize(). Added panic recovery in drawImage() that falls back to alt text display. Cleaned up all debug logging from the investigation. --- app/compositeview.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/compositeview.go b/app/compositeview.go index b9793eb..99a983a 100644 --- a/app/compositeview.go +++ b/app/compositeview.go @@ -252,6 +252,19 @@ func (cc *compositeContent) drawImage(ctx *ui.Context, idx, row, width, height i vx := ctx.Window().Vx graphic, ok := cc.graphics[idx] + // Recover from panics in vaxis image encoding (e.g. sixel encoder bugs) + defer func() { + if r := recover(); r != nil { + log.Errorf("composite: panic rendering image %d: %v", idx, r) + alt := "[image: render error]" + if idx < len(cc.images) && cc.images[idx].Alt != "" { + alt = fmt.Sprintf("[%s]", cc.images[idx].Alt) + } + if row >= 0 && row < ctx.Height() { + ctx.Printf(0, row, style, "%s", alt) + } + } + }() if !ok { var err error graphic, err = vx.NewImage(img)