@@ -117,21 +117,31 @@ function userMessageNode(msg: UserMessage): Node {
117117
118118 function toolMessageNode(msg: ToolResultMessage): Node {
119119 // Output only shows last 10 lines of scroll.
120- return VStack(
121- {
122- height: 10,
123- padding: { x: 4 },
124- overflow: "scroll",
125- scrollOffset: Infinity,
126- onScroll: () => false,
127- },
128- msg.content.map((block) => {
129- if (block.type === "text") {
130- return Text(block.text, { wrap: "word", fgColor: theme.bblack });
131- }
132- return Text(""); // TODO: image case needs attention
120+ const text = msg.content
121+ .filter((c) => c.type === "text")
122+ .map((c) => c.text)
123+ .join("")
124+ .trim();
125+
126+ return VStack({ padding: { x: 4 }, gap: 1 }, [
127+ Text(`~${estimateTokens(text)} tokens, ${text.split("\n").length} lines.`, {
128+ fgColor: theme.bblack,
133129 }),
134- );
130+ VStack(
131+ {
132+ flex: 1,
133+ maxHeight: msg.toolName === "edit" ? 20 : 10,
134+ overflow: "scroll",
135+ scrollOffset: Infinity,
136+ onScroll: () => false,
137+ },
138+ [
139+ msg.toolName === "edit"
140+ ? SyntaxHighlight(text, "diff")
141+ : Text(text, { wrap: "word", fgColor: theme.white }),
142+ ],
143+ ),
144+ ]);
135145 }
136146
137147 const messageBodyCache = new WeakMap<Message, { key: number; node: Node }>();
@@ -187,6 +197,7 @@ function cachedMessageBody(msg: Message): Node {
187197 }
188198
189199 function conversationMessageNode(msg: Message): Node {
200+ const label = msg.role === "toolResult" ? `${msg.toolName} result` : msg.role;
190201 return VStack({ gap: 1 }, [
191202 cachedMessageBody(msg),
192203 HStack({ gap: 1, justifyContent: "end" }, [
@@ -194,7 +205,7 @@ function conversationMessageNode(msg: Message): Node {
194205 fgColor: theme.bblack,
195206 italic: true,
196207 }),
197- TextPill(msg.role, theme.bwhite, theme.bblack),
208+ TextPill(label, theme.bwhite, theme.bblack),
198209 ]),
199210 ]);
200211 }
@@ -246,7 +257,7 @@ export function Conversation(state: TUIState) {
246257 return VStack(
247258 {
248259 flex: 1,
249- gap: 1,
260+ gap: 3,
250261 overflow: "scroll",
251262 scrollOffset: state.stickToBottom ? Infinity : state.scrollOffset,
252263 onScroll(offset, maxOffset) {