Skip to content

[WEB-3837] fix: mutation of child work item added via Cmd+K with parent context#6910

Merged
sriramveeraghanta merged 1 commit intopreviewfrom
fix-cmdk-sub-work-item-mutation
Apr 10, 2025
Merged

[WEB-3837] fix: mutation of child work item added via Cmd+K with parent context#6910
sriramveeraghanta merged 1 commit intopreviewfrom
fix-cmdk-sub-work-item-mutation

Conversation

@anmolsinghbhatia
Copy link
Collaborator

@anmolsinghbhatia anmolsinghbhatia commented Apr 10, 2025

Summary

Fixed an issue where adding a new work item via the Cmd+K menu, with the current detail page set as its parent, didn’t immediately update the UI to reflect the change. The mutation logic was updated to ensure newly added child items appear instantly, and data syncing was improved for a smoother user experience.

Type of Change

  • Bug fix

References

[WEB-3837]

Summary by CodeRabbit

  • New Features
    • Enhanced the issue deletion workflow to automatically apply the appropriate process for different issue types, ensuring proper handling and redirection after deletion.
    • Streamlined the issue creation process with improved validations and a smoother submission experience, reducing errors during the creation of various issue types.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 10, 2025

Walkthrough

This change refactors the issue handling within the IssueLevelModals component. The deletion flow now distinguishes between epic and project issues by calling either removeEpic or removeWorkItem via the new useIssuesActions hook. Additionally, asynchronous functions handleDeleteIssue and handleCreateIssueSubmit have been introduced to manage deletion and creation logic, respectively. A helper function, getCreateIssueModalData, was also added to streamline modal data preparation, alongside improved error handling and redirect logic.

Changes

File Change Summary
web/.../command-palette/modals/issue-level.tsx Refactored deletion logic: replaced useIssuesStore with useIssuesActions to differentiate between epic and project issue deletion. Added handleDeleteIssue for deletion, handleCreateIssueSubmit for creation, and getCreateIssueModalData for modal data preparation, with enhanced error handling and redirection.

Sequence Diagram(s)

sequenceDiagram
    participant UI as User Interface
    participant ILM as IssueLevelModals
    participant Actions as Issues Actions Hook

    UI->>ILM: Trigger handleDeleteIssue(issueId, workspaceSlug, projectId)
    ILM->>ILM: Check if issue is Epic?
    alt Issue is Epic
        ILM->>Actions: Call removeEpic(issueId)
    else Issue is Project Issue
        ILM->>Actions: Call removeWorkItem(issueId)
    end
    Actions-->>ILM: Return result
    ILM->>UI: Redirect on success / Show error on failure
Loading
sequenceDiagram
    participant UI as User Interface
    participant ILM as IssueLevelModals
    participant API as Backend API

    UI->>ILM: Trigger handleCreateIssueSubmit(newIssue)
    ILM->>ILM: Validate newIssue properties
    alt Issue is Epic
        ILM->>API: Call createEpic(newIssue)
    else Standard Work Item
        ILM->>API: Call createWorkItem(newIssue)
    end
    API-->>ILM: Return creation result
    ILM->>ILM: Prepare modal data with getCreateIssueModalData()
    ILM->>UI: Update modal with new issue details
Loading

Possibly Related PRs

Suggested Labels

🐛bug

Suggested Reviewers

  • sriramveeraghanta
  • prateekshourya29

Poem

I'm a coding bunny with hops so neat,
Leaping through issues with a spring in my beat.
I nibble on bugs like carrots so sweet,
Sorting epics and work items with swift little feet.
In the tech garden, my code grows and shines bright!
🐰🥕

✨ 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.
    • 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.

@makeplane
Copy link

makeplane bot commented Apr 10, 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

🧹 Nitpick comments (2)
web/ce/components/command-palette/modals/issue-level.tsx (2)

49-60: Consider user-facing error handling.
While the try/catch logs errors, users might benefit from a more explicit error notification when deletion fails.

You could add a toast or alert modal to provide feedback:

} catch (error) {
-  console.error("Failed to delete issue:", error);
+  console.error("Failed to delete issue:", error);
+  // e.g., add a toast notification here
}

62-67: Improve error handling during issue creation.
Currently, this function silently returns if any condition fails. Consider adding confirmation or logging for debug purposes, especially if fetchSubWorkItems or fetchEpicSubWorkItems throws.

const handleCreateIssueSubmit = async (newIssue: TIssue) => {
  if (!workspaceSlug || !newIssue.project_id || !newIssue.id || newIssue.parent_id !== issueDetails?.id) {
    // e.g., console.error or show a toast about invalid submission
    return;
  }
  try {
    const fetchAction = issueDetails?.is_epic ? fetchEpicSubWorkItems : fetchSubWorkItems;
    await fetchAction(workspaceSlug?.toString(), newIssue.project_id, issueDetails.id);
  } catch (error) {
    console.error("Issue creation failed:", error);
  }
};
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0ae57b4 and 7780aed.

📒 Files selected for processing (1)
  • web/ce/components/command-palette/modals/issue-level.tsx (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
web/ce/components/command-palette/modals/issue-level.tsx (5)
web/core/hooks/use-issues-actions.tsx (1)
  • useIssuesActions (40-82)
web/core/hooks/store/use-issue-detail.ts (1)
  • useIssueDetail (9-14)
packages/types/src/issues/issue.d.ts (1)
  • TIssue (54-67)
web/core/components/issues/issue-modal/modal.tsx (1)
  • CreateUpdateIssueModal (34-50)
web/core/components/issues/delete-issue-modal.tsx (1)
  • DeleteIssueModal (27-125)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (8)
web/ce/components/command-palette/modals/issue-level.tsx (8)

4-6: Imports look good.
No issues here; this is a straightforward addition of imports and labeling with a comment.


13-13: New import usage is appropriate.
The import for useIssuesActions looks correct and consistent with the rest of the codebase.


31-34: Clear separation of epic vs. work item removal.
Renaming the imported removeIssue function is a good approach for readability, ensuring each removal action is context-specific.


46-47: Well-structured fetch action for sub-issues.
These aliases effectively distinguish between epic vs. standard work items, aligning with the logic in useIssueDetail.


69-73: Data preparation method is concise.
This function cleanly handles conditional modal data logic.


80-80: Correct usage of modal data.
Passing the computed object from getCreateIssueModalData() ensures the right fields are pre-filled.


82-82: Submission handler properly assigned.
The onSubmit prop correctly references the newly introduced handleCreateIssueSubmit.


89-90: Deletion callback is well-integrated.
The code ensures the workspace, project, and issue IDs are passed in a controlled context, preventing undefined values.

@sriramveeraghanta sriramveeraghanta merged commit 33a1b91 into preview Apr 10, 2025
5 of 6 checks passed
@sriramveeraghanta sriramveeraghanta deleted the fix-cmdk-sub-work-item-mutation branch April 10, 2025 20:10
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