2025-09-06 01:39:02 -04:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { Box, Static } from 'ink';
|
2025-09-23 11:04:49 -07:00
|
|
|
import { HistoryList } from './HistoryList.js';
|
|
|
|
|
import { PendingHistoryList } from './PendingHistoryList.js';
|
2025-09-06 01:39:02 -04:00
|
|
|
import { ShowMoreLines } from './ShowMoreLines.js';
|
|
|
|
|
import { OverflowProvider } from '../contexts/OverflowContext.js';
|
|
|
|
|
import { useUIState } from '../contexts/UIStateContext.js';
|
|
|
|
|
import { useAppContext } from '../contexts/AppContext.js';
|
|
|
|
|
import { AppHeader } from './AppHeader.js';
|
2025-09-23 11:04:49 -07:00
|
|
|
import { useLayoutConfig } from '../hooks/useLayoutConfig.js';
|
2025-09-06 01:39:02 -04:00
|
|
|
|
|
|
|
|
export const MainContent = () => {
|
|
|
|
|
const { version } = useAppContext();
|
|
|
|
|
const uiState = useUIState();
|
2025-09-23 11:04:49 -07:00
|
|
|
const layout = useLayoutConfig();
|
2025-09-06 01:39:02 -04:00
|
|
|
const {
|
|
|
|
|
pendingHistoryItems,
|
|
|
|
|
mainAreaWidth,
|
|
|
|
|
staticAreaMaxItemHeight,
|
|
|
|
|
availableTerminalHeight,
|
|
|
|
|
} = uiState;
|
|
|
|
|
|
2025-09-23 11:04:49 -07:00
|
|
|
// In screen reader mode, use regular layout without Static component
|
|
|
|
|
if (!layout.shouldUseStatic) {
|
|
|
|
|
return (
|
|
|
|
|
<OverflowProvider>
|
|
|
|
|
<Box flexDirection="column">
|
|
|
|
|
<AppHeader version={version} />
|
|
|
|
|
<HistoryList
|
|
|
|
|
history={uiState.history}
|
|
|
|
|
terminalWidth={mainAreaWidth}
|
|
|
|
|
staticAreaMaxItemHeight={staticAreaMaxItemHeight}
|
|
|
|
|
slashCommands={uiState.slashCommands}
|
|
|
|
|
/>
|
|
|
|
|
<PendingHistoryList
|
|
|
|
|
pendingHistoryItems={pendingHistoryItems}
|
|
|
|
|
terminalWidth={mainAreaWidth}
|
|
|
|
|
availableTerminalHeight={availableTerminalHeight}
|
|
|
|
|
constrainHeight={uiState.constrainHeight}
|
|
|
|
|
isEditorDialogOpen={uiState.isEditorDialogOpen}
|
|
|
|
|
/>
|
|
|
|
|
<ShowMoreLines constrainHeight={uiState.constrainHeight} />
|
|
|
|
|
</Box>
|
|
|
|
|
</OverflowProvider>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Default mode with Static component
|
2025-09-06 01:39:02 -04:00
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Static
|
|
|
|
|
key={uiState.historyRemountKey}
|
|
|
|
|
items={[
|
|
|
|
|
<AppHeader key="app-header" version={version} />,
|
2025-09-23 11:04:49 -07:00
|
|
|
<HistoryList
|
|
|
|
|
key="history-list"
|
|
|
|
|
history={uiState.history}
|
|
|
|
|
terminalWidth={mainAreaWidth}
|
|
|
|
|
staticAreaMaxItemHeight={staticAreaMaxItemHeight}
|
|
|
|
|
slashCommands={uiState.slashCommands}
|
|
|
|
|
/>,
|
2025-09-06 01:39:02 -04:00
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
{(item) => item}
|
|
|
|
|
</Static>
|
|
|
|
|
<OverflowProvider>
|
|
|
|
|
<Box flexDirection="column">
|
2025-09-23 11:04:49 -07:00
|
|
|
<PendingHistoryList
|
|
|
|
|
pendingHistoryItems={pendingHistoryItems}
|
|
|
|
|
terminalWidth={mainAreaWidth}
|
|
|
|
|
availableTerminalHeight={availableTerminalHeight}
|
|
|
|
|
constrainHeight={uiState.constrainHeight}
|
|
|
|
|
isEditorDialogOpen={uiState.isEditorDialogOpen}
|
|
|
|
|
activePtyId={uiState.activePtyId?.toString()}
|
|
|
|
|
embeddedShellFocused={uiState.embeddedShellFocused}
|
|
|
|
|
/>
|
2025-09-06 01:39:02 -04:00
|
|
|
<ShowMoreLines constrainHeight={uiState.constrainHeight} />
|
|
|
|
|
</Box>
|
|
|
|
|
</OverflowProvider>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|