Skip to content

feat(output): add one Rich theme of status roles and marks #4748

Done

Description

@dan-petty

Problem or Motivation

The terminal output of devops (Rich 15.0.0) has no rich.theme.Theme:

  • 688 inline markups in 59 files with 23 style combinations, and 162 style= arguments.
  • The success mark has 6 styles, the error mark has 2 styles (red and bold red), and the warning has 3 marks.
  • 4 severity maps do not agree: review/report.py:123, commands/review.py:996, output/formatters/scalars.py:20 and commands/scan.py:85. LOW is cyan or blue, HIGH is red or orange3, and INFO is green, the same as success.
  • The syntax theme is monokai on every terminal (config/defaults.py:380).
  • Status logic reads emoji in strings: tables.py:215, report.py:847, reference_extractor.py:609, and pipeline.py:844 and 2009.
  • The Textual TUI (8.2.8) is dark only, and its status dots (ui/projections.py:38-40) have no word.

Proposed Solution & Architectural Design

  • Add src/devops_cli/design/roles.ini with two sections. [styles] is the Rich theme. [grafana] holds the Grafana color names of the same status roles (ok text, warn semi-dark-orange, error red), which the Grafana color item reads.
  • Roles in [styles], as ANSI names (a hex value becomes grey code 90 on 16-color terminals, and Rich cannot detect a light background): status.ok green, status.warn yellow, status.error bold red, status.info default; sev.critical bold red, sev.high red, sev.medium yellow, sev.low default, sev.info dim; muted dim, heading bold, table.header bold, border dim, accent cyan, link underline cyan, code cyan.
  • get_console() loads Theme.read() of roles.ini and sets highlight=False.
  • Each status prints a mark and a word: "OK" with the check mark, "! Warn", "Fail" with the ballot x, "i Info".
  • One severity map replaces the 4 maps. INFO is no longer green.
  • The syntax theme ansi_dark replaces monokai, with ansi_light as a setting.
  • A status enum replaces the emoji reads in status logic. messages.py moves to role names.
  • textual_theme(mode) in the design module registers devops-light and devops-dark from the token JSON of feat(design): add the design tokens and their build #4738: primary accent, warning status.warn, error status.error, success status.ok, foreground fg, background bg, surface and panel surface. The default is devops-dark, with a setting for light, because Textual cannot detect the terminal background. The status dots get a word.
  • With NO_COLOR set, the output keeps bold, the marks and the words.

Target Subsystem

Terminal output (src/devops_cli/output/, src/devops_cli/ui/, src/devops_cli/design/).

Existing Tool Considered

rich.theme.Theme.read (Rich 15.0.0, in use) reads an INI file; Rich has the ansi_dark and ansi_light syntax themes and honors NO_COLOR. Textual 8.2.8 (in use) has register_theme. No new dependency. Custom code: one severity map, one status enum and the theme function. Cost (estimate): about 150,000 tokens and 1 day.

Acceptance Criteria

  • A test asserts that the status keys of roles.ini in [styles] and in [grafana] equal the status roles of the tokens.
  • grep finds 0 emoji comparisons in status logic.
  • One severity map remains.
  • With NO_COLOR set, the output keeps the marks and words (snapshot test).
  • The Textual app starts with devops-dark and switches to devops-light through the setting.

Dependencies

Source: #4735

