diff --git a/README.md b/README.md index b39c9a7..13b3162 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ Named workspaces hold **up to four independent agents each**. Keyboard shortcuts ## A new way to work in the terminal — v0.16.0 -**Patch v0.16.1:** fixes a startup race around prompt activation, keeps prompt state updates on the UI dispatcher, and includes clipboard and component lifecycle improvements. See the [release notes](docs/CHANGELOG.md#0161---2026-10-21). +**Patch v0.16.2:** fixes the startup screen that filled with repeated prompt borders and left the first agent unable to take input. See the [release notes](docs/CHANGELOG.md#0162---2026-11-11). Built on **RazorConsole 0.6.0**, this release brings multiple workspaces, up to four independent agents per workspace, agent collaboration, portable context snapshots, and saved-agent history into one terminal interface. Explore your files, manage MCP servers and Skills, and keep working while other agents handle their tasks. diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 566b026..9a5ebaf 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -2,12 +2,31 @@ All notable changes to MandoCode will be documented in this file. -## [Unreleased] +## [0.16.2] - 2026-11-11 + +**The startup screen no longer fills with repeated prompt borders.** On some launches the first agent drew its prompt as rows of bottom borders and could not take input; the workaround was to open a second agent and close the first. The 0.16.1 startup change did not address this. RazorConsole remains at 0.6.0. + +![The startup screen before this fix: every row below the agent header shows a prompt border](images/startup-repeated-borders-before-0.16.2.png) + +*Before 0.16.2: what the first agent could look like on launch.* + +**Highlights** + +- Fix the corrupted startup prompt that left the first agent unusable. +- Focus requests raised while a component finishes rendering now run after the render batch completes. + +### Fixed + +- Stop the prompt, and any panel that takes focus as it opens, from being inserted into the interface twice. A focus request made from `OnAfterRenderAsync` dispatched its focus events inside the render batch still in progress, and RazorConsole 0.6.0 then applied that batch a second time. Whether this happened depended on thread timing, so it appeared on some launches and not others. These requests now go through `DeferredFocus`, which waits for the batch to finish. Focus changes from key and click handlers are unchanged. RazorConsole 0.7.0 corrects the dispatch itself; this release does not upgrade to it. ### Changed - Group CLI components into feature folders for shell, workspaces, conversations, input, project browsing, sessions, settings, onboarding, and activity. Keep component namespaces and behavior unchanged, and document where new components belong. +### Test coverage + +- The full suite passes on net10.0 and net8.0 (1,247 tests each). No automated regression covers this failure: it was reproduced, and the fix confirmed, by launching the built CLI in a pseudo-terminal with the timing forced. + ## [0.16.1] - 2026-10-21 **Startup and component stability.** The chat prompt now waits for model validation and MCP initialization to finish. Prompt state changes run together on the UI dispatcher, and agents closed during startup cannot start an input loop afterward. RazorConsole remains at 0.6.0. diff --git a/docs/images/startup-repeated-borders-before-0.16.2.png b/docs/images/startup-repeated-borders-before-0.16.2.png new file mode 100644 index 0000000..c67c7c2 Binary files /dev/null and b/docs/images/startup-repeated-borders-before-0.16.2.png differ diff --git a/src/MandoCode/Components/Activity/PlanStepEditor.razor b/src/MandoCode/Components/Activity/PlanStepEditor.razor index a774649..47c8305 100644 --- a/src/MandoCode/Components/Activity/PlanStepEditor.razor +++ b/src/MandoCode/Components/Activity/PlanStepEditor.razor @@ -50,7 +50,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender) { if (Pane is not null) Pane.FocusKey = _hook; - if (firstRender && (Pane is null || Pane.Active)) await Focus.FocusAsync(_hook); + if (firstRender && (Pane is null || Pane.Active)) await Focus.FocusDeferredAsync(_hook); } private void HandleChanged() => StateHasChanged(); diff --git a/src/MandoCode/Components/Conversation/ConversationView.razor b/src/MandoCode/Components/Conversation/ConversationView.razor index 4222505..749076d 100644 --- a/src/MandoCode/Components/Conversation/ConversationView.razor +++ b/src/MandoCode/Components/Conversation/ConversationView.razor @@ -48,7 +48,7 @@ if (Pane is not null && Pane.FocusKey is null) { Pane.FocusKey = _focusKey; - if (Pane.Active) await Focus.FocusAsync(_focusKey); + if (Pane.Active) await Focus.FocusDeferredAsync(_focusKey); } } public void Scroll(string key) diff --git a/src/MandoCode/Components/Input/ApprovalSelect.razor b/src/MandoCode/Components/Input/ApprovalSelect.razor index f7227c8..abbb0d6 100644 --- a/src/MandoCode/Components/Input/ApprovalSelect.razor +++ b/src/MandoCode/Components/Input/ApprovalSelect.razor @@ -78,7 +78,7 @@ if (Pane is not null) Pane.FocusKey = _focusKey; if ((Pane is null || Pane.Active) && (firstRender || _requestFocus || !Focus.IsFocused(_focusKey))) { - await Focus.FocusAsync(_focusKey); + await Focus.FocusDeferredAsync(_focusKey); // A newly mounted selector may not yet be in the framework's focus // snapshot. Keep retrying until its registered target owns focus. _requestFocus = !Focus.IsFocused(_focusKey); diff --git a/src/MandoCode/Components/Input/PromptInput.razor b/src/MandoCode/Components/Input/PromptInput.razor index e4dc31b..4287111 100644 --- a/src/MandoCode/Components/Input/PromptInput.razor +++ b/src/MandoCode/Components/Input/PromptInput.razor @@ -263,7 +263,7 @@ if ((Pane is null || Pane.Active) && (firstRender || _focusPicker)) { _focusPicker = false; - await Focus.FocusAsync(_hook); + await Focus.FocusDeferredAsync(_hook); } } diff --git a/src/MandoCode/Components/Onboarding/OllamaPullPanel.razor b/src/MandoCode/Components/Onboarding/OllamaPullPanel.razor index 0213923..ca73d8f 100644 --- a/src/MandoCode/Components/Onboarding/OllamaPullPanel.razor +++ b/src/MandoCode/Components/Onboarding/OllamaPullPanel.razor @@ -117,7 +117,7 @@ protected override void OnInitialized() { _ = Animate(); _ = Load(); } private Task Load() => Run(async ct => { _newestModels = await Library.Models(ct, newest: true); if (_newestModels.Count == 0) throw new IOException("The library could not be read. Type a model name and press Ctrl+P to pull it."); _status = ""; }); protected override void OnParametersSet() { if (ExplorerFocus is not null) { ExplorerFocus.NavigateTab = Cycle; ExplorerFocus.FocusExplorer = FocusPanel; } } - protected override async Task OnAfterRenderAsync(bool firstRender) { if ((Pane is null || Pane.Active) && !Focus.IsFocused(_searchFocused ? _searchKey : _focusKey)) { if (_searchFocused) await FocusSearch(); else await FocusPanel(); } } + protected override async Task OnAfterRenderAsync(bool firstRender) { if ((Pane is null || Pane.Active) && !Focus.IsFocused(_searchFocused ? _searchKey : _focusKey)) { await DeferredFocus.AfterRenderBatch(); if (_searchFocused) await FocusSearch(); else await FocusPanel(); } } private async Task FocusPanel() { if (Pane is not null && !Pane.Active) return; if (Pane is not null) Pane.FocusKey = _focusKey; ExplorerFocus?.SetPromptFocused(false); await Focus.FocusAsync(_focusKey); } private async Task Cycle(bool reverse) { if (_busy) return; diff --git a/src/MandoCode/Components/Onboarding/SetupWizardPanel.razor b/src/MandoCode/Components/Onboarding/SetupWizardPanel.razor index 31e79b9..bcc32f9 100644 --- a/src/MandoCode/Components/Onboarding/SetupWizardPanel.razor +++ b/src/MandoCode/Components/Onboarding/SetupWizardPanel.razor @@ -131,7 +131,7 @@ else if (_browsing || Pane is not null && !Pane.Active) return; var key = _urlInput ? _urlKey : _key; if (Pane is not null) Pane.FocusKey = key; - if (!Focus.IsFocused(key)) await Focus.FocusAsync(key); + if (!Focus.IsFocused(key)) await Focus.FocusDeferredAsync(key); } private async Task Animate() { try { while (!_stop.IsCancellationRequested) { await Task.Delay(120, _stop.Token); if (_choices.Length == 0 && !_browsing && !_urlInput) { _frame++; if (!_disposed) await InvokeAsync(StateHasChanged); } } } catch (OperationCanceledException) { } } public void Dispose() { _disposed = true; _stop.Cancel(); _operations.Dispose(); if (ExplorerFocus?.NavigateTab == Cycle) ExplorerFocus.NavigateTab = null; } diff --git a/src/MandoCode/Components/Project/AgentFileExplorer.razor b/src/MandoCode/Components/Project/AgentFileExplorer.razor index 39bb33e..f8777c7 100644 --- a/src/MandoCode/Components/Project/AgentFileExplorer.razor +++ b/src/MandoCode/Components/Project/AgentFileExplorer.razor @@ -71,7 +71,7 @@ if (Pane is not null && (firstRender || Focus.IsFocused(_focusKey))) Pane.FocusKey = _focusKey; if ((Pane is null || Pane.Active) && (firstRender || (ExplorerFocus is { Active: true, PromptFocused: false } && !Focus.IsFocused(_focusKey)))) - await FocusExplorerAsync(); + { await DeferredFocus.AfterRenderBatch(); await FocusExplorerAsync(); } } private string Caption(AgentFileTree.Entry? item, int index) { diff --git a/src/MandoCode/Components/Project/AgentGitChanges.razor b/src/MandoCode/Components/Project/AgentGitChanges.razor index fa14a61..e6d13d3 100644 --- a/src/MandoCode/Components/Project/AgentGitChanges.razor +++ b/src/MandoCode/Components/Project/AgentGitChanges.razor @@ -157,7 +157,7 @@ } protected override async Task OnAfterRenderAsync(bool firstRender) { - if ((Pane is null || Pane.Active) && (firstRender || (ExplorerFocus is { Active: true, PromptFocused: false } && !Focus.IsFocused(_focusKey)))) await FocusPanel(); + if ((Pane is null || Pane.Active) && (firstRender || (ExplorerFocus is { Active: true, PromptFocused: false } && !Focus.IsFocused(_focusKey)))) { await DeferredFocus.AfterRenderBatch(); await FocusPanel(); } } private async Task FocusPanel() { diff --git a/src/MandoCode/Components/Project/DirectoryBrowser.razor b/src/MandoCode/Components/Project/DirectoryBrowser.razor index 88c2797..6449bca 100644 --- a/src/MandoCode/Components/Project/DirectoryBrowser.razor +++ b/src/MandoCode/Components/Project/DirectoryBrowser.razor @@ -40,7 +40,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender) { if (Pane is not null) Pane.FocusKey = _focusKey; - if ((Pane is null || Pane.Active) && !Focus.IsFocused(_focusKey)) await Focus.FocusAsync(_focusKey); + if ((Pane is null || Pane.Active) && !Focus.IsFocused(_focusKey)) await Focus.FocusDeferredAsync(_focusKey); } private async Task Navigate(string path) { diff --git a/src/MandoCode/Components/Sessions/AgentHistoryBrowser.razor b/src/MandoCode/Components/Sessions/AgentHistoryBrowser.razor index f9bef88..f38833f 100644 --- a/src/MandoCode/Components/Sessions/AgentHistoryBrowser.razor +++ b/src/MandoCode/Components/Sessions/AgentHistoryBrowser.razor @@ -134,7 +134,7 @@ } protected override async Task OnAfterRenderAsync(bool firstRender) { - if ((Pane is null || Pane.Active) && (firstRender || ExplorerFocus?.PromptFocused == false && !Focus.IsFocused(_focusKey))) await FocusPanel(); + if ((Pane is null || Pane.Active) && (firstRender || ExplorerFocus?.PromptFocused == false && !Focus.IsFocused(_focusKey))) { await DeferredFocus.AfterRenderBatch(); await FocusPanel(); } } private async Task FocusPanel() { diff --git a/src/MandoCode/Components/Sessions/ContextSnapshotsPanel.razor b/src/MandoCode/Components/Sessions/ContextSnapshotsPanel.razor index 2cf32b8..c15a051 100644 --- a/src/MandoCode/Components/Sessions/ContextSnapshotsPanel.razor +++ b/src/MandoCode/Components/Sessions/ContextSnapshotsPanel.razor @@ -233,7 +233,7 @@ } private void StoreChanged() { if (!_disposed) _ = InvokeAsync(() => { ResetBrowser(_selectionId); StateHasChanged(); }); } protected override void OnParametersSet() { if (ExplorerFocus is not null) { ExplorerFocus.NavigateTab = Cycle; ExplorerFocus.FocusExplorer = FocusPanel; } } - protected override async Task OnAfterRenderAsync(bool firstRender) { if ((Pane is null || Pane.Active) && !Focus.IsFocused(_inputFocused ? _inputKey : _focusKey)) { if (_inputFocused) await FocusInput(); else await FocusPanel(); } } + protected override async Task OnAfterRenderAsync(bool firstRender) { if ((Pane is null || Pane.Active) && !Focus.IsFocused(_inputFocused ? _inputKey : _focusKey)) { await DeferredFocus.AfterRenderBatch(); if (_inputFocused) await FocusInput(); else await FocusPanel(); } } private async Task FocusPanel() { _inputFocused = false; if (Pane is not null) Pane.FocusKey = _focusKey; ExplorerFocus?.SetPromptFocused(false); await Focus.FocusAsync(_focusKey); } private async Task FocusInput() { if (_busy || _offer || _confirmDelete || _choosingModel) return; _previewFocused = false; _inputFocused = true; if (Pane is not null) Pane.FocusKey = _inputKey; await Focus.FocusAsync(_inputKey); } private async Task Cycle(bool reverse) { diff --git a/src/MandoCode/Components/Settings/AgentSettingsPanel.razor b/src/MandoCode/Components/Settings/AgentSettingsPanel.razor index 4b03fae..8e5e029 100644 --- a/src/MandoCode/Components/Settings/AgentSettingsPanel.razor +++ b/src/MandoCode/Components/Settings/AgentSettingsPanel.razor @@ -230,9 +230,9 @@ if (Pane is not null && !Pane.Active) return; if (_custom) { - if (_focusCustom && _customInput is not null) { _focusCustom = false; await _customInput.FocusPromptAsync(); } + if (_focusCustom && _customInput is not null) { _focusCustom = false; await DeferredFocus.AfterRenderBatch(); await _customInput.FocusPromptAsync(); } } - else if (!Focus.IsFocused(_focusKey)) await FocusPanel(); + else if (!Focus.IsFocused(_focusKey)) { await DeferredFocus.AfterRenderBatch(); await FocusPanel(); } } private async Task FocusPanel() { diff --git a/src/MandoCode/Components/Settings/IntegrationSettingsPanel.razor b/src/MandoCode/Components/Settings/IntegrationSettingsPanel.razor index bd2ab86..e95e83b 100644 --- a/src/MandoCode/Components/Settings/IntegrationSettingsPanel.razor +++ b/src/MandoCode/Components/Settings/IntegrationSettingsPanel.razor @@ -545,7 +545,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender) { if (_input is null && _tools is null && !_installBrowser && (Pane is null || Pane.Active) && !Focus.IsFocused(FocusTarget)) - await FocusPanel(); + { await DeferredFocus.AfterRenderBatch(); await FocusPanel(); } } private async Task FocusPanel() diff --git a/src/MandoCode/Components/Settings/McpToolsViewer.razor b/src/MandoCode/Components/Settings/McpToolsViewer.razor index c323872..dc3ff1a 100644 --- a/src/MandoCode/Components/Settings/McpToolsViewer.razor +++ b/src/MandoCode/Components/Settings/McpToolsViewer.razor @@ -45,7 +45,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender && (Pane is null || Pane.Active)) { if (Pane is not null) Pane.FocusKey = _focusKey; - await Focus.FocusAsync(_focusKey); + await Focus.FocusDeferredAsync(_focusKey); } } private async Task Key(KeyboardEventArgs key) { diff --git a/src/MandoCode/Components/Workspaces/AgentWorkspaceView.razor b/src/MandoCode/Components/Workspaces/AgentWorkspaceView.razor index 518c88d..041f6a5 100644 --- a/src/MandoCode/Components/Workspaces/AgentWorkspaceView.razor +++ b/src/MandoCode/Components/Workspaces/AgentWorkspaceView.razor @@ -48,7 +48,7 @@ { _lastFocusVersion = Workspace.FocusVersion; _lastFocusKey = key; - await Focus.FocusAsync(key); + await Focus.FocusDeferredAsync(key); } } public void Dispose() { Workspace.Changed -= Changed; Viewport.OnResized -= Changed; } diff --git a/src/MandoCode/Components/Workspaces/WorkspacePicker.razor b/src/MandoCode/Components/Workspaces/WorkspacePicker.razor index 9eba11d..7ae0a50 100644 --- a/src/MandoCode/Components/Workspaces/WorkspacePicker.razor +++ b/src/MandoCode/Components/Workspaces/WorkspacePicker.razor @@ -37,7 +37,7 @@ } protected override async Task OnAfterRenderAsync(bool firstRender) { - if (firstRender) await Focus.FocusAsync(_hook); + if (firstRender) await Focus.FocusDeferredAsync(_hook); } protected override void OnParametersSet() { diff --git a/src/MandoCode/MandoCode.csproj b/src/MandoCode/MandoCode.csproj index 050948a..72d1bcf 100644 --- a/src/MandoCode/MandoCode.csproj +++ b/src/MandoCode/MandoCode.csproj @@ -13,14 +13,14 @@ MandoCode - 0.16.1 + 0.16.2 Armando Fernandez (DevMando) An AI coding assistant built for the developer workflow: independent agents, workspaces, portable context, and local or cloud models through Ollama. https://github.com/DevMando/MandoCode https://github.com/DevMando/MandoCode MIT ai;cli;coding-assistant;ollama;agent-framework;razorconsole;multi-agent;local-llm;dotnet10;dotnet8 - v0.16.1 fixes a startup race that could activate the chat prompt before model and MCP initialization finished, keeps prompt updates on the UI dispatcher, and prevents closed agents from starting input. Includes clipboard fixes, component lifecycle refactoring, and stronger regression testing. Full release notes: https://github.com/DevMando/MandoCode/blob/v0.16.1/docs/CHANGELOG.md + v0.16.2 fixes the startup screen that filled with repeated prompt borders and left the first agent unable to take input. Focus requests made while a component finishes rendering now wait for the render in progress to complete. Full release notes: https://github.com/DevMando/MandoCode/blob/v0.16.2/docs/CHANGELOG.md README.md MC.png MC.ico diff --git a/src/MandoCode/Services/Rendering/DeferredFocus.cs b/src/MandoCode/Services/Rendering/DeferredFocus.cs new file mode 100644 index 0000000..b8402de --- /dev/null +++ b/src/MandoCode/Services/Rendering/DeferredFocus.cs @@ -0,0 +1,30 @@ +using System.Runtime.CompilerServices; +using RazorConsole.Core.Focus; + +namespace MandoCode.Services; + +/// +/// Keeps focus requests made from OnAfterRender out of the render batch that raised them. +/// +/// +/// FocusManager.FocusAsync dispatches focusin/focusout as soon as the key is a known focus +/// target. OnAfterRender runs while the renderer is still inside its batch, so that dispatch +/// starts the event's own render pass before the batch has been cleared. The renderer then hands +/// the same edits to the display a second time and every component the batch created is inserted +/// twice. At startup that batch is the one that creates the prompt, which then drew as rows of +/// bottom borders and could not take input. Whether the key was already a known target depended +/// on a thread-pool observer, which made the failure intermittent. +/// Event handlers are not affected: they run outside a batch and may call FocusAsync directly. +/// +public static class DeferredFocus +{ + /// Resumes on the renderer's dispatcher once the batch in progress has finished. + public static YieldAwaitable AfterRenderBatch() => Task.Yield(); + + /// Requests focus after the batch in progress has finished. Use from OnAfterRender. + public static async Task FocusDeferredAsync(this FocusManager focus, string key, CancellationToken token = default) + { + await AfterRenderBatch(); + return await focus.FocusAsync(key, token); + } +}