Performance: SQLite WAL, lighter startup, per-platform tick rates
PicoCalc plan phase P2, driven by measurements taken on the Lyra as a paired A/B (git archive HEAD vs the working tree, run side by side against the same venv). The headline is the database. Every packet the monitor hears is one durable commit, and on the SD card each was costing 33.78 ms of fsync. db._tune() opens in WAL with temp_store=MEMORY: 0.59 ms per commit, a 54x cut. synchronous=NORMAL is requested only once WAL is confirmed engaged - the pragma returns the mode it settled on rather than raising when a filesystem refuses it - because under WAL it risks the last transactions to a power cut, and under the rollback journal it risks the file itself. This device runs on a battery pack. Startup: bleak/dbus-fast were already lazy; the real finds were two cheap *values* dragging heavy subtrees. core/connection.py imports one constant from core/channels.py, which imported PyCryptodome at module level (224 ms of CPU-feature probing per run) - now deferred into the two functions that decrypt. And tools/map.py's register_cli, which runs for every tool at boot, reached into ui/map_screen.py for a --fraction default, dragging the basemap's urllib.request -> http.client -> ssl behind it; DEFAULT_VIEW_FRACTION moves to core/geo.py (pure arithmetic, already on the boot path) and is re-exported so existing importers are untouched. 26 modules and 316 ms of import self-time gone. Per-frame: the corner glow only ever recolours truecolor foregrounds, so on a 16-slot console it scanned every line of every frame to hand back the identical list - skipped outright where effects are off, along with the battery blink and the braille spinner cycle. _has_wide_glyph answers from the platform when no emoji can be drawn instead of scanning the composed frame (6.5-9.1 ms per repaint on its own). The header built its segments twice to measure the compact separator, on exactly the narrow terminals that take that branch every frame; it now builds once and measures arithmetically. Together: 101.2 -> 73.2 ms per frame at 53x26, 151.8 -> 110.4 at 53x40, and 72x24 unregressed at 91.7. That finally gave numbers to set the clocks against. refresh_interval becomes per-platform tick_s (2.0 s on picocalc: a 1 Hz idle tick alone was 7-11% of a core doing nothing, and only the header's per-minute pulse drifts, since screens push their own repaints via invalidate). The 0.12 s spinner was untenable - 84% of a core at 53x26, and at 53x40 it did not fit in its own interval at all. Five duplicate _SPINNER_INTERVAL = 0.12 constants across the UI collapse into one platform-aware spinner_interval() beside the Spinner it paces. The header refactor was verified equivalent over 540 renders, plain text and style spans both. The span check earned its keep: the first cut passed style= to the Text constructor, which makes it the object's base style and blankets everything appended after, so the version string would have rendered brand-under-muted. test_header.py only asserted on .plain and never saw it; it now pins the styling too. tests/test_performance.py pins each contract as behaviour rather than timing, including a subprocess guard that fails if Crypto, the network stack, or the map screen ever creep back onto the startup import graph. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8f1fba135e
commit
63cd4e5f96
18 files changed
+462
-84
No files matched your search
+4
-6
@@ -34,7 +34,7 @@ from .tui.prompt import (
|
||||
)
|
||||
from .tui.render import render_hanging, render_lines, right_aligned_tail
|
||||
from .tui.screen import CANCEL, Screen
|
||||
from .tui.spinner import Spinner
|
||||
from .tui.spinner import Spinner, spinner_interval
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..context import AppContext
|
||||
@@ -56,9 +56,6 @@ _MENTION = re.compile(r"@\[([^\]]{1,20})\]")
|
||||
_DELIVERED = ("✓", "ok")
|
||||
_FAILED = ("✗", "err")
|
||||
|
||||
#: Seconds between spinner frames on a message that is still awaiting its ack.
|
||||
_SPINNER_INTERVAL = 0.12
|
||||
|
||||
#: The sender-prefix parser, shared app-wide from the protocol layer (the transcript,
|
||||
#: the conversation picker, the dashboard feed, and the message-paths matcher must all
|
||||
#: split ``Name: body`` identically). Kept under its old private name for the callers
|
||||
@@ -684,7 +681,8 @@ class ChatScreen(Screen):
|
||||
"""Await ``coro`` while animating the delivery spinner on the in-flight message.
|
||||
|
||||
A background timer advances the shared spinner and repaints every
|
||||
:data:`_SPINNER_INTERVAL` seconds, so a pending message's trailing glyph spins until
|
||||
:func:`~meshterm.ui.tui.spinner.spinner_interval` seconds (the platform's spin
|
||||
cadence), so a pending message's trailing glyph spins until
|
||||
the ack resolves. The timer is always cancelled (and awaited, so it can't outlive the
|
||||
send as a stray pending task) before returning. The spinner is cosmetic, so any hiccup
|
||||
in the animation is swallowed rather than allowed to break the send.
|
||||
@@ -693,7 +691,7 @@ class ChatScreen(Screen):
|
||||
|
||||
async def animate() -> None:
|
||||
while True:
|
||||
await asyncio.sleep(_SPINNER_INTERVAL)
|
||||
await asyncio.sleep(spinner_interval())
|
||||
self._spinner.tick()
|
||||
self._session.invalidate()
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import asyncio
|
||||
import math
|
||||
from typing import TYPE_CHECKING, Callable, Optional
|
||||
|
||||
from ..core.geo import EARTH_RADIUS_KM, Viewport, clamp_lat
|
||||
from ..core.geo import DEFAULT_VIEW_FRACTION, EARTH_RADIUS_KM, Viewport, clamp_lat
|
||||
from ..core.mvt import Layer
|
||||
from ..services.basemap import BasemapSource
|
||||
from .map_render import MapMarker, render_map
|
||||
@@ -49,10 +49,6 @@ _PAN_DIRS: dict[str, tuple[int, int]] = {
|
||||
#: How far past the tile source's max zoom the display may go (lower tiles are magnified).
|
||||
_OVERZOOM = 2
|
||||
|
||||
#: Default fraction of nodes the map frames on open — the densest half, so a few distant
|
||||
#: outliers don't zoom the whole mesh out to a continent. See :meth:`geo.Viewport.fit`.
|
||||
DEFAULT_VIEW_FRACTION = 0.5
|
||||
|
||||
#: The zoom an Enter-to-frame homes in at when the matches set no extent of their own — a
|
||||
#: single node (or several at one spot) has nothing to frame, so Enter zooms to this
|
||||
#: street-level closeness rather than the fit's neutral default. Capped at the tile
|
||||
|
||||
+66
-36
@@ -42,6 +42,7 @@ from .tui import (
|
||||
TuiSession,
|
||||
)
|
||||
from .tui.emoji_width import calibrate as calibrate_emoji_width
|
||||
from .tui.spinner import spinner_interval
|
||||
|
||||
|
||||
#: Grace period (seconds) allowed for the whole exit sequence — the full-screen unwind,
|
||||
@@ -61,9 +62,6 @@ _LIVENESS_POLL_S = 2.0
|
||||
#: can't fire a false "disconnected" prompt (seconds).
|
||||
_LIVENESS_CONFIRM_S = 0.4
|
||||
|
||||
#: Seconds between frames of the reconnect dialog's spinner while it waits for the device.
|
||||
_RECONNECT_SPINNER_S = 0.12
|
||||
|
||||
|
||||
def _arm_exit_watchdog(seconds: float = _EXIT_WATCHDOG_S) -> None:
|
||||
"""Guarantee the process terminates even if the exit path wedges.
|
||||
@@ -126,6 +124,11 @@ _SPARK_MIN_CELLS = 24
|
||||
#: many packets-per-minute, so a single stray reads as a small nub, not a full column.
|
||||
_HEADER_ACTIVITY_FLOOR = 3.0
|
||||
|
||||
#: The header's default segment separator, and the tighter one it falls back to when the
|
||||
#: roomy form would squeeze the pulse below :data:`_SPARK_MIN_CELLS` (see :func:`_header`).
|
||||
_SEP_ROOMY = " · "
|
||||
_SEP_COMPACT = " · "
|
||||
|
||||
|
||||
def _header(ctx: AppContext, cache: dict, width: int) -> Text:
|
||||
"""Build the persistent one-line header: who's connected, unread mail, mesh pulse.
|
||||
@@ -156,15 +159,30 @@ def _header(ctx: AppContext, cache: dict, width: int) -> Text:
|
||||
# leading separator) before the pulse claims the rest; a wider separator estimate for
|
||||
# the fit decision is harmless slack.
|
||||
battery = _battery_segment(ctx)
|
||||
reserve = (cell_len(" · ") + battery.cell_len) if battery.cell_len else 0
|
||||
sep = " · "
|
||||
header = _header_segments(ctx, cache, sep)
|
||||
if width - header.cell_len - reserve < _SPARK_MIN_CELLS:
|
||||
sep = " · "
|
||||
header = _header_segments(ctx, cache, sep)
|
||||
reserve = (cell_len(sep) + battery.cell_len) if battery.cell_len else 0
|
||||
# The separator choice changes only the *joins*, never the segments themselves, so the
|
||||
# segments are built once and each candidate width is arithmetic: one separator per
|
||||
# segment (each is preceded by one, and a trailing one leads into the pulse). Building
|
||||
# them twice to measure the second option was pure waste on exactly the narrow terminals
|
||||
# that take the compact branch every repaint — the PicoCalc's 53 columns among them.
|
||||
pieces = _header_segments(ctx, cache)
|
||||
content = sum(piece.cell_len for piece in pieces)
|
||||
|
||||
def _measure(sep: str) -> tuple[int, int]:
|
||||
"""The joined header width and the right-edge reserve, for one separator."""
|
||||
joined = content + len(pieces) * cell_len(sep)
|
||||
return joined, (cell_len(sep) + battery.cell_len) if battery.cell_len else 0
|
||||
|
||||
sep = _SEP_ROOMY
|
||||
header_w, reserve = _measure(sep)
|
||||
if width - header_w - reserve < _SPARK_MIN_CELLS:
|
||||
sep = _SEP_COMPACT
|
||||
header_w, reserve = _measure(sep)
|
||||
header = Text()
|
||||
for piece in pieces:
|
||||
header.append_text(piece)
|
||||
header.append(sep)
|
||||
# Two dot columns per cell: every cell left of the reserved tail shows two minutes.
|
||||
room = width - header.cell_len - reserve
|
||||
room = width - header_w - reserve
|
||||
if room > 0:
|
||||
# Buckets seeded from a previous session's stored history draw grey; only
|
||||
# traffic this session actually heard pulses green.
|
||||
@@ -189,7 +207,7 @@ def _header(ctx: AppContext, cache: dict, width: int) -> Text:
|
||||
# gauge land against the edge. With no room for a pulse (a very narrow terminal),
|
||||
# pad instead so the gauge still sits in the corner rather than trailing the text.
|
||||
if room <= 0:
|
||||
header.append(" " * max(0, width - header.cell_len - reserve))
|
||||
header.append(" " * max(0, width - header_w - reserve))
|
||||
header.append(sep)
|
||||
header.append_text(battery)
|
||||
return header
|
||||
@@ -220,49 +238,61 @@ def _battery_segment(ctx: AppContext) -> Text:
|
||||
reading = ctx.battery.reading()
|
||||
if reading is None:
|
||||
return Text()
|
||||
frame = int(time.monotonic() / _BATTERY_ANIM_S)
|
||||
# Frame 0 is the gauge's resting state: the true fill, unblinking. A platform without
|
||||
# effects holds it there, so the charging sweep and the low-battery blink never run —
|
||||
# both exist to catch the eye, and neither is worth a forced repaint (nor, on a 16-slot
|
||||
# console, a colour swap) on hardware where the cells are dear.
|
||||
frame = int(time.monotonic() / _BATTERY_ANIM_S) if get_platform().effects else 0
|
||||
return battery_cell(reading.percent, charging=reading.charging, frame=frame)
|
||||
|
||||
|
||||
def _header_segments(ctx: AppContext, cache: dict, sep: str) -> Text:
|
||||
"""The header's fixed segments — everything left of the pulse — at one separator width.
|
||||
def _header_segments(ctx: AppContext, cache: dict) -> list[Text]:
|
||||
"""The header's fixed segments — everything left of the pulse — unjoined.
|
||||
|
||||
Built twice per repaint at worst (roomy first, compact if the row is tight; see
|
||||
:func:`_header`). The trailing separator is included, so the caller can append the
|
||||
sparkline directly after it.
|
||||
Separator-free by design: which separator fits depends on how wide these come out, and
|
||||
the choice changes nothing about the segments themselves, so :func:`_header` measures
|
||||
both options arithmetically off this one build and joins once.
|
||||
|
||||
Args:
|
||||
ctx: The shared application context.
|
||||
cache: The device-label cache (see :func:`_device_label`).
|
||||
sep: The separator between segments (``" · "`` or the compact ``" · "``).
|
||||
|
||||
Returns:
|
||||
The fixed-left portion of the header row.
|
||||
The segments in display order — the app mark, the device, then whichever badges
|
||||
have something to report. :func:`_header` writes one separator after each.
|
||||
"""
|
||||
header = Text()
|
||||
header.append("MeshTerm", style="brand")
|
||||
header.append(f" v{__version__}", style="muted")
|
||||
header.append(sep)
|
||||
# Each segment starts as an unstyled Text and takes its styles per append. A base style
|
||||
# passed to the constructor would instead blanket everything appended after it, layering
|
||||
# the mark's brand under the version's muted.
|
||||
mark = Text()
|
||||
mark.append("MeshTerm", style="brand")
|
||||
mark.append(f" v{__version__}", style="muted")
|
||||
segments = [mark]
|
||||
|
||||
device = Text()
|
||||
if ctx.mock:
|
||||
header.append("simulator", style="warn")
|
||||
device.append("simulator", style="warn")
|
||||
else:
|
||||
name, where = _device_label(ctx, cache)
|
||||
header.append(name or "no device", style=None if name else "muted")
|
||||
device.append(name or "no device", style=None if name else "muted")
|
||||
if where:
|
||||
header.append(f" ({where})", style="muted")
|
||||
device.append(f" ({where})", style="muted")
|
||||
segments.append(device)
|
||||
|
||||
unread = ctx.chat.unread_total()
|
||||
if unread:
|
||||
header.append(sep)
|
||||
header.append("●", style="err")
|
||||
header.append(f" {unread}", style="warn")
|
||||
badge = Text()
|
||||
badge.append("●", style="err")
|
||||
badge.append(f" {unread}", style="warn")
|
||||
segments.append(badge)
|
||||
alerts = ctx.watchtower.unacked_count()
|
||||
if alerts:
|
||||
# The Watchtower's badge: a triangle so it never reads as unread mail.
|
||||
header.append(sep)
|
||||
header.append("▲", style="err")
|
||||
header.append(f" {alerts}", style="warn")
|
||||
header.append(sep)
|
||||
return header
|
||||
badge = Text()
|
||||
badge.append("▲", style="err")
|
||||
badge.append(f" {alerts}", style="warn")
|
||||
segments.append(badge)
|
||||
return segments
|
||||
|
||||
|
||||
def _device_label(ctx: AppContext, cache: dict) -> tuple[str, str]:
|
||||
@@ -878,7 +908,7 @@ async def _handle_disconnect(ctx: AppContext, session: TuiSession) -> bool:
|
||||
async def _animate_dialog(session: TuiSession, dialog: ReconnectDialog) -> None:
|
||||
"""Advance the reconnect dialog's spinner and repaint on a steady cadence, until cancelled."""
|
||||
while True:
|
||||
await asyncio.sleep(_RECONNECT_SPINNER_S)
|
||||
await asyncio.sleep(spinner_interval())
|
||||
dialog.tick()
|
||||
session.invalidate()
|
||||
|
||||
|
||||
@@ -46,16 +46,13 @@ from .menus import (
|
||||
)
|
||||
from .trace_screen import TracingDialog
|
||||
from .tui import Choice, Separator
|
||||
from .tui.spinner import Spinner
|
||||
from .tui.spinner import Spinner, spinner_interval
|
||||
from .widgets import _age_seconds, _format_age
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..context import AppContext
|
||||
from ..core.connection import Device
|
||||
|
||||
#: Seconds between spinner frames while a remote command is in flight.
|
||||
_SPINNER_INTERVAL = 0.12
|
||||
|
||||
#: Seconds to wait for one remote reply. Repeaters answer over the mesh — multi-hop
|
||||
#: routes take seconds — so this is deliberately more patient than a local command.
|
||||
_REPLY_TIMEOUT_S = 10.0
|
||||
@@ -470,7 +467,7 @@ async def _run_under_dialog(ctx: "AppContext", title: str, work) -> bool:
|
||||
|
||||
async def animate() -> None:
|
||||
while True:
|
||||
await asyncio.sleep(_SPINNER_INTERVAL)
|
||||
await asyncio.sleep(spinner_interval())
|
||||
spinner.tick()
|
||||
session.invalidate()
|
||||
|
||||
@@ -608,7 +605,7 @@ async def _command_line(ctx: "AppContext", device: "Device", node: Contact) -> N
|
||||
|
||||
async def animate() -> None:
|
||||
while True:
|
||||
await asyncio.sleep(_SPINNER_INTERVAL)
|
||||
await asyncio.sleep(spinner_interval())
|
||||
if screen.busy:
|
||||
screen.tick()
|
||||
session.invalidate()
|
||||
|
||||
@@ -100,16 +100,13 @@ from .menus import back_rows, section_heading
|
||||
from .theme import snr_style
|
||||
from .tui.render import render_lines, render_to_ansi
|
||||
from .tui.screen import ListWindow, Screen
|
||||
from .tui.spinner import Spinner
|
||||
from .tui.spinner import Spinner, spinner_interval
|
||||
from .pathline import PathHop, PathLine, path_line
|
||||
from .widgets import NodeResolver, _link_text, _route_path, highlighted_hash
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..context import AppContext
|
||||
|
||||
#: Seconds between spinner frames while a trace or probe is in flight.
|
||||
_SPINNER_INTERVAL = 0.12
|
||||
|
||||
#: How wide the per-hop SNR quality bars draw, in characters. Each character packs
|
||||
#: two fill steps (see :func:`snr_bar`), so the bar reads at 16-step resolution in
|
||||
#: half the columns a one-step-per-cell block bar would need.
|
||||
@@ -525,7 +522,7 @@ class TraceScreen(Screen):
|
||||
async def _animate(self) -> None:
|
||||
"""Advance the in-flight spinner and repaint on a steady cadence, until cancelled."""
|
||||
while True:
|
||||
await asyncio.sleep(_SPINNER_INTERVAL)
|
||||
await asyncio.sleep(spinner_interval())
|
||||
self._spinner.tick()
|
||||
self._session.invalidate()
|
||||
|
||||
@@ -1534,7 +1531,7 @@ async def _open_session(
|
||||
|
||||
async def animate() -> None:
|
||||
while True:
|
||||
await asyncio.sleep(_SPINNER_INTERVAL)
|
||||
await asyncio.sleep(spinner_interval())
|
||||
spinner.tick()
|
||||
session.invalidate()
|
||||
|
||||
@@ -1807,7 +1804,7 @@ async def _open_session(
|
||||
|
||||
async def animate() -> None:
|
||||
while True:
|
||||
await asyncio.sleep(_SPINNER_INTERVAL)
|
||||
await asyncio.sleep(spinner_interval())
|
||||
spinner.tick()
|
||||
session.invalidate()
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ from rich.console import Group, RenderableType
|
||||
from rich.panel import Panel
|
||||
from rich.text import Text
|
||||
|
||||
from ...platforms import get_platform
|
||||
from ..theme import hint_style, title_style
|
||||
from .glow import apply_corner_glow
|
||||
from .render import render_lines
|
||||
@@ -189,8 +190,14 @@ def compose_base(
|
||||
viewport = max(1, rows - header_h - 1 - 2) # minus footer(1) and panel border(2)
|
||||
panel = _panel(base, cols - 4, viewport, active=True)
|
||||
footer = Text.from_markup(f"[muted]{footer_hint}[/muted]")
|
||||
# The glow pass lights the outer frame *and* any tool panels nested in the body.
|
||||
lines = header_lines + apply_corner_glow(render_lines(Group(panel, footer), cols))
|
||||
# The glow pass lights the outer frame *and* any tool panels nested in the body. It only
|
||||
# ever recolours truecolor foregrounds (see glow._advance_fg), so on a platform without
|
||||
# effects — which is also a platform without truecolor — it would scan every line of
|
||||
# every frame and hand back the identical list. Skipping it outright is the same picture
|
||||
# for none of the work. Read live rather than bound at import: set_platform() runs in the
|
||||
# CLI callback, long after this module is imported (see meshterm.platforms).
|
||||
body = render_lines(Group(panel, footer), cols)
|
||||
lines = header_lines + (apply_corner_glow(body) if get_platform().effects else body)
|
||||
# Guarantee we never exceed the terminal height (pt would otherwise clip unpredictably).
|
||||
if len(lines) > rows:
|
||||
lines = lines[:rows]
|
||||
|
||||
@@ -234,7 +234,15 @@ def _has_wide_glyph(text: str) -> bool:
|
||||
marks (``▲●■``) and chart braille are width-1 everywhere, so they never trip this. The
|
||||
``>= 0x1100`` guard skips the ASCII/Latin bulk of a frame before the width lookup, which
|
||||
matters because this runs over the whole composed frame on every repaint.
|
||||
|
||||
On a platform that draws no emoji the answer is ``False`` by construction — its console
|
||||
font is a fixed 512-glyph set with no wide glyph in it, so nothing a frame can contain
|
||||
would return ``True``. Answering from the platform instead of the text skips a
|
||||
per-character scan of the entire frame on every repaint, and with it the scrub machinery
|
||||
that a ``True`` would arm, leaving the cheap differential paint permanently in play.
|
||||
"""
|
||||
if not get_platform().emoji:
|
||||
return False
|
||||
return any(ord(ch) >= 0x1100 and get_cwidth(ch) == 2 for ch in text)
|
||||
|
||||
|
||||
@@ -1112,7 +1120,9 @@ class TuiSession:
|
||||
key_bindings=self._key_bindings(),
|
||||
full_screen=True,
|
||||
mouse_support=False,
|
||||
refresh_interval=1.0, # keep the live monitor counter in the header ticking
|
||||
# Keeps the live monitor counter in the header ticking. Per-platform, so a host
|
||||
# where an idle repaint is expensive can breathe more slowly between frames.
|
||||
refresh_interval=get_platform().tick_s,
|
||||
input=self._input,
|
||||
output=self._resolve_output(),
|
||||
)
|
||||
|
||||
@@ -13,6 +13,23 @@ from typing import Optional
|
||||
|
||||
from rich.text import Text
|
||||
|
||||
from ...platforms import get_platform
|
||||
|
||||
|
||||
def spinner_interval() -> float:
|
||||
"""Seconds a "working" animation should wait between frames, on this platform.
|
||||
|
||||
The single source of the app's spin cadence — every animated wait sleeps on this rather
|
||||
than on its own constant, so the rate is one platform decision instead of five copies
|
||||
drifting apart. Called at each tick rather than read into a module constant: a constant
|
||||
would freeze whatever platform was active at *import* time, which is always the default
|
||||
(``set_platform`` runs later, in the CLI callback — see :mod:`meshterm.platforms`).
|
||||
|
||||
Returns:
|
||||
The active platform's :attr:`~meshterm.platforms.Platform.spinner_tick_s`.
|
||||
"""
|
||||
return get_platform().spinner_tick_s
|
||||
|
||||
|
||||
class Spinner:
|
||||
"""An animated spinner that cycles through a set of frame glyphs.
|
||||
@@ -26,13 +43,19 @@ class Spinner:
|
||||
#: A plain ASCII cycle for terminals/fonts without Braille glyphs.
|
||||
LINE = "|/-\\"
|
||||
|
||||
def __init__(self, frames: str = BRAILLE, *, style: str = "accent") -> None:
|
||||
def __init__(self, frames: Optional[str] = None, *, style: str = "accent") -> None:
|
||||
"""Create a spinner resting on its first frame.
|
||||
|
||||
Args:
|
||||
frames: The glyphs to cycle through, one per animation frame.
|
||||
frames: The glyphs to cycle through, one per animation frame. Defaults to the
|
||||
active platform's cycle — :data:`BRAILLE` where effects are on, the
|
||||
four-frame :data:`LINE` where they aren't. Resolved here, at construction,
|
||||
so a spinner built after ``set_platform`` picks the right cycle and never
|
||||
re-decides while it spins.
|
||||
style: The Rich style :meth:`text` applies to the current glyph.
|
||||
"""
|
||||
if frames is None:
|
||||
frames = self.BRAILLE if get_platform().effects else self.LINE
|
||||
if not frames:
|
||||
raise ValueError("a spinner needs at least one frame")
|
||||
self._frames = frames
|
||||
|
||||
@@ -46,15 +46,12 @@ from .theme import name_style, snr_style
|
||||
from .trace_screen import TracingDialog, _collapse_trace_width, snr_bar
|
||||
from .tui.render import render_lines, render_to_ansi
|
||||
from .tui.screen import Screen
|
||||
from .tui.spinner import Spinner
|
||||
from .tui.spinner import Spinner, spinner_interval
|
||||
from .widgets import NodeResolver
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..context import AppContext
|
||||
|
||||
#: Seconds between spinner frames while the sweep is measuring.
|
||||
_SPINNER_INTERVAL = 0.12
|
||||
|
||||
#: Human phrasing for each optimizer phase reported through ``on_phase``.
|
||||
_PHASE_LABELS = {
|
||||
"coarse": "coarse sweep",
|
||||
@@ -963,7 +960,7 @@ async def _animate(
|
||||
) -> None:
|
||||
"""Advance the in-flight dialog's spinner and status on a steady cadence."""
|
||||
while True:
|
||||
await asyncio.sleep(_SPINNER_INTERVAL)
|
||||
await asyncio.sleep(spinner_interval())
|
||||
spinner.tick()
|
||||
flight.status = screen.phase_label()
|
||||
session.invalidate()
|
||||
Reference in new issue
Block a user