Repository navigation
fix(site/src/pages/AgentsPage): preserve chat input typed while loading - #26415
DanielleMaywood merged 2 commits into
Conversation
The loading view rendered its own AgentChatInput with initialValue="" and no onContentChange, so text typed before the chat finished loading was never persisted. When the queries resolved, that input unmounted and the loaded editor mounted seeded from the mount-time draft snapshot (empty), discarding the text. Wire the loading input to the shared draft state and add handleLoadingDraftChange, which persists the draft and advances the seed state so the loaded editor mounts with the in-progress text.
|
/coder-agents-review |
|
Chat: Review posted | View chat Review historydeep-review v0.7.1 | Round 2 | Last posted: Round 2, 4 findings (1 P3, 3 Nit), APPROVE. Review Finding inventoryFindings
Contested and acknowledged(none) Round logRound 1Panel (13 reviewers). Netero: no findings. 1 P3, 3 Nit. 2 Gon findings downgraded from P2 to Nit (comment verbosity is stylistic; Leorio explicitly praised the same comments). Reviewed against 894734a..9adab1f. Round 2Panel (4 reviewers: Bisky, Mafuuu, Gon, Chopper). Netero: no findings. CRF-1 through CRF-4 all verified fixed in 9ccf830. No new findings. APPROVE. Reviewed against 894734a..9ccf830. About deep-reviewCRF = Coder Review Finding (P0-P4, Nit, Note)
|
There was a problem hiding this comment.
Clean, well-scoped fix. The diagnosis is accurate (loading view's input was disconnected from the editing state), the solution is proportional (a separate handler that bridges the gap without touching the per-keystroke path), and the test coverage is solid at 1:1 LOC ratio.
Pariston tried four alternative framings and could not build a case against the chosen approach. Meruem verified the structural correctness of the loading-to-loaded handoff, remountKey stability, and shared inputRef lifecycle. Mafu-san confirmed every factual claim in the PR description against the code.
1 P3, 3 Nits. The P3 is a missing negative assertion that would catch a future regression if someone merges the two handlers.
"I tried to build a case against this and could not. The problem is correctly understood, the solution is proportional, and the fix is at the right level of the causal chain." (Pariston)
site/src/pages/AgentsPage/AgentChatPage.test.ts:316
P3 [CRF-1] The existing test asserts localStorage after handleContentChange but never checks that editorInitialValue and initialEditorState remain unchanged. The two handlers differ by exactly one setDraftState call. If a future refactor adds setDraftState to handleContentChange, the full test suite passes while silently introducing per-keystroke re-renders in the loaded editor.
Two assertions after the localStorage check would close this:
// handleContentChange must NOT update the seed state, only localStorage.
// handleLoadingDraftChange exists for when the seed must advance.
expect(result.current.editorInitialValue).toBe("");
expect(result.current.initialEditorState).toBeUndefined();(Bisky P3, Chopper Note)
🤖
🤖 This review was automatically generated with Coder Agents.
- Guard the handler separation: assert handleContentChange does not advance editorInitialValue/initialEditorState (CRF-1). - Trim verbose comments on handleLoadingDraftChange and its test (CRF-2, CRF-3, CRF-4).
CRF-1: Good guard. Added the two negative assertions in 9ccf830 so a future merge of |
|
/coder-agents-review |
There was a problem hiding this comment.
All four R1 findings verified fixed in 9ccf830.
CRF-1 (P3): Negative assertions added at test lines 327-329. handleContentChange now provably does not advance the seed. CRF-2/CRF-3: Comments trimmed to the essential content. CRF-4: Garden-path sentence eliminated by the CRF-2 rewrite.
Bisky verified both halves of the handler contract (positive and negative). Mafuuu traced the full loading-to-loaded lifecycle and checked adversarial scenarios (rapid typing then immediate load, navigation during loading, history-edit after load). Gon confirmed the rewritten comments are clean. Chopper found no operational concerns.
No new findings. Ship it.
🤖 This review was automatically generated with Coder Agents.
Problem
Typed chat input was lost when a chat was still loading. If the user started
typing in the message composer before the chat finished loading, their text was
discarded once the chat loaded.
Root cause
While the chat is loading,
AgentChatPagerenders a separateAgentChatPageLoadingViewwhoseAgentChatInputwas wired withinitialValue=""and noonContentChange, so anything typed was neverpersisted. When the queries resolved, that subtree unmounted and the loaded
editor mounted seeded from
editing.editorInitialValue/initialEditorState,which were captured (empty) at the page's first mount. The typed text was
therefore discarded.
Fix
handleLoadingDraftChangetouseConversationEditingState. It persiststhe draft via the existing
handleContentChangeand also advances the seedstate so the draft survives the loading-to-loaded editor swap. It is kept
separate from
handleContentChange, which runs on every keystroke in theloaded editor and must avoid re-renders.
inputRef,initialValue,initialEditorState,remountKey, andonContentChange={editing.handleLoadingDraftChange}to the loading view.AgentChatPageLoadingViewnow accepts and forwards those props to itsAgentChatInput. As a side effect it also restores any pre-existing draft,which it previously ignored.
Testing
tsc --noEmit: cleanvitest(useConversationEditingState): passing, including a new regressiontest that a draft typed during loading is carried into the seed for the loaded
editor
biome check: cleanAgentChatPageLoadingViewstories for the new propsImplementation notes
The seed update lives in a dedicated loading-only handler rather than in
handleContentChangebecause the latter is called on every keystroke in themounted loaded editor and deliberately avoids
setStateto prevent per-keystrokere-renders. During loading there is no heavy editor mounted, so updating the seed
state there is cheap and the active Lexical instance is preserved (its
LexicalComposerkey,remountKey, is unchanged andValueSyncPluginonly seedsonce per mount).
Note
🤖 This PR was written by Coder Agent on behalf of Danielle Maywood