| 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 | } |
| 22 | |
| 23 | export const BottomStatusBar: React.FC<BottomStatusBarProps> = ({ |
| 24 | currentMode, |
| 25 | repoURLText, |
| 26 | isRemoteMode, |
| 27 | services, |
| 28 | navState, |
| 29 | navigateTo, |
| 30 | closeCurrentScreen, |
| 31 | contextPercentage, |
| 32 | }) => ( |
| 33 | <Box flexDirection="row" justifyContent="space-between" alignItems="center"> |
| 34 | <Box marginLeft={2} flexDirection="row" alignItems="center"> |
| 35 | {currentMode === "normal" && ( |
| 36 | <React.Fragment> |
| 37 | <Text key="repo-url" color="dim" wrap="truncate-start"> |
| 38 | {repoURLText} |
| 39 | </Text> |
| 40 | <Text key="repo-separator"> </Text> |
| 41 | </React.Fragment> |
| 42 | )} |
| 43 | <ModeIndicator /> |
| 44 | {contextPercentage !== undefined && contextPercentage > 75 && ( |
| 45 | <React.Fragment> |
| 46 | <Text key="context-separator"> • </Text> |
| 47 | <ContextPercentageDisplay percentage={contextPercentage} /> |
| 48 | </React.Fragment> |
| 49 | )} |
| 50 | </Box> |
| 51 | <Box> |
| 52 | {!isRemoteMode && services.model?.model && ( |
| 53 | <FreeTrialStatus |
| 54 | apiClient={services.apiClient?.apiClient || undefined} |
| 55 | model={services.model.model} |
| 56 | onTransitionStateChange={(shouldShow) => { |
| 57 | if (shouldShow && navState.currentScreen === "chat") { |
| 58 | navigateTo("free-trial"); |
| 59 | } else if (!shouldShow && navState.currentScreen === "free-trial") { |
| 60 | closeCurrentScreen(); |
| 61 | } |
| 62 | }} |
| 63 | /> |
| 64 | )} |
| 65 | </Box> |
| 66 | <Box marginRight={2} marginLeft={2}> |
| 67 | <UpdateNotification isRemoteMode={isRemoteMode} /> |
| 68 | </Box> |
| 69 | </Box> |
| 70 | ); |