prime8dev

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

commit b51dbdcd9567bf531475fed00be9647e35e00658
parent 86e8c56194c317b68458dfbcc2258a98684a6b56
Author: Damian Myrda <damian@prime8.dev>
Date:   Wed, 21 Oct 2026 08:01:53 +0000

feat(curl): truecolor logo in the curl fetch block

curl prime8.dev now gets the colored ascii photo like the TUI. Logo lines
are padded by visible width (escape codes excluded) and reset before the
info column, so the columns still line up. Color depends on COLORTERM in
the server env, which the Docker image already sets.

Diffstat:
Mcmd/server/handlers/curl.go | 7++++---
Acmd/server/handlers/curl_test.go | 36++++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/cmd/server/handlers/curl.go b/cmd/server/handlers/curl.go @@ -7,10 +7,10 @@ import ( "strings" "sync" "time" - "unicode/utf8" "git.prime8.dev/moncheeta/prime8dev/internal/config" "git.prime8.dev/moncheeta/prime8dev/internal/utils" + "github.com/charmbracelet/x/ansi" ) const ( @@ -22,7 +22,7 @@ const ( ansiBlue = "\x1b[38;5;110m" ) -var curlLogo = sync.OnceValue(func() string { return utils.LogoASCII(curlLogoWidth, false) }) +var curlLogo = sync.OnceValue(func() string { return utils.LogoASCII(curlLogoWidth, true) }) // isTerminalClient reports whether the request comes from a CLI http client. func isTerminalClient(r *http.Request) bool { @@ -84,7 +84,8 @@ func terminalFetch(about config.About, job *config.Experience) string { if i < len(logo) { l = logo[i] } - b.WriteString(l + strings.Repeat(" ", max(0, curlLogoWidth-utf8.RuneCountInString(l))) + " ") + // pad by visible width: the logo lines carry truecolor escapes + b.WriteString(l + ansiReset + strings.Repeat(" ", max(0, curlLogoWidth-ansi.StringWidth(l))) + " ") if i < len(lines) { b.WriteString(lines[i]) } diff --git a/cmd/server/handlers/curl_test.go b/cmd/server/handlers/curl_test.go @@ -0,0 +1,36 @@ +package handlers + +import ( + "os" + "strings" + "testing" + + "git.prime8.dev/moncheeta/prime8dev/internal/config" + "github.com/charmbracelet/x/ansi" +) + +func TestTerminalFetchColoredLogoAligned(t *testing.T) { + if err := os.Chdir("../../.."); err != nil { + t.Fatal(err) + } + out := terminalFetch(config.GetAbout(), config.CurrentJob(config.GetExperience())) + // aic picks its color level from COLORTERM at init (the Docker image sets + // COLORTERM=truecolor); without it the logo is plain but must still align. + if strings.Contains(os.Getenv("COLORTERM"), "truecolor") && !strings.Contains(out, "\x1b[38;2;") { + t.Fatal("logo is not truecolor") + } + lines := strings.Split(strings.Trim(out, "\n"), "\n") + for i, l := range lines { + plain := ansi.Strip(l) + if ansi.StringWidth(plain) <= curlLogoWidth { + continue + } + // the info column starts right after the padded logo and 3 spaces + if got := []rune(plain)[curlLogoWidth : curlLogoWidth+3]; string(got) != " " { + t.Errorf("line %d misaligned: %q", i, plain) + } + } + if !strings.Contains(ansi.Strip(lines[0]), "moncheeta@prime8") { + t.Errorf("first line missing title: %q", ansi.Strip(lines[0])) + } +}