feat(rust): extract reusable terminal-UI primitives into mergify-tui#1379
Conversation
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
Member
Author
|
This pull request is part of a Mergify stack:
|
This was referenced May 6, 2026
Contributor
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🔴 ⛓️ Depends-On RequirementsWaiting for
This rule is failing.Requirement based on the presence of
🔴 🤖 Continuous IntegrationWaiting for
This rule is failing.
🔴 👀 Review RequirementsWaiting for
This rule is failing.
🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 🔎 ReviewsWonderful, this rule succeeded.
🟢 📕 PR descriptionWonderful, this rule succeeded.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reviewer feedback: the colored-tree rendering helpers in
crates/mergify-queue/src/status.rs(Theme + relative-timeformatter + 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 themin a new
mergify-tuicrate so each port consumes the sameprimitives instead of forking its own copy.
The new crate has three modules:
theme:Themestruct with TTY/NO_COLOR-awareenable/disable. Pre-built named styles (
bold,dim,cyan/green/red/yellow/magenta,warn)plus a
fg(AnsiColor)helper for domain-specific palettes.Theme::detectis the production constructor;Theme::new(enabled)is for tests that need to exercise thestyled or plain branch deterministically.
time:relative_time(iso, now, future)— coarseNs/Nm/Nh/Ndformatter mirroring the PythonCLI's
_relative_time. Empty string on parse failure so amalformed timestamp doesn't abort the surrounding render.
tree: Unicode box-drawing constants (BRANCH,LAST_BRANCH,CONTINUATION,LAST_CONTINUATION) plusbranch_chars(is_last)to pick both prefixes for a row inone call.
mergify-queue::statusis refactored to consume frommergify-tui: the localThemestruct andrelative_timefunction are deleted, the inline
├──/└──/│/literals are replaced withtree::branch_charscalls,and the queue-specific
batch_status_stylehelper now usesTheme::fgfor its per-status color mapping.Tests: 11 new in
mergify-tui(theme on/off, relative-timeunits + parse failure + future prefix, tree-character pairing).
The 6
relative_time_*tests inmergify-queueare 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