Skip to content

[WIKI-637] fix: work item description version history#7725

Merged
sriramveeraghanta merged 2 commits intopreviewfrom
fix/work-item-description-version
Sep 4, 2025
Merged

[WIKI-637] fix: work item description version history#7725
sriramveeraghanta merged 2 commits intopreviewfrom
fix/work-item-description-version

Conversation

@aaryan610
Copy link
Member

@aaryan610 aaryan610 commented Sep 4, 2025

Description

This PR fixes the bug where description version history for work items doesn't render when the modal is opened initially, but renders fine when it is re-opened.

Cause of bug- An empty p tag was being passed until the API request was completed for version history details which initialized the editor with the empty p tag and didn't update later when the call was successful.

Fix- The check for API request completion is now stricter.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Summary by CodeRabbit

  • Bug Fixes
    • Description Versions modal now opens with a truly empty editor when no active version exists, instead of inserting placeholder HTML.
    • Editor will refresh when switching between versions so the correct content is shown.
    • Editor now only appears when a valid version is selected; behavior is unchanged when a version exists without a description (still shows an empty paragraph).

Copilot AI review requested due to automatic review settings September 4, 2025 12:03
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 4, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Updates description handling and editor mounting: root computes activeVersionDescription (undefined when no response); modal now requires activeVersionId and activeVersionDescription to render RichTextEditor, and forces remount via key={activeVersionId}. No public API signature changes.

Changes

Cohort / File(s) Summary of changes
Description versions root
apps/web/core/components/core/description-versions/root.tsx
Adds activeVersionDescription derived from activeVersionResponse; passes activeVersionDescription (undefined when no response) to DescriptionVersionsModal instead of always falling back to "<p></p>".
Description versions modal / editor mounting
apps/web/core/components/core/description-versions/modal.tsx
Rendering of RichTextEditor now requires both activeVersionId and activeVersionDescription; adds key={activeVersionId} to force remount; initialValue uses activeVersionDescription directly and id uses activeVersionId (no fallback). Loader/placeholder remains for else branch.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Root as DescriptionVersionsRoot
  participant Modal as DescriptionVersionsModal
  participant Editor as RichTextEditor

  User->>Root: open versions modal
  Root->>Root: compute activeVersionDescription from activeVersionResponse
  Root->>Modal: open(description = activeVersionDescription, id = activeVersionId)

  alt activeVersionId && activeVersionDescription
    Note right of Modal: Render editor with forced remount\nkey = activeVersionId
    Modal->>Editor: mount(id = activeVersionId, initialValue = activeVersionDescription)
    Editor-->>Modal: ready
  else missing id or description
    Note right of Modal: Render loader/placeholder instead of editor
    Modal-->>User: show loader/placeholder
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • prateekshourya29
  • sriramveeraghanta
  • Palanikannan1437

Poem

A rabbit hops through code and light,
I nudge the props to make them right.
When versions sleep, undefined I leave—
so editors mount and gently breathe.
Carrots in commits, a soft delight. 🥕

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/work-item-description-version

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.

@makeplane
Copy link

makeplane bot commented Sep 4, 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 (1)
apps/web/core/components/core/description-versions/root.tsx (1)

80-82: Disable nav buttons while index is unknown to avoid no-op clicks.

When versions isn’t loaded, activeVersionIndex is undefined, but the buttons aren’t disabled. Minor UX nit—disable until the index is known.

Apply this diff:

-        isNextDisabled={activeVersionIndex === versionsCount - 1}
+        isNextDisabled={activeVersionIndex === undefined || activeVersionIndex === versionsCount - 1}
         isOpen={isModalOpen}
-        isPrevDisabled={activeVersionIndex === 0}
+        isPrevDisabled={activeVersionIndex === undefined || activeVersionIndex === 0}
📜 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 c6c46f9 and 88f9a85.

📒 Files selected for processing (1)
  • apps/web/core/components/core/description-versions/root.tsx (2 hunks)
⏰ 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). (2)
  • GitHub Check: Build and lint web apps
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
apps/web/core/components/core/description-versions/root.tsx (2)

70-70: Prop wiring looks right.

Passing the derived var keeps modal logic clean. Ensure the modal does not internally coerce undefined back to "<p></p>" before the fetch completes to avoid reintroducing the flicker.


51-53: Types and guard verified; changes approved
Props define activeVersionDescription as string | undefined, and the RichTextEditor mounts only when activeVersionDescription is truthy, preventing premature initialization.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug where work item description version history doesn't render initially in the modal but works correctly when re-opened. The issue was caused by passing an empty <p></p> tag while the API request was in progress, which prevented the editor from updating once the actual content was loaded.

  • Improved the conditional check for API request completion to be more explicit
  • Extracted the description logic into a separate variable for better readability

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

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 (3)
apps/web/core/components/core/description-versions/modal.tsx (3)

134-142: Solid fix; consider explicit undefined checks to avoid falsy edge cases.

Truthiness can hide legitimate empty values later. Use explicit undefined checks for readiness.

-          {activeVersionId && activeVersionDescription ? (
+          {activeVersionId !== undefined && activeVersionDescription !== undefined ? (

If description_html could ever be an empty string (not "

"), this prevents the loader from persisting indefinitely. Can you confirm root.tsx never sets activeVersionDescription to ""?


167-179: Disable “Copy Markdown” until the editor is ready.

Prevents a no-op click when the editor isn’t mounted yet.

Add a readiness flag near Line 61:

const isEditorReady = activeVersionId !== undefined && activeVersionDescription !== undefined;

Then apply:

-            <button
+            <button
               type="button"
               className={cn(
                 "flex-shrink-0",
                 getButtonStyling("neutral-primary", "sm"),
                 "border-none grid place-items-center"
               )}
               onClick={handleCopyMarkdown}
+              disabled={!isEditorReady}
+              aria-disabled={!isEditorReady}
             >

184-195: Avoid restoring a placeholder (“

”) if data hasn’t loaded; gate the action.

Restoring before data arrives could overwrite content with an empty paragraph.

-              <Button
+              <Button
                 variant="primary"
                 size="sm"
-                onClick={() => {
-                  handleRestore(activeVersionDescription ?? "<p></p>");
-                  handleClose();
-                }}
+                disabled={activeVersionDescription === undefined}
+                onClick={() => {
+                  if (activeVersionDescription !== undefined) {
+                    handleRestore(activeVersionDescription);
+                    handleClose();
+                  }
+                }}
               >

If isRestoreDisabled is already true while loading, this becomes a no-op; otherwise the disable guard above is needed. Can you confirm current loading states keep restore disabled?

📜 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 88f9a85 and 1c1aacf.

📒 Files selected for processing (1)
  • apps/web/core/components/core/description-versions/modal.tsx (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
apps/web/core/components/core/description-versions/modal.tsx (1)
apps/space/core/components/editor/rich-text-editor.tsx (1)
  • RichTextEditor (30-66)
⏰ 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). (2)
  • GitHub Check: Build and lint web apps
  • GitHub Check: Analyze (javascript)

@sriramveeraghanta sriramveeraghanta merged commit 88f194c into preview Sep 4, 2025
6 of 7 checks passed
@sriramveeraghanta sriramveeraghanta deleted the fix/work-item-description-version branch September 4, 2025 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants