diff --git a/.eslintrc.js b/.eslintrc.js index 6df5b76c..0d3f1459 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -42,9 +42,14 @@ module.exports = { 'no-process-exit': 'off', 'prettier/prettier': 'error', 'node/no-unsupported-features/es-syntax': 'off', - 'react/prop-types': ['error', { ignore: ['children'] }], // Already covered by React.FC }, overrides: [ + { + files: ['*.tsx'], + rules: { + 'react/prop-types': ['off'], // Covered by React.FC + }, + }, { files: ['*config*', 'test/**/*.ts'], rules: { diff --git a/lib/ui/components/AppCLI.tsx b/lib/ui/components/AppCLI.tsx index f73690d4..e3dbb51e 100644 --- a/lib/ui/components/AppCLI.tsx +++ b/lib/ui/components/AppCLI.tsx @@ -1,4 +1,5 @@ import React from 'react'; +import { Newline, Text } from 'ink'; import Status from './Status'; import Tasks from './Tasks'; @@ -11,7 +12,7 @@ import useOnHorizontalResize from '../hooks/useOnHorizontalResize'; /** * Application for CLIs */ -export default function AppCLI(): JSX.Element { +const AppCLI: React.FC<{ isTTY: boolean }> = ({ isTTY }) => { const done = useOnExit(); // Clear screen completely on horizontal resize @@ -22,11 +23,24 @@ export default function AppCLI(): JSX.Element { return ; } + // Scrollbox can only be rendered in TTY + const wrapper = isTTY ? MessagesScrollBox : undefined; + return ( <> + {!isTTY && ( + + Terminal is not detected as TTY. Scrollbox is disabled. + + + )} + - + {!isTTY && {/* Spacer */}} + ); -} +}; + +export default AppCLI; diff --git a/lib/ui/render-application.tsx b/lib/ui/render-application.tsx index ec88c234..d94ef0f6 100644 --- a/lib/ui/render-application.tsx +++ b/lib/ui/render-application.tsx @@ -6,8 +6,11 @@ import AppCI from './components/AppCI'; import AppCLI from './components/AppCLI'; export default function renderApplication(): void { - render(config.CI ? : , { + // Both stdout and stdin need to be TTY in order to get scrollbox working + const isTTY = !!(process.stdout.isTTY && process.stdin.isTTY); + + render(config.CI ? : , { // CLIs will exit by useScroll hook, CIs by default - exitOnCtrlC: config.CI, + exitOnCtrlC: config.CI || !isTTY, }); }