Alternatives check of 2026-11-28: in-use.
The repository already uses this tool.
Tool: Textualize/rich (https://github.com/Textualize/rich), MIT, last activity 2026-11-13, maintained.
Reason: Searches and the facts of Rich 15.0.0, already in use, show it reads named style roles from an INI theme, ships ANSI syntax themes and honors NO_COLOR; the status vocabulary, severity map, enum and Textual themes stay custom code.

Covers:

  • Loads named style roles from one INI file with Theme.read
  • Ships the ansi_dark and ansi_light syntax themes
  • Honors NO_COLOR and a console highlight switch

Lacks:

  • No project status roles, grafana section or single severity map
  • No status enum, so emoji string comparisons remain
  • No token-driven devops-light and devops-dark Textual themes

Proposed design

Problem statement

The terminal output has no shared Rich theme. It uses 688 inline markups in 59 files, 162 style= arguments, six success marks, two error styles and three warning marks. Four severity maps disagree. Status logic reads emoji. The syntax theme is monokai on every terminal. The Textual TUI is dark only, and its status dots have no word. The change adds one theme in src/devops_cli/design/roles.ini, one severity map, a status enum, ANSI syntax themes and token-driven Textual themes. It keeps bold, marks and words when NO_COLOR is set.

Acceptance criteria

Requirement: Shared console status theme

The console SHALL load the status-role styles from src/devops_cli/design/roles.ini through rich.theme.Theme.read and SHALL set highlight=False.

Scenario: Console role styles

  • WHEN A test calls get_console() and reads the status.ok and status.error styles.
  • THEN The status.ok style is green, the status.error style is bold red, and console.highlight is false.

Requirement: Grafana status color access

The design module SHALL expose grafana_color(role) that reads the [grafana] section of src/devops_cli/design/roles.ini.

Scenario: Grafana status colors

  • WHEN A test calls grafana_color('ok'), grafana_color('warn') and grafana_color('error').
  • THEN The function returns text, semi-dark-orange and red.

Requirement: Status mark and word

Each status SHALL print one mark and one word: the check mark with OK, ! with Warn, the ballot x with Fail, and i with Info.

Scenario: Status rendering

  • WHEN A test renders OK, Warn, Fail and Info through the status helper.
  • THEN The text holds ✓ OK, ! Warn, ✗ Fail and i Info.

Requirement: Single severity map

The code SHALL keep one severity map and SHALL make the four former severity paths use it.

Scenario: Severity map sites

  • WHEN A test imports the severity map and inspects src/devops_cli/review/report.py, src/devops_cli/commands/review.py, src/devops_cli/output/formatters/scalars.py and src/devops_cli/commands/scan.py.
  • THEN It finds one map, and each former site uses it.

Requirement: Status enum

Status logic SHALL compare a status enum and SHALL contain zero emoji comparisons.

Scenario: Status logic scan

  • WHEN A test scans src/devops_cli for comparisons to emoji string literals in status code.
  • THEN It finds zero emoji comparisons.

Requirement: Syntax theme setting

The syntax highlighter SHALL use ansi_dark by default and SHALL use ansi_light when the setting selects it.

Scenario: Syntax theme selection

  • WHEN A test builds output with the default setting and with the ansi_light setting.
  • THEN The syntax theme is ansi_dark by default and ansi_light with the setting.

Requirement: Textual theme registration

textual_theme(mode) in the design module SHALL register devops-light and devops-dark from the token JSON and SHALL map primary to accent, warning to status.warn, error to status.error, success to status.ok, foreground to fg, background to bg, and surface and panel to surface.

Scenario: Theme mode selection

  • WHEN A test calls textual_theme('dark') and textual_theme('light').
  • THEN It gets the two registered themes with the mapped colors, and the app default is devops-dark.

Requirement: Textual status dot words

The Textual status dots SHALL show a word with each dot.

Scenario: Projection status dot

  • WHEN A test renders a projection with a status.
  • THEN The dot carries the matching status word.

Requirement: NO_COLOR output

With NO_COLOR set, the output SHALL keep bold, the marks and the words and SHALL contain no color.

Scenario: NO_COLOR snapshot

  • WHEN A test renders status output with NO_COLOR=1.
  • THEN The snapshot has bold styling, the marks and the words, and no color escape.

Requirement: Textual theme setting

The Textual app SHALL start with devops-dark and SHALL switch to devops-light through the setting.

Scenario: Textual theme setting

  • WHEN A test starts the app with the default setting and with the light setting.
  • THEN The app theme is devops-dark by default and devops-light with the light setting.

Existing Tool Considered

Rich (https://pypi.org/project/rich) is in use and is maintained. It covers theme loading with rich.theme.Theme.read, the ansi_dark and ansi_light syntax themes, NO_COLOR handling, and named style roles. It lacks the project's status-role vocabulary, the [grafana] section, one shared severity map, a status enum, mark-plus-word status rendering, and token-driven Textual devops-light/devops-dark themes. The custom code is one roles.ini, one severity map, one status enum, grafana_color(role) and textual_theme(mode). No new dependency is needed. Written cost: about 150,000 tokens and 1 day.

Key questions

  • Which file format and loader should hold the shared status roles?: Use src/devops_cli/design/roles.ini with [styles] and [grafana]. Load [styles] with rich.theme.Theme.read in get_console(). (best practice) [sources: src/devops_cli/output/console.py]
    • Chosen: INI file read by Rich Theme.read. Rich reads it directly, and the Grafana item reads the same keys from one file.
    • Rejected: Python dictionary in a module. It splits the Grafana names from the Rich theme and needs extra code.
    • Rejected: TOML file. Rich Theme.read does not read TOML, so it adds a parser.
  • Which color values should the theme roles use?: Use ANSI names: status.ok green, status.warn yellow, status.error bold red, status.info default; sev.critical bold red, sev.high red, sev.medium yellow, sev.low default, sev.info dim; muted dim, heading bold, table.header bold, border dim, accent cyan, link underline cyan, code cyan. (best practice) [sources: docs/DESIGN.md:266]
    • Chosen: ANSI color names. A hex value becomes grey code 90 on a 16-color terminal, and Rich cannot detect a light background.
    • Rejected: Hex values. They collapse to grey on 16-color terminals and need background detection.
    • Rejected: 256-color values. They need a palette and do not work on a 16-color terminal.
  • How should each status show its state?: Print one mark and one word: ✓ OK, ! Warn, ✗ Fail and i Info. (best practice) [sources: src/devops_cli/output/formatters/tables.py:215, docs/DESIGN.md:266]
    • Chosen: Mark plus word. It stays readable with no color and in snapshots.
    • Rejected: Emoji only. It is not readable in NO_COLOR and is hard to test.
    • Rejected: Word only. It loses the fast visual cue that the marks give.
  • How should the code consolidate severity?: Keep one severity map with sev.critical bold red, sev.high red, sev.medium yellow, sev.low default and sev.info dim. INFO is not green. The four legacy paths import it. (best practice) [sources: src/devops_cli/review/report.py, src/devops_cli/commands/review.py, src/devops_cli/output/formatters/scalars.py:20, src/devops_cli/commands/scan.py:85]
    • Chosen: One shared severity map. It removes four disagreeing maps and keeps LOW, HIGH and INFO consistent.
    • Rejected: Keep four maps. They disagree on LOW, HIGH and INFO.
    • Rejected: Reuse status roles for severity. Severity and status are different vocabularies, and INFO must not be green.
  • How should status logic stop reading emoji strings?: Add one status enum and make status logic compare enum members. messages.py uses role names. (best practice) [sources: src/devops_cli/output/formatters/tables.py:215, src/devops_cli/review/report.py:847, src/devops_cli/security/reference_extractor.py:609]
    • Chosen: Status enum. It gives one typed value for status and removes string comparisons.
    • Rejected: String constants. They still compare strings and can drift.
    • Rejected: Regular expressions on output. They parse rendered text and are fragile.
  • Which syntax theme should be the default?: Use ansi_dark by default and expose ansi_light as a setting. (best practice) [sources: src/devops_cli/config/defaults.py:380]
    • Chosen: ansi_dark default, ansi_light setting. Rich ships both ANSI themes and they follow the terminal palette.
    • Rejected: monokai. It puts one palette on every terminal.
    • Rejected: ansi_light default. The project terminals are mostly dark; light stays a setting.
  • How should the Textual themes map the design tokens?: textual_theme(mode) registers devops-light and devops-dark from the token JSON. Primary uses accent, warning status.warn, error status.error, success status.ok, foreground fg, background bg, surface and panel surface. The default is devops-dark, with a setting for light. (best practice) [sources: src/devops_cli/ui/projections.py:38-40]
    • Chosen: Token-driven Textual themes. It keeps the TUI on the same tokens as the rest of the design.
    • Rejected: Hard-coded Textual CSS. It duplicates colors and cannot follow the token files.
    • Rejected: Built-in Textual themes. They do not carry the project's status roles or token names.
  • How should NO_COLOR change output?: With NO_COLOR set, keep bold, the marks and the words, and remove color. (best practice) [sources: src/devops_cli/output/console.py]
    • Chosen: Keep bold, marks and words. It keeps output readable in pipes and on no-color terminals.
    • Rejected: Strip all styling. It loses emphasis and NO_COLOR does not require it.
    • Rejected: Disable output. NO_COLOR asks for no color, not no output.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4738

Activity

  1. added
    source/agent
    on Nov 11, 2026
  2. added
    type/feature
    scope/output
    status/new
    value/medium
    effort/medium
    on Nov 11, 2026
  3. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/output. The (output) scope of the title gives the scope.
    • Priority: P2-Medium. It unifies inconsistent status colors and adds theming, but does not fix a broken function or a security gap.
    • Value: Medium. Users see consistent status marks and words across all commands instead of four disagreeing severity maps and emoji reads.
    • Effort: Medium. The body estimates one day and touches 59 files, a new design module, a status enum, and the Textual TUI.
    • Related: feat(cli): rich renderables architecture, terminal capability negotiation & universal output serialization research #326, which asks for a different change. Both target terminal output formatting, but #326 delivers the renderables pipeline and capability negotiation, while the candidate delivers a specific theme file with status roles and a unified severity map.
  4. added
    priority/p2-medium
    on Nov 11, 2026
  5. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Waiting for the alternatives check to run. The next refine round looks at the item again after the check records a verdict.

  6. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: The searches found no library that ships a status-role theme, one severity map and mark-plus-word status output for a project's own vocabulary. Rich, which the issue already names as in use, does cover a real part of the need with rich.theme.Theme.read for an INI theme, the built-in ansi_dark/ansi_light syntax themes and NO_COLOR handling, but the role vocabulary, severity map, status enum and Textual token themes stay custom code.

    The repository already uses this tool.

    Tool: rich (https://pypi.org/project/rich)

    • License: MIT
    • Last activity: 2026-04-12
    • Maintained: yes

    Covers:

    • Loads a theme from an INI file with rich.theme.Theme.read, which get_console() can use for the [styles] roles
    • Ships the ansi_dark and ansi_light syntax themes that replace monokai
    • Honors NO_COLOR while keeping non-color styling such as bold
    • Applies named style roles to console output and marks

    Lacks:

    • A status-role vocabulary (status.ok, status.warn, status.error, status.info, sev.*, muted, heading, border, accent, link, code) defined for this project
    • The [grafana] section that maps the same status roles to Grafana color names
    • One shared severity map replacing the four disagreeing maps
    • A status enum replacing emoji string comparisons in status logic
    • Mark-plus-word status rendering (OK with the check mark, ! Warn, Fail with the ballot x, i Info)
    • Token-driven Textual devops-light/devops-dark theme registration and status-dot words

    Tools considered:

    Searches run:

    • rich theme INI status roles status marks library, results: 5
    • python library terminal status symbols severity colors rich theme, results: 5
    • Textual Rich Theme register_theme documentation, results: 5
    • python package status icons ok warn error info terminal output, results: 5
    • python terminal status indicator library check mark cross warning symbol word, results: 5
    • "rich" python "Theme.read" theme ini file documentation, results: 5
    • pypi rich-status severity levels library, results: 5
    • github Textualize rich theme styles console documentation, results: 5
    • Textual register_theme custom theme app, results: 5
    • Rich Python library console styling, results: 5

    Sources:

    Checked on 2026-11-17. A person decides what this means for the item. The check changes no label and closes no issue.

  7. added
    status/ready
    and removed
    status/new
    on Nov 17, 2026
  8. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 0857ee5 (see proposed design in issue body).

  9. added
    owner/service
    on Nov 25, 2026
  10. 9 remaining items

  11. added
    owner/service
    and removed
    owner/service
    on Nov 25, 2026
  12. added
    owner/agent
    status/in-progress
    and removed
    status/ready
    on Nov 28, 2026
  13. devops-cli-service commented on Nov 28, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: in-use, tool https://pypi.org/project/rich. A person decides what the new result means for the item.

    Searches (6)

    Tools considered:

    Searches run:

    • Rich Theme.read INI file custom styles console, results: 5
    • Rich ANSI syntax theme ansi_dark ansi_light highlight False NO_COLOR, results: 5
    • textual register_theme custom theme Textual app, results: 5
    • rich python library theme documentation style roles console, results: 5
    • rich.readthedocs.io theme ini file, results: 5
    • "Theme.read" rich python, results: 5

    Sources:

  14. added
    status/in-review
    and removed
    status/in-progress
    on Nov 28, 2026
  15. removed
    status/in-review
    owner/agent
    on Nov 28, 2026
  16. devops-cli-service commented on Nov 28, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-28 18:38 UTC

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/outputsource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions