Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@

All notable changes to MandoCode will be documented in this file.

## [Unreleased]

**Updated terminal rendering with RazorConsole 0.7.0.** The CLI now includes RazorConsole's upstream fix for focus events raised while the interface is being drawn. MandoCode keeps the deferred focus safeguard introduced in v0.16.2, which prevents the repeated prompt borders seen on some launches.

**Highlights**

- Upgrade the terminal UI framework while preserving the startup rendering fix.
- Keep transcript formatting, hyperlinks, and emoji shortcuts compatible with the updated rendering dependencies.
- Clear the clipboard attachment message reliably after sending a prompt.

### Changed

- Upgrade RazorConsole.Core from 0.6.0 to 0.7.0. Retain `DeferredFocus` for startup and panels so focus requests made from `OnAfterRenderAsync` continue to wait until their render batch completes.
- Adapt transcript rendering, saved-agent history, HTML exports, and emoji expansion to the updated Spectre.Console APIs. Hyperlinks now use the separate link API, and styles use the new value type.
- Update Markdig to 1.5.1 and Microsoft.Extensions.FileSystemGlobbing to 10.0.14 to satisfy the new dependency requirements on both supported .NET targets.

### Fixed

- Refresh the prompt after submission so the clipboard attachment message clears reliably.

### Test coverage

- Explicitly enable hyperlink support in Markdown rendering tests so their clickable-link assertions run consistently in local terminals and CI.
- Add a component check that focusing and redrawing the prompt repeatedly leaves one prompt in the render tree and keeps keyboard focus on it.
- All 1,248 tests pass on net10.0 and net8.0. Verify startup, typing, and resizing in a real pseudo-terminal on both builds, with no reported rendering errors. Confirm the CLI tool package builds successfully.

## [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. A screenshot of the failure is in [#138](https://github.com/DevMando/MandoCode/pull/138).
Expand Down
1 change: 1 addition & 0 deletions src/MandoCode/Components/Input/PromptInput.razor
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@
_composer.SetText("");
_clipboardStatus = "";
await OnSubmit.InvokeAsync(value);
StateHasChanged();
}
public void SetValue(string value) { _composer.SetText(value); StateHasChanged(); }
}
6 changes: 3 additions & 3 deletions src/MandoCode/MandoCode.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

<ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.12.4" />
<PackageReference Include="Markdig" Version="1.3.2" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="10.0.11" />
<PackageReference Include="Markdig" Version="1.5.1" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="10.0.14" />
<!-- SK -> Agent Framework migration (feat/agent-framework-migration) is complete —
Microsoft.SemanticKernel is no longer referenced anywhere in the codebase. See memory
agent-framework-migration.md. -->
Expand All @@ -53,7 +53,7 @@
<!-- Held at 2.x on purpose: NAudio 3.x raised its floor to net9.0, which would drop the
net8.0 build entirely. Revisit when net8.0 is dropped (November 2026). -->
<PackageReference Include="NAudio" Version="2.2.1" />
<PackageReference Include="RazorConsole.Core" Version="0.6.0" />
<PackageReference Include="RazorConsole.Core" Version="0.7.0" />
<PackageReference Include="YamlDotNet" Version="18.1.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/MandoCode/Services/Input/PromptEmojiAliases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static bool Expand(TextSelectionState buffer)
"cool" => "😎",
"brain" => "🧠",
"llama" => "🦙",
_ => Emoji.Replace(alias.AsSpan())
_ => Emoji.Replace(alias)
};
if (emoji == alias) return false;
buffer.SetText(text[..start] + emoji + text[cursor..]);
Expand Down
4 changes: 2 additions & 2 deletions src/MandoCode/Services/Rendering/AnsiTranscriptText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static Paragraph Parse(string input)
for (var index = 0; index < input.Length; index++)
{
if (input[index] != '\u001b') continue;
if (index > start) output.Append(input[start..index], new Style(foreground, background, decoration, link));
if (index > start) output.Append(input[start..index], new Style(foreground, background, decoration), link is null ? null : new Link(link));
if (index + 1 < input.Length && input[index + 1] == '[')
{
var end = index + 2;
Expand Down Expand Up @@ -70,7 +70,7 @@ public static Paragraph Parse(string input)
else index = Math.Min(index + 1, input.Length - 1);
start = index + 1;
}
if (start < input.Length) output.Append(input[start..], new Style(foreground, background, decoration, link));
if (start < input.Length) output.Append(input[start..], new Style(foreground, background, decoration), link is null ? null : new Link(link));
return output;
}
}
4 changes: 3 additions & 1 deletion src/MandoCode/Services/Rendering/DeferredFocus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ namespace MandoCode.Services;
/// Keeps focus requests made from OnAfterRender out of the render batch that raised them.
/// </summary>
/// <remarks>
/// FocusManager.FocusAsync dispatches focusin/focusout as soon as the key is a known focus
/// In RazorConsole 0.6, FocusManager.FocusAsync dispatched focusin/focusout as soon as the key was 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.
/// RazorConsole 0.7 also defers reentrant dispatch upstream. Keep this lifecycle safeguard
/// so MandoCode's after-render focus requests explicitly run after their batch completes.
/// </remarks>
public static class DeferredFocus
{
Expand Down
4 changes: 2 additions & 2 deletions src/MandoCode/Services/Rendering/PaneColors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ public IEnumerable<Segment> Render(RenderOptions options, int maxWidth)
yield return segment;
continue;
}
var foreground = segment.Style?.Foreground ?? Color.Default;
var foreground = segment.Style.Foreground;
// Error and warning colors remain noticeable in background transcripts.
if (foreground == Color.Red || foreground == Color.Red1 || foreground == Color.Yellow)
yield return segment;
else
yield return new Segment(segment.Text, new Style(Color.Grey62, Color.Default, segment.Style?.Decoration ?? Decoration.None));
yield return new Segment(segment.Text, new Style(Color.Grey62, Color.Default, segment.Style.Decoration));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/MandoCode/Services/Sessions/AgentArchiveStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public static List<ArchivedBlock> Capture(TuiSession session)
foreach (var entry in entries.Skip(start))
{
var spans = entry.Content.Render(options, 120).Where(s => !s.IsControlCode)
.Select(s => new ArchivedSpan(s.Text, s.Style?.ToMarkup() ?? "")).ToList();
.Select(s => new ArchivedSpan(s.Text, s.Style.ToMarkup())).ToList();
blocks.Add(new(spans, entry.UserPrompt, entry.SpaceAfter)
{
ToolGroup = entry.ToolActivity is not null ? entry.Id : entry.ToolOutput is { } output ? groups.GetValueOrDefault(output) : null,
Expand Down
4 changes: 2 additions & 2 deletions src/MandoCode/Services/Sessions/TranscriptExport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static string BuildHtml(TuiSession session, string agent, string project,
foreach (var span in block.Spans)
{
var css = new StringBuilder();
if (Style.TryParse(span.Style, out var style) && style is not null) {
if (Style.TryParse(span.Style, out var style)) {
if (style.Foreground != Color.Default) css.Append($"color:#{style.Foreground.R:x2}{style.Foreground.G:x2}{style.Foreground.B:x2};");
if (style.Background != Color.Default) css.Append($"background:#{style.Background.R:x2}{style.Background.G:x2}{style.Background.B:x2};");
if (style.Decoration.HasFlag(Decoration.Bold)) css.Append("font-weight:bold;");
Expand Down Expand Up @@ -63,4 +63,4 @@ public static async Task<string> SaveAsync(TuiSession session, string agent, str
}
private static bool IsSaveCommand(string text) => text.Trim().Equals("/transcript-save", StringComparison.OrdinalIgnoreCase) || text.TrimStart().StartsWith("/transcript-save ", StringComparison.OrdinalIgnoreCase);
private static string E(string text) => WebUtility.HtmlEncode(text);
}
}
2 changes: 2 additions & 0 deletions tests/MandoCode.Tests/MarkdownHtmlRendererTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ private static string RenderToString(IRenderable renderable)
ColorSystem = ColorSystemSupport.TrueColor,
Out = new AnsiConsoleOutput(writer),
});
// Exercise hyperlink rendering regardless of the host terminal or CI detection.
console.Profile.Capabilities.Links = true;
console.Write(renderable);
return writer.ToString();
}
Expand Down
63 changes: 63 additions & 0 deletions tests/MandoCode.Tests/PromptStartupRenderingTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System.Reflection;
using MandoCode.Components;
using MandoCode.Services;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Rendering;
using Microsoft.Extensions.DependencyInjection;
using RazorConsole.Core;
using RazorConsole.Core.Focus;
using Xunit;

namespace MandoCode.Tests;

[Trait("Category", "Component")]
public sealed class PromptStartupRenderingTests
{
[Fact]
public async Task FocusAndRefocusKeepOnePromptInTheRenderTree()
{
var registrations = new ServiceCollection().AddLogging();
registrations.AddRazorConsoleServices();
registrations.AddSingleton(new InputStateMachine(new Dictionary<string, string>(), null));
await using var services = registrations.BuildServiceProvider();
PromptInput input = null!;
await using var renderer = await WidgetRendererHarness.MountAsync<Host>(services, new()
{
[nameof(Host.Capture)] = (Action<PromptInput>)(value => input = value)
});
var hook = (string)typeof(PromptInput).GetField("_hook", BindingFlags.Instance | BindingFlags.NonPublic)!.GetValue(input)!;
var focus = services.GetRequiredService<FocusManager>();
// The test renderer has no console host to deliver snapshots to the focus observer.
await renderer.Dispatcher.InvokeAsync(async () =>
{
typeof(FocusManager).GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
.Single(method => method.Name.EndsWith("OnNext")).Invoke(focus, [renderer.Snapshot()]);
await input.FocusPromptAsync();
});
for (var iteration = 0; iteration < 5; iteration++)
{
await renderer.Dispatcher.InvokeAsync(async () =>
{
input.SetValue($"Prompt {iteration}");
await input.FocusPromptAsync();
});
await renderer.Dispatcher.InvokeAsync(() =>
{
var nodes = WidgetRendererHarness.Flatten(WidgetRendererHarness.Root(renderer.Snapshot()));
Assert.Single(nodes, node => node.Attributes.TryGetValue("data-focus-key", out var key) && key == hook);
Assert.True(focus.IsFocused(hook));
});
}
}

public sealed class Host : ComponentBase
{
[Parameter] public Action<PromptInput> Capture { get; set; } = default!;
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
builder.OpenComponent<PromptInput>(0);
builder.AddComponentReferenceCapture(1, value => Capture((PromptInput)value));
builder.CloseComponent();
}
}
}
Loading