@xynogen/pix-pretty 1.33.0 → 1.34.0
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/package.json +1 -1
- package/src/command-preview.ts +2 -1
- package/src/gate-overlay.ts +3 -2
- package/src/utils.ts +34 -3
package/package.json
CHANGED
package/src/command-preview.ts
CHANGED
|
@@ -10,7 +10,8 @@ export function commandPreview(
|
|
|
10
10
|
state: Record<string, unknown>,
|
|
11
11
|
invalidate: () => void,
|
|
12
12
|
expanded = false,
|
|
13
|
-
|
|
13
|
+
/** Body column: under the tool name (2-col status glyph + space). */
|
|
14
|
+
indent = 3,
|
|
14
15
|
) {
|
|
15
16
|
type Slot = { code: string; language: string | undefined; theme: typeof theme; styled: string };
|
|
16
17
|
let slot = state.commandPreview as Slot | undefined;
|
package/src/gate-overlay.ts
CHANGED
|
@@ -36,7 +36,7 @@ export interface OverlayResult {
|
|
|
36
36
|
action: OverlayAction;
|
|
37
37
|
/** Only present when action === "approved" and mode === "sudo". */
|
|
38
38
|
password?: string;
|
|
39
|
-
/** True when password validation exhausted every allowed attempt. */
|
|
39
|
+
/** True when password validation exhausted every allowed attempt (action is "denied"). */
|
|
40
40
|
passwordAttemptsExhausted?: boolean;
|
|
41
41
|
/** Value of the picked choice (absent on timeout or esc). */
|
|
42
42
|
choice?: string;
|
|
@@ -368,7 +368,8 @@ export function showOverlay(ui: OverlayUI, config: OverlayConfig): Promise<Overl
|
|
|
368
368
|
passwordAttempts += 1;
|
|
369
369
|
const maxAttempts = config.maxPasswordAttempts ?? 3;
|
|
370
370
|
if (passwordAttempts >= maxAttempts) {
|
|
371
|
-
|
|
371
|
+
// Fail closed: a caller that ignores the flag must not run anything.
|
|
372
|
+
finish({ action: "denied", passwordAttemptsExhausted: true });
|
|
372
373
|
return;
|
|
373
374
|
}
|
|
374
375
|
maskedInput.setValue("");
|
package/src/utils.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { isAbsolute, relative, resolve } from "node:path";
|
|
2
2
|
import { pathToFileURL } from "node:url";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
type Component,
|
|
5
|
+
getCapabilities,
|
|
6
|
+
hyperlink,
|
|
7
|
+
MouseRegion,
|
|
8
|
+
truncateToWidth,
|
|
9
|
+
visibleWidth,
|
|
10
|
+
} from "@earendil-works/pi-tui";
|
|
4
11
|
|
|
5
12
|
import {
|
|
6
13
|
ANSI_CAPTURE_RE,
|
|
@@ -597,15 +604,39 @@ export function sectionRule(line: string, theme: MutedTheme, width: number): str
|
|
|
597
604
|
}
|
|
598
605
|
|
|
599
606
|
/**
|
|
600
|
-
*
|
|
601
|
-
*
|
|
607
|
+
* Make a custom message/entry card toggle on left click, like Pi's tool results.
|
|
608
|
+
* Pi gives custom renderers no click handling, so a renderer returns
|
|
609
|
+
* `clickToggle(expanded, (open) => card(open))`: a left click rebuilds the card
|
|
610
|
+
* with the flipped state. A host Ctrl+O rebuild resets it to the host `expanded`.
|
|
611
|
+
* Other mouse events are left unhandled (drag selects text, wheel scrolls).
|
|
602
612
|
*/
|
|
613
|
+
export function clickToggle(
|
|
614
|
+
expanded: boolean,
|
|
615
|
+
build: (expanded: boolean) => Component,
|
|
616
|
+
): MouseRegion {
|
|
617
|
+
let open = expanded;
|
|
618
|
+
let view = build(open);
|
|
619
|
+
return new MouseRegion(
|
|
620
|
+
{ render: (width) => view.render(width), invalidate: () => view.invalidate() },
|
|
621
|
+
(event) => {
|
|
622
|
+
if (event.type !== "click" || event.button !== "left") return undefined;
|
|
623
|
+
open = !open;
|
|
624
|
+
view = build(open);
|
|
625
|
+
return { handled: true };
|
|
626
|
+
},
|
|
627
|
+
);
|
|
628
|
+
}
|
|
629
|
+
|
|
603
630
|
/**
|
|
604
631
|
* Body indent: one tab. pi-tui renders `\t` as 3 cells, the title column after
|
|
605
632
|
* the 2-cell status icon + space.
|
|
606
633
|
*/
|
|
607
634
|
export const BODY_PAD = "\t";
|
|
608
635
|
|
|
636
|
+
/**
|
|
637
|
+
* One tool-result body line, aligned under the tool title. An `=== label ===` line
|
|
638
|
+
* becomes a full-width section rule. Other lines go through `paint`.
|
|
639
|
+
*/
|
|
609
640
|
export function bodyLine(
|
|
610
641
|
line: string,
|
|
611
642
|
theme: MutedTheme,
|