diff --git a/src/cli/cli.ts b/src/cli/cli.ts index 7b9eef675..72cf5c50d 100644 --- a/src/cli/cli.ts +++ b/src/cli/cli.ts @@ -26,6 +26,7 @@ import { LayoutProvider } from './tui/context'; import { COMMAND_DESCRIPTIONS } from './tui/copy'; import { clearExitAction, getExitAction } from './tui/exit-action'; import { clearExitMessage, getExitMessage } from './tui/exit-message'; +import { requireTTY } from './tui/guards'; import { CommandListScreen } from './tui/screens/home'; import { getCommandsForUI } from './tui/utils'; import { type UpdateCheckResult, checkForUpdate, printUpdateNotification } from './update-notifier'; @@ -212,6 +213,7 @@ export const main = async (argv: string[]) => { // Show TUI for no arguments, commander handles --help via configureHelp() if (args.length === 0) { + requireTTY(); renderTUI(updateCheck, isFirstRun); return; } diff --git a/src/cli/commands/add/command.tsx b/src/cli/commands/add/command.tsx index a94d8658e..934908301 100644 --- a/src/cli/commands/add/command.tsx +++ b/src/cli/commands/add/command.tsx @@ -1,5 +1,5 @@ import { COMMAND_DESCRIPTIONS } from '../../tui/copy'; -import { requireProject } from '../../tui/guards'; +import { requireProject, requireTTY } from '../../tui/guards'; import { AddFlow } from '../../tui/screens/add/AddFlow'; import type { Command } from '@commander-js/extra-typings'; import { render } from 'ink'; @@ -21,6 +21,7 @@ export function registerAdd(program: Command): Command { } requireProject(); + requireTTY(); const { clear, unmount } = render( { options.language = options.language ?? 'Python'; await handleCreateCLI(options as CreateOptions); } else { + requireTTY(); handleCreateTUI(); } } catch (error) { diff --git a/src/cli/commands/deploy/command.tsx b/src/cli/commands/deploy/command.tsx index 58fe8b254..5870c7ff8 100644 --- a/src/cli/commands/deploy/command.tsx +++ b/src/cli/commands/deploy/command.tsx @@ -1,6 +1,6 @@ import { getErrorMessage } from '../../errors'; import { COMMAND_DESCRIPTIONS } from '../../tui/copy'; -import { requireProject } from '../../tui/guards'; +import { requireProject, requireTTY } from '../../tui/guards'; import { DeployScreen } from '../../tui/screens/deploy/DeployScreen'; import { handleDeploy } from './actions'; import type { DeployOptions } from './types'; @@ -160,8 +160,10 @@ export const registerDeploy = (program: Command) => { await handleDeployCLI(options as DeployOptions); } else if (cliOptions.diff) { // Diff-only: use TUI with diff mode + requireTTY(); handleDeployTUI({ diffMode: true }); } else { + requireTTY(); handleDeployTUI(); } } catch (error) { diff --git a/src/cli/commands/dev/command.tsx b/src/cli/commands/dev/command.tsx index fadcfc54e..eac485d8c 100644 --- a/src/cli/commands/dev/command.tsx +++ b/src/cli/commands/dev/command.tsx @@ -21,7 +21,7 @@ import { OtelCollector, startOtelCollector } from '../../operations/dev/otel'; import { FatalError } from '../../tui/components'; import { LayoutProvider } from '../../tui/context'; import { COMMAND_DESCRIPTIONS } from '../../tui/copy'; -import { requireProject } from '../../tui/guards'; +import { requireProject, requireTTY } from '../../tui/guards'; import { parseHeaderFlags } from '../shared/header-utils'; import { runBrowserMode } from './browser-mode'; import type { Command } from '@commander-js/extra-typings'; @@ -383,6 +383,7 @@ export const registerDev = (program: Command) => { // If --no-browser provided, launch terminal TUI mode if (!opts.browser) { + requireTTY(); // Enter alternate screen buffer for fullscreen mode process.stdout.write(ENTER_ALT_SCREEN); diff --git a/src/cli/commands/invoke/command.tsx b/src/cli/commands/invoke/command.tsx index 6243d90f2..dc94a4912 100644 --- a/src/cli/commands/invoke/command.tsx +++ b/src/cli/commands/invoke/command.tsx @@ -1,6 +1,6 @@ import { getErrorMessage } from '../../errors'; import { COMMAND_DESCRIPTIONS } from '../../tui/copy'; -import { requireProject } from '../../tui/guards'; +import { requireProject, requireTTY } from '../../tui/guards'; import { InvokeScreen } from '../../tui/screens/invoke'; import { parseHeaderFlags } from '../shared/header-utils'; import { handleInvoke, loadInvokeConfig } from './action'; @@ -168,6 +168,7 @@ export const registerInvoke = (program: Command) => { }); } else { // No CLI options - interactive TUI mode (headers still passed if provided) + requireTTY(); const { waitUntilExit, unmount } = render( { json: cliOptions.json, }); } else { + requireTTY(); const { unmount } = render( { } requireProject(); + requireTTY(); const { clear, unmount } = render(