Skip to content

qauld-ctl tui Refactor: qauld tui async refresh (without demo script) - #935

Merged
MathJud merged 1 commit into
mainfrom
refactor/qauld-tui-async-refresh-without-demo
Aug 5, 2026
Merged

qauld-ctl tui Refactor: qauld tui async refresh (without demo script)#935
MathJud merged 1 commit into
mainfrom
refactor/qauld-tui-async-refresh-without-demo

Conversation

@MathJud

@MathJud MathJud commented Aug 5, 2026

Copy link
Copy Markdown
Member

TUI changes of #929 without the demo script

Polling used to run inline in the render loop's select tick — 8 RPCs awaited sequentially, freezing input/redraws while they ran and up to ~40s/cycle if the daemon was unreachable. Move polling to a background task: refresh_once fans the fetches out concurrently (one round-trip's latency, not eight) and posts a Send-able Snapshot to the loop, which applies it synchronously. No network .await anywhere in the loop. r and post-feed-send just fire a trigger.

Crypto events now dedup through one path (the poll floor lives with the task), so poll/push overlaps and the daemon's inclusive since_ms re-sends are dropped. Three new dedup unit tests.

The refresh cycle used to run inline in the render loop's tokio::select
tick arm: eight RPCs awaited one after another, each on a fresh socket.
While it ran, no keystrokes or redraws were processed — and if the
daemon was slow or unreachable, the loop froze for up to (8 fetches x
timeout) per cycle (~40s at the 5s default), making the whole UI feel
dead.

Move polling into a dedicated background task:

- data::refresh_once fans the fetches out concurrently (tokio::join!)
  after resolving the default user first (the DTN fetches need its id),
  so a cycle costs one round-trip's latency instead of the sum of
  eight. It returns a Send-able Snapshot (Result<_, String> fields).
- The task loops on an interval (first tick immediate → non-blocking
  prime) plus a manual-trigger channel, and posts each Snapshot to the
  render loop over an mpsc.
- The render loop's select now has a snapshot arm that calls the pure,
  synchronous apply_snapshot — no .await on network anywhere in the
  loop. 'r' and post-feed-send just fire the trigger.

Crypto-event dedup: the poll floor now lives with the task (sole owner
of the poll path), so the daemon's inclusive since_ms filter re-sends
the boundary event each cycle. append_crypto_events now routes every
event through the same dedup as the push path (merge_crypto_event), so
poll/push overlaps and boundary re-sends are dropped without the two
paths sharing a floor.

Tests: three append_crypto_events dedup cases (boundary re-send,
push/poll overlap, distinct-same-timestamp). Verified live against two
daemons — 22/22 feature checks still pass — plus a daemon-death probe:
with every fetch hitting the 5s timeout, tab switches still register in
~50ms (identical to daemon-alive), where the old design would have
frozen for up to 40s.
@MathJud
MathJud force-pushed the refactor/qauld-tui-async-refresh-without-demo branch from 8bd187b to c4a574a Compare August 5, 2026 14:40
@sonarqubecloud

sonarqubecloud Bot commented Aug 5, 2026

Copy link
Copy Markdown

@MathJud
MathJud merged commit 524adc6 into main Aug 5, 2026
3 of 4 checks passed
@MathJud
MathJud deleted the refactor/qauld-tui-async-refresh-without-demo branch August 5, 2026 14:45
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants