fix(ui): keep comment text when a post or edit fails#320
Merged
martian56 merged 2 commits intoJul 16, 2026
Conversation
CommentEditor cleared the editor synchronously right after firing onSubmit, so a failed comment (offline, 5xx, EXTERNAL-comment permission error) was silently lost — the parent showed an error but the typed text was already gone. onSubmit now reports success: it may return/resolve to false (or throw) to signal failure, and the editor only clears when the submit actually succeeds. postComment/updateComment on the work-item page return true/false accordingly. Closes Devlaner#315 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/web/src/components/work-item/CommentEditor.tsx`:
- Around line 116-130: Update handleSubmit after the awaited onSubmit call and
error handling to check editor.isDestroyed before calling
editor.commands.clearContent() or updating editor-related state. If the editor
has been destroyed, return without interacting with it; preserve the existing
successful-submit behavior otherwise.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: fc89f20d-1d30-4660-9f05-7f1dfeacea7e
📒 Files selected for processing (2)
apps/web/src/components/work-item/CommentEditor.tsxapps/web/src/pages/IssueDetailPage.tsx
Since onSubmit is awaited, the editor can be torn down (parent unmounts or cancels the edit) before the submit resolves; clearing a destroyed TipTap editor throws. Bail out when editor.isDestroyed before clearContent. Addresses CodeRabbit review on Devlaner#315. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
martian56
approved these changes
Jul 16, 2026
Contributor
Author
|
@martian56 small but annoying bug (#315): posting a comment cleared the editor before the request finished, so a failed post lost whatever you typed. Now it only clears on success. CodeRabbit flagged an edge case (clearing a torn-down editor) which I've fixed and resolved. Green and no open threads — good to go? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CommentEditorcleared the editor synchronously right after firingonSubmit, so a failed comment (offline, 5xx, or the EXTERNAL-comment permission error) was silently lost — the parent showed an error toast but the typed text was already gone.Linked issues
Closes #315
Type of change
fix:)Surface
apps/web/)What changed
onSubmitnow reports success: it may return/resolve tofalse(or throw) to signal failure.CommentEditor.handleSubmitawaits it and only callsclearContent()when the submit actually succeeded.postComment/updateCommenton the work-item page returntrue/falseaccordingly (they already caught their own errors and showed a message — they just didn't tell the editor).Why this approach
The parent deliberately swallows the error to render its own message, so the promise resolved even on failure and the editor couldn't tell success from failure. Rather than make the parent rethrow (which would double-handle the error), the handler now returns a success flag — the least surprising contract for a controlled editor.
Test plan
npm run typecheck+npm run lint(with the i18n gate) passAI assistance
Claude Code (Opus 4.8)— commits carry aCo-Authored-By:trailerSummary by CodeRabbit