Skip to content

feat: add video preview modal - #1429

Merged
Calcium-Ion merged 1 commit into
QuantumNous:alphafrom
feitianbubu:pr/video-preview-modal
Aug 9, 2025
Merged

feat: add video preview modal#1429
Calcium-Ion merged 1 commit into
QuantumNous:alphafrom
feitianbubu:pr/video-preview-modal

Conversation

@feitianbubu

@feitianbubu feitianbubu commented Jul 24, 2025

Copy link
Copy Markdown
Member

增加视频预览模态窗

Summary by CodeRabbit

  • New Features

    • Added the ability to preview generated videos in a modal window directly from the task logs table.
    • Introduced a dedicated video preview modal for successful video generation tasks.
  • Enhancements

    • Improved task log details by allowing video links to open in a modal instead of a new browser tab for a more seamless user experience.

@coderabbitai

coderabbitai Bot commented Jul 24, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This change introduces a video preview modal feature for task logs. It adds state management for video modal visibility and URL, updates the modal component to support video content, modifies table column rendering to trigger the modal, and ensures the relevant props and handlers are passed through the component hierarchy.

Changes

File(s) Change Summary
web/src/components/table/task-logs/TaskLogsColumnDefs.js Added openVideoModal parameter; updated "详情" column to trigger video modal instead of opening links in new tab.
web/src/components/table/task-logs/TaskLogsTable.jsx Passed openVideoModal prop to column definitions; updated useMemo dependencies accordingly.
web/src/components/table/task-logs/index.jsx Rendered two ContentModal components: one for general content, one for video; managed video modal state and props.
web/src/components/table/task-logs/modals/ContentModal.jsx Added isVideo prop; conditionally rendered video or text content based on this prop.
web/src/hooks/task-logs/useTaskLogsData.js Introduced isVideoModalOpen, videoUrl state, and openVideoModal handler; exposed them via the hook's return object.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TaskLogsTable
    participant TaskLogsColumnDefs
    participant useTaskLogsData
    participant ContentModal

    User->>TaskLogsTable: Clicks video link in task log row
    TaskLogsTable->>TaskLogsColumnDefs: Renders columns with openVideoModal
    TaskLogsColumnDefs->>useTaskLogsData: Calls openVideoModal(url)
    useTaskLogsData->>TaskLogsTable: Updates isVideoModalOpen, videoUrl
    TaskLogsTable->>ContentModal: Renders video modal with videoUrl and isVideo=true
    User->>ContentModal: Views video in modal
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Poem

In the warren of code, a new modal appears,
For videos in logs, now greeted with cheers.
Click not for a tab, but a preview on show,
A bunny’s delight, as the features now grow.
Hop in, press play—let the task videos flow!
🐇🎬

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 0

🧹 Nitpick comments (2)
web/src/components/table/task-logs/modals/ContentModal.jsx (1)

38-42: Consider removing autoplay and adding error handling for better UX.

The conditional rendering logic is correct, but there are a few improvements to consider:

  1. Autoplay concerns: The autoPlay attribute may cause accessibility issues and unexpected behavior
  2. Missing error handling: No fallback for video loading failures
  3. Missing accessibility: Video element lacks proper ARIA labels

Apply this diff to improve the video implementation:

-      {isVideo ? (
-        <video src={modalContent} controls style={{ width: '100%' }} autoPlay />
-      ) : (
-        <p style={{ whiteSpace: 'pre-line' }}>{modalContent}</p>
-      )}
+      {isVideo ? (
+        <video 
+          src={modalContent} 
+          controls 
+          style={{ width: '100%' }} 
+          aria-label="Task video preview"
+          onError={(e) => console.error('Video loading failed:', e)}
+        >
+          Your browser does not support the video tag.
+        </video>
+      ) : (
+        <p style={{ whiteSpace: 'pre-line' }}>{modalContent}</p>
+      )}
web/src/components/table/task-logs/TaskLogsColumnDefs.js (1)

346-355: Consider improving the anchor implementation for better accessibility.

The video modal trigger works correctly, but there are some improvements to consider:

  1. Semantic HTML: Using href="#" is not ideal for buttons that trigger actions
  2. Accessibility: A button element would be more semantically correct

Apply this diff to improve the implementation:

-            <a
-              href="#"
-              onClick={e => {
-                e.preventDefault();
-                openVideoModal(text);
-              }}
-            >
-              {t('点击预览视频')}
-            </a>
+            <button
+              type="button"
+              onClick={() => openVideoModal(text)}
+              style={{ 
+                background: 'none', 
+                border: 'none', 
+                color: 'var(--semi-color-primary)', 
+                cursor: 'pointer',
+                textDecoration: 'underline'
+              }}
+            >
+              {t('点击预览视频')}
+            </button>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b704fc9 and 9b73696.

📒 Files selected for processing (5)
  • web/src/components/table/task-logs/TaskLogsColumnDefs.js (2 hunks)
  • web/src/components/table/task-logs/TaskLogsTable.jsx (2 hunks)
  • web/src/components/table/task-logs/index.jsx (1 hunks)
  • web/src/components/table/task-logs/modals/ContentModal.jsx (2 hunks)
  • web/src/hooks/task-logs/useTaskLogsData.js (4 hunks)
🔇 Additional comments (8)
web/src/components/table/task-logs/modals/ContentModal.jsx (1)

27-27: LGTM: Clean prop addition for video functionality.

The new isVideo prop is well-integrated into the component signature.

web/src/components/table/task-logs/index.jsx (2)

40-40: Good: Explicit prop makes intent clear.

Adding isVideo={false} explicitly improves code readability and makes the modal's purpose clear.


41-47: Well-structured video modal implementation.

The dedicated video modal instance with separate state management is a clean approach that maintains separation of concerns.

web/src/components/table/task-logs/TaskLogsTable.jsx (1)

42-42: Clean integration of video modal functionality.

The openVideoModal prop is correctly destructured, passed to getTaskLogsColumns, and included in the useMemo dependency array. This follows React best practices for prop passing and memoization.

Also applies to: 55-55, 63-63

web/src/components/table/task-logs/TaskLogsColumnDefs.js (1)

214-214: LGTM: Parameter correctly added.

The openVideoModal parameter is properly added to the function signature.

web/src/hooks/task-logs/useTaskLogsData.js (3)

66-68: Clean state management for video modal.

The video modal state variables follow the existing pattern in the hook and are properly initialized.


250-254: Well-implemented modal handler function.

The openVideoModal function correctly sets both the video URL and modal visibility state in a single operation, following the same pattern as the existing openContentModal function.


277-280: Proper state exposure in hook return.

The new video modal states and handler are correctly added to the hook's return object, making them available to consuming components.

Also applies to: 308-308

@Calcium-Ion
Calcium-Ion merged commit ec28671 into QuantumNous:alpha Aug 9, 2025
3 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Apr 20, 2026
11 tasks
x22x22 pushed a commit to x22x22/new-api that referenced this pull request Apr 24, 2026
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