Skip to content

feat: change auto-refresh interval with pause/play toggle#168

Merged
rajsinghtech merged 3 commits intorajsinghtech:mainfrom
cmmattson:fix/auto-refresh-ux
Apr 16, 2026
Merged

feat: change auto-refresh interval with pause/play toggle#168
rajsinghtech merged 3 commits intorajsinghtech:mainfrom
cmmattson:fix/auto-refresh-ux

Conversation

@cmmattson
Copy link
Copy Markdown
Contributor

Problem

On larger tailnets (100+ nodes, 300+ flows), the hardcoded 60-second auto-refresh interval causes the network graph
to reset too frequently. Each refresh triggers a full ELK re-layout which destroys and rebuilds the entire
SvelteFlow component, resetting the user's viewport (zoom/pan position). This makes the graph essentially unusable
for exploration on busy networks.

Solution

Two targeted changes:

  1. Increase the default auto-refresh interval from 60s to 5 minutes — gives users time to explore the graph
    between refreshes
  2. Add a pause/play toggle — lets users stop auto-refresh entirely while investigating

I experimented with preserving node dimensions between refreshes, but it led to some unintended behavior and overlaps. I'll revisit this later.

Changes (5 files, +37/-15 lines)

File Change
network-store.ts Add AUTO_REFRESH_INTERVAL constant (300s), toggleAutoRefresh() function
stores/index.ts Export new symbols
+page.svelte Use centralized interval, add P keyboard shortcut
Header.svelte Add Pause/Play button (replaces ping indicator on refresh button)
TimelineSlider.svelte Use AUTO_REFRESH_INTERVAL instead of hardcoded 60_000

UI

  • Pause button in header when auto-refresh is active
  • Play button when paused
  • P keyboard shortcut toggles pause/play
  • R / Refresh button still triggers immediate manual refresh regardless of pause state
  • Auto-refresh still pauses in historical mode and resumes on switch to live

No breaking changes

  • The interval is a single constant — easy to adjust
  • All existing functionality (manual refresh, historical mode, timeline slider) unchanged
  • NetworkGraph component is completely untouched

cmmattson and others added 3 commits April 15, 2026 10:36
- Increase auto-refresh interval from 60s to 5min (300s)
- Add pause/play toggle button in header (P keyboard shortcut)
- Centralize refresh interval constant across all callsites
- Keep SvelteFlow mounted during layout recalculations to preserve
  viewport pan/zoom state across data refreshes
- Use node-only topology key so edge churn doesn't trigger re-layout
- Preserve existing node positions on incremental topology changes
- Add layout versioning to prevent stale async results from applying
- Show non-destructive overlay indicator during layout updates

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When SvelteFlow stays mounted across refreshes (our viewport
preservation change), xyflow's internal ResizeObservers don't re-fire
for existing DOM elements. This means new node objects without
measured/width/height cause nodeHasDimensions() to return false,
making the MiniMap render empty.

Fix: capture existing node state (measured, width, height) from the
flow store before creating replacement nodes, and carry these
properties forward in all code paths (ELK layout, merge, removal,
fallback).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Reverts all NetworkGraph.svelte changes (viewport preservation, layout
versioning, topology key, conditional rendering) back to upstream.

Remaining changes:
- Auto-refresh interval increased from 60s to 5 minutes
- Pause/Play toggle button in header (+ P keyboard shortcut)
- Centralized AUTO_REFRESH_INTERVAL constant
- TimelineSlider uses centralized interval

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rajsinghtech
Copy link
Copy Markdown
Owner

Thank you!

@rajsinghtech rajsinghtech merged commit 27b5d08 into rajsinghtech:main Apr 16, 2026
3 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.

2 participants