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

Function detectGeometryShift

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

Source from the content-addressed store, hash-verified

336}
337
338function detectGeometryShift(frames: SwitchFrameSample[]) {
339 const anchorIndex = frames.findIndex((frame) => frame.containsTargetMarker);
340 if (anchorIndex === -1) return [];
341 const anchor = frames[anchorIndex];
342 const props: Array<
343 keyof Pick<
344 SwitchFrameSample,
345 "messageWindowTop" | "messageWindowHeight" | "scrollTop" | "chatInputHeight"
346 >
347 > = ["messageWindowTop", "messageWindowHeight", "scrollTop", "chatInputHeight"];
348 const shifts = [] as Array<{ frame: number; property: string; delta: number }>;
349 for (const frame of frames.slice(anchorIndex + 1)) {
350 if (!frame.containsTargetMarker) continue;
351 for (const prop of props) {
352 const a = anchor[prop];
353 const b = frame[prop];
354 if (a == null || b == null) continue;
355 const delta = b - a;
356 if (Math.abs(delta) > 1) shifts.push({ frame: frame.frame, property: prop, delta });
357 }
358 }
359 return shifts;
360}
361
362async function computeDiffRatio(leftPng: Buffer, rightPng: Buffer): Promise<number> {
363 const [left, right] = await Promise.all([

Callers 1

mainFunction · 0.85

Calls 2

absMethod · 0.80
pushMethod · 0.65

Tested by

no test coverage detected