fix(cli): address code review feedback regarding btw rendering and throttle cleanup

This commit is contained in:
Mahima Shanware
2026-04-03 18:44:43 +00:00
parent 96798e32b2
commit c1c8ecef3c
2 changed files with 20 additions and 4 deletions
@@ -436,6 +436,9 @@ export const MainContent = () => {
{(item) => item}
</Static>
{pendingItems}
{/* In alternate buffer mode, the btwDisplayNode is rendered within the ScrollableList
(via virtualizedData) to ensure proper scrolling. In standard mode, it is rendered
here at the bottom of the layout. */}
{btwDisplayNode}
</>
);
+17 -4
View File
@@ -148,7 +148,10 @@ export const useBtw = (
break;
}
case GeminiEventType.Error: {
if (flushTimerRef.current) clearTimeout(flushTimerRef.current);
if (flushTimerRef.current) {
clearTimeout(flushTimerRef.current);
flushTimerRef.current = null;
}
flushResponse();
const value = event.value;
@@ -177,7 +180,10 @@ export const useBtw = (
}
case GeminiEventType.Finished:
case GeminiEventType.UserCancelled:
if (flushTimerRef.current) clearTimeout(flushTimerRef.current);
if (flushTimerRef.current) {
clearTimeout(flushTimerRef.current);
flushTimerRef.current = null;
}
flushResponse();
dispatch({ type: 'FINISHED' });
break;
@@ -186,7 +192,10 @@ export const useBtw = (
}
}
} catch (err) {
if (flushTimerRef.current) clearTimeout(flushTimerRef.current);
if (flushTimerRef.current) {
clearTimeout(flushTimerRef.current);
flushTimerRef.current = null;
}
flushResponse();
if (err instanceof Error && err.name === 'AbortError') {
@@ -198,7 +207,10 @@ export const useBtw = (
});
}
} finally {
if (flushTimerRef.current) clearTimeout(flushTimerRef.current);
if (flushTimerRef.current) {
clearTimeout(flushTimerRef.current);
flushTimerRef.current = null;
}
flushResponse();
if (requestIdRef.current === requestId) {
@@ -217,6 +229,7 @@ export const useBtw = (
}
if (flushTimerRef.current) {
clearTimeout(flushTimerRef.current);
flushTimerRef.current = null;
}
},
[],