Skip to content

Conversation

@ameer2468
Copy link
Contributor

@ameer2468 ameer2468 commented Aug 18, 2025

This PR: You will be able to see video duration on newly uploaded videos since we added this as metadata.

Screenshot 2025-08-18 at 15 50 50

Summary by CodeRabbit

  • New Features
    • Added a duration badge on relevant dashboard cards that shows concise time (hrs/mins/secs) from available metadata; displays "0 secs" when no duration is present.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 18, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds moment-based duration formatting and renders a duration badge in CapCard when cap.metadata?.duration exists. Change is internal to CapCard; no public component signatures or VideoThumbnail props were modified.

Changes

Cohort / File(s) Summary of Changes
CapCard duration UI & utils
apps/web/app/(org)/dashboard/caps/components/CapCard/CapCard.tsx
Adds moment import and a new internal formatDuration(duration) helper; computes hours/minutes/seconds and renders a concise duration badge when cap.metadata?.duration exists. No public API or prop signature changes.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CapCard

  User->>CapCard: Render cap card
  CapCard->>CapCard: parse & format duration (moment) if metadata.duration
  CapCard-->>User: Render duration badge (when present)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • new: add video duration to cards #902 — Modifies the same CapCard.tsx to add moment-based duration formatting and a duration badge; that PR additionally introduces a VideoThumbnail prop, while this change does not.

Poem

I hop through timestamps, nibble time in bits,
I stitch calm badges of seconds, minutes, hits.
With whiskers of moment and a tiny cheer,
This cap now counts the moments near. 🐇

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ebe73d2 and 91434e3.

📒 Files selected for processing (1)
  • apps/web/app/(org)/dashboard/caps/components/CapCard/CapCard.tsx (3 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-video-duration

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

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

🔭 Outside diff range comments (1)
apps/web/app/(org)/dashboard/caps/components/CapCard/CapCard.tsx (1)

454-467: Add optional videoMetadata prop to VideoThumbnail and rename usage

The VideoThumbnailProps interface currently only defines userId, videoId, and alt. Since you’re passing cap.metadata, you need to:

  • Declare a new optional prop in VideoThumbnailProps:
    import { VideoMetadata } from "…"; // wherever VideoMetadata lives
    
    interface VideoThumbnailProps {
      userId: string;
      videoId: string;
      alt: string;
      videoMetadata?: VideoMetadata; // new, optional
    }
  • Destructure and safely handle it in the component:
    export const VideoThumbnail: React.FC<VideoThumbnailProps> = memo(
      ({ userId, videoId, alt, videoMetadata }) => {
        // e.g. 
        const { resolution, bandwidth } = videoMetadata ?? {};
        // …
      }
    );
  • Rename the prop in CapCard.tsx for consistency:
     <VideoThumbnail
  • videoMetaData={cap.metadata}
  • videoMetadata={cap.metadata}
    imageClass={…}
    userId={cap.ownerId}
    videoId={cap.id}
    alt={${cap.name} Thumbnail}
    />

Locations to update:
- **apps/web/components/VideoThumbnail.tsx**  
– Add import of `VideoMetadata`  
– Extend `VideoThumbnailProps` with `videoMetadata?: VideoMetadata`  
– Update component signature and internal handling  
- **apps/web/app/(org)/dashboard/caps/components/CapCard/CapCard.tsx**  
– Change `videoMetaData` → `videoMetadata`

</blockquote></details>

</blockquote></details>

<details>
<summary>🧹 Nitpick comments (2)</summary><blockquote>

<details>
<summary>apps/web/app/(org)/dashboard/caps/components/CapCard/CapCard.tsx (2)</summary><blockquote>

`108-124`: **Replace Moment-based formatter; fix pluralization and multi-hour handling**

Current logic returns "1 hr" for any duration ≥ 1 hour, and produces "1 mins" for 1 minute. It also depends on Moment unnecessarily. A small math-based formatter is clearer, correct, and cheaper for the bundle.



```diff
-  const formatDuration = (duration: number | undefined) => {
-    if (!duration) return "0 secs";
-
-    const momentDuration = moment.duration(duration, "milliseconds");
-    const totalMinutes = Math.floor(momentDuration.asMinutes());
-    const totalHours = Math.floor(momentDuration.asHours());
-    const seconds = momentDuration.seconds();
-
-    if (totalHours > 0) {
-      return "1 hr";
-    } else if (totalMinutes > 0) {
-      return `${totalMinutes} mins`;
-    } else {
-      return `${seconds} secs`;
-    }
-  };
+  const formatDuration = (durationMs?: number) => {
+    const totalSeconds = Math.max(0, Math.floor((durationMs ?? 0) / 1000));
+    const hours = Math.floor(totalSeconds / 3600);
+    if (hours > 0) {
+      return `${hours} ${hours === 1 ? "hr" : "hrs"}`;
+    }
+    const minutes = Math.floor((totalSeconds % 3600) / 60);
+    if (minutes > 0) {
+      return `${minutes} ${minutes === 1 ? "min" : "mins"}`;
+    }
+    const seconds = totalSeconds % 60;
+    return `${seconds} ${seconds === 1 ? "sec" : "secs"}`;
+  };

If you prefer the original product requirement of “1 hr” for all multi-hour videos, keep the hours branch but fix pluralization elsewhere.


410-414: Show 0s durations, fix invalid Tailwind class; consider more robust positioning

  • The current guard hides 0-length videos; use a type check so 0 shows as “0 secs”.
  • Tailwind doesn’t provide leading-0; use leading-none.
  • Positioning via top-[112px] is brittle across card sizes. Consider anchoring to the thumbnail container’s bottom-left instead.
-{cap.metadata?.duration && (
-  <p className="text-white leading-0 px-2 py-px rounded-full backdrop-blur-sm absolute z-10 left-3 top-[112px] bg-black/50 text-[10px]">
-    {formatDuration(cap.metadata.duration as number)}
-  </p>
-)}
+{typeof cap.metadata?.duration === "number" && (
+  <p className="text-white leading-none px-2 py-px rounded-full backdrop-blur-sm absolute z-10 left-3 top-[112px] bg-black/50 text-[10px]">
+    {formatDuration(cap.metadata.duration)}
+  </p>
+)}

To robustly position over the thumbnail, move the badge inside the Link and make the Link a positioning context:

<Link className={clsx("block group relative", anyCapSelected && "cursor-pointer pointer-events-none")} ...>
  <VideoThumbnail ... />
  {typeof cap.metadata?.duration === "number" && (
    <p className="text-white leading-none px-2 py-px rounded-full backdrop-blur-sm absolute z-10 left-2 bottom-2 bg-black/50 text-[10px]">
      {formatDuration(cap.metadata.duration)}
    </p>
  )}
</Link>
📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 26eba96 and ebe73d2.

📒 Files selected for processing (1)
  • apps/web/app/(org)/dashboard/caps/components/CapCard/CapCard.tsx (4 hunks)
⏰ 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). (4)
  • GitHub Check: Build Desktop (x86_64-pc-windows-msvc, windows-latest)
  • GitHub Check: Build Desktop (aarch64-apple-darwin, macos-latest)
  • GitHub Check: Analyze (rust)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
apps/web/app/(org)/dashboard/caps/components/CapCard/CapCard.tsx (1)

22-22: Multiple Moment.js imports detected—plan a full removal

Moment.js is still imported in several components and declared in your bundle’s dependencies:

• apps/web/app/s/[videoId]/_components/ShareHeader.tsx
• apps/web/app/(org)/dashboard/caps/components/CapCard/CapCardContent.tsx
• apps/web/app/(org)/dashboard/spaces/[spaceId]/components/VideoCard.tsx
• apps/web/app/(org)/dashboard/caps/components/CapCard/CapCard.tsx
• apps/web/app/(org)/dashboard/_components/Notifications/NotificationItem.tsx

And in apps/web/package.json:

"moment": "^2.30.1"

To safely remove Moment.js and avoid runtime errors:

  1. Replace each moment usage with your lightweight formatter (e.g., a small date‐math utility or date-fns).
  2. Remove all import moment from "moment"; lines across the codebase.
  3. Verify no remaining imports with:
    rg -nP "import\s+moment\s+from\s+['\"]moment['\"]"
  4. Drop "moment" from package.json once all references are gone.

Please review and confirm that all usages are migrated before removing the dependency.

@ameer2468 ameer2468 merged commit 4e11eab into main Aug 18, 2025
13 of 15 checks passed
@ameer2468 ameer2468 deleted the add-video-duration branch August 18, 2025 13:02
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