🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@pablogsal
Copy link
Member

@pablogsal pablogsal commented Dec 6, 2025

The Tachyon profiler's curses-based TUI now uses the centralized theming
infrastructure in _colorize.py, enabling users to customize colors via
the standard Python theming API. This adds a LiveProfiler theme section
with two pre-configured themes: the default dark theme optimized for
dark terminal backgrounds, and LiveProfilerLight for white/light
backgrounds. Users can switch themes by calling _colorize.set_theme() in
their PYTHONSTARTUP or sitecustomize.py.

The table header rendering was also improved to draw a continuous
background, eliminating visual gaps between columns when using reverse
video styling.

…ystem

The Tachyon profiler's curses-based TUI now uses the centralized theming
infrastructure in _colorize.py, enabling users to customize colors via
the standard Python theming API. This adds a LiveProfiler theme section
with two pre-configured themes: the default dark theme optimized for
dark terminal backgrounds, and LiveProfilerLight for white/light
backgrounds. Users can switch themes by calling _colorize.set_theme() in
their PYTHONSTARTUP or sitecustomize.py.

The table header rendering was also improved to draw a continuous
background, eliminating visual gaps between columns when using reverse
video styling.
@picnixz
Copy link
Member

picnixz commented Dec 7, 2025

Users can switch themes by calling _colorize.set_theme() in their PYTHONSTARTUP or sitecustomize.py.

I thought that this wasn't yet ready for public interface? should we really advertise this feature in the NEWS (cc @hugovk)

NoColors = ANSIColors()


class CursesColors:
Copy link
Member

Choose a reason for hiding this comment

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

I would rather have this one after the for-loop as it's not tied to ANSI colors.

@pablogsal
Copy link
Member Author

Users can switch themes by calling _colorize.set_theme() in their PYTHONSTARTUP or sitecustomize.py.

I thought that this wasn't yet ready for public interface? should we really advertise this feature in the NEWS (cc @hugovk)

Is not but eventually that will be the mechanism. I can change the news entry if you want

@picnixz
Copy link
Member

picnixz commented Dec 7, 2025

Originally, I preferred not advertising this interface officially for now otherwise users could assume that they can freely use it as they want (and we don't know how we eventually want to document and expose it) but I saw that we had other NEWS entries that mentioned _colorize so... maybe just say that changing this should be at their own risk?

@hugovk
Copy link
Member

hugovk commented Dec 9, 2025

Yep, hopefully we'll have something public for 3.15. In the meantime we could say experimental.



@dataclass(frozen=True, kw_only=True)
class LiveProfiler(ThemeSection):
Copy link
Member

Choose a reason for hiding this comment

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

Please slot this and LiveProfilerLight in alphabetically between the other classes.

Comment on lines +535 to +536
theme = _colorize.get_theme(force_color=True)
profiler_theme = theme.live_profiler
Copy link
Member

Choose a reason for hiding this comment

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

Maybe combine and just use theme below instead of profiler_theme?

Suggested change
theme = _colorize.get_theme(force_color=True)
profiler_theme = theme.live_profiler
theme = _colorize.get_theme(force_color=True).live_profiler

self.display.init_color_pair(2, profiler_theme.file_fg, default_bg)
self.display.init_color_pair(3, profiler_theme.func_fg, default_bg)

header_bg = 2 if profiler_theme.background_style == "dark" else 4
Copy link
Member

Choose a reason for hiding this comment

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

Use colour constants instead of hardcoded 2 and 4?

Comment on lines +539 to +541
self.display.init_color_pair(1, profiler_theme.samples_fg, default_bg)
self.display.init_color_pair(2, profiler_theme.file_fg, default_bg)
self.display.init_color_pair(3, profiler_theme.func_fg, default_bg)
Copy link
Member

@hugovk hugovk Dec 9, 2025

Choose a reason for hiding this comment

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

We use constants for 4+ below, should we use constants for 1-3?

pablogsal and others added 5 commits December 9, 2025 14:55
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants