pi-polish 0.1.12 → 0.1.13
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/extensions/tools.ts +14 -7
- package/package.json +1 -1
package/extensions/tools.ts
CHANGED
|
@@ -89,8 +89,9 @@ interface Group {
|
|
|
89
89
|
started: number;
|
|
90
90
|
ended?: number;
|
|
91
91
|
timer?: NodeJS.Timeout;
|
|
92
|
-
// Opened by a click,
|
|
92
|
+
// Opened or folded by a click, overriding ctrl+o for this group until ctrl+o is toggled
|
|
93
93
|
open?: boolean;
|
|
94
|
+
openUnder?: boolean;
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
type Result = { content: Array<{ type: string; text?: string }>; details?: unknown };
|
|
@@ -618,7 +619,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
618
619
|
// Live rows wait for tool_execution_start to place them; history rows without a group render alone
|
|
619
620
|
if (!group) return live || !ready ? empty() : undefined;
|
|
620
621
|
if (group.members[0].id !== toolCallId) return empty();
|
|
621
|
-
if (context.expanded
|
|
622
|
+
if (shown(group, context.expanded)) return clickable(group, tree(group, theme), context.expanded);
|
|
622
623
|
|
|
623
624
|
const running = group.members.some((m) => !m.done);
|
|
624
625
|
const failed = group.members.filter((m) => m.error).length;
|
|
@@ -638,18 +639,24 @@ export default function (pi: ExtensionAPI) {
|
|
|
638
639
|
const mark = failed ? theme.fg("error", `${MARK} `) : " ";
|
|
639
640
|
// Always the summary, even for one call ("Ran 1 shell command"), like Claude Code; a click or ctrl+o shows each one
|
|
640
641
|
const text = summary(group, false);
|
|
641
|
-
return clickable(group, oneLine([mark + theme.fg("dim", text)], failNote));
|
|
642
|
+
return clickable(group, oneLine([mark + theme.fg("dim", text)], failNote), context.expanded);
|
|
642
643
|
};
|
|
643
644
|
|
|
645
|
+
/** Whether a group shows as a tree: ctrl+o's state, unless a click changed it since ctrl+o was last toggled. */
|
|
646
|
+
const shown = (group: Group, expanded?: boolean) => (group.open !== undefined && group.openUnder === Boolean(expanded) ? group.open : Boolean(expanded));
|
|
644
647
|
/** A row that opens or closes its group when clicked. */
|
|
645
|
-
const clickable = (group: Group, row: Component): Component =>
|
|
648
|
+
const clickable = (group: Group, row: Component, expanded?: boolean): Component =>
|
|
646
649
|
new MouseRegion(row, (event) => {
|
|
647
650
|
if (event.type !== "click" || event.button !== "left") return undefined;
|
|
648
|
-
group.open = !group
|
|
651
|
+
group.open = !shown(group, expanded);
|
|
652
|
+
group.openUnder = Boolean(expanded);
|
|
649
653
|
refresh(group);
|
|
650
654
|
return { handled: true };
|
|
651
655
|
});
|
|
652
|
-
const isOpen = (context: { expanded?: boolean; toolCallId?: string }) =>
|
|
656
|
+
const isOpen = (context: { expanded?: boolean; toolCallId?: string }) => {
|
|
657
|
+
const group = groupOf.get(context.toolCallId ?? "");
|
|
658
|
+
return group ? shown(group, context.expanded) : Boolean(context.expanded);
|
|
659
|
+
};
|
|
653
660
|
|
|
654
661
|
// The ● carries the status, like Claude Code: dim while arguments stream, accent while running, green or red when done.
|
|
655
662
|
// History rows redrawn after /reload have no execution state, so they count as done.
|
|
@@ -682,7 +689,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
682
689
|
};
|
|
683
690
|
// A row of a group opened by a click closes it again
|
|
684
691
|
const group = groupOf.get(context.toolCallId);
|
|
685
|
-
return group
|
|
692
|
+
return group && shown(group, context.expanded) ? clickable(group, row, context.expanded) : row;
|
|
686
693
|
},
|
|
687
694
|
renderResult(result, { expanded }, theme, context) {
|
|
688
695
|
// A group's first row draws every call's output in its tree
|