Refactor ChatView into memoized UI subcomponents #58
Mergedjuliusmarmingemerged 2 commits into
main fromcodething/b1a7277cmerged by juliusmarminge View on GitHub- @@ -913 +900,20 @@913- };900+ setRespondingRequestIds((existing) =>901+ existing.includes(requestId) ? existing : [...existing, requestId],902+ );903+ try {904+ await api.providers.respondToRequest({905+ sessionId: activeThread.session.sessionId,906+ requestId,907+ decision,908+ });909+ } catch (err) {910+ dispatch({911+ type: "SET_ERROR",912+ threadId: activeThread.id,913+ error: err instanceof Error ? err.message : "Failed to submit approval decision.",914+ });915+ } finally {916+ setRespondingRequestIds((existing) => existing.filter((id) => id !== requestId));917+ }918+ },919+ [activeThread?.id, activeThread?.session, api, dispatch],@@ -1259,8 +1017,13 @@1259- <span className="h-1 w-1 rounded-full bg-muted-foreground/30 animate-pulse [animation-delay:400ms]" />1260- </span>1261- </div>1262- </div>1263- )}1264- <div ref={messagesEndRef} />1265- </div>1266- )}1017+ <MessagesTimeline1018+ activeThread={activeThread}1019+ isWorking={isWorking}1020+ timelineEntries={timelineEntries}1021+ completionDividerBeforeEntryId={completionDividerBeforeEntryId}1022+ completionSummary={completionSummary}1023+ assistantCompletionByItemId={assistantCompletionByItemId}1024+ nowIso={nowIso}1025+ expandedWorkGroups={expandedWorkGroups}1026+ onToggleWorkGroup={onToggleWorkGroup}1027+ onImageExpand={onExpandTimelineImage}1028+ messagesEndRef={messagesEndRef}1029+ />
juliusmarminge merged this73fa2d6
juliusmarminge closed this
Sign in to join this conversation.
Walkthrough#
Wrapped ChatMarkdown with React.memo. Refactored ChatView by extracting inline UI into multiple memoized subcomponents (ChatHeader, ThreadErrorBanner, PendingApprovalsPanel, MessagesTimeline, ModelPicker, ReasoningEffortPicker, OpenInPicker), adjusted callback wiring and timer interval.
Changes#
apps/web/src/components/ChatMarkdown.tsxmemoimport and exportedmemo(ChatMarkdown)instead of the raw component; no rendering or prop changes.apps/web/src/components/ChatView.tsxChatHeader,ThreadErrorBanner,PendingApprovalsPanel,MessagesTimeline,ModelPicker,ReasoningEffortPicker,OpenInPicker), moved logic into those components, introduceduseCallbackfor approval handling, addedactiveSessionIdusage, changed running-phase timer from 250ms to 1000ms, and expanded imports/types.Sequence Diagram(s)#
Estimated code review effort#
🎯 4 (Complex) | ⏱️ ~45 minutes
🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (3 passed)
main✨ Finishing touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands and usage tips.