mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-12 12:54:07 -07:00
test commit
This commit is contained in:
@@ -35,6 +35,20 @@ describe('ThinkingMessage', () => {
|
|||||||
expect(lastFrame()).toContain('(1)');
|
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', () => {
|
it('renders empty state gracefully', () => {
|
||||||
const { lastFrame } = render(
|
const { lastFrame } = render(
|
||||||
<ThinkingMessage thoughts={[]} terminalWidth={80} />,
|
<ThinkingMessage thoughts={[]} terminalWidth={80} />,
|
||||||
|
|||||||
@@ -23,11 +23,24 @@ export const ThinkingMessage: React.FC<ThinkingMessageProps> = ({
|
|||||||
width={terminalWidth}
|
width={terminalWidth}
|
||||||
paddingX={1}
|
paddingX={1}
|
||||||
marginBottom={1}
|
marginBottom={1}
|
||||||
|
flexDirection="column"
|
||||||
>
|
>
|
||||||
|
<Box>
|
||||||
<Text color="magenta">◆ </Text>
|
<Text color="magenta">◆ </Text>
|
||||||
<Text bold color="magenta">
|
<Text bold color="magenta">
|
||||||
Thinking
|
Thinking
|
||||||
</Text>
|
</Text>
|
||||||
<Text dimColor> ({thoughts.length})</Text>
|
<Text dimColor> ({thoughts.length})</Text>
|
||||||
</Box>
|
</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>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -119,7 +119,9 @@ export const useGeminiStream = (
|
|||||||
const activeQueryIdRef = useRef<string | null>(null);
|
const activeQueryIdRef = useRef<string | null>(null);
|
||||||
const [isResponding, setIsResponding] = useState<boolean>(false);
|
const [isResponding, setIsResponding] = useState<boolean>(false);
|
||||||
const [thought, setThought] = useState<ThoughtSummary | null>(null);
|
const [thought, setThought] = useState<ThoughtSummary | null>(null);
|
||||||
const thoughtsBufferRef = useRef<ThoughtSummary[]>([]);
|
const [thoughtsBuffer, thoughtsBufferRef, setThoughtsBuffer] = useStateAndRef<
|
||||||
|
ThoughtSummary[]
|
||||||
|
>([]);
|
||||||
const [pendingHistoryItem, pendingHistoryItemRef, setPendingHistoryItem] =
|
const [pendingHistoryItem, pendingHistoryItemRef, setPendingHistoryItem] =
|
||||||
useStateAndRef<HistoryItemWithoutId | null>(null);
|
useStateAndRef<HistoryItemWithoutId | null>(null);
|
||||||
|
|
||||||
@@ -136,10 +138,10 @@ export const useGeminiStream = (
|
|||||||
} as HistoryItemThinking,
|
} as HistoryItemThinking,
|
||||||
userMessageTimestamp,
|
userMessageTimestamp,
|
||||||
);
|
);
|
||||||
thoughtsBufferRef.current = [];
|
setThoughtsBuffer([]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[addItem, settings],
|
[addItem, settings, setThoughtsBuffer, thoughtsBufferRef],
|
||||||
);
|
);
|
||||||
|
|
||||||
const processedMemoryToolsRef = useRef<Set<string>>(new Set());
|
const processedMemoryToolsRef = useRef<Set<string>>(new Set());
|
||||||
@@ -828,7 +830,7 @@ export const useGeminiStream = (
|
|||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case ServerGeminiEventType.Thought:
|
case ServerGeminiEventType.Thought:
|
||||||
setThought(event.value);
|
setThought(event.value);
|
||||||
thoughtsBufferRef.current.push(event.value);
|
setThoughtsBuffer((prev) => [...prev, event.value]);
|
||||||
break;
|
break;
|
||||||
case ServerGeminiEventType.Content:
|
case ServerGeminiEventType.Content:
|
||||||
geminiMessageBuffer = handleContentEvent(
|
geminiMessageBuffer = handleContentEvent(
|
||||||
@@ -908,6 +910,7 @@ export const useGeminiStream = (
|
|||||||
handleCitationEvent,
|
handleCitationEvent,
|
||||||
handleChatModelEvent,
|
handleChatModelEvent,
|
||||||
flushThoughts,
|
flushThoughts,
|
||||||
|
setThoughtsBuffer,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
const submitQuery = useCallback(
|
const submitQuery = useCallback(
|
||||||
@@ -1085,6 +1088,7 @@ export const useGeminiStream = (
|
|||||||
config,
|
config,
|
||||||
startNewPrompt,
|
startNewPrompt,
|
||||||
getPromptCount,
|
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(
|
const pendingHistoryItems = useMemo(
|
||||||
() =>
|
() =>
|
||||||
[pendingHistoryItem, pendingToolCallGroupDisplay].filter(
|
[
|
||||||
(i) => i !== undefined && i !== null,
|
pendingThinkingItem,
|
||||||
),
|
pendingHistoryItem,
|
||||||
[pendingHistoryItem, pendingToolCallGroupDisplay],
|
pendingToolCallGroupDisplay,
|
||||||
|
].filter((i) => i !== undefined && i !== null),
|
||||||
|
[pendingThinkingItem, pendingHistoryItem, pendingToolCallGroupDisplay],
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ try {
|
|||||||
|
|
||||||
const fileContent = `/**
|
const fileContent = `/**
|
||||||
* @license
|
* @license
|
||||||
* Copyright ${new Date().getFullYear()} Google LLC
|
* Copyright 2025 Google LLC
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user