2025-04-18 17:44:24 -07:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2025-09-23 15:44:33 -04:00
|
|
|
import { Box, Text } from 'ink';
|
2025-09-23 11:04:49 -07:00
|
|
|
import { StreamingContext } from './contexts/StreamingContext.js';
|
2025-09-23 15:44:33 -04:00
|
|
|
import { Notifications } from './components/Notifications.js';
|
|
|
|
|
import { MainContent } from './components/MainContent.js';
|
|
|
|
|
import { DialogManager } from './components/DialogManager.js';
|
|
|
|
|
import { Composer } from './components/Composer.js';
|
|
|
|
|
import { useUIState } from './contexts/UIStateContext.js';
|
2025-09-06 01:39:02 -04:00
|
|
|
import { QuittingDisplay } from './components/QuittingDisplay.js';
|
2025-09-23 15:44:33 -04:00
|
|
|
import { theme } from './semantic-colors.js';
|
2025-09-06 01:39:02 -04:00
|
|
|
|
|
|
|
|
export const App = () => {
|
|
|
|
|
const uiState = useUIState();
|
|
|
|
|
|
|
|
|
|
if (uiState.quittingMessages) {
|
|
|
|
|
return <QuittingDisplay />;
|
2025-06-11 20:08:32 -04:00
|
|
|
}
|
2025-08-06 15:47:58 -04:00
|
|
|
|
2025-04-17 18:06:21 -04:00
|
|
|
return (
|
2025-09-06 01:39:02 -04:00
|
|
|
<StreamingContext.Provider value={uiState.streamingState}>
|
2025-09-23 15:44:33 -04:00
|
|
|
<Box flexDirection="column" width="90%">
|
|
|
|
|
<MainContent />
|
|
|
|
|
|
|
|
|
|
<Box flexDirection="column" ref={uiState.mainControlsRef}>
|
|
|
|
|
<Notifications />
|
|
|
|
|
|
|
|
|
|
{uiState.dialogsVisible ? (
|
|
|
|
|
<DialogManager addItem={uiState.historyManager.addItem} />
|
|
|
|
|
) : (
|
|
|
|
|
<Composer />
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{uiState.dialogsVisible && uiState.ctrlCPressedOnce && (
|
|
|
|
|
<Box marginTop={1}>
|
|
|
|
|
<Text color={theme.status.warning}>
|
|
|
|
|
Press Ctrl+C again to exit.
|
|
|
|
|
</Text>
|
|
|
|
|
</Box>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{uiState.dialogsVisible && uiState.ctrlDPressedOnce && (
|
|
|
|
|
<Box marginTop={1}>
|
|
|
|
|
<Text color={theme.status.warning}>
|
|
|
|
|
Press Ctrl+D again to exit.
|
|
|
|
|
</Text>
|
|
|
|
|
</Box>
|
|
|
|
|
)}
|
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
2025-05-24 00:44:17 -07:00
|
|
|
</StreamingContext.Provider>
|
2025-04-17 18:06:21 -04:00
|
|
|
);
|
2025-04-15 21:41:08 -07:00
|
|
|
};
|