diff options
| author | Tae Hyung Kim <[email protected]> | 2025-05-07 22:58:41 -0700 |
|---|---|---|
| committer | N. Taylor Mullen <[email protected]> | 2025-05-07 23:47:58 -0700 |
| commit | 448a24746c00dc01a7f7fdc960b5a634e3da3e31 (patch) | |
| tree | 134fbb287f3947b14f5c43061712456e979fd2bf /packages/cli/src | |
| parent | 6989032414d55704a3542a0e9ec02356cc92336e (diff) | |
init
Diffstat (limited to 'packages/cli/src')
| -rw-r--r-- | packages/cli/src/ui/hooks/useGeminiStream.ts | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/packages/cli/src/ui/hooks/useGeminiStream.ts b/packages/cli/src/ui/hooks/useGeminiStream.ts index 78456d57..de073373 100644 --- a/packages/cli/src/ui/hooks/useGeminiStream.ts +++ b/packages/cli/src/ui/hooks/useGeminiStream.ts @@ -180,12 +180,16 @@ export const useGeminiStream = ( if (signal.aborted) break; if (event.type === ServerGeminiEventType.Content) { - if (pendingHistoryItemRef.current?.type !== 'gemini') { + if ( + pendingHistoryItemRef.current?.type !== 'gemini' && + pendingHistoryItemRef.current?.type !== 'gemini_content' + ) { // Flush out existing pending history item. if (pendingHistoryItemRef.current) { addItem(pendingHistoryItemRef.current, userMessageTimestamp); } setPendingHistoryItem({ + // Use the 'gemini' type for the initial history item. type: 'gemini', text: '', }); @@ -199,10 +203,10 @@ export const useGeminiStream = ( const splitPoint = findLastSafeSplitPoint(geminiMessageBuffer); if (splitPoint === geminiMessageBuffer.length) { // Update the existing message with accumulated content - setPendingHistoryItem({ - type: 'gemini', + setPendingHistoryItem((item) => ({ + type: item?.type as 'gemini' | 'gemini_content', text: geminiMessageBuffer, - }); + })); } else { // This indicates that we need to split up this Gemini Message. // Splitting a message is primarily a performance consideration. There is a @@ -216,11 +220,16 @@ export const useGeminiStream = ( const afterText = geminiMessageBuffer.substring(splitPoint); geminiMessageBuffer = afterText; // Continue accumulating from split point addItem( - { type: 'gemini', text: beforeText }, + { + type: pendingHistoryItemRef.current?.type as + | 'gemini' + | 'gemini_content', + text: beforeText, + }, userMessageTimestamp, ); setPendingHistoryItem({ - type: 'gemini', + type: 'gemini_content', text: afterText, }); } |
