Metadata
| Status | done |
|---|---|
| Assigned | agent-1083 |
| Agent identity | f51439356729d112a6c404803d88015d5b44832c6c584c62b96732b63c2b0c7e |
| Created | 2026-04-29T11:50:30.391818088+00:00 |
| Started | 2026-04-29T12:14:46.828449820+00:00 |
| Completed | 2026-04-29T12:15:34.462675401+00:00 |
| Tags | eval-scheduled |
| Eval score | 0.52 |
| └ blocking impact | 0.35 |
| └ completeness | 0.45 |
| └ coordination overhead | 0.45 |
| └ correctness | 0.60 |
| └ downstream usability | 0.50 |
| └ efficiency | 0.75 |
| └ intent fidelity | 0.84 |
| └ style adherence | 0.65 |
Description
Description
Per diagnose-wg-tui findings (artifact: .wg/output/diagnose-wg-tui/findings.md):
render::draw_chat_tab (src/tui/viz_viewer/render.rs:3054-3055) calls
app.active_tab_ids_and_labels() and app.list_user_board_entries() on every redraw.
Both helpers internally call workgraph::parser::load_graph(graph_path) (state.rs:13362
and :13470), so each redraw fully JSON-deserializes a 2.19 MB / 683-task graph TWICE.
With chat tab active and any animation/streaming, the adaptive poll runs at 50-200 ms
(state.rs:7212), producing 10-40 graph reloads/second. Perf profile attributes ~55% of
CPU to serde_json deserialize + matching malloc/free/BTreeMap allocator churn
driven by these reloads.
Implementation (priority 1 from findings.md)
- Add cached fields to
VizAppinsrc/tui/viz_viewer/state.rs:cached_chat_tab_entries: Vec<(u32, String)>cached_user_board_entries: Vec<(String, String)>
- Add
&Graph-taking variants of the three helpers (or make them inherent on&Graph):list_coordinator_ids_and_labels(state.rs:13360)list_user_board_entries(state.rs:13468)live_chat_count(state.rs:13344)
- In
maybe_refresh()(state.rs:6772), at the existingif let Ok(graph) = load_graph(...)block (state.rs:7035), populate the cached fields from&graphwhenever the graph reloads. Also populate inside the fs-watcher fast-path block atstate.rs:6809. - Replace the two render.rs:3054-3055 calls with reads of the cached fields. Also audit
list_coordinator_idscallers in render and event paths to use the cache. - Optional but recommended: cache the loaded
Graphitself onVizAppand make the other ~22load_graphcallsites insrc/tui/viz_viewer/state.rsreuse it (seeperf-callgraph.txtfor the call list).
Validation
-
Failing test or benchmark first: open
wg tuiagainst a graph with 500+ tasks, switch to chat tab, captureperf record -F 99for 20s. Before fix: serde_json + libc allocator symbols dominate. After fix: those drop below 1% on idle. -
cargo buildandcargo testpass with no regressions -
Manual smoke:
wg tui, chat tab visible, idle for 30s —topshould show <5% CPU -
No regression in tab-bar correctness: creating a new chat (
wg addwith chat-loop tag), archiving a chat, and abandoning a chat all reflect immediately in the tab bar - Verify against fix-pty-scrollback: if duplication symptom disappears after this fix, mark fix-pty-scrollback as duplicate; otherwise it has its own root cause and stays open
Files (estimated scope)
src/tui/viz_viewer/state.rs— VizApp fields, helper signatures, maybe_refresh wiringsrc/tui/viz_viewer/render.rs— replace lines 3054-3055 with cache reads
Depends on
Required by
- (none)
Log
- 2026-04-29T11:54:01.801838326+00:00 Lightweight assignment: agent=Careful Programmer (f5143935), exec_mode=full, context_scope=task, reason=Careful Programmer is the only agent with code-implementation capability; Careful tradeoff ensures precise caching logic and rigorous benchmark validation required for performance-critical optimization.
- 2026-04-29T11:54:03.308664760+00:00 Spawned by coordinator --executor claude --model opus
- 2026-04-29T11:54:11.026831800+00:00 Starting work on fix-wg-tui — caching graph reads in TUI to fix 55% CPU
- 2026-04-29T12:13:15.010722789+00:00 Implemented cache: cached_chat_tab_entries + cached_user_board_entries + cached_coordinator_id_set on VizApp. Refreshed in maybe_refresh (3 graph-load points), force_refresh, and constructor. Render reads cache (no per-frame load_graph). active_tabs mutations (close_tab, sync_active_tabs_from_graph) trigger cheap in-memory cache rebuild.
- 2026-04-29T12:13:19.732969185+00:00 cargo build: clean. cargo install --path .: replaced binary in ~/.cargo/bin. cargo test --bin wg blocked by 2 pre-existing main-branch compile errors (setup.rs api_key_ref, ResumeConfig missing fields) — both unrelated to fix-wg-tui.
- 2026-04-29T12:14:38.877738451+00:00 Task unclaimed: agent 'agent-1080' (PID 2584062) process exited
- 2026-04-29T12:14:46.828456082+00:00 Spawned by coordinator --executor claude --model opus
- 2026-04-29T12:15:22.026857841+00:00 Committed: 9873dce6e — pushed to origin/wg/agent-1080/fix-wg-tui
- 2026-04-29T12:15:34.462678917+00:00 Task pending eval (agent reported done; awaiting `.evaluate-*` to score)
- 2026-04-29T12:17:49.383173668+00:00 PendingEval → Done (evaluator passed; downstream unblocks)