@@ -20,6 +20,7 @@ const usage_mod = @import("usage.zig");
2020 const diff_view = @import("diff_view.zig");
2121 const tool_view = @import("tool_view.zig");
2222 const screen = @import("screen.zig");
23+const status = @import("../status.zig");
2324
2425 const SPINNER = "⠀⠁⠂⠃⠄⠅⠆⠇⡀⡁⡂⡃⡄⡅⡆⡇⠈⠉⠊⠋⠌⠍⠎⠏⡈⡉⡊⡋⡌⡍⡎⡏⠐⠑⠒⠓⠔⠕⠖⠗⡐⡑⡒⡓⡔⡕⡖⡗⠘⠙⠚⠛⠜⠝⠞⠟⡘⡙⡚⡛⡜⡝⡞⡟⠠⠡⠢⠣⠤⠥⠦⠧⡠⡡⡢⡣⡤⡥⡦⡧⠨⠩⠪⠫⠬⠭⠮⠯⡨⡩⡪⡫⡬⡭⡮⡯⠰⠱⠲⠳⠴⠵⠶⠷⡰⡱⡲⡳⡴⡵⡶⡷⠸⠹⠺⠻⠼⠽⠾⠿⡸⡹⡺⡻⡼⡽⡾⡿⢀⢁⢂⢃⢄⢅⢆⢇⣀⣁⣂⣃⣄⣅⣆⣇⢈⢉⢊⢋⢌⢍⢎⢏⣈⣉⣊⣋⣌⣍⣎⣏⢐ …
2526 const SPINNER_MS = 120;
@@ -295,13 +296,13 @@ const Tui = struct {
295296 self.resetScratch();
296297 const width = @max(self.term.width(), 1);
297298 const height = @max(self.term.height() - 1, 1);
298- const status = self.statusLine();
299- const status_rows = physicalRows(status, width);
299+ const status_line = self.statusLine();
300+ const status_rows = physicalRows(status_line, width);
300301 const editor_budget = height -| status_rows;
301302 const ed = self.editor.layout(width, @max(editor_budget, 1));
302303
303304 var lines: std.ArrayList([]const u8) = .empty;
304- lines.append(self.s, status) catch {};
305+ lines.append(self.s, status_line) catch {};
305306 const caret_line = lines.items.len + ed.cursor_row;
306307 for (ed.rows) |r| lines.append(self.s, r) catch {};
307308
@@ -331,6 +332,11 @@ const Tui = struct {
331332 self.text_bytes = 0;
332333 self.reasoning_bytes = 0;
333334 }
335+ self.reportStatus(switch (p.phase) {
336+ .preparing, .waiting_model, .streaming, .snapshotting, .running_tool => "working",
337+ .pausing => "blocked",
338+ .idle => "idle",
339+ }, if (p.phase == .pausing) "question" else null, if (p.phase == .pausing) "paused - type steering to continue" else null);
334340 },
335341 .text => |delta| {
336342 self.stream_kind = .text;
@@ -365,14 +371,31 @@ const Tui = struct {
365371 .tool_output => {},
366372 .message => |am| self.commitMessage(am),
367373 .tool_result => |tr| self.commitToolResult(tr.name, tr.text, tr.is_error, tr.diffs, tr.body),
368- .err => |m| self.endTurn(styles.red(self.s, std.fmt.allocPrint(self.s, "! {s}", .{m}) catch "! error")),
369- .no_model => self.endTurn(styles.red(self.s, "! no model configured")),
370- .cancelled => self.endTurn(styles.red(self.s, "! cancelled")),
371- .complete => self.endTurn(styles.dim(self.s, std.fmt.allocPrint(self.s, "[complete · {d}s]", .{@max(0, @divFloor(time.nowMs() - self.turn_start, 1000))}) catch "[complete]")),
374+ .err => |m| {
375+ self.reportStatus("error", null, m);
376+ self.endTurn(styles.red(self.s, std.fmt.allocPrint(self.s, "! {s}", .{m}) catch "! error"));
377+ },
378+ .no_model => {
379+ self.reportStatus("error", null, "no model configured");
380+ self.endTurn(styles.red(self.s, "! no model configured"));
381+ },
382+ .cancelled => {
383+ self.reportStatus("idle", null, null);
384+ self.endTurn(styles.red(self.s, "! cancelled"));
385+ },
386+ .complete => {
387+ self.reportStatus("done", null, null);
388+ self.endTurn(styles.dim(self.s, std.fmt.allocPrint(self.s, "[complete · {d}s]", .{@max(0, @divFloor(time.nowMs() - self.turn_start, 1000))}) catch "[complete]"));
389+ },
372390 }
373391 self.dirty = true;
374392 }
375393
394+ fn reportStatus(self: *Tui, state: []const u8, kind: ?[]const u8, msg: ?[]const u8) void {
395+ if (!self.cfg.program_status) return;
396+ status.report(state, kind, msg);
397+ }
398+
376399 fn endTurn(self: *Tui, line: []const u8) void {
377400 self.phase = .idle;
378401 self.keepName(&self.detail, null);
@@ -446,6 +469,7 @@ const Tui = struct {
446469 self.steering_text = "";
447470 if (!self.aborting) {
448471 self.aborting = true;
472+ self.reportStatus("idle", null, null);
449473 self.endTurn(styles.red(self.s, "! cancelled"));
450474 }
451475 self.dirty = true;
@@ -869,6 +893,7 @@ pub fn run(opts: agent.Options, cfg: *const config.Config, tool_names: []const c
869893 std.posix.sigaction(std.posix.SIG.HUP, &term_act, null);
870894 std.posix.sigaction(std.posix.SIG.QUIT, &term_act, null);
871895
896+ self.reportStatus("idle", null, null);
872897 self.pushBanner();
873898 self.draw();