MCPcopy
hub / github.com/coder/mux / detectVisualInstability

Function detectVisualInstability

scripts/reproWorkspaceSwitchTearWeb.ts:380–395  ·  view source on GitHub ↗
(frames: SwitchFrameSample[])

Source from the content-addressed store, hash-verified

378}
379
380async function detectVisualInstability(frames: SwitchFrameSample[]) {
381 const anchorIndex = frames.findIndex((frame) => frame.containsTargetMarker);
382 if (anchorIndex === -1) return [];
383 const diffs = [] as Array<{ fromFrame: number; toFrame: number; ratio: number }>;
384 for (let index = anchorIndex; index < frames.length - 1; index++) {
385 const current = frames[index];
386 const next = frames[index + 1];
387 if (!current.containsTargetMarker || !next.containsTargetMarker) continue;
388 diffs.push({
389 fromFrame: current.frame,
390 toFrame: next.frame,
391 ratio: await computeDiffRatio(current.png, next.png),
392 });
393 }
394 return diffs.filter((diff) => diff.ratio > 0.01);
395}
396
397function stripPng(frames: SwitchFrameSample[]) {
398 return frames.map(({ png, ...rest }) => rest);

Callers 1

mainFunction · 0.85

Calls 2

computeDiffRatioFunction · 0.85
pushMethod · 0.65

Tested by

no test coverage detected