Skip to content

Comments

[WIKI-551] refactor: work item activity logic#7417

Merged
sriramveeraghanta merged 1 commit intopreviewfrom
refactor/activity
Jul 15, 2025
Merged

[WIKI-551] refactor: work item activity logic#7417
sriramveeraghanta merged 1 commit intopreviewfrom
refactor/activity

Conversation

@aaryan610
Copy link
Member

@aaryan610 aaryan610 commented Jul 15, 2025

Description

This PR includes the following changes-

  1. New loader implementation for work item activity and comments.
  2. Refactored the way how activity and comments were being fetched, stored and displayed.

Type of Change

  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring

Summary by CodeRabbit

  • New Features

    • Introduced a loading indicator for issue activity content, providing visual feedback while data is loading.
  • Refactor

    • Updated activity and comment retrieval to use a unified method, ensuring activities and comments are combined and displayed together.
    • Improved handling of empty and loading states in the issue activity section for a smoother user experience.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 15, 2025

Walkthrough

The changes rename and update a store method to return combined activity and comment data, update a React component to use this new method and handle loading and empty states, and introduce a new loader component for visual feedback during data fetching.

Changes

Files Change Summary
apps/web/ce/store/issue/issue-details/activity.store.ts Renamed and updated method to return combined activities and comments; updated interface and class.
apps/web/core/components/issues/issue-detail/issue-activity/activity-comment-root.tsx Switched to new combined data method, added loading state, updated empty state and filtering logic.
apps/web/core/components/issues/issue-detail/issue-activity/loader.tsx Added new IssueActivityLoader component for activity loading UI.

Suggested labels

🧹chore

Suggested reviewers

  • prateekshourya29
  • pushya22

Poem

In the warren of code, a method’s new name,
Activities and comments now play the same game.
A loader appears, with shimmer and gleam,
While rabbits await their activity stream.
With hops and with bounds, the changes take root—
A tidy new flow, both combined and astute!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.

@makeplane
Copy link

makeplane bot commented Jul 15, 2025

Pull Request Linked with Plane Work Items

Comment Automatically Generated by Plane

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

🔭 Outside diff range comments (1)
apps/web/core/components/issues/issue-detail/issue-activity/activity-comment-root.tsx (1)

55-90: Fix missing key prop in mapped elements.

The static analysis tool correctly identifies that the mapped elements are missing the key prop, which is required for React's reconciliation process.

Apply this fix:

-      {filteredActivityAndComments.map((activityComment, index) => {
+      {filteredActivityAndComments.map((activityComment, index) => {
         const comment = getCommentById(activityComment.id);
         return activityComment.activity_type === "COMMENT" ? (
           <CommentCard
             key={activityComment.id}

Add the key prop to all other rendered elements:

         ) : activityComment.activity_type === "ACTIVITY" ? (
           <IssueActivityItem
+            key={activityComment.id}
             activityId={activityComment.id}
             ends={index === 0 ? "top" : index === filteredActivityAndComments.length - 1 ? "bottom" : undefined}
           />
         ) : activityComment.activity_type === "ISSUE_ADDITIONAL_PROPERTIES_ACTIVITY" ? (
           <IssueAdditionalPropertiesActivity
+            key={activityComment.id}
             activityId={activityComment.id}
             ends={index === 0 ? "top" : index === filteredActivityAndComments.length - 1 ? "bottom" : undefined}
           />
         ) : activityComment.activity_type === "WORKLOG" ? (
           <IssueActivityWorklog
+            key={activityComment.id}
             workspaceSlug={workspaceSlug}
             projectId={projectId}
             issueId={issueId}
             activityComment={activityComment}
             ends={index === 0 ? "top" : index === filteredActivityAndComments.length - 1 ? "bottom" : undefined}
           />
         ) : (
-          <></>
+          <div key={activityComment.id}></div>
         );
🧹 Nitpick comments (2)
apps/web/core/components/issues/issue-detail/issue-activity/loader.tsx (1)

6-29: Consider extracting repeated block structure to reduce duplication.

The three loader blocks share identical structure with only minor width variations. Consider extracting this into a reusable sub-component or loop structure.

Example refactor:

+const LoaderBlock = ({ widths }: { widths: [string, string, string] }) => (
+  <div className="flex items-start gap-3">
+    <Loader.Item className="shrink-0" height="28px" width="28px" />
+    <div className="space-y-2 w-full">
+      <Loader.Item height="8px" width={widths[0]} />
+      <Loader.Item height="8px" width={widths[1]} />
+      <Loader.Item height="10px" width={widths[2]} />
+    </div>
+  </div>
+);

 export const IssueActivityLoader = () => (
   <Loader className="space-y-8">
-    <div className="flex items-start gap-3">
-      <Loader.Item className="shrink-0" height="28px" width="28px" />
-      <div className="space-y-2 w-full">
-        <Loader.Item height="8px" width="60%" />
-        <Loader.Item height="8px" width="40%" />
-        <Loader.Item height="10px" width="100%" />
-      </div>
-    </div>
-    <div className="flex items-start gap-3">
-      <Loader.Item className="shrink-0" height="28px" width="28px" />
-      <div className="space-y-2 w-full">
-        <Loader.Item height="8px" width="40%" />
-        <Loader.Item height="8px" width="60%" />
-        <Loader.Item height="10px" width="80%" />
-      </div>
-    </div>
-    <div className="flex items-start gap-3">
-      <Loader.Item className="shrink-0" height="28px" width="28px" />
-      <div className="space-y-2 w-full">
-        <Loader.Item height="8px" width="60%" />
-        <Loader.Item height="8px" width="40%" />
-        <Loader.Item height="10px" width="100%" />
-      </div>
-    </div>
+    <LoaderBlock widths={["60%", "40%", "100%"]} />
+    <LoaderBlock widths={["40%", "60%", "80%"]} />
+    <LoaderBlock widths={["60%", "40%", "100%"]} />
   </Loader>
 );
apps/web/core/components/issues/issue-detail/issue-activity/activity-comment-root.tsx (1)

87-89: Improve fallback case handling.

The fallback case returns an empty fragment, which should either have a key prop or be replaced with null.

Consider this improvement:

-        ) : (
-          <></>
-        );
+        ) : null;

Or if you need to maintain the element for layout purposes:

-        ) : (
-          <></>
-        );
+        ) : (
+          <div key={activityComment.id} />
+        );
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2058f06 and efc37e5.

📒 Files selected for processing (3)
  • apps/web/ce/store/issue/issue-details/activity.store.ts (3 hunks)
  • apps/web/core/components/issues/issue-detail/issue-activity/activity-comment-root.tsx (3 hunks)
  • apps/web/core/components/issues/issue-detail/issue-activity/loader.tsx (1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: prateekshourya29
PR: makeplane/plane#7188
File: web/app/(all)/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/cycles/(list)/header.tsx:40-45
Timestamp: 2025-06-18T09:46:08.566Z
Learning: When reviewing breadcrumb components that accept projectId or similar props, check if empty strings are being passed during loading states, which can result in invalid URLs. The preferred approach is to handle these loading states internally within the component rather than requiring each consumer to manage the loading logic.
apps/web/core/components/issues/issue-detail/issue-activity/loader.tsx (1)
Learnt from: lifeiscontent
PR: makeplane/plane#7164
File: packages/ui/.storybook/main.ts:24-47
Timestamp: 2025-06-04T16:22:44.344Z
Learning: In packages/ui/.storybook/main.ts, the webpackFinal function intentionally overrides the CSS loader strategy by finding and replacing existing CSS rules. This is a temporary workaround for a known upstream issue in Storybook's CSS handling that has been communicated to the Storybook maintainers. The current implementation should not be changed until the upstream issue is resolved.
apps/web/core/components/issues/issue-detail/issue-activity/activity-comment-root.tsx (1)
Learnt from: vamsikrishnamathala
PR: makeplane/plane#7061
File: web/core/components/workspace-notifications/root.tsx:18-18
Timestamp: 2025-05-14T13:16:23.323Z
Learning: In the Plane project codebase, the path alias `@/plane-web` resolves to the `ce` directory, making imports like `@/plane-web/hooks/use-notification-preview` correctly resolve to files in `web/ce/hooks/`.
apps/web/ce/store/issue/issue-details/activity.store.ts (1)
Learnt from: vamsikrishnamathala
PR: makeplane/plane#7214
File: web/core/store/issue/helpers/base-issues.store.ts:117-117
Timestamp: 2025-06-16T07:23:39.497Z
Learning: In the updateIssueDates method of BaseIssuesStore (web/core/store/issue/helpers/base-issues.store.ts), the projectId parameter is intentionally made optional to support override implementations in subclasses. The base implementation requires projectId and includes an early return check, but making it optional allows derived classes to override the method with different parameter requirements.
🪛 Biome (1.9.4)
apps/web/core/components/issues/issue-detail/issue-activity/activity-comment-root.tsx

[error] 75-78: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

🔇 Additional comments (8)
apps/web/core/components/issues/issue-detail/issue-activity/loader.tsx (1)

4-31: Well-implemented loading component with good visual hierarchy.

The loader component follows established skeleton loading patterns with proper spacing, sizing, and visual variation. The repeated structure effectively simulates the expected content layout.

apps/web/core/components/issues/issue-detail/issue-activity/activity-comment-root.tsx (3)

41-41: Good refactoring to use the renamed store method.

The update to use getActivityAndCommentsByIssueId aligns with the store changes and maintains consistency in the codebase.


47-47: Proper loading state handling with the new loader component.

The integration of IssueActivityLoader provides good visual feedback during data fetching and handles the undefined state appropriately.


49-49: Good improvement: using null instead of empty fragment.

Returning null for empty states is more semantically correct than an empty fragment and properly indicates "no content" to React.

apps/web/ce/store/issue/issue-details/activity.store.ts (4)

46-46: Good method renaming for clarity.

The renamed method getActivityAndCommentsByIssueId better describes its purpose of returning combined activity and comment data.


87-123: Improved data handling with proper undefined checks.

The refactored method includes better error handling with early returns for missing data and uses optional chaining appropriately. The explicit undefined return enables proper loading state detection in consuming components.


100-118: Consistent use of optional chaining for safe iteration.

The optional chaining usage in the forEach loops provides safe iteration over potentially undefined arrays, preventing runtime errors.


98-98: Verification complete: All references updated to the new method
rg confirms no occurrences of getActivityCommentByIssueId remain; only getActivityAndCommentsByIssueId is in use.

@sriramveeraghanta sriramveeraghanta merged commit df762af into preview Jul 15, 2025
5 of 6 checks passed
@sriramveeraghanta sriramveeraghanta deleted the refactor/activity branch July 15, 2025 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants