Skip to content

[feat] fix stale graph nodes and minimap viewport mapping#81

Merged
lowhung merged 2 commits into
mainfrom
lowhung/fix-stale-graph-and-minimap
Feb 23, 2026
Merged

[feat] fix stale graph nodes and minimap viewport mapping#81
lowhung merged 2 commits into
mainfrom
lowhung/fix-stale-graph-and-minimap

Conversation

@lowhung

@lowhung lowhung commented Feb 23, 2026

Copy link
Copy Markdown
Owner

Summary

This fixes two user-visible correctness issues in graph lifecycle and minimap viewport mapping.

When snapshots dropped modules, the graph retained stale nodes indefinitely. This caused the UI to display modules that no longer existed in the live stream and could also keep stale rate-tracker state around for removed node pairs.

Separately, the minimap viewport rectangle used an incorrect inverse transform from screen space to world space. The previous code subtracted pan directly without accounting for zoom, so the minimap rectangle drifted from the true viewport position whenever zoom was not 1.0.

Root Cause

The graph update path incrementally updated/added nodes but never removed missing ones, while edges were rebuilt each frame. That made node lifetime additive instead of snapshot-consistent.

The minimap conversion inverted world_to_screen incorrectly by omitting division by zoom in the pan term.

Fix

  • Reworked MessageFlowGraph::update_from_snapshot to rebuild a fresh graph/module index from each snapshot, ensuring only current modules exist.
  • Added rate-tracker pruning for modules no longer present to avoid stale edge-rate memory.
  • Corrected minimap viewport center conversion with pan / zoom and extracted a helper for focused testing.
  • Added regression tests for:
    • Removing modules absent from subsequent snapshots.
    • Minimap viewport world-center mapping under non-unit zoom.

Validation

  • cargo test (all tests passing)

@lowhung lowhung marked this pull request as ready for review February 23, 2026 16:38
@lowhung lowhung force-pushed the lowhung/fix-stale-graph-and-minimap branch from 8709fc6 to b33a71e Compare February 23, 2026 16:47
@lowhung lowhung merged commit 5a62fb3 into main Feb 23, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant