oira666_pi-subagent 0.6.0 → 0.6.1
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.
- package/extension/activity-widget.ts +1 -1
- package/extension/message-tool.ts +2 -2
- package/package.json +1 -1
- package/render.ts +34 -13
|
@@ -72,7 +72,7 @@ export function registerActivityWidget(state: ExtensionState): void {
|
|
|
72
72
|
(tui, theme) => {
|
|
73
73
|
requestRender = () => tui.requestRender();
|
|
74
74
|
return {
|
|
75
|
-
render: (width) => [theme.fg("
|
|
75
|
+
render: (width) => [theme.fg("accent", formatActivityLine(entries, width))],
|
|
76
76
|
invalidate() {},
|
|
77
77
|
};
|
|
78
78
|
},
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
updateNameRecord,
|
|
15
15
|
} from "../names.js";
|
|
16
16
|
import { originalModelSettings } from "../storage/session-settings.js";
|
|
17
|
-
import { recordToolCallStart,
|
|
17
|
+
import { recordToolCallStart, renderMessageResult } from "../render.js";
|
|
18
18
|
import { buildSubagentDetails, DEFAULT_DELEGATION_MODE } from "../types.js";
|
|
19
19
|
import { startBackground } from "./async-jobs.js";
|
|
20
20
|
import { updateLatestBroadcastTargets } from "./broadcast.js";
|
|
@@ -241,6 +241,6 @@ export function registerMessageSubagentTool(state: ExtensionState) {
|
|
|
241
241
|
0,
|
|
242
242
|
0,
|
|
243
243
|
),
|
|
244
|
-
renderResult: (result, { expanded }, theme, context) =>
|
|
244
|
+
renderResult: (result, { expanded }, theme, context) => renderMessageResult(result, expanded, theme, context),
|
|
245
245
|
});
|
|
246
246
|
}
|
package/package.json
CHANGED
package/render.ts
CHANGED
|
@@ -145,6 +145,39 @@ function takePromptLine(text: string, width: number): { line: string; rest: stri
|
|
|
145
145
|
return { line: normalized.slice(0, split), rest: normalized.slice(split).trimStart() };
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
+
function promptPreviewLines(prefix: string, prompt: string, width: number, theme: { fg: ThemeFg }): string[] {
|
|
149
|
+
if (width <= 0) return [];
|
|
150
|
+
const prefixWidth = visibleWidth(prefix);
|
|
151
|
+
const first = takePromptLine(prompt, Math.max(0, width - prefixWidth));
|
|
152
|
+
const indent = " ".repeat(Math.min(prefixWidth, Math.max(0, width - 8)));
|
|
153
|
+
const secondWidth = Math.max(0, width - indent.length);
|
|
154
|
+
const second = takePromptLine(first.rest, secondWidth);
|
|
155
|
+
const lines = [fitLine(`${prefix}${theme.fg("dim", first.line)}`, width)];
|
|
156
|
+
if (first.rest) {
|
|
157
|
+
const text = second.rest ? truncateToWidth(first.rest, secondWidth) : second.line;
|
|
158
|
+
lines.push(fitLine(`${indent}${theme.fg("dim", text)}`, width));
|
|
159
|
+
}
|
|
160
|
+
return lines;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function renderMessageResult(
|
|
164
|
+
result: { content: Array<{ type: string; text?: string }>; details?: unknown },
|
|
165
|
+
expanded: boolean,
|
|
166
|
+
theme: { fg: ThemeFg; bold: (s: string) => string },
|
|
167
|
+
context?: ResultRenderContext & { args?: { name?: string; message?: string }; isError?: boolean },
|
|
168
|
+
): Component {
|
|
169
|
+
const message = context?.args?.message;
|
|
170
|
+
if (context?.isError || typeof message !== "string") return renderResult(result, expanded, theme, context);
|
|
171
|
+
const prefix = ` ${statusEmoji("success", theme)} ${theme.fg("accent", context?.args?.name ?? "")} `;
|
|
172
|
+
return {
|
|
173
|
+
render: (width) =>
|
|
174
|
+
expanded
|
|
175
|
+
? new Text(`${prefix}${theme.fg("dim", message)}`, 0, 0).render(width).map((line) => fitLine(line, width))
|
|
176
|
+
: promptPreviewLines(prefix, message, width, theme),
|
|
177
|
+
invalidate() {},
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
148
181
|
class CollapsedSubagentComponent implements Component {
|
|
149
182
|
constructor(
|
|
150
183
|
private readonly details: SubagentDetails,
|
|
@@ -157,19 +190,7 @@ class CollapsedSubagentComponent implements Component {
|
|
|
157
190
|
const lines: string[] = [];
|
|
158
191
|
for (const node of nodes) {
|
|
159
192
|
const prefix = ` ${statusEmoji(node.status, this.theme)} ${this.theme.fg("accent", node.label)} `;
|
|
160
|
-
|
|
161
|
-
const firstWidth = Math.max(0, width - prefixWidth);
|
|
162
|
-
const first = takePromptLine(node.task ?? "", firstWidth);
|
|
163
|
-
const continuationIndent = " ".repeat(Math.min(prefixWidth, Math.max(0, width - 8)));
|
|
164
|
-
const secondWidth = Math.max(0, width - continuationIndent.length);
|
|
165
|
-
const second = takePromptLine(first.rest, secondWidth);
|
|
166
|
-
const firstLine = `${prefix}${this.theme.fg("dim", first.line)}`;
|
|
167
|
-
lines.push(fitLine(firstLine, width));
|
|
168
|
-
if (first.rest) {
|
|
169
|
-
const hasMore = second.rest.length > 0;
|
|
170
|
-
const secondText = hasMore ? truncateToWidth(first.rest, secondWidth) : second.line;
|
|
171
|
-
lines.push(fitLine(`${continuationIndent}${this.theme.fg("dim", secondText)}`, width));
|
|
172
|
-
}
|
|
193
|
+
lines.push(...promptPreviewLines(prefix, node.task ?? "", width, this.theme));
|
|
173
194
|
const actionAt = node.lastActionAt ?? node.startedAt;
|
|
174
195
|
if (actionAt !== undefined) {
|
|
175
196
|
lines.push(fitLine(` ${this.theme.fg("muted", `last action: ${formatClockTime(actionAt)}`)}`, width));
|