Repository navigation
fix(chat): lock the composer input while a chat is still opening - #213
MihaelaStoica wants to merge 3 commits into
Conversation
… is shown Until an opened chat's thread runtime attaches, assistant-ui shows its empty placeholder thread, whose composer throws on every edit. Typing then sent each keystroke into it from SyncPlugin's Lexical listener, so the empty-thread error reached the renderer unhandled and the text was lost. The window lasts seconds when the Kilo server is still starting. The Lexical editor is now read-only while the placeholder is shown. Only the placeholder has no extras: every real thread, a draft included, carries its message queue controls.
…o open While the empty placeholder thread is shown the composer input is locked, which on a slow open left it ignoring clicks with no explanation. Its placeholder now reads "Loading chat…" (and the input is aria-busy) once the placeholder thread has been shown for 400 ms. Most chats replace it within a frame, where an immediate swap would only flash.
|
React Doctor found no issues. 🎉 Reviewed by React Doctor for commit |
| }); | ||
|
|
||
| await expect.element(input()).toHaveAttribute("contenteditable", "true"); | ||
| watcher.disconnect(); |
There was a problem hiding this comment.
[SUGGESTION]: The MutationObserver leaks when an assertion above fails
watcher.disconnect() runs only on the happy path: if renderChat() throws or toHaveAttribute("contenteditable", "true") times out (a slow CI run would do it), the observer stays attached to document.body for the rest of this test file, retaining its callback and inspecting every later mutation. Disconnect it in a try/finally so a failed assertion can't leave it observing.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (4 files)
Previous Review Summary (commit f7789ce)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit f7789ce)Status: 1 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (4 files)
Reviewed by deepseek-v4.1-flash-1017 · Input: 56.1K · Output: 5.8K · Cached: 262.7K |
Problem
Typing in the composer while a chat was still opening threw assistant-ui's "This is the empty thread…" error, unhandled in the renderer, and the typed text was lost. Until an opened chat's thread runtime attaches, assistant-ui shows an empty placeholder thread whose composer throws on every edit; the Lexical input's sync listener pushes each keystroke into it. The window lasts seconds when the user opens a chat right after launch, while the Kilo server is still starting, and is one of the most frequent renderer errors we report.
(Ticket: DESK-3510)
Solution
The Lexical editor is read-only while the placeholder thread is shown, so no edit reaches its composer. The placeholder is the only thread without extras: Kilo's runtime gives every real thread, a draft included, its message queue controls.
So a slow open doesn't leave an input that silently ignores clicks, the placeholder text reads "Loading chat…" (and the input is
aria-busy) once the placeholder has been shown for 400 ms. Most chats replace it within a frame, where an immediate swap would flash.Risk & Tradeoffs
use-chat-runtimepassing queue user controls; both ends carry a comment. If that were removed, draft composers would stay read-only, which the existing draft tests would catch.LexicalComposerInput's own editable rule (thread disabled, dictation blocking input) so it has the last word; worth rechecking on@assistant-ui/react-lexicalupgrades.insertText) while the placeholder is shown. No reports point to it yet.Testing
pnpm lint; typecheck.Change Classification