diff options
| author | Jacob MacDonald <[email protected]> | 2025-06-13 21:21:40 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-14 04:21:40 +0000 |
| commit | d5c6bb9740a52d87b71d812e698d0e88abf10caa (patch) | |
| tree | 7cb990c0adbd1d76d60a655d3dfa15e22db033e3 /packages/cli/src/ui/components/messages/CompressionMessage.tsx | |
| parent | 1452bb4ca4ffe3b5c13aab81baaf510d4c45f06f (diff) | |
Add `/compress` command to force a compression of the context (#986)
Related to https://b.corp.google.com/issues/423605555 - I figured this might be a simpler solution to start with, while still also being useful on its own even if we do implement that.
Diffstat (limited to 'packages/cli/src/ui/components/messages/CompressionMessage.tsx')
| -rw-r--r-- | packages/cli/src/ui/components/messages/CompressionMessage.tsx | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/packages/cli/src/ui/components/messages/CompressionMessage.tsx b/packages/cli/src/ui/components/messages/CompressionMessage.tsx new file mode 100644 index 00000000..aaa56149 --- /dev/null +++ b/packages/cli/src/ui/components/messages/CompressionMessage.tsx @@ -0,0 +1,48 @@ +/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +import React from 'react'; +import { Box, Text } from 'ink'; +import { CompressionProps } from '../../types.js'; +import Spinner from 'ink-spinner'; +import { Colors } from '../../colors.js'; + +export interface CompressionDisplayProps { + compression: CompressionProps; +} + +/* + * Compression messages appear when the /compress command is ran, and show a loading spinner + * while compression is in progress, followed up by some compression stats. + */ +export const CompressionMessage: React.FC<CompressionDisplayProps> = ({ + compression, +}) => { + const text = compression.isPending + ? 'Compressing chat history' + : `Chat history compressed from ${compression.originalTokenCount} to ${compression.newTokenCount} tokens.`; + + return ( + <Box flexDirection="row"> + <Box marginRight={1}> + {compression.isPending ? ( + <Spinner type="dots" /> + ) : ( + <Text color={Colors.AccentPurple}>✦</Text> + )} + </Box> + <Box> + <Text + color={ + compression.isPending ? Colors.AccentPurple : Colors.AccentGreen + } + > + {text} + </Text> + </Box> + </Box> + ); +}; |
