Skip to content

Conversation

@ameer2468
Copy link
Contributor

@ameer2468 ameer2468 commented Sep 28, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Comment timestamps now preserve 0 values instead of becoming null, ensuring accurate timing on new comments.
    • Improved reliability when jumping to a specific time in video playback (e.g., from shared links), with better handling of video readiness and safe clamping to duration to prevent failed or delayed seeks.
  • Chores

    • Removed outdated comments and minor cleanups with no impact on functionality or user experience.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 28, 2025

Walkthrough

Refines comment timestamp handling to use nullish coalescing. Reworks video seeking in Share.tsx to clamp and perform a single, listener-once readiness flow with timeout-based cleanup. Removes inline comments in page.tsx and Notification.ts without changing behavior. No exported/public API signatures changed.

Changes

Cohort / File(s) Summary
Comment timestamp handling
apps/web/actions/videos/new-comment.ts
Replace logical OR with nullish coalescing for the comment timestamp so 0 is preserved; only null/undefined become null.
Video seek readiness refactor
apps/web/app/s/[videoId]/Share.tsx
Consolidate video source selection, add clamp-based seekOnce, seek immediately when readyState ≥ 1, attach once-only canplay/loadedmetadata handlers, and add 3s cleanup timeout; remove prior multi-event/fallback logic.
Non-functional comment cleanup
apps/web/app/s/[videoId]/page.tsx, apps/web/lib/Notification.ts
Remove comments only; no logic or exported/public entity changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Share as Share.tsx
  participant Video as HTMLVideoElement

  User->>Share: Request share with time
  Share->>Video: Resolve v (playerRef or document.querySelector)
  alt Video found
    alt readyState ≥ 1
      Share->>Video: seekOnce(clampedTime)
    else Not ready yet
      rect rgb(240,248,255)
      note right of Share: Attach once-only listeners
      Share->>Video: addEventListener('canplay', handleReady, {once:true})
      Share->>Video: addEventListener('loadedmetadata', handleReady, {once:true})
      Share->>Share: start 3s cleanup timeout
      end
      Video-->>Share: canplay or loadedmetadata
      Share->>Video: seekOnce(clampedTime)
      Share->>Share: remove listeners & clear timeout
      opt No event within 3s
        Share->>Share: cleanup listeners (timeout)
      end
    end
  else No video
    Share->>Share: warn and return
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

A whisker twitch, a hop in time,
I nudge the seek to clamp and climb.
Zero’s real, not tossed away—
Comments land where hours say.
Listeners bow, one show, then fade;
Clean trails left where changes played.
— Your diligent code rabbit 🐇✨

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 title succinctly describes the two core aspects of the changeset: cleaning up comments across various files and improving the video seeking logic, which aligns directly with the main feature update in Share.tsx and the non-functional comment removals elsewhere. It avoids unnecessary detail while remaining specific enough for reviewers to understand the intent at a glance.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch improve-initial-seeking

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.

@ameer2468 ameer2468 merged commit 5c4d36b into main Sep 28, 2025
14 of 16 checks passed
@ameer2468 ameer2468 deleted the improve-initial-seeking branch September 28, 2025 06:49
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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d653638 and a9df628.

📒 Files selected for processing (4)
  • apps/web/actions/videos/new-comment.ts (1 hunks)
  • apps/web/app/s/[videoId]/Share.tsx (1 hunks)
  • apps/web/app/s/[videoId]/page.tsx (0 hunks)
  • apps/web/lib/Notification.ts (0 hunks)
💤 Files with no reviewable changes (2)
  • apps/web/lib/Notification.ts
  • apps/web/app/s/[videoId]/page.tsx
🧰 Additional context used
📓 Path-based instructions (7)
apps/web/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

apps/web/**/*.{ts,tsx}: Use TanStack Query v5 for all client-side server state and data fetching in the web app
Web mutations should call Server Actions directly and perform targeted cache updates with setQueryData/setQueriesData rather than broad invalidations
Client code should use useEffectQuery/useEffectMutation and useRpcClient from apps/web/lib/EffectRuntime.ts; do not create ManagedRuntime inside components

