| 1 | import { Box, Text } from "ink"; |
| 2 | import React from "react"; |
| 3 | |
| 4 | import type { PermissionMode } from "../../permissions/types.js"; |
| 5 | import type { NavigationScreen } from "../context/NavigationContext.js"; |
| 6 | import { FreeTrialStatus } from "../FreeTrialStatus.js"; |
| 7 | import { UpdateNotification } from "../UpdateNotification.js"; |
| 8 | |
| 9 | import { ContextPercentageDisplay } from "./ContextPercentageDisplay.js"; |
| 10 | import { ModeIndicator } from "./ModeIndicator.js"; |
| 11 | |
| 12 | interface BottomStatusBarProps { |
| 13 | currentMode: PermissionMode; |
| 14 | repoURLText: string; |
| 15 | isRemoteMode: boolean; |
| 16 | services: any; |
| 17 | navState: any; |
| 18 | navigateTo: (screen: NavigationScreen, data?: any) => void; |
| 19 | closeCurrentScreen: () => void; |
| 20 | contextPercentage?: number; |
| 21 | hasImageInClipboard?: boolean; |
| 22 | } |
| 23 | |
| 24 | export const BottomStatusBar: React.FC<BottomStatusBarProps> = ({ |
| 25 | currentMode, |
| 26 | repoURLText, |
| 27 | isRemoteMode, |
| 28 | services, |
| 29 | navState, |
| 30 | navigateTo, |
| 31 | closeCurrentScreen, |
| 32 | contextPercentage, |
| 33 | hasImageInClipboard, |
| 34 | }) => ( |
| 35 | <Box flexDirection="row" justifyContent="space-between" alignItems="center"> |
| 36 | <Box marginLeft={2} flexDirection="row" alignItems="center"> |
| 37 | {currentMode === "normal" && ( |
| 38 | <React.Fragment> |
| 39 | {hasImageInClipboard ? ( |
| 40 | <Text key="image-paste-hint" color="cyan" wrap="truncate-start"> |
| 41 | Press Ctrl+V to paste image |
| 42 | </Text> |
| 43 | ) : ( |
| 44 | <Text key="repo-url" color="dim" wrap="truncate-start"> |
| 45 | {repoURLText} |
| 46 | </Text> |
| 47 | )} |
| 48 | <Text key="repo-separator"> </Text> |
| 49 | </React.Fragment> |
| 50 | )} |
| 51 | <ModeIndicator /> |
| 52 | {contextPercentage !== undefined && contextPercentage > 75 && ( |
| 53 | <React.Fragment> |
| 54 | <Text key="context-separator" color="dim"> |
| 55 | {" "} |
| 56 | •{" "} |
| 57 | </Text> |
| 58 | <ContextPercentageDisplay percentage={contextPercentage} /> |
| 59 | </React.Fragment> |
| 60 | )} |
| 61 | </Box> |
| 62 | <Box> |
| 63 | {!isRemoteMode && services.model?.model && ( |
| 64 | <FreeTrialStatus |
| 65 | apiClient={services.apiClient?.apiClient || undefined} |
| 66 | model={services.model.model} |
| 67 | onTransitionStateChange={(shouldShow) => { |
| 68 | if (shouldShow && navState.currentScreen === "chat") { |
| 69 | navigateTo("free-trial"); |
| 70 | } else if (!shouldShow && navState.currentScreen === "free-trial") { |
| 71 | closeCurrentScreen(); |
| 72 | } |
| 73 | }} |
| 74 | /> |
| 75 | )} |
| 76 | </Box> |
| 77 | <Box marginRight={2} marginLeft={2}> |
| 78 | <UpdateNotification isRemoteMode={isRemoteMode} /> |
| 79 | </Box> |
| 80 | </Box> |
| 81 | ); |