Skip to content

feat(rust): extract reusable terminal-UI primitives into mergify-tui#1379

Draft
jd wants to merge 1 commit intodevs/jd/worktree-rust-port/derive-native-queue-cmds-binary-hardcoded-list--74502fe8from
devs/jd/worktree-rust-port/extract-reusable-terminal-ui-primitives-mergify--bbdbce1e
Draft

feat(rust): extract reusable terminal-UI primitives into mergify-tui#1379
jd wants to merge 1 commit intodevs/jd/worktree-rust-port/derive-native-queue-cmds-binary-hardcoded-list--74502fe8from
devs/jd/worktree-rust-port/extract-reusable-terminal-ui-primitives-mergify--bbdbce1e

Conversation

@jd
Copy link
Copy Markdown
Member

@jd jd commented May 6, 2026

Reviewer feedback: the colored-tree rendering helpers in
crates/mergify-queue/src/status.rs (Theme + relative-time
formatter + box-drawing characters) are general-purpose and will
be needed by every command with structured human-readable output
(queue show, freeze list, future ports). Centralize them
in a new mergify-tui crate so each port consumes the same
primitives instead of forking its own copy.

The new crate has three modules:

  • theme: Theme struct with TTY/NO_COLOR-aware
    enable/disable. Pre-built named styles (bold, dim,
    cyan/green/red/yellow/magenta, warn)
    plus a fg(AnsiColor) helper for domain-specific palettes.
    Theme::detect is the production constructor;
    Theme::new(enabled) is for tests that need to exercise the
    styled or plain branch deterministically.

  • time: relative_time(iso, now, future) — coarse
    Ns/Nm/Nh/Nd formatter mirroring the Python
    CLI's _relative_time. Empty string on parse failure so a
    malformed timestamp doesn't abort the surrounding render.

  • tree: Unicode box-drawing constants (BRANCH,
    LAST_BRANCH, CONTINUATION, LAST_CONTINUATION) plus
    branch_chars(is_last) to pick both prefixes for a row in
    one call.

mergify-queue::status is refactored to consume from
mergify-tui: the local Theme struct and relative_time
function are deleted, the inline ├── /└── //
literals are replaced with tree::branch_chars calls,
and the queue-specific batch_status_style helper now uses
Theme::fg for its per-status color mapping.

Tests: 11 new in mergify-tui (theme on/off, relative-time
units + parse failure + future prefix, tree-character pairing).
The 6 relative_time_* tests in mergify-queue are removed
— their coverage moves with the function. Workspace count: queue
24 (was 30), tui 11.

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

Depends-On: #1366

Reviewer feedback: the colored-tree rendering helpers in
``crates/mergify-queue/src/status.rs`` (Theme + relative-time
formatter + box-drawing characters) are general-purpose and will
be needed by every command with structured human-readable output
(``queue show``, ``freeze list``, future ports). Centralize them
in a new ``mergify-tui`` crate so each port consumes the same
primitives instead of forking its own copy.

The new crate has three modules:

- ``theme``: ``Theme`` struct with TTY/``NO_COLOR``-aware
  enable/disable. Pre-built named styles (``bold``, ``dim``,
  ``cyan``/``green``/``red``/``yellow``/``magenta``, ``warn``)
  plus a ``fg(AnsiColor)`` helper for domain-specific palettes.
  ``Theme::detect`` is the production constructor;
  ``Theme::new(enabled)`` is for tests that need to exercise the
  styled or plain branch deterministically.

- ``time``: ``relative_time(iso, now, future)`` — coarse
  ``Ns``/``Nm``/``Nh``/``Nd`` formatter mirroring the Python
  CLI's ``_relative_time``. Empty string on parse failure so a
  malformed timestamp doesn't abort the surrounding render.

- ``tree``: Unicode box-drawing constants (``BRANCH``,
  ``LAST_BRANCH``, ``CONTINUATION``, ``LAST_CONTINUATION``) plus
  ``branch_chars(is_last)`` to pick both prefixes for a row in
  one call.

``mergify-queue::status`` is refactored to consume from
``mergify-tui``: the local ``Theme`` struct and ``relative_time``
function are deleted, the inline ``├── ``/``└── ``/``│   ``/
``    `` literals are replaced with ``tree::branch_chars`` calls,
and the queue-specific ``batch_status_style`` helper now uses
``Theme::fg`` for its per-status color mapping.

Tests: 11 new in ``mergify-tui`` (theme on/off, relative-time
units + parse failure + future prefix, tree-character pairing).
The 6 ``relative_time_*`` tests in ``mergify-queue`` are removed
— their coverage moves with the function. Workspace count: queue
24 (was 30), tui 11.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Change-Id: Ibbdbce1e8272ab6d81b2dc8a194d527dd41d8744
@jd
Copy link
Copy Markdown
Member Author

jd commented May 6, 2026

This pull request is part of a Mergify stack:

# Pull Request Link
1 feat(rust): port queue pause and unpause to native Rust #1352
2 feat(rust): port ci git-refs and ci queue-info to native Rust #1353
3 feat(rust): port queue status to native Rust #1359
4 test: derive native queue commands from the binary, not a hardcoded list #1366
5 feat(rust): extract reusable terminal-UI primitives into mergify-tui #1379 👈
6 fix(cli): surface clap's --help instead of erroring on native subcommands #1380

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 6, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🔴 ⛓️ Depends-On Requirements

Waiting for

This rule is failing.

Requirement based on the presence of Depends-On in the body of the pull request

🔴 🤖 Continuous Integration

Waiting for

  • check-success=ci-gate
This rule is failing.
  • all of:
    • check-success=ci-gate

🔴 👀 Review Requirements

Waiting for

  • #approved-reviews-by>=2
This rule is failing.
  • any of:
    • #approved-reviews-by>=2
    • author = dependabot[bot]
    • author = mergify-ci-bot
    • author = renovate[bot]

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|ui)(?:\(.+\))?:

🟢 🔎 Reviews

Wonderful, this rule succeeded.
  • #changes-requested-reviews-by = 0
  • #review-requested = 0
  • #review-threads-unresolved = 0

🟢 📕 PR description

Wonderful, this rule succeeded.
  • body ~= (?ms:.{48,})

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant