xonecas.io
79113
Ma

mini-coding-agent / commit d8d7891

fix: statusline never showed some states.

xonecas2026-10-04 d8d789186c3056961f3afca9a48059ee256a2b2a parent bce96fa

2 files changed

ISSUES.md+5−6
@@ -1,11 +1,9 @@
11 # Issues from QA/Live use
22
3-- ~~No user-agent is sent, this is explicit against Opencode Go and many other providers rules. Start sending `mini-coding-agent/VERSION`~~
4-- Audit statusline states, I never see "waiting for provider". Seems that we don't have that much granularity
5-- `authFile` in config is a fragment of mini-coder's functionality that we don't have, why was it ported without thinking?
6-- Agents use markdown tables in their replies, and usually with terrible whitespace, can we format them for readability?
7-- thinking effort selection doesn't trigger on model selection like it does in mini-coder. since we clamp thinking to the model's
8- options, this is required, it's why mini-coder does it.
3+> The user owns this file, do not edit unless asked to.
4+> If there are edits, it's the user updating the file.
5+
6+- None
97
108 # Improvements
119
@@ -18,3 +16,4 @@
1816 image metadata in the single line body to match the new behaviour suggested here.
1917 - Add to the banner a second line, that shows the count of AGENTS.md files loaded and the SKILL.md files loaded.
2018 - When we start a new session, print a blank line, the banner, and then the "new session" label but dimmed.
19+- Agents use markdown tables in their replies, and usually with terrible whitespace, can we format them for readability?
src/agent.zig+11−5
@@ -82,8 +82,15 @@ pub const Options = struct {
8282 cancel: *const std.atomic.Value(bool),
8383 };
8484
85+const StreamCtx = struct { listener: Listener, started: bool = false };
86+
8587 fn onApiEvent(ctx: *anyopaque, event: api.Event) void {
86- const listener: *Listener = @ptrCast(@alignCast(ctx));
88+ const stream_ctx: *StreamCtx = @ptrCast(@alignCast(ctx));
89+ const listener = stream_ctx.listener;
90+ if (!stream_ctx.started) {
91+ stream_ctx.started = true;
92+ listener.emit(.{ .phase = .{ .phase = .streaming } });
93+ }
8794 switch (event) {
8895 .text => |d| listener.emit(.{ .text = d }),
8996 .reasoning => |d| listener.emit(.{ .reasoning = d }),
@@ -169,12 +176,11 @@ pub fn runTurn(opts: Options, messages: *std.ArrayList(types.Message), interacti
169176 };
170177
171178 listener.emit(.{ .phase = .{ .phase = .waiting_model } });
172- var api_listener = listener;
179+ var stream_ctx = StreamCtx{ .listener = listener };
173180 const assistant = opts.a.create(types.AssistantMessage) catch {
174181 listener.emit(.{ .err = "out of memory" });
175182 return;
176183 };
177- listener.emit(.{ .phase = .{ .phase = .streaming } });
178184 assistant.* = api.stream(.{
179185 .pers = opts.a,
180186 .scratch = scratch,
@@ -185,7 +191,7 @@ pub fn runTurn(opts: Options, messages: *std.ArrayList(types.Message), interacti
185191 .effort = model.effort,
186192 .session_id = opts.session.id,
187193 .cancel = opts.cancel,
188- }, .{ .ctx = &api_listener, .on_event = onApiEvent }) catch |e| {
194+ }, .{ .ctx = &stream_ctx, .on_event = onApiEvent }) catch |e| {
189195 listener.emit(.{ .err = @errorName(e) });
190196 return;
191197 };
@@ -240,7 +246,7 @@ pub fn runTurn(opts: Options, messages: *std.ArrayList(types.Message), interacti
240246 const result = tools.execute(opts.a, scratch, call.name, call.arguments, .{
241247 .cancel = opts.cancel,
242248 .supports_images = opts.supports_images,
243- .on_output = .{ .ctx = &api_listener, .on_chunk = onToolOutput },
249+ .on_output = .{ .ctx = &stream_ctx.listener, .on_chunk = onToolOutput },
244250 });
245251
246252 const tool_message = types.Message{ .tool_result = .{