Skip to content

Conversation

@SylvainChevalier
Copy link
Contributor

@SylvainChevalier SylvainChevalier commented Jan 20, 2026

Fixes issue where the comment edit UI would disappear when all text was deleted during editing. The comment persisted in the database but was removed from the UI immediately.

The fix adds a check to exclude editing mode from the cleanup logic that removes empty comments from the UI.

Fixes #4077

Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved comment editing stability: comments are now only removed when their text is empty, they contain no key factors, and they are not currently being edited. Editing state changes are correctly respected so comments won't be prematurely removed during an active edit.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 20, 2026

📝 Walkthrough

Walkthrough

Added an isEditing guard to the effect that removes empty comments so it only runs when the comment is not being edited; the effect's dependency array was updated to include isEditing.

Changes

Cohort / File(s) Summary
Comment removal effect
front_end/src/components/comment_feed/comment.tsx
Added isEditing guard to prevent removal of comments while actively editing; updated effect dependency array to include isEditing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I nibble on code in the light,
A vanished comment gave me a fright.
With a gentle guard placed,
The typing won't be erased,
Now edits stay safe through the night.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: preventing comment UI from disappearing when editing empty text, which directly addresses the bug being fixed.
Linked Issues check ✅ Passed The code changes directly address issue #4077 by adding an isEditing guard to prevent comment removal during edit mode, fixing the issue where deleting all text caused UI disappearance.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the specific bug in issue #4077; the modifications only affect comment cleanup logic with an editing state guard.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1133825 and 122cafa.

📒 Files selected for processing (1)
  • front_end/src/components/comment_feed/comment.tsx
⏰ 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: Build Docker Image
  • GitHub Check: integration-tests
  • GitHub Check: Backend Checks
🔇 Additional comments (1)
front_end/src/components/comment_feed/comment.tsx (1)

401-405: LGTM! Clean fix for the disappearing comment issue.

The !isEditing guard correctly prevents the cleanup effect from running while the user is actively editing. The dependency array properly includes isEditing to ensure the effect re-evaluates when editing state changes.

The fix handles the lifecycle correctly:

  • During editing: empty text won't trigger removal
  • After save: if text is empty and no key factors, comment is appropriately removed
  • After cancel: original text is restored before isEditing flips, preserving the comment

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Fixes issue where the comment edit UI would disappear when all text
was deleted during editing. The comment persisted in the database but
was removed from the UI immediately.

The fix adds a check to exclude editing mode from the cleanup logic
that removes empty comments from the UI.

Fixes #4077

Co-authored-by: Sylvain <SylvainChevalier@users.noreply.github.com>
@github-actions
Copy link
Contributor

🚀 Preview Environment

Your preview environment is ready!

Resource Details
🌐 Preview URL https://metaculus-pr-4105-claude-issue-4077-20260119-143.fly.dev
📦 Docker Image ghcr.io/metaculus/metaculus:claude-issue-4077-20260119-143-0dca79d
🗄️ PostgreSQL NeonDB branch preview/pr-4105-claude-issue-4077-20260119-143
Redis Fly Redis mtc-redis-pr-4105-claude-issue-4077-20260119-143

Details

  • Commit: 0dca79dd2b77dca35588af900cb124f883fb06f4
  • Branch: claude/issue-4077-20260119-1435
  • Fly App: metaculus-pr-4105-claude-issue-4077-20260119-143

ℹ️ Preview Environment Info

Isolation:

  • PostgreSQL and Redis are fully isolated from production
  • Each PR gets its own database branch and Redis instance
  • Changes pushed to this PR will trigger a new deployment

Limitations:

  • Background workers and cron jobs are not deployed in preview environments
  • If you need to test background jobs, use Heroku staging environments

Cleanup:

  • This preview will be automatically destroyed when the PR is closed

@SylvainChevalier
Copy link
Contributor Author

Tested in Preview Environment, works.

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.

Erasing all text from a comment "deletes" the comment

2 participants