pi-bro 0.19.1 → 0.19.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.
- package/CHANGELOG.md +6 -0
- package/bro.ts +38 -11
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to pi-bro are documented here.
|
|
4
4
|
|
|
5
|
+
## [0.19.2] - 2026-09-30
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- Preserve Show's diagram controls, captured source, and steering when reopening and rerunning a result. Recreate missing temporary diagrams without a model call and retain the previous diagram after a failed rerun (#71).
|
|
10
|
+
|
|
5
11
|
## [0.19.1] - 2026-09-30
|
|
6
12
|
|
|
7
13
|
### Fixed
|
package/bro.ts
CHANGED
|
@@ -2942,6 +2942,12 @@ async function showBroModal(ctx: ExtensionCommandContext, options: BroModalOptio
|
|
|
2942
2942
|
options.retryLabel ?? "simplify again",
|
|
2943
2943
|
);
|
|
2944
2944
|
|
|
2945
|
+
const present = (result: ModalResult, notice = "") => {
|
|
2946
|
+
const display = result.htmlPath ? stripShowHtmlFence(result.text) : result.text;
|
|
2947
|
+
modal.setResult(display, options.retryable ?? Boolean(options.run), notice, result.source?.label, result.text, result.model);
|
|
2948
|
+
modal.setHtmlPath(result.htmlPath ?? "");
|
|
2949
|
+
};
|
|
2950
|
+
|
|
2945
2951
|
execute = (source?: BroSource) => {
|
|
2946
2952
|
if (!options.run || controller || closed) return;
|
|
2947
2953
|
const previous = current;
|
|
@@ -2958,16 +2964,14 @@ async function showBroModal(ctx: ExtensionCommandContext, options: BroModalOptio
|
|
|
2958
2964
|
if (closed || nextController.signal.aborted) return;
|
|
2959
2965
|
current = result;
|
|
2960
2966
|
options.onResult?.(result);
|
|
2961
|
-
|
|
2962
|
-
modal.setResult(display, options.retryable ?? true, "", result.source?.label, result.text, result.model);
|
|
2963
|
-
if (result.htmlPath) modal.setHtmlPath(result.htmlPath);
|
|
2967
|
+
present(result);
|
|
2964
2968
|
})
|
|
2965
2969
|
.catch((error) => {
|
|
2966
2970
|
if (closed || nextController.signal.aborted) return;
|
|
2967
2971
|
const message = error instanceof Error ? error.message : String(error);
|
|
2968
2972
|
if (previous) {
|
|
2969
2973
|
current = previous;
|
|
2970
|
-
|
|
2974
|
+
present(previous, `Retry failed: ${message}`);
|
|
2971
2975
|
} else {
|
|
2972
2976
|
modal.setError(message);
|
|
2973
2977
|
}
|
|
@@ -2980,7 +2984,7 @@ async function showBroModal(ctx: ExtensionCommandContext, options: BroModalOptio
|
|
|
2980
2984
|
if (options.text !== undefined) {
|
|
2981
2985
|
modal.setStatic(options.kind ?? "help", options.text, options.copyable ?? false);
|
|
2982
2986
|
} else if (current) {
|
|
2983
|
-
|
|
2987
|
+
present(current);
|
|
2984
2988
|
} else {
|
|
2985
2989
|
execute();
|
|
2986
2990
|
}
|
|
@@ -3479,10 +3483,14 @@ async function openBtwModal(
|
|
|
3479
3483
|
}
|
|
3480
3484
|
|
|
3481
3485
|
export default async function bro(pi: ExtensionAPI) {
|
|
3482
|
-
let lastResult:
|
|
3486
|
+
let lastResult: ModalResult | undefined;
|
|
3487
|
+
let lastShowSteering: string | undefined;
|
|
3483
3488
|
let btwThread: BtwThread | undefined;
|
|
3484
|
-
const remember = (result: ModalResult) => {
|
|
3485
|
-
if (result.source)
|
|
3489
|
+
const remember = (result: ModalResult, showSteering?: string) => {
|
|
3490
|
+
if (result.source) {
|
|
3491
|
+
lastResult = result;
|
|
3492
|
+
lastShowSteering = showSteering;
|
|
3493
|
+
}
|
|
3486
3494
|
};
|
|
3487
3495
|
|
|
3488
3496
|
pi.on("session_start", async (_event, _ctx) => {
|
|
@@ -3659,7 +3667,7 @@ export default async function bro(pi: ExtensionAPI) {
|
|
|
3659
3667
|
loadingText: "Drawing what happened…",
|
|
3660
3668
|
retryLabel: "show again",
|
|
3661
3669
|
run: runShow,
|
|
3662
|
-
onResult: remember,
|
|
3670
|
+
onResult: (result) => remember(result, steering),
|
|
3663
3671
|
});
|
|
3664
3672
|
} catch (error) {
|
|
3665
3673
|
ctx.ui.notify(withDoctor(error), "error");
|
|
@@ -3860,10 +3868,29 @@ export default async function bro(pi: ExtensionAPI) {
|
|
|
3860
3868
|
return;
|
|
3861
3869
|
}
|
|
3862
3870
|
|
|
3871
|
+
const steering = lastShowSteering;
|
|
3872
|
+
if (steering !== undefined) {
|
|
3873
|
+
const html = extractShowHtml(lastResult.text);
|
|
3874
|
+
// Temp files may have been cleaned by the OS or another Bro session.
|
|
3875
|
+
if (html && ctx.mode === "tui") {
|
|
3876
|
+
try { lastResult.htmlPath = await writeShowHtml(html); }
|
|
3877
|
+
catch (error) {
|
|
3878
|
+
lastResult.htmlPath = undefined;
|
|
3879
|
+
ctx.ui.notify(`Diagram file unavailable: ${errorMessage(error)}`, "warning");
|
|
3880
|
+
}
|
|
3881
|
+
}
|
|
3882
|
+
}
|
|
3863
3883
|
await showBroModal(ctx, {
|
|
3864
3884
|
result: lastResult,
|
|
3865
|
-
|
|
3866
|
-
|
|
3885
|
+
loadingText: steering !== undefined ? "Drawing what happened…" : undefined,
|
|
3886
|
+
retryLabel: steering !== undefined ? "show again" : undefined,
|
|
3887
|
+
run: steering === undefined ? run : async (signal, source, onProgress) => {
|
|
3888
|
+
if (!source) throw new Error("No captured Show source.");
|
|
3889
|
+
const result = await runShowExplanation(source.text, steering, signal, await readSettings(), onProgress);
|
|
3890
|
+
const html = extractShowHtml(result.text);
|
|
3891
|
+
return { source, ...result, ...(html ? { htmlPath: await writeShowHtml(html) } : {}) };
|
|
3892
|
+
},
|
|
3893
|
+
onResult: (result) => remember(result, steering),
|
|
3867
3894
|
});
|
|
3868
3895
|
return;
|
|
3869
3896
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-bro",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.2",
|
|
4
4
|
"description": "An Earendil Pi extension that explains pasted text, assistant responses, local documents, public webpages, and recent session turns (as shapes) in a context-isolated window, opens a sandboxed side conversation with /bro btw, and provides a second-opinion advisor tool for executor agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|