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
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ recorded by the `MandoCode` submodule.
period-correct white dialog on the silver desktop.

### Fixed
- **The context window setting now actually reaches the model.** It was exported as
`OLLAMA_CONTEXT_LENGTH` only when MandoCode launched the Ollama daemon itself — anyone whose
daemon was already running (the tray app, most commonly) silently got the daemon's own default
instead, making the Settings field, the "context window sized to Nk tokens" line, and the
per-model auto-sizing all cosmetic. The window now rides on every chat request as `num_ctx`,
which outranks the tray app's slider and the daemon default, applies from the next message with
no restart, and — as a bonus the old design could never offer — is genuinely per-agent: two tabs
can run different windows against the same daemon. The Settings caption and README stop calling
it app-wide, and `0` still means "let Ollama decide."
- **W98 chat prompts are readable again.** Your own prompts rendered in the theme's gold, which
resolves to a dark mustard `#806000` — 3.21:1 on a silver window, under the accessibility floor
and hard going for anyone with less-than-perfect sight. W98 prompts now use black window text
Expand All @@ -33,6 +42,13 @@ recorded by the `MandoCode` submodule.
and is now white underlined at 4.77:1. Other themes are untouched.

### Added
- **Conversations compact themselves before the context window overflows** (pinned harness
update). Local Ollama never rejects an oversized prompt — it silently drops the oldest tokens,
system prompt first, which surfaced as "Model returned an empty response" at the end of a
tool-heavy turn on a small model. The harness now estimates each outgoing prompt (history plus
every tool schema riding along, MCP servers included) before sending, and when it nears the
window it folds older history into a recap first and says so in the reply — leaving thinking
models the generation headroom they spend reasoning before any visible answer appears.
- **Undo for the notes assistant.** A gold undo arrow appears in the note header after the assistant
inserts or replaces text, putting the note back exactly as it was. Ctrl+Z can't do this job —
assigning the editor's text resets the TextBox's own undo history, so the one edit you *didn't*
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,11 @@ approval in one agent would stop another's from ever rendering; and `ChatControl
(not `+=`) five approval delegates, so on shared services the last agent constructed silently
steals every approval.

Two settings can't be per-agent and are labelled app-wide in the UI: **Appearance** is a property
of the window (and lives outside the shared config), and **Context window** is applied as
`OLLAMA_CONTEXT_LENGTH` when MandoCode starts the Ollama daemon — one daemon, one context window.
One setting can't be per-agent and is labelled app-wide in the UI: **Appearance** is a property
of the window (and lives outside the shared config). **Context window** used to share that label —
it was applied as `OLLAMA_CONTEXT_LENGTH` at daemon start, one daemon, one window — but it now
rides on every chat request as `num_ctx`, so each agent's own value governs its own conversations,
like any other per-agent setting.

### Settings and the config file

Expand Down
4 changes: 2 additions & 2 deletions src/MandoCode.Desktop/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1027,11 +1027,11 @@
Minimum="1" SpinButtonPlacementMode="Compact" SmallChange="1024"
ValueChanged="Setting_NumberChanged" HorizontalAlignment="Stretch"
ToolTipService.ToolTip="Upper limit on how long a single response can be. Raise it if answers get cut off mid-code; lower it for shorter, faster replies."/>
<NumberBox x:Name="S_ContextLength" Header="Context window (tokens, 0 = Ollama default) — app-wide"
<NumberBox x:Name="S_ContextLength" Header="Context window (tokens, 0 = Ollama default)"
Tag="contextLength" Minimum="0" SpinButtonPlacementMode="Compact" SmallChange="2048"
ValueChanged="Setting_NumberChanged" HorizontalAlignment="Stretch"
ToolTipService.ToolTip="How much conversation and file content the model can see at once. Larger windows track big files and long chats but use much more RAM/VRAM and respond slower. 0 keeps Ollama's default."/>
<TextBlock Text="Applied when MandoCode starts Ollama (as OLLAMA_CONTEXT_LENGTH). One Ollama server backs every agent, so unlike the settings above this one is app-wide, not per-agent."
<TextBlock Text="Sent with every request (num_ctx), so it applies from this agent's next message — no restart needed. Auto-sized to the model's hardware tier when you switch models; set it here to override."
Opacity="0.5" FontSize="11" TextWrapping="Wrap" Margin="0,-6,0,0"/>
<ComboBox x:Name="S_Streaming" Header="Response streaming" SelectionChanged="Streaming_Changed"
HorizontalAlignment="Stretch"
Expand Down
15 changes: 7 additions & 8 deletions src/MandoCode.Desktop/Services/ConfigCoordinator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ namespace MandoCode.Desktop.Services;
/// current settings"; it is <see cref="Defaults"/>, the starting point every NEW agent is seeded
/// from. "Make Default for New Agents" is the one action that writes it.
///
/// Two things are deliberately app-wide rather than per-agent, because the machinery underneath
/// them is:
/// • MCP servers — OS processes owned by a single shared McpClientManager. An agent can turn
/// MCP on or off for itself (AIService.AttachMcpPluginsAsync honours its own EnableMcp), but
/// the server SET is one list. Edits land on Defaults and mirror into every live agent, so
/// per-agent autoApprove lookups agree with what the MCP page shows.
/// • ContextLength — applied as OLLAMA_CONTEXT_LENGTH when MandoCode starts the Ollama daemon.
/// One daemon, one context window.
/// One thing is deliberately app-wide rather than per-agent, because the machinery underneath
/// it is: MCP servers — OS processes owned by a single shared McpClientManager. An agent can turn
/// MCP on or off for itself (AIService.AttachMcpPluginsAsync honours its own EnableMcp), but
/// the server SET is one list. Edits land on Defaults and mirror into every live agent, so
/// per-agent autoApprove lookups agree with what the MCP page shows.
/// (ContextLength used to be on this list — env-var-scoped to the one daemon — but it now rides
/// on every request as num_ctx, so each agent's own value governs its own conversations.)
///
/// A clone's Save() must never be called: it would write that agent's session settings over
/// everybody's defaults. The method is public and non-virtual on a type in the read-only harness
Expand Down
2 changes: 1 addition & 1 deletion src/MandoCode.Desktop/ViewModels/ChatController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ private async Task ApplyModelSwitchAsync(string modelTag)
if (recommendedCtx > 0 && recommendedCtx != _config.ContextLength)
{
_config.ContextLength = recommendedCtx;
_transcript.Append(_html.Dim($"Context window sized to {recommendedCtx / 1024}k tokens for this model tier (takes effect when MandoCode starts Ollama)."));
_transcript.Append(_html.Dim($"Context window sized to {recommendedCtx / 1024}k tokens for this model tier (applies from your next message)."));
}

_busy.Start("Switching model...");
Expand Down
Loading