Files:

  • apps/web/app/s/[videoId]/Share.tsx
  • apps/web/actions/videos/new-comment.ts
apps/web/app/**/*.{tsx,ts}

📄 CodeRabbit inference engine (CLAUDE.md)

Prefer Server Components for initial data in the Next.js App Router and pass initialData to client components

Files:

  • apps/web/app/s/[videoId]/Share.tsx
**/*.{ts,tsx,js,jsx,rs}

📄 CodeRabbit inference engine (CLAUDE.md)

Do not add inline, block, or docstring comments in any language; code must be self-explanatory

Files:

  • apps/web/app/s/[videoId]/Share.tsx
  • apps/web/actions/videos/new-comment.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Use strict TypeScript and avoid any; leverage shared types from packages

**/*.{ts,tsx}: Use a 2-space indent for TypeScript code.
Use Biome for formatting and linting TypeScript/JavaScript files by running pnpm format.

Files:

  • apps/web/app/s/[videoId]/Share.tsx
  • apps/web/actions/videos/new-comment.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx}: Use kebab-case for filenames for TypeScript/JavaScript modules (e.g., user-menu.tsx).
Use PascalCase for React/Solid components.

Files:

  • apps/web/app/s/[videoId]/Share.tsx
  • apps/web/actions/videos/new-comment.ts
apps/web/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

On the client, always use useEffectQuery or useEffectMutation from @/lib/EffectRuntime; never call EffectRuntime.run* directly in components.

Files:

  • apps/web/app/s/[videoId]/Share.tsx
  • apps/web/actions/videos/new-comment.ts
apps/web/actions/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

All Groq/OpenAI calls must be implemented in Next.js Server Actions under apps/web/actions; do not place AI calls elsewhere

Files:

  • apps/web/actions/videos/new-comment.ts
⏰ 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: Vercel Agent Review
  • GitHub Check: Build Desktop (x86_64-pc-windows-msvc, windows-latest)
  • GitHub Check: Build Desktop (aarch64-apple-darwin, macos-latest)
  • GitHub Check: Analyze (rust)

Comment on lines +247 to 250
timeoutId = setTimeout(() => {
v.removeEventListener("canplay", handleReady);
v.removeEventListener("loadedmetadata", handleReady);
}, 3000);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Do not drop readiness listeners after 3 s

If the video metadata takes longer than 3 seconds to arrive (slow network, large asset, cold CDN), this timeout removes both readiness listeners before they ever fire. Once that happens there is no remaining path to call seekOnce, so the user’s chapter/time jump silently fails. That’s a regression from the previous behavior that waited indefinitely for readiness. Please keep the listeners until they run, or at least only remove them after we actually succeed in seeking.

-    timeoutId = setTimeout(() => {
-      v.removeEventListener("canplay", handleReady);
-      v.removeEventListener("loadedmetadata", handleReady);
-    }, 3000);
+    timeoutId = setTimeout(() => {
+      if (v.readyState >= 1) {
+        seekOnce(time);
+        v.removeEventListener("canplay", handleReady);
+        v.removeEventListener("loadedmetadata", handleReady);
+        timeoutId = null;
+      }
+    }, 3000);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
timeoutId = setTimeout(() => {
v.removeEventListener("canplay", handleReady);
v.removeEventListener("loadedmetadata", handleReady);
}, 3000);
timeoutId = setTimeout(() => {
if (v.readyState >= 1) {
seekOnce(time);
v.removeEventListener("canplay", handleReady);
v.removeEventListener("loadedmetadata", handleReady);
timeoutId = null;
}
}, 3000);
🤖 Prompt for AI Agents
In apps/web/app/s/[videoId]/Share.tsx around lines 247 to 250, the code
currently drops the "canplay" and "loadedmetadata" readiness listeners after a
3s timeout which can prevent seekOnce from ever being called on slow networks;
remove that timeout logic and instead keep the listeners attached until they
fire, or alternatively only remove each listener after its handler successfully
runs (and only clear any timeout if/when the seek succeeds), ensuring there
remains a path to call seekOnce even when metadata arrives later than 3s.

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