summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/App.tsx
diff options
context:
space:
mode:
authorTae Hyung Kim <[email protected]>2025-05-07 12:57:19 -0700
committerGitHub <[email protected]>2025-05-07 12:57:19 -0700
commit0a7f461d392dbf887ab562e38a2e827e124bfa80 (patch)
treecb0c70da1fbd57630da59c14b69c5f7ea9d1d92b /packages/cli/src/ui/App.tsx
parent358281f0fda7ef4045ca2e9d827a45b56f949467 (diff)
Fix flicker in iterm2 (#266)
Diffstat (limited to 'packages/cli/src/ui/App.tsx')
-rw-r--r--packages/cli/src/ui/App.tsx49
1 files changed, 10 insertions, 39 deletions
diff --git a/packages/cli/src/ui/App.tsx b/packages/cli/src/ui/App.tsx
index 1c1ec424..9fe651b5 100644
--- a/packages/cli/src/ui/App.tsx
+++ b/packages/cli/src/ui/App.tsx
@@ -36,7 +36,7 @@ interface AppProps {
}
export const App = ({ config, settings, cliVersion }: AppProps) => {
- const { history, addItem, updateItem, clearItems } = useHistory();
+ const { history, addItem, clearItems } = useHistory();
const [startupWarnings, setStartupWarnings] = useState<string[]>([]);
const [showHelp, setShowHelp] = useState<boolean>(false);
const {
@@ -57,9 +57,9 @@ export const App = ({ config, settings, cliVersion }: AppProps) => {
initError,
debugMessage,
slashCommands,
+ pendingHistoryItem,
} = useGeminiStream(
addItem,
- updateItem,
clearItems,
refreshStatic,
setShowHelp,
@@ -124,9 +124,6 @@ export const App = ({ config, settings, cliVersion }: AppProps) => {
// --- Render Logic ---
- const { staticallyRenderedHistoryItems, updatableHistoryItems } =
- getHistoryRenderSlices(history);
-
// Get terminal width
const { stdout } = useStdout();
const terminalWidth = stdout?.columns ?? 80;
@@ -146,10 +143,7 @@ export const App = ({ config, settings, cliVersion }: AppProps) => {
* content is set it'll flush content to the terminal and move the area which it's "clearing"
* down a notch. Without Static the area which gets erased and redrawn continuously grows.
*/}
- <Static
- key={'static-key-' + staticKey}
- items={['header', ...staticallyRenderedHistoryItems]}
- >
+ <Static key={'static-key-' + staticKey} items={['header', ...history]}>
{(item, index) => {
if (item === 'header') {
return (
@@ -170,19 +164,14 @@ export const App = ({ config, settings, cliVersion }: AppProps) => {
);
}}
</Static>
-
- {updatableHistoryItems.length > 0 && (
- <Box flexDirection="column" alignItems="flex-start">
- {updatableHistoryItems.map((historyItem) => (
- <HistoryItemDisplay
- key={'history-' + historyItem.id}
- item={historyItem}
- onSubmit={submitQuery}
- />
- ))}
- </Box>
+ {pendingHistoryItem && (
+ <HistoryItemDisplay
+ // TODO(taehykim): It seems like references to ids aren't necessary in
+ // HistoryItemDisplay. Refactor later. Use a fake id for now.
+ item={{ ...pendingHistoryItem, id: 0 }}
+ onSubmit={submitQuery}
+ />
)}
-
{showHelp && <Help commands={slashCommands} />}
{startupWarnings.length > 0 && (
@@ -295,21 +284,3 @@ export const App = ({ config, settings, cliVersion }: AppProps) => {
</Box>
);
};
-
-function getHistoryRenderSlices(history: HistoryItem[]) {
- let staticallyRenderedHistoryItems: HistoryItem[] = [];
- let updatableHistoryItems: HistoryItem[] = [];
- if (
- history.length > 1 &&
- history[history.length - 2]?.type === 'tool_group'
- ) {
- // If the second-to-last item is a tool_group, it and the last item are updateable
- staticallyRenderedHistoryItems = history.slice(0, -2);
- updatableHistoryItems = history.slice(-2);
- } else {
- // Otherwise, only the last item is updateable
- staticallyRenderedHistoryItems = history.slice(0, -1);
- updatableHistoryItems = history.slice(-1);
- }
- return { staticallyRenderedHistoryItems, updatableHistoryItems };
-}