Skip to content

Fix screenshot support: schema, file filtering, and step numbering - #19

Merged
Niels Laute (niels9001) merged 4 commits into
mainfrom
niels9001/screenshot
Apr 8, 2026
Merged

Fix screenshot support: schema, file filtering, and step numbering#19
Niels Laute (niels9001) merged 4 commits into
mainfrom
niels9001/screenshot

Conversation

@niels9001

@niels9001 Niels Laute (niels9001) commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Three follow-up fixes to the screenshot support feature:

  • gallery.schema.json — Created the missing .github/schemas/gallery.schema.json that generate.py and extensions.json already referenced via $schema/GALLERY_SCHEMA_URL. Includes screenshotUrls (optional, max 5 URIs) alongside all existing gallery entry fields.

  • generate.pydiscover_screenshots() hardening

    • Filter entries with os.path.isfile() to skip directories that happen to have image-like names
    • Sort inline via sorted(os.listdir(...)) and cap with [:MAX_SCREENSHOTS] (new constant, mirrors validate.py)
  • validate.py — step numbering — Renumbered # 9# 8 and # 10# 9 to close the gap left by missing step 8.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for optional extension screenshots by validating screenshots/ folders during submission checks and emitting screenshotUrls in the generated gallery output so the Command Palette app (and gallery consumers) can display preview images.

Changes:

  • Add screenshot discovery in .github/scripts/generate.py and emit screenshotUrls into extensions.json.
  • Add optional screenshots/ folder validation (type/count/size) in .github/scripts/validate.py.
  • Document the screenshot folder structure/rules in docs/CONTRIBUTING.md and docs/ARCHITECTURE.md, and regenerate extensions.json to include screenshots for one extension.

Reviewed changes

Copilot reviewed 5 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
extensions.json Regenerated gallery metadata/entries; adds screenshotUrls for nielslaute.event-viewer.
docs/CONTRIBUTING.md Adds contributor-facing guidance and rules for screenshots.
docs/ARCHITECTURE.md Updates repo layout and generation/validation notes to include screenshots.
.github/scripts/validate.py Validates optional screenshots/ folder (extensions, max count, max size).
.github/scripts/generate.py Discovers screenshot images and emits screenshotUrls into gallery entries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/scripts/generate.py
Comment on lines +86 to +97
filenames = []
for name in os.listdir(screenshots_dir):
ext = os.path.splitext(name)[1].lower()
if ext in VALID_SCREENSHOT_EXTENSIONS:
filenames.append(name)

filenames.sort()

return [
f"{BASE_RAW_URL}/extensions/{author}/{ext_name}/screenshots/{name}"
for name in filenames
]

Copilot AI Apr 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discover_screenshots() uses os.listdir() and only filters by extension, so it can accidentally include non-file entries (e.g., a directory named foo.png) and it will include more than the documented max of 5 screenshots if validation is skipped. Consider filtering with os.path.isfile(...) and defensively capping the returned list (e.g., first 5 after sorting) to match the documented/validated limits.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot apply the suggestion

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot fix the comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit ac2c7da. discover_screenshots() now uses sorted(os.listdir(...)) with an os.path.isfile() guard and slices to MAX_SCREENSHOTS (5) before building URLs.

Comment thread docs/CONTRIBUTING.md Outdated
Comment thread .github/scripts/validate.py Outdated
Comment on lines +248 to +249
# 10. Screenshots validation (optional folder)
screenshots_dir = folder / "screenshots"

Copilot AI Apr 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The section comment here is labeled # 10, but earlier validation steps skip numbers (e.g., it jumps from # 7 to # 9). Consider renumbering these step comments to be sequential so future contributors can keep the docs/checklist aligned with the code more easily.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot use the correct numbering

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit ac2c7da. Renumbered # 9# 8 and # 10# 9 so the steps are sequential (1–9).

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI changed the title Adding screenshot support Add gallery.schema.json to fix broken schema URL reference Apr 8, 2026
Copilot AI changed the title Add gallery.schema.json to fix broken schema URL reference Fix screenshot support: schema, file filtering, and step numbering Apr 8, 2026
@niels9001
Niels Laute (niels9001) merged commit b5cdb97 into main Apr 8, 2026
2 checks passed
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.

4 participants