Conversation
…S fallback, duplicate requests Co-authored-by: numbers-official <181934381+numbers-official@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [Feature] Fix media-viewer component deficiencies
Fix media-viewer: src reactivity, error state, configurable alt, CORS fallback, duplicate fetches
Mar 17, 2026
Contributor
numbers-official
left a comment
There was a problem hiding this comment.
Automated Code Review (Heartbeat Deep Check)
Reviewed 2 files changed (src/media-viewer/media-viewer.ts, src/media-viewer/media-viewer-styles.ts). No regression risks, bugs, or security concerns found.
Review Notes
- Reactivity fix: The
updated()lifecycle hook correctly resets state and re-fetches whensrcchanges, preventing stale renders. - Duplicate fetch guard:
_fetchingFortracking prevents concurrent fetches for the same URL — well handled. - CORS fallback: Extension-based MIME detection is a pragmatic fallback when HEAD requests fail due to CORS. Reasonable tradeoff.
- Error state: New
_errorstate with UI feedback and custom event dispatch is clean. - Configurable alt: Making the alt attribute a property with a sensible default improves accessibility.
LGTM from automated review — still requires human approval before merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
<media-viewer>had several deficiencies: no re-fetch whensrcchanged after mount, blank UI on fetch failure, hardcodedalt="Image", silent CORS failures with no fallback, and duplicate HEAD requests on reconnection.Changes
srcreactivity: Addedupdated()hook that resetsmimeType/_errorand re-fetches whensrcchanges.@state() _error— renders<div class="error">Unable to load media</div>instead of a permanently blank loading div on fetch failure.alt: Added@property() alt = 'Image'passed through to<img alt=${this.alt}>.fallbackToExtensionBasedType()— infersvideo/{ext}for mp4/webm/ogg, falls back toimage/unknownotherwise. Called in both the no-header andcatchpaths._fetchingFor: string | nullflag — set on fetch start, cleared infinally— prevents the double HEAD request that occurs whenconnectedCallbackandupdatedboth fire on initial mount with asrcattribute set.Added
.errorCSS class tomedia-viewer-styles.tsto match.unsupportedstyling.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.