Skip to content

feat(rust): port queue status to native Rust#1359

Open
jd wants to merge 1 commit into
devs/jd/worktree-rust-port/add-live-smoke-test-queue-status--76f21b1afrom
devs/jd/worktree-rust-port/port-queue-status-native-rust-phase-1-7--8cebcd32
Open

feat(rust): port queue status to native Rust#1359
jd wants to merge 1 commit into
devs/jd/worktree-rust-port/add-live-smoke-test-queue-status--76f21b1afrom
devs/jd/worktree-rust-port/port-queue-status-native-rust-phase-1-7--8cebcd32

Conversation

@jd
Copy link
Copy Markdown
Member

@jd jd commented May 5, 2026

The Rust binary now serves mergify queue status natively. The
Python implementation (mergify_cli/queue/cli.py:status plus the
batch/scope/topology helpers it depended on) is removed in the
same PR — the port-and-delete rule we adopted in #1322 keeps a
single live copy of every command.

This change also introduces the mergify-tui crate. The
colored-tree rendering primitives are written there from the
start (Theme + relative-time formatter + box-drawing
characters) rather than inlined in status.rs and extracted
later — they're general-purpose and will be needed by every
command with structured human output (queue show,
freeze list, future ports).

mergify queue status [-r REPO] [-t TOKEN] [-u URL] [-b BRANCH] [--json]:

  1. Resolves repository / token / API URL via the shared
    mergify_queue::auth resolver introduced in feat(rust): port queue pause and unpause to native Rust #1352.
  2. Fetches GET /v1/repos/<repo>/merge-queue/status, optionally
    with ?branch=<branch> (URL-encoded via
    url::form_urlencoded::byte_serialize).
  3. With --json: pretty-prints the raw response. The schema is
    Mergify's API contract, not this CLI's, so we deserialize into
    serde_json::Value and emit verbatim — unknown fields and
    future schema additions survive the round trip.
  4. Without --json: deserializes into a typed StatusView
    that uses #[serde(default)] Option<…> for every field the
    Mergify API has historically treated as optional/nullable
    (matches the port checklist from docs(port): add port review checklist for HTTP/test/UX parity pitfalls #1357), then renders a
    header, an optional pause indicator, the batch tree (grouped
    by scope when there is more than one), and the waiting-PR
    list. Status icons (● ◑ ◌ ✓ ✗ ◎ ⏳ ↻ ⏰ ❄), tree
    characters (├── └── │ ), and relative times
    (5m ago / ~1h) match the Python implementation.

The mergify-tui 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.
  • 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.

Tests:

  • mergify-tui: 11 tests (theme on/off, relative-time units +
    parse failure + future prefix, tree-character pairing).
  • build_path covers no-branch, branch, and URL-encoding of a
    branch name with slashes + spaces.
  • topological_sort covers parents-before-children ordering
    and tolerance of parent_ids that reference missing batches.
  • group_by_scope covers the []"default" fallback
    and multi-scope batches appearing under each scope they claim.
  • status_icon covers known + unknown codes.
  • End-to-end wiremock tests: empty queue, paused queue, batches +
    waiting PRs, multi-scope grouping, ?branch=… query
    threading, JSON-passthrough preserving an extra_field,
    and tolerance of a response that omits all optional fields.

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

Depends-On: #1409

@jd
Copy link
Copy Markdown
Member Author

jd commented May 5, 2026

This pull request is part of a Mergify stack:

# Pull Request Link
1 test(ci): add live smoke test for ci queue-info #1406
2 feat(rust): port ci queue-info to native Rust #1407
3 test(queue): add live smoke test for queue status #1409
4 feat(rust): port queue status to native Rust #1359 👈
5 test: derive native queue commands from the binary, not a hardcoded list #1366
6 test(queue): add live smoke test for queue show #1408
7 feat(rust): port queue show to native Rust #1399
8 test(skill): port the skill-references test to Rust #1414

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 5, 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

🔴 👀 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]

🔴 🔎 Reviews

