pi-render-btw 0.6.19 → 0.6.20
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
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.20 — 2026-11-23
|
|
4
|
+
|
|
5
|
+
- Make the BTW transcript's `▎` a persistent selected-block rail: the newest block starts selected, click any block to move focus, and hover no longer moves it.
|
|
6
|
+
- Keep THINKING blocks focusable and visible; click a tool block to toggle its inline show-more details while preserving the full Tool Output preview.
|
|
7
|
+
- Support click-to-focus and tool toggling on hosts that deliver raw SGR mouse press/release input, and ignore clicks on the frame and scrollbar rail.
|
|
8
|
+
|
|
3
9
|
## 0.6.19 — 2026-11-23
|
|
4
10
|
|
|
5
11
|
- Fix BTW prompts submitted during streaming by always routing them as steering input, including rapid submits that race the first run's startup.
|
package/README.md
CHANGED
|
@@ -95,6 +95,8 @@ pi install /path/to/pi-render-btw
|
|
|
95
95
|
- `Alt+/` toggles focus between BTW and the main editor without closing the overlay
|
|
96
96
|
- while BTW is streaming, `Enter` steers the BTW agent after its current tool or assistant turn instead of rejecting the new prompt
|
|
97
97
|
- `Ctrl+X` stops only the active BTW agent/tool run and clears its queued BTW prompts; the overlay and BTW session stay ready for the next message
|
|
98
|
+
- the newest transcript block starts focused with a persistent `▎` rail; clicking any block moves that focus without hover changing it
|
|
99
|
+
- clicking a focused tool row toggles its `[click more]` / `[click less]` details; `Ctrl+O` and title `[preview]` still open the full read-only Tool Output
|
|
98
100
|
- `Ctrl+Alt+W` is a fallback focus toggle for terminals that do not deliver `Alt+/` as a usable shortcut
|
|
99
101
|
- `Ctrl+G` opens the current BTW draft in `$VISUAL`/`$EDITOR` (falling back to `nano`) and reads it back when the editor exits successfully
|
|
100
102
|
- the composer uses Pi's native editor behavior for undo, paste, prompt history, and Tab file-path completion (including `@` prefixes) relative to the BTW working directory; `Alt+Up` (`a-up`/`alt+up`) recalls a submitted draft
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# BTW Agent View 焦點互動 Implementation Plan
|
|
2
|
+
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> 此目錄由 npm tarball 建立,沒有 Git metadata;本次不建立 commit、tag 或 publish。
|
|
5
|
+
|
|
6
|
+
**Goal:** BTW transcript 採用 Agent View 風格的 selected-block focus:`▎` 常駐於當前焦點 block,滑鼠 hover 不改變焦點;點擊任一 block 切換焦點,點擊工具 block 同時切換其 show-more 內容,並保留 THINKING block。
|
|
7
|
+
|
|
8
|
+
**Architecture:** `BtwOverlayComponent` 以 `liveFocusedEntryId` 作為唯一 transcript selection state;首次 render 選擇最新可互動 block,之後只由 explicit click 改變。render 時以 `transcriptLineEntryIds` 將 rail 套到選定 block 的所有內容行;tool block 沿用既有 `liveExpandedToolCallId` 做同一焦點工具的 inline show-more toggle,完整 Tool Output preview 仍可由 Ctrl+O 或 title `[preview]` 進入。
|
|
9
|
+
|
|
10
|
+
**Tech Stack:** TypeScript、Pi TUI、Vitest。
|
|
11
|
+
|
|
12
|
+
## Global Constraints
|
|
13
|
+
|
|
14
|
+
- transcript hover 不得修改 `liveFocusedEntryId` 或 rail。
|
|
15
|
+
- explicit left click 任一可互動 block 都必須更新 focus;非 tool click 清除 stale tool focus。
|
|
16
|
+
- tool click 必須更新 focus,並在同一 tool 上切換 `[click more]` / `[click less]`;不影響 Ctrl+O 的唯讀完整 preview。
|
|
17
|
+
- THINKING 保持現有 badge、Markdown rendering、streaming marker,且可被 focus。
|
|
18
|
+
- rail 使用 `▎`,不改變右側 scrollbar 的所有權。
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
### Task 1: 寫 focus 與工具 click 的失敗測試
|
|
23
|
+
|
|
24
|
+
**Files:**
|
|
25
|
+
- Test: `extensions/btw-transcript.test.ts`
|
|
26
|
+
|
|
27
|
+
**Interfaces:**
|
|
28
|
+
- `BtwOverlayComponent.handleMouse()` 的 explicit `click` 為 selection 邊界。
|
|
29
|
+
- `BtwOverlayComponent.render()` 對 selected block 的可見行輸出 `▎`。
|
|
30
|
+
|
|
31
|
+
- [ ] 建立包含 USER、THINKING、TOOL、ASSISTANT 的 fixture。
|
|
32
|
+
- [ ] 斷言初始 render 的最新 block 有 `▎`;mouse move 到別 block 後 rail 不變。
|
|
33
|
+
- [ ] 斷言 click THINKING 後 THINKING 行有 rail 且內容仍存在。
|
|
34
|
+
- [ ] 斷言 click tool 後 tool 取得 rail、展開 `[click less]` 與 details;再次 click 收合為 `[click more]`。
|
|
35
|
+
- [ ] 執行 `./node_modules/.bin/vitest --run extensions/btw-transcript.test.ts`,確認測試在舊 hover 實作失敗。
|
|
36
|
+
|
|
37
|
+
### Task 2: 將 transcript rail 改為 selected-block render
|
|
38
|
+
|
|
39
|
+
**Files:**
|
|
40
|
+
- Modify: `extensions/btw.ts`
|
|
41
|
+
|
|
42
|
+
**Interfaces:**
|
|
43
|
+
- `liveFocusedEntryId: number | null` 是唯一 transcript focus state。
|
|
44
|
+
- `ensureLiveTranscriptFocus(entries)` 在無有效 focus 時選擇最新 non-boundary entry。
|
|
45
|
+
- `applyFocusedTranscriptRail(lines, entryIds)` 在 selected entry 所有實質行套用 `▎`。
|
|
46
|
+
|
|
47
|
+
- [ ] 移除 `liveHoveredEntryId` 的 state、render 分支與 live transcript move handling。
|
|
48
|
+
- [ ] 在 build transcript 前確認 initial selected block,在 line IDs 建好後將 rail 套在 selected block 的所有實質行。
|
|
49
|
+
- [ ] 保持 THINKING 與 streaming text 的既有 rendering,讓其 entry ID 可接收 rail。
|
|
50
|
+
|
|
51
|
+
### Task 3: 對齊 click focus 與 tool show-more
|
|
52
|
+
|
|
53
|
+
**Files:**
|
|
54
|
+
- Modify: `extensions/btw.ts`
|
|
55
|
+
- Test: `extensions/btw-transcript.test.ts`
|
|
56
|
+
- Modify: `README.md`
|
|
57
|
+
|
|
58
|
+
**Interfaces:**
|
|
59
|
+
- `focusLiveTranscriptEntry(entryId)` 僅由 explicit click 呼叫。
|
|
60
|
+
- `liveExpandedToolCallId` 維持 selected tool 的 inline show-more toggle。
|
|
61
|
+
|
|
62
|
+
- [ ] click 一般 block:更新 `liveFocusedEntryId`、清除 stale tool focus,不展開工具。
|
|
63
|
+
- [ ] click tool block:更新 focus,切換同 tool 的 expanded state;點不同 tool 時切換至該 tool。
|
|
64
|
+
- [ ] README 說明常駐 selected rail、click-to-focus 與工具 show-more。
|
|
65
|
+
|
|
66
|
+
### Task 4: 驗證
|
|
67
|
+
|
|
68
|
+
**Files:**
|
|
69
|
+
- Test: `extensions/btw-transcript.test.ts`
|
|
70
|
+
|
|
71
|
+
- [ ] 執行 focused suite:`./node_modules/.bin/vitest --run extensions/btw-transcript.test.ts`。
|
|
72
|
+
- [ ] 執行全套:`npm test`。
|
|
73
|
+
- [ ] 執行變更檔案的 TypeScript check:`./node_modules/.bin/tsc --noEmit --target es2022 --module nodenext --moduleResolution nodenext --allowImportingTsExtensions --skipLibCheck extensions/btw.ts extensions/btw-transcript.test.ts`。
|
|
74
|
+
- [ ] 由獨立 reviewer 檢查 rail width、scrollbar、click scope、thinking preservation 與 tool-preview toggle。
|
|
75
|
+
|
|
76
|
+
## Self-review
|
|
77
|
+
|
|
78
|
+
- Spec coverage:Task 1 先把 user 要求變成 red tests;Task 2 移除 hover-driven rail;Task 3 實作 click focus、tool toggle 與文件;Task 4 驗證 rendering/integration risk。
|
|
79
|
+
- Placeholder scan:沒有 TBD、TODO 或模糊交付項。
|
|
80
|
+
- Type consistency:每個 transcript row 維持 `entryId` 對應;selection 只保存 entry ID,expanded tool 只保存 tool call ID。
|
|
@@ -42,7 +42,7 @@ describe("BTW transcript message layout", () => {
|
|
|
42
42
|
{ id: 1, turnId: 1, type: "user-message", text: "Prompt" },
|
|
43
43
|
]);
|
|
44
44
|
|
|
45
|
-
expect(lines.slice(0, 2)).toEqual(["
|
|
45
|
+
expect(lines.slice(0, 2)).toEqual(["▎USER ", "▎ Prompt"]);
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
it("keeps assistant heading and response on separate lines", () => {
|
|
@@ -50,8 +50,8 @@ describe("BTW transcript message layout", () => {
|
|
|
50
50
|
{ id: 1, turnId: 1, type: "assistant-text", text: "Response", streaming: false },
|
|
51
51
|
]);
|
|
52
52
|
|
|
53
|
-
expect(lines[0]).toBe("
|
|
54
|
-
expect(lines[1].startsWith("
|
|
53
|
+
expect(lines[0]).toBe("▎ASSISTANT ");
|
|
54
|
+
expect(lines[1].startsWith("▎ Response")).toBe(true);
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
it("opens Peek with Ctrl+P even when the composer contains a draft", () => {
|
|
@@ -531,6 +531,112 @@ describe("BTW transcript message layout", () => {
|
|
|
531
531
|
}
|
|
532
532
|
});
|
|
533
533
|
|
|
534
|
+
it("keeps a persistent clicked rail, ignores transcript hover, and toggles tool details", () => {
|
|
535
|
+
const entries = [
|
|
536
|
+
{ id: 1, turnId: 1, type: "user-message", text: "Question" },
|
|
537
|
+
{ id: 2, turnId: 1, type: "thinking", text: "Reasoning line one\nReasoning line two", streaming: false },
|
|
538
|
+
{ id: 3, turnId: 1, type: "tool-call", toolCallId: "call-focus", toolName: "read", args: "src/index.ts" },
|
|
539
|
+
{ id: 4, turnId: 1, type: "assistant-text", text: "Answer", streaming: false },
|
|
540
|
+
] as any;
|
|
541
|
+
const component = new BtwOverlayComponent(
|
|
542
|
+
tui,
|
|
543
|
+
theme,
|
|
544
|
+
keybindings,
|
|
545
|
+
() => entries,
|
|
546
|
+
() => null,
|
|
547
|
+
() => "contextual",
|
|
548
|
+
() => {},
|
|
549
|
+
() => {},
|
|
550
|
+
() => {},
|
|
551
|
+
);
|
|
552
|
+
|
|
553
|
+
let lines = component.render(80);
|
|
554
|
+
expect(lines.some((line) => line.includes("▎") && line.includes("ASSISTANT"))).toBe(true);
|
|
555
|
+
const contentTop = (component as any).transcriptContentTop as number;
|
|
556
|
+
const lineEntryIds = (component as any).transcriptLineEntryIds as Array<number | null>;
|
|
557
|
+
const hostRowFor = (entryId: number) => contentTop - 1 + lineEntryIds.indexOf(entryId);
|
|
558
|
+
|
|
559
|
+
component.handleMouse({ type: "click", button: "left", x: 5, y: hostRowFor(2) } as any);
|
|
560
|
+
expect((component as any).liveFocusedEntryId).toBe(2);
|
|
561
|
+
lines = component.render(80);
|
|
562
|
+
expect(lines.filter((line) => line.includes("▎")).length).toBeGreaterThanOrEqual(2);
|
|
563
|
+
expect(lines.some((line) => line.includes("THINKING"))).toBe(true);
|
|
564
|
+
|
|
565
|
+
component.handleMouse({ type: "move", button: "none", x: 5, y: hostRowFor(1) } as any);
|
|
566
|
+
expect((component as any).liveFocusedEntryId).toBe(2);
|
|
567
|
+
|
|
568
|
+
component.handleMouse({ type: "click", button: "left", x: 5, y: hostRowFor(3) } as any);
|
|
569
|
+
expect((component as any).liveFocusedEntryId).toBe(3);
|
|
570
|
+
expect((component as any).liveExpandedToolCallId).toBe("call-focus");
|
|
571
|
+
expect(component.render(80).join("\n")).toContain("[click less]");
|
|
572
|
+
|
|
573
|
+
component.handleMouse({ type: "click", button: "left", x: 5, y: hostRowFor(3) } as any);
|
|
574
|
+
expect((component as any).liveExpandedToolCallId).toBeNull();
|
|
575
|
+
expect(component.render(80).join("\n")).toContain("[click more]");
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
it("uses raw SGR clicks to focus blocks and toggle a tool", () => {
|
|
579
|
+
const entries = [
|
|
580
|
+
{ id: 1, turnId: 1, type: "user-message", text: "Question" },
|
|
581
|
+
{ id: 2, turnId: 1, type: "tool-call", toolCallId: "call-sgr", toolName: "read", args: "src/index.ts" },
|
|
582
|
+
{ id: 3, turnId: 1, type: "assistant-text", text: "Answer", streaming: false },
|
|
583
|
+
] as any;
|
|
584
|
+
const component = new BtwOverlayComponent(
|
|
585
|
+
tui,
|
|
586
|
+
theme,
|
|
587
|
+
keybindings,
|
|
588
|
+
() => entries,
|
|
589
|
+
() => null,
|
|
590
|
+
() => "contextual",
|
|
591
|
+
() => {},
|
|
592
|
+
() => {},
|
|
593
|
+
() => {},
|
|
594
|
+
);
|
|
595
|
+
|
|
596
|
+
component.render(80);
|
|
597
|
+
const contentTop = (component as any).transcriptContentTop as number;
|
|
598
|
+
const lineEntryIds = (component as any).transcriptLineEntryIds as Array<number | null>;
|
|
599
|
+
const rawClick = (entryId: number) => {
|
|
600
|
+
const y = contentTop + lineEntryIds.indexOf(entryId);
|
|
601
|
+
component.handleInput(`\x1b[<0;5;${y}M`);
|
|
602
|
+
component.handleInput(`\x1b[<0;5;${y}m`);
|
|
603
|
+
};
|
|
604
|
+
|
|
605
|
+
rawClick(1);
|
|
606
|
+
expect((component as any).liveFocusedEntryId).toBe(1);
|
|
607
|
+
|
|
608
|
+
rawClick(2);
|
|
609
|
+
expect((component as any).liveFocusedEntryId).toBe(2);
|
|
610
|
+
expect((component as any).liveExpandedToolCallId).toBe("call-sgr");
|
|
611
|
+
});
|
|
612
|
+
|
|
613
|
+
it("does not focus or toggle a tool when clicking the scrollbar rail", () => {
|
|
614
|
+
const entries = [
|
|
615
|
+
{ id: 1, turnId: 1, type: "tool-call", toolCallId: "call-rail", toolName: "read", args: "src/index.ts" },
|
|
616
|
+
{ id: 2, turnId: 1, type: "assistant-text", text: "Answer", streaming: false },
|
|
617
|
+
] as any;
|
|
618
|
+
const component = new BtwOverlayComponent(
|
|
619
|
+
tui,
|
|
620
|
+
theme,
|
|
621
|
+
keybindings,
|
|
622
|
+
() => entries,
|
|
623
|
+
() => null,
|
|
624
|
+
() => "contextual",
|
|
625
|
+
() => {},
|
|
626
|
+
() => {},
|
|
627
|
+
() => {},
|
|
628
|
+
);
|
|
629
|
+
|
|
630
|
+
component.render(80);
|
|
631
|
+
const contentTop = (component as any).transcriptContentTop as number;
|
|
632
|
+
const lineEntryIds = (component as any).transcriptLineEntryIds as Array<number | null>;
|
|
633
|
+
const toolHostRow = contentTop - 1 + lineEntryIds.indexOf(1);
|
|
634
|
+
component.handleMouse({ type: "click", button: "left", x: 78, y: toolHostRow } as any);
|
|
635
|
+
|
|
636
|
+
expect((component as any).liveFocusedEntryId).toBe(2);
|
|
637
|
+
expect((component as any).liveExpandedToolCallId).toBeNull();
|
|
638
|
+
});
|
|
639
|
+
|
|
534
640
|
it("focuses and expands a live tool, scrolls locally, and opens Ctrl+O output", () => {
|
|
535
641
|
const entries = [
|
|
536
642
|
{ id: 1, turnId: 1, type: "tool-call", toolCallId: "call-1", toolName: "write", args: "compact input" },
|
|
@@ -567,10 +673,10 @@ describe("BTW transcript message layout", () => {
|
|
|
567
673
|
const hostToolRow = contentTop - 1;
|
|
568
674
|
component.handleMouse({ type: "press", button: "left", x: 5, y: hostToolRow } as any);
|
|
569
675
|
component.handleMouse({ type: "release", button: "left", x: 5, y: hostToolRow } as any);
|
|
570
|
-
expect((component as any).liveFocusedToolCallId).
|
|
676
|
+
expect((component as any).liveFocusedToolCallId).toBe("call-1");
|
|
571
677
|
|
|
572
678
|
component.handleMouse({ type: "move", button: "none", x: 5, y: hostToolRow } as any);
|
|
573
|
-
expect((component as any).
|
|
679
|
+
expect((component as any).liveFocusedEntryId).toBe(2);
|
|
574
680
|
component.handleMouse({ type: "click", button: "left", x: 5, y: hostToolRow } as any);
|
|
575
681
|
expect((component as any).liveFocusedToolCallId).toBe("call-1");
|
|
576
682
|
expect((component as any).liveExpandedToolCallId).toBe("call-1");
|
package/extensions/btw.ts
CHANGED
|
@@ -1263,7 +1263,6 @@ export class BtwOverlayComponent extends Container implements Focusable {
|
|
|
1263
1263
|
private transcriptViewportHeight = 8;
|
|
1264
1264
|
private followTranscript = true;
|
|
1265
1265
|
private scrollbarActive = false;
|
|
1266
|
-
private liveHoveredEntryId: number | null = null;
|
|
1267
1266
|
private liveFocusedEntryId: number | null = null;
|
|
1268
1267
|
private liveFocusedToolCallId: string | null = null;
|
|
1269
1268
|
private liveExpandedToolCallId: string | null = null;
|
|
@@ -1292,6 +1291,7 @@ export class BtwOverlayComponent extends Container implements Focusable {
|
|
|
1292
1291
|
private hoveredPreviewHint = false;
|
|
1293
1292
|
private rawEscapePress = false;
|
|
1294
1293
|
private rawPreviewPress = false;
|
|
1294
|
+
private rawContentPress: { x: number; y: number } | null = null;
|
|
1295
1295
|
/** The same bounded preview is used by Peek and by the live BTW panel. */
|
|
1296
1296
|
private toolPreviewParent: "peek" | "live" | null = null;
|
|
1297
1297
|
private liveToolPreviewBlock: PeekBlock | null = null;
|
|
@@ -1600,6 +1600,16 @@ export class BtwOverlayComponent extends Container implements Focusable {
|
|
|
1600
1600
|
return [this.theme.fg("dim", "No BTW thread yet. Ask a side question to start one.")];
|
|
1601
1601
|
}
|
|
1602
1602
|
|
|
1603
|
+
const hasFocusedEntry = entries.some((entry) => entry.id === this.liveFocusedEntryId && entry.type !== "turn-boundary");
|
|
1604
|
+
if (!hasFocusedEntry) {
|
|
1605
|
+
const fallbackEntry = [...entries].reverse().find((entry) => entry.type !== "turn-boundary");
|
|
1606
|
+
this.liveFocusedEntryId = fallbackEntry?.id ?? null;
|
|
1607
|
+
this.liveFocusedToolCallId = fallbackEntry?.type === "tool-call" || fallbackEntry?.type === "tool-result"
|
|
1608
|
+
? fallbackEntry.toolCallId ?? null
|
|
1609
|
+
: null;
|
|
1610
|
+
this.liveExpandedToolCallId = null;
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1603
1613
|
const allLines: string[] = [];
|
|
1604
1614
|
const lineEntryIds: Array<number | null> = [];
|
|
1605
1615
|
const markBlock = (entryId: number, start: number): void => {
|
|
@@ -1609,8 +1619,6 @@ export class BtwOverlayComponent extends Container implements Focusable {
|
|
|
1609
1619
|
lineEntryIds[index] = value.trim() && !/^─+$/.test(value.trim()) ? entryId : null;
|
|
1610
1620
|
}
|
|
1611
1621
|
};
|
|
1612
|
-
const focusRail = (entryId: number): string =>
|
|
1613
|
-
this.liveFocusedEntryId === entryId ? "▎ " : this.liveHoveredEntryId === entryId ? "│ " : "";
|
|
1614
1622
|
const userBadge = buildTranscriptBadge(this.theme, "USER", "userMessageBg", "accent");
|
|
1615
1623
|
const thinkingBadge = buildTranscriptBadge(this.theme, "THINKING", "toolPendingBg", "warning");
|
|
1616
1624
|
const assistantBadge = buildTranscriptBadge(this.theme, "ASSISTANT", "customMessageBg", "success");
|
|
@@ -1642,7 +1650,7 @@ export class BtwOverlayComponent extends Container implements Focusable {
|
|
|
1642
1650
|
|
|
1643
1651
|
if (entry.type === "user-message") {
|
|
1644
1652
|
pushBlank();
|
|
1645
|
-
allLines.push(
|
|
1653
|
+
allLines.push(userBadge);
|
|
1646
1654
|
const boundedText = entry.text.length > 16_000 ? `${entry.text.slice(0, 15_970)}\n… [truncated]` : entry.text;
|
|
1647
1655
|
const mdLines = renderBtwMarkdown(boundedText, mdContentWidth, this.theme, "user", this.mdTheme);
|
|
1648
1656
|
for (const line of mdLines) {
|
|
@@ -1655,7 +1663,7 @@ export class BtwOverlayComponent extends Container implements Focusable {
|
|
|
1655
1663
|
if (entry.type === "thinking") {
|
|
1656
1664
|
const thinkingHeader = entry.streaming ? `${thinkingBadge} ${this.theme.fg("warning", "▍")}` : thinkingBadge;
|
|
1657
1665
|
pushBlank();
|
|
1658
|
-
allLines.push(
|
|
1666
|
+
allLines.push(thinkingHeader);
|
|
1659
1667
|
const markdownLines = renderBtwMarkdown(entry.text, mdContentWidth, this.theme, "thinking", this.mdTheme);
|
|
1660
1668
|
for (const line of markdownLines) {
|
|
1661
1669
|
allLines.push(`${blockIndent}${line.replace(/[ \t]+$/u, "")}`);
|
|
@@ -1670,7 +1678,7 @@ export class BtwOverlayComponent extends Container implements Focusable {
|
|
|
1670
1678
|
const isExpanded = this.liveExpandedToolCallId === entry.toolCallId;
|
|
1671
1679
|
const moreLabel = this.theme.fg("dim", isExpanded ? " · [click less]" : " · [click more]");
|
|
1672
1680
|
pushBlank();
|
|
1673
|
-
allLines.push(`${
|
|
1681
|
+
allLines.push(`${toolLabel}${argsLabel}${moreLabel}`);
|
|
1674
1682
|
if (isExpanded && entry.args) {
|
|
1675
1683
|
const toolLines = renderBtwToolText(entry.args, mdContentWidth, this.theme);
|
|
1676
1684
|
for (const line of toolLines) {
|
|
@@ -1690,7 +1698,7 @@ export class BtwOverlayComponent extends Container implements Focusable {
|
|
|
1690
1698
|
const isExpanded = this.liveExpandedToolCallId === entry.toolCallId;
|
|
1691
1699
|
const moreLabel = this.theme.fg("dim", isExpanded ? " · [click less]" : " · [click more]");
|
|
1692
1700
|
pushBlank();
|
|
1693
|
-
allLines.push(`${
|
|
1701
|
+
allLines.push(`${resultLabel}${summary}${truncLabel}${moreLabel}`);
|
|
1694
1702
|
if (isExpanded) {
|
|
1695
1703
|
const toolLines = renderBtwToolText(
|
|
1696
1704
|
entry.fullContent ?? entry.content,
|
|
@@ -1710,7 +1718,7 @@ export class BtwOverlayComponent extends Container implements Focusable {
|
|
|
1710
1718
|
if (entry.type === "assistant-text") {
|
|
1711
1719
|
pushBlank();
|
|
1712
1720
|
const header = entry.streaming ? `${assistantBadge} ${this.theme.fg("warning", "▍")}` : assistantBadge;
|
|
1713
|
-
allLines.push(
|
|
1721
|
+
allLines.push(header);
|
|
1714
1722
|
|
|
1715
1723
|
// Use the same Pi Markdown renderer for completed and streaming text.
|
|
1716
1724
|
// Markdown is intentionally cheap here because the overlay already
|
|
@@ -1730,7 +1738,13 @@ export class BtwOverlayComponent extends Container implements Focusable {
|
|
|
1730
1738
|
}
|
|
1731
1739
|
|
|
1732
1740
|
this.transcriptLineEntryIds = lineEntryIds;
|
|
1733
|
-
return allLines
|
|
1741
|
+
return allLines.map((line, index) => {
|
|
1742
|
+
if (lineEntryIds[index] !== this.liveFocusedEntryId) {
|
|
1743
|
+
return line;
|
|
1744
|
+
}
|
|
1745
|
+
const rail = this.theme.fg("accent", "▎");
|
|
1746
|
+
return line.startsWith(" ") ? `${rail}${line.slice(1)}` : `${rail}${line}`;
|
|
1747
|
+
});
|
|
1734
1748
|
}
|
|
1735
1749
|
|
|
1736
1750
|
private getDialogHeight(inputLines: number): number {
|
|
@@ -1792,10 +1806,12 @@ export class BtwOverlayComponent extends Container implements Focusable {
|
|
|
1792
1806
|
const entry = this.readTranscriptEntries().find((candidate) => candidate.id === entryId);
|
|
1793
1807
|
if (!entry || entry.type === "turn-boundary") return false;
|
|
1794
1808
|
this.liveFocusedEntryId = entryId;
|
|
1795
|
-
this.liveHoveredEntryId = entryId;
|
|
1796
1809
|
this.liveFocusedToolCallId = entry.type === "tool-call" || entry.type === "tool-result"
|
|
1797
1810
|
? entry.toolCallId ?? null
|
|
1798
1811
|
: null;
|
|
1812
|
+
if (this.liveFocusedToolCallId === null) {
|
|
1813
|
+
this.liveExpandedToolCallId = null;
|
|
1814
|
+
}
|
|
1799
1815
|
this.tui.requestRender();
|
|
1800
1816
|
return true;
|
|
1801
1817
|
}
|
|
@@ -1976,11 +1992,9 @@ export class BtwOverlayComponent extends Container implements Focusable {
|
|
|
1976
1992
|
this.render(this.lastRenderWidth);
|
|
1977
1993
|
}
|
|
1978
1994
|
if (normalized.action === "move" || normalized.action === "drag") {
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
this.tui.requestRender();
|
|
1983
|
-
return { handled: true, render: true };
|
|
1995
|
+
// Transcript focus changes only through explicit clicks. Hover remains
|
|
1996
|
+
// intentionally inert so the persistent rail never jumps under the pointer.
|
|
1997
|
+
return { handled: true, render: false };
|
|
1984
1998
|
}
|
|
1985
1999
|
if (normalized.action === "press" || normalized.action === "release") {
|
|
1986
2000
|
return { handled: true, render: false };
|
|
@@ -1988,7 +2002,9 @@ export class BtwOverlayComponent extends Container implements Focusable {
|
|
|
1988
2002
|
if (normalized.action !== "click" || normalized.button !== 0) {
|
|
1989
2003
|
return { handled: true, render: false };
|
|
1990
2004
|
}
|
|
1991
|
-
|
|
2005
|
+
// The outer frame and right-hand scrollbar are navigation chrome, not
|
|
2006
|
+
// transcript content. Keep their clicks from changing block focus.
|
|
2007
|
+
if (normalized.x < 2 || normalized.x > this.lastRenderWidth - 2) {
|
|
1992
2008
|
return { handled: true, render: false };
|
|
1993
2009
|
}
|
|
1994
2010
|
const entryId = this.transcriptEntryAtLine(normalized.y);
|
|
@@ -2090,9 +2106,9 @@ export class BtwOverlayComponent extends Container implements Focusable {
|
|
|
2090
2106
|
}
|
|
2091
2107
|
return;
|
|
2092
2108
|
}
|
|
2093
|
-
//
|
|
2094
|
-
//
|
|
2095
|
-
//
|
|
2109
|
+
// Older hosts expose raw SGR press/release pairs instead of normalized
|
|
2110
|
+
// click events. Recreate explicit clicks so transcript selection and tool
|
|
2111
|
+
// show-more retain the same behavior on both host generations.
|
|
2096
2112
|
if (mouseEvent) {
|
|
2097
2113
|
const overPreviewHint = this.isPreviewHintHit(mouseEvent.x, mouseEvent.y);
|
|
2098
2114
|
const overEscapeHint = this.isEscapeHintHit(mouseEvent.x, mouseEvent.y);
|
|
@@ -2100,22 +2116,28 @@ export class BtwOverlayComponent extends Container implements Focusable {
|
|
|
2100
2116
|
if (mouseEvent.button === 0 && mouseEvent.action === "press") {
|
|
2101
2117
|
this.rawPreviewPress = overPreviewHint;
|
|
2102
2118
|
this.rawEscapePress = overEscapeHint;
|
|
2119
|
+
this.rawContentPress = overPreviewHint || overEscapeHint ? null : { x: mouseEvent.x, y: mouseEvent.y };
|
|
2103
2120
|
} else if (mouseEvent.button === 0 && mouseEvent.action === "release") {
|
|
2104
2121
|
const preview = this.rawPreviewPress && overPreviewHint;
|
|
2105
2122
|
const close = this.rawEscapePress && overEscapeHint;
|
|
2123
|
+
const contentClick = this.rawContentPress?.x === mouseEvent.x && this.rawContentPress.y === mouseEvent.y && !preview && !close;
|
|
2106
2124
|
this.rawPreviewPress = false;
|
|
2107
2125
|
this.rawEscapePress = false;
|
|
2126
|
+
this.rawContentPress = null;
|
|
2108
2127
|
if (preview) {
|
|
2109
2128
|
if (this.peekState.active) this.enterToolPreview();
|
|
2110
2129
|
else this.enterLiveToolPreview();
|
|
2111
2130
|
} else if (close) {
|
|
2112
2131
|
this.closeEscapeTarget();
|
|
2132
|
+
} else if (contentClick && !this.peekState.active) {
|
|
2133
|
+
this.handleMouse({ ...mouseEvent, action: "click", button: 0 });
|
|
2113
2134
|
}
|
|
2114
2135
|
}
|
|
2115
2136
|
return;
|
|
2116
2137
|
}
|
|
2117
2138
|
this.rawPreviewPress = false;
|
|
2118
2139
|
this.rawEscapePress = false;
|
|
2140
|
+
this.rawContentPress = null;
|
|
2119
2141
|
|
|
2120
2142
|
// Peek mode active → route all input to peek handler
|
|
2121
2143
|
if (this.peekState.active) {
|
package/package.json
CHANGED