pi-render-btw 0.6.19 → 0.6.21

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,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.21 — 2026-11-24
4
+
5
+ - Fix BTW overlay clipping at host widths below 24 columns by laying out the frame at the actual host width instead of expanding first and truncating the completed frame afterward.
6
+ - Preserve the selected transcript `▎`, scrollbar rail, and right border in narrow overlays.
7
+
8
+ ## 0.6.20 — 2026-11-23
9
+
10
+ - 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.
11
+ - Keep THINKING blocks focusable and visible; click a tool block to toggle its inline show-more details while preserving the full Tool Output preview.
12
+ - 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.
13
+
3
14
  ## 0.6.19 — 2026-11-23
4
15
 
5
16
  - 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。
@@ -21,6 +21,8 @@ const tui = {
21
21
  stop: () => {},
22
22
  } as any;
23
23
 
24
+ const visibleText = (value: string): string => value.replace(/\x1b\[[0-9;?]*[ -/]*[@-~]/g, "");
25
+
24
26
  function transcriptLines(entries: unknown[]): string[] {
25
27
  const component = new BtwOverlayComponent(
26
28
  tui,
@@ -42,7 +44,7 @@ describe("BTW transcript message layout", () => {
42
44
  { id: 1, turnId: 1, type: "user-message", text: "Prompt" },
43
45
  ]);
44
46
 
45
- expect(lines.slice(0, 2)).toEqual([" USER ", " Prompt"]);
47
+ expect(lines.slice(0, 2)).toEqual(["▎USER ", "▎ Prompt"]);
46
48
  });
47
49
 
48
50
  it("keeps assistant heading and response on separate lines", () => {
@@ -50,8 +52,27 @@ describe("BTW transcript message layout", () => {
50
52
  { id: 1, turnId: 1, type: "assistant-text", text: "Response", streaming: false },
51
53
  ]);
52
54
 
53
- expect(lines[0]).toBe(" ASSISTANT ");
54
- expect(lines[1].startsWith(" Response")).toBe(true);
55
+ expect(lines[0]).toBe("▎ASSISTANT ");
56
+ expect(lines[1].startsWith("▎ Response")).toBe(true);
57
+ });
58
+
59
+ it("keeps the selected transcript frame intact at narrow host widths", () => {
60
+ const component = new BtwOverlayComponent(
61
+ tui,
62
+ theme,
63
+ keybindings,
64
+ () => [{ id: 1, turnId: 1, type: "assistant-text", text: "123456789012345", streaming: false }] as any,
65
+ () => null,
66
+ () => "contextual",
67
+ () => {},
68
+ () => {},
69
+ () => {},
70
+ );
71
+
72
+ const lines = component.render(20).map(visibleText);
73
+
74
+ expect(lines[0]).toBe(`┌${"─".repeat(18)}┐`);
75
+ expect(lines.find((line) => line.includes("1234567890123"))?.endsWith("│")).toBe(true);
55
76
  });
56
77
 
57
78
  it("opens Peek with Ctrl+P even when the composer contains a draft", () => {
@@ -531,6 +552,112 @@ describe("BTW transcript message layout", () => {
531
552
  }
532
553
  });
533
554
 
555
+ it("keeps a persistent clicked rail, ignores transcript hover, and toggles tool details", () => {
556
+ const entries = [
557
+ { id: 1, turnId: 1, type: "user-message", text: "Question" },
558
+ { id: 2, turnId: 1, type: "thinking", text: "Reasoning line one\nReasoning line two", streaming: false },
559
+ { id: 3, turnId: 1, type: "tool-call", toolCallId: "call-focus", toolName: "read", args: "src/index.ts" },
560
+ { id: 4, turnId: 1, type: "assistant-text", text: "Answer", streaming: false },
561
+ ] as any;
562
+ const component = new BtwOverlayComponent(
563
+ tui,
564
+ theme,
565
+ keybindings,
566
+ () => entries,
567
+ () => null,
568
+ () => "contextual",
569
+ () => {},
570
+ () => {},
571
+ () => {},
572
+ );
573
+
574
+ let lines = component.render(80);
575
+ expect(lines.some((line) => line.includes("▎") && line.includes("ASSISTANT"))).toBe(true);
576
+ const contentTop = (component as any).transcriptContentTop as number;
577
+ const lineEntryIds = (component as any).transcriptLineEntryIds as Array<number | null>;
578
+ const hostRowFor = (entryId: number) => contentTop - 1 + lineEntryIds.indexOf(entryId);
579
+
580
+ component.handleMouse({ type: "click", button: "left", x: 5, y: hostRowFor(2) } as any);
581
+ expect((component as any).liveFocusedEntryId).toBe(2);
582
+ lines = component.render(80);
583
+ expect(lines.filter((line) => line.includes("▎")).length).toBeGreaterThanOrEqual(2);
584
+ expect(lines.some((line) => line.includes("THINKING"))).toBe(true);
585
+
586
+ component.handleMouse({ type: "move", button: "none", x: 5, y: hostRowFor(1) } as any);
587
+ expect((component as any).liveFocusedEntryId).toBe(2);
588
+
589
+ component.handleMouse({ type: "click", button: "left", x: 5, y: hostRowFor(3) } as any);
590
+ expect((component as any).liveFocusedEntryId).toBe(3);
591
+ expect((component as any).liveExpandedToolCallId).toBe("call-focus");
592
+ expect(component.render(80).join("\n")).toContain("[click less]");
593
+
594
+ component.handleMouse({ type: "click", button: "left", x: 5, y: hostRowFor(3) } as any);
595
+ expect((component as any).liveExpandedToolCallId).toBeNull();
596
+ expect(component.render(80).join("\n")).toContain("[click more]");
597
+ });
598
+
599
+ it("uses raw SGR clicks to focus blocks and toggle a tool", () => {
600
+ const entries = [
601
+ { id: 1, turnId: 1, type: "user-message", text: "Question" },
602
+ { id: 2, turnId: 1, type: "tool-call", toolCallId: "call-sgr", toolName: "read", args: "src/index.ts" },
603
+ { id: 3, turnId: 1, type: "assistant-text", text: "Answer", streaming: false },
604
+ ] as any;
605
+ const component = new BtwOverlayComponent(
606
+ tui,
607
+ theme,
608
+ keybindings,
609
+ () => entries,
610
+ () => null,
611
+ () => "contextual",
612
+ () => {},
613
+ () => {},
614
+ () => {},
615
+ );
616
+
617
+ component.render(80);
618
+ const contentTop = (component as any).transcriptContentTop as number;
619
+ const lineEntryIds = (component as any).transcriptLineEntryIds as Array<number | null>;
620
+ const rawClick = (entryId: number) => {
621
+ const y = contentTop + lineEntryIds.indexOf(entryId);
622
+ component.handleInput(`\x1b[<0;5;${y}M`);
623
+ component.handleInput(`\x1b[<0;5;${y}m`);
624
+ };
625
+
626
+ rawClick(1);
627
+ expect((component as any).liveFocusedEntryId).toBe(1);
628
+
629
+ rawClick(2);
630
+ expect((component as any).liveFocusedEntryId).toBe(2);
631
+ expect((component as any).liveExpandedToolCallId).toBe("call-sgr");
632
+ });
633
+
634
+ it("does not focus or toggle a tool when clicking the scrollbar rail", () => {
635
+ const entries = [
636
+ { id: 1, turnId: 1, type: "tool-call", toolCallId: "call-rail", toolName: "read", args: "src/index.ts" },
637
+ { id: 2, turnId: 1, type: "assistant-text", text: "Answer", streaming: false },
638
+ ] as any;
639
+ const component = new BtwOverlayComponent(
640
+ tui,
641
+ theme,
642
+ keybindings,
643
+ () => entries,
644
+ () => null,
645
+ () => "contextual",
646
+ () => {},
647
+ () => {},
648
+ () => {},
649
+ );
650
+
651
+ component.render(80);
652
+ const contentTop = (component as any).transcriptContentTop as number;
653
+ const lineEntryIds = (component as any).transcriptLineEntryIds as Array<number | null>;
654
+ const toolHostRow = contentTop - 1 + lineEntryIds.indexOf(1);
655
+ component.handleMouse({ type: "click", button: "left", x: 78, y: toolHostRow } as any);
656
+
657
+ expect((component as any).liveFocusedEntryId).toBe(2);
658
+ expect((component as any).liveExpandedToolCallId).toBeNull();
659
+ });
660
+
534
661
  it("focuses and expands a live tool, scrolls locally, and opens Ctrl+O output", () => {
535
662
  const entries = [
536
663
  { id: 1, turnId: 1, type: "tool-call", toolCallId: "call-1", toolName: "write", args: "compact input" },
@@ -567,10 +694,10 @@ describe("BTW transcript message layout", () => {
567
694
  const hostToolRow = contentTop - 1;
568
695
  component.handleMouse({ type: "press", button: "left", x: 5, y: hostToolRow } as any);
569
696
  component.handleMouse({ type: "release", button: "left", x: 5, y: hostToolRow } as any);
570
- expect((component as any).liveFocusedToolCallId).toBeNull();
697
+ expect((component as any).liveFocusedToolCallId).toBe("call-1");
571
698
 
572
699
  component.handleMouse({ type: "move", button: "none", x: 5, y: hostToolRow } as any);
573
- expect((component as any).liveHoveredEntryId).toBe(1);
700
+ expect((component as any).liveFocusedEntryId).toBe(2);
574
701
  component.handleMouse({ type: "click", button: "left", x: 5, y: hostToolRow } as any);
575
702
  expect((component as any).liveFocusedToolCallId).toBe("call-1");
576
703
  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(`${focusRail(entry.id)}${userBadge}`);
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(`${focusRail(entry.id)}${thinkingHeader}`);
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(`${focusRail(entry.id)}${toolLabel}${argsLabel}${moreLabel}`);
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(`${focusRail(entry.id)}${resultLabel}${summary}${truncLabel}${moreLabel}`);
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(`${focusRail(entry.id)}${header}`);
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
- const hoveredEntryId = this.transcriptEntryAtLine(normalized.y);
1980
- if (hoveredEntryId === this.liveHoveredEntryId) return { handled: true, render: false };
1981
- this.liveHoveredEntryId = hoveredEntryId;
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
- if (normalized.x < 1 || normalized.x > this.lastRenderWidth) {
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
- // Consume bounded SGR button events locally. Older hosts do not expose
2094
- // normalized click dispatch, so retain preview/close press/release pairs
2095
- // as the actionable fallback; transcript clicks remain read-only.
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) {
@@ -2149,8 +2171,10 @@ export class BtwOverlayComponent extends Container implements Focusable {
2149
2171
  }
2150
2172
 
2151
2173
  override render(width: number): string[] {
2152
- const dialogWidth = Math.max(24, width);
2153
- const innerWidth = Math.max(22, dialogWidth - 2);
2174
+ // Layout must use the host's real width. Expanding to a cosmetic minimum
2175
+ // and truncating afterward drops the rightmost transcript cells.
2176
+ const dialogWidth = Math.max(3, width);
2177
+ const innerWidth = Math.max(1, dialogWidth - 2);
2154
2178
  this.lastRenderWidth = dialogWidth;
2155
2179
 
2156
2180
  // Tool Output is a read-only view over the currently focused live tool.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-render-btw",
3
- "version": "0.6.19",
3
+ "version": "0.6.21",
4
4
  "description": "A pi extension for parallel side conversations with /btw — with markdown rendering in the floating window",
5
5
  "type": "module",
6
6
  "license": "MIT",