Waiting for

  • #review-requested = 0
This rule is failing.
  • #review-requested = 0
  • #changes-requested-reviews-by = 0
  • #review-threads-unresolved = 0

🟢 🤖 Continuous Integration

Wonderful, this rule succeeded.
  • all of:
    • check-success=ci-gate

🟢 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)(?:\(.+\))?:

🟢 📕 PR description

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

@jd jd force-pushed the devs/jd/worktree-rust-port/port-queue-status-native-rust-phase-1-7--8cebcd32 branch from ef75ea5 to d733d15 Compare May 5, 2026 13:13
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-git-refs-ci-queue-info-native-rust-phase--8d3f96e6 branch from 742d92c to 839ea5a Compare May 5, 2026 13:13
@jd
Copy link
Copy Markdown
Member Author

jd commented May 5, 2026

Revision history

# Type Changes Reason Date
1 initial ef75ea5 2026-05-05 13:13 UTC
2 rebase ef75ea5 → d733d15 2026-05-05 13:13 UTC
3 content d733d15 → aa25245 2026-05-05 13:22 UTC
4 content aa25245 → 53d4832 2026-05-05 15:18 UTC
5 content 53d4832 → e7ad85a 2026-05-05 19:59 UTC
6 rebase e7ad85a → 4be1b66 2026-05-06 10:57 UTC
7 content 4be1b66 → d75104b 2026-05-06 13:00 UTC
8 content d75104b → e7408de 2026-05-07 13:40 UTC
9 rebase e7408de → e9b1c70 2026-05-07 15:17 UTC
10 content e9b1c70 → 439025b 2026-05-07 18:21 UTC
11 rebase 439025b → 5f0f240 2026-05-11 07:13 UTC
12 content 5f0f240 → 2958801 2026-05-11 11:46 UTC
13 rebase 2958801 → 5c930de 2026-05-11 12:06 UTC
14 rebase 5c930de → 6080692 2026-05-11 12:19 UTC
15 rebase 6080692 → 76f551a 2026-05-11 14:08 UTC
16 rebase 76f551a → 1371b4e 2026-05-11 14:59 UTC
17 rebase 1371b4e → cefce9c 2026-05-11 15:05 UTC
18 rebase cefce9c → e7ff17e 2026-05-11 20:59 UTC
19 content e7ff17e → b6f9bf8 (raw) 2026-05-12 07:44 UTC
20 rebase b6f9bf8 → 5eb39a5 (rebase only) 2026-05-13 08:25 UTC

