@herbertgao/pi-extensions 2026.11.7 → 2026.11.8

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.
Files changed (123) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +5 -5
  3. package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +6 -0
  4. package/node_modules/@herbertgao/pi-subagents/README.md +2 -2
  5. package/node_modules/@herbertgao/pi-subagents/package.json +4 -4
  6. package/node_modules/@herbertgao/pi-subagents/src/ui/conversation-viewer.ts +10 -6
  7. package/node_modules/@herbertgao/pi-subagents/src/ui/viewer-keys.ts +47 -4
  8. package/node_modules/@narumitw/pi-btw/CHANGELOG.md +12 -0
  9. package/node_modules/@narumitw/pi-btw/dist/chunks/{main-tree-picker-WHRN26NJ.ts → main-tree-picker-3PXJARQW.ts} +59 -53
  10. package/node_modules/@narumitw/pi-btw/dist/chunks/main-tree-picker-3PXJARQW.ts.map +7 -0
  11. package/node_modules/@narumitw/pi-btw/dist/index.ts +1 -1
  12. package/node_modules/@narumitw/pi-btw/docs/main-tree-snapshots.md +39 -0
  13. package/node_modules/@narumitw/pi-btw/docs/workflows.md +1 -0
  14. package/node_modules/@narumitw/pi-btw/package.json +1 -1
  15. package/node_modules/@narumitw/pi-btw/src/main-tree-picker.ts +73 -63
  16. package/node_modules/pi-lens/CHANGELOG-USER.md +6 -6
  17. package/node_modules/pi-lens/CHANGELOG.md +30 -0
  18. package/node_modules/pi-lens/README.md +1 -0
  19. package/node_modules/pi-lens/dist/{chunk-KDGKKK7A.js → chunk-2HWVG3IM.js} +1 -1
  20. package/node_modules/pi-lens/dist/{chunk-3QCI3V6C.js → chunk-3EIZMRXI.js} +5 -5
  21. package/node_modules/pi-lens/dist/{chunk-NWK7KKNO.js → chunk-3MHY4BQY.js} +2 -2
  22. package/node_modules/pi-lens/dist/{chunk-3NVGBFJS.js → chunk-3PMLYGJN.js} +2 -2
  23. package/node_modules/pi-lens/dist/{chunk-OP5BMZKK.js → chunk-3QMLB4TI.js} +1 -1
  24. package/node_modules/pi-lens/dist/{chunk-V7IPIAE5.js → chunk-3VWEZ6H2.js} +24 -26
  25. package/node_modules/pi-lens/dist/{chunk-NLRKB32C.js → chunk-5EEWCJG7.js} +1 -1
  26. package/node_modules/pi-lens/dist/{chunk-VDMF7Q2P.js → chunk-5FDUKJZO.js} +4 -4
  27. package/node_modules/pi-lens/dist/{chunk-KBSC5Z3G.js → chunk-5KLRCUDT.js} +2 -2
  28. package/node_modules/pi-lens/dist/{chunk-GL6J5R34.js → chunk-6EXGCXM5.js} +3 -3
  29. package/node_modules/pi-lens/dist/{chunk-OC4ZGVMH.js → chunk-6GWCYEP7.js} +5 -7
  30. package/node_modules/pi-lens/dist/{chunk-LXE7JAMV.js → chunk-6JLNZ6DP.js} +4 -4
  31. package/node_modules/pi-lens/dist/{chunk-TTGDTNSN.js → chunk-75TVYCQW.js} +3 -3
  32. package/node_modules/pi-lens/dist/{chunk-QAM2Q3VO.js → chunk-7BEADGAZ.js} +2 -2
  33. package/node_modules/pi-lens/dist/{chunk-R5BNSOIV.js → chunk-7KWI5UHL.js} +7 -8
  34. package/node_modules/pi-lens/dist/{chunk-5YTDZ5WP.js → chunk-7M64NTAK.js} +1 -1
  35. package/node_modules/pi-lens/dist/{chunk-B4K6OSLL.js → chunk-7T64QA5D.js} +25 -27
  36. package/node_modules/pi-lens/dist/{chunk-KDMJ2DJD.js → chunk-7ZVEFWOE.js} +5 -5
  37. package/node_modules/pi-lens/dist/{chunk-D5L7Q57Z.js → chunk-AAIVSSUU.js} +1 -1
  38. package/node_modules/pi-lens/dist/{chunk-LIDFFCZZ.js → chunk-AD7JDEI6.js} +9 -9
  39. package/node_modules/pi-lens/dist/{chunk-WBXCIRVI.js → chunk-AVBEPUCD.js} +1 -1
  40. package/node_modules/pi-lens/dist/{chunk-VTXJAO5R.js → chunk-AZXTLZHE.js} +9 -9
  41. package/node_modules/pi-lens/dist/{chunk-UELHWF5I.js → chunk-BEIPWPVR.js} +10 -10
  42. package/node_modules/pi-lens/dist/{chunk-SQBDX6IO.js → chunk-C6V2DSZZ.js} +6 -6
  43. package/node_modules/pi-lens/dist/{chunk-ZD4KVFXI.js → chunk-D2ZYRI7M.js} +172 -3
  44. package/node_modules/pi-lens/dist/{chunk-HIUVHRLM.js → chunk-D6ANA6YU.js} +20 -22
  45. package/node_modules/pi-lens/dist/{chunk-YUF4DRYB.js → chunk-D7OEGXDX.js} +1 -1
  46. package/node_modules/pi-lens/dist/{chunk-AOQKQWZU.js → chunk-DFAY7JUN.js} +1 -1
  47. package/node_modules/pi-lens/dist/{chunk-QUZYRDT6.js → chunk-DIIDMDZU.js} +6 -6
  48. package/node_modules/pi-lens/dist/{chunk-QBUSONNE.js → chunk-DZSQXG66.js} +45 -27
  49. package/node_modules/pi-lens/dist/{chunk-UY3WWW5R.js → chunk-E5SSUV2A.js} +3 -3
  50. package/node_modules/pi-lens/dist/{chunk-DNB4ZQGN.js → chunk-ET3DSSFZ.js} +1 -1
  51. package/node_modules/pi-lens/dist/{chunk-4WWPDMRA.js → chunk-F7AMFFVK.js} +4 -4
  52. package/node_modules/pi-lens/dist/{chunk-LHCDWFDB.js → chunk-FDLGJFAE.js} +1 -1
  53. package/node_modules/pi-lens/dist/{chunk-C4ICGFEO.js → chunk-FVQKX5KI.js} +12 -12
  54. package/node_modules/pi-lens/dist/{chunk-TRYOYWWU.js → chunk-G3LR6V6N.js} +4 -4
  55. package/node_modules/pi-lens/dist/{chunk-AVOUHMCS.js → chunk-GHATCG2A.js} +10 -10
  56. package/node_modules/pi-lens/dist/{chunk-R2UF54ON.js → chunk-HJWF7CGW.js} +9 -9
  57. package/node_modules/pi-lens/dist/chunk-HRQTYU2T.js +355 -0
  58. package/node_modules/pi-lens/dist/{chunk-NR4KQOXZ.js → chunk-HSTN27NR.js} +1 -1
  59. package/node_modules/pi-lens/dist/{chunk-YVPB5YGO.js → chunk-HWMNTQBJ.js} +1 -1
  60. package/node_modules/pi-lens/dist/{chunk-6XNVY3FW.js → chunk-HYDJUVOE.js} +1 -1
  61. package/node_modules/pi-lens/dist/{chunk-WXMUGUZV.js → chunk-HYR25MV3.js} +4 -4
  62. package/node_modules/pi-lens/dist/{chunk-AJ62EQIQ.js → chunk-IC4L65U7.js} +12 -9
  63. package/node_modules/pi-lens/dist/{chunk-R2VUZZPJ.js → chunk-ILC2B7IJ.js} +4 -4
  64. package/node_modules/pi-lens/dist/{chunk-E6Z3CJT2.js → chunk-IZ36G463.js} +5 -5
  65. package/node_modules/pi-lens/dist/{chunk-IBEYUBCM.js → chunk-JKAVKTMY.js} +6 -6
  66. package/node_modules/pi-lens/dist/{chunk-LHU6NG5Z.js → chunk-JLMS7EMD.js} +8 -8
  67. package/node_modules/pi-lens/dist/{chunk-6RXMQYNU.js → chunk-JRSS6KM4.js} +1 -1
  68. package/node_modules/pi-lens/dist/{chunk-HASJPQBC.js → chunk-K2LD6YNH.js} +4 -4
  69. package/node_modules/pi-lens/dist/{chunk-UQ6OZYTO.js → chunk-KUDUKKQE.js} +43 -45
  70. package/node_modules/pi-lens/dist/{chunk-34RXPR7M.js → chunk-KXDQD34C.js} +1 -1
  71. package/node_modules/pi-lens/dist/{chunk-QDZ3ZZMY.js → chunk-LD7SXICE.js} +3 -3
  72. package/node_modules/pi-lens/dist/{chunk-NQFXN5U7.js → chunk-MOEWCPMC.js} +1 -1
  73. package/node_modules/pi-lens/dist/{chunk-IJ55MYO6.js → chunk-MV6ST2KT.js} +4 -4
  74. package/node_modules/pi-lens/dist/{chunk-532X3OCZ.js → chunk-NCDH2JB7.js} +7 -9
  75. package/node_modules/pi-lens/dist/{chunk-ITAPXBIB.js → chunk-NRVWLTOY.js} +9 -9
  76. package/node_modules/pi-lens/dist/{chunk-DPDA3ILA.js → chunk-NZINZCHB.js} +1 -1
  77. package/node_modules/pi-lens/dist/{chunk-A4HKPAEN.js → chunk-OEPWTSUG.js} +6 -6
  78. package/node_modules/pi-lens/dist/{chunk-TBE4OLPA.js → chunk-OF2YGDUE.js} +21 -23
  79. package/node_modules/pi-lens/dist/{chunk-BLL4VYGZ.js → chunk-OHEUOWYT.js} +1 -1
  80. package/node_modules/pi-lens/dist/{chunk-PSUXESQ5.js → chunk-ORYQGVC3.js} +1 -1
  81. package/node_modules/pi-lens/dist/{chunk-FVEEEEIM.js → chunk-OVPR3GQ6.js} +4 -4
  82. package/node_modules/pi-lens/dist/{chunk-BN36MQW5.js → chunk-PCREZ4HJ.js} +20 -22
  83. package/node_modules/pi-lens/dist/{chunk-KNP4ENFT.js → chunk-PK3GDU4M.js} +1 -1
  84. package/node_modules/pi-lens/dist/{chunk-2SD2CGVH.js → chunk-PPYUBO6Y.js} +1 -1
  85. package/node_modules/pi-lens/dist/{chunk-4HNBY7S7.js → chunk-PTJXMYRY.js} +7 -9
  86. package/node_modules/pi-lens/dist/{chunk-VI3BJMZO.js → chunk-PXGVB2CY.js} +14 -18
  87. package/node_modules/pi-lens/dist/{chunk-3C6ZZAB2.js → chunk-QY6J2FTK.js} +10 -12
  88. package/node_modules/pi-lens/dist/{chunk-5RLEDUUE.js → chunk-R67WQ5RY.js} +3 -3
  89. package/node_modules/pi-lens/dist/{chunk-WMCAEP2K.js → chunk-S6ZQFPOX.js} +2 -2
  90. package/node_modules/pi-lens/dist/{chunk-LPM6NKVI.js → chunk-SF7KSXB5.js} +2 -2
  91. package/node_modules/pi-lens/dist/{chunk-ECYUBKYX.js → chunk-T6PPK3T6.js} +40 -37
  92. package/node_modules/pi-lens/dist/{chunk-RV5VX2XW.js → chunk-TM3A3K7T.js} +8 -9
  93. package/node_modules/pi-lens/dist/{chunk-AFNPNHJV.js → chunk-TOOXNL6M.js} +3 -3
  94. package/node_modules/pi-lens/dist/{chunk-BJDB7PXU.js → chunk-TS5EIWEF.js} +6 -6
  95. package/node_modules/pi-lens/dist/{chunk-UG4YLCJ5.js → chunk-VD7MQFEV.js} +21 -23
  96. package/node_modules/pi-lens/dist/{chunk-BBJXIZ3X.js → chunk-VU2PRGRI.js} +5 -34
  97. package/node_modules/pi-lens/dist/{chunk-GTNO6F6K.js → chunk-WTSQKJAR.js} +4 -4
  98. package/node_modules/pi-lens/dist/{chunk-TPMBNWHO.js → chunk-Y7XMKBFP.js} +16 -16
  99. package/node_modules/pi-lens/dist/{chunk-JSQK5DH3.js → chunk-YLHJWAQS.js} +2 -2
  100. package/node_modules/pi-lens/dist/{chunk-HTUG7ZFK.js → chunk-YLW26OHX.js} +3 -3
  101. package/node_modules/pi-lens/dist/{chunk-C2REOMPO.js → chunk-YTXFNCVN.js} +1 -1
  102. package/node_modules/pi-lens/dist/{chunk-F37CCZUA.js → chunk-YULIERZW.js} +8 -8
  103. package/node_modules/pi-lens/dist/{chunk-KX4DF6XX.js → chunk-Z2W5YJBW.js} +6 -6
  104. package/node_modules/pi-lens/dist/{chunk-DBAHJFBU.js → chunk-Z6WTLVUL.js} +13 -18
  105. package/node_modules/pi-lens/dist/{chunk-6K4X7IIF.js → chunk-ZWZD4TJ5.js} +23 -25
  106. package/node_modules/pi-lens/dist/index.js +1134 -618
  107. package/node_modules/pi-lens/dist/mcp/analyze-cli.js +5 -7
  108. package/node_modules/pi-lens/dist/mcp/cli.js +25 -27
  109. package/node_modules/pi-lens/dist/mcp/server.js +101 -100
  110. package/node_modules/pi-lens/dist/mcp/worker.js +43 -45
  111. package/node_modules/pi-lens/dist/probes/installer.js +11 -11
  112. package/node_modules/pi-lens/docs/agent-tools.md +54 -12
  113. package/node_modules/pi-lens/docs/configuration.md +3 -3
  114. package/node_modules/pi-lens/docs/globalconfig.md +8 -1
  115. package/node_modules/pi-lens/docs/invariants/lsp-trust-exec.md +7 -0
  116. package/node_modules/pi-lens/docs/mcp.md +2 -1
  117. package/node_modules/pi-lens/docs/usage.md +1 -1
  118. package/node_modules/pi-lens/package.json +1 -1
  119. package/package.json +4 -4
  120. package/node_modules/@narumitw/pi-btw/dist/chunks/main-tree-picker-WHRN26NJ.ts.map +0 -7
  121. package/node_modules/pi-lens/dist/chunk-3HZ6MNB2.js +0 -140
  122. package/node_modules/pi-lens/dist/chunk-43KD3PPM.js +0 -162
  123. package/node_modules/pi-lens/dist/chunk-CKEQFGLT.js +0 -32
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @herbertgao/pi-extensions
2
2
 
