test commit

This commit is contained in:
Dmitry Lyalin
2026-01-03 19:00:15 -05:00
parent 3a513f9890
commit d58a127753
4 changed files with 57 additions and 14 deletions

View File

@@ -35,6 +35,20 @@ describe('ThinkingMessage', () => {
expect(lastFrame()).toContain('(1)');
});
it('renders thought content', () => {
const { lastFrame } = render(
<ThinkingMessage
thoughts={[
{ subject: 'Planning', description: 'I am planning the solution.' },
]}
terminalWidth={80}
/>,
);
expect(lastFrame()).toContain('Planning');
expect(lastFrame()).toContain('I am planning the solution.');
});
it('renders empty state gracefully', () => {
const { lastFrame } = render(
<ThinkingMessage thoughts={[]} terminalWidth={80} />,

View File

@@ -23,11 +23,24 @@ export const ThinkingMessage: React.FC<ThinkingMessageProps> = ({
width={terminalWidth}
paddingX={1}
marginBottom={1}
flexDirection="column"
>
<Text color="magenta"> </Text>
<Text bold color="magenta">
Thinking
</Text>
<Text dimColor> ({thoughts.length})</Text>
<Box>
<Text color="magenta"> </Text>
<Text bold color="magenta">
Thinking
</Text>
<Text dimColor> ({thoughts.length})</Text>
</Box>
{thoughts.map((thought, index) => (
<Box key={index} marginTop={1} flexDirection="column">
{thought.subject && (
<Text bold color="magenta">
{thought.subject}
</Text>
)}
<Text>{thought.description || ' '}</Text>
</Box>
))}
</Box>
);

View File

@@ -119,7 +119,9 @@ export const useGeminiStream = (
const activeQueryIdRef = useRef<string | null>(null);
const [isResponding, setIsResponding] = useState<boolean>(false);
const [thought, setThought] = useState<ThoughtSummary | null>(null);
const thoughtsBufferRef = useRef<ThoughtSummary[]>([]);
const [thoughtsBuffer, thoughtsBufferRef, setThoughtsBuffer] = useStateAndRef<
ThoughtSummary[]
>([]);
const [pendingHistoryItem, pendingHistoryItemRef, setPendingHistoryItem] =
useStateAndRef<HistoryItemWithoutId | null>(null);
@@ -136,10 +138,10 @@ export const useGeminiStream = (
} as HistoryItemThinking,
userMessageTimestamp,
);
thoughtsBufferRef.current = [];
setThoughtsBuffer([]);
}
},
[addItem, settings],
[addItem, settings, setThoughtsBuffer, thoughtsBufferRef],
);
const processedMemoryToolsRef = useRef<Set<string>>(new Set());
@@ -828,7 +830,7 @@ export const useGeminiStream = (
switch (event.type) {
case ServerGeminiEventType.Thought:
setThought(event.value);
thoughtsBufferRef.current.push(event.value);
setThoughtsBuffer((prev) => [...prev, event.value]);
break;
case ServerGeminiEventType.Content:
geminiMessageBuffer = handleContentEvent(
@@ -908,6 +910,7 @@ export const useGeminiStream = (
handleCitationEvent,
handleChatModelEvent,
flushThoughts,
setThoughtsBuffer,
],
);
const submitQuery = useCallback(
@@ -1085,6 +1088,7 @@ export const useGeminiStream = (
config,
startNewPrompt,
getPromptCount,
thoughtsBufferRef,
],
);
@@ -1282,12 +1286,24 @@ export const useGeminiStream = (
],
);
const pendingThinkingItem = useMemo(() => {
if (settings.merged.ui?.showInlineThinking && thoughtsBuffer.length > 0) {
return {
type: 'thinking',
thoughts: thoughtsBuffer,
} as HistoryItemWithoutId;
}
return null;
}, [settings.merged.ui?.showInlineThinking, thoughtsBuffer]);
const pendingHistoryItems = useMemo(
() =>
[pendingHistoryItem, pendingToolCallGroupDisplay].filter(
(i) => i !== undefined && i !== null,
),
[pendingHistoryItem, pendingToolCallGroupDisplay],
[
pendingThinkingItem,
pendingHistoryItem,
pendingToolCallGroupDisplay,
].filter((i) => i !== undefined && i !== null),
[pendingThinkingItem, pendingHistoryItem, pendingToolCallGroupDisplay],
);
useEffect(() => {

View File

@@ -57,7 +57,7 @@ try {
const fileContent = `/**
* @license
* Copyright ${new Date().getFullYear()} Google LLC
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/