@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 5, 2026 13:13 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-queue-status-native-rust-phase-1-7--8cebcd32 branch from d733d15 to aa25245 Compare May 5, 2026 13:21
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 5, 2026 13:22 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-queue-status-native-rust-phase-1-7--8cebcd32 branch from aa25245 to 53d4832 Compare May 5, 2026 15:18
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 5, 2026 15:18 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-queue-status-native-rust-phase-1-7--8cebcd32 branch from 53d4832 to e7ad85a Compare May 5, 2026 19:58
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-git-refs-ci-queue-info-native-rust-phase--8d3f96e6 branch from 3df5705 to 0349b1d Compare May 5, 2026 19:58
@jd jd changed the title feat(rust): port queue status to native Rust (Phase 1.7) feat(rust): port queue status to native Rust May 5, 2026
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 5, 2026 19:59 Failure
@mergify mergify Bot requested a review from a team May 5, 2026 20:08
@jd jd force-pushed the devs/jd/worktree-rust-port/port-ci-git-refs-ci-queue-info-native-rust-phase--8d3f96e6 branch from 0349b1d to c3fc948 Compare May 6, 2026 10:57
@jd jd force-pushed the devs/jd/worktree-rust-port/port-queue-status-native-rust-phase-1-7--8cebcd32 branch from e7ad85a to 4be1b66 Compare May 6, 2026 10:57
@jd jd temporarily deployed to func-tests-live May 6, 2026 10:57 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live May 6, 2026 10:57 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 6, 2026 10:57 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-queue-status-native-rust-phase-1-7--8cebcd32 branch from 4be1b66 to d75104b Compare May 6, 2026 13:00
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 11, 2026 11:46 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-queue-status-native-rust-phase-1-7--8cebcd32 branch from 2958801 to 5c930de Compare May 11, 2026 12:06
@jd jd changed the base branch from devs/jd/worktree-rust-port/port-ci-queue-info-native-rust--f0cdc5a0 to devs/jd/worktree-rust-port/add-live-smoke-test-queue-status--76f21b1a May 11, 2026 12:06
@jd jd had a problem deploying to func-tests-live May 11, 2026 12:06 — with GitHub Actions Failure
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 11, 2026 12:06 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-queue-status-native-rust-phase-1-7--8cebcd32 branch from 5c930de to 6080692 Compare May 11, 2026 12:19
@jd jd force-pushed the devs/jd/worktree-rust-port/add-live-smoke-test-queue-status--76f21b1a branch from 542af35 to a630c92 Compare May 11, 2026 12:19
@jd jd had a problem deploying to func-tests-live May 11, 2026 12:19 — with GitHub Actions Failure
@jd jd had a problem deploying to func-tests-live May 11, 2026 12:19 — with GitHub Actions Failure
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 11, 2026 12:19 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/add-live-smoke-test-queue-status--76f21b1a branch from a630c92 to 7eb3c64 Compare May 11, 2026 14:07
@jd jd force-pushed the devs/jd/worktree-rust-port/port-queue-status-native-rust-phase-1-7--8cebcd32 branch from 6080692 to 76f551a Compare May 11, 2026 14:07
@jd jd had a problem deploying to func-tests-live May 11, 2026 14:07 — with GitHub Actions Failure
@jd jd had a problem deploying to func-tests-live May 11, 2026 14:07 — with GitHub Actions Failure
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 11, 2026 14:08 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/add-live-smoke-test-queue-status--76f21b1a branch from 7eb3c64 to 37735a7 Compare May 11, 2026 14:59
@jd jd force-pushed the devs/jd/worktree-rust-port/port-queue-status-native-rust-phase-1-7--8cebcd32 branch from 76f551a to 1371b4e Compare May 11, 2026 14:59
@jd jd temporarily deployed to func-tests-live May 11, 2026 14:59 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 11, 2026 15:00 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/add-live-smoke-test-queue-status--76f21b1a branch from 37735a7 to f706a9a Compare May 11, 2026 15:05
@jd jd force-pushed the devs/jd/worktree-rust-port/port-queue-status-native-rust-phase-1-7--8cebcd32 branch from 1371b4e to cefce9c Compare May 11, 2026 15:05
@jd jd temporarily deployed to func-tests-live May 11, 2026 15:05 — with GitHub Actions Inactive
@jd jd temporarily deployed to func-tests-live May 11, 2026 15:05 — with GitHub Actions Inactive
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 11, 2026 15:06 Failure
@jd jd force-pushed the devs/jd/worktree-rust-port/port-queue-status-native-rust-phase-1-7--8cebcd32 branch from cefce9c to e7ff17e Compare May 11, 2026 20:59
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Ports mergify queue status from the Python shim to the native Rust binary, removing the Python implementation to keep a single source of truth and introducing a small shared “TUI primitives” crate for consistent human-readable rendering across future ports.

Changes:

  • Add a native Rust implementation of queue status (human output + --json passthrough) and wire it into the Rust CLI dispatcher.
  • Introduce the new mergify-tui crate (theme/color handling, relative-time formatting, tree characters) and use it from mergify-queue.
  • Remove the Python queue status command + its API/types and delete the Python CLI tests that were specific to that implementation.

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
mergify_cli/tests/queue/test_skill.py Marks status as Rust-native for skill validation.
mergify_cli/tests/queue/test_cli.py Removes Python queue status tests; keeps _relative_time tests.
mergify_cli/queue/cli.py Deletes Python queue status implementation and helper renderers.
mergify_cli/queue/api.py Removes Python get_queue_status + related TypedDicts.
crates/mergify-tui/src/lib.rs Exposes shared TUI primitives for ported commands.
crates/mergify-tui/src/theme.rs Adds Theme with TTY/NO_COLOR detection + named styles.
crates/mergify-tui/src/time.rs Adds coarse relative_time formatter.
crates/mergify-tui/src/tree.rs Adds box-drawing constants and branch_chars().
crates/mergify-tui/Cargo.toml Defines the new mergify-tui crate/deps.
crates/mergify-queue/src/status.rs Implements native queue status + unit/e2e tests.
crates/mergify-queue/src/lib.rs Exports the new status module and updates module docs.
crates/mergify-queue/Cargo.toml Adds deps required by status and mergify-tui.
crates/mergify-cli/src/main.rs Adds native dispatch + clap wiring for queue status.
Cargo.lock Locks new crate dependencies (chrono, iana-time-zone, etc.).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/mergify-queue/src/status.rs
Comment thread crates/mergify-queue/src/status.rs
Comment thread crates/mergify-tui/src/time.rs
Comment thread crates/mergify-queue/src/status.rs Outdated
The Rust binary now serves ``mergify queue status`` natively. The
Python implementation (``mergify_cli/queue/cli.py:status`` plus the
batch/scope/topology helpers it depended on) is removed in the
same PR — the port-and-delete rule we adopted in #1322 keeps a
single live copy of every command.

This change also introduces the ``mergify-tui`` crate. The
colored-tree rendering primitives are written there from the
start (``Theme`` + relative-time formatter + box-drawing
characters) rather than inlined in ``status.rs`` and extracted
later — they're general-purpose and will be needed by every
command with structured human output (``queue show``,
``freeze list``, future ports).

``mergify queue status [-r REPO] [-t TOKEN] [-u URL] [-b BRANCH]
[--json]``:

1. Resolves repository / token / API URL via the shared
   ``mergify_queue::auth`` resolver introduced in #1352.
2. Fetches ``GET /v1/repos/<repo>/merge-queue/status``, optionally
   with ``?branch=<branch>`` (URL-encoded via
   ``url::form_urlencoded::byte_serialize``).
3. With ``--json``: pretty-prints the raw response. The schema is
   Mergify's API contract, not this CLI's, so we deserialize into
   ``serde_json::Value`` and emit verbatim — unknown fields and
   future schema additions survive the round trip.
4. Without ``--json``: deserializes into a typed ``StatusView``
   that uses ``#[serde(default)] Option<…>`` for every field the
   Mergify API has historically treated as optional/nullable
   (matches the port checklist from #1357), then renders a
   header, an optional pause indicator, the batch tree (grouped
   by scope when there is more than one), and the waiting-PR
   list. Status icons (``● ◑ ◌ ✓ ✗ ◎ ⏳ ↻ ⏰ ❄``), tree
   characters (``├── └── │   ``), and relative times
   (``5m ago`` / ``~1h``) match the Python implementation.

The ``mergify-tui`` 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.
- ``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.

Tests:

- ``mergify-tui``: 11 tests (theme on/off, relative-time units +
  parse failure + future prefix, tree-character pairing).
- ``build_path`` covers no-branch, branch, and URL-encoding of a
  branch name with slashes + spaces.
- ``topological_sort`` covers parents-before-children ordering
  and tolerance of ``parent_ids`` that reference missing batches.
- ``group_by_scope`` covers the ``[]`` → ``"default"`` fallback
  and multi-scope batches appearing under each scope they claim.
- ``status_icon`` covers known + unknown codes.
- End-to-end wiremock tests: empty queue, paused queue, batches +
  waiting PRs, multi-scope grouping, ``?branch=…`` query
  threading, JSON-passthrough preserving an ``extra_field``,
  and tolerance of a response that omits all optional fields.

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

Change-Id: I8cebcd325f05173dfa41083da2ec6516a6ec3a3f
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.

2 participants