Skip to content

Support media gallery - #2

Merged
freekh merged 6 commits into
mainfrom
support-media-gallery
Jun 8, 2026
Merged

Support media gallery#2
freekh merged 6 commits into
mainfrom
support-media-gallery

Conversation

@freekh

@freekh freekh commented May 18, 2026

Copy link
Copy Markdown
Contributor

No description provided.

freekh added 4 commits May 18, 2026 21:17
- Add `addToMediaGallery` command to insert media entries into gallery modules.
- Introduce `moveFileToGalleryDirectory` command to relocate files into the appropriate gallery directory.
- Create `findMediaGalleryIssues` function to validate media references against gallery schemas.
- Implement tests for gallery entry generation and insertion logic.
- Enhance completion providers to filter and provide context for media files based on gallery status.
- Update server to include media gallery validation diagnostics in document validation process.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds media gallery awareness to the Val VS Code extension/language server, including diagnostics + quick-fixes for unregistered gallery items and improved path completions scoped to a referenced gallery.

Changes:

  • Add server-side validation to detect when c.image/c.file references a media gallery but the referenced asset is not registered or not in the gallery directory.
  • Add client quick-fixes to (a) insert a metadata entry into the gallery module and (b) move an asset into the configured gallery directory and update references.
  • Improve completion providers by resolving the schema at the cursor’s field-path (including richtext href) and filtering image/file path completions to the referenced gallery directory.

Reviewed changes

Copilot reviewed 14 out of 17 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
server/src/server.ts Runs new media gallery validation and emits LSP diagnostics with fix data.
server/src/metadataUtils.ts Adjusts image-size input type for updated dependency behavior.
server/src/metadataUtils.test.ts Updates tests to match new image-size input handling.
server/src/mediaGalleryValidation.ts Implements (source,schema) walker to produce media gallery diagnostics.
server/src/mediaGalleryValidation.test.ts Adds tests for the media gallery diagnostics walker.
server/src/completionProviders.ts Uses field-path schema resolution; filters file/image completions to referenced gallery directory.
server/src/completionFieldSchema.ts New helpers to derive field paths from AST and resolve schema at that path (incl. richtext href).
server/src/completionFieldSchema.test.ts Adds unit tests for schema resolution helpers.
server/package.json Bumps @valbuild/* dependencies to versions that support media gallery behavior.
server/package-lock.json Lockfile updates from dependency bumps (incl. transitive deps).
package-lock.json Root lockfile version bump.
client/src/extension.ts Registers new commands and adds quick-fix actions for media gallery diagnostics.
client/src/commands/moveFileToGalleryDirectory.ts New command to move an asset into the gallery directory and update the reference.
client/src/commands/addToMediaGallery.ts New command to insert a gallery entry with inferred metadata into the referenced gallery module.
client/src/commands/addToMediaGallery.test.ts Unit tests for helper functions used by the gallery insertion command.
client/package.json Bumps @valbuild/core to match server/core expectations.
client/package-lock.json Lockfile updates for client dependency bump.
Files not reviewed (2)
  • client/package-lock.json: Language not supported
  • server/package-lock.json: Language not supported
Comments suppressed due to low confidence (1)

client/src/commands/addToMediaGallery.ts:177

  • getImageMetadata/getFileMetadata ultimately call path.join(rootPath, relativePath) (client/src/metadataUtils.ts). If data.path is a Val-style path starting with /public/..., path.join treats it as absolute and ignores rootPath, so metadata lookup will likely fail. Consider stripping the leading / (for FS resolution only) or updating metadataUtils to treat leading-slash Val paths as project-root relative.
  const mediaType = data.mediaType ?? "images";
  const rawMetadata =
    mediaType === "images"
      ? getImageMetadata(data.path, uri)
      : getFileMetadata(data.path, uri);
  const metadata = stripAlt(rawMetadata as Record<string, string | number>);
  if (Object.keys(metadata).length === 0) {
    vscode.window.showErrorMessage(
      `Could not read metadata for ${data.path}. Make sure the file exists at ${path.join(valRoot, ...data.path.split("/"))}.`,
    );

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

Comment thread client/src/commands/moveFileToGalleryDirectory.ts Outdated
Comment thread client/src/commands/addToMediaGallery.ts Outdated
Comment thread server/src/mediaGalleryValidation.ts Outdated
Comment thread server/src/server.ts Outdated
Comment thread server/package.json
freekh added 2 commits May 24, 2026 19:59
… modulePathMap

- Validate that paths from .val source stay inside the project root before
  any fs operation in addToMediaGallery / moveFileToGalleryDirectory.
- Use FILE_REF_PROP instead of the literal "_ref" in media gallery diagnostics.
- Hoist modulePathMap so it's computed once per validate pass instead of twice.
- Tighten server engines.node to >=20.19.0 to match chokidar v5.
@freekh
freekh merged commit c38d418 into main Jun 8, 2026
1 check passed
@freekh
freekh deleted the support-media-gallery branch July 31, 2026 12:37
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.

2 participants