MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / liveRefresh

Function liveRefresh

ui/src/lib/live.svelte.ts:355–380  ·  view source on GitHub ↗
(
  file: () => string | null,
  refresh: (reason: 'index' | 'disk') => void
)

Source from the content-addressed store, hash-verified

353 * Must be called during component initialisation (it creates an `$effect`).
354 */
355export function liveRefresh(
356 file: () => string | null,
357 refresh: (reason: 'index' | 'disk') => void
358): void {
359 let seenIndex = indexTick;
360 let seenDisk = diskTick;
361 $effect(() => {
362 const index = live.indexTick;
363 const disk = live.diskTick;
364 const path = file();
365 untrack(() => {
366 if (index !== seenIndex) {
367 seenIndex = index;
368 // An index event supersedes any disk event before it: the sync that
369 // just landed is what those edits became.
370 seenDisk = disk;
371 refresh('index');
372 return;
373 }
374 if (disk !== seenDisk) {
375 seenDisk = disk;
376 if (touchesFile(path)) refresh('disk');
377 }
378 });
379 });
380}

Callers

nothing calls this directly

Calls 2

touchesFileFunction · 0.85
fileFunction · 0.50

Tested by

no test coverage detected