Skip to content

[Bug]: parseRichMarkup creates one Line per color tag, breaking multi-color banner_hero rows in the new TUI #46776

Description

@kusuriya

[Bug]: parseRichMarkup creates one Line per color tag, breaking multi-color banner_hero rows in the new TUI

Hermes version: 0.16.0 (2026.6.5), upstream 45e2f4fd
Affected surface: new TUI (ui-tui/)
File: ui-tui/src/banner.ts:5-44
Fix in progress: PR #46773 (fix(ui-tui): keep color segments within one Line in parseRichMarkup)
Related but distinct: #9879 (CLI banner centering distorts braille-padding — same theme of inconsistent rich-markup handling across surfaces, but different code path)

Discovered while: running a user skin whose banner_hero block contains multiple Rich color tags per visual row. Any such skin triggers the bug — see the minimal repro below.


Bug Description

parseRichMarkup in ui-tui/src/banner.ts returns a Line[] whose entries do not correspond to visual rows of the input. A single input row containing N [#hex]…[/] tags is emitted as N separate Line entries, so the renderer stacks them and the banner_hero displays as multiple lines of fragmentary text ("line soup") instead of one tinted row.

The defect is silent — multi-color banner_hero rows render fine in the Rich CLI banner and the older TUI, so affected skins appear to work in some surfaces and break in others depending on which code path is used.

This is a TypeScript analogue of the same pattern flagged in #4071 (consolidate color/styling systems) — the ui-tui parser is a fourth, structurally-broken implementation of the same Rich-markup idea.

Steps to Reproduce

Minimal repro — no custom assets required:

  1. Create ~/.hermes/skins/repro.yaml with one row containing three color tags:
    name: repro
    banner_hero: |2-
      [#ff0000]RED[/][#00ff00]GREEN[/][#0000ff]BLUE[/]
  2. In the new TUI, run /skin repro to load it.
  3. Pre-fix the banner_hero renders as three stacked rows (RED, GREEN, BLUE each on their own line) instead of one row with three colored segments. Post-fix it renders as one row: REDGREENBLUE with red, green, and blue inline.

The bug is independent of which colors are used and of any specific skin — the test skin above is a 6-line artifact that any reviewer can write in under a minute. An external real-world trigger is the cyberdeck skin at ~/.hermes/skins/cyberdeck.yaml (a 3-fold biohazard with 5–7 color tags per row), which is what originally surfaced the defect.

Expected Behavior

Every \n-delimited row in the input banner_hero markup should produce exactly one Line (or one logical visual row) in the output, preserving all color segments within that row.

Actual Behavior

Every [#hex]…[/] match produces a separate Line, so a row like [#A]abc[/][#B]def[/] emits two Line entries. The renderer draws two short fragments on separate visual rows. With 5+ tags per row the result is unreadable.

Root Cause

ui-tui/src/banner.ts:5-44:

const RICH_RE = /\[(?:bold\s+)?(?:dim\s+)?(#(?:[0-9a-fA-F]{3,8}))\]([\s\S]*?)(\[\/\])/g

export function parseRichMarkup(markup: string): Line[] {
  const lines: Line[] = []

  for (const raw of markup.split('\n')) {
    const trimmed = raw.trimEnd()
    // ...
    for (const m of matches) {
      const before = trimmed.slice(cursor, m.index)
      if (before) { lines.push(['', before]) }   // pushes a new Line
      lines.push([m[1]!, m[2]!])                  // pushes a new Line
      cursor = m.index! + m[0].length
    }
    // ...
  }
  return lines
}

The function splits on \n correctly, but inside each row it pushes one Line per color-tag match instead of grouping segments into a single Line per row. The Line = [string, string] type cannot represent multi-color rows as a single 2-tuple, so the data model has to change.

Suggested Fix

Widen Line so a row can carry multiple color segments:

// before
type Line = [string, string]

// after
export type Line = Array<[string, string]>

Then parseRichMarkup pushes one Line per input row, accumulating [color, text] segments inside it. colorize() in the same file is updated to return [[color, text]] (single-segment) per row. artWidth() is updated to iterate segments and find the max. The only consumer of Line[] in ui-tui/src/ is ArtLines in components/branding.tsx:30-40, which needs to render each row as one outer <Text> with one inner <Text color={c}> per segment.

A full reference implementation with 16 test cases lives in the companion PR.

Why It Stayed Hidden

  • The default caduceus (CADUCEUS_ART + CADUC_GRADIENT) is generated by colorize(), single-color-per-row. The parser bug only manifests for parseRichMarkup output, which only runs for customHero.
  • The Rich CLI banner and the older TUI use a different code path that collapses each row to its first color. They render the broken case acceptably, masking the underlying defect.
  • Most built-in skins ship the default caduceus and have never been tested with a multi-color banner_hero against the new TUI.

Workaround

Until fixed, restrict banner_hero to zero or one Rich color tag per visual row. The procedural generator at ~/.hermes/skills/.../scripts/generate_braille_art.py does run-length color grouping; the cyberdeck skin is shipped locally as a working single-color example pending the upstream fix.

Environment

  • Hermes Agent v0.16.0 (2026.6.5), upstream 45e2f4fd
  • macOS 26.4.1 (Apple Silicon, M2 Max 32GB)
  • ui-tui/src/banner.ts:5-44 — buggy function
  • ~/.hermes/skins/repro.yaml — minimal repro skin (6 lines, included in the Steps to Reproduce)

Debug Report

hermes debug share not run — issue is deterministic and trivially reproducible against the repo's own built-in TUI bundle. CI on a fresh checkout with the 6-line repro.yaml from the Steps to Reproduce will reproduce without any extra setup.

Activity

  1. added
    type/bugSomething isn't working
    comp/tuiTerminal UI (ui-tui/ + tui_gateway/)
    P3Low — cosmetic, nice to have
    on Jun 15, 2026
  2. GottZ commented on Jul 28, 2026

    @GottZ

    This was generated by AI during triage.

    Summary

    One PR addresses #46776. #46773 changes the banner model and renderer so each newline-delimited visual row remains one Line containing multiple colored segments, directly fixing the reported vertical fragmentation and correcting width calculation for segmented rows.

    Related pull requests

    Suggested consolidation

    Merge #46773 after adding the focused regression coverage requested by the keep_open contributor review; it is the only PR in this complex and its parser, data-model, renderer, and width changes directly address #46776, so there are no duplicate PRs to close.

    Complex graph

    flowchart LR
        classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a
        classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d
        classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937
        classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151
        classDef best stroke-width:3px,stroke:#b45309
        classDef target stroke-width:3px,stroke:#4338ca
        I46776(["issue #46776 (open)"])
        P46773["PR #46773 (open)"]
        P46773 -->|best fix| I46776
        class I46776 open
        class I46776 target
        class P46773 open
        class P46773 best
        click I46776 "https://github.com/NousResearch/hermes-agent/issues/46776"
        click P46773 "https://github.com/NousResearch/hermes-agent/pull/46773"
    
    Loading

    Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed or no verify verdict yet (state tag in the node label).

    Cross-PR triage: Reviewed 1 pull request and 1 issue in this complex. Each diff was read against this issue; Assessment working set: 4 kB of PR diffs, 12 kB of issue/PR text, 1 kB of discussion (2 comments), 2 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.

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

    P3Low — cosmetic, nice to havecomp/tuiTerminal UI (ui-tui/ + tui_gateway/)type/bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions