Skip to content

Fallback to demo gif on mp4 load failure#256

Merged
yamcodes merged 1 commit intomainfrom
cursor/fallback-to-demo-gif-on-mp4-load-failure-2430
Nov 1, 2025
Merged

Fallback to demo gif on mp4 load failure#256
yamcodes merged 1 commit intomainfrom
cursor/fallback-to-demo-gif-on-mp4-load-failure-2430

Conversation

@yamcodes
Copy link
Owner

@yamcodes yamcodes commented Nov 1, 2025

This pull request contains changes generated by a Cursor Cloud Agent

Open in Cursor Open in Web


Note

Add GIF fallback to VideoDemo on video load error and tests to verify behavior and click-through.

  • Frontend:
    • apps/www/components/page/video-demo.tsx: Add GIF fallback for video load errors using useState (videoError) and onError on video; renders /assets/demo.gif with matching dimensions/styles; preserves existing click-to-open StackBlitz behavior.
  • Tests:
    • apps/www/components/page/video-demo.test.tsx: Add tests verifying fallback to img on video error and that button click still opens the StackBlitz URL after fallback.

Written by Cursor Bugbot for commit 53f7b99. This will update automatically on new commits. Configure here.

Summary by CodeRabbit

  • Bug Fixes

    • Video demo now gracefully handles load failures by displaying a fallback image instead of a broken video, while maintaining button functionality.
  • Tests

    • Added test coverage for video fallback UI behavior.
    • Added test coverage for button interaction during fallback state.

Co-authored-by: yamyam263 <yamyam263@gmail.com>
@cursor
Copy link

cursor bot commented Nov 1, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@changeset-bot
Copy link

changeset-bot bot commented Nov 1, 2025

⚠️ No Changeset found

Latest commit: 53f7b99

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Nov 1, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
arkenv Ready Ready Preview Comment Nov 1, 2025 11:05am

@github-actions github-actions bot added www Improvements or additions to arkenv.js.org tests This issue or PR is about adding, removing or changing tests labels Nov 1, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 1, 2025

Walkthrough

Added error handling to the VideoDemo component with client-side state tracking and conditional rendering. When video loading fails, the component displays a fallback GIF image instead. Added corresponding test coverage for fallback UI rendering and button interaction after failure.

Changes

Cohort / File(s) Change Summary
VideoDemo error handling
apps/www/components/page/video-demo.tsx
Introduces videoError state, handleVideoError callback, and conditional rendering to display fallback GIF image (/assets/demo.gif) when video fails to load.
VideoDemo test coverage
apps/www/components/page/video-demo.test.tsx
Adds two new test cases: one verifying fallback GIF renders with correct attributes when video fails; another confirming button click behavior persists after fallback.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant VideoDemo
    participant Video as Video Element
    participant GIF as Fallback GIF
    
    User->>VideoDemo: Render component
    VideoDemo->>Video: Attempt to load video
    
    alt Video loads successfully
        Video-->>VideoDemo: onLoad
        VideoDemo->>VideoDemo: videoError = false
        VideoDemo->>User: Display video
    else Video fails to load
        Video-->>VideoDemo: onError
        VideoDemo->>VideoDemo: videoError = true
        VideoDemo->>GIF: Render fallback image
        VideoDemo->>User: Display fallback GIF
    end
    
    User->>VideoDemo: Click button
    VideoDemo-->>User: Open StackBlitz URL
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Straightforward conditional rendering pattern for error handling
  • Limited scope to a single component with well-isolated logic
  • Good test coverage validates both success and failure paths
  • No complex state management or side effects

Poem

🐰 When videos stumble and fail to appear,
A fallback GIF brings cheer!
With error states tracked so clean,
The smoothest fallback ever seen. 🎬✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "Fallback to demo gif on mp4 load failure" accurately and comprehensively describes the main change across the modified files. The PR introduces error handling to the VideoDemo component that conditionally renders a fallback GIF image when video loading fails, and adds tests to verify this behavior. The title is specific, concrete, and conveys the primary functionality without using vague terms or generic phrases. A teammate reviewing the git history would immediately understand the purpose of this changeset.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cursor/fallback-to-demo-gif-on-mp4-load-failure-2430

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@yamcodes yamcodes marked this pull request as ready for review November 1, 2025 11:11
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
apps/www/components/page/video-demo.tsx (1)

27-51: Conditional rendering implemented correctly with consistent styling.

The fallback logic properly switches between video and image based on the error state, maintaining consistent styling and dimensions across both render paths.

Consider these optional defensive enhancements:

  1. Add error handling for the fallback GIF:
 {videoError ? (
 	<img
 		src="/assets/demo.gif"
 		alt="ArkEnv Demo"
 		width={958}
 		className="block max-h-[600px] sm:max-h-[1000px] object-contain"
+		onError={(e) => {
+			// Prevent infinite error loop if GIF also fails
+			e.currentTarget.style.display = 'none';
+		}}
 	/>
  1. Add explicit height to prevent layout shift (matches the 958 width aspect ratio if known):
 <img
 	src="/assets/demo.gif"
 	alt="ArkEnv Demo"
 	width={958}
+	height={539}
 	className="block max-h-[600px] sm:max-h-[1000px] object-contain"
 />

Note: The error state persists for the component's lifetime and doesn't retry, which is appropriate for a demo video component.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8d4f05c and 53f7b99.

📒 Files selected for processing (2)
  • apps/www/components/page/video-demo.test.tsx (1 hunks)
  • apps/www/components/page/video-demo.tsx (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-09-12T06:23:45.463Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-12T06:23:45.463Z
Learning: Applies to **/*.test.ts : Test both success and failure cases for environment validation and utilities

Applied to files:

  • apps/www/components/page/video-demo.test.tsx
📚 Learning: 2025-09-12T06:23:45.463Z
Learnt from: CR
Repo: yamcodes/arkenv PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-12T06:23:45.463Z
Learning: Applies to **/*.test.ts : Verify both runtime behavior and TypeScript types in tests

Applied to files:

  • apps/www/components/page/video-demo.test.tsx
🧬 Code graph analysis (1)
apps/www/components/page/video-demo.test.tsx (1)
apps/www/components/page/video-demo.tsx (1)
  • VideoDemo (5-55)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test-e2e
🔇 Additional comments (4)
apps/www/components/page/video-demo.test.tsx (2)

217-242: Excellent test coverage for the fallback behavior!

This test comprehensively validates the error handling path. It verifies the initial state, simulates the error event, and confirms the complete replacement of the video element with the fallback image including all attributes and styling.


244-261: Good defensive test for post-fallback interaction!

This test ensures the button remains functional after the video error occurs, which is crucial for maintaining the user experience when the fallback is triggered.

apps/www/components/page/video-demo.tsx (2)

3-6: Clean state management setup.

The useState import and videoError state initialization are correct for React 19. The initial state of false appropriately represents the no-error condition.


14-16: Error handler implementation is correct.

The handler appropriately updates the error state to trigger the fallback UI rendering.

@yamcodes yamcodes merged commit 1cd8ff5 into main Nov 1, 2025
16 checks passed
@yamcodes yamcodes deleted the cursor/fallback-to-demo-gif-on-mp4-load-failure-2430 branch November 1, 2025 11:16
@yamcodes
Copy link
Owner Author

yamcodes commented Nov 1, 2025

This is a bandaid solution for #254, but not a true fix that would close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests This issue or PR is about adding, removing or changing tests www Improvements or additions to arkenv.js.org

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants