- sendInput(editorState, modifiers, index)
- }
- isLastUserInput={isLastUserInput(index)}
- isMainInput={false}
- editorState={editorState ?? item.message.content}
- contextItems={contextItems}
- appliedRules={appliedRules}
- inputId={message.id}
- />
- );
- }
-
- if (message.role === "tool") {
- return null;
- }
-
- if (message.role === "assistant") {
- return (
- <>
- {/* Always render assistant content through normal path */}
-
-
- }
- open={
- typeof stepsOpen[index] === "undefined"
- ? true
- : stepsOpen[index]!
- }
- onToggle={() => {}}
- >
-
-
-
-
- {toolCallStates && (
-
- )}
- >
- );
- }
-
- if (message.role === "thinking") {
- const thinkingContent = renderChatMessage(message);
- if (!thinkingContent?.trim()) {
- return null;
- }
- return (
-
- 0 ? history[index - 1] : null}
- inProgress={index === history.length - 1 && isStreaming}
- signature={message.signature}
- />
-
- );
- }
+ const lastUserInputIndex = useMemo(() => {
+ for (let i = history.length - 1; i >= 0; i--) {
+ if (history[i].message.role === "user") return i;
+ }
+ return -1;
+ }, [history.length]);
- // Default case - regular assistant message
- return (
-
- }
- open={
- typeof stepsOpen[index] === "undefined" ? true : stepsOpen[index]!
- }
- onToggle={() => {}}
- >
-
-
-
- );
- },
- [sendInput, isLastUserInput, history, stepsOpen, isStreaming],
+ const latestSummaryIndex = useMemo(
+ () => findLatestSummaryIndex(history),
+ [history],
);
const showScrollbar = showChatScrollbar ?? window.innerHeight > 5000;
@@ -462,7 +464,16 @@ export function Chat() {
dispatch(newSession());
}}
>
- {renderChatHistoryItem(item, index)}
+ 0 ? history[index - 1] : null}
+ />
{index === history.length - 1 && }
diff --git a/gui/src/pages/gui/useAutoScroll.ts b/gui/src/pages/gui/useAutoScroll.ts
index 236ca9f7694..63cfe9f27df 100644
--- a/gui/src/pages/gui/useAutoScroll.ts
+++ b/gui/src/pages/gui/useAutoScroll.ts
@@ -45,14 +45,9 @@ export const useAutoScroll = (
ref.current.addEventListener("scroll", handleScroll);
- // Observe the container
+ // Observe the container — its scrollHeight changes whenever children grow
resizeObserver.observe(ref.current);
- // Observe all immediate children
- Array.from(ref.current.children).forEach((child) => {
- resizeObserver.observe(child);
- });
-
return () => {
resizeObserver.disconnect();
ref.current?.removeEventListener("scroll", handleScroll);