feat(site): replace Agent chat textarea with Lexical editor#22449
Merged
feat(site): replace Agent chat textarea with Lexical editor#22449
Conversation
|
I have read the CLA Document and I hereby sign the CLA Coder seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. |
27840ed to
8b6d88b
Compare
Replace the plain <TextareaAutosize> in the Agent chat input with a Lexical-based editor component, matching the pattern used in coder/blink. This gives us a content-editable surface with proper keyboard command handling, paste sanitization, and an imperative ref API (insertText, clear, focus, getValue). The new ChatMessageInput component: - Uses Lexical as the editor engine (plain-text mode, formatting disabled) - Enter submits, Shift+Enter inserts newline - Strips rich-text formatting on paste - Supports undo/redo via HistoryPlugin - Exposes imperative ref for programmatic text manipulation This lays the groundwork for future enhancements like ghost text autocomplete, @-mentions, slash commands, and inline decorators. Parent components (AgentDetail, AgentsPage) updated from controlled value/onChange to the ref-based pattern.
8b6d88b to
8a85794
Compare
added 3 commits
March 1, 2026 02:48
ValueSyncPlugin seeded content in a useEffect, making it async. In Chromatic, the Send button click could fire before the editor had flushed the update, so getValue() returned empty string. Move initial value seeding into initialConfig.editorState which runs synchronously during LexicalComposer mount.
…in story The editor.focus() callback runs via Lexical's $onUpdate() deferred mechanism, which executes outside of editor.update()/read() context. Calling $getRoot() there threw 'Unable to find an active editor state'. Fix: wrap the focus callback body in editor.update(). Also restore ValueSyncPlugin for initial value seeding (editorState config approach had the same issue), and update the story to wait for the editor text to render before clicking Send.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
Replaces the plain
<TextareaAutosize>in the Agent chat input (AgentChatInput) with a Lexical-based editor component, matching the pattern used in coder/blink.What changed
New component:
ChatMessageInputsite/src/components/ChatMessageInput/ChatMessageInput.tsxA Lexical-powered text input that behaves as a plain-text editor with:
insertText(),clear(),focus(),getValue()Updated components
AgentChatInput.tsx— Swapped<TextareaAutosize>for<ChatMessageInput>. Moved from controlledvalue/onChangeto ref-based pattern withinitialValue/onContentChange.AgentDetail.tsx— Updated to useuseReffor input value tracking andeditorInitialValuestate for editor resets (edit/cancel flows).AgentsPage.tsx— Updated to useuseRef+initialValuepattern.AgentChatInput.stories.tsx— Updated prop names.Why Lexical?
This lays the groundwork for features that a native
<textarea>can't support:No adornments are added in this PR — it's a drop-in replacement that matches existing behavior.