fix: pasted-text chip revert breaks after draft restore#2013
Merged
Conversation
The `pastedText` chip attribute was being stripped during the EditorContent <-> Tiptap JSON conversion in useDraftSync, so any time the editor was rehydrated from the persisted draft (e.g. on remount or when the editor instance was rebuilt), pasted-text chips lost their flag and rendered as the non-clickable DefaultChip variant. Clicking them no longer reverted the text inline. Pass pastedText through both conversion functions so the chip identity survives a round trip. Generated-By: PostHog Code Task-Id: 95b90a23-b18c-496a-9bf0-eed999ec40aa
adboio
approved these changes
May 4, 2026
Contributor
|
Reviews (1): Last reviewed commit: "fix: preserve pastedText flag through dr..." | Re-trigger Greptile |
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.
Problem
Clicking a pasted-text chip in the prompt input no longer reverts the chip back to inline text after the editor restores from a saved draft (for example, after the editor instance is rebuilt because
disabledtoggled, after a remount, or after returning to a session whose draft contained a pasted chip).Root cause
MentionChipNodecarries a booleanpastedTextattribute that distinguishes pasted-text chips (rendered byPastedTextChipwith a click-to-revert handler) from normal mention chips (rendered byDefaultChip, which has no click action forfiletypes).In
useDraftSync.ts, bothtiptapJsonToEditorContentandeditorContentToTiptapJsonwere dropping thepastedTextattribute when round-tripping throughEditorContent. After a draft restore, every chip came back withpastedTextdefaulted tofalse, so the view renderedDefaultChipand clicks did nothing.Fix
pastedTextto theMentionChipinterface inutils/content.ts.node.attrs.pastedTextintiptapJsonToEditorContentand write it back ineditorContentToTiptapJson(defaulting tofalseso existing chips are unaffected).This preserves the flag through the draft save/restore cycle, so pasted-text chips remain clickable and continue to revert inline.
Test plan
disabled), then click the chip → text is restored inline (this was broken before)pnpm --filter code test src/renderer/features/message-editorCreated with PostHog Code