3
+ ## 2026.11.8
4
+
5
+ ### Patch Changes
6
+
7
+ - [#368](https://github.com/HerbertGao/pi-extensions/pull/368) [`6a7741f`](https://github.com/HerbertGao/pi-extensions/commit/6a7741f944d09ac27bae47165a4c534086b6679e) Thanks [@HerbertGao](https://github.com/HerbertGao)! - Pin pi-btw 0.63.7 and pi-lens 4.4.12. The main-thread tree picker walks a deep session without overflowing the call stack and joins copy text only when copying. pi-lens names a function an edit made more complex than the default branch, and AST replace no longer requests strict sampling.
8
+
9
+ - [#368](https://github.com/HerbertGao/pi-extensions/pull/368) [`6a7741f`](https://github.com/HerbertGao/pi-extensions/commit/6a7741f944d09ac27bae47165a4c534086b6679e) Thanks [@HerbertGao](https://github.com/HerbertGao)! - Pin graphifyy 0.9.106. The CLI stays outside the npm aggregate and requires Python >=3.10,<3.15 so installers keep a tree-sitter wheel.
10
+
11
+ - Updated dependencies [[`6a7741f`](https://github.com/HerbertGao/pi-extensions/commit/6a7741f944d09ac27bae47165a4c534086b6679e)]:
12
+ - @herbertgao/pi-subagents@0.23.1
13
+
3
14
  ## 2026.11.7
4
15
 
5
16
  ### Patch Changes
package/README.md CHANGED
@@ -25,7 +25,7 @@ The package bundles 6 active `@herbertgao/*` child packages—`pi-agency`, `pi-b
25
25
  - `pi-provider-qoder@0.6.12`
26
26
  - `@dietrichgebert/ponytail@5.3.3`
27
27
  - `@juicesharp/rpiv-ask-user-question@2.15.0`
28
- - `@narumitw/pi-btw@0.63.5`
28
+ - `@narumitw/pi-btw@0.63.7`
29
29
  - `@narumitw/pi-caffeinate@0.49.14`
30
30
  - `@pi-plugins/fast-mode@0.1.15`
31
31
  - `@tifan/pi-copy-response@0.2.7`
@@ -36,7 +36,7 @@ The package bundles 6 active `@herbertgao/*` child packages—`pi-agency`, `pi-b
36
36
  - `@tintinweb/pi-tasks@0.9.1`
37
37
  - `pi-typesafe@0.14.0`
38
38
  - `pi-next-cue@1.0.8`
39
- - `pi-lens@4.4.11`
39
+ - `pi-lens@4.4.12`
40
40
  - `pi-web-access@0.47.0`
41
41
 
42
42
  Pi loads their extensions and skills through `node_modules/` paths inside one package root. The upstream companions are pinned and bundled, not forked or renamed.
@@ -57,13 +57,13 @@ Impeccable `4.8.2` is vendored as `@herbertgao/pi-impeccable` and loaded with `/
57
57
 
58
58
  `@herbertgao/pi-bark` sends localized Bark pushes when a user-facing Pi run fully settles or `@juicesharp/rpiv-ask-user-question` needs an answer. Notifications include emoji-labeled machine/path metadata and support the bundled official Pi badge through Bark's `icon` parameter. Configure it in `$PI_CODING_AGENT_DIR/bark.json` (normally `~/.pi/agent/bark.json`); see the [package README](../pi-bark/README.md). Without a valid endpoint it stays inactive.
59
59
 
60
- `@narumitw/pi-caffeinate@0.49.14` uses the host platform's sleep inhibitor during each Pi agent run. On macOS, `/caffeinate sleep` keeps the system awake while allowing the display to sleep; `/caffeinate display` also keeps the display awake. It releases the inhibitor when the run or session ends. Its D-Bus dependency remains on the normal socket transport under Node; Bun on Linux/macOS can use FFI and an in-process reader thread for Unix file-descriptor transport, and that thread can be unreferenced so the connection need not keep the process alive. It falls back when FFI is unavailable. No daemon or build step is added. The published extension source is unchanged from 0.49.13 aside from the manifest. It still declares `@narumitw/pi-tui-kit@^0.69.0` and `dbus-native@^0.16.3`. BTW `0.63.5` requires `@narumitw/pi-tui-kit@^0.69.1`, so the aggregate resolves one `0.69.1` install for both.
60
+ `@narumitw/pi-caffeinate@0.49.14` uses the host platform's sleep inhibitor during each Pi agent run. On macOS, `/caffeinate sleep` keeps the system awake while allowing the display to sleep; `/caffeinate display` also keeps the display awake. It releases the inhibitor when the run or session ends. Its D-Bus dependency remains on the normal socket transport under Node; Bun on Linux/macOS can use FFI and an in-process reader thread for Unix file-descriptor transport, and that thread can be unreferenced so the connection need not keep the process alive. It falls back when FFI is unavailable. No daemon or build step is added. The published extension source is unchanged from 0.49.13 aside from the manifest. It still declares `@narumitw/pi-tui-kit@^0.69.0` and `dbus-native@^0.16.3`. BTW `0.63.7` requires `@narumitw/pi-tui-kit@^0.69.1`, so the aggregate resolves one `0.69.1` install for both.
61
61
 
62
- `@narumitw/pi-btw@0.63.5` opens its side workspace through the `@narumitw/pi-tui-kit@^0.69.1` fullscreen handoff. Fullscreen, menu, and transcript modules load on first use. An already ended session does not open that UI. The loaded flow still stops when the dedicated UI is disposed or the parent terminal cannot be restored. Only one BTW flow can be open per session; a second `/btw` warns and stays closed. In split layout, mounting the first split releases Pi's idle wait so the main input stays usable. Importing new main-thread context stays manual. Settings rows keep a clipped label or value in full under the list, and a searchable model choice shows how many results match. A searchable choice keeps page scrolling; the host still owns search activation.
62
+ `@narumitw/pi-btw@0.63.7` opens its side workspace through the `@narumitw/pi-tui-kit@^0.69.1` fullscreen handoff. Fullscreen, menu, and transcript modules load on first use. An already ended session does not open that UI. The loaded flow still stops when the dedicated UI is disposed or the parent terminal cannot be restored. Only one BTW flow can be open per session; a second `/btw` warns and stays closed. In split layout, mounting the first split releases Pi's idle wait so the main input stays usable. Importing new main-thread context stays manual. The main-thread tree picker walks an arbitrarily deep session on the heap, keeps raw copy text as fragments until a copy, and stores a saved label only when the entry has one. Settings rows keep a clipped label or value in full under the list, and a searchable model choice shows how many results match. A searchable choice keeps page scrolling; the host still owns search activation.
63
63
 
64
64
  `clef` asks Cloudflare Clef-flash an on-demand yes/no, choice, or score and prints the questions and answers in the transcript, plus a one-line notice. It is not a permission gate. `pi-typesafe@0.14.0` provides `/typesafe` and `typesafe_evaluate` for explicit structured decisions; `/typesafe enable` or `PI_TYPESAFE_ENABLED=1` is still required for agent tool calls. The default backend remains `https://api.typesafe.ai`. `PI_TYPESAFE_BACKEND` and `PI_TYPESAFE_MODEL` select the session backend and model, and `/typesafe login` stores a key for the named backend. Only HTTP 401 refuses that key, and only for 15 minutes; a 403 refuses one request and leaves the key usable. Nace.AI (`https://console.nace.ai`, `NACE_API_KEY`, default model `drex-v2.0`) is a judgment backend. Daily request, token, and USD caps are opt-in. OpenRouter, Command Code, Liquid, SubQ, Nace.AI, and a named endpoint stay explicit and use that backend's own key. The promoted SDK is `@typesafe-ai/sdk@0.7.0`. Under Bun, the judge transport reads each response body once and replays it, so the SDK can still read the result after Bun marks the original body used.
65
65
 
66
- `@herbertgao/sol-pi` adds opt-in Action Fusion, ObservationPack, Evidence-Preserving Reducer, and Online Context Compact; see its [configuration guide](../sol-pi/docs/configuration.md). `pi-lens@4.4.11` publishes a public LSP config schema, reads user-level custom rule directories (project before user before built-in), normalizes argv-style server entries, downgrades `throw-new-error` to a warning, and counts Docker, JSON, and Jedi servers in idle eviction; language routing and the retained multi-root diagnostic facts are unchanged. `.mts` and `.cts` use the TypeScript rules. Groovy files still classify as Groovy, and the vendored Groovy grammar lists classes and methods. `--no-read-expansion` turns off read widening without disabling the read-before-edit guard. It promotes `@ast-grep/cli` to `0.51.1` and `@ast-grep/napi` to `^0.51.0`. A blank `PI_LENS_*` number falls back to the default, and an explicit `0` is a value. Four MCP tools advertise only `path`. A session rooted at `/` keeps `lsp.disabledServers`. Concatenated SQL passed to `.execute()` is an advisory full-analysis finding; a parameterized `execute(sql, values)` call stays quiet. Keeping injected findings in later requests is opt-in. A workspace edit through a dangling symlink is refused, and a symlink that resolves outside the workspace is refused; the fallback Biome config no longer names a nursery rule. An identity `filter(x => x).map(...)` stays a warning, and a non-identity `filter(fn).map(...)` is no longer flagged. A reduce that copies its accumulator with `Object.assign` is a warning. A directory whose name starts with `..` stays inside its project. `.groovy`, `.gvy`, `.gy`, `.gsh`, `Jenkinsfile`, `build.gradle`, and `settings.gradle` classify as Groovy; `build.gradle.kts` does not. `minimatch` is `^11.0.4` and `vscode-jsonrpc` is `^10.0.0`. `pi-web-access@0.47.0` provides configurable web search and fetch tools; its `toolActivation` defaults to `auto`, choosing eager or dynamic tool activation per model. `toolActivation: "none"` stays opt-in and still requires deferred exposure. Field extraction, 9router, empty or off-topic search fallback, and plain HTTP gateway URLs stay off unless configured. An unknown tool-call provider name fails instead of selecting a provider automatically, and DuckDuckGo searches stay spaced apart after a bot check. It adds structured search/fetch data for codemode and an optional, manually started `pi-web-access-mcp` stdio CLI; installing the aggregate does not start that server. Degoog, Keenable, Ceramic, Linkup, DeepSeek fetch, Cloudflare search, SearchApi, Outcrawl, Sofya, and Tabstack are explicit-only, excluded from automatic and `all` selection. `lockProxy: true` rejects a tool-call proxy other than the configured one. A GitHub repository README is returned up to 100K characters, and a clone with no `githubClone.clonePath` goes under the OS temp directory. Optional `fetchContent.curl` and Exa/Tabstack fetch routing stay off unless configured. Provider gateway base URLs are opt-in and are not configured by the aggregate. OpenAI search now defaults to `gpt-6-luna`, results and clone cleanup are scoped per extension instance, and the promoted `@modelcontextprotocol/sdk@^1.32.1` moves the bundle off GHSA-6qxp-vccf-f47h. Perplexity search now uses the Search API's ranked pages and snippets rather than a Sonar-generated answer; requests requiring prose still use Sonar. `pi-antigravity@0.12.0` reads Pi 0.86+ transcript system messages, so Antigravity requests carry Pi's system prompt and tools; it also registers `google_search` and `generate_image` tools that use the signed-in Antigravity account. Those tools stay direct unless `ANTIGRAVITY_DEFER_TOOLS=1`. A model removed by catalog refresh is not filled back in from the bootstrap list. Image saves reject symlink destinations. The aggregate keeps host `typebox` and `undici@^8.11.2`. `pi-provider-qoder@0.6.12` registers the `qoder` and `qoder-cn` model providers. A tool-call argument stream that is cut off before a usable call is reported as a retryable server error. Startup logs one line when the npm registry has a newer release; `PI_PROVIDER_QODER_SKIP_UPDATE_CHECK=1` skips that lookup. A queued model-busy response reports its wait instead of being ignored; a ready busy response stays retryable. A queued wait that does not fit in a safe millisecond count uses `retryAfterSeconds` instead. Agent chat prefers the account's remote-agent node and, on daily chat limit code 110, tries the next node. The chosen node is cached for one hour. Sign in with `/login qoder` (browser or a personal access token from [qoder.com/account/integrations](https://qoder.com/account/integrations)) or `/login qoder-cn` (token from [qoder.com.cn/account/integrations](https://qoder.com.cn/account/integrations)). `QODER_PERSONAL_ACCESS_TOKEN` and `QODERCN_PERSONAL_ACCESS_TOKEN` log those providers in at startup. `/qoder-usage footer on` replaces the status-bar footer for that session, so leave it off while the pi-cc footer is in use. `pi-commandcode-provider@0.8.1` registers `commandcode` beside `qoder`, `qoder-cn`, and `antigravity`. Inference uses the Provider API only. `/login` lists those subscription providers and runs only the one you select. `@tifan/pi-preferred-thinking` is no longer bundled. Per-model thinking levels come from Pi. Deprecated `@tifan/pi-titlebar-spinner` is no longer bundled; Rename remains the single owner of Herdr tab naming. `@tifan/pi-handoff` imports `@tifan/pi-rename/naming` when it generates a session name, so Rename stays installed and its `/rename` command stays registered.
66
+ `@herbertgao/sol-pi` adds opt-in Action Fusion, ObservationPack, Evidence-Preserving Reducer, and Online Context Compact; see its [configuration guide](../sol-pi/docs/configuration.md). `pi-lens@4.4.12` publishes a public LSP config schema, reads user-level custom rule directories (project before user before built-in), normalizes argv-style server entries, downgrades `throw-new-error` to a warning, and counts Docker, JSON, and Jedi servers in idle eviction; language routing and the retained multi-root diagnostic facts are unchanged. `.mts` and `.cts` use the TypeScript rules. Groovy files still classify as Groovy, and the vendored Groovy grammar lists classes and methods. `--no-read-expansion` turns off read widening without disabling the read-before-edit guard. It promotes `@ast-grep/cli` to `0.51.1` and `@ast-grep/napi` to `^0.51.0`. A blank `PI_LENS_*` number falls back to the default, and an explicit `0` is a value. An edit that raises a named function past the high-complexity threshold and past the default branch names that function on one line; a function the edit improved, or that is still no worse than the default branch, is not named. `ast_grep_replace` no longer requests strict JSON-schema sampling; `lens_diagnostic_mark` still does. A language server for a project outside the session folder starts only when Pi would trust that project. Four MCP tools advertise only `path`. A session rooted at `/` keeps `lsp.disabledServers`. Concatenated SQL passed to `.execute()` is an advisory full-analysis finding; a parameterized `execute(sql, values)` call stays quiet. Keeping injected findings in later requests is opt-in. A workspace edit through a dangling symlink is refused, and a symlink that resolves outside the workspace is refused; the fallback Biome config no longer names a nursery rule. An identity `filter(x => x).map(...)` stays a warning, and a non-identity `filter(fn).map(...)` is no longer flagged. A reduce that copies its accumulator with `Object.assign` is a warning. A directory whose name starts with `..` stays inside its project. `.groovy`, `.gvy`, `.gy`, `.gsh`, `Jenkinsfile`, `build.gradle`, and `settings.gradle` classify as Groovy; `build.gradle.kts` does not. `minimatch` is `^11.0.4` and `vscode-jsonrpc` is `^10.0.0`. `pi-web-access@0.47.0` provides configurable web search and fetch tools; its `toolActivation` defaults to `auto`, choosing eager or dynamic tool activation per model. `toolActivation: "none"` stays opt-in and still requires deferred exposure. Field extraction, 9router, empty or off-topic search fallback, and plain HTTP gateway URLs stay off unless configured. An unknown tool-call provider name fails instead of selecting a provider automatically, and DuckDuckGo searches stay spaced apart after a bot check. It adds structured search/fetch data for codemode and an optional, manually started `pi-web-access-mcp` stdio CLI; installing the aggregate does not start that server. Degoog, Keenable, Ceramic, Linkup, DeepSeek fetch, Cloudflare search, SearchApi, Outcrawl, Sofya, and Tabstack are explicit-only, excluded from automatic and `all` selection. `lockProxy: true` rejects a tool-call proxy other than the configured one. A GitHub repository README is returned up to 100K characters, and a clone with no `githubClone.clonePath` goes under the OS temp directory. Optional `fetchContent.curl` and Exa/Tabstack fetch routing stay off unless configured. Provider gateway base URLs are opt-in and are not configured by the aggregate. OpenAI search now defaults to `gpt-6-luna`, results and clone cleanup are scoped per extension instance, and the promoted `@modelcontextprotocol/sdk@^1.32.1` moves the bundle off GHSA-6qxp-vccf-f47h. Perplexity search now uses the Search API's ranked pages and snippets rather than a Sonar-generated answer; requests requiring prose still use Sonar. `pi-antigravity@0.12.0` reads Pi 0.86+ transcript system messages, so Antigravity requests carry Pi's system prompt and tools; it also registers `google_search` and `generate_image` tools that use the signed-in Antigravity account. Those tools stay direct unless `ANTIGRAVITY_DEFER_TOOLS=1`. A model removed by catalog refresh is not filled back in from the bootstrap list. Image saves reject symlink destinations. The aggregate keeps host `typebox` and `undici@^8.11.2`. `pi-provider-qoder@0.6.12` registers the `qoder` and `qoder-cn` model providers. A tool-call argument stream that is cut off before a usable call is reported as a retryable server error. Startup logs one line when the npm registry has a newer release; `PI_PROVIDER_QODER_SKIP_UPDATE_CHECK=1` skips that lookup. A queued model-busy response reports its wait instead of being ignored; a ready busy response stays retryable. A queued wait that does not fit in a safe millisecond count uses `retryAfterSeconds` instead. Agent chat prefers the account's remote-agent node and, on daily chat limit code 110, tries the next node. The chosen node is cached for one hour. Sign in with `/login qoder` (browser or a personal access token from [qoder.com/account/integrations](https://qoder.com/account/integrations)) or `/login qoder-cn` (token from [qoder.com.cn/account/integrations](https://qoder.com.cn/account/integrations)). `QODER_PERSONAL_ACCESS_TOKEN` and `QODERCN_PERSONAL_ACCESS_TOKEN` log those providers in at startup. `/qoder-usage footer on` replaces the status-bar footer for that session, so leave it off while the pi-cc footer is in use. `pi-commandcode-provider@0.8.1` registers `commandcode` beside `qoder`, `qoder-cn`, and `antigravity`. Inference uses the Provider API only. `/login` lists those subscription providers and runs only the one you select. `@tifan/pi-preferred-thinking` is no longer bundled. Per-model thinking levels come from Pi. Deprecated `@tifan/pi-titlebar-spinner` is no longer bundled; Rename remains the single owner of Herdr tab naming. `@tifan/pi-handoff` imports `@tifan/pi-rename/naming` when it generates a session name, so Rename stays installed and its `/rename` command stays registered.
67
67
 
68
68
  `pi-stash` is no longer bundled: `/btw` already preserves the main editor draft while handling side questions outside the main conversation. Prior `@herbertgao/pi-stash` releases remain available but are no longer maintained here.
69
69
 
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.23.2-local.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#368](https://github.com/HerbertGao/pi-extensions/pull/368) [`6a7741f`](https://github.com/HerbertGao/pi-extensions/commit/6a7741f944d09ac27bae47165a4c534086b6679e) Thanks [@HerbertGao](https://github.com/HerbertGao)! - Resolve the conversation viewer's jump-to-latest and scroll-to-top keys through the user's `tui.altScreen` bindings. The away-from-latest divider names that jump key, and Home and End still work as aliases.
8
+
3
9
  ## 0.23.1-local.1
4
10
 
5
11
  ### Minor Changes
@@ -165,7 +165,7 @@ In pi's `/settings → TUI mode → fullscreen`, the observer supports:
165
165
  - pi's `/settings → Fullscreen scrollbar` preference applies to the observer: `auto` appears on scrolling or hovering and hides after one second of inactivity; `always` reserves a column and stays visible even when the conversation fits; `hidden` removes the rail and its mouse target. The observer reads the main session's settings when opened, without changing them.
166
166
  - Clickable footer controls for steering, stopping, Markdown mode, and closing. Stopping still takes two presses, as with `x`.
167
167
  - Keyboard navigation and steering as before. Mouse scrolling also works while composing a steering message.
168
- - The bottom divider stays pinned above the footer (and steering composer when open). While scrolled away, a centered `[ ↓ N new messages · Ctrl+End ]` indicator within the divider counts new conversation messages, not streaming updates. Before any arrive, it reads `[ ↓ Jump to latest message · Ctrl+End ]`. Click it or press `Ctrl+End` to resume following and clear the count, without losing an open steering draft.
168
+ - The bottom divider stays pinned above the footer (and steering composer when open). While scrolled away, a centered `[ ↓ N new messages · Ctrl+End ]` indicator within the divider counts new conversation messages, not streaming updates. Before any arrive, it reads `[ ↓ Jump to latest message · Ctrl+End ]`. Click it or press the jump-to-latest key to resume following and clear the count, without losing an open steering draft. The key is `tui.altScreen.bottom` (default `Ctrl+End`); the label reflects your binding, and `End` also works. Scroll-to-top follows `tui.altScreen.top` (default `Ctrl+Home`), with `Home` as an alias.
169
169
 
170
170
  Observer mouse events are consumed, including at scroll limits, so they do not scroll, select, or click the main view underneath. Closing restores focus without editing the main prompt. The main conversation can still advance as its agent runs.
171
171
 
@@ -1119,7 +1119,7 @@ src/
1119
1119
  agent-widget.ts # Persistent widget: spinners, activity, status icons, theming
1120
1120
  fleet-list.ts # FleetView: navigable agent list below the editor
1121
1121
  conversation-viewer.ts # Live conversation overlay for viewing agent sessions
1122
- viewer-keys.ts # Viewer scroll and expand keys, resolved through user keybindings
1122
+ viewer-keys.ts # Viewer scroll, expand and jump keys, resolved through user keybindings
1123
1123
  agent-mention.ts # `@` roster (running, resumable, and startable agents) + popup rows
1124
1124
  schedule-menu.ts # /agents → Scheduled jobs submenu
1125
1125
  select-item.ts # Collision-safe ctx.ui.select wrapper (numbered rows)
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@herbertgao/pi-subagents",
3
- "version": "0.23.1-local.1",
3
+ "version": "0.23.2-local.1",
4
4
  "description": "Claude Code-style autonomous subagents and workflow orchestration for Pi, with HerbertGao-maintained UI extensions.",
5
5
  "keywords": [
6
6
  "agent",
@@ -69,10 +69,10 @@
69
69
  },
70
70
  "x-upstream": {
71
71
  "package": "@tintinweb/pi-subagents",
72
- "version": "0.23.1",
73
- "reviewedVersion": "0.23.1",
72
+ "version": "0.23.2",
73
+ "reviewedVersion": "0.23.2",
74
74
  "repository": "https://github.com/tintinweb/pi-subagents",
75
- "commit": "9bb6c822bae9f4fe8d33384b715a5e2e96d5df10",
75
+ "commit": "a35acfb3b699e49f579f494473c38c87592f6c8e",
76
76
  "trackVersion": true
77
77
  }
78
78
  }
@@ -361,8 +361,7 @@ export class ConversationViewer implements Component, Focusable {
361
361
  if (this.closed) return
362
362
  if (
363
363
  this.fullscreen &&
364
- (matchesKey(data, "ctrl+end") ||
365
- (!this.composer && matchesKey(data, "end")))
364
+ (this.keys.bottom(data) || (!this.composer && matchesKey(data, "end")))
366
365
  ) {
367
366
  this.jumpToLatest()
368
367
  return
@@ -459,7 +458,8 @@ export class ConversationViewer implements Component, Focusable {
459
458
  else if (this.keys.pageUp(data)) this.scrollView.scrollBy(-viewportHeight)
460
459
  else if (this.keys.pageDown(data))
461
460
  this.scrollView.scrollBy(viewportHeight)
462
- else if (matchesKey(data, "home")) this.scrollView.scrollToStart()
461
+ else if (this.keys.top(data) || matchesKey(data, "home"))
462
+ this.scrollView.scrollToStart()
463
463
  return
464
464
  }
465
465
  const maxScroll = Math.max(0, totalLines - viewportHeight)
@@ -479,10 +479,10 @@ export class ConversationViewer implements Component, Focusable {
479
479
  this.scrollOffset + viewportHeight,
480
480
  )
481
481
  this.autoScroll = this.scrollOffset >= maxScroll
482
- } else if (matchesKey(data, "home")) {
482
+ } else if (this.keys.top(data) || matchesKey(data, "home")) {
483
483
  this.scrollOffset = 0
484
484
  this.autoScroll = false
485
- } else if (matchesKey(data, "end")) {
485
+ } else if (this.keys.bottom(data) || matchesKey(data, "end")) {
486
486
  this.scrollOffset = maxScroll
487
487
  this.autoScroll = true
488
488
  }
@@ -741,7 +741,11 @@ export class ConversationViewer implements Component, Focusable {
741
741
  this.newMessages > 0
742
742
  ? `${this.newMessages} new message${this.newMessages === 1 ? "" : "s"}`
743
743
  : "Jump to latest message"
744
- const label = truncateToWidth(`[ ↓ ${text} · Ctrl+End ]`, innerW, "…")
744
+ const label = truncateToWidth(
745
+ `[ ↓ ${text} · ${this.keys.jumpToLatestLabel()} ]`,
746
+ innerW,
747
+ "…",
748
+ )
745
749
  const labelWidth = visibleWidth(label)
746
750
  const padding = Math.floor((innerW - labelWidth) / 2)
747
751
  this.latestTarget = {
@@ -1,9 +1,11 @@
1
1
  /**
2
- * viewer-keys.ts — Scroll key matchers for the conversation viewer.
2
+ * viewer-keys.ts — Scroll, expand and jump key matchers for the conversation viewer.
3
3
  *
4
- * Resolves `tui.select.*` through the user's keybindings when pi provides a
5
- * manager, falling back to the previous hardcoded keys otherwise. The viewer's
6
- * k/j and shift+arrow aliases always work alongside whatever is bound.
4
+ * Resolves `tui.select.*`, `app.tools.expand` and the `tui.altScreen.top`/
5
+ * `tui.altScreen.bottom` jump keys through the user's keybindings when pi
6
+ * provides a manager, falling back to the previous hardcoded keys otherwise. The
7
+ * viewer's k/j, shift+arrow and home/end aliases always work alongside whatever
8
+ * is bound.
7
9
  */
8
10
 
9
11
  import { type KeyId, matchesKey } from "@earendil-works/pi-tui"
@@ -15,10 +17,13 @@ export type ViewerKeybindingId =
15
17
  | "tui.select.pageUp"
16
18
  | "tui.select.pageDown"
17
19
  | "app.tools.expand"
20
+ | "tui.altScreen.top"
21
+ | "tui.altScreen.bottom"
18
22
 
19
23
  /** Structural subset of pi-tui's `KeybindingsManager` (which satisfies it). */
20
24
  export interface ViewerKeybindings {
21
25
  matches(data: string, keybinding: ViewerKeybindingId): boolean
26
+ getKeys(keybinding: ViewerKeybindingId): KeyId[]
22
27
  }
23
28
 
24
29
  export interface ViewerKeys {
@@ -28,6 +33,33 @@ export interface ViewerKeys {
28
33
  pageDown(data: string): boolean
29
34
  /** Unfold the output of the viewer's tool blocks, as in the main transcript. */
30
35
  expand(data: string): boolean
36
+ /** Scroll to the start of the conversation (`tui.altScreen.top`). */
37
+ top(data: string): boolean
38
+ /** Jump to the latest message and resume following (`tui.altScreen.bottom`). */
39
+ bottom(data: string): boolean
40
+ /** Display label for the jump-to-latest key, e.g. `Ctrl+End`, for the divider. */
41
+ jumpToLatestLabel(): string
42
+ }
43
+
44
+ /**
45
+ * `ctrl+end` → `Ctrl+End`. The pure formatter pi uses (`formatKeyText`) lives in
46
+ * an unexported submodule, and the exported hint helpers resolve the extension's
47
+ * own package copy — whose global keybindings are empty — so they render without
48
+ * the key (pi #4748). Formatting the injected manager's own resolved keys here
49
+ * sidesteps both.
50
+ */
51
+ function formatKeyLabel(key: KeyId): string {
52
+ return key
53
+ .split("+")
54
+ .map((part) => {
55
+ // `alt` reads as `option` on macOS, the way pi's own `formatKeyPart` renders it.
56
+ const display =
57
+ process.platform === "darwin" && part.toLowerCase() === "alt"
58
+ ? "option"
59
+ : part
60
+ return display.charAt(0).toUpperCase() + display.slice(1)
61
+ })
62
+ .join("+")
31
63
  }
32
64
 
33
65
  export function createViewerKeys(keybindings?: ViewerKeybindings): ViewerKeys {
@@ -49,5 +81,16 @@ export function createViewerKeys(keybindings?: ViewerKeybindings): ViewerKeys {
49
81
  matches(data, "tui.select.pageDown", "pageDown") ||
50
82
  matchesKey(data, "shift+down"),
51
83
  expand: (data) => matches(data, "app.tools.expand", "ctrl+o"),
84
+ // The configurable binding only; the home/end aliases stay at the call sites
85
+ // so the fullscreen "end only when not composing" rule is preserved.
86
+ top: (data) => matches(data, "tui.altScreen.top", "home"),
87
+ bottom: (data) => matches(data, "tui.altScreen.bottom", "ctrl+end"),
88
+ jumpToLatestLabel: () => {
89
+ const keys = keybindings
90
+ ? keybindings.getKeys("tui.altScreen.bottom")
91
+ : (["ctrl+end"] as KeyId[])
92
+ // Unbound → the bare `end` alias is still live, so name it.
93
+ return keys.length > 0 ? formatKeyLabel(keys[0]) : "End"
94
+ },
52
95
  }
53
96
  }
@@ -1,5 +1,17 @@
1
1
  # @narumitw/pi-btw
2
2
 
3
+ ## 0.63.7
4
+
5
+ ### Patch Changes
6
+
7
+ - b2b91fa: Reduce main-thread tree picker allocations by joining raw text fragments only when copying and storing saved labels only when needed.
8
+
9
+ ## 0.63.6
10
+
11
+ ### Patch Changes
12
+
13
+ - aca87cf: Fix call stack overflows when opening the main-thread tree picker for deep session histories.
14
+
3
15
  ## 0.63.5
4
16
 
5
17
  ### Patch Changes
@@ -61,9 +61,7 @@ async function pickMainEntry(pi, ctx, dependencies = {}) {
61
61
  notifySafely(ctx, "No main-thread entries are available", "warning");
62
62
  return { kind: "back" };
63
63
  }
64
- const tree = sanitizeTreeForDisplay(rawTree);
65
- const rawCopyText = collectRawCopyText(rawTree);
66
- const savedLabels = collectSavedLabels(rawTree);
64
+ const { tree, rawCopyText, savedLabels } = prepareTreeSnapshot(rawTree);
67
65
  const createSelector = dependencies.createSelector ?? createNativeTreeSelector;
68
66
  const copy = dependencies.copyToClipboard ?? copyText;
69
67
  const copyControllers = /* @__PURE__ */ new Set();
@@ -84,7 +82,14 @@ async function pickMainEntry(pi, ctx, dependencies = {}) {
84
82
  };
85
83
  const onCopy = (entryId, displayText) => {
86
84
  if (settled) return;
87
- const text = entryId ? rawCopyText.get(entryId) : displayText;
85
+ let text;
86
+ try {
87
+ const source = entryId ? rawCopyText.get(entryId) : displayText;
88
+ text = typeof source === "string" ? source : source?.join("");
89
+ } catch (error) {
90
+ notifySafely(ctx, `Could not copy selected message: ${formatError(error)}`, "error");
91
+ return;
92
+ }
88
93
  if (!text) {
89
94
  notifySafely(ctx, "Selected entry has no text to copy", "warning");
90
95
  return;
@@ -125,7 +130,8 @@ async function pickMainEntry(pi, ctx, dependencies = {}) {
125
130
  }
126
131
  const persistedLabel = label === void 0 ? void 0 : sanitizeSingleLine(label);
127
132
  pi.setLabel(entryId, persistedLabel);
128
- savedLabels.set(entryId, { label: persistedLabel });
133
+ if (persistedLabel === void 0) savedLabels.delete(entryId);
134
+ else savedLabels.set(entryId, { label: persistedLabel });
129
135
  selector?.setViewLabel?.(entryId, persistedLabel);
130
136
  tui.requestRender();
131
137
  } catch (error) {
@@ -162,18 +168,37 @@ function createNativeTreeSelector(options) {
162
168
  result.setViewLabel = (entryId, label, labelTimestamp) => selector.getTreeList().updateNodeLabel(entryId, label, labelTimestamp);
163
169
  return result;
164
170
  }
165
- function sanitizeTreeForDisplay(tree) {
166
- return tree.map((node) => {
167
- const result = {
171
+ function prepareTreeSnapshot(rawTree) {
172
+ const tree = [];
173
+ const rawCopyText = /* @__PURE__ */ new Map();
174
+ const savedLabels = /* @__PURE__ */ new Map();
175
+ const stack = [{ source: rawTree, target: tree, index: 0 }];
176
+ while (stack.length > 0) {
177
+ const frame = stack[stack.length - 1];
178
+ if (frame.index === frame.source.length) {
179
+ stack.pop();
180
+ continue;
181
+ }
182
+ const node = frame.source[frame.index++];
183
+ const label = node.label === void 0 ? void 0 : sanitizeSingleLine(node.label);
184
+ const labelTimestamp = node.labelTimestamp === void 0 ? void 0 : sanitizeSingleLine(node.labelTimestamp);
185
+ const displayNode = {
168
186
  entry: sanitizeEntryForDisplay(node.entry),
169
- children: sanitizeTreeForDisplay(node.children)
187
+ children: []
170
188
  };
171
- if (node.label !== void 0) result.label = sanitizeSingleLine(node.label);
172
- if (node.labelTimestamp !== void 0) {
173
- result.labelTimestamp = sanitizeSingleLine(node.labelTimestamp);
189
+ if (label !== void 0) displayNode.label = label;
190
+ if (labelTimestamp !== void 0) displayNode.labelTimestamp = labelTimestamp;
191
+ frame.target.push(displayNode);
192
+ const source = captureRawCopySource(node.entry);
193
+ if (source !== void 0) rawCopyText.set(node.entry.id, source);
194
+ if (label !== void 0 || labelTimestamp !== void 0) {
195
+ savedLabels.set(node.entry.id, { label, labelTimestamp });
174
196
  }
175
- return result;
176
- });
197
+ if (node.children.length > 0) {
198
+ stack.push({ source: node.children, target: displayNode.children, index: 0 });
199
+ }
200
+ }
201
+ return { tree, rawCopyText, savedLabels };
177
202
  }
178
203
  function sanitizeEntryForDisplay(entry) {
179
204
  switch (entry.type) {
@@ -263,50 +288,30 @@ function sanitizeToolArguments(value, seen) {
263
288
  }
264
289
  return result;
265
290
  }
266
- function collectRawCopyText(tree) {
267
- const result = /* @__PURE__ */ new Map();
268
- const visit = (nodes) => {
269
- for (const node of nodes) {
270
- const text = getRawCopyText(node.entry);
271
- if (text !== void 0) result.set(node.entry.id, text);
272
- visit(node.children);
273
- }
274
- };
275
- visit(tree);
276
- return result;
277
- }
278
- function getRawCopyText(entry) {
279
- let text;
291
+ function captureRawCopySource(entry) {
292
+ let source;
280
293
  if (entry.type === "message") {
281
- if (entry.message.role === "bashExecution") text = entry.message.command;
294
+ if (entry.message.role === "bashExecution") source = entry.message.command;
282
295
  else if ("content" in entry.message) {
283
- text = extractRawText(entry.message.content);
284
- if (!text && entry.message.role === "assistant") text = entry.message.errorMessage;
296
+ source = captureRawText(entry.message.content);
297
+ const empty = typeof source === "string" ? source.length === 0 : source.every((part) => part.length === 0);
298
+ if (empty && entry.message.role === "assistant") source = entry.message.errorMessage;
285
299
  }
286
- } else if (entry.type === "custom_message") text = extractRawText(entry.content);
287
- else if (entry.type === "compaction" || entry.type === "branch_summary") text = entry.summary;
288
- return text?.trim() ? text : void 0;
300
+ } else if (entry.type === "custom_message") source = captureRawText(entry.content);
301
+ else if (entry.type === "compaction" || entry.type === "branch_summary") source = entry.summary;
302
+ if (typeof source === "string") return /\S/u.test(source) ? source : void 0;
303
+ return source?.some((part) => /\S/u.test(part)) ? source : void 0;
289
304
  }
290
- function extractRawText(content) {
305
+ function captureRawText(content) {
291
306
  if (typeof content === "string") return content;
292
307
  if (!Array.isArray(content)) return "";
293
- return content.filter(
294
- (block) => block !== null && typeof block === "object" && "type" in block && block.type === "text" && "text" in block && typeof block.text === "string"
295
- ).map((block) => block.text).join("");
296
- }
297
- function collectSavedLabels(tree) {
298
- const result = /* @__PURE__ */ new Map();
299
- const visit = (nodes) => {
300
- for (const node of nodes) {
301
- result.set(node.entry.id, {
302
- label: node.label === void 0 ? void 0 : sanitizeSingleLine(node.label),
303
- labelTimestamp: node.labelTimestamp === void 0 ? void 0 : sanitizeSingleLine(node.labelTimestamp)
304
- });
305
- visit(node.children);
308
+ const parts = [];
309
+ for (const block of content) {
310
+ if (block !== null && typeof block === "object" && "type" in block && block.type === "text" && "text" in block && typeof block.text === "string") {
311
+ parts.push(block.text);
306
312
  }
307
- };
308
- visit(tree);
309
- return result;
313
+ }
314
+ return parts.length === 1 ? parts[0] : parts;
310
315
  }
311
316
  async function copyText(text, signal) {
312
317
  signal.throwIfAborted();
@@ -323,6 +328,7 @@ function formatError(error) {
323
328
  return error instanceof Error ? error.message : String(error);
324
329
  }
325
330
  export {
326
- pickMainEntry
331
+ pickMainEntry,
332
+ prepareTreeSnapshot
327
333
  };
328
- //# sourceMappingURL=main-tree-picker-WHRN26NJ.ts.map
334
+ //# sourceMappingURL=main-tree-picker-3PXJARQW.ts.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/main-tree-picker.ts"],
4
+ "sourcesContent": ["import {\n copyToClipboard,\n type ExtensionAPI,\n type ExtensionCommandContext,\n type SessionEntry,\n type SessionTreeNode,\n TreeSelectorComponent,\n} from \"@earendil-works/pi-coding-agent\";\nimport { type Component, type Focusable, Key, matchesKey } from \"@earendil-works/pi-tui\";\nimport { showBtwCustomPreservingEditor } from \"./menu.js\";\nimport { sanitizeSingleLine } from \"./text.js\";\n\nexport type MainEntryPickResult = { kind: \"selected\"; entryId: string } | { kind: \"back\" } | { kind: \"closed\" };\n\nexport interface MainThreadTreeSelector extends Component, Focusable {\n onCopy?: (text: string | undefined) => void;\n setViewLabel?(entryId: string, label: string | undefined, labelTimestamp?: string): void;\n dispose?(): void;\n}\n\nexport interface MainThreadTreeSelectorOptions {\n tree: SessionTreeNode[];\n currentLeafId: string | null;\n terminalRows: number;\n onSelect: (entryId: string) => void;\n onCancel: () => void;\n onCopy: (entryId: string | undefined, displayText: string | undefined) => void;\n onLabelChange: (entryId: string, label: string | undefined) => void;\n}\n\nexport interface MainThreadTreePickerDependencies {\n createSelector?: (options: MainThreadTreeSelectorOptions) => MainThreadTreeSelector;\n copyToClipboard?: (text: string, signal: AbortSignal) => Promise<void>;\n}\n\nclass MainThreadTreePickerComponent implements Component, Focusable {\n constructor(\n private readonly selector: MainThreadTreeSelector,\n private readonly onClose: () => void,\n ) {}\n\n get focused(): boolean {\n return this.selector.focused;\n }\n\n set focused(value: boolean) {\n this.selector.focused = value;\n }\n\n get wantsKeyRelease(): boolean | undefined {\n return this.selector.wantsKeyRelease;\n }\n\n render(width: number): string[] {\n return this.selector.render(width);\n }\n\n handleInput(data: string): void {\n if (matchesKey(data, Key.ctrl(\"c\"))) {\n this.onClose();\n return;\n }\n this.selector.handleInput?.(data);\n }\n\n invalidate(): void {\n this.selector.invalidate();\n }\n\n dispose(): void {\n this.selector.dispose?.();\n this.onClose();\n }\n}\n\nexport async function pickMainEntry(\n pi: ExtensionAPI,\n ctx: ExtensionCommandContext,\n dependencies: MainThreadTreePickerDependencies = {},\n): Promise<MainEntryPickResult> {\n let rawTree: SessionTreeNode[];\n let currentLeafId: string | null;\n try {\n rawTree = ctx.sessionManager.getTree();\n currentLeafId = ctx.sessionManager.getLeafId();\n } catch {\n return { kind: \"closed\" };\n }\n\n if (rawTree.length === 0) {\n notifySafely(ctx, \"No main-thread entries are available\", \"warning\");\n return { kind: \"back\" };\n }\n\n const { tree, rawCopyText, savedLabels } = prepareTreeSnapshot(rawTree);\n const createSelector = dependencies.createSelector ?? createNativeTreeSelector;\n const copy = dependencies.copyToClipboard ?? copyText;\n const copyControllers = new Set<AbortController>();\n const copyTasks = new Set<Promise<void>>();\n const abortCopies = () => {\n for (const controller of copyControllers) {\n controller.abort(new Error(\"The main-thread tree picker closed\"));\n }\n };\n const result = await showBtwCustomPreservingEditor<MainEntryPickResult>(ctx, (tui, _theme, _keybindings, done) => {\n let settled = false;\n let selector: MainThreadTreeSelector | undefined;\n const finish = (value: MainEntryPickResult) => {\n if (settled) return;\n settled = true;\n abortCopies();\n done(value);\n };\n const onCopy = (entryId: string | undefined, displayText: string | undefined) => {\n if (settled) return;\n let text: string | undefined;\n try {\n const source = entryId ? rawCopyText.get(entryId) : displayText;\n text = typeof source === \"string\" ? source : source?.join(\"\");\n } catch (error: unknown) {\n notifySafely(ctx, `Could not copy selected message: ${formatError(error)}`, \"error\");\n return;\n }\n if (!text) {\n notifySafely(ctx, \"Selected entry has no text to copy\", \"warning\");\n return;\n }\n const controller = new AbortController();\n copyControllers.add(controller);\n let operation: Promise<void>;\n try {\n operation = copy(text, controller.signal);\n } catch (error: unknown) {\n operation = Promise.reject(error);\n }\n let task!: Promise<void>;\n task = operation\n .then(() => {\n if (!settled) notifySafely(ctx, \"Copied selected message\", \"info\");\n })\n .catch((error: unknown) => {\n if (!settled && !controller.signal.aborted) {\n notifySafely(ctx, `Could not copy selected message: ${formatError(error)}`, \"error\");\n }\n })\n .finally(() => {\n copyControllers.delete(controller);\n copyTasks.delete(task);\n });\n copyTasks.add(task);\n };\n const restoreLabel = (entryId: string) => {\n const previous = savedLabels.get(entryId);\n selector?.setViewLabel?.(entryId, previous?.label, previous?.labelTimestamp);\n tui.requestRender();\n };\n const onLabelChange = (entryId: string, label: string | undefined) => {\n if (settled) return;\n try {\n if (!ctx.sessionManager.getEntry(entryId)) {\n restoreLabel(entryId);\n notifySafely(ctx, \"The selected main-thread entry is no longer available\", \"warning\");\n return;\n }\n const persistedLabel = label === undefined ? undefined : sanitizeSingleLine(label);\n pi.setLabel(entryId, persistedLabel);\n if (persistedLabel === undefined) savedLabels.delete(entryId);\n else savedLabels.set(entryId, { label: persistedLabel });\n selector?.setViewLabel?.(entryId, persistedLabel);\n tui.requestRender();\n } catch (error: unknown) {\n restoreLabel(entryId);\n notifySafely(ctx, `Could not update tree label: ${formatError(error)}`, \"error\");\n }\n };\n selector = createSelector({\n tree,\n currentLeafId,\n terminalRows: tui.terminal.rows,\n onSelect: (entryId) => finish({ kind: \"selected\", entryId }),\n onCancel: () => finish({ kind: \"back\" }),\n onCopy,\n onLabelChange,\n });\n return new MainThreadTreePickerComponent(selector, () => finish({ kind: \"closed\" }));\n });\n abortCopies();\n await Promise.allSettled([...copyTasks]);\n\n return result ?? { kind: \"closed\" };\n}\n\nfunction createNativeTreeSelector(options: MainThreadTreeSelectorOptions): MainThreadTreeSelector {\n const selector = new TreeSelectorComponent(\n options.tree,\n options.currentLeafId,\n options.terminalRows,\n options.onSelect,\n options.onCancel,\n options.onLabelChange,\n );\n selector.onCopy = (displayText) => options.onCopy(selector.getTreeList().getSelectedNode()?.entry.id, displayText);\n const result = selector as MainThreadTreeSelector;\n result.setViewLabel = (entryId, label, labelTimestamp) =>\n selector.getTreeList().updateNodeLabel(entryId, label, labelTimestamp);\n return result;\n}\n\ntype RawCopySource = string | readonly string[];\n\n/** @internal Package-local snapshot test boundary; not an extension entrypoint. */\nexport function prepareTreeSnapshot(rawTree: readonly SessionTreeNode[]): {\n tree: SessionTreeNode[];\n rawCopyText: Map<string, RawCopySource>;\n savedLabels: Map<string, SavedLabel>;\n} {\n const tree: SessionTreeNode[] = [];\n const rawCopyText = new Map<string, RawCopySource>();\n const savedLabels = new Map<string, SavedLabel>();\n // Keep traversal state on the heap: valid session histories can be arbitrarily deep.\n const stack = [{ source: rawTree, target: tree, index: 0 }];\n while (stack.length > 0) {\n const frame = stack[stack.length - 1];\n if (frame.index === frame.source.length) {\n stack.pop();\n continue;\n }\n const node = frame.source[frame.index++];\n const label = node.label === undefined ? undefined : sanitizeSingleLine(node.label);\n const labelTimestamp = node.labelTimestamp === undefined ? undefined : sanitizeSingleLine(node.labelTimestamp);\n const displayNode: SessionTreeNode = {\n entry: sanitizeEntryForDisplay(node.entry),\n children: [],\n };\n if (label !== undefined) displayNode.label = label;\n if (labelTimestamp !== undefined) displayNode.labelTimestamp = labelTimestamp;\n frame.target.push(displayNode);\n const source = captureRawCopySource(node.entry);\n if (source !== undefined) rawCopyText.set(node.entry.id, source);\n if (label !== undefined || labelTimestamp !== undefined) {\n savedLabels.set(node.entry.id, { label, labelTimestamp });\n }\n if (node.children.length > 0) {\n stack.push({ source: node.children, target: displayNode.children, index: 0 });\n }\n }\n return { tree, rawCopyText, savedLabels };\n}\n\nfunction sanitizeEntryForDisplay(entry: SessionEntry): SessionEntry {\n switch (entry.type) {\n case \"message\": {\n const message = { ...entry.message } as Record<string, unknown>;\n if (\"content\" in entry.message) message.content = sanitizeDisplayContent(entry.message.content);\n for (const key of [\"role\", \"errorMessage\", \"command\", \"toolName\"] as const) {\n const value = message[key];\n if (typeof value === \"string\") message[key] = sanitizeSingleLine(value);\n }\n return { ...entry, message } as unknown as SessionEntry;\n }\n case \"custom_message\":\n return {\n ...entry,\n customType: sanitizeSingleLine(entry.customType),\n content: sanitizeDisplayContent(entry.content) as typeof entry.content,\n };\n case \"compaction\":\n return { ...entry, summary: sanitizeSingleLine(entry.summary) };\n case \"branch_summary\":\n return { ...entry, summary: sanitizeSingleLine(entry.summary) };\n case \"model_change\":\n return {\n ...entry,\n provider: sanitizeSingleLine(entry.provider),\n modelId: sanitizeSingleLine(entry.modelId),\n };\n case \"thinking_level_change\":\n return { ...entry, thinkingLevel: sanitizeSingleLine(entry.thinkingLevel) };\n case \"custom\":\n return { ...entry, customType: sanitizeSingleLine(entry.customType) };\n case \"context_edit\":\n return { ...entry, targetId: sanitizeSingleLine(entry.targetId) };\n case \"label\":\n return {\n ...entry,\n label: entry.label === undefined ? undefined : sanitizeSingleLine(entry.label),\n };\n case \"session_info\":\n return {\n ...entry,\n name: entry.name === undefined ? undefined : sanitizeSingleLine(entry.name),\n };\n case \"usage\":\n return {\n ...entry,\n kind: sanitizeSingleLine(entry.kind),\n provider: sanitizeSingleLine(entry.provider),\n model: sanitizeSingleLine(entry.model),\n note: entry.note === undefined ? undefined : sanitizeSingleLine(entry.note),\n };\n }\n}\n\nfunction sanitizeDisplayContent(content: unknown): unknown {\n if (typeof content === \"string\") return sanitizeSingleLine(content);\n if (!Array.isArray(content)) return content;\n return content.map((block) => {\n if (block === null || typeof block !== \"object\" || !(\"type\" in block)) return block;\n if (block.type === \"text\" && \"text\" in block && typeof block.text === \"string\") {\n return { ...block, text: sanitizeSingleLine(block.text) };\n }\n if (block.type === \"toolCall\") {\n const copy = { ...block } as Record<string, unknown>;\n if (typeof copy.name === \"string\") copy.name = sanitizeSingleLine(copy.name);\n copy.arguments = sanitizeToolArguments(copy.arguments, new WeakMap());\n return copy;\n }\n return block;\n });\n}\n\nfunction sanitizeToolArguments(value: unknown, seen: WeakMap<object, unknown>): unknown {\n if (typeof value === \"string\") return sanitizeSingleLine(value);\n if (value === null || typeof value !== \"object\") return value;\n const existing = seen.get(value);\n if (existing !== undefined) return existing;\n if (Array.isArray(value)) {\n const result: unknown[] = [];\n seen.set(value, result);\n for (const item of value) result.push(sanitizeToolArguments(item, seen));\n return result;\n }\n const result: Record<string, unknown> = {};\n seen.set(value, result);\n for (const [key, item] of Object.entries(value)) {\n result[key] = sanitizeToolArguments(item, seen);\n }\n return result;\n}\n\nfunction captureRawCopySource(entry: SessionEntry): RawCopySource | undefined {\n let source: RawCopySource | undefined;\n if (entry.type === \"message\") {\n if (entry.message.role === \"bashExecution\") source = entry.message.command;\n else if (\"content\" in entry.message) {\n source = captureRawText(entry.message.content);\n const empty = typeof source === \"string\" ? source.length === 0 : source.every((part) => part.length === 0);\n if (empty && entry.message.role === \"assistant\") source = entry.message.errorMessage;\n }\n } else if (entry.type === \"custom_message\") source = captureRawText(entry.content);\n else if (entry.type === \"compaction\" || entry.type === \"branch_summary\") source = entry.summary;\n if (typeof source === \"string\") return /\\S/u.test(source) ? source : undefined;\n return source?.some((part) => /\\S/u.test(part)) ? source : undefined;\n}\n\nfunction captureRawText(content: unknown): RawCopySource {\n if (typeof content === \"string\") return content;\n if (!Array.isArray(content)) return \"\";\n // Retain immutable strings, not live blocks or joined copies of every message.\n const parts: string[] = [];\n for (const block of content) {\n if (\n block !== null &&\n typeof block === \"object\" &&\n \"type\" in block &&\n block.type === \"text\" &&\n \"text\" in block &&\n typeof block.text === \"string\"\n ) {\n parts.push(block.text);\n }\n }\n return parts.length === 1 ? parts[0] : parts;\n}\n\ninterface SavedLabel {\n label: string | undefined;\n labelTimestamp?: string;\n}\n\nasync function copyText(text: string, signal: AbortSignal): Promise<void> {\n signal.throwIfAborted();\n await copyToClipboard(text);\n signal.throwIfAborted();\n}\n\nfunction notifySafely(\n ctx: ExtensionCommandContext,\n message: string,\n level: Parameters<ExtensionCommandContext[\"ui\"][\"notify\"]>[1],\n): void {\n try {\n ctx.ui.notify(sanitizeSingleLine(message), level);\n } catch {\n // The command context may have been replaced while the selector was open.\n }\n}\n\nfunction formatError(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;AAAA;AAAA,EACE;AAAA,EAKA;AAAA,OACK;AACP,SAAyC,KAAK,kBAAkB;AA2BhE,IAAM,gCAAN,MAAoE;AAAA,EAClE,YACmB,UACA,SACjB;AAFiB;AACA;AAAA,EAChB;AAAA,EAFgB;AAAA,EACA;AAAA,EAGnB,IAAI,UAAmB;AACrB,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA,EAEA,IAAI,QAAQ,OAAgB;AAC1B,SAAK,SAAS,UAAU;AAAA,EAC1B;AAAA,EAEA,IAAI,kBAAuC;AACzC,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA,E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AAC1B,SAAO,eAAe;AACxB;AAEA,SAAS,aACP,KACA,SACA,OACM;AACN,MAAI;AACF,QAAI,GAAG,OAAO,mBAAmB,OAAO,GAAG,KAAK;AAAA,EAClD,QAAQ;AAAA,EAER;AACF;AAEA,SAAS,YAAY,OAAwB;AAC3C,SAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;",
6
+ "names": ["result"]
7
+ }
@@ -217,7 +217,7 @@ var runFullscreenOnFirstUse = async (ctx, run, options) => {
217
217
  return runBtwFullscreen(ctx, run, options);
218
218
  };
219
219
  var pickEntryOnFirstUse = async (pi, ctx) => {
220
- const { pickMainEntry } = await import("./chunks/main-tree-picker-WHRN26NJ.ts");
220
+ const { pickMainEntry } = await import("./chunks/main-tree-picker-3PXJARQW.ts");
221
221
  if (ctx.signal?.aborted) return { kind: "closed" };
222
222
  return pickMainEntry(pi, ctx);
223
223
  };
@@ -0,0 +1,39 @@
1
+ # Main-thread tree snapshots
2
+
3
+ The tree picker preserves the entries available when it opens. Display text is sanitized, but copying uses the original text captured in that snapshot, not a later lookup in the current session.
4
+
5
+ ## Allocation behavior
6
+
7
+ `prepareTreeSnapshot()` builds the sanitized tree in one iterative depth-first traversal. It keeps one raw string for single-block copy sources and an array of immutable strings for multi-block sources. It does not retain image or tool-call payloads in copy sources. The copy callback joins only the selected entry's fragments and does not cache that joined string. If joining fails, the picker reports a sanitized copy error without starting clipboard work.
8
+
9
+ Whitespace-only sources are excluded without joining them. Assistant errors replace empty content, but do not replace whitespace-only content. Copy preserves the original spaces, line breaks, terminal controls, and text-block order.
10
+
11
+ The saved-label map contains only entries with a defined label or timestamp. Empty strings and timestamp-only values remain distinct from absent values. Successful label updates replace the saved value, clearing removes it, and failed writes restore the last saved value.
12
+
13
+ The display tree still contains the full session history. Its preparation time and retained heap remain proportional to history size. Joining a selected multi-block message moves that work to each copy action; this change does not guarantee faster picker startup.
14
+
15
+ ## Measured allocation change
16
+
17
+ The baseline was repository commit `348ed352`. The comparison used the actual updated snapshot functions, without a replacement implementation. Both sides included entry sanitization and snapshot maps, but excluded Pi's core tree builder, native selector, Jiti startup, and clipboard I/O.
18
+
19
+ Measurements ran on macOS arm64 with Node `26.11.1`. Each synthetic session was a 10,000-node linear tree. Each result is the median of three separate Node processes. Each process performed three warmup preparations, then measured retained heap with `--expose-gc` before and after one preparation. The input was allocated before measurement and the output was retained through the final collection.
20
+
21
+ | Workload | Baseline heap | Updated heap | Baseline preparation | Updated preparation |
22
+ | --- | ---: | ---: | ---: | ---: |
23
+ | Short single-block messages | 6.228 MiB | 5.410 MiB | 8.07 ms | 7.71 ms |
24
+ | Four-block messages | 27.965 MiB | 18.685 MiB | 113.45 ms | 110.80 ms |
25
+ | Four-block messages, all labeled | 29.032 MiB | 20.571 MiB | 121.62 ms | 122.65 ms |
26
+ | Metadata entries | 4.184 MiB | 3.368 MiB | 2.94 ms | 2.53 ms |
27
+ | Whitespace-only blocks | 6.630 MiB | 5.812 MiB | 115.55 ms | 113.57 ms |
28
+
29
+ Message text used an entry/block prefix followed by 32 `x` characters for the short case, or 256 `x` characters per block for four-block cases. Whitespace entries had four blocks of 256 spaces. Except for the all-labeled and metadata cases, labels occurred every 1,000 entries. Metadata entries were unlabeled model changes. Disposable benchmark files were removed after the comparison.
30
+
31
+ The multi-block workload retained about 33% less snapshot heap. The other measured workloads also retained less heap. The all-labeled workload took about one millisecond longer in this sample, so the timing data does not establish a general startup-speed improvement. These samples are not deterministic test thresholds or total Pi memory measurements.
32
+
33
+ ## Verification and platform limits
34
+
35
+ `test/main-tree-snapshot.test.ts` checks fragment retention, whitespace classification, and sparse-label storage. `test/main-tree-copy.test.ts` checks copy-source branches, immutable snapshot behavior, label state transitions, missing entries, and cancellation of pending clipboard work. The existing deep-tree and Jiti tests cover native rendering and lazy package loading with 10,000 entries.
36
+
37
+ The package-directory smoke checks offline registration, RPC guards, unchanged transcript state, and shutdown. It does not verify a physical terminal or a real clipboard.
38
+
39
+ Windows terminal behavior and the original private reported session remain unverified. A Windows maintainer with a synthetic deep session can check rendering, raw copying, label rollback, and cancellation in a physical terminal. The expected behavior is unchanged; this platform check does not replace the deterministic tests or repository verification gates.
@@ -13,6 +13,7 @@ The side thread retains the last 40,000 characters of this text and adds a trunc
13
13
  The initial snapshot stays immutable. Later main progress reaches the side model only after an explicit import; see [Import main updates](#import-main-updates).
14
14
  An explicit `Shift+L` label edit is the selector's only main-session mutation and persists through Pi.
15
15
  Native tree copying reports success or failure; Escape returns to the manager and Ctrl+C closes the flow.
16
+ The [tree snapshot guide](./main-tree-snapshots.md) describes allocation behavior, measurements, and verification limits.
16
17
 
17
18
  **Resume side thread** searches retained in-memory threads by their first question and question count; threads containing only confirmed imports use **Main context updates** as their title.
18
19
  The first question remains the title; threads are ordered by their newest answer or visible error.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narumitw/pi-btw",
3
- "version": "0.63.5",
3
+ "version": "0.63.7",
4
4
  "description": "Pi extension that adds a /btw side-question command.",
5
5
  "type": "module",
6
6
  "license": "MIT",