Skip to content

feat: smart default snapshot scoping to main content area#62

Merged
avifenesh merged 6 commits intomainfrom
feature/smart-default-snapshot-scoping-45
Feb 24, 2026
Merged

feat: smart default snapshot scoping to main content area#62
avifenesh merged 6 commits intomainfrom
feature/smart-default-snapshot-scoping-45

Conversation

@avifenesh
Copy link
Collaborator

Summary

  • Snapshots now auto-scope to <main> element (then [role="main"], fallback to <body>), reducing output size by excluding navigation, headers, and footers
  • Added --snapshot-full flag to bypass auto-detection and capture full page body
  • --snapshot-selector still takes priority over auto-detection
  • Uses Promise.all() to parallelize DOM queries for minimal performance overhead

Test Plan

  • 417 tests passing (10 new tests added)
  • detectMainContent unit tests: main tag, role attr, both present, neither, error fallback
  • getSnapshot auto-scoping tests: auto-scope, snapshotFull bypass, snapshotSelector priority, selector+full interaction, full+transforms
  • parseOptions tests for --snapshot-full flag
  • Source assertion tests for flag and function existence

Related Issues

Closes #45

Add detectMainContent() helper that tries <main>, then [role="main"],
then falls back to <body>. Snapshots now default to the main content
area instead of the full page body, reducing noise from nav/footer.

Add --snapshot-full flag to bypass auto-detection when full page body
is needed.
Update replicated getSnapshot to use detectMainContent for main-area
auto-detection. Update existing body-default mocks to handle the new
detection flow. Add detectMainContent unit tests (main tag, role attr,
body fallback, error fallback) and getSnapshot auto-scoping tests
(auto-scope, snapshotFull bypass, snapshotSelector priority).
…nContent

Verify --snapshot-full is in BOOLEAN_FLAGS, help text documents the
flag, and detectMainContent function exists in web-ctl.js source.
Update replicated BOOLEAN_FLAGS to stay in sync with source.
Add auto-scoping behavior explanation to SKILL.md Snapshot Control
section. Add --snapshot-full subsection with usage examples. Add
--snapshot-full example to command reference quick reference.
… review tests

Use Promise.all() for main/role count checks. Add tests for flag
priority (selector > full), both-exist priority, and parseOptions.
@avifenesh avifenesh merged commit 97b785a into main Feb 24, 2026
2 of 3 checks passed
@avifenesh avifenesh deleted the feature/smart-default-snapshot-scoping-45 branch February 24, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Smart default snapshot scoping to main content area

1 participant