diff --git a/packages/cli/src/ui/App.tsx b/packages/cli/src/ui/App.tsx index e37ab2f2..3b499ab9 100644 --- a/packages/cli/src/ui/App.tsx +++ b/packages/cli/src/ui/App.tsx @@ -80,8 +80,8 @@ export const App = ({ config, cliVersion }: AppProps) => { // --- Render Logic --- - const staticallyRenderedHistoryItems = history.slice(0, -1); - const updatableHistoryItem = history[history.length - 1]; + const { staticallyRenderedHistoryItems, updatableHistoryItems } = + getHistoryRenderSlices(history); return ( @@ -118,13 +118,15 @@ export const App = ({ config, cliVersion }: AppProps) => { }} - {updatableHistoryItem && ( + {updatableHistoryItems.length > 0 && ( - + {updatableHistoryItems.map((historyItem) => ( + + ))} )} @@ -214,3 +216,21 @@ export const App = ({ config, cliVersion }: AppProps) => { ); }; + +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 }; +}