Skip to content

Conversation

@Oksamies
Copy link
Contributor

As the package like action uses a toast, it needs the provided to be
present, when it's fired up. This means that it can't be a globally "in
the file" defined function, but rather has to be defined within the
route function, so that it has access to the provider when it's
initializedFix package like action usage in package page

As the package like action uses a toast, it needs the provided to be
present, when it's fired up. This means that it can't be a globally "in
the file" defined function, but rather has to be defined within the
route function, so that it has access to the provider when it's
initialized.

As the package like action uses a toast, it needs the provided to be
present, when it's fired up. This means that it can't be a globally "in
the file" defined function, but rather has to be defined within the
route function, so that it has access to the provider when it's
initializedFix package like action usage in package page

As the package like action uses a toast, it needs the provided to be
present, when it's fired up. This means that it can't be a globally "in
the file" defined function, but rather has to be defined within the
route function, so that it has access to the provider when it's
initialized.
Copy link
Contributor Author

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

@coderabbitai
Copy link

coderabbitai bot commented Oct 21, 2025

Walkthrough

The packageListing.tsx file introduces a new packageLikeAction instance that consolidates the package liking logic. The Actions component's props signature is updated to accept packageLikeAction as a single function parameter, replacing the previous separate likeUpdateTrigger and requestConfig props. The likeAction helper is removed and its invocations are replaced with direct packageLikeAction calls throughout the component. This action is propagated to both the main listing detail area and sidebar render paths where Actions is used.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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
Title Check ✅ Passed The title "Fix package like action usage in package page" directly and specifically describes the primary change in the pull request. The raw summary confirms the PR refactors how the packageLikeAction is instantiated and propagated within the package listing component. The title is concise, avoids vague phrasing, and clearly communicates the main change without noise or unnecessary detail.
Description Check ✅ Passed The description is directly related to the changeset, explaining the technical rationale for moving the packageLikeAction definition inside the route function to ensure access to the provider when the action fires. This reasoning aligns with the actual changes shown in the raw summary where the action is now instantiated within PackageListing rather than as a global handler. While the description is somewhat repetitive, it remains on-topic and related to the changes.
✨ 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 10-21-fix_package_like_action_usage_in_package_page

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.

@codecov
Copy link

codecov bot commented Oct 21, 2025

Codecov Report

❌ Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 9.89%. Comparing base (ed81119) to head (17db301).

Files with missing lines Patch % Lines
apps/cyberstorm-remix/app/p/packageListing.tsx 0.00% 9 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##           master   #1588   +/-   ##
======================================
  Coverage    9.89%   9.89%           
======================================
  Files         308     308           
  Lines       22497   22482   -15     
  Branches      404     404           
======================================
  Hits         2225    2225           
+ Misses      20272   20257   -15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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: 0

Caution

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

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

293-297: Bug: og:url builds “[object Object]/path” instead of a full URL.

getPublicEnvVariables returns an object; access the VITE_BETA_SITE_URL key.

-              <meta
-                property="og:url"
-                content={`${getPublicEnvVariables(["VITE_BETA_SITE_URL"])}${location.pathname}`}
-              />
+              <meta
+                property="og:url"
+                content={`${getPublicEnvVariables(["VITE_BETA_SITE_URL"]).VITE_BETA_SITE_URL}${location.pathname}`}
+              />
🧹 Nitpick comments (5)
apps/cyberstorm-remix/app/p/packageListing.tsx (5)

193-209: Stabilize dataUpdateTrigger with useCallback.

This avoids recreating the trigger each render and reduces stale-closure risk.

-  const fetchAndSetRatedPackages = async () => {
+  const fetchAndSetRatedPackages = useCallback(async () => {
     const rp = await dapper.getRatedPackages();
     if (isPromise(listing)) {
       listing.then((listingData) => {
         setIsLiked(
           rp.rated_packages.includes(
             `${listingData.namespace}-${listingData.name}`
           )
         );
       });
     } else {
       setIsLiked(
         rp.rated_packages.includes(`${listing.namespace}-${listing.name}`)
       );
     }
-  };
+  }, [dapper, listing]);

Also add the import:

-import {
-  memo,
-  type ReactElement,
-  Suspense,
-  useEffect,
-  useMemo,
-  useRef,
-  useState,
-} from "react";
+import {
+  memo,
+  type ReactElement,
+  Suspense,
+  useEffect,
+  useMemo,
+  useRef,
+  useState,
+  useCallback,
+} from "react";

210-215: Include the stabilized trigger in effect deps.

Ensures the effect responds if the trigger changes (e.g., route swap).

-  }, [currentUser]);
+  }, [currentUser, fetchAndSetRatedPackages]);

438-445: Prop pass-through looks correct in both render paths.

Both call sites now pass packageLikeAction consistently. If you want to retain memo benefits for Actions, consider ignoring handler identity in a custom comparator (see note on component below).

Also applies to: 601-607


960-972: Actions props: minor polish to reduce re-renders and ambiguity.

  • Optional: rename prop to onPackageLike to avoid name clash with the imported factory and improve readability.
  • Optional: add a memo comparator to ignore handler identity churn.

Example comparator:

const Actions = memo(function Actions(props: {...}) {
  // ...
}, (prev, next) =>
  prev.isLiked === next.isLiked &&
  prev.listing === next.listing &&
  prev.team === next.team &&
  (prev.currentUser?.username ?? "") === (next.currentUser?.username ?? "")
);

1001-1008: Tooltip should reflect toggle state.

Show “Unlike” when already liked.

-        tooltipText="Like"
+        tooltipText={isLiked ? "Unlike" : "Like"}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ed81119 and 17db301.

📒 Files selected for processing (1)
  • apps/cyberstorm-remix/app/p/packageListing.tsx (5 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
apps/cyberstorm-remix/app/p/packageListing.tsx (2)
packages/cyberstorm-forms/src/actions/PackageLikeAction.tsx (1)
  • PackageLikeAction (9-56)
packages/cyberstorm-forms/src/index.ts (1)
  • PackageLikeAction (2-2)
⏰ 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). (1)
  • GitHub Check: Build
🔇 Additional comments (2)
apps/cyberstorm-remix/app/p/packageListing.tsx (2)

273-278: Good fix: create the like action inside the route component.

This aligns with the toast/provider requirement and removes the global handler hazard. Keep this call at component top-level (not inside useMemo/conditions) so the internal hook usage remains valid.


960-971: Verified: All Actions call sites updated correctly.

The verification script found no remaining usages of the Actions component with the old props (likeUpdateTrigger or requestConfig). The requestConfig matches found were in unrelated modules (MultipartUpload, upload context extraction, DeleteAccountForm), not the Actions component. ✓

@Oksamies Oksamies requested a review from anttimaki October 23, 2025 10:43
Copy link
Contributor

@anttimaki anttimaki left a comment

Choose a reason for hiding this comment

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

so that it has access to the provider when it's
initializedFix package like action usage in package page

Had to read the commit couple of times until I realized that initializedFix is not a name of some variable or function 😅 . So feel free to fix the commit message.

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