pi-render-btw 0.6.12 → 0.6.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/CHANGELOG.md +5 -0
- package/README.md +1 -1
- package/extensions/btw-transcript.test.ts +69 -0
- package/extensions/btw.ts +72 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.13 — 2026-09-14
|
|
4
|
+
|
|
5
|
+
- Keep the BTW/Peek/Tool Output title-row `[Esc]` affordance visible beside long titles.
|
|
6
|
+
- Highlight `[Esc]` on hover and close the current surface on a normalized or legacy SGR mouse click.
|
|
7
|
+
|
|
3
8
|
## 0.6.12 — 2026-09-13
|
|
4
9
|
|
|
5
10
|
- Recover interrupted streaming turns as closed history after reload.
|
package/README.md
CHANGED
|
@@ -128,7 +128,7 @@ pi install /path/to/pi-render-btw
|
|
|
128
128
|
- normalized mouse hover highlights a block and a left click selects it; press/release events do not change selection
|
|
129
129
|
- `M` copies the selected message; `o` opens it read-only in nvim
|
|
130
130
|
- `Esc`, `q`, or `Ctrl+C` returns to the BTW composer; press `Esc` again in the composer to dismiss BTW
|
|
131
|
-
- the Peek and Tool Output headers show `[Esc]
|
|
131
|
+
- the Peek and Tool Output headers show a hoverable `[Esc]` close/back affordance; wheel input is handled locally without changing the main viewport
|
|
132
132
|
|
|
133
133
|
### `/btw:clear`
|
|
134
134
|
|
|
@@ -676,6 +676,75 @@ describe("BTW transcript message layout", () => {
|
|
|
676
676
|
expect(dismissed).toBe(1);
|
|
677
677
|
});
|
|
678
678
|
|
|
679
|
+
it("keeps the title [Esc] affordance visible, highlights it on hover, and closes on click", () => {
|
|
680
|
+
let dismissed = 0;
|
|
681
|
+
const component = new BtwOverlayComponent(
|
|
682
|
+
tui,
|
|
683
|
+
theme,
|
|
684
|
+
keybindings,
|
|
685
|
+
() => [],
|
|
686
|
+
() => null,
|
|
687
|
+
() => "contextual",
|
|
688
|
+
() => {},
|
|
689
|
+
() => { dismissed++; },
|
|
690
|
+
() => {},
|
|
691
|
+
);
|
|
692
|
+
|
|
693
|
+
const lines = component.render(24);
|
|
694
|
+
expect(lines[1]).toMatch(/\[Esc\]│$/);
|
|
695
|
+
|
|
696
|
+
const hover = component.handleMouse({ type: "move", button: "none", x: 20, y: 1 } as any);
|
|
697
|
+
expect((component as any).hoveredEscapeHint).toBe(true);
|
|
698
|
+
expect(hover).toEqual({ handled: true, render: true });
|
|
699
|
+
|
|
700
|
+
const click = component.handleMouse({ type: "click", button: "left", x: 20, y: 1 } as any);
|
|
701
|
+
expect(click).toEqual({ handled: true, render: false });
|
|
702
|
+
expect(dismissed).toBe(1);
|
|
703
|
+
});
|
|
704
|
+
|
|
705
|
+
it("uses the title [Esc] button in Peek as back, not overlay dismissal", () => {
|
|
706
|
+
let dismissed = 0;
|
|
707
|
+
const component = new BtwOverlayComponent(
|
|
708
|
+
tui,
|
|
709
|
+
theme,
|
|
710
|
+
keybindings,
|
|
711
|
+
() => [],
|
|
712
|
+
() => null,
|
|
713
|
+
() => "contextual",
|
|
714
|
+
() => {},
|
|
715
|
+
() => { dismissed++; },
|
|
716
|
+
() => {},
|
|
717
|
+
);
|
|
718
|
+
|
|
719
|
+
component.handleInput("\x10");
|
|
720
|
+
component.render(80);
|
|
721
|
+
component.handleMouse({ type: "click", button: "left", x: 76, y: 1 } as any);
|
|
722
|
+
|
|
723
|
+
expect((component as any).peekState.active).toBe(false);
|
|
724
|
+
expect(dismissed).toBe(0);
|
|
725
|
+
});
|
|
726
|
+
|
|
727
|
+
it("closes from the title [Esc] button through the raw SGR fallback", () => {
|
|
728
|
+
let dismissed = 0;
|
|
729
|
+
const component = new BtwOverlayComponent(
|
|
730
|
+
tui,
|
|
731
|
+
theme,
|
|
732
|
+
keybindings,
|
|
733
|
+
() => [],
|
|
734
|
+
() => null,
|
|
735
|
+
() => "contextual",
|
|
736
|
+
() => {},
|
|
737
|
+
() => { dismissed++; },
|
|
738
|
+
() => {},
|
|
739
|
+
);
|
|
740
|
+
|
|
741
|
+
component.render(80);
|
|
742
|
+
component.handleInput("\x1b[<0;77;2M");
|
|
743
|
+
component.handleInput("\x1b[<0;77;2m");
|
|
744
|
+
|
|
745
|
+
expect(dismissed).toBe(1);
|
|
746
|
+
});
|
|
747
|
+
|
|
679
748
|
it("configures fd-backed completion for @ path suggestions", () => {
|
|
680
749
|
const component = new BtwOverlayComponent(
|
|
681
750
|
tui,
|
package/extensions/btw.ts
CHANGED
|
@@ -1175,6 +1175,8 @@ export class BtwOverlayComponent extends Container implements Focusable {
|
|
|
1175
1175
|
private peekToolPreviewLines: string[] = [];
|
|
1176
1176
|
private peekToolPreviewScrollOffset = 0;
|
|
1177
1177
|
private expandedToolId: number | null = null;
|
|
1178
|
+
private hoveredEscapeHint = false;
|
|
1179
|
+
private rawEscapePress = false;
|
|
1178
1180
|
/** The same bounded preview is used by Peek and by the live BTW panel. */
|
|
1179
1181
|
private toolPreviewParent: "peek" | "live" | null = null;
|
|
1180
1182
|
private liveToolPreviewBlock: PeekBlock | null = null;
|
|
@@ -1334,9 +1336,17 @@ export class BtwOverlayComponent extends Container implements Focusable {
|
|
|
1334
1336
|
}
|
|
1335
1337
|
|
|
1336
1338
|
private titleLine(title: string, innerWidth: number): string {
|
|
1337
|
-
const
|
|
1338
|
-
const
|
|
1339
|
-
|
|
1339
|
+
const escapeLabel = "[Esc]";
|
|
1340
|
+
const escapeHint = this.hoveredEscapeHint
|
|
1341
|
+
? this.theme.fg("text", this.theme.bold(escapeLabel))
|
|
1342
|
+
: this.theme.fg("dim", escapeLabel);
|
|
1343
|
+
const escapeWidth = visibleWidth(escapeLabel);
|
|
1344
|
+
// Reserve the close label before truncating the title so a long tool name
|
|
1345
|
+
// can never hide the only visible mouse/keyboard dismissal affordance.
|
|
1346
|
+
const titleWidth = Math.max(0, innerWidth - escapeWidth - 1);
|
|
1347
|
+
const clippedTitle = truncateToWidth(title, titleWidth, "");
|
|
1348
|
+
const gap = Math.max(1, innerWidth - visibleWidth(clippedTitle) - escapeWidth);
|
|
1349
|
+
return this.frameLine(`${clippedTitle}${" ".repeat(gap)}${escapeHint}`, innerWidth);
|
|
1340
1350
|
}
|
|
1341
1351
|
|
|
1342
1352
|
private wrapTranscript(innerWidth: number): string[] {
|
|
@@ -1569,6 +1579,23 @@ export class BtwOverlayComponent extends Container implements Focusable {
|
|
|
1569
1579
|
return null;
|
|
1570
1580
|
}
|
|
1571
1581
|
|
|
1582
|
+
/** The title row is line 2 in one-based local coordinates. */
|
|
1583
|
+
private isEscapeHintHit(x: number, y: number): boolean {
|
|
1584
|
+
const labelWidth = visibleWidth("[Esc]");
|
|
1585
|
+
const labelStart = this.lastRenderWidth - labelWidth;
|
|
1586
|
+
return y === 2 && x >= labelStart && x < this.lastRenderWidth;
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
private closeEscapeTarget(): void {
|
|
1590
|
+
if (this.toolPreviewParent !== null) {
|
|
1591
|
+
this.exitToolPreview();
|
|
1592
|
+
} else if (this.peekState.active) {
|
|
1593
|
+
this.exitPeekMode();
|
|
1594
|
+
} else {
|
|
1595
|
+
this.onDismissCallback();
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1572
1599
|
/**
|
|
1573
1600
|
* Viewer-local mouse seam. Newer Pi TUI hosts call `handleMouse` with
|
|
1574
1601
|
* zero-based `{ type, button, x, y, wheelDelta }` events; older hosts and
|
|
@@ -1612,6 +1639,32 @@ export class BtwOverlayComponent extends Container implements Focusable {
|
|
|
1612
1639
|
delta: event.wheelDelta,
|
|
1613
1640
|
};
|
|
1614
1641
|
|
|
1642
|
+
const overEscapeHint = this.isEscapeHintHit(normalized.x, normalized.y);
|
|
1643
|
+
if (normalized.action === "move" || normalized.action === "drag") {
|
|
1644
|
+
const hoverChanged = overEscapeHint !== this.hoveredEscapeHint;
|
|
1645
|
+
this.hoveredEscapeHint = overEscapeHint;
|
|
1646
|
+
if (overEscapeHint) {
|
|
1647
|
+
return { handled: true, render: hoverChanged };
|
|
1648
|
+
}
|
|
1649
|
+
// Continue routing a move outside the title to update transcript/block
|
|
1650
|
+
// hover state. In preview mode there is no other hover target.
|
|
1651
|
+
if (hoverChanged && this.toolPreviewParent !== null) {
|
|
1652
|
+
return { handled: true, render: true };
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
if (overEscapeHint && normalized.button === 0) {
|
|
1656
|
+
if (normalized.action === "press") {
|
|
1657
|
+
return { handled: true, capture: true, render: false };
|
|
1658
|
+
}
|
|
1659
|
+
if (normalized.action === "click") {
|
|
1660
|
+
this.closeEscapeTarget();
|
|
1661
|
+
return { handled: true, render: false };
|
|
1662
|
+
}
|
|
1663
|
+
if (normalized.action === "release") {
|
|
1664
|
+
return { handled: true, render: false };
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1615
1668
|
if (normalized.action === "wheel") {
|
|
1616
1669
|
const delta = Math.trunc(normalized.delta ?? 0);
|
|
1617
1670
|
if (this.toolPreviewParent !== null) {
|
|
@@ -1741,9 +1794,22 @@ export class BtwOverlayComponent extends Container implements Focusable {
|
|
|
1741
1794
|
}
|
|
1742
1795
|
return;
|
|
1743
1796
|
}
|
|
1744
|
-
// Consume bounded SGR button events locally.
|
|
1745
|
-
// click dispatch,
|
|
1746
|
-
|
|
1797
|
+
// Consume bounded SGR button events locally. Older hosts do not expose
|
|
1798
|
+
// normalized click dispatch, so retain the close-button press/release
|
|
1799
|
+
// pair as the one actionable fallback; transcript clicks remain read-only.
|
|
1800
|
+
if (mouseEvent) {
|
|
1801
|
+
const overEscapeHint = this.isEscapeHintHit(mouseEvent.x, mouseEvent.y);
|
|
1802
|
+
this.handleMouse(mouseEvent);
|
|
1803
|
+
if (mouseEvent.button === 0 && mouseEvent.action === "press") {
|
|
1804
|
+
this.rawEscapePress = overEscapeHint;
|
|
1805
|
+
} else if (mouseEvent.button === 0 && mouseEvent.action === "release") {
|
|
1806
|
+
const close = this.rawEscapePress && overEscapeHint;
|
|
1807
|
+
this.rawEscapePress = false;
|
|
1808
|
+
if (close) this.closeEscapeTarget();
|
|
1809
|
+
}
|
|
1810
|
+
return;
|
|
1811
|
+
}
|
|
1812
|
+
this.rawEscapePress = false;
|
|
1747
1813
|
|
|
1748
1814
|
// Peek mode active → route all input to peek handler
|
|
1749
1815
|
if (this.peekState.active) {
|
package/package.json
CHANGED