Skip to content

Conversation

Oksamies
Copy link
Contributor

@Oksamies Oksamies commented Sep 1, 2025

Summary by CodeRabbit

  • New Features

    • Dynamic page metadata now updates based on resolved community content.
    • Smoother loading experience with placeholders while content fetches.
  • Refactor

    • Migrated community and package browsing to Suspense-driven, asynchronous rendering for faster, non-blocking loads.
    • Updated package search to resolve results asynchronously, improving perceived performance and responsiveness.
    • Streamlined app-level data sourcing to use the route’s standard loader data.
  • Style

    • Adjusted PageHeader layout to prevent unwanted stretching within flex containers.

Copy link

coderabbitai bot commented Sep 1, 2025

Walkthrough

Client-side Suspense/Await rendering replaces server-side meta generation and eager data fetching. Community route loaders now return Promises consumed in the UI. PackageSearch accepts a Promise for listings and renders within Suspense. PageHeader CSS removes a flex rule. Root switches from useRouteLoaderData to useLoaderData.

Changes

Cohort / File(s) Summary
Community route: Suspense-driven data & meta in component
apps/cyberstorm-remix/app/c/community.tsx
Removed exported meta; loaders return Promises; component builds meta using resolved data with Suspense/Await; hero, breadcrumbs, header links, and PackageSearch now render from resolved values; added location/env-based og:url; added loading and error fallbacks; extended PackageSearch props from outlet context.
PackageSearch async listings with Suspense
apps/cyberstorm-remix/app/commonComponents/PackageSearch/PackageSearch.tsx
Prop change: listings now Promise<PackageListings>; replaced StalenessIndicator flow with Suspense/Await; render count, grid, pagination from resolved data; removed useNavigation; added loading fallbacks.
Root loader hook adjustment
apps/cyberstorm-remix/app/root.tsx
Replaced useRouteLoaderData with useLoaderData for root route data retrieval; imports updated; data shape unchanged.
Page header styling tweak
apps/cyberstorm-remix/app/commonComponents/PageHeader/PageHeader.css
Removed flex: 1 1 0; from .page-header; other rules unchanged.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Router as Remix Router
  participant Loader as community.loader
  participant UI as Community Route Component
  participant PS as PackageSearch

  User->>Router: Navigate to /c/:community
  Router->>Loader: Invoke loader
  note over Loader: Return Promises { community, listings }
  Loader-->>Router: { community: Promise, listings: Promise }
  Router->>UI: Render with data (Promises)

  par Suspense boundaries
    UI->>UI: Suspense for meta/hero/header
    UI->>Loader: Await community
    Loader-->>UI: community data
    UI->>UI: Construct meta, hero image, breadcrumbs
  and
    UI->>PS: Render PackageSearch(listings: Promise)
    PS->>Loader: Await listings
    Loader-->>PS: listings data
    PS->>PS: Render count, grid, pagination
  end
Loading
sequenceDiagram
  autonumber
  participant Root as Root Route
  participant Hook as useLoaderData
  participant Ctx as App Context
  Root->>Hook: Read loader data
  Hook-->>Root: RootLoadersType data
  Root->>Ctx: Provide outlet context (sections, config, currentUser, dapper)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Poem

I hop through Promises, soft and light,
Awaiting data mid-suspenseful night.
Meta blooms when truths arrive,
Listings load, the grids revive.
With lighter CSS and roots that guide,
I twitch my nose—then ship with pride. 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 09-01-add_suspense_usage

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 or @coderabbit 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 Author

Oksamies commented Sep 1, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

Comment on lines +146 to +184
<Suspense>
<Await resolve={community}>
{(resolvedValue) => {
return (
<>
<meta
title={`Thunderstore - The ${resolvedValue.name} Mod Database`}
/>
<meta
name="description"
content={`Mods for ${resolvedValue.name}`}
/>
<meta property="og:type" content="website" />
<meta
property="og:url"
content={`${
getPublicEnvVariables(["VITE_SITE_URL"]).VITE_SITE_URL
}${location.pathname}`}
/>
<meta
property="og:title"
content={`Thunderstore - The ${resolvedValue.name} Mod Database`}
/>
<meta
property="og:description"
content={`Thunderstore is a mod database and API for downloading ${resolvedValue.name} mods`}
/>
<meta property="og:image:width" content="360" />
<meta property="og:image:height" content="480" />
<meta
property="og:image"
content={resolvedValue.cover_image_url ?? undefined}
/>
<meta property="og:site_name" content="Thunderstore" />
</>
);
}}
</Await>
</Suspense>
Copy link

Choose a reason for hiding this comment

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

Meta tags implementation issue

The current implementation places meta tags inside Suspense/Await blocks within the component body, which is problematic for SEO and metadata functionality. Meta tags need to be in the document <head> to be properly recognized by search engines and social media platforms.

The original approach using the meta function was more appropriate for setting document metadata, as React Router handles placing these tags in the document head.

Consider reverting to the previous pattern:

export const meta: MetaFunction<typeof loader> = ({ data, location }) => {
  return [
    { title: `Thunderstore - The ${data?.community.name} Mod Database` },
    // other meta tags...
  ];
};

If you need to handle the asynchronous nature of the data, consider alternative approaches that ensure meta tags are properly placed in the document head while still supporting the suspense pattern.

Suggested change
<Suspense>
<Await resolve={community}>
{(resolvedValue) => {
return (
<>
<meta
title={`Thunderstore - The ${resolvedValue.name} Mod Database`}
/>
<meta
name="description"
content={`Mods for ${resolvedValue.name}`}
/>
<meta property="og:type" content="website" />
<meta
property="og:url"
content={`${
getPublicEnvVariables(["VITE_SITE_URL"]).VITE_SITE_URL
}${location.pathname}`}
/>
<meta
property="og:title"
content={`Thunderstore - The ${resolvedValue.name} Mod Database`}
/>
<meta
property="og:description"
content={`Thunderstore is a mod database and API for downloading ${resolvedValue.name} mods`}
/>
<meta property="og:image:width" content="360" />
<meta property="og:image:height" content="480" />
<meta
property="og:image"
content={resolvedValue.cover_image_url ?? undefined}
/>
<meta property="og:site_name" content="Thunderstore" />
</>
);
}}
</Await>
</Suspense>
export const meta: MetaFunction<typeof loader> = ({ data, location }) => {
if (!data?.community) {
return [];
}
const resolvedValue = data.community;
const siteUrl = getPublicEnvVariables(["VITE_SITE_URL"]).VITE_SITE_URL;
return [
{
title: `Thunderstore - The ${resolvedValue.name} Mod Database`
},
{
name: "description",
content: `Mods for ${resolvedValue.name}`
},
{ property: "og:type", content: "website" },
{
property: "og:url",
content: `${siteUrl}${location.pathname}`
},
{
property: "og:title",
content: `Thunderstore - The ${resolvedValue.name} Mod Database`
},
{
property: "og:description",
content: `Thunderstore is a mod database and API for downloading ${resolvedValue.name} mods`
},
{ property: "og:image:width", content: "360" },
{ property: "og:image:height", content: "480" },
{
property: "og:image",
content: resolvedValue.cover_image_url ?? undefined
},
{ property: "og:site_name", content: "Thunderstore" }
];
};

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Copy link

@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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
apps/cyberstorm-remix/app/root.tsx (1)

221-226: Sanitize window.ENV injection to prevent XSS.

Unescaped JSON inside a <script> can break out via </script> or U+2028/2029. Escape before injecting.

-        <script
-          dangerouslySetInnerHTML={{
-            __html: `window.ENV = ${JSON.stringify(
-              data.publicEnvVariables.ENV
-            )}`,
-          }}
-        />
+        <script
+          dangerouslySetInnerHTML={{
+            __html: (() => {
+              const json = JSON.stringify(data.publicEnvVariables.ENV)
+                .replace(/</g, "\\u003C")
+                .replace(/\u2028/g, "\\u2028")
+                .replace(/\u2029/g, "\\u2029");
+              return `window.ENV = ${json};`;
+            })(),
+          }}
+        />
apps/cyberstorm-remix/app/commonComponents/PackageSearch/PackageSearch.tsx (1)

483-490: Rated packages never load on initial render when user is already logged in.

useRef(currentUser) prevents the effect from firing on mount. Fetch once on mount when currentUser exists.

   const currentUserRef = useRef(currentUser);
   useEffect(() => {
+    // initial load
+    if (currentUser?.username) {
+      fetchAndSetRatedPackages();
+    }
+  }, []);
+
+  useEffect(() => {
     if (currentUserRef.current !== currentUser && currentUser?.username) {
       fetchAndSetRatedPackages();
       currentUserRef.current = currentUser;
     }
   }, [currentUser]);
🧹 Nitpick comments (9)
apps/cyberstorm-remix/app/root.tsx (2)

15-16: Remove dead import comment.

Drop the commented // useRouteLoaderData, to avoid confusion.

-  // useRouteLoaderData,

271-279: Switch to useLoaderData looks good; verify typing.

useLoaderData<RootLoadersType>() assumes loaders return the same shape. If they ever diverge, prefer useLoaderData<typeof loader | typeof clientLoader>() for tighter inference.

apps/cyberstorm-remix/app/commonComponents/PackageSearch/PackageSearch.tsx (5)

299-310: Effect uses navigationType but doesn’t list it as a dependency.

Add it to avoid stale reads on back/forward navigations.

-  }, [searchParams]);
+  }, [searchParams, navigationType]);

311-475: Same here: include navigationType in deps.

Prevents logic running with an outdated navigation mode.

-  }, [debouncedSearchParamsBlob]);
+  }, [debouncedSearchParamsBlob, navigationType]);

586-600: Consolidate Await/Suspense to reduce triple fallback flashes.

You’re awaiting the same promise three times. Consider one boundary higher up and pass the resolved data down to Count, Grid, and Pagination to avoid repeated “Loading...” flicker.

Also applies to: 612-683, 684-699


586-600: Surface an error state instead of empty fragments.

errorElement={<></>} swallows errors silently. Show a minimal failure message and/or retry.

- <Await resolve={listings} errorElement={<></>}>
+ <Await resolve={listings} errorElement={<div className="package-search__error">Failed to load results.</div>}>

Also applies to: 612-683, 684-699


114-123: Avoid empty string entries when parsing categories.

Filter falsy IDs after split to be safe.

-  const iCArr = includedCategories.split(",");
-  const eCArr = excludedCategories.split(",");
+  const iCArr = includedCategories.split(",").filter(Boolean);
+  const eCArr = excludedCategories.split(",").filter(Boolean);
apps/cyberstorm-remix/app/c/community.tsx (2)

186-204: Hero rendering via Suspense is fine. Consider using defer for clarity.

Using React Router defer communicates intent and streams better. Not mandatory, but it simplifies loaders and typing.

// Example
import { defer } from "react-router";
return defer({
  community: dapper.getCommunity(params.communityId),
  listings: dapper.getPackageListings(/* ... */),
  filters, // awaited before
  sortedSections,
});

214-223: Minor: “Loading” breadcrumb fallback.

Use a consistent fallback (e.g., “Loading…” with ellipsis) or a skeleton to avoid layout shift.

-              <Suspense fallback={<>Loading</>}>
+              <Suspense fallback={<>Loading…</>}>
📜 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 a64e10e and 7e0b924.

📒 Files selected for processing (4)
  • apps/cyberstorm-remix/app/c/community.tsx (6 hunks)
  • apps/cyberstorm-remix/app/commonComponents/PackageSearch/PackageSearch.tsx (5 hunks)
  • apps/cyberstorm-remix/app/commonComponents/PageHeader/PageHeader.css (0 hunks)
  • apps/cyberstorm-remix/app/root.tsx (2 hunks)
💤 Files with no reviewable changes (1)
  • apps/cyberstorm-remix/app/commonComponents/PageHeader/PageHeader.css
🧰 Additional context used
🧬 Code graph analysis (2)
apps/cyberstorm-remix/app/commonComponents/PackageSearch/PackageSearch.tsx (3)
packages/dapper/src/types/package.ts (1)
  • PackageListings (20-20)
apps/cyberstorm-remix/app/commonComponents/PackageSearch/components/PackageCount/PackageCount.tsx (1)
  • PackageCount (19-36)
packages/cyberstorm/src/newComponents/Card/CardPackage/CardPackage.tsx (1)
  • CardPackage (40-271)
apps/cyberstorm-remix/app/c/community.tsx (3)
apps/cyberstorm-remix/app/p/packageListing.tsx (1)
  • meta (85-131)
apps/cyberstorm-remix/cyberstorm/security/publicEnvVariables.ts (1)
  • getPublicEnvVariables (17-35)
apps/cyberstorm-remix/app/commonComponents/PageHeader/PageHeader.tsx (1)
  • PageHeader (17-81)
⏰ 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). (3)
  • GitHub Check: Generate visual diffs
  • GitHub Check: Test
  • GitHub Check: CodeQL

Comment on lines 50 to 56
const filters = await dapper.getCommunityFilters(params.communityId);
const sortedSections = filters.sections.sort(
(a, b) => b.priority - a.priority
);
return {
community: community,
filters: filters,
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Await community on the server loader to guarantee meta data.

Keep the UI using Suspense if desired, but resolve community on the server so the meta export has the data during SSR. Client loader can keep returning a Promise.

-    const community = dapper.getCommunity(params.communityId);
+    const community = await dapper.getCommunity(params.communityId);
📝 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
const filters = await dapper.getCommunityFilters(params.communityId);
const sortedSections = filters.sections.sort(
(a, b) => b.priority - a.priority
);
return {
community: community,
filters: filters,
const community = await dapper.getCommunity(params.communityId);
const filters = await dapper.getCommunityFilters(params.communityId);
const sortedSections = filters.sections.sort(
(a, b) => b.priority - a.priority
);
return {
community: community,
filters: filters,
};
🤖 Prompt for AI Agents
In apps/cyberstorm-remix/app/c/community.tsx around lines 50 to 56, the loader
returns a Promise for `community` which prevents `meta` from having
server-resolved data during SSR; change the loader to await the community fetch
before returning (i.e., await dapper.getCommunity(params.communityId) and assign
the resolved object to `community`) so the returned object contains concrete
community data for meta generation, while keeping the client-side code able to
return a Promise if desired.

Comment on lines +146 to +185
<Await resolve={community}>
{(resolvedValue) => {
return (
<>
<meta
title={`Thunderstore - The ${resolvedValue.name} Mod Database`}
/>
<meta
name="description"
content={`Mods for ${resolvedValue.name}`}
/>
<meta property="og:type" content="website" />
<meta
property="og:url"
content={`${
getPublicEnvVariables(["VITE_SITE_URL"]).VITE_SITE_URL
}${location.pathname}`}
/>
<meta
property="og:title"
content={`Thunderstore - The ${resolvedValue.name} Mod Database`}
/>
<meta
property="og:description"
content={`Thunderstore is a mod database and API for downloading ${resolvedValue.name} mods`}
/>
<meta property="og:image:width" content="360" />
<meta property="og:image:height" content="480" />
<meta
property="og:image"
content={resolvedValue.cover_image_url ?? undefined}
/>
<meta property="og:site_name" content="Thunderstore" />
</>
);
}}
</Await>
</Suspense>

<Suspense>
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Meta tags rendered in the body won’t set document metadata. Reintroduce route meta.

Placing (and a “title” attribute) in the body is invalid and breaks SEO/sharing. Use a route meta export so in root can render these into .

-      <Suspense>
-        <Await resolve={community}>
-          {(resolvedValue) => {
-            return (
-              <>
-                <meta
-                  title={`Thunderstore - The ${resolvedValue.name} Mod Database`}
-                />
-                <meta
-                  name="description"
-                  content={`Mods for ${resolvedValue.name}`}
-                />
-                <meta property="og:type" content="website" />
-                <meta
-                  property="og:url"
-                  content={`${getPublicEnvVariables(["VITE_SITE_URL"]).VITE_SITE_URL}${location.pathname}`}
-                />
-                <meta
-                  property="og:title"
-                  content={`Thunderstore - The ${resolvedValue.name} Mod Database`}
-                />
-                <meta
-                  property="og:description"
-                  content={`Thunderstore is a mod database and API for downloading ${resolvedValue.name} mods`}
-                />
-                <meta property="og:image:width" content="360" />
-                <meta property="og:image:height" content="480" />
-                <meta
-                  property="og:image"
-                  content={resolvedValue.cover_image_url ?? undefined}
-                />
-                <meta property="og:site_name" content="Thunderstore" />
-              </>
-            );
-          }}
-        </Await>
-      </Suspense>

Add a proper meta export (outside this hunk):

import type { MetaFunction } from "react-router";

export const meta: MetaFunction<typeof loader | typeof clientLoader> = ({
  data,
  location,
}) => {
  const site = getPublicEnvVariables(["VITE_SITE_URL"]).VITE_SITE_URL;
  const name =
    // supports server loader resolving the community or client loader promise
    (data as any)?.community?.name ?? undefined;
  return [
    {
      title: name
        ? `Thunderstore - The ${name} Mod Database`
        : "Thunderstore - The Mod Database",
    },
    {
      name: "description",
      content: name ? `Mods for ${name}` : "Thunderstore mod database",
    },
    { property: "og:type", content: "website" },
    { property: "og:url", content: `${site}${location.pathname}` },
    {
      property: "og:title",
      content: name ? `Thunderstore - The ${name} Mod Database` : "Thunderstore",
    },
    {
      property: "og:description",
      content: name
        ? `Thunderstore is a mod database and API for downloading ${name} mods`
        : "Thunderstore is a mod database and API",
    },
    { property: "og:site_name", content: "Thunderstore" },
  ];
};
🤖 Prompt for AI Agents
In apps/cyberstorm-remix/app/c/community.tsx around lines 146–185, the component
is rendering <meta> tags inside the body which won’t set document head metadata;
remove these body meta tags and add a route-level export named meta (using the
MetaFunction type) outside this component file/hunk that builds and returns an
array of meta objects: derive site URL from
getPublicEnvVariables(["VITE_SITE_URL"]).VITE_SITE_URL, resolve the community
name from data (supporting server loader or client promise), and populate title,
description, og:type, og:url (using location.pathname), og:title,
og:description, and og:site_name accordingly so the app’s <Meta /> in root can
inject proper head tags for SEO/sharing.

@Oksamies Oksamies closed this Sep 15, 2025
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