Skip to content

Commit b28747d

Browse files
fix(cli): respect timeline-free static compositions (#3533)
1 parent af1cb1c commit b28747d

4 files changed

Lines changed: 26 additions & 0 deletions

File tree

‎packages/cli/src/commands/check.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ function fakeDriver(overrides: Partial<CheckAuditDriver> = {}): CheckAuditDriver
145145
return {
146146
initialize: vi.fn(async (_contrast: boolean) => undefined),
147147
getDuration: vi.fn(async () => 9),
148+
hasNoTimelineDeclaration: vi.fn(async () => false),
148149
getTransitionBoundaries: vi.fn(async () => []),
149150
getCanvas: vi.fn(async () => ({ width: 1920, height: 1080 })),
150151
findAmbiguousSelectors: vi.fn(async (_selectors: string[]) => []),
@@ -1222,6 +1223,18 @@ describe("check pipeline", () => {
12221223
).toBe(true);
12231224
});
12241225

1226+
it("does not flag intentional static content declared with data-no-timeline", async () => {
1227+
const driver = fakeDriver({
1228+
getDuration: vi.fn(async () => 6),
1229+
hasNoTimelineDeclaration: vi.fn(async () => true),
1230+
collectLayoutGeometry: vi.fn(async () => "frozen"),
1231+
});
1232+
1233+
const { report } = await runScenario(driver);
1234+
1235+
expect(report.layout.findings.some((finding) => finding.code === "sweep_static")).toBe(false);
1236+
});
1237+
12251238
it("does not flag a 1.5s static title card — too short for the guard to apply", async () => {
12261239
const driver = fakeDriver({
12271240
getDuration: vi.fn(async () => 1.5),

‎packages/cli/src/utils/checkBrowser.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ function createPageDriver(page: Page, setTime: (time: number) => void): CheckAud
395395
return {
396396
initialize: (contrast) => injectAuditScripts(page, contrast),
397397
getDuration: () => getCompositionDuration(page),
398+
hasNoTimelineDeclaration: () => hasNoTimelineDeclaration(page),
398399
getTransitionBoundaries: () => collectTweenBoundaries(page),
399400
getCanvas: () =>
400401
page.evaluate(() => ({ width: window.innerWidth, height: window.innerHeight })),
@@ -420,6 +421,13 @@ function createPageDriver(page: Page, setTime: (time: number) => void): CheckAud
420421
};
421422
}
422423

424+
async function hasNoTimelineDeclaration(page: Page): Promise<boolean> {
425+
return page.evaluate(
426+
() =>
427+
document.querySelector("[data-composition-id]")?.hasAttribute("data-no-timeline") ?? false,
428+
);
429+
}
430+
423431
async function injectAuditScripts(page: Page, contrast: boolean): Promise<void> {
424432
await page.addScriptTag({ content: loadBrowserScript("layout-audit.browser.js") });
425433
await page.addScriptTag({ content: loadBrowserScript("motion-sample.browser.js") });

‎packages/cli/src/utils/checkPipeline.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,9 @@ function detectSweepStatic(
492492
duration: number,
493493
geometrySignatures: string[],
494494
motionIssues: AnchoredLayoutIssue[],
495+
hasNoTimelineDeclaration: boolean,
495496
): AnchoredLayoutIssue[] {
497+
if (hasNoTimelineDeclaration) return [];
496498
if (duration < SWEEP_STATIC_MIN_DURATION_SEC) return [];
497499
if (geometrySignatures.length < 2) return [];
498500
if (motionIssues.some((issue) => issue.code === "motion_frozen")) return [];
@@ -1071,6 +1073,7 @@ export async function runAuditGrid(
10711073
grid.duration,
10721074
collected.geometrySignatures,
10731075
motionIssues,
1076+
await driver.hasNoTimelineDeclaration(),
10741077
);
10751078
const rotationFindings = detectRotationPivotDrift(
10761079
collected.rotationSamples,

‎packages/cli/src/utils/checkTypes.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ export type MotionSpecResolution =
179179
export interface CheckAuditDriver {
180180
initialize(contrast: boolean): Promise<void>;
181181
getDuration(): Promise<number>;
182+
/** True when the root composition explicitly declares that it is intentionally timeline-free. */
183+
hasNoTimelineDeclaration(): Promise<boolean>;
182184
getTransitionBoundaries(): Promise<number[]>;
183185
getCanvas(): Promise<Canvas>;
184186
findAmbiguousSelectors(selectors: string[]): Promise<AnchoredLayoutIssue[]>;

0 commit comments

Comments
 (0)