Skip to content

⚡ Bolt: optimize homepage speakers fetching#27

Merged
anyulled merged 3 commits intomainfrom
bolt-optimize-speakers-fetching-15807052520496551474
Feb 7, 2026
Merged

⚡ Bolt: optimize homepage speakers fetching#27
anyulled merged 3 commits intomainfrom
bolt-optimize-speakers-fetching-15807052520496551474

Conversation

@anyulled
Copy link
Copy Markdown
Owner

@anyulled anyulled commented Feb 7, 2026

💡 What: Moved speaker data fetching from Section5 (Client Component) to app/[year]/page.tsx (Server Component).
🎯 Why: To improve performance by leveraging ISR caching, reducing client-side JavaScript execution, and eliminating layout shifts caused by client-side fetching.
📊 Impact:

  • Eliminated client-side fetch request for speakers on homepage load.
  • Removed layout shift for the "Meet Our Speakers" section.
  • Improved SEO by having speaker content available in the initial HTML (when data is present).
    🔬 Measurement:
  • Verified that Section5 receives speakers as props.
  • Verified that the homepage still renders correctly.
  • Confirmed that "No speakers available yet" message appears correctly when API returns empty list (current state for 2026).

PR created automatically by Jules for task 15807052520496551474 started by @anyulled

Summary by CodeRabbit

  • Documentation

    • Added a dated entry documenting a client-side fetching anti-pattern and optimization approaches
  • Refactor

    • Moved speaker data fetching to server-side pages to enable caching and reduce client-side waterfalls
    • Simplified the speakers section to accept preloaded data and display total speaker count
  • Tests

    • Updated tests to assert speaker counts and rendering for the updated speakers flow

Refactors the Section5 (Speakers) component to receive data via props instead of fetching it client-side.
Updates the homepage (app/[year]/page.tsx) to fetch speakers during server rendering (ISR) and pass a random subset to the component.
This eliminates a client-side waterfall, reduces layout shifts, and improves LCP.

Co-authored-by: anyulled <100741+anyulled@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 7, 2026

📝 Walkthrough

Walkthrough

Server pages now fetch speaker data and compute random subsets; Section5 is refactored to accept speakers and totalSpeakers props rather than fetching statefully. Tests and documentation updated; a new getRandomSpeakers utility was added.

Changes

Cohort / File(s) Summary
Documentation
./.jules/bolt.md
Appended a dated entry describing the client-side fetching anti-pattern and its migration to server-side fetching for ISR and layout stability.
Tests & Mocks
__tests__/pages/year-index.test.tsx
Updated Section5 test mock to accept speakers and totalSpeakers; added mock exports for @/hooks/useSpeakers (getSpeakers, getRandomSpeakers) and adjusted assertions to include speaker counts.
Server pages
app/[year]/page.tsx, app/index8/page.tsx
Pages converted to async server components that call getSpeakers and getRandomSpeakers, compute totalSpeakers, and pass speakers + totalSpeakers into Section5 props.
Client component
components/sections/home8/section5.tsx
Removed internal data fetching/state and loading/error branches; Section5 now accepts speakers: Speaker[] and totalSpeakers: number as props and renders directly from them.
Utilities / Hooks
hooks/useSpeakers.ts
Added getRandomSpeakers(speakers, count) implementing Fisher–Yates shuffle and safe guards to return a random subset or full list as appropriate.

Sequence Diagram(s)

sequenceDiagram
    participant User as User/Browser
    participant Server as Server<br/>(page.tsx)
    participant Hook as Hook<br/>(useSpeakers)
    participant Section as Client Component<br/>(Section5)

    User->>Server: Request page for year
    Server->>Hook: getSpeakers(year)
    Hook-->>Server: allSpeakers
    Server->>Hook: getRandomSpeakers(allSpeakers, 6)
    Hook-->>Server: randomSpeakers
    Server->>Server: compute totalSpeakers
    Server->>Section: render with props {speakers, totalSpeakers}
    Section-->>User: render speaker list in browser
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped from client to the hill,

Fetching moved where caches chill.
Props arrive, no state to comb,
Little rabbits call this home.
A shuffled bunch, now on the roam.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 mentions optimizing homepage speakers fetching, which directly aligns with the PR's main objective of moving speaker data fetching from client to server component.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 bolt-optimize-speakers-fetching-15807052520496551474

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.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @anyulled, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant optimization to the homepage by refactoring how speaker data is fetched. By moving the data fetching logic from a client-side component to server-side pages, the application now benefits from improved initial load performance, reduced client-side JavaScript overhead, and the elimination of layout shifts. This strategic shift also enhances SEO by ensuring speaker content is present in the initial HTML and leverages ISR caching for efficient data delivery.

Highlights

  • Server-Side Data Fetching: Speaker data fetching for the homepage has been migrated from the client-side Section5 component to the server-side app/[year]/page.tsx and app/index8/page.tsx components.
  • Performance and User Experience: This change significantly improves initial page load performance by eliminating client-side fetch requests, reducing JavaScript execution, and preventing layout shifts in the "Meet Our Speakers" section.
  • SEO and Caching: By fetching speaker data on the server, content is available in the initial HTML, enhancing SEO. The approach also leverages Incremental Static Regeneration (ISR) caching for better efficiency.
  • Code Refactoring: The getRandomSpeakers utility function has been centralized in hooks/useSpeakers.ts and client-side state management for speakers (loading, error) has been removed from Section5.
Changelog
  • .jules/bolt.md
    • Documented a new learning about the anti-pattern of client-side fetching for static content in App Router, advocating for server-side data fetching.
  • tests/pages/year-index.test.tsx
    • Added mocks for getSpeakers and getRandomSpeakers to support testing the new server-side data fetching approach.
  • app/[year]/page.tsx
    • Imported getRandomSpeakers and getSpeakers for server-side use.
    • Implemented server-side fetching of speaker data (allSpeakers, randomSpeakers, totalSpeakers).
    • Passed the fetched speakers and totalSpeakers as props to the Section5 component.
  • app/index8/page.tsx
    • Converted the Home8 component to an async function to enable server-side data fetching for speakers.
    • Implemented server-side fetching of speaker data (allSpeakers, randomSpeakers, totalSpeakers).
    • Passed the fetched speakers and totalSpeakers as props to the Section5 component.
  • components/sections/home8/section5.tsx
    • Transformed this component from a client-side data fetcher to a pure presentational component, now receiving speaker data and total count directly via props.
    • Removed internal useEffect, useState, and client-side data fetching logic.
    • Removed the local getRandomSpeakers utility function, as it's now centralized.
  • hooks/useSpeakers.ts
    • Centralized and exported the getRandomSpeakers utility function, making it available for server-side usage.
  • package-lock.json
    • Updated dependencies, removing several unused or outdated packages related to development tools and build processes, contributing to a cleaner dependency tree.
Activity
  • This pull request was automatically generated by Jules to address task 15807052520496551474, initiated by @anyulled.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request is a great performance optimization, moving speaker data fetching from the client to the server in app/[year]/page.tsx. This correctly leverages Next.js Server Components and ISR to reduce client-side JavaScript, eliminate layout shifts, and improve SEO. The refactoring of getRandomSpeakers into a shared hook is also a good code quality improvement. I've identified one critical issue regarding the package-lock.json changes and a medium-severity suggestion to improve test coverage for the new data flow.

I am having trouble creating individual review comments. Click here to see my feedback.

package-lock.json (4428-4451)

critical

The changes in package-lock.json remove numerous development dependencies (like @types/eslint, webpack, terser-webpack-plugin, etc.). As you've noted in the PR description, this likely indicates an environment mismatch and could break the development and build setup for other contributors. These unrelated changes should be reverted to prevent such issues. Please consider running npm install in an environment that matches the project's setup and committing only the necessary changes, or reverting this file to its state on the target branch.

app/[year]/page.tsx (94)

medium

The Section5 component now receives speakers and totalSpeakers props, which is a key part of this refactor. To ensure this data flow is correctly tested, the unit test for this page (__tests__/pages/year-index.test.tsx) should be updated. The current test mock for Section5 doesn't account for these new props, so the test isn't verifying that the fetched speaker data is passed down correctly. Please update the mock and add assertions for these new props.

Refactors the Section5 (Speakers) component to receive data via props instead of fetching it client-side.
Updates the homepage (app/[year]/page.tsx) to fetch speakers during server rendering (ISR) and pass a random subset to the component.
This eliminates a client-side waterfall, reduces layout shifts, and improves LCP.

Co-authored-by: anyulled <100741+anyulled@users.noreply.github.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 7, 2026

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

Project Deployment Actions Updated (UTC)
devbcn Error Error Feb 7, 2026 9:49am

@anyulled
Copy link
Copy Markdown
Owner Author

anyulled commented Feb 7, 2026

The Section5 component now receives speakers and totalSpeakers props, which is a key part of this refactor. To ensure this data flow is correctly tested, the unit test for this page (tests/pages/year-index.test.tsx) should be updated. The current test mock for Section5 doesn't account for these new props, so the test isn't verifying that the fetched speaker data is passed down correctly. Please update the mock and add assertions for these new props.

@google-labs-jules
Copy link
Copy Markdown
Contributor

The Section5 component now receives speakers and totalSpeakers props, which is a key part of this refactor. To ensure this data flow is correctly tested, the unit test for this page (tests/pages/year-index.test.tsx) should be updated. The current test mock for Section5 doesn't account for these new props, so the test isn't verifying that the fetched speaker data is passed down correctly. Please update the mock and add assertions for these new props.

Thank you for the feedback. I have updated the __tests__/pages/year-index.test.tsx file to mock Section5 with the new speakers and totalSpeakers props, and added assertions to verify they are passed correctly.

Updates the __tests__/pages/year-index.test.tsx to verify that the
new `speakers` and `totalSpeakers` props are correctly passed to
the Section5 component. This addresses PR feedback to ensure
data flow is tested.

Co-authored-by: anyulled <100741+anyulled@users.noreply.github.com>
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.

1 participant