Skip to content

[Bug]: Broken Screenshot Images in Screenshots Tab - Issue(#3739) #3751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 12, 2025

Conversation

AnicetFantomas
Copy link
Contributor

@AnicetFantomas AnicetFantomas commented Apr 11, 2025

Description

  • Refractored duplicate code in ScreenshotPerHour component
  • Add a image placeholder in case the screenshots array is empty

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented on my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

Previous screenshots

Image

Current screenshots

Screenshot from 2025-04-11 11-03-44

Please add here videos or images of the current (new) status

Summary by CodeRabbit

  • New Features

    • Introduced a team-specific screenshot view for displaying hourly screenshots in a team context.
  • Bug Fixes

    • Corrected naming inconsistencies to ensure a unified experience.
  • Enhancements

    • Improved image handling by providing a fallback image for missing thumbnails.
    • Refined rendering logic with dynamic styling for improved layout consistency.
    • Enhanced logging for better tracking of screenshot updates.

Copy link
Contributor

coderabbitai bot commented Apr 11, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request refactors and enhances the screenshot components. The primary component is renamed from ScreenshootPerHour to ScreenshotPerHour, and an optional isTeamPage prop is added to support team-specific rendering. A new ScreenshotPerHourTeam component is introduced to wrap the main component with the team context. Additionally, the image handling in the ScreenshotItem component now includes a fallback placeholder and error logging, while the import statements in the related container file are updated accordingly.

Changes

File(s) Change Summary
apps/web/.../screenshoots-per-hour.tsx, apps/web/.../screenshoots.tsx Renamed ScreenshootPerHour to ScreenshotPerHour; added an isTeamPage boolean prop with conditional rendering; introduced ScreenshotPerHourTeam as a wrapper component; updated useEffect logging and corrected import statements.
apps/web/.../screenshot-item.tsx Enhanced image handling: now defaults to a placeholder image if none is provided; added onError logging; adjusted class names for layout consistency.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TeamPage as ScreenshotPerHourTeam
    participant Component as ScreenshotPerHour
    participant Item as ScreenshotItem

    User->>TeamPage: Render team page
    TeamPage->>Component: Call with isTeamPage=true
    Component->>Component: Execute useEffect logging on timeSlots change
    Component->>Item: Render screenshot items with conditional layout
Loading

Poem

I'm a rabbit, hopping with delight,
Coding changes through day and night.
Screenshots now shine with a clearer view,
Placeholders ready when images are few.
Logs and components dance in the light –
Hoppy updates, making everything right!
🐰💻

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/web/lib/features/activity/components/screenshoots-per-hour.tsx

Oops! Something went wrong! :(

ESLint: 8.46.0

ESLint couldn't find the config "next/core-web-vitals" to extend from. Please check that the name of the config is correct.

The config "next/core-web-vitals" was referenced from the config file in "/apps/web/.eslintrc.json".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6d0ee78 and 176f6b0.

📒 Files selected for processing (1)
  • apps/web/lib/features/activity/components/screenshoots-per-hour.tsx (2 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR addresses broken screenshots by adding fallback image handling and refactoring duplicate code in screenshot components for better maintainability.

  • Added fallback image handling in apps/web/lib/features/activity/components/screenshot-item.tsx with onError handler to display a placeholder when images fail to load
  • Refactored apps/web/lib/features/activity/components/screenshoots-per-hour.tsx to merge team and regular screenshot components using an isTeamPage prop
  • Standardized naming from "Screenshoot" to "Screenshot" across components for consistency
  • Added debug logging in screenshot components to help troubleshoot loading issues
  • Improved conditional class assignments for better code organization and readability

3 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

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 (4)
apps/web/lib/features/activity/screenshoots.tsx (1)

9-82: Consider consistent naming throughout the codebase

The component name has been corrected from "Screenshoot" to "Screenshot", but the file name (screenshoots.tsx) and some component names (ScreenshootTab, ScreenshootTeamTab, ScreenshootSkeleton) still use the old spelling.

For complete consistency, consider updating the remaining occurrences of "Screenshoot" in file names and component names.

apps/web/lib/features/activity/components/screenshoots-per-hour.tsx (3)

32-37: Remove debugging console logs before production

Debug console logs were added to trace time slots and screenshot data. While useful during development, these should be removed before merging to production.

-useEffect(() => {
-  console.log('Time slots received:', timeSlots);
-  if (timeSlots && timeSlots.length > 0) {
-    console.log('First slot screenshots:', timeSlots[0]?.screenshots);
-  }
-}, [timeSlots]);

63-63: Use optional chaining for better code quality

Consider using optional chaining for a more concise syntax when accessing nested properties.

-imageUrl={(el.screenshots && el.screenshots[0]?.thumbUrl) || '/assets/jpeg/placeholder-image.jpeg'}
+imageUrl={el.screenshots?.[0]?.thumbUrl || '/assets/jpeg/placeholder-image.jpeg'}

Also applies to: 79-79

🧰 Tools
🪛 Biome (1.9.4)

[error] 63-63: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


1-95: Consider renaming the file to match component name spelling

The component name has been corrected from "Screenshoot" to "Screenshot", but the file name still uses the old spelling (screenshoots-per-hour.tsx).

For complete consistency, consider updating the file name to screenshots-per-hour.tsx.

🧰 Tools
🪛 Biome (1.9.4)

[error] 63-63: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 79-79: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between babe168 and 17f6838.

⛔ Files ignored due to path filters (1)
  • apps/web/public/assets/jpeg/placeholder-image.jpeg is excluded by !**/*.jpeg
📒 Files selected for processing (3)
  • apps/web/lib/features/activity/components/screenshoots-per-hour.tsx (2 hunks)
  • apps/web/lib/features/activity/components/screenshot-item.tsx (4 hunks)
  • apps/web/lib/features/activity/screenshoots.tsx (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
apps/web/lib/features/activity/screenshoots.tsx (1)
apps/web/lib/features/activity/components/screenshoots-per-hour.tsx (2)
  • ScreenshotPerHour (10-90)
  • ScreenshotPerHourTeam (92-94)
apps/web/lib/features/activity/components/screenshot-item.tsx (1)
apps/web/lib/components/progress-bar.tsx (1)
  • ProgressBar (3-42)
apps/web/lib/features/activity/components/screenshoots-per-hour.tsx (2)
apps/web/app/interfaces/timer/ITimerSlot.ts (1)
  • ITimerSlot (4-26)
apps/server-web/src/renderer/libs/utils/clsxm.ts (1)
  • clsxm (5-7)
🪛 Biome (1.9.4)
apps/web/lib/features/activity/components/screenshoots-per-hour.tsx

[error] 63-63: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 79-79: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: deploy
🔇 Additional comments (12)
apps/web/lib/features/activity/screenshoots.tsx (2)

2-2: Components renamed for better consistency

The import statement has been updated to use the correctly spelled component names ScreenshotPerHour and ScreenshotPerHourTeam (instead of "Screenshoot").


43-43: Component usage updated to match renamed components

The component references have been correctly updated to match the renamed components.

Also applies to: 67-67

apps/web/lib/features/activity/components/screenshot-item.tsx (5)

39-47: Improved image error handling with fallback

Good job adding error handling for image loading failures:

  1. The src attribute now includes a fallback path for when imageUrl is empty
  2. The onError handler logs errors and sets the fallback image when loading fails

This enhancement improves the user experience by ensuring something is always displayed.


50-56: Styling and layout improvements

The layout structure and class organization have been improved for better readability and maintainability.


59-69: Consistent button styling

The view buttons container has been updated with more consistent class ordering and spacing.


98-98: Removed extra whitespace in ProgressBar className

Extra whitespace has been removed from the ProgressBar className.


110-111: Improved modal content layout

The delete confirmation modal layout has been improved with better spacing and alignment.

apps/web/lib/features/activity/components/screenshoots-per-hour.tsx (5)

8-8: Added missing imports

The useCallback and useEffect imports have been added to support the new functionality.


10-20: Component renamed and enhanced with isTeamPage prop

The component has been renamed from ScreenshootPerHour to ScreenshotPerHour for correct spelling, and an optional isTeamPage boolean prop has been added to support different rendering scenarios.


39-45: Good refactoring of class names for reusability

Extracting the class names into variables based on the isTeamPage prop improves code readability and maintainability. This is a good refactoring approach.


53-85: Refactored rendering logic with conditional display

The rendering logic has been effectively refactored to conditionally display content based on the isTeamPage prop. This eliminates duplicate code and improves maintainability.

The fallback image path ('/assets/jpeg/placeholder-image.jpeg') is now consistently used when screenshots are unavailable.

🧰 Tools
🪛 Biome (1.9.4)

[error] 63-63: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 79-79: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


92-94: Good implementation of the wrapper component

The new ScreenshotPerHourTeam component effectively wraps ScreenshotPerHour with the isTeamPage prop set to true. This is a clean pattern that promotes code reuse.

Innocent-Akim
Innocent-Akim previously approved these changes Apr 11, 2025
@Innocent-Akim Innocent-Akim self-requested a review April 11, 2025 09:22
@AnicetFantomas AnicetFantomas changed the title Fx/broken screenshots [Bug]: Broken Screenshot Images in Screenshots Tab - Issue(#3739) Apr 11, 2025
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

♻️ Duplicate comments (1)
apps/web/lib/features/activity/components/screenshoots-per-hour.tsx (1)

56-56: Duplicate key warning from previous review.

The key prop is used on both the parent div and the child component. Using it only on the parent div is sufficient.

🧹 Nitpick comments (3)
apps/web/lib/features/activity/components/screenshoots-per-hour.tsx (3)

32-37: Remove debugging console logs before production.

The useEffect hook includes console log statements that appear to be for debugging purposes. These should be removed before merging to production.

-useEffect(() => {
-    console.log('Time slots received:', timeSlots);
-    if (timeSlots && timeSlots.length > 0) {
-        console.log('First slot screenshots:', timeSlots[0]?.screenshots);
-    }
-}, [timeSlots]);

53-54: Consider using item IDs as keys instead of array indices.

Using array indices as keys in React lists can cause issues when items are reordered, added, or removed. Since each el has an id property, consider using that as the key for better performance and reliability.

-{timeSlots.map((el, i) => {
+{timeSlots.map((el) => {
    if (isTeamPage) {
        return (
-            <div key={i} className={clsxm('min-w-[15rem] xl:w-1/6 p-4')}>
+            <div key={el.id} className={clsxm('min-w-[15rem] xl:w-1/6 p-4')}>
                <ScreenshotItem
                    /* ... props ... */
                />
            </div>
        );
    }

    return (
        <ScreenshotItem
-            key={i}
+            key={el.id}
            /* ... props ... */
        />
    );
})}

Also applies to: 72-73, 83-84


62-63: Optimize optional chaining in image URL handling.

The static analysis is suggesting to improve the optional chaining in the image URL expressions.

-imageUrl={(el.screenshots && el.screenshots[0]?.thumbUrl) || '/assets/jpeg/placeholder-image.jpeg'}
+imageUrl={el.screenshots?.[0]?.thumbUrl || '/assets/jpeg/placeholder-image.jpeg'}

Also applies to: 78-78

🧰 Tools
🪛 Biome (1.9.4)

[error] 62-62: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 17f6838 and 6d0ee78.

📒 Files selected for processing (1)
  • apps/web/lib/features/activity/components/screenshoots-per-hour.tsx (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/web/lib/features/activity/components/screenshoots-per-hour.tsx (2)
apps/web/app/interfaces/timer/ITimerSlot.ts (1)
  • ITimerSlot (4-26)
apps/server-web/src/renderer/libs/utils/clsxm.ts (1)
  • clsxm (5-7)
🪛 Biome (1.9.4)
apps/web/lib/features/activity/components/screenshoots-per-hour.tsx

[error] 62-62: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 78-78: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: deploy
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (5)
apps/web/lib/features/activity/components/screenshoots-per-hour.tsx (5)

8-8: Good addition of useEffect import.

You've properly added the required React hooks to support the new functionality.


10-14: Component name correction and props enhancement.

The component name correction from "Screenshoot" to "Screenshot" improves consistency. The addition of the optional isTeamPage prop with a default value follows React best practices for component interfaces.

Also applies to: 19-19


39-45: Well-structured conditional styling.

Creating separate variables for container, heading, and content classes based on the isTeamPage prop is a clean approach to conditional styling. This makes the JSX more readable and maintainable.


48-52: Clean implementation of conditional classes.

The usage of conditional class variables in the component structure makes the code more maintainable and readable.


91-93: Good component composition with ScreenshotPerHourTeam.

Creating a wrapper component that sets isTeamPage={true} is a clean way to provide a specialized component for team pages while reusing the existing functionality.

@Innocent-Akim Innocent-Akim dismissed their stale review April 11, 2025 09:23

Hello,
I’m withdrawing my review request for now, as some changes are still in progress.

@NdekoCode NdekoCode self-requested a review April 12, 2025 07:57
@Cedric921 Cedric921 linked an issue Apr 12, 2025 that may be closed by this pull request
}) => {
const { isOpen, closeModal, openModal } = useModal();
useEffect(() => {
console.log('Time slots received:', timeSlots);
Copy link
Member

Choose a reason for hiding this comment

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

@AnicetFantomas please review each line of your PR when you created it and make sure you clean up those console.log and other things. I really suggest to literally ALWAYS review EACH line, it helps a LOT, thanks!

const { isOpen, closeModal, openModal } = useModal();
useEffect(() => {
if (timeSlots && timeSlots.length > 0) {
console.log('First slot screenshots:', timeSlots[0]?.screenshots);
Copy link
Member

Choose a reason for hiding this comment

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

@AnicetFantomas do we need this whole useEffect() (except for temp debugging)? Can we remove it? If yes, do in another PR based on develop branch as I will merge this PR with Squash.

@evereq evereq merged commit f048726 into develop Apr 12, 2025
13 of 16 checks passed
@evereq evereq deleted the Fx/broken-screenshots branch April 12, 2025 10:48
@evereq
Copy link
Member

evereq commented Apr 12, 2025

@Innocent-Akim / @Cedric921 / @NdekoCode when do review (not only in this PR, but in general), please make sure you review EACH line of code and note those console.log and other problematic things etc.

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.

[Bug]: Broken Screenshot Images in Screenshots Tab
4 participants