pi-fast-subagent 0.1.1 → 0.1.2

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.
Files changed (2) hide show
  1. package/index.ts +21 -8
  2. package/package.json +8 -2
package/index.ts CHANGED
@@ -10,7 +10,7 @@
10
10
  */
11
11
 
12
12
  import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
13
- import { Text } from "@mariozechner/pi-tui";
13
+ import { truncateToWidth } from "@mariozechner/pi-tui";
14
14
  import {
15
15
  AuthStorage,
16
16
  createAgentSession,
@@ -368,22 +368,35 @@ export default function (pi: ExtensionAPI) {
368
368
  model?: string;
369
369
  };
370
370
 
371
- let status = "";
371
+ const statusLines: string[] = [];
372
372
  if (details.running) {
373
373
  const statusParts: string[] = ["running"];
374
374
  if (details.usage?.turns) statusParts.push(`${details.usage.turns} turn${details.usage.turns > 1 ? "s" : ""}`);
375
375
  if (details.elapsedMs !== undefined) statusParts.push(formatDuration(details.elapsedMs));
376
376
  if (details.model) statusParts.push(details.model);
377
- status = `\n${statusParts.join(" · ")}`;
377
+ statusLines.push(statusParts.join(" · "));
378
378
  } else if (details.usage) {
379
379
  const usageStr = formatUsage(details.usage, details.model);
380
- if (usageStr) status = `\n${usageStr}`;
380
+ if (usageStr) statusLines.push(usageStr);
381
381
  }
382
382
 
383
- if (isPartial) {
384
- return new Text(theme.fg("dim", (text || "Running...") + status), 0, 0);
385
- }
386
- return new Text(text + status, 0, 0);
383
+ // Apply dim per-line rather than across the whole block to avoid ANSI codes spanning
384
+ // newlines, which confuses wrapTextWithAnsi ANSI state tracking.
385
+ const textLines = (text || (isPartial ? "Running..." : "")).split("\n");
386
+ const styledLines = isPartial
387
+ ? [...textLines.map((l) => theme.fg("dim", l)), ...statusLines]
388
+ : [...textLines, ...statusLines];
389
+
390
+ // Use a custom component with truncateToWidth per line instead of Text + wrapTextWithAnsi.
391
+ // visibleWidth (used by wrapTextWithAnsi) undercounts wide chars (emoji/CJK), causing the
392
+ // TUI to crash with "Rendered line exceeds terminal width". truncateToWidth uses
393
+ // graphemeWidth internally and correctly measures wide chars.
394
+ return {
395
+ invalidate() {},
396
+ render(width: number): string[] {
397
+ return styledLines.map((line) => truncateToWidth(line, width, "...", true));
398
+ },
399
+ };
387
400
  },
388
401
 
389
402
  async execute(_id, params, signal, onUpdate, ctx) {
package/package.json CHANGED
@@ -1,9 +1,15 @@
1
1
  {
2
2
  "name": "pi-fast-subagent",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "In-process subagent delegation for pi with single, parallel, and chain modes",
5
5
  "type": "module",
6
- "keywords": ["pi-package", "pi", "subagent", "agents", "extension"],
6
+ "keywords": [
7
+ "pi-package",
8
+ "pi",
9
+ "subagent",
10
+ "agents",
11
+ "extension"
12
+ ],
7
13
  "homepage": "https://github.com/tuansondinh/pi-fast-subagent#readme",
8
14
  "repository": {
9
15
  "type": "git",