xonecas.io
79113
Ma

mini-coding-agent / commit 45eb5ec

fix: colorscheme fixes

xonecas2026-10-26 45eb5ec4061a2a79e4d29d8625c2151613762e47 parent ab1b6d6

5 files changed

README.md+1−1
@@ -186,7 +186,7 @@ Keys:
186186 | `snapshotDiffsInContext` | `false` | send the `bash` tool's snapshot diffs to the model inside the tool result |
187187 | `historySize` | `100` | past inputs kept in `<state dir>/mini-coding-agent/history` for `Shift+Up`/`Shift+Down` and `Ctrl+R` |
188188 | `maxDiffLines` | `2000` | diffs longer than this render as a "too large" notice instead of highlighting every line |
189-| `colorscheme` | `{}` | per-role `#rrggbb` foreground overrides; roles are `comment`, `prompt`, `accent`, `err`, `warn`, `code`, `diff_add`, `diff_delete`, `inline_code`, `link`, `uri`, `heading1`-`heading6`; a role left out keeps its terminal palette color |
189+| `colorscheme` | `{}` | per-role `#rrggbb` foreground overrides; roles are `comment`, `prompt`, `accent`, `err`, `warn`, `code`, `output`, `diff_add`, `diff_delete`, `inline_code`, `link`, `uri`, `heading1`-`heading6`; a role left out keeps its terminal palette color |
190190
191191 Unknown keys are rejected. `provider` and `model` must both be set to make a
192192 request; a custom provider must list the model in its `models`. Config errors
src/config.zig+1−0
@@ -42,6 +42,7 @@ pub const Colorscheme = struct {
4242 err: ?[]const u8 = null,
4343 warn: ?[]const u8 = null,
4444 code: ?[]const u8 = null,
45+ output: ?[]const u8 = null,
4546 diff_add: ?[]const u8 = null,
4647 diff_delete: ?[]const u8 = null,
4748 inline_code: ?[]const u8 = null,
src/tui/styles.zig+14−2
@@ -38,15 +38,16 @@ pub const Style = struct {
3838
3939 /// Every role resolves to the terminal's default foreground unless it asks otherwise.
4040 pub const Roles = struct {
41- comment: Style = .{ .fg = .{ .palette = .bright_black }, .dim = true },
41+ comment: Style = .{ .fg = .{ .palette = .bright_black } },
4242 prompt: Style = .{ .fg = .{ .palette = .blue } },
4343 accent: Style = .{ .fg = .{ .palette = .cyan } },
4444 err: Style = .{ .fg = .{ .palette = .red } },
4545 warn: Style = .{ .fg = .{ .palette = .yellow } },
4646 code: Style = .{ .fg = .{ .palette = .bright_black } },
47+ output: Style = .{},
4748 diff_add: Style = .{ .fg = .{ .palette = .green } },
4849 diff_delete: Style = .{ .fg = .{ .palette = .red } },
49- inline_code: Style = .{ .fg = .{ .palette = .cyan } },
50+ inline_code: Style = .{ .fg = .{ .palette = .magenta } },
5051 link: Style = .{ .fg = .{ .palette = .blue }, .underline = true },
5152 uri: Style = .{ .underline = true },
5253 heading1: Style = .{ .fg = .{ .palette = .bright_blue }, .bold = true },
@@ -125,6 +126,17 @@ pub fn anySet(style: Style) bool {
125126 return style.fg != null or style.bold or style.italic or style.underline or style.dim;
126127 }
127128
129+/// The `·` between sections. Every separator in the interface uses this one
130+/// role, so a line never mixes separator colors.
131+pub fn sep(a: std.mem.Allocator) []const u8 {
132+ return styledWith(a, roles.comment, " · ");
133+}
134+
135+/// Joins already-styled parts with separators.
136+pub fn join(a: std.mem.Allocator, parts: []const []const u8) []const u8 {
137+ return std.mem.join(a, sep(a), parts) catch "";
138+}
139+
128140 pub fn comment(a: std.mem.Allocator, text: []const u8) []const u8 {
129141 return styledWith(a, roles.comment, text);
130142 }
src/tui/tool_view.zig+7−2
@@ -62,8 +62,13 @@ pub const Result = struct {
6262
6363 pub fn diffFooter(a: std.mem.Allocator, r: diff_view.Rendered) ?[]const u8 {
6464 if (r.added == 0 and r.removed == 0) return null;
65- const stats = std.fmt.allocPrint(a, "+{d} -{d}", .{ r.added, r.removed }) catch return null;
66- return metaLine(a, stats);
65+ const add = std.fmt.allocPrint(a, "+{d}", .{r.added}) catch return null;
66+ const del = std.fmt.allocPrint(a, "-{d}", .{r.removed}) catch return null;
67+ return std.fmt.allocPrint(a, "{s}{s} {s}", .{
68+ styles.comment(a, " └ "),
69+ styles.styledWith(a, styles.roles.diff_add, add),
70+ styles.styledWith(a, styles.roles.diff_delete, del),
71+ }) catch null;
6772 }
6873
6974 pub fn resultLines(a: std.mem.Allocator, name: []const u8, text: []const u8, max_diff_lines: usize) Result {
src/tui/tui.zig+29−24
@@ -28,7 +28,6 @@ const SPINNER = "⠀⠁⠂⠃⠄⠅⠆⠇⡀⡁⡂⡃⡄⡅⡆⡇⠈⠉⠊⠋⠌
2828 const SPINNER_MS = 120;
2929 const BODY_PREFIX = " │ ";
3030 const ERROR_PREFIX = " ! ";
31-const TOOL_BODY: styles.Style = .{ .dim = true };
3231
3332 const PendingCall = tool_view.PendingCall;
3433 const Picker = picker_mod.Picker;
@@ -205,23 +204,23 @@ const Tui = struct {
205204
206205 fn pushBanner(self: *Tui) void {
207206 self.scrollback.separator = true;
208- const model = self.opts.model;
209- const brand = styles.accent(self.s, "mini-coding-agent");
210- self.push(if (model) |m|
211- if (m.effort.len == 0)
212- std.fmt.allocPrint(self.s, "{s} · {s}/{s}", .{ brand, m.provider, m.id }) catch brand
213- else
214- std.fmt.allocPrint(self.s, "{s} · {s}/{s} · {s}", .{ brand, m.provider, m.id, m.effort }) catch brand
215- else
216- std.fmt.allocPrint(self.s, "{s} · no model configured", .{brand}) catch brand);
217- const loaded = self.opts.loaded;
207+ const a = self.s;
218208 var parts: std.ArrayList([]const u8) = .empty;
209+ parts.append(a, styles.accent(a, "mini-coding-agent")) catch {};
210+ if (self.opts.model) |m| {
211+ parts.append(a, std.fmt.allocPrint(a, "{s}/{s}", .{ m.provider, m.id }) catch m.id) catch {};
212+ if (m.effort.len > 0) parts.append(a, m.effort) catch {};
213+ } else {
214+ parts.append(a, "no model configured") catch {};
215+ }
216+ self.push(styles.join(a, parts.items));
217+ const loaded = self.opts.loaded;
218+ var resources: std.ArrayList([]const u8) = .empty;
219219 if (loaded.agent_files > 0)
220- parts.append(self.s, plural(self.s, loaded.agent_files, "agent file", "agent files")) catch {};
220+ resources.append(a, styles.comment(a, plural(a, loaded.agent_files, "agent file", "agent files"))) catch {};
221221 if (loaded.skills > 0)
222- parts.append(self.s, plural(self.s, loaded.skills, "skill", "skills")) catch {};
223- if (parts.items.len > 0)
224- self.push(styles.comment(self.s, std.mem.join(self.s, " · ", parts.items) catch "resources"));
222+ resources.append(a, styles.comment(a, plural(a, loaded.skills, "skill", "skills"))) catch {};
223+ if (resources.items.len > 0) self.push(styles.join(a, resources.items));
225224 self.scrollback.separator = true;
226225 }
227226
@@ -237,25 +236,29 @@ const Tui = struct {
237236 const used = self.ctx_used;
238237 const cache = self.ctx_cache;
239238 self.messages_mutex.unlock(platform.io);
240- const info = std.fmt.allocPrint(self.s, "{s} {s}", .{
239+ const info = std.fmt.allocPrint(self.s, "{s}{s}{s}", .{
241240 usage_mod.contextUsageLine(self.s, used, model),
241+ styles.sep(self.s),
242242 usage_mod.cacheLine(self.s, cache),
243243 }) catch "ctx";
244+ const sep = styles.sep(self.s);
244245 if (self.paused or self.phase == .pausing) {
245- return std.fmt.allocPrint(self.s, "{s} · {s}", .{ styles.comment(self.s, "paused - type steering, Enter to submit"), info }) catch info;
246+ return std.fmt.allocPrint(self.s, "{s}{s}{s}", .{ styles.comment(self.s, "paused - type steering, Enter to submit"), sep, info }) catch info;
246247 }
247248 if (self.active and self.pause_requested.load(.seq_cst)) {
248- return std.fmt.allocPrint(self.s, "{s} · {s}", .{ styles.comment(self.s, "pausing - waiting for the step boundary"), info }) catch info;
249+ return std.fmt.allocPrint(self.s, "{s}{s}{s}", .{ styles.comment(self.s, "pausing - waiting for the step boundary"), sep, info }) catch info;
249250 }
250251 if (self.retry) {
251- return std.fmt.allocPrint(self.s, "{s} · {s}", .{ styles.err(self.s, "failed - Enter to retry"), info }) catch info;
252+ return std.fmt.allocPrint(self.s, "{s}{s}{s}", .{ styles.err(self.s, "failed - Enter to retry"), sep, info }) catch info;
252253 }
253254 if (!self.active or self.phase == .idle) return info;
254255 const elapsed = @max(0, @divFloor(time.nowMs() - self.turn_start, 1000));
255- return std.fmt.allocPrint(self.s, "{s} {s} · {s} · {s}", .{
256+ return std.fmt.allocPrint(self.s, "{s} {s}{s}{s}{s}{s}", .{
256257 styles.accent(self.s, spinnerChar(self.frame)),
257258 self.stateLabel(),
259+ sep,
258260 styles.comment(self.s, std.fmt.allocPrint(self.s, "{d}s", .{elapsed}) catch ""),
261+ sep,
259262 info,
260263 }) catch info;
261264 }
@@ -301,11 +304,13 @@ const Tui = struct {
301304 out.appendSlice(a, if (role) |r| styles.styledWith(a, r, text) else styles.comment(a, text)) catch {};
302305 if (bytes > 0) {
303306 const n = usage_mod.formatTokens(a, (bytes + 3) / 4);
304- out.appendSlice(a, styles.comment(a, std.fmt.allocPrint(a, " · ~{s} tok", .{n}) catch "")) catch {};
307+ out.appendSlice(a, styles.sep(a)) catch {};
308+ out.appendSlice(a, styles.comment(a, std.fmt.allocPrint(a, "~{s} tok", .{n}) catch "")) catch {};
305309 }
306310 const queued = self.pending_calls.items.len -| @intFromBool(self.phase == .running_tool);
307311 if (queued > 0) {
308- out.appendSlice(a, styles.comment(a, std.fmt.allocPrint(a, " · {d} queued", .{queued}) catch "")) catch {};
312+ out.appendSlice(a, styles.sep(a)) catch {};
313+ out.appendSlice(a, styles.comment(a, std.fmt.allocPrint(a, "{d} queued", .{queued}) catch "")) catch {};
309314 }
310315 return out.items;
311316 }
@@ -521,7 +526,7 @@ const Tui = struct {
521526 const is_bash = std.mem.eql(u8, name, "bash");
522527 const bash_exit: ?[]const u8 = if (is_bash) tool_view.exitLine(self.s, shown) else null;
523528 const result = tool_view.resultLines(self.s, name, shown, self.cfg.max_diff_lines);
524- const rows = if (std.mem.eql(u8, name, "edit")) render.plainRows(self.s, result.lines, TOOL_BODY) else render.bodyRows(self.s, result.lines, width, TOOL_BODY);
529+ const rows = if (std.mem.eql(u8, name, "edit")) render.plainRows(self.s, result.lines, styles.roles.output) else render.bodyRows(self.s, result.lines, width, styles.roles.output);
525530 const mark_error = is_error and bash_exit == null;
526531 for (rows, 0..) |row, i| {
527532 const prefix = if (mark_error and i == rows.len - 1) styles.err(self.s, ERROR_PREFIX) else styles.comment(self.s, BODY_PREFIX);
@@ -533,7 +538,7 @@ const Tui = struct {
533538 for (diffs) |d| {
534539 self.push(tool_view.diffHead(self.s, name, d.path));
535540 const r = diff_view.diffBody(self.s, d, self.cfg.max_diff_lines);
536- for (render.plainRows(self.s, r.lines, TOOL_BODY)) |row| {
541+ for (render.plainRows(self.s, r.lines, styles.roles.output)) |row| {
537542 self.push(std.fmt.allocPrint(self.s, "{s}{s}", .{ styles.comment(self.s, BODY_PREFIX), row }) catch row);
538543 }
539544 if (tool_view.diffFooter(self.s, r)) |footer| self.push(footer);