fix(tui): graph metrics panel always showing zero (#1938)#1943
Merged
Conversation
Two root causes fixed: 1. App::with_metrics_rx() now eagerly reads the initial MetricsSnapshot via rx.borrow().clone(). Previously has_changed() returned false for the initial watch channel value, causing poll_metrics() to skip it on the first poll. 2. spawn_graph_extraction() now returns JoinHandle<()>. A follow-up fire-and-forget spawn in persistence.rs awaits the handle, then re-reads entity/edge/community counts from the DB and pushes them via metrics_tx — replacing the stale-zero sync that ran before the extraction task completed. Adds regression test: with_metrics_rx_reads_initial_value.
73a93a9 to
48f00e7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
App::with_metrics_rx()now eagerly reads the initialMetricsSnapshotviarx.borrow().clone()— fixes the startup case wherehas_changed()returnsfalsefor the initial watch channel value, causingpoll_metrics()to skip itspawn_graph_extraction()returnsJoinHandle<()>; a follow-up fire-and-forget spawn awaits the handle, then re-reads counts from the DB and pushes them viametrics_tx— fixes stale-zero reads that occurred before the fire-and-forget extraction task finishedwith_metrics_rx_reads_initial_valueCloses #1938
Test plan
cargo +nightly fmt --check— passescargo clippy --features full --workspace -- -D warnings— passescargo nextest run --workspace --features full --lib --bins— 6118 passed (+1 new regression test)