feat(events): cap the default page at one API page - #1766
Conversation
`colors_enabled()` opened with `if cfg!(test) { return false }`, whose
comment claims tests "never depend on the dev's TTY". It cannot do
that: `cfg!(test)` is false whenever mergify-tui is compiled as a
dependency, so the guard only ever covered mergify-tui's own tests.
Every *consumer* crate's tests fell through to the real policy and read
the developer's environment — `FORCE_COLOR=1 cargo test -p
mergify-events` fails on main today, on escape sequences injected into
asserted output.
Gate on the recorded `--color` choice instead. `set_color_choice()` is
called from exactly one place, `detect_dispatch()` in main, so an unset
choice means the process did not come through the CLI: a test harness,
a doctest, an embedder. Colors stay off there, in any environment,
across every crate.
`resolve_enabled()` takes the `Option<ColorChoice>` so the new case is
covered by the existing precedence unit test rather than by global
state.
Refs MRGFY-8533.
Change-Id: Id7eb12b906409122000a14722e5ce172ab93cb4c
|
This pull request is part of a Mergify stack:
|
Merge Protections🔴 2 of 7 protections blocking · waiting on 👀 reviews
🔴 👀 Review RequirementsWaiting for
This rule is failing.
🔴 🔎 ReviewsWaiting for
This rule is failing.
Show 5 satisfied protections🟢 ⛓️ Depends-On RequirementsRequirement based on the presence of
🟢 🤖 Continuous Integration
🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 📕 PR description
🟢 🚦 Auto-queueWhen all merge protections are satisfied, this pull request will be queued automatically. |
`mergify events` with no flags took minutes on a busy repository:
`--since` defaulted to 24h but `--limit` defaulted to `None`, so the
command walked every page of the window — 100 events at a time —
before printing a line.
`--limit` now defaults to 100, which is exactly one page, so the
no-flag invocation makes one request and stops. The header says when
that cap bit and names the flag that reaches further back:
Mergifyio/monorepo · newest 100 events · 2026-08-09 12:24 → 2026-08-10 12:24 UTC
Older events in this window were not fetched — raise --limit.
That announcement is what makes a default cap acceptable rather than
a way of hiding events, and `--json` carries the same fact as
`truncated`, so a script reading `size` is never quietly reading a
default. `--limit 0` is now a usage error: it would fetch a page and
print none of it, which is indistinguishable from an empty window.
This command is a low-level query over the activity log API. Deciding
*which* events are worth showing is the caller's job, and `--pr` and
`--type` already do it — so the only thing the default owes is a
bound.
Two things the same page was missing, and they are the reason
capping it is not enough:
**A subject on every line.** `Event::pull_request()` was decoded and
never read, so the repo-wide view — the default — never said which
pull request an event was about. It is now a column, cyan `#N` to
match `queue status`, suppressed under `--pr` where the header
already said it. The summary column also learned the types the page
is actually made of, measured over 500 consecutive events on
Mergifyio/monorepo rather than guessed: the queue state pair reports
the queue and its depth, `action.label` prints `+conflict` instead of
"Rule: label on unresolved" for the twentieth time, `action.comment`
prints its first line, `action.request_reviews` the reviewers.
**Color.** `mergify_tui::Theme` already had the palette and the
policy; `list.rs` used `dim` on every column, so `success` and
`failure` were the same grey. The outcome now carries its verdict —
green merged/success, red dequeued/failure, yellow aborted/pending —
and nothing else is colored, because coloring everything reproduces
the wall in a brighter palette.
2026-08-10
10:58 #38425 action.label -review threads unresolved
11:57 #38237 action.queue.leave merged
12:16 #38414 action.queue.leave merged
`truncated` is observed by the fetch rather than inferred from
`events.len() == limit`, which called a window holding exactly `limit`
events truncated.
Before: minutes, indistinguishable lines. After: ~2s on the monorepo.
Refs MRGFY-8533.
Change-Id: I901a6978c85e9c4bf442ac4c3303b6de1da3be87
a34e21d to
bf667db
Compare
Revision history
|
|
Reworked and force-pushed ( The type-exclusion design is out.
What's left is the actual bug and its fix: Kept, since they were asked for directly: the cyan Net −342 lines against the previous revision. |
mergify eventswith no flags took minutes on a busy repository:--sincedefaulted to 24h but--limitdefaulted toNone, so thecommand walked every page of the window — 100 events at a time —
before printing a line.
--limitnow defaults to 100, which is exactly one page, so theno-flag invocation makes one request and stops. The header says when
that cap bit and names the flag that reaches further back:
That announcement is what makes a default cap acceptable rather than
a way of hiding events, and
--jsoncarries the same fact astruncated, so a script readingsizeis never quietly reading adefault.
--limit 0is now a usage error: it would fetch a page andprint none of it, which is indistinguishable from an empty window.
This command is a low-level query over the activity log API. Deciding
which events are worth showing is the caller's job, and
--prand--typealready do it — so the only thing the default owes is abound.
Two things the same page was missing, and they are the reason
capping it is not enough:
A subject on every line.
Event::pull_request()was decoded andnever read, so the repo-wide view — the default — never said which
pull request an event was about. It is now a column, cyan
#Ntomatch
queue status, suppressed under--prwhere the headeralready said it. The summary column also learned the types the page
is actually made of, measured over 500 consecutive events on
Mergifyio/monorepo rather than guessed: the queue state pair reports
the queue and its depth,
action.labelprints+conflictinstead of"Rule: label on unresolved" for the twentieth time,
action.commentprints its first line,
action.request_reviewsthe reviewers.Color.
mergify_tui::Themealready had the palette and thepolicy;
list.rsuseddimon every column, sosuccessandfailurewere the same grey. The outcome now carries its verdict —green merged/success, red dequeued/failure, yellow aborted/pending —
and nothing else is colored, because coloring everything reproduces
the wall in a brighter palette.
truncatedis observed by the fetch rather than inferred fromevents.len() == limit, which called a window holding exactlylimitevents truncated.
Before: minutes, indistinguishable lines. After: ~2s on the monorepo.
Refs MRGFY-8533.
Depends-On: #1765