Skip to content

cmdio: route lipgloss styling through a version-agnostic renderer - #7737

Draft
pietern wants to merge 1 commit into
pietern/charm-v2/01-termtest-emulatorfrom
pietern/charm-v2/02a-renderer
Draft

pietern wants to merge 1 commit into
pietern/charm-v2/01-termtest-emulatorfrom
pietern/charm-v2/02a-renderer

Conversation

@pietern

@pietern pietern commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Changes

Adds the renderer seam the charm.land v2 swap needs, with no output change on v1:

  • libs/cmdio/lipgloss.go: Renderer (NewStyle, Profile, Writer, Render), Color, LightDark, Hyperlink. NewRenderer keeps cmdio: make NO_COLOR only affect color #7700's rules: termenv's profile, Ascii when color is off, and the MSYS2 pty raise to ANSI unless CLICOLOR=0.
  • cmd/air writes through Renderer.Writer.
  • cmd/selftest/tui profile and huh probes read the profile and dark background through cmdio.
  • Ruleguard: libs/gorules/rule_lipgloss.go bans lipgloss.AdaptiveColor and termenv.Hyperlink in new code.
  • libs/apps/prompt: Theme alias for the huh theme; the appkit theme builder is appkitStyles. cmd/apps uses prompt.Theme.

Why

v2 removes AdaptiveColor, termenv.Hyperlink and the *Renderer methods the callers used, so every caller needs a version-agnostic seam first. Landing it on v1 first keeps the swap a mechanical change. LogString is not in this PR, so stderr output is unchanged; that is the next PR.

Tests

  • go build ./...; go vet on touched packages; golangci-lint (0 issues); gofmt clean.
  • TERM=xterm-256color go test -race -count=3 ./libs/cmdio/... passes.
  • go test for libs/tableview, libs/apps/..., cmd/air, cmd/apps, cmd/fs, cmd/aitools, cmd/selftest/..., internal/build passes.
  • Full acceptance suite (go test ./acceptance/...) passes.
  • The pins pass without -update. No golden changes.

Stack: based on pietern/charm-v2/01-termtest-emulator. The branch after this one is pietern/charm-v2/02b-logstring-strip, which changes stderr output.

Manual checks for real terminals: none for this PR (no behaviour change).

This pull request and its description were written by Isaac.

@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Integration test report

Commit: 47eb25f

Run: 44744241262

Env 💚​RECOVERED ✅​pass 🙈​skip Time
💚​ aws linux-2core-8gb 1 272 19 5:11
💚​ aws-windows-latest-4core-16gb 1 274 17 4:41
💚​ azure linux-2core-8gb 1 271 19 4:11
💚​ azure-windows-latest-4core-16gb 1 273 17 3:49
💚​ gcp linux-2core-8gb 1 272 19 5:22
💚​ gcp-windows-latest-4core-16gb 1 274 17 4:20
Test Name aws linux-2core-8gb aws-windows-latest-4core-16gb azure linux-2core-8gb azure-windows-latest-4core-16gb gcp linux-2core-8gb gcp-windows-latest-4core-16gb
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
Top 3 slowest tests (at least 2 minutes):
duration env testname
4:40 aws-windows-latest-4core-16gb TestAccept
4:18 gcp-windows-latest-4core-16gb TestAccept
3:27 azure-windows-latest-4core-16gb TestAccept

@pietern
pietern added this pull request to stack #7754 November 18, 2026 08:35
@pietern

pietern commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

/review

Comment thread cmd/selftest/tui/huh.go Outdated
cmdio.LogString(ctx, fmt.Sprintf("dark_background=%t", r.HasDarkBackground()))
cmdio.LogString(ctx, fmt.Sprintf("dark_background=%t", cmdio.HasDarkBackground()))

// The blurred button colour is an AdaptiveColor, which hides the choice

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment says the blurred button colour is an AdaptiveColor, but this PR changes AppkitTheme to resolve the variant eagerly with cmdio.LightDark, so GetForeground() now returns a plain lipgloss.Color. The if adaptive, ok branch on line 83 is dead for the appkit theme and the comment describes something that no longer happens. Can you update the comment and either drop the AdaptiveColor branch or note that it's kept only for non-appkit themes?

@pietern
pietern force-pushed the pietern/charm-v2/02a-renderer branch from 61fd417 to f9e24c5 Compare November 18, 2026 13:07
@github-actions github-actions Bot added Dependencies Pull requests that update a dependency file AIR Databricks AI Runtime CLI labels Nov 18, 2026
@pietern
pietern force-pushed the pietern/charm-v2/02a-renderer branch from f9e24c5 to c8050e5 Compare November 18, 2026 15:55
@pietern
pietern force-pushed the pietern/charm-v2/02a-renderer branch from c8050e5 to d7b1888 Compare November 18, 2026 16:07
@pietern

pietern commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

/review

Adds the seam the charm.land v2 swap needs without changing output on
v1. cmdio.Renderer carries the color profile for one writer: NewStyle,
Profile, Writer, Render. Color, LightDark and Hyperlink stand in for the
lipgloss helpers whose shape changes in v2. NewRenderer keeps #7700's
rules: termenv's profile, Ascii when color is off, and the MSYS2 pty
raise to ANSI unless CLICOLOR=0.

Callers move to it: cmd/air writes through Renderer.Writer, and the
selftest profile and huh probes read the profile and dark background
through cmdio. Ruleguard bans lipgloss.AdaptiveColor and
termenv.Hyperlink in new code so the v2 swap does not reintroduce them.

No output changes: LogString still writes to stderr unstripped, and no
pin golden moves.

Co-authored-by: Isaac <no-reply@databricks.com>
@pietern
pietern force-pushed the pietern/charm-v2/02a-renderer branch from d7b1888 to 47eb25f Compare November 20, 2026 13:23

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AIR Databricks AI Runtime CLI Dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants