Dedupe missing-page notices and colorize output
Add brighter white ANSI constant and update console messages to use consistent color/styling. Simplify print_missing_pages (remove per-page reasons) and make the recovery instruction more explicit. In the live capture runner introduce active_gap_notices to suppress repeated missing-page alerts per pool kind and clear the flag when the gap is recovered. These changes reduce duplicate noise and improve visibility of the guidance shown to users.
This commit is contained in:
parent
df1add6cf1
commit
fefe3a1567
2 changed files with 16 additions and 13 deletions
|
|
@ -13,6 +13,7 @@ DIM = "\x1b[2m"
|
|||
CYAN = "\x1b[36m"
|
||||
GREEN = "\x1b[32m"
|
||||
YELLOW = "\x1b[33m"
|
||||
BRIGHT_WHITE = "\x1b[97m"
|
||||
|
||||
_ansi: bool | None = None
|
||||
|
||||
|
|
@ -91,17 +92,20 @@ def print_page_captured(label: str, page: int | None, *, recaptured: bool = Fals
|
|||
print(style(" + ", GREEN, BOLD) + label + style(f" {action} {page}", DIM))
|
||||
|
||||
|
||||
def print_missing_pages(label: str, pages: list[int], reasons: dict[int, str] | None = None) -> None:
|
||||
def print_missing_pages(label: str, pages: list[int]) -> None:
|
||||
page_list = ", ".join(str(page) for page in pages)
|
||||
print(style(" ! ", YELLOW, BOLD) + f"{label} missing page(s): {page_list}.")
|
||||
if reasons:
|
||||
for page in pages:
|
||||
print(style(f" Page {page}: {reasons[page]}.", DIM))
|
||||
print(" Close and reopen this history board, then scroll down again.")
|
||||
print(style(" ! ", YELLOW, BOLD) + style(f"{label} missing page(s): {page_list}.", YELLOW, BOLD))
|
||||
print(
|
||||
style(
|
||||
" Close and reopen this history board, then scroll down until page gap recovered is shown.",
|
||||
BRIGHT_WHITE,
|
||||
BOLD,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def print_page_gap_recovered(label: str) -> None:
|
||||
print(style(" + ", GREEN, BOLD) + f"{label} page gap recovered.")
|
||||
print(style(" + ", GREEN, BOLD) + style(f"{label} page gap recovered.", GREEN, BOLD))
|
||||
|
||||
|
||||
def print_capture_stats(received: int, dropped: int, interface_dropped: int) -> None:
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ def run_live_capture(
|
|||
if capture.fallback_reason:
|
||||
console.print_capture_fallback(capture.fallback_reason)
|
||||
reported_missing_pages: dict[str, tuple[int, ...]] = {}
|
||||
active_gap_notices: set[str] = set()
|
||||
|
||||
try:
|
||||
with StopKeyMonitor() as stop_key:
|
||||
|
|
@ -115,14 +116,12 @@ def run_live_capture(
|
|||
label = POOL_META.get(kind, POOL_META["permanent"])["name"]
|
||||
missing_pages = tuple(session.missing_pages(kind))
|
||||
previously_missing = reported_missing_pages.get(kind, ())
|
||||
if missing_pages and missing_pages != previously_missing:
|
||||
reasons = {
|
||||
page: session.missing_page_reason(kind, page)
|
||||
for page in missing_pages
|
||||
}
|
||||
console.print_missing_pages(label, list(missing_pages), reasons)
|
||||
if missing_pages and kind not in active_gap_notices:
|
||||
console.print_missing_pages(label, list(missing_pages))
|
||||
active_gap_notices.add(kind)
|
||||
elif previously_missing and not missing_pages:
|
||||
console.print_page_gap_recovered(label)
|
||||
active_gap_notices.discard(kind)
|
||||
reported_missing_pages[kind] = missing_pages
|
||||
finally:
|
||||
stats = capture.stats()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue