/** * RunScreen - TUI screen for running feature loop * * Spawns feature-loop.sh and polls status files for progress. * Wrapped in AppShell for consistent layout. * * Supports two modes: * - Foreground: spawns the process and monitors it * - Monitor-only: polls status files without spawning (for /monitor) * * Esc backgrounds the run in foreground mode; in monitor mode, Esc returns to shell. * On completion, shows RunCompletionSummary inline. */ import React from 'react'; import { type PhaseInfo } from '../utils/loop-status.js'; import type { SessionState } from '../../repl/session-state.js'; export type { PhaseInfo } from '../utils/loop-status.js'; /** * Iteration breakdown across different contexts */ export interface IterationBreakdown { /** Total iterations across all runs */ total: number; /** Iterations during implementation phase */ implementation?: number; /** Iterations during resume operations */ resumes?: number; } /** * File change statistics from git diff */ export interface FileChangeStat { /** Relative path from project root */ path: string; /** Lines added */ added: number; /** Lines removed */ removed: number; } /** * Changes summary with git diff stats */ export interface ChangesSummary { /** Total number of files changed */ totalFilesChanged?: number; /** Per-file diff statistics */ files?: FileChangeStat[]; /** Whether git diff information was available */ available: boolean; } /** * A single commit entry with hash and title */ export interface CommitEntry { /** Short commit hash */ hash: string; /** Commit title (first line of message) */ title: string; } /** * Commit information from git */ export interface CommitsSummary { /** Starting commit hash (short) */ fromHash?: string; /** Ending commit hash (short) */ toHash?: string; /** Full list of commits between fromHash and toHash */ commitList?: CommitEntry[]; /** Merge type if applicable */ mergeType?: 'squash' | 'normal' | 'none'; /** Whether git commit information was available */ available: boolean; } /** * Pull request metadata */ export interface PrSummary { /** PR number if created */ number?: number; /** PR URL if created */ url?: string; /** Whether PR information was available to query */ available: boolean; /** Whether a PR was created as part of this loop */ created: boolean; } /** * Issue metadata */ export interface IssueSummary { /** Issue number if linked */ number?: number; /** Issue URL if available */ url?: string; /** Issue status (e.g., 'Closed') */ status?: string; /** Whether issue information was available to query */ available: boolean; /** Whether an issue was linked/closed as part of this loop */ linked: boolean; } export interface RunSummary { feature: string; /** Legacy field: total iterations (deprecated, use iterationBreakdown.total) */ iterations: number; maxIterations: number; tasksDone: number; tasksTotal: number; tokensInput: number; tokensOutput: number; cacheCreate: number; cacheRead: number; exitCode: number; /** True when the exit code was inferred (e.g. monitor mode heuristic) rather than observed directly */ exitCodeInferred?: boolean; branch?: string; logPath?: string; errorTail?: string; /** Loop start timestamp (ISO 8601 or epoch ms) */ startedAt?: string | number; /** Loop end timestamp (ISO 8601 or epoch ms) */ endedAt?: string | number; /** Total duration across all runs/resumes in milliseconds */ totalDurationMs?: number; /** Detailed iteration breakdown */ iterationBreakdown?: IterationBreakdown; /** Task completion counts */ tasks?: { completed: number | null; total: number | null; }; /** Phase execution details */ phases?: PhaseInfo[]; /** Git diff changes summary */ changes?: ChangesSummary; /** Git commit information */ commits?: CommitsSummary; /** Pull request metadata */ pr?: PrSummary; /** Issue metadata */ issue?: IssueSummary; } export interface RunScreenProps { /** Pre-built header element from App */ header: React.ReactNode; featureName: string; projectRoot: string; sessionState: SessionState; /** Monitor-only mode: don't spawn, just poll status */ monitorOnly?: boolean; /** Override review mode from CLI flags (takes precedence over config) */ reviewMode?: 'manual' | 'auto' | 'merge'; /** Override implementation CLI from CLI flags (takes precedence over config) */ cli?: 'claude' | 'codex'; /** Override review CLI from CLI flags (takes precedence over config) */ reviewCli?: 'claude' | 'codex'; onComplete: (summary: RunSummary) => void; /** Called when user presses Esc to background the run */ onBackground?: (featureName: string) => void; onCancel: () => void; } export declare function RunScreen({ header, featureName, projectRoot, sessionState, monitorOnly, reviewMode: reviewModeProp, cli: cliProp, reviewCli: reviewCliProp, onComplete, onBackground, onCancel, }: RunScreenProps): React.ReactElement;