From 922b2e10eb8172f891f981d4cd9588c9e7590b26 Mon Sep 17 00:00:00 2001 From: Brendan Allan <14191578+Brendonovich@users.noreply.github.com> Date: Tue, 19 May 2026 20:22:50 +0800 Subject: [PATCH] refactor(app): remove Accessor wrapping from timeline row renders (#28334) --- .../src/pages/session/message-timeline.tsx | 108 +++++++----------- 1 file changed, 41 insertions(+), 67 deletions(-) diff --git a/packages/app/src/pages/session/message-timeline.tsx b/packages/app/src/pages/session/message-timeline.tsx index c1186b1d10..1df861cfc3 100644 --- a/packages/app/src/pages/session/message-timeline.tsx +++ b/packages/app/src/pages/session/message-timeline.tsx @@ -1,19 +1,4 @@ -import { - createEffect, - createMemo, - createSignal, - For, - Index, - Match, - Switch, - on, - onCleanup, - Show, - mapArray, - untrack, - type Accessor, - type JSX, -} from "solid-js" +import { createEffect, createMemo, createSignal, For, Index, on, onCleanup, Show, mapArray, type JSX } from "solid-js" import { createStore, produce } from "solid-js/store" import { Dynamic } from "solid-js/web" import { useNavigate } from "@solidjs/router" @@ -995,26 +980,26 @@ export function MessageTimeline(props: { const getMsgPart = (messageID: string, partID: string) => getMsgParts(messageID).find((part) => part.id === partID) - const renderAssistantPartGroup = (row: Accessor) => { - if (untrack(row).group.type === "context") { + const renderAssistantPartGroup = (row: TimelineRowMap["AssistantPart"]) => { + if (row.group.type === "context") { const parts = createMemo(() => { - const group = row().group + const group = row.group if (group.type !== "context") return emptyTools return group.refs .map((ref) => getMsgPart(ref.messageID, ref.partID)) .filter((part): part is ToolPart => part?.type === "tool") }) - return + return } const message = createMemo(() => { - const group = row().group + const group = row.group if (group.type !== "part") return return messageByID().get(group.ref.messageID) }) const part = createMemo(() => { - const group = row().group + const group = row.group if (group.type !== "part") return return getMsgPart(group.ref.messageID, group.ref.partID) }) @@ -1027,8 +1012,8 @@ export function MessageTimeline(props: { ; children: JSX.Element }) { + function TimelineRowFrame(input: { row: FramedTimelineRow; children: JSX.Element }) { const anchor = () => { - const row = input.row() + const row = input.row return row._tag === "CommentStrip" || (row._tag === "UserMessage" && row.anchor) } const previousUserMessage = () => { - const row = input.row() + const row = input.row return (row._tag === "CommentStrip" || row._tag === "UserMessage") && row.previousUserMessage } const previousAssistantPart = () => { - const row = input.row() + const row = input.row return row._tag === "AssistantPart" && row.previousAssistantPart } return (
) => { - switch (row()._tag) { + const renderTimelineRow = (row: TimelineRow.TimelineRow) => { + switch (row._tag) { case "CommentStrip": { - const commentStripRow = row as Accessor> const comments = createMemo(() => - getMsgParts(commentStripRow().userMessageID).flatMap((part) => MessageComment.fromPart(part) ?? []), + getMsgParts(row.userMessageID).flatMap((part) => MessageComment.fromPart(part) ?? []), ) return ( - +
@@ -1118,22 +1102,17 @@ export function MessageTimeline(props: { ) } case "UserMessage": { - const userMessageRow = row as Accessor> const message = createMemo(() => { - const m = messageByID().get(userMessageRow().userMessageID) + const m = messageByID().get(row.userMessageID) if (m?.role === "user") return m }) return ( - + {(message) => (
- +
)} @@ -1142,14 +1121,13 @@ export function MessageTimeline(props: { ) } case "TurnDivider": { - const turnDividerRow = row as Accessor> return ( - +
@@ -1158,27 +1136,22 @@ export function MessageTimeline(props: { ) } case "AssistantPart": { - const assistantPartRow = row as Accessor> return ( - +
-
- {renderAssistantPartGroup(assistantPartRow)} +
+ {renderAssistantPartGroup(row)}
) } case "Thinking": { - const thinkingRow = row as Accessor> return ( - +
@@ -1186,32 +1159,29 @@ export function MessageTimeline(props: { ) } case "Retry": { - const retryRow = row as Accessor> return ( - +
- +
) } case "DiffSummary": { - const diffSummaryRow = row as Accessor> return ( - +
- +
) } case "Error": { - const errorRow = row as Accessor> return ( - +
- {errorRow().text} + {row.text}
@@ -1223,7 +1193,11 @@ export function MessageTimeline(props: { } function TimelineRowView(props: { rowKey: string }) { - return {(item) => renderTimelineRow(item)} + return ( + + {(item) => renderTimelineRow(item)} + + ) } return (