summaryrefslogtreecommitdiff
path: root/src/tui_app.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/tui_app.zig')
-rw-r--r--src/tui_app.zig28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/tui_app.zig b/src/tui_app.zig
index e44a74a..c68daf4 100644
--- a/src/tui_app.zig
+++ b/src/tui_app.zig
@@ -605,7 +605,7 @@ pub const App = struct {
.{ .tool = box },
.tool,
"tool",
- .{ .tool = .{ .index = index } },
+ .{ .tool = .{ .index = index, .collapsed = self.tools_collapsed } },
);
return box;
}
@@ -633,7 +633,14 @@ pub const App = struct {
payload: Payload,
) !void {
const entry = self.findToolEntry(box) orelse return;
- _ = try self.fireForEntry(entry, lc, name, payload);
+ var enriched = payload;
+ if (enriched == .tool) {
+ enriched.tool.collapsed = box.collapsed;
+ if (enriched.tool.id.len == 0) {
+ if (box.id) |id| enriched.tool.id = id.items;
+ }
+ }
+ _ = try self.fireForEntry(entry, lc, name, enriched);
}
/// Fire a thinking/assistant lifecycle event for the entry backing a
@@ -732,6 +739,7 @@ pub const App = struct {
.ToolUse => |tu| {
const box = try self.spawnTool(0);
try box.setName(tu.name);
+ try box.setId(tu.id);
try box.setInput(tu.input.items);
try self.router.putToolId(tu.id, box);
},
@@ -760,8 +768,18 @@ pub const App = struct {
/// the whole list and flip each one. Requests a render.
pub fn toggleToolCollapse(self: *App) void {
self.tools_collapsed = !self.tools_collapsed;
- for (self.transcript.items) |e| {
- if (e.kind == .tool) e.kind.tool.setCollapsed(self.tools_collapsed);
+ for (self.transcript.items) |*e| {
+ if (e.kind == .tool) {
+ const box = e.kind.tool;
+ box.setCollapsed(self.tools_collapsed);
+ _ = self.fireForEntry(e, null, "tool_collapse", .{ .tool = .{
+ .tool_name = if (box.name) |n| n.items else "",
+ .id = if (box.id) |id| id.items else "",
+ .input = box.input.items,
+ .output = if (box.output) |out| out.items else "",
+ .collapsed = self.tools_collapsed,
+ } }) catch {};
+ }
}
self.scheduler.requestRender();
}
@@ -837,6 +855,7 @@ pub const App = struct {
// the name-based claim point). A handler swap here takes
// over before the real content paints further.
try box.setName(d.name);
+ try box.setId(d.id);
try self.fireToolLifecycle(box, .tool_details, "tool_details", .{ .tool = .{
.index = d.index,
.tool_name = d.name,
@@ -916,6 +935,7 @@ pub const App = struct {
// tool_details never fired and replaces any
// partial streamed args with the final bytes).
try box.setName(tu.name);
+ try box.setId(tu.id);
try box.setInput(tu.input.items);
try self.router.putToolId(tu.id, box);
// Fire `tool_call_complete` (end of the CALL;