@@ -142,6 +142,7 @@ export function SessionTurn( |
142 | 142 | props: ParentProps<{ |
143 | 143 | sessionID: string |
144 | 144 | messageID: string |
| 145 | + messages?: MessageType[] |
145 | 146 | actions?: UserActions |
146 | 147 | showReasoningSummaries?: boolean |
147 | 148 | shellToolDefaultOpen?: boolean |
@@ -166,7 +167,7 @@ export function SessionTurn( |
166 | 167 | const emptyDiffs: FileDiff[] = [] |
167 | 168 | const idle = { type: "idle" as const } |
168 | 169 |
|
169 | | - const allMessages = createMemo(() => list(data.store.message?.[props.sessionID], emptyMessages)) |
| 170 | + const allMessages = createMemo(() => props.messages ?? list(data.store.message?.[props.sessionID], emptyMessages)) |
170 | 171 |
|
171 | 172 | const messageIndex = createMemo(() => { |
172 | 173 | const messages = allMessages() ?? emptyMessages |
@@ -340,30 +341,28 @@ export function SessionTurn( |
340 | 341 | if (end < start) return undefined |
341 | 342 | return end - start |
342 | 343 | }) |
343 | | - const assistantVisible = createMemo(() => |
344 | | - assistantMessages().reduce((count, message) => { |
345 | | - const parts = list(data.store.part?.[message.id], emptyParts) |
346 | | - return count + parts.filter((part) => partState(part, showReasoningSummaries()) === "visible").length |
347 | | - }, 0), |
348 | | - ) |
349 | | - const assistantTailVisible = createMemo(() => |
350 | | - assistantMessages() |
351 | | - .flatMap((message) => list(data.store.part?.[message.id], emptyParts)) |
352 | | - .flatMap((part) => { |
353 | | - if (partState(part, showReasoningSummaries()) !== "visible") return [] |
354 | | - if (part.type === "text") return ["text" as const] |
355 | | - return ["other" as const] |
356 | | - }) |
357 | | - .at(-1), |
358 | | - ) |
359 | | - const reasoningHeading = createMemo(() => |
360 | | - assistantMessages() |
361 | | - .flatMap((message) => list(data.store.part?.[message.id], emptyParts)) |
362 | | - .filter((part): part is PartType & { type: "reasoning"; text: string } => part.type === "reasoning") |
363 | | - .map((part) => heading(part.text)) |
364 | | - .filter((text): text is string => !!text) |
365 | | - .at(-1), |
366 | | - ) |
| 344 | + const assistantDerived = createMemo(() => { |
| 345 | + let visible = 0 |
| 346 | + let tail: "text" | "other" | undefined |
| 347 | + let reason: string | undefined |
| 348 | + const show = showReasoningSummaries() |
| 349 | + for (const message of assistantMessages()) { |
| 350 | + for (const part of list(data.store.part?.[message.id], emptyParts)) { |
| 351 | + if (partState(part, show) === "visible") { |
| 352 | + visible++ |
| 353 | + tail = part.type === "text" ? "text" : "other" |
| 354 | + } |
| 355 | + if (part.type === "reasoning" && part.text) { |
| 356 | + const h = heading(part.text) |
| 357 | + if (h) reason = h |
| 358 | + } |
| 359 | + } |
| 360 | + } |
| 361 | + return { visible, tail, reason } |
| 362 | + }) |
| 363 | + const assistantVisible = createMemo(() => assistantDerived().visible) |
| 364 | + const assistantTailVisible = createMemo(() => assistantDerived().tail) |
| 365 | + const reasoningHeading = createMemo(() => assistantDerived().reason) |
367 | 366 | const showThinking = createMemo(() => { |
368 | 367 | if (!working() || !!error()) return false |
369 | 368 | if (status().type === "retry") return false |
|