prime8dev

prime8dev
git clone https://git.prime8.dev/prime8dev.git
Log | Files | Refs | README | LICENSE

commit 0fcd3f97317770aeedfc3522cc4de15c68ef6017
parent 96ac7b867595e86bdeea354d404a7819c19986d3
Author: Damian Myrda <damian@prime8.dev>
Date:   Tue,  7 Apr 2026 23:23:39 -0500

fix(tui): stable colored about ascii rendering over ssh

Retry the render when the cache is empty, serialize the ascii
conversion across ssh sessions and set the terminal color env
so the colored output survives.

Diffstat:
MDockerfile | 2++
Menv.example | 2++
Minternal/tui/about_ascii.go | 6++++++
Minternal/tui/about_render.go | 10++++++++--
4 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/Dockerfile b/Dockerfile @@ -18,6 +18,8 @@ COPY --from=build /app/static ./static COPY --from=build /app/content ./content ENV SSH_PORT=22 +ENV TERM=xterm-256color +ENV COLORTERM=truecolor EXPOSE 22 ENV WEB_PORT=3000 diff --git a/env.example b/env.example @@ -1,5 +1,7 @@ APP_ENV=dev SSH_PORT=22 WEB_PORT=3000 +TERM=xterm-256color +COLORTERM=truecolor GITLAB_HOST=https://git.prime8.dev WAKATIME_API_KEY=your_wakatime_api_key_here diff --git a/internal/tui/about_ascii.go b/internal/tui/about_ascii.go @@ -3,10 +3,13 @@ package tui import ( "path/filepath" "strings" + "sync" aic "github.com/TheZoraiz/ascii-image-converter/aic_package" ) +var aboutASCIIConvertMu sync.Mutex + func (m portfolioModel) aboutASCIIFor(width int) string { width = normalizeAboutASCIIWidth(width) @@ -35,6 +38,9 @@ func loadAboutASCII(width int) string { flags.Dither = true flags.Threshold = 160 + aboutASCIIConvertMu.Lock() + defer aboutASCIIConvertMu.Unlock() + ascii, err := aic.Convert(filepath.Join("static", "me.jpg"), flags) if err != nil { return "" diff --git a/internal/tui/about_render.go b/internal/tui/about_render.go @@ -36,8 +36,10 @@ func (m *portfolioModel) maybeRenderAboutASCIICmd() tea.Cmd { return nil } - if _, cached := m.aboutASCIICache[width]; cached { - return nil + if ascii, cached := m.aboutASCIICache[width]; cached { + if strings.TrimSpace(ascii) != "" { + return nil + } } if m.aboutASCIILoads[width] { return nil @@ -70,6 +72,10 @@ func renderAboutASCIICmd(width int) tea.Cmd { func (m *portfolioModel) applyAboutASCIIRendered(msg aboutASCIIRenderedMsg) { delete(m.aboutASCIILoads, msg.width) + if strings.TrimSpace(msg.ascii) == "" { + delete(m.aboutASCIICache, msg.width) + return + } m.aboutASCIICache[msg.width] = msg.ascii }