From a7e912cac79ccee1088d15bf787ff5c31e2c3502 Mon Sep 17 00:00:00 2001 From: Shahovalov MIkhail Date: Tue, 14 Apr 2026 00:02:45 +0300 Subject: [PATCH] =?UTF-8?q?TUI:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20endpoint=20=D0=B2=20dashboard=20=D0=B8=20=D0=B2?= =?UTF-8?q?=D1=8B=D1=85=D0=BE=D0=B4=20=D0=BF=D0=BE=20Q?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LazyBear.MCP/TUI/Components/App.razor | 11 ++++ LazyBear.MCP/TUI/Components/OverviewTab.razor | 3 + LazyBear.MCP/TUI/Components/_Imports.razor | 1 + LazyBear.MCP/TUI/Localization/TuiResources.cs | 55 ++++++++++--------- 4 files changed, 44 insertions(+), 26 deletions(-) diff --git a/LazyBear.MCP/TUI/Components/App.razor b/LazyBear.MCP/TUI/Components/App.razor index f961e9b..44ed906 100644 --- a/LazyBear.MCP/TUI/Components/App.razor +++ b/LazyBear.MCP/TUI/Components/App.razor @@ -4,6 +4,7 @@ @inject InMemoryLogSink LogSink @inject GlobalKeyboardService KeyboardService @inject LocalizationService Localization +@inject IHostApplicationLifetime AppLifetime @implements IDisposable @@ -38,6 +39,7 @@ SelectedIndex="@_overviewSelection" SelectedIndexChanged="@OnOverviewSelectionChanged" ViewportRows="@GetOverviewViewportRows()" + Endpoint="@_mcpEndpoint" Loc="@Localization.Current" /> } else if (_activeTab == Tab.Logs) @@ -81,6 +83,9 @@ private int _settingsSelection; private bool _logsStickToBottom = true; + private static readonly string _mcpEndpoint = + Environment.GetEnvironmentVariable("ASPNETCORE_URLS") ?? "http://localhost:5000"; + private static int GetPanelHeight() => Math.Max(Console.WindowHeight - 2, 10); private static int GetOverviewViewportRows() => Math.Max(Console.WindowHeight - 11, 3); private static int GetLogsViewportRows() => Math.Max(Console.WindowHeight - 16, 5); @@ -152,6 +157,12 @@ return; // StateHasChanged вызовет OnLocaleChanged } + if (args.Key is "q" or "Q") + { + AppLifetime.StopApplication(); + return; + } + switch (_activeTab) { case Tab.Overview: diff --git a/LazyBear.MCP/TUI/Components/OverviewTab.razor b/LazyBear.MCP/TUI/Components/OverviewTab.razor index fd29163..3fd9f21 100644 --- a/LazyBear.MCP/TUI/Components/OverviewTab.razor +++ b/LazyBear.MCP/TUI/Components/OverviewTab.razor @@ -2,6 +2,8 @@ + + @if (Rows.Count == 0) { @@ -30,6 +32,7 @@ [Parameter] public int SelectedIndex { get; set; } [Parameter] public EventCallback SelectedIndexChanged { get; set; } [Parameter] public int ViewportRows { get; set; } = 3; + [Parameter] public string Endpoint { get; set; } = ""; [Parameter] public TuiResources Loc { get; set; } = TuiResources.En; private int[] GetOptions() => Enumerable.Range(0, Rows.Count).ToArray(); diff --git a/LazyBear.MCP/TUI/Components/_Imports.razor b/LazyBear.MCP/TUI/Components/_Imports.razor index 2efc1c9..abbcbf5 100644 --- a/LazyBear.MCP/TUI/Components/_Imports.razor +++ b/LazyBear.MCP/TUI/Components/_Imports.razor @@ -1,5 +1,6 @@ @using Microsoft.AspNetCore.Components @using Microsoft.AspNetCore.Components.Web +@using Microsoft.Extensions.Hosting @using RazorConsole.Components @using RazorConsole.Core @using RazorConsole.Core.Rendering diff --git a/LazyBear.MCP/TUI/Localization/TuiResources.cs b/LazyBear.MCP/TUI/Localization/TuiResources.cs index fd2bbd8..138d408 100644 --- a/LazyBear.MCP/TUI/Localization/TuiResources.cs +++ b/LazyBear.MCP/TUI/Localization/TuiResources.cs @@ -12,14 +12,15 @@ public sealed record TuiResources public string TabLogs { get; init; } = ""; public string TabSettings { get; init; } = ""; - // ── Overview ───────────────────────────────────────────────────────────── - public string OverviewTitle { get; init; } = ""; - public string OverviewHint { get; init; } = ""; - public string OverviewEmpty { get; init; } = ""; - public string StateOn { get; init; } = ""; - public string StateOff { get; init; } = ""; - public string FooterModule { get; init; } = ""; - public string FooterTools { get; init; } = ""; + // ── Dashboard ──────────────────────────────────────────────────────────── + public string OverviewTitle { get; init; } = ""; + public string OverviewHint { get; init; } = ""; + public string OverviewEmpty { get; init; } = ""; + public string DashboardEndpointLabel { get; init; } = ""; + public string StateOn { get; init; } = ""; + public string StateOff { get; init; } = ""; + public string FooterModule { get; init; } = ""; + public string FooterTools { get; init; } = ""; // ── Logs ───────────────────────────────────────────────────────────────── public string LogsTitle { get; init; } = ""; @@ -43,18 +44,19 @@ public sealed record TuiResources public static readonly TuiResources En = new() { - HintBar = "Tab: tabs | Arrows: navigate | Space: toggle | Enter: open | L: language", - TabOverview = "Overview", + HintBar = "Tab: tabs | Arrows: navigate | Space: toggle | Enter: open | L: language | Q: quit", + TabOverview = "Dashboard", TabLogs = "Logs", TabSettings = "Settings", - OverviewTitle = "Module Overview", - OverviewHint = "Up/Down: select module. Enter: open settings.", - OverviewEmpty = "No modules registered.", - StateOn = "ON", - StateOff = "OFF", - FooterModule = "Module", - FooterTools = "Tools", + OverviewTitle = "Dashboard", + OverviewHint = "Up/Down: select module. Enter: open settings.", + OverviewEmpty = "No modules registered.", + DashboardEndpointLabel = "MCP Endpoint", + StateOn = "ON", + StateOff = "OFF", + FooterModule = "Module", + FooterTools = "Tools", LogsTitle = "Runtime Logs", LogsHint = "Left/Right: filter | Up/Down: scroll | PageUp/Down: page", @@ -75,18 +77,19 @@ public sealed record TuiResources public static readonly TuiResources Ru = new() { - HintBar = "Tab: вкладки | Стрелки: навигация | Space: вкл/выкл | Enter: открыть | L: язык", - TabOverview = "Обзор", + HintBar = "Tab: вкладки | Стрелки: навигация | Space: вкл/выкл | Enter: открыть | L: язык | Q: выход", + TabOverview = "Dashboard", TabLogs = "Логи", TabSettings = "Настройки", - OverviewTitle = "Модули", - OverviewHint = "Вверх/вниз: выбор модуля. Enter: открыть настройки.", - OverviewEmpty = "Нет зарегистрированных модулей.", - StateOn = "ВКЛ", - StateOff = "ВЫКЛ", - FooterModule = "Модуль", - FooterTools = "Инструменты", + OverviewTitle = "Dashboard", + OverviewHint = "Вверх/вниз: выбор модуля. Enter: открыть настройки.", + OverviewEmpty = "Нет зарегистрированных модулей.", + DashboardEndpointLabel = "MCP Endpoint", + StateOn = "ВКЛ", + StateOff = "ВЫКЛ", + FooterModule = "Модуль", + FooterTools = "Инструменты", LogsTitle = "Логи", LogsHint = "Лево/право: фильтр | Вверх/вниз: прокрутка | PageUp/Down: страница",