// Copyright (c) Microsoft. All rights reserved.
using Harness.ConsoleReactiveFramework;
using Microsoft.Extensions.AI;
namespace Harness.Shared.Console;
///
/// Determines which component is shown in the bottom panel.
///
public enum BottomPanelMode
{
/// Show the text input component for user input.
TextInput,
/// Show the list selection component for interactive prompts.
ListSelection,
/// Show a disabled input indicator during agent streaming.
Streaming,
}
///
/// Internal state for . All UI fields that may
/// change after construction live here; they are mutated exclusively via
/// by the
/// owning .
///
public record HarnessAppComponentState : ConsoleReactiveState
{
// --- Console dimensions ---
/// Gets the current console width in columns.
public int ConsoleWidth { get; init; }
/// Gets the current console height in rows.
public int ConsoleHeight { get; init; }
// --- Bottom panel mode ---
/// Gets the bottom panel mode.
public BottomPanelMode Mode { get; init; } = BottomPanelMode.TextInput;
///
/// Gets the queue of follow-up questions waiting for user answers. The head
/// ([0]) is the question currently being displayed; subsequent items
/// are dispatched in order as each is answered. While this queue is non-empty,
/// the next user submission is treated as the answer to the head question
/// instead of going to the agent runner's normal input handler.
///
public IReadOnlyList PendingQuestions { get; init; } = [];
///
/// Gets the accumulated follow-up response messages collected during the
/// current agent turn — both direct s emitted
/// by observers and continuation results from answered questions. Consumed
/// by the runner via
/// before the next agent invocation.
///
public IReadOnlyList AccumulatedFollowUpResponses { get; init; } = [];
// --- Text input (active in TextInput / Streaming modes) ---
/// Gets the prompt string for text input mode.
public string Prompt { get; init; } = "> ";
/// Gets the placeholder text shown when the input is empty.
public string Placeholder { get; init; } = "";
/// Gets the current input text being typed.
public string InputText { get; init; } = "";
/// Gets a value indicating whether input is enabled during streaming.
public bool InputEnabled { get; init; }
/// Gets the prompt to show during streaming when input is disabled.
public string StreamingPrompt { get; init; } = "(agent is running...)";
// --- List selection (active in ListSelection mode) ---
/// Gets the title text displayed above the list selection (for interactive prompts).
public string? ListSelectionTitle { get; init; }
/// Gets the list selection options.
public IReadOnlyList ListSelectionOptions { get; init; } = [];
/// Gets the highlighted option index in list selection mode.
public int ListSelectionIndex { get; init; }
/// Gets the placeholder text for the custom text input option in the list.
public string? ListSelectionCustomTextPlaceholder { get; init; }
/// Gets the current text being typed into the list's custom text option.
public string ListSelectionCustomInputText { get; init; } = "";
/// Gets the highlight color for the active list item.
public ConsoleColor ListHighlightColor { get; init; } = ConsoleColor.Cyan;
// --- Scroll / output area ---
/// Gets the items rendered in the scroll-area. Each item is a pre-rendered
/// console string (may include ANSI escape sequences and newlines).
public IReadOnlyList ScrollAreaContentItems { get; init; } = [];
/// Gets the queued input items to display above the rule. Each item is a
/// pre-rendered console string (may include ANSI escape sequences and newlines).
public IReadOnlyList QueuedItems { get; init; } = [];
// --- Agent mode + status display ---
/// Gets the foreground color for the rule borders and mode label.
public ConsoleColor? ModeColor { get; init; }
/// Gets the current mode name displayed below the bottom rule (e.g. "plan").
public string? ModeText { get; init; }
/// Gets the help text displayed below the bottom rule (available commands).
public string? HelpText { get; init; }
/// Gets a value indicating whether the agent status spinner is visible.
public bool ShowSpinner { get; init; }
/// Gets the formatted token usage text to display in the status bar.
public string? UsageText { get; init; }
}