Skip to content

fix(web): keep the caret outside pasted Markdown styles - #41328

Closed
faga295 wants to merge 1 commit into
pingdotgg:mainfrom
faga295:fix/web-markdown-paste-caret
Closed

faga295 wants to merge 1 commit into
pingdotgg:mainfrom
faga295:fix/web-markdown-paste-caret

Conversation

@faga295

@faga295 faga295 commented Nov 23, 2026 •

Copy link
Copy Markdown

Problem

With the rich-text Web composer enabled, paste **DEV** into an empty draft and immediately type !. The caret lands before the closing **, producing **DEV!**. The expected draft is **DEV**!.

Change

Record text input where it enters the editor. Use that signal, IME composition, or explicitly stored marks to decide whether the caret should continue an inline style. Pasted and programmatically inserted content ends outside the closing delimiter by default.

Scope

Fixes #41321.

Verification

  • In the Web client on Chromium, pasted **DEV** using the system clipboard and typed ! without moving the caret. The base produced **DEV!**. The fix produced **DEV**!.
  • The browser regression tests cover clipboard paste and programmatic insertion. Both put the next character outside bold. Also checked italic, strikethrough, inline code, and nested styles in Chromium.
  • vp run check:changed upstream/main passed.

Before the fix

image

With the fix

image

Created with GPT-6.2-Sol via Codex in T3 Code.

Any document change could continue the active style, leaving the caret inside closing markers after a paste. Record text input at its entry point and use that signal, composition, or explicit stored marks to choose which style to continue.

Cover clipboard paste and programmatic insertion in the browser.

Assisted by GPT-6.2-Sol in Codex.
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 23, 2026
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Markdown source normalization now determines style continuation from stored marks or text-input and composition metadata, then uses caret affinity to select a continuation side. A new editing extension tags handled text-input transactions. Browser tests cover typing after bold content inserted by paste or editor command.

Changes: Markdown caret continuation

Layer / File(s) Summary
Select the style continuation side
apps/web/src/composer-markdown-source.ts
revealStyledText and normalizeMarkdownSource now use a continuation side. Caret mapping uses that side, and detached normalization passes no continuation side.
Tag text input and verify typing
apps/web/src/composer-markdown-source.ts, apps/web/src/components/ComposerPromptEditorTiptap.input.browser.test.tsx
A new editing extension tags handled text-input transactions, and the Markdown source extension registers it. Browser tests assert that typing ! after pasted or command-inserted bold text produces **DEV**!.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: juliusmarminge, yash-singh1, stienswout

Merge Risk: Minimal · up to 0fb8d

Pasting styled Markdown and typing immediately after it should now keep the caret outside the closing delimiter. The change is localized to the web composer and no merge-blocking risk was found.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive [#41321] The requirement is a coding behavior fix in apps/web. Pasting **DEV** and typing ! must yield **DEV**!, and the same must hold for italic, strikethrough, inline code, and nested styles.… Make the changed blobs for apps/web/src/components/ComposerPromptEditorTiptap.input.browser.test.tsx available for inspection. Confirm that the browser tests assert **DEV**! after paste and typing !, and cover the italic, strikethrough,…
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title "fix(web): keep the caret outside pasted Markdown styles" matches the main change. The PR keeps the caret outside a pasted Markdown bold delimiter, so typing after pasted **DEV** produces …
Out of Scope Changes check Passed All reviewed source changes in apps/web/src/composer-markdown-source.ts relate to the reported caret behavior. The change replaces the typed and takesBefore flags with a ContinuedStyleSide value…
Description check Passed The description follows the template well. It states the problem with clear reproduction steps (paste **DEV**, type !, caret lands before closing **, producing **DEV!** instead of **DEV**!).…
Full details: Title check

Explanation

The title "fix(web): keep the caret outside pasted Markdown styles" matches the main change. The PR keeps the caret outside a pasted Markdown bold delimiter, so typing after pasted **DEV** produces **DEV**! instead of **DEV!**. The title follows the conventional commit format and names the web component. The changes in composer-markdown-source.ts and the new regression test support this claim.

Full details: Out of Scope Changes check

Explanation

All reviewed source changes in apps/web/src/composer-markdown-source.ts relate to the reported caret behavior. The change replaces the typed and takesBefore flags with a ContinuedStyleSide value. It adds a text-input marker and a composition check. It renames MarkdownSourceHistoryExtension to MarkdownSourceEditingExtension and adds a handleTextInput hook. The detached path passes null for the side, which keeps its previous no-continuation behavior. No unrelated feature or file change was found in the reviewed diff. The browser test file diff could not be read, so its content could not be checked for scope. Its described content (paste and programmatic insertion regression tests) matches the issue.

Full details: Description check

Explanation

The description follows the template well. It states the problem with clear reproduction steps (paste **DEV**, type !, caret lands before closing **, producing **DEV!** instead of **DEV**!). It explains the change at a high level (record text input where it enters the editor, use that signal, IME composition, or stored marks to decide style continuation). It links the issue (#41321) and gives verification steps on Chromium with before/after screenshots and a passing repo check command. Minor gaps: the Change section does not say why the composition/stored-marks logic is needed across the two source files, and the Scope section links a bug issue rather than explaining it in detail. The closing agent line is present. Overall the description is mostly complete.

Full details: Linked Issues check

Explanation

[#41321] The requirement is a coding behavior fix in apps/web. Pasting **DEV** and typing ! must yield **DEV**!, and the same must hold for italic, strikethrough, inline code, and nested styles. The reviewed diff of apps/web/src/composer-markdown-source.ts adds a text-input marker. It also sets a continue-style side only for stored marks, text-input transactions, or composition. Paste and other non-input transactions therefore resolve to no continuation side, which places the caret outside the closing delimiter. This mechanism matches the requirement. However, the diff of apps/web/src/components/ComposerPromptEditorTiptap.input.browser.test.tsx could not be read because its changed blobs are missing from the checkout. The browser regression tests cannot be verified. The result for the typed ! path also depends on caretTakesMarksBefore and on how the closing marker mapping behaves after a text-input transaction. This path was not traced to a runtime result. The author reports Chromium results, but those are not repository evidence.

Resolution

Make the changed blobs for apps/web/src/components/ComposerPromptEditorTiptap.input.browser.test.tsx available for inspection. Confirm that the browser tests assert **DEV**! after paste and typing !, and cover the italic, strikethrough, inline code, and nested cases from #41321. Confirm that the typed ! path places the character outside the closing delimiter.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f02a14e and 0fb8d61.

Files selected for processing: 2

  • apps/web/src/components/ComposerPromptEditorTiptap.input.browser.test.tsx
  • apps/web/src/composer-markdown-source.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 23, 2026
@juliusmarminge juliusmarminge added takeover:blocked Takeover blocked; reason in the PR body and removed takeover:in-progress A takeover lead is working on this PR labels Nov 23, 2026
@faga295

faga295 commented Nov 23, 2026

Copy link
Copy Markdown
Author

closed

@faga295 faga295 closed this Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). takeover:blocked Takeover blocked; reason in the PR body vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Caret lands before closing Markdown markers after pasting into the composer

2 participants