Skip to content

Add sequential fallback wizard for non-TTY and unsupported Ink terminals #1603

Closed

Description

@propr-dev

Context

The setup command must fall back to a simple sequential wizard when Ink TUI is unsupported. This matters for terminals without raw mode, SSH environments, CI-like shells, and users who pass --no-tui.

Requirements

  • Implement prompt callbacks using readline/promises.
  • Reuse the same setup engine as the Ink path.
  • Print step updates and choices clearly.
  • Avoid prompting when stdin is not interactive; fail with actionable guidance instead.

Implementation Specification

Create packages/cli/src/commands/setup/sequential.ts.

Acceptance Criteria

  • propr setup --no-tui runs the sequential wizard in an interactive terminal.
  • Non-interactive stdin fails early with a clear message.
  • Choices, confirmations, and inputs work without Ink.

Created by ProPR AI Planner

Activity

  1. propr-dev commented on Jun 22, 2026

    @propr-dev
    ContributorAuthor

    Suggested Implementation:

    Implementation Approach

    The fallback uses the same engine with a readline prompt adapter. This avoids having two setup implementations and makes behavior consistent across renderers. A non-interactive auto mode was considered, but setup includes authentication and security choices that should not be guessed silently. The fallback therefore requires a TTY unless a future explicit --yes automation mode is designed.

    File: packages/cli/src/commands/setup/sequential.ts (new file)

    Why this file: This file provides the non-Ink user experience. It connects the setup engine to simple line-based prompts while preserving the same step sequencing and mutation behavior.

    import { createInterface } from 'node:readline/promises';
    import type { Interface as ReadlineInterface } from 'node:readline/promises';
    import { stdin as input, stdout as output } from 'node:process';
    import { runSetupEngine, type SetupPrompts } from './engine.js';
    import { createInitialSetupState } from './state.js';
    import type { SetupDecision, SetupRunOptions, SetupWizardState } from './types.js';
    
    function requireInteractive(): void {
      if (!process.stdin.isTTY || !process.stdout.isTTY) {
        // Setup writes credentials and deployment choices, so failing early is safer
        // than silently choosing defaults in a pipe or CI job.
        throw new Error('propr setup requires an interactive terminal. Re-run in a TTY or use existing non-interactive commands such as propr init stack and propr start.');
      }
    }
    
    function makePrompts(rl: ReadlineInterface): SetupPrompts {
      return {
        async confirm(message: string, defaultValue = false): Promise<boolean> {
          const suffix = defaultValue ? '[Y/n]' : '[y/N]';
          const answer = (await rl.question(`${message} ${suffix} `)).trim().toLowerCase();
          if (!answer) return defaultValue;
          return answer === 'y' || answer === 'yes';
        },
        async input(message: string, defaultValue = ''): Promise<string> {
          const suffix = defaultValue ? ` (${defaultValue})` : '';
          const answer = await rl.question(`${message}${suffix}: `);
          return answer.trim() === '' ? defaultValue : answer.trim();
        },
        async choose<T extends string>(message: string, choices: Array<SetupDecision<T>>, defaultValue: T): Promise<T> {
          console.log('');
          console.log(message);
          choices.forEach((choice, index) => {
            const defaultMarker = choice.value === defaultValue ? ' default' : '';
            console.log(`  ${index + 1}. ${choice.label}${defaultMarker}`);
            console.log(`     ${choice.detail}`);
          });
          const answer = (await rl.question('Choose a number: ')).trim();
          if (!answer) return defaultValue;
          const index = Number(answer) - 1;
          if (!Number.isInteger(index) || index < 0 || index >= choices.length) {
            console.log('Invalid choice. Try again.');
            return this.choose(message, choices, defaultValue);
          }
          return choices[index]!.value;
        },
        async multiChoose<T extends string>(message: string, choices: Array<SetupDecision<T>>, defaults: T[]): Promise<T[]> {
          console.log('');
          console.log(message);
          choices.forEach((choice, index) => {
            const defaultMarker = defaults.includes(choice.value) ? ' default' : '';
            console.log(`  ${index + 1}. ${choice.label}${defaultMarker}`);
            console.log(`     ${choice.detail}`);
          });
          const answer = (await rl.question('Choose comma-separated numbers, or leave blank for none: ')).trim();
          if (!answer) return defaults;
          const selected = answer.split(',').map((part) => Number(part.trim()) - 1);
          if (selected.some((index) => !Number.isInteger(index) || index < 0 || index >= choices.length)) {
            console.log('Invalid selection. Try again.');
            return this.multiChoose(message, choices, defaults);
          }
          // Use Set to remove duplicate numbers so downstream image pulls are not
          // repeated when a user types the same choice twice.
          return [...new Set(selected.map((index) => choices[index]!.value))];
        },
      };
    }
    
    export async function runSequentialSetup(rootDir: string, options: SetupRunOptions): Promise<SetupWizardState> {
      requireInteractive();
      const rl = createInterface({ input, output });
      try {
        const state = createInitialSetupState(rootDir, true);
        return await runSetupEngine(state, options, makePrompts(rl), {
          onState: (next) => {
            const current = next.steps.find((step) => step.id === next.currentStep);
            if (current) console.log(`${current.title}: ${current.status}${current.detail ? ` - ${current.detail}` : ''}`);
          },
          onMessage: (message) => console.log(message),
        });
      } finally {
        rl.close();
      }
    }
  2. propr-dev commented on Jun 22, 2026

    @propr-dev
    ContributorAuthor

    🤖 AI processing has started for this issue using claude agent with claude-opus-4-8 model.

    I'll analyze the problem and work on a solution. This may take a few minutes.

    Processing Details:

    • Agent: claude
    • Model: claude-opus-4-8
    • Branch: 1603/claude-opus-4-8-add-sequential-fallback-w-20260622-1022-nt3
    • Base Branch: 1599-epic-build-comprehensive-b5c
    • Worktree: issue-1603-20260622-1022-claude-opus-4-8-nt3

    🔍 Track Task Execution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions