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"
|
CYAN = "\x1b[36m"
|
||||||
GREEN = "\x1b[32m"
|
GREEN = "\x1b[32m"
|
||||||
YELLOW = "\x1b[33m"
|
YELLOW = "\x1b[33m"
|
||||||
|
BRIGHT_WHITE = "\x1b[97m"
|
||||||
|
|
||||||
_ansi: bool | None = None
|
_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))
|
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)
|
page_list = ", ".join(str(page) for page in pages)
|
||||||
print(style(" ! ", YELLOW, BOLD) + f"{label} missing page(s): {page_list}.")
|
print(style(" ! ", YELLOW, BOLD) + style(f"{label} missing page(s): {page_list}.", YELLOW, BOLD))
|
||||||
if reasons:
|
print(
|
||||||
for page in pages:
|
style(
|
||||||
print(style(f" Page {page}: {reasons[page]}.", DIM))
|
" Close and reopen this history board, then scroll down until page gap recovered is shown.",
|
||||||
print(" Close and reopen this history board, then scroll down again.")
|
BRIGHT_WHITE,
|
||||||
|
BOLD,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def print_page_gap_recovered(label: str) -> None:
|
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:
|
def print_capture_stats(received: int, dropped: int, interface_dropped: int) -> None:
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,7 @@ def run_live_capture(
|
||||||
if capture.fallback_reason:
|
if capture.fallback_reason:
|
||||||
console.print_capture_fallback(capture.fallback_reason)
|
console.print_capture_fallback(capture.fallback_reason)
|
||||||
reported_missing_pages: dict[str, tuple[int, ...]] = {}
|
reported_missing_pages: dict[str, tuple[int, ...]] = {}
|
||||||
|
active_gap_notices: set[str] = set()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with StopKeyMonitor() as stop_key:
|
with StopKeyMonitor() as stop_key:
|
||||||
|
|
@ -115,14 +116,12 @@ def run_live_capture(
|
||||||
label = POOL_META.get(kind, POOL_META["permanent"])["name"]
|
label = POOL_META.get(kind, POOL_META["permanent"])["name"]
|
||||||
missing_pages = tuple(session.missing_pages(kind))
|
missing_pages = tuple(session.missing_pages(kind))
|
||||||
previously_missing = reported_missing_pages.get(kind, ())
|
previously_missing = reported_missing_pages.get(kind, ())
|
||||||
if missing_pages and missing_pages != previously_missing:
|
if missing_pages and kind not in active_gap_notices:
|
||||||
reasons = {
|
console.print_missing_pages(label, list(missing_pages))
|
||||||
page: session.missing_page_reason(kind, page)
|
active_gap_notices.add(kind)
|
||||||
for page in missing_pages
|
|
||||||
}
|
|
||||||
console.print_missing_pages(label, list(missing_pages), reasons)
|
|
||||||
elif previously_missing and not missing_pages:
|
elif previously_missing and not missing_pages:
|
||||||
console.print_page_gap_recovered(label)
|
console.print_page_gap_recovered(label)
|
||||||
|
active_gap_notices.discard(kind)
|
||||||
reported_missing_pages[kind] = missing_pages
|
reported_missing_pages[kind] = missing_pages
|
||||||
finally:
|
finally:
|
||||||
stats = capture.stats()
|
stats = capture.stats()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue