Skip to content

fix(composer): double-click expands a paste chip in the Lexical composer - #23153

Merged
bolichen97 merged 1 commit into
mainfrom
fix/lexical-paste-chip-dblclick-expand
Oct 23, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/lexical-paste-chip-dblclick-expand

Conversation

@JLargent42

@JLargent42 JLargent42 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: double-clicking a collapsed paste in the composer expands it to the full pasted text again, whichever composer engine is in use.

A user reports that since the latest update, double-clicking a collapsed paste (Paste #1 · N lines) in the composer does nothing. With Settings > Chat > Style Markdown While Typing on, the composer is the Lexical engine, and its paste chip can only be selected, previewed or deleted. It cannot be expanded.

Why it matters

Expanding a paste in place is how a user checks or trims a large paste before sending it. Turning on a styling preference silently removes that gesture, and the preview tooltip still says "Double-click to insert the full text" (#22782), so the UI promises something it does not do.

Not a goal

What changed (motivation → approach → change)

Symptom → cause: #15031 (6765454, in 0.9.0) made Style Markdown While Typing also switch ChatInput onto the Lexical composer. The textarea composer expands a paste on detail >= 2 (handleTextareaClick in website/src/chat-core/composer/pasteEditor.ts), but the Lexical paste chip never had an equivalent. Before #15031 no user-reachable setting led to that engine, so the gap did not show.

Change: in website/src/components/PasteTokenNode.tsx, the chip now handles onDoubleClick. The handler closes the preview, then calls a new $expandPasteTokenNode that replaces the node with the block's text and puts the caret after it. The text-to-nodes split (one text node per line, line breaks between) is the composer's existing appendPlainText, moved from website/src/components/LexicalComposerInput.tsx into PasteTokenNode.tsx and exported, so the draft loader and the expand share one implementation. The composer derives its paste blocks from the nodes, so the expanded block drops out of the sidecar on its own, the same way the textarea path drops it. While the editor is read-only (Optimize running), neither click handler touches the editor: onDoubleClick does nothing, and onClick still toggles the preview but no longer selects the chip. A real double-click sends two click events before dblclick, so both guards are needed for the gesture to leave the draft alone and not make the optimizer throw its rewrite away.

Backwards compatibility

Compatible: the only addition is a double-click handler on the chip; appendPlainText moves files with identical behaviour. Single click, keyboard, copy/cut, delete and draft loading behave as before.

Removes nothing: the chip gains a gesture and every existing path stays.

Tests

website/src/test/LexicalComposerInput.test.tsx:

  • expands a paste chip to its full text on double-click and drops the block: the value becomes the surrounding text plus the full content, the chip is gone, and the blocks are []. It fails with the PasteTokenNode.tsx change reverted (verified locally) and passes with it.
  • does not change the editor on a real double-click while read-only: the editor is made read-only, then userEvent.dblClick sends the browser's click, click, dblclick sequence to the chip. It asserts no editor.update call, an unchanged value, unchanged paste blocks, and the chip still present. It fails without the onClick guard (the two clicks each call editor.update).
  • a single click on a paste chip still only selects it, never expands: guards the select-first single click.

Determinism: the whole file (49 tests) passed shuffled runs with --sequence.shuffle. Neither test uses timers or randomness.

Local gates: npx vitest run src/test/LexicalComposerInput.test.tsx green; tsc -p tsconfig.app.json clean; eslint clean on both files; semgrep --config semgrep/ clean on both files. On this host, scripts/local-gate.py's cross-surface backend batch shows 62 failures and 15 errors (PlatformCompositionError: the host resolves an enterprise profile). The same set fails on the unmodified base, so it is environmental, not this diff. CI is the authority on the backend suites.

Manual verification

Captured in a browser (see Screenshots / video): a real double-click on the Lexical chip expands it in place. The unit tests drive the same component through fireEvent.doubleClick.

Screenshots / video

Real LexicalComposerInput (dark theme, inline markdown on) mounted in an isolated capture harness, driven by Playwright Chromium: the chip shows Paste #1 · 6 lines, a double-click replaces it with the pasted traceback, and the paste-block count drops from 1 to 0.

Before (collapsed chip):

Lexical composer with a collapsed Paste #1 · 6 lines chip

After double-click (full text inserted in place):

Lexical composer after double-click: the pasted traceback is inline and the chip is gone

Recording:

Related Issues

Closes #23148

Overlap note: open PR #11100 (fork, conflicting, needs-author-decision) deletes PasteTokenNode.tsx in favour of new pill nodes. If it lands later, its pills need the same double-click gesture.

Sibling sweep

Siblings: none -- PasteTokenChip is the only paste-token editor node in the Lexical composer; the textarea engine already expands via handleTextareaClick, and the sent-bubble PastedChip is a toggle button, not an editor node.

Pattern harvest

Rule candidate: review-prompt
Pattern: "a setting that switches users between two engines of one surface must keep every gesture the other engine honours (the composer engines here)".

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable) — N/A, the preview hint already names the gesture
  • No secrets, credentials, or internal references in the diff

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS (a BLOCK with no Trigger and no Outcome does not block)

UX-level review of 5453f38cf0e624dfac14a1e4868ef0f97e31223b — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

cannot evaluate: missing a screenshot of the Lexical paste chip before and after double-click, and a recording of it expanding. No image was admitted, so the blind read was not performed.

Evidence gaps

  • Double-click expand on PasteTokenChip (Paste #1 · N lines → full pasted text in place): the screenshot list is empty, and the blind-read report says "BLIND READ NOT PERFORMED". The description's "Before (collapsed chip)" and "After double-click" images arrived as [image removed], so neither was admitted. Attach both stills as github.com/user-attachments images, or commit them under temp-screenshots/.
  • Chip-to-text state change (lens 13): the chip unmounts and plain text nodes take its place. The recording list is empty, so nobody can judge whether a user sees the text as the same paste. Attach the Playwright recording the description mentions.
  • Read-only (Optimize running) state: no still shows that a single click still opens the preview but no longer selects the chip, and that double-click does nothing. Attach one still of the chip while Optimize runs.

[UX-REVIEWED] 5453f38

Description read

[DESCRIPTION-READ] 75cd83e028655f8c3d3a73a4fda7f3686b594e2e9c747ab825f1fc0d25eecad1

That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 5453f38cf0e624dfac14a1e4868ef0f97e31223b — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: this gives the Lexical chip back the double-click gesture the textarea composer already has, and the paste blocks are derived from the nodes, so the expanded block drops out of the sidecar without extra code.

Notes

  • The evidence list shows 0 downloaded attachments: the before/after screenshots and the recording in the description never reached this review. A gesture on an existing chip is not a new surface, so this does not block, but the "Manual verification" claim is unbacked here. Re-attach them so the UX lane can see them.

[DESIGN-REVIEWED] 5453f38

Description read

[DESCRIPTION-READ] 0481999ee312cacc577dfc3256287616c4e255e70613ebeba733ef9758e7f63b

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 5453f38cf0e624dfac14a1e4868ef0f97e31223b — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

The double-click expand fixes the defect reported in #23148 at the cause: the Lexical chip never had the handler. The read-only click guard comes along with it, and the description declares it.

What this change ships

Inventory (4 items) — 3 justified

Intent: a user can double-click a collapsed paste in the Lexical composer to expand it back to the full text, as the textarea composer already allows. FIX.

  1. Double-clicking a paste chip in the Lexical composer replaces it with the full pasted text — justified
  2. After expanding, the caret sits right after the inserted text and the paste block leaves the sidecar — justified
  3. In a read-only editor (Optimize running), a single click on the chip still toggles the preview but no longer selects the chip — rides along
  4. appendPlainText moves from LexicalComposerInput.tsx to PasteTokenNode.tsx and is exported, so the draft loader and the new expand share one implementation — justified

[FIRST-PRINCIPLES-REVIEWED] 5453f38

Description read

[DESCRIPTION-READ] b4383caeaef88401a0585b61a43345e2f1de65c86244dd54f53c28602ecdb422

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 5453f38cf0e624dfac14a1e4868ef0f97e31223b — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 5453f38

Verdict parsed from the review's SHA-scoped output markers for commit 5453f38cf0e624dfac14a1e4868ef0f97e31223b.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 5453f38cf0e624dfac14a1e4868ef0f97e31223b: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 5453f38cf0e624dfac14a1e4868ef0f97e31223b and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 5453f38

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 5453f38cf0e624dfac14a1e4868ef0f97e31223b: <one-sentence reason>

@JLargent42
JLargent42 force-pushed the fix/lexical-paste-chip-dblclick-expand branch from 7815d9f to 0f3b969 Compare October 22, 2026 20:32
@JLargent42

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in website/src/components/ (ArtifactBody.tsx, CommentOverlay.tsx, MarkdownPanel.tsx, same-dir only) since this head went green (69b2e50 -> b2b87b0); CI re-running.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 22, 2026
@JLargent42
JLargent42 force-pushed the fix/lexical-paste-chip-dblclick-expand branch from 0f3b969 to f27740f Compare October 22, 2026 20:54
@JLargent42

JLargent42 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author
  • span=41a17e374944 Expansion overwrites the preceding typing undo snapshot

rebutted, disproportional, in line with the lane's own adjudication (DOWNGRADE F2, reason=disproportionate-remedy). It only happens when a double-click lands within 400 ms (UNDO_COALESCE_MS) of the last keystroke and the expanded text is within 8 chars (UNDO_BULK_DELTA) of the marker's length; for most collapsed pastes the length change is larger, so useUndoHistory records a separate snapshot.
In the worst case one Undo also reverts a few just-typed characters, which is visible and recoverable with Redo. The fix would mean passing onEndUndoBurst into the separately rendered decorator node through new context, a mechanism that serves only this path. Not a security, data-loss or corruption class.

@JLargent42

JLargent42 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: double-click expand handler on the Lexical paste chip

  • span=41a17e374944 Expansion bypasses the optimizer’s read-only state

fixed in f27740f: the onDoubleClick handler in website/src/components/PasteTokenNode.tsx now returns before it touches the event, the preview or the editor when !editor.isEditable(). That is the state LexicalComposerInput sets via editor.setEditable(!disabled && !readOnly) while Optimize runs.
Regression test does not expand a paste chip on double-click while read-only (website/src/test/LexicalComposerInput.test.tsx) asserts no editor.update and an unchanged value. It fails with the guard removed.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 22, 2026
@JLargent42
JLargent42 force-pushed the fix/lexical-paste-chip-dblclick-expand branch from f27740f to c8100c4 Compare October 22, 2026 22:48
@JLargent42

Copy link
Copy Markdown
Contributor Author

Rebased (approved by the owner) onto main 41708c9 to pick up the #23201 test fix for the inherited main-red #23200. 8 cases in test/test_chat_runner_redact_across_tool_boundary.py were failing on Backend Tests (Windows) (3) at f27740f. Same single commit, no code change; CI re-running on c8100c4.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 22, 2026
@JLargent42
JLargent42 force-pushed the fix/lexical-paste-chip-dblclick-expand branch from c8100c4 to 657f38d Compare October 22, 2026 22:59
@JLargent42

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: inline text-to-nodes loop inside $expandPasteTokenNode

  • The text-to-nodes conversion now exists twice — duplicate of LexicalComposerInput.tsx:139

fixed in 657f38d: appendPlainText moved out of website/src/components/LexicalComposerInput.tsx into website/src/components/PasteTokenNode.tsx with the same behaviour and is now exported. $replaceComposerValue (the draft loader) and $expandPasteTokenNode both call it, and the inline loop is deleted.
Grep of website/src outside tests: $createLineBreakNode( has one call site, inside appendPlainText. No import cycle: LexicalComposerInput.tsx already imported from ./PasteTokenNode. 82 Lexical composer tests, tsc and eslint pass locally.

@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Oct 22, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 23, 2026
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 23, 2026
@JLargent42
JLargent42 force-pushed the fix/lexical-paste-chip-dblclick-expand branch from 657f38d to da873ab Compare October 23, 2026 06:26
@JLargent42

Copy link
Copy Markdown
Contributor Author

Rebased once onto main for the #23264 Windows fix.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 23, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

HOLD

The read-only double-click test dispatches only dblclick, but a real browser sends two click events first. Each click reaches onClick and calls editor.update before the double-click editable guard runs. The test therefore does not prove the stated read-only boundary.

Use the real double-click event sequence, or userEvent.dblClick, and assert the content and paste blocks remain unchanged. If read-only clicks must not change selection or preview state, guard onClick too.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: passed Eligible automated validation passed for the current revision labels Oct 23, 2026
@JLargent42
JLargent42 force-pushed the fix/lexical-paste-chip-dblclick-expand branch from da873ab to 5453f38 Compare October 23, 2026 18:14
@JLargent42
JLargent42 requested a review from bolichen97 October 23, 2026 18:14
@JLargent42

Copy link
Copy Markdown
Contributor Author

@bolichen97 Thanks, you were right. Addressed in 5453f38 (no rebase; the branch is not in conflict).

  • Test: the read-only test now uses userEvent.dblClick, which sends click, click, dblclick. It asserts no editor.update call, an unchanged value, unchanged paste blocks, and the chip still present. On the previous head it failed: the two clicks each called editor.update through onClick.
  • Code: onClick in website/src/components/PasteTokenNode.tsx now skips the node-selection update when the editor is read-only. It still toggles the preview, which does not touch editor state. The onDoubleClick guard is unchanged.
  • Local checks: 163 composer/paste-related vitest files (3,524 tests) pass; tsc -p tsconfig.app.json and eslint are clean.

Re-requested your review.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 23, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good to ship. Head reviewed: 5453f38.

My earlier change request is resolved on this head. The read-only test now uses userEvent.dblClick, so it sends click, click, dblclick. The onClick handler now skips the selection update while the editor is read-only.

What I verified locally at this head:

  • src/test/LexicalComposerInput.test.tsx passes (49 tests).
  • With the new editor.isEditable() guard in onClick removed, the read-only test fails. The test pins the guard.
  • With the expand test switched to userEvent.dblClick in an editable editor, the chip still expands. The two preceding clicks do not interfere.
  • $expandPasteTokenNode handles empty content, a trailing newline and a final text node, and puts the caret after the inserted text.
  • appendPlainText moved unchanged, and the draft loader still calls it.
  • The linked issue is tier:T1. No file is on the security path list. Main has not changed the three touched files since this branch's base.

Note, not blocking: the screenshot and recording links in the description are local file paths, so they do not render on GitHub. Upload them as attachments if you want the UX lane to read them.

Remaining gate: PR Readiness is still running on this head. I will approve after it reports passed.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 23, 2026
@bolichen97
bolichen97 dismissed their stale review October 23, 2026 23:04

Resolved on head 5453f38.

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving head 5453f38.

My earlier change request is resolved on this head: the read-only test uses userEvent.dblClick and the onClick handler skips the selection update while the editor is read-only.

Gates checked on this head: readiness label is passed, PR Readiness is green, no check is failing or pending, the Opus, GPT, Design and First Principles lanes report no blocking findings, there is no merge conflict, the base is main, and the linked issue is tier:T1. No touched file is on the security path list.

@bolichen97
bolichen97 merged commit aefe7ab into main Oct 23, 2026
108 of 117 checks passed
@bolichen97
bolichen97 deleted the fix/lexical-paste-chip-dblclick-expand branch October 23, 2026 23:04
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 23, 2026
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.

Regression: double-click no longer expands a collapsed paste in the composer (Lexical path)

2 participants