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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ submodule.
## [Unreleased]

### Added
- **Attach images to Desktop prompts.** Paste a screenshot or copied image file, use Attach image, or drop image files into the chat. Select multiple files, preview the batch, and remove images individually before sending. Supports up to four PNG, JPEG, GIF, or WebP images per message, each limited to 4 MiB and 16 million pixels. Check vision support again at send time, retain refused drafts, and queue image bytes only after this agent claims the user turn. Image-only messages receive an explicit description prompt.
- **Organize agents into workspaces.** A new upper tab row groups agents into named workspaces. Each workspace remembers its selected agent and split layout; switching workspaces keeps background agents running. Existing tabs move into **Main**, and all workspaces reopen on the next launch. Working and approval badges help you find agents that need attention, including in other workspaces.
- **Close workspaces directly from their tabs.** The **×** appears on the selected workspace and when another workspace is hovered or focused, without shifting tab labels. Right-click still offers Rename and Close. Both closing actions keep at least one workspace open, block closure while agents or commands are running or approvals are waiting, and save conversations to History before closing.
- **More ways for agents to collaborate.** Agents can ask for an immediate answer or a background reply, send information, request a read-only review, hand off work, and update or cancel individual jobs. Messages and results appear in expandable transcript entries that identify the agents involved. Background jobs use readable IDs such as `job1`, support bounded waits, and cancel when an associated agent closes. The existing `ask_agent` tool remains available alongside `ask_agent_and_wait`.
Expand All @@ -22,6 +23,7 @@ submodule.
- **Plan mode starts only through /plan.** Ordinary requests run directly, including multi-step tasks and prose outlines. Desktop no longer automatically proposes structured plans based on task complexity or model tool calls. Existing plan review, editing, execution, and recovery remain available. Settings now explain the explicit command instead of offering automatic planning.

### Fixed
- **Explain decision-model chat rejections.** When Ollama reports that a model requires its decision endpoint, show guidance to select a compatible chat model instead of suggesting a restart or download. Mark the selected model unavailable for chat until it is changed or revalidated, and keep provider errors out of successful assistant replies.
- **Stop peer turns from their receiving tab.** Link incoming peer turns to the target agent's normal cancellation action while keeping each background job's cancellation separate. Inbox messages are consumed on peer turns as well as user turns.
- **Resolve Desktop snapshot types explicitly.** Avoid ambiguous references when both the updated engine and Desktop expose snapshot helpers.
- **Clear guidance when Ollama retires a model.** HTTP 410 Gone errors, including wrapped provider errors, identify the unavailable model and recommend choosing another with `/model` instead of restarting Ollama or pulling a retired cloud model. The shared engine does not retry these failures.
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ Two problems, one app:

## Features

- **Image attachments for vision models** — paste a screenshot or copied image file, click **Attach image**, or drop image files into chat. Select multiple files or paste screenshots one at a time. Preview and remove individual images before sending. Supports up to four PNG, JPEG, GIF, or WebP images per message, each up to 4 MiB and 16 million pixels. The selected model must have confirmed vision support. Images are supplied for the submitted turn; attach again when another turn needs the original pixels.

- **Workspace tabs** — group agents into named workspaces in the upper tab row. Each workspace remembers its selected agent and split layout; switching keeps background agents running. Use **+ Workspace** to create one. Close with the **×** on the selected tab, or hover/focus another workspace to reveal its close button. Right-click also offers Rename and Close. **Split** and **New agent** apply to the selected workspace. Workspaces restore on launch, and existing installations migrate their tabs into **Main**. Alt+Shift+N creates a workspace, Alt+Shift+Left/Right switches, and Alt+Shift+W closes an idle workspace.

- **Agent tabs, and Split view for up to four at once** — each tab is its own independent
Expand Down
2 changes: 2 additions & 0 deletions src/MandoCode.Desktop.Tests/MandoCode.Desktop.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
Windows App SDK into the test host). If these files ever grow UI dependencies, that's
a design regression this project exists to catch. -->
<ItemGroup>
<Compile Include="..\MandoCode.Desktop\Services\Input\PromptImageAttachment.cs" Link="src\PromptImageAttachment.cs" />
<Compile Include="..\MandoCode.Desktop\Services\Input\PromptMentionPicker.cs" Link="src\PromptMentionPicker.cs" />
<Compile Include="..\MandoCode.Desktop\Services\Input\CommandSuggestion.cs" Link="src\CommandSuggestion.cs" />
<Compile Include="..\MandoCode.Desktop\Services\Input\PromptFileLookup.cs" Link="src\PromptFileLookup.cs" />
Expand Down Expand Up @@ -112,6 +113,7 @@
<!-- The streamed-response loop and the small WinUI-free collaborators it needs, so it can be
driven by a fake IAiService. TranscriptWriter/BusyStateService are pure event emitters;
ITranscriptHtml keeps the WinUI-coupled TranscriptHtmlBuilder out of the test host. -->
<Compile Include="..\MandoCode.Desktop\Services\Ai\OllamaChatCompatibility.cs" Link="src\OllamaChatCompatibility.cs" />
<Compile Include="..\MandoCode.Desktop\Services\Ai\IAiService.cs" Link="src\IAiService.cs" />
<Compile Include="..\MandoCode.Desktop\Services\Rendering\ITranscriptHtml.cs" Link="src\ITranscriptHtml.cs" />
<Compile Include="..\MandoCode.Desktop\Services\Rendering\PlanCardHtml.cs" Link="src\PlanCardHtml.cs" />
Expand Down
115 changes: 115 additions & 0 deletions src/MandoCode.Desktop.Tests/PromptImageAttachmentTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
using MandoCode.Desktop.Services;
using MandoCode.Models;
using Xunit;

namespace MandoCode.Desktop.Tests;

public class PromptImageAttachmentTests
{
[Theory]
[InlineData("89504E470D0A1A0A", "image/png")]
[InlineData("FFD8FF", "image/jpeg")]
[InlineData("474946383961", "image/gif")]
[InlineData("474946383761", "image/gif")]
[InlineData("524946460000000057454250", "image/webp")]
public void UsesFileSignatureRatherThanExtension(string hex, string expected)
{
var image = PromptImageAttachment.Create("misleading.txt", Convert.FromHexString(hex));
Assert.Equal(expected, image.MediaType);
}

[Fact]
public void CopiesDraftBytesSoClipboardBuffersCannotChangeQueuedEvidence()
{
var bytes = Convert.FromHexString("89504E470D0A1A0A");
var image = PromptImageAttachment.Create("screen.png", bytes);
bytes[0] = 0;
Assert.Equal(137, image.Bytes.Span[0]);
}

[Theory]
[InlineData("")]
[InlineData("3C7376673E")]
[InlineData("424D00000000")]
public void RejectsEmptyAndUnsupportedBinary(string hex) =>
Assert.Throws<InvalidDataException>(() => PromptImageAttachment.Create("image.png", Convert.FromHexString(hex)));

[Fact]
public void EnforcesEngineByteLimit()
{
Assert.Throws<InvalidDataException>(() => PromptImageAttachment.Create("large.png", new byte[PromptImageAttachment.MaxBytes + 1]));
}

[Theory]
[InlineData(ModelVisionSupport.Unknown)]
[InlineData(ModelVisionSupport.Unsupported)]
public void RechecksVisionWhenSubmittingAfterAModelSwitch(ModelVisionSupport vision)
{
Assert.NotNull(PromptImageAttachment.SubmissionError("Explain this", vision, true, false));
Assert.Null(PromptImageAttachment.SubmissionError("Explain this", ModelVisionSupport.Supported, true, false));
}

[Theory]
[InlineData(" /model")]
[InlineData("/clear")]
[InlineData(" !echo hello")]
public void ImagesCannotBeQueuedByCommands(string prompt) =>
Assert.NotNull(PromptImageAttachment.SubmissionError(prompt, ModelVisionSupport.Supported, true, false));

[Theory]
[InlineData(false, false)]
[InlineData(true, true)]
public void RefusesUnavailableConnectionOrModel(bool connected, bool error) =>
Assert.NotNull(PromptImageAttachment.SubmissionError("Look", ModelVisionSupport.Supported, connected, error));

[Fact]
public void ImageOnlySubmissionHasAnExplicitPrompt()
{
Assert.Equal("Describe the attached image.", PromptImageAttachment.MessageText(" "));
Assert.Equal("Compare the colors", PromptImageAttachment.MessageText("Compare the colors"));
}
[Theory]
[InlineData(1)]
[InlineData(4)]
public void AcceptsSupportedBatchSizes(int count) =>
Assert.Null(PromptImageAttachment.SubmissionError("Compare these", ModelVisionSupport.Supported, true, false, count));

[Theory]
[InlineData(0)]
[InlineData(5)]
public void RefusesInvalidBatchBeforeQueueing(int count) =>
Assert.NotNull(PromptImageAttachment.SubmissionError("Compare these", ModelVisionSupport.Supported, true, false, count));

[Fact]
public void MultipleImageOnlyMessageDescribesTheWholeBatch() =>
Assert.Equal("Describe the attached images.", PromptImageAttachment.MessageText("", 4));

[Fact]
public async Task FourCaptionedImagesFitTheSharedEngineQueue()
{
var config = new MandoCodeConfig();
var root = new MandoCode.Services.ProjectRootAccessor(Path.GetTempPath());
var ai = new MandoCode.Services.AIService(root, config,
new MandoCode.Services.TokenTrackingService(), new MandoCode.Services.PlanHandoff(),
new MandoCode.Services.SkillLoader(config, root), new MandoCode.Services.McpClientManager(config),
new MandoCode.Services.McpApprovalGate(config), new MandoCode.Services.SpinnerService());
using var http = new HttpClient(new VisionHandler());
// Use the engine's existing HTTP test seam without a live Ollama daemon.
var validate = typeof(MandoCode.Services.AIService).GetMethod("ValidateModelAsync",
System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic,
binder: null, types: new[] { typeof(HttpClient) }, modifiers: null)!;
await (Task)validate.Invoke(ai, new object[] { http })!;
var image = PromptImageAttachment.Create("image.png", Convert.FromHexString("89504E470D0A1A0A"));
for (var index = 0; index < PromptImageAttachment.MaxImages; index++)
Assert.True(ai.TryAttachImage(image.Bytes, image.MediaType, $"Image {index + 1}", out var error), error);
Assert.False(ai.TryAttachImage(image.Bytes, image.MediaType, "Extra", out _));
}

private sealed class VisionHandler : HttpMessageHandler
{
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) =>
Task.FromResult(new HttpResponseMessage(System.Net.HttpStatusCode.OK)
{ Content = new StringContent("{\"capabilities\":[\"vision\"]}") });
}

}
39 changes: 39 additions & 0 deletions src/MandoCode.Desktop.Tests/ResponseStreamerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,4 +339,43 @@ public async Task RetiredModelError_ShowsModelSwitchGuidance()
Assert.Contains(blocks, b => b.StartsWith("ERR:") && b.Contains("no longer available on Ollama") && b.Contains("/model"));
Assert.DoesNotContain(blocks, b => b.Contains("ollama serve") || b.Contains("ollama pull"));
}
[Fact]
public async Task DecisionModelException_IsCaughtWithModelSelectionGuidance()
{
var error = new InvalidOperationException("Provider failed",
new Exception("clef is a decision model and only supports /v1/systemone (ref: test)"));
var (streamer, blocks) = Make(new FakeAiService(Array.Empty<string>(), error));
string? rejected = null;
streamer.OnModelRejected = message => rejected = message;
Assert.Equal("", await streamer.StreamAsync("look", CancellationToken.None));
Assert.NotNull(rejected);
Assert.Contains(blocks, b => b.StartsWith("ERR:") && b.Contains("decision model") && b.Contains("/model"));
Assert.DoesNotContain(blocks, b => b.Contains("ollama serve") || b.Contains("ollama pull"));
}

[Fact]
public async Task EngineFormattedDecisionError_IsNotAnAssistantReply()
{
var (streamer, blocks) = Make(new FakeAiService(new[] {
"Error communicating with AI: clef is a decision model and only supports /v1/systemone\nRun: ollama pull clef" }));
var logged = new List<string>();
streamer.ConversationLogger = (_, text) => logged.Add(text);
var rejected = false;
streamer.OnModelRejected = _ => rejected = true;
Assert.Equal("", await streamer.StreamAsync("look", CancellationToken.None));
Assert.True(rejected);
Assert.Empty(logged);
Assert.DoesNotContain(blocks, b => b.StartsWith("CARD:"));
Assert.Contains(blocks, b => b.StartsWith("ERR:") && b.Contains("/model"));
}

[Fact]
public async Task DiscussionOfDecisionModels_RemainsANormalReply()
{
const string reply = "Clef is a decision model and only supports /v1/systemone.";
var (streamer, blocks) = Make(new FakeAiService(new[] { reply }));
Assert.Equal(reply, await streamer.StreamAsync("explain", CancellationToken.None));
Assert.Contains("CARD:" + reply, blocks);
}

}
14 changes: 12 additions & 2 deletions src/MandoCode.Desktop/Controls/Chat/ChatTabView.Explorer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1278,15 +1278,25 @@ private async Task HandleDropAsync(DragEventArgs e)
{
// Shell drop (Windows Explorer): real files/folders with paths.
var items = await e.DataView.GetStorageItemsAsync();
InsertFileTokens(items.Select(i => i.Path).Where(p => !string.IsNullOrEmpty(p)));
var files = items.OfType<Windows.Storage.StorageFile>().ToArray();
if (files.Length > 0 && files.Length == items.Count && files.All(file => MandoCode.Services.ImageFileReference.IsImage(file.Name)))
await AttachImageFilesAsync(files);
else
InsertFileTokens(items.Select(i => i.Path).Where(p => !string.IsNullOrEmpty(p)));
}
else if (e.DataView.Contains(StandardDataFormats.Text))
{
// Text drop: explorer-tree rows arrive as newline-joined full paths. If every
// line is an existing path, tokenize; otherwise it's ordinary dragged text.
var text = await e.DataView.GetTextAsync();
var lines = text.Split('\n', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
if (lines.Length > 0 && lines.All(l => File.Exists(l) || Directory.Exists(l)))
if (lines.Length > 0 && lines.All(path => File.Exists(path) && MandoCode.Services.ImageFileReference.IsImage(path)))
{
var images = new List<Windows.Storage.StorageFile>();
foreach (var path in lines) images.Add(await Windows.Storage.StorageFile.GetFileFromPathAsync(path));
await AttachImageFilesAsync(images);
}
else if (lines.Length > 0 && lines.All(l => File.Exists(l) || Directory.Exists(l)))
InsertFileTokens(lines);
else
InsertAtCaret(text);
Expand Down
Loading
Loading