Skip to content

feat(cli): shared page session #76

@nucliweb

Description

@nucliweb

Problem

When the decision tree fires a follow-up snippet (e.g. LCP-Subparts when LCP > 2.5s), the runner closes and relaunches the browser, re-navigating the page. This wastes time and risks different results across measurements.

Current flow

launch browser → navigate → evaluate [LCP, CLS] → close browser
  → launch browser → navigate → evaluate [LCP-Subparts] → close browser

Proposed flow

launch browser
  → navigate + waitMs
  → evaluate initial steps [LCP, CLS]
  → apply nextSteps(results) → follow-up items
  → evaluate follow-ups [LCP-Subparts] in same page (no re-navigation)
  → close browser
  → return { url, navMs, results: [...initial, ...followUps], pageErrors }

Implementation

runner.js current signature:

export async function runSnippets({ url, items, waitMs, headless, viewport })

New signature:

export async function runMeasurement({ url, workflow, rules, waitMs, headless, viewport })

Where rules is the array from decision-tree.js. The runner applies nextSteps() internally after the first round, within the same browser session.

Files

  • cli/src/runner.js — main refactor
  • cli/src/bin.js — update call site

Acceptance criteria

  • LCP + LCP-Subparts complete with a single navigation
  • Follow-up snippets run against the same page state as initial snippets
  • Existing tests pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    cliCLI packageenhancementNew feature or requestv0.2Milestone v0.2

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions