pi-pretty-tui 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1174,6 +1174,16 @@ export default function prettyTui(pi: ExtensionAPI) {
1174
1174
  invalidate() {},
1175
1175
  }));
1176
1176
 
1177
+ const messageContentItems = (message: any): any[] =>
1178
+ Array.isArray(message?.content) ? message.content : [];
1179
+
1180
+ const messageHasVisibleText = (message: any): boolean =>
1181
+ typeof message?.content === "string"
1182
+ ? message.content.trim().length > 0
1183
+ : messageContentItems(message).some(
1184
+ (item: any) => item.type === "text" && typeof item.text === "string" && item.text.trim().length > 0,
1185
+ );
1186
+
1177
1187
  const restoreCleanSession = (ctx: any) => {
1178
1188
  cleanToolsExpanded = ctx.ui.getToolsExpanded();
1179
1189
  settledSummaries.clear();
@@ -1278,11 +1288,8 @@ export default function prettyTui(pi: ExtensionAPI) {
1278
1288
  }
1279
1289
 
1280
1290
  if (message.role === "assistant") {
1281
- const hasVisibleText = (message.content ?? []).some(
1282
- (item: any) => item.type === "text" && typeof item.text === "string" && item.text.trim().length > 0,
1283
- );
1284
- if (hasVisibleText) finishGroup();
1285
- for (const item of message.content ?? []) {
1291
+ if (messageHasVisibleText(message)) finishGroup();
1292
+ for (const item of messageContentItems(message)) {
1286
1293
  if (item.type !== "toolCall" || !supportedTools.has(item.name)) continue;
1287
1294
  count++;
1288
1295
  lastToolCallId = item.id;
@@ -1309,12 +1316,10 @@ export default function prettyTui(pi: ExtensionAPI) {
1309
1316
  });
1310
1317
 
1311
1318
  const hasVisibleAssistantText = (message: any): boolean =>
1312
- message?.role === "assistant" && (message.content ?? []).some(
1313
- (item: any) => item.type === "text" && typeof item.text === "string" && item.text.trim().length > 0,
1314
- );
1319
+ message?.role === "assistant" && messageHasVisibleText(message);
1315
1320
 
1316
1321
  const pendingToolCalls = (message: any): any[] =>
1317
- (message?.content ?? []).filter(
1322
+ messageContentItems(message).filter(
1318
1323
  (item: any) => item.type === "toolCall" && supportedTools.has(item.name) && item.id,
1319
1324
  );
1320
1325
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-pretty-tui",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Polished user messages, tool calls, and list rendering for the Pi coding agent TUI",
5
5
  "license": "MIT",
6
6
  "author": "Kainan Yang <ykn0309@whu.edu.cn>",
@@ -40,6 +40,6 @@
40
40
  "extensions": [
41
41
  "./extensions/index.ts"
42
42
  ],
43
- "image": "https://unpkg.com/pi-pretty-tui@0.1.5/assets/screenshot.png"
43
+ "image": "https://unpkg.com/pi-pretty-tui@0.1.6/assets/screenshot.png"
44
44
  }
45
45
  }