proper-base 0.8.3 → 0.8.5

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 ADDED
@@ -0,0 +1,310 @@
1
+ # Changelog
2
+
3
+ ## [0.8.5]
4
+
5
+ Pi 1.7.0 compatibility release. `/tokens max` covers the GPT-6.2 models, automatic restart works for launches that use `--agent-dir`, and two features Pi now provides itself are removed. The package is tested against Pi 1.7.0.
6
+
7
+ ### Improvements
8
+
9
+ - **`/tokens max` for GPT-6.2 Sol, GPT-6.2 Astra, and GPT-6.1 Terra** - These models can use the 922K input window through `openai-codex`, CLIProxyAPI, or the `openai` API.
10
+
11
+ ### Fixes
12
+
13
+ - **Automatic restart with `--agent-dir`** - A Pi started with its new `--agent-dir` flag restarts after an update with the same profile, instead of asking for a manual restart.
14
+
15
+ ### Upgrade Notes
16
+
17
+ - The `↓ jump to bottom` row above the prompt is removed. Pi's own `Jump to latest message` label, shown in the transcript while it is scrolled up, replaces it.
18
+ - `PROPER_WHEEL_SCROLL_LINES` is removed. It has no effect on Pi 1.5.2 or later; set Pi's `fullscreenWheelScrollLines` under `/settings` instead.
19
+ - In a terminal that supports program resume, a Pi restarted by an automatic update reports no resume command. Quit and start Pi again to restore it.
20
+
21
+ ## [0.8.4]
22
+
23
+ Restores prompt display on Pi 1.5.1 and later, where slash-command prompts showed their expanded body and extra skill blocks appeared as raw text. Update notices and the updater's progress line also work again. The package is tested against Pi 1.5.2.
24
+
25
+ ### Fixes
26
+
27
+ - **Raw slash commands and skill disclosures on Pi 1.5.1 and later** - Prompt-template submissions show the command you typed again, and every skill block in a message collapses into its own disclosure.
28
+ - **Restart hint in update notices** - When an update is recorded for the next launch, Pi's update notices now say to restart Pi and keep saying it after a theme change.
29
+ - **Copied text matches the selection on Pi 1.5.0 and later** - Copy-on-select and the copy shortcut no longer return the line above the selection in messages with several paragraphs.
30
+ - **Updater progress after package updates** - The update widget moves on to the Pi version check when Pi 1.5.1's new package summaries appear, instead of staying on the last package.
31
+
32
+ ## [0.8.3] - 2026-11-02
33
+
34
+ Clipboard copies from Markdown blocks now render cleanly on Pi 1.5.0, dropping the stale quote borders and soft wraps that leaked in from Pi's new per-block render cache. The package is tested against Pi 1.5.0, and development lockfiles follow suit.
35
+
36
+ ### Fixes
37
+
38
+ - **Clean Markdown clipboard copies on Pi 1.5.0** - Clipboard selection drops Pi 1.5.0's new per-block render cache before replaying tokens, so copied text no longer carries quote borders or soft-wrap artifacts.
39
+
40
+ ### Upgrade Notes
41
+
42
+ - Requires Pi 1.5.0; the `undici` and `minimatch` overrides are gone because Pi now pins them itself.
43
+
44
+ ## [0.8.2] - 2026-10-29
45
+
46
+ Pi 1.4.0 compatibility release. Skill tools come back correctly after resume, and automatic compaction no longer competes with reasoning budgets on chunked input.
47
+
48
+ ### Improvements
49
+
50
+ - **Smarter summary sizing** - Automatic compaction now scales the summary budget to the summarizer's own output limit (capped at half its context window) so long reasoning runs no longer exhaust a fixed cap.
51
+ - **Reliable skill tool restoration** - Explicitly enabled skill tools are reinstated after resume, and `/skill-context on` restores a recorded removal even across restarts.
52
+
53
+ ### Fixes
54
+
55
+ - **Security patch for Undici** - Pinned Undici to 8.12.3 to close a known vulnerability in the transitive dependency.
56
+ - **Workflow worker completion** - Workflow workers now use native completion notices, keeping chunked input and multi-step runs on track.
57
+
58
+ ### Upgrade Notes
59
+
60
+ - Tested against Pi 1.4.0; upgrade Pi alongside this release. `maxOutputTokens` in proper-compact now accepts `null`/blank/`auto` and defaults to automatic sizing; explicit numeric values continue to behave as before.
61
+
62
+ lat.md sync: no code changes made here, docs untouched.
63
+
64
+ ## [0.8.1] - 2026-10-21
65
+
66
+ Overlay transcript scrolling now works cleanly with Pi 1.3.0, preserving native wheel behavior while keeping keyboard navigation available behind focused overlays. Updated dependencies also resolve a graphics-library security advisory.
67
+
68
+ ### Improvements
69
+
70
+ - **Current Pi compatibility** - Verified proper-base against Pi 1.3.0 and adapted overlay scrolling to Pi’s native wheel-event handling.
71
+ - **Focused overlay navigation** - Page Up, Page Down, Ctrl+Home, and Ctrl+End continue scrolling the transcript while an overlay has focus.
72
+
73
+ ### Fixes
74
+
75
+ - **Safer image processing dependency** - Updated Sharp to resolve its librsvg security advisory without dropping optional macOS artifacts.
76
+
77
+ ## [0.8.0] - 2026-10-05
78
+
79
+ Persistent skill context keeps selected instructions intact across turns, branches, and compaction, with multi-skill loading and explicit controls. Supported OpenAI models can also use a 922,000-token input window per session or globally.
80
+
81
+ ### Highlights
82
+
83
+ - **Persistent skill workflows** - Load multiple skills, retain complete instruction snapshots through compaction and branching, and manage selections with `/skill-context`.
84
+ - **Larger OpenAI context windows** - `/tokens max` raises supported GPT models from 272,000 to 922,000 input tokens, while session and global scopes provide control over where it applies.
85
+
86
+ ### Improvements
87
+
88
+ - **Clear sessions without losing active choices** - `/clear` now preserves the provider, model, thinking level, session Fast setting, and session context-window choice.
89
+ - **Cleaner skill transcripts** - Multiple expanded skills render as individually collapsible sections while requests remain visible and complete instructions still reach the model.
90
+ - **Consistent proactive delegation** - Proactive multi-agent guidance now applies when pi-subagents starts with only its loader active.
91
+
92
+ ### Fixes
93
+
94
+ - **Large skill selections remain complete** - Selections above 200,000 characters now request confirmation instead of being rejected or truncated, with approval remembered for unchanged selections.
95
+
96
+ ### Upgrade Notes
97
+
98
+ - Skill context management is enabled by default. Use `/skill-context off` or the settings menu to restore native Pi skill behavior.
99
+ - `/tokens max` is opt-in and may incur long-context pricing for input above 272,000 tokens.
100
+
101
+ ## [0.7.0] - 2026-09-21
102
+
103
+ Deferred automatic updates now install detected Pi and package updates on the next eligible launch, with live progress and safe restart handling. Fullscreen Markdown copying is cleaner, while long sessions and image previews stay more responsive.
104
+
105
+ ### Highlights
106
+
107
+ - **Deferred automatic updates** - Detected updates install on the next supported launch and restart Pi when safe. Control the default-enabled feature through `/settings`, `--no-auto-update`, or `PROPER_UPDATER_OFF=1`.
108
+ - **Clean Markdown copying** - Fullscreen paragraphs and blockquotes copy without borders, margins, or soft-wrap newlines while preserving intentional line breaks and code indentation.
109
+
110
+ ### Improvements
111
+
112
+ - **Smoother long sessions** - Footer rendering reuses cached usage data, session search results refresh as indexing completes, and image preview preparation no longer blocks the editor.
113
+ - **More reliable saved preferences** - Model and thinking selections persist through live Pi settings without saving automatic clamps or router placeholder values.
114
+
115
+ ### Fixes
116
+
117
+ - **Context stays intact across extensions and compaction** - Prompt contributions compose correctly, slash-command display metadata follows message identity, and edited or removed skill context is no longer restored incorrectly.
118
+
119
+ ### Upgrade Notes
120
+
121
+ - Restart Pi once after upgrading from releases with permanent host patches. Automatic updates require npm-installed Pi 0.86+ on Linux or macOS with Node 22.19+; unsupported launches retain manual update instructions.
122
+
123
+ ## [0.6.0] - 2026-09-11
124
+
125
+ Proactive multi-agent delegation now routes worthwhile parallel work to suitable enabled models while keeping tightly coupled tasks local. Overlay sessions remain navigable, live widgets scroll naturally, and Fast status appears immediately.
126
+
127
+ ### Highlights
128
+
129
+ - **Smarter automatic delegation** - Independent work can run concurrently using session-enabled models, while small, sequential, and same-area tasks stay in the current session.
130
+ - **Scrollable overlay sessions** - Wheel controls and transcript scroll keys keep earlier context reachable while questionnaires and other overlays have focus.
131
+
132
+ ### Improvements
133
+
134
+ - **Live widgets follow the conversation** - Extension widgets now scroll at the transcript tail and release unused rows as their content shrinks.
135
+ - **Immediate Fast status** - Session-scoped `/fast` toggles update the footer chip immediately without duplicating provider indicators.
136
+
137
+ ### Fixes
138
+
139
+ - **Astra capacity failures recover automatically** - Model-at-capacity responses now enter Pi's normal retry and backoff flow.
140
+
141
+ ### Upgrade Notes
142
+
143
+ - Proactive delegation is enabled by default. Set `"proactiveDelegation": false` in `proper-base.json` to retain explicit-only delegation.
144
+
145
+ ## [0.5.1] - 2026-09-05
146
+
147
+ `/model` now sets the model and thinking level in one autocomplete-driven command. Model and thinking-level choices also persist as Pi startup defaults. Prompt editing gains safer history recall and control over click-to-position behavior.
148
+
149
+ ### Highlights
150
+
151
+ - **Set model and thinking level together** - Use `/model provider/model level` to apply both choices, with level autocomplete and immediate submission after completing the final level.
152
+ - **Keep preferred defaults across sessions** - Model and thinking-level selections become Pi startup defaults, and unsupported levels are saved as the level Pi actually applies.
153
+
154
+ ### Improvements
155
+
156
+ - **Protect typed drafts** - Up recalls history only from an empty prompt, so Home then Up no longer replaces text already entered.
157
+ - **Control prompt mouse clicks** - A new `/settings` toggle prevents prompt clicks from moving the cursor while preserving drag-to-select and border clicks.
158
+
159
+ ### Fixes
160
+
161
+ - **Wait for actual tool output** - Transcript cleanup recognizes Pi 0.85.0's updated Working indicator, preventing premature compaction while output is still pending.
162
+
163
+ ### Upgrade Notes
164
+
165
+ - `Tab` on a model completion no longer switches immediately. Press `Enter` to keep the current thinking level, or complete a level and press `Tab` or `Enter` to apply both.
166
+ - Model and thinking-level selections now persist by default. Set `"stickyDefaults": false` in `~/.pi/agent/proper-base.json` to retain session-only behavior.
167
+
168
+ ## [0.5.0] - 2026-09-01
169
+
170
+ A new session action rail makes long transcripts easier to navigate, with clickable markers for prompts, replies, tools, and failures. Autocomplete and paste handling now remain reliable through command selection, history search, and image previews.
171
+
172
+ ### Highlights
173
+
174
+ - **Navigate sessions at a glance** - A color-coded rail marks each session action, highlights the current position, reveals labels on hover, and jumps directly to an action when clicked.
175
+ - **Keep the transcript uncluttered** - A persisted settings toggle disables the session action rail when it is not needed.
176
+
177
+ ### Improvements
178
+
179
+ - **Continue slash commands without interruption** - Accepting a command immediately opens its argument suggestions, while word and line deletion keeps the menu synchronized with the edited prompt.
180
+
181
+ ### Fixes
182
+
183
+ - **Large pastes remain intact** - Reverse history search and image preview updates no longer cause paste markers to submit as literal tags.
184
+ - **Images pasted during active runs stay usable** - Image markers waiting in the editor continue resolving to their source paths after the current run finishes.
185
+
186
+ ## [0.4.0] - 2026-08-30
187
+
188
+ Links in Scribe now remain one clickable target when URLs wrap across rows. Fullscreen transcript scrolling is faster and configurable. Prompt cancellation, selection copying, and Linux clipboard use are more reliable.
189
+
190
+ ### Highlights
191
+
192
+ - **Whole-link activation in Scribe** - Wrapped URLs now highlight and open as one link, avoiding partial URL clicks.
193
+ - **Faster fullscreen scrolling** - Mouse-wheel scrolling now moves three lines by default, with `PROPER_WHEEL_SCROLL_LINES` available for per-terminal tuning.
194
+
195
+ ### Improvements
196
+
197
+ - **Stable Linux clipboard use** - Clipboard reads avoid an X11 connection leak that could eventually exhaust Xorg clients and cause desktop-wide paste failures.
198
+
199
+ ### Fixes
200
+
201
+ - **Cancelled prompts stay cancelled** - Pressing Esc before assistant content arrives now removes the aborted turn from model context.
202
+ - **Copy preserves fullscreen selections** - Pi 0.84.4’s `app.message.copy` binding no longer clears the selection before copying.
203
+
204
+ ### Upgrade Notes
205
+
206
+ - Linux clipboard text reads now require `wl-paste`, `xclip`, or `xsel`. Install one if none is available.
207
+ - Compatibility is tested against Pi 0.84.4.
208
+
209
+ ## [0.3.0] - 2026-08-28
210
+
211
+ Fast mode now separates session and global priority control for supported CLIProxyAPI models. The `/resume` picker opens much faster on large transcript collections, while fullscreen interactions behave more predictably.
212
+
213
+ ### Highlights
214
+
215
+ - **Choose the right Fast mode scope** - `/fast` applies priority service to the current session; `/fast-global` persists it across sessions and updates running sessions on their next request.
216
+ - **Resume large histories sooner** - `/resume` displays rows before full-text search finishes; measured listing time fell from 6.4 seconds to 1.0 second across 394 sessions totaling 2.7 GB.
217
+ - **Dismiss stale selections naturally** - Typing or pasting now clears fullscreen mouse highlights without consuming input, preventing old selections from repainting over new content.
218
+
219
+ ### Improvements
220
+
221
+ - **Expand extension entries directly** - Clicking a custom transcript entry header now expands that entry, matching existing tool-summary behavior.
222
+ - **Keep long sessions responsive** - Idle autocomplete and image-preview frames avoid unnecessary layout work, while prompt-position readings reuse unchanged results.
223
+
224
+ ### Fixes
225
+
226
+ - **Cancel rewritten prompts cleanly** - Cancelling an unprocessed prompt now removes related extension entries from the active branch instead of leaving orphan transcript rows.
227
+
228
+ ### Upgrade Notes
229
+
230
+ - `/fast` no longer persists globally; it resets when a session starts or resumes. Use `/fast-global` wherever existing workflows depended on the provider’s previous persistent `/fast` behavior.
231
+
232
+ ## [0.2.8] - 2026-08-26
233
+
234
+ Prompt navigation arrows now jump between user prompts and scroll to the latest output. Skill reuse consumes less context while keeping instructions available after compaction.
235
+
236
+ ### Highlights
237
+
238
+ - **Jump between prompts** - Use the transcript’s corner arrows to move through prompts, see the current prompt position, or return to the end.
239
+ - **Reuse skills without duplicate context** - Repeated skill invocations keep the request but replace identical instruction copies with a short note. Compaction restores needed instructions within bounded context limits.
240
+
241
+ ### Fixes
242
+
243
+ - **Collapsed rows remain clickable while scrolling** - Transcript controls now respond to the row currently visible, even when scrolling briefly advances ahead of the painted screen.
244
+
245
+ ## [0.2.7] - 2026-08-25
246
+
247
+ Clipboard images now appear as bounded thumbnails in Kitty-compatible terminals, making pasted images easier to review before sending. Loading feedback and text fallbacks keep the editor usable when previews are delayed or unavailable.
248
+
249
+ ### Highlights
250
+
251
+ - **Preview pasted images before sending** - Clipboard image markers render as compact thumbnails without repeatedly loading full-size image data.
252
+
253
+ ### Improvements
254
+
255
+ - **Edit image markers as single items** - Navigation and deletion now treat each image marker as one highlighted editor token.
256
+
257
+ ### Fixes
258
+
259
+ - **Restore previews after focus changes** - Returning to the terminal retransmits thumbnails that may have disappeared while focus was elsewhere.
260
+
261
+ ## [0.2.6] - 2026-08-24
262
+
263
+ `/refine` replaces `/backlog` with planning built around selected cards and scoped sources. Collapsed transcripts now identify proxied MCP tools and keep controls accurate while scrolling.
264
+
265
+ ### Highlights
266
+
267
+ - **Refine work from relevant context** - Plan from a selected card and limit which sources inform the result.
268
+ - **Identify proxied tool calls** - Collapsed transcript entries show the underlying MCP tool name.
269
+
270
+ ### Improvements
271
+
272
+ - **Cleaner transcript controls** - Bold chevrons and scroll-aware mouse targets improve navigation while removing interaction hints and terminal links.
273
+
274
+ ### Upgrade Notes
275
+
276
+ - Replace `/backlog` with `/refine` in saved prompts, documentation, and workflows.
277
+
278
+ ## [0.2.5] - 2026-08-24
279
+
280
+ Commit commands that break project rules are now blocked before they run, with all problems reported together. Router controls, transcript following, and footer model labels also behave more reliably.
281
+
282
+ ### Highlights
283
+
284
+ - **Safer automated commits** - Bash and Quill commit commands must use direct, compliant invocations and valid messages, reducing failed hooks and malformed commit history.
285
+
286
+ ### Improvements
287
+
288
+ - **Faster router configuration** - Config pickers open on saved values, wrap between list boundaries, and correctly locate the active judge configuration.
289
+ - **Transcript follows new output** - Submitting a prompt restores output-following mode in the fullscreen transcript.
290
+
291
+ ### Fixes
292
+
293
+ - **Model tags remain visible** - Footer labels such as CLIProxyAPI's fast tag no longer disappear when terminal width is limited.
294
+
295
+ ## [0.2.4] - 2026-08-23
296
+
297
+ Long transcripts now stay responsive instead of repeatedly rebuilding settled messages and consuming full CPU. Installation is more predictable because proper-base no longer changes Pi settings or runs post-install setup.
298
+
299
+ ### Highlights
300
+
301
+ - **Responsive long sessions** - Settled transcript content is reused until relevant state changes, eliminating per-frame rebuilds while preserving updates after resizing, theme changes, and terminal changes.
302
+
303
+ ### Improvements
304
+
305
+ - **Side-effect-free installation** - Installing proper-base no longer writes to Pi settings, so existing preferences remain untouched.
306
+ - **Safer optional flow setup** - Setup installs proper-flow and beads-flow only when `bd` is available and checks for `jq` before running the beads-flow installer.
307
+
308
+ ## [0.2.3] - 2026-08-22
309
+
310
+ Maintenance release — no user-facing changes.
package/README.md CHANGED
@@ -42,9 +42,9 @@ proactive subagent delegation, and deferred automatic updates.
42
42
  - CLIProxyAPI `empty_stream` failures and `Selected model is at capacity`
43
43
  overload errors become normal retryable network errors, so Pi applies its
44
44
  existing retry budget and backoff.
45
- - `/tokens max` raises an OpenAI model's context window from its 272K default
46
- to the backend's 922K input cap for this session, through `openai-codex`,
47
- CLIProxyAPI, or the `openai` API. `/tokens default` returns to
45
+ - `/tokens max` raises an OpenAI model's context window from its 272K or 500K
46
+ default to the backend's 922K input cap for this session, through
47
+ `openai-codex`, CLIProxyAPI, or the `openai` API. `/tokens default` returns to
48
48
  the default. Append `global` to set it for every session (saved as
49
49
  `contextTokens` in `~/.pi/agent/proper-base.json`); a session choice
50
50
  overrides the global one. Bare `/tokens` shows the current window. Tab on
@@ -173,12 +173,10 @@ to the newest output.
173
173
  | Home, End, PageUp, PageDown | Stay assigned to the prompt editor. |
174
174
  | Ctrl+Shift+Home or End | Jump the transcript to its top or bottom. |
175
175
  | Ctrl+Shift+PageUp or PageDown | Scroll the transcript by one page. |
176
- | Mouse wheel | Scroll three lines per notch instead of Pi's one. |
177
176
  | Double-click | Select a complete one-line URL, path, flag, qualified identifier, or quoted value when possible. |
178
177
 
179
- Set `PROPER_WHEEL_SCROLL_LINES` to a positive integer to change the wheel step,
180
- for example `1` in a terminal that already sends one report per scrolled line.
181
- Wheel and transcript scroll keys keep working while an `ask_user_question`
178
+ The wheel step is Pi's own `fullscreenWheelScrollLines` setting, under
179
+ `/settings`. Wheel and transcript scroll keys keep working while an `ask_user_question`
182
180
  questionnaire or other overlay has focus, so earlier context stays reachable.
183
181
 
184
182
  Typing or pasting clears a mouse selection, so a stale highlight never sits
@@ -190,10 +188,6 @@ quote borders, and screen-width line breaks. Real newlines, paragraph boundaries
190
188
  and code indentation stay intact. Works with copy-on-select and Pi's configured
191
189
  copy shortcut. Lists, tables, and unmatched custom output keep native copying.
192
190
 
193
- Scrolling away from current output adds a `↓ jump to bottom` row above the
194
- prompt. Clicking it returns to the newest output without disabling scrollbar
195
- dragging.
196
-
197
191
  Extension widgets that Pi would pin above the prompt (for example the
198
192
  pi-subagents async-agents card) render at the end of the transcript instead, so
199
193
  they scroll with the session and shrink as their content does rather than
@@ -389,7 +383,7 @@ highlight. Custom replacement footers are not changed.
389
383
 
390
384
  ## Install
391
385
 
392
- Node 22.19 or newer is required. The package is tested against Pi 1.5.0.
386
+ Node 22.19 or newer is required. The package is tested against Pi 1.7.0.
393
387
 
394
388
  From npm:
395
389
 
@@ -431,7 +425,6 @@ described in [UPDATES.md](./UPDATES.md#disable).
431
425
 
432
426
  | Environment variable | Effect |
433
427
  | --- | --- |
434
- | `PROPER_WHEEL_SCROLL_LINES` | Lines per mouse-wheel notch in fullscreen mode. Default `3`. |
435
428
  | `PROPER_UPDATER_OFF=1` | Skips automatic updates for one launch, like `--no-auto-update`. |
436
429
  | `CLIPROXYAPI_FAST` | The provider's Fast override. While it is set, `/fast-global` refuses to write. |
437
430
  | `CLIPROXYAPI_PROVIDER_ID` | Provider ID that Fast mode and `/tokens` treat as CLIProxyAPI. Otherwise `providerId` from `cliproxyapi.json`, then `cliproxyapi`. |
package/UPDATES.md CHANGED
@@ -76,6 +76,11 @@ working directory, Node arguments, Pi options, environment, and the selected
76
76
  persisted session are preserved. A PID-scoped one-shot marker prevents an
77
77
  update/restart loop and is removed before descendants inherit it.
78
78
 
79
+ One variable does not survive: Pi removes the terminal's `OSC7577_TOKEN` when
80
+ it starts. In a terminal that supports program resume, a Pi restarted this way
81
+ reports no resume command, so the terminal cannot bring that session back
82
+ after it restarts itself. Quit and start Pi again to restore that.
83
+
79
84
  Pi has no public restart API. This implementation relies on Pi 0.86's graceful
80
85
  quit ending in `process.exit(0)` and Node's experimental `process.execve`.
81
86
  The restart executable is checked against the installed version before quitting.
@@ -84,7 +89,8 @@ Automatic restart is deferred, with a warning, when:
84
89
 
85
90
  - You type during updates, have an editor draft, or have active/queued work.
86
91
  - The launch includes a prompt, `@file`, `--resume`, `--fork`, `--session-id`,
87
- unknown extension flags, or invalid arguments.
92
+ unknown extension flags, or invalid arguments. Pi's own `--agent-dir` is
93
+ safe: the restarted Pi keeps the same profile.
88
94
  - A selected session cannot be verified on disk, or the updated executable
89
95
  fails its version probe.
90
96
 
package/index.ts CHANGED
@@ -69,7 +69,6 @@ import {
69
69
  type ImagePreviewController,
70
70
  installImagePreview,
71
71
  } from "./src/image-preview.ts";
72
- import { installJumpToBottom } from "./src/jump-to-bottom.ts";
73
72
  import { installOsc8LinkIds } from "./src/osc8-link-ids.ts";
74
73
  import { installOverlayScroll } from "./src/overlay-scroll.ts";
75
74
  import {
@@ -102,7 +101,6 @@ import {
102
101
  type TranscriptCleanupController,
103
102
  } from "./src/transcript-cleanup.ts";
104
103
  import { normalizeCpaTransientError } from "./src/transient-retry.ts";
105
- import { installWheelScrollLines } from "./src/wheel-scroll.ts";
106
104
  import { installWidgetTranscript } from "./src/widget-transcript.ts";
107
105
 
108
106
  /** Prompts seeded into the editor. Older prompts past this point are dropped. */
@@ -371,12 +369,10 @@ export default function (pi: ExtensionAPI) {
371
369
 
372
370
  let removeFooterColors: (() => void) | undefined;
373
371
  let removeKeybindings: (() => void) | undefined;
374
- let removeWheelScroll: (() => void) | undefined;
375
372
  // ctx.ui.addAutocompleteProvider() returns void and stacks permanently, so
376
373
  // re-registering on every session_start would leave one live provider per
377
374
  // session load. Register the model sort exactly once.
378
375
  let autocompleteInstalled = false;
379
- let removeJumpToBottom: (() => void) | undefined;
380
376
  let removePromptJump: (() => void) | undefined;
381
377
  let settings: SettingsController | undefined;
382
378
  let removeEditorMouseGuard: (() => void) | undefined;
@@ -736,13 +732,9 @@ export default function (pi: ExtensionAPI) {
736
732
  stickyDefaults.restore();
737
733
  removeKeybindings?.();
738
734
  removeKeybindings = undefined;
739
- removeWheelScroll?.();
740
- removeWheelScroll = undefined;
741
735
  removeFooterColors?.();
742
736
  removeFooterColors = undefined;
743
737
  fastOverlay.stopDisplayRefresh();
744
- removeJumpToBottom?.();
745
- removeJumpToBottom = undefined;
746
738
  removePromptJump?.();
747
739
  removePromptJump = undefined;
748
740
  settings?.dispose();
@@ -871,9 +863,6 @@ export default function (pi: ExtensionAPI) {
871
863
  new CustomEditor(tui, theme, keybindings);
872
864
  activeEditor = editor as PromptEditor;
873
865
  activeTui = tui;
874
- // @lat: [[lat.md/proper-base/lifecycle#Prompt history lifecycle#Wheel scroll rate]]
875
- removeWheelScroll?.();
876
- removeWheelScroll = installWheelScrollLines(tui);
877
866
  // @lat: [[lat.md/proper-base/lifecycle#Prompt history lifecycle#Settled transcript]]
878
867
  transcriptCleanup?.uninstall();
879
868
  transcriptCleanup = installTranscriptCleanup(tui, ctx);
@@ -899,8 +888,6 @@ export default function (pi: ExtensionAPI) {
899
888
  removeOsc8LinkIds?.();
900
889
  removeOsc8LinkIds = installOsc8LinkIds(tui);
901
890
  historyGuard = installHistoryGuard(editor);
902
- removeJumpToBottom?.();
903
- removeJumpToBottom = installJumpToBottom(editor, tui);
904
891
  removePromptJump?.();
905
892
  settings?.dispose();
906
893
  settings = installSettings(tui, editor, getAgentDir(), (error) =>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proper-base",
3
- "version": "0.8.3",
3
+ "version": "0.8.5",
4
4
  "description": "Baseline Pi behavior for session naming, history, prompt editing, fullscreen navigation, and footer styling",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -37,6 +37,7 @@
37
37
  "index.ts",
38
38
  "src",
39
39
  "README.md",
40
+ "CHANGELOG.md",
40
41
  "UPDATES.md",
41
42
  "LICENSE"
42
43
  ],
@@ -59,6 +60,10 @@
59
60
  "@types/node": "25.9.5",
60
61
  "typescript": "6.0.2"
61
62
  },
63
+ "overrides": {
64
+ "cross-spawn@7.0.6": "7.1.2",
65
+ "minimatch@11.0.3": "11.0.9"
66
+ },
62
67
  "pi": {
63
68
  "extensions": [
64
69
  "./index.ts"
@@ -4,26 +4,37 @@ import {
4
4
  type ExtensionContext,
5
5
  InteractiveMode,
6
6
  } from "@earendil-works/pi-coding-agent";
7
+ import { Text } from "@earendil-works/pi-tui";
7
8
  import { installWrapper } from "../host-interop.ts";
8
9
  import type { UpdateKind } from "./readiness.ts";
9
10
 
11
+ function restartHint(text: string): string {
12
+ const lines = text.split("\n");
13
+ const instruction = stripVTControlCharacters(lines[1] ?? "").match(
14
+ /^(New version .+ is available\.|Package updates are available\.) Run pi update(?: --extensions)?$/,
15
+ );
16
+ if (!instruction) return text;
17
+ lines[1] = `${instruction[1]} Restart Pi to install detected updates.`;
18
+ return lines.join("\n");
19
+ }
20
+
10
21
  function showRestartHint(receiver: object, start: number): void {
11
22
  const chat = Reflect.get(receiver, "chatContainer") as
12
23
  | { children?: object[] }
13
24
  | undefined;
14
25
  if (!Array.isArray(chat?.children)) return;
15
26
  for (const child of chat.children.slice(start)) {
16
- if (child.constructor?.name !== "Text") continue;
27
+ if (!(child instanceof Text)) continue;
28
+ // Pi's notices are ThemedText: empty until first render and rebuilt from
29
+ // `build` after every theme change, so the hint has to live in `build`.
30
+ const build = Reflect.get(child, "build");
31
+ if (typeof build === "function")
32
+ Reflect.set(child, "build", () =>
33
+ restartHint(Reflect.apply(build, child, [])),
34
+ );
17
35
  const text = Reflect.get(child, "text");
18
- const setText = Reflect.get(child, "setText");
19
- if (typeof text !== "string" || typeof setText !== "function") continue;
20
- const lines = text.split("\n");
21
- const instruction = stripVTControlCharacters(lines[1] ?? "").match(
22
- /^(New version .+ is available\.|Package updates are available\.) Run pi update(?: --extensions)?$/,
23
- );
24
- if (!instruction) continue;
25
- lines[1] = `${instruction[1]} Restart Pi to install detected updates.`;
26
- Reflect.apply(setText, child, [lines.join("\n")]);
36
+ const hinted = typeof text === "string" ? restartHint(text) : text;
37
+ if (hinted !== text) child.setText(hinted);
27
38
  }
28
39
  }
29
40
 
@@ -24,6 +24,7 @@ import {
24
24
  run,
25
25
  summary,
26
26
  updateStatus,
27
+ withoutAgentDir,
27
28
  } from "./runtime.ts";
28
29
  import { installSettings } from "./settings.ts";
29
30
 
@@ -63,7 +64,7 @@ export function registerAutoUpdates(pi: ExtensionAPI): void {
63
64
  let settings: ReturnType<typeof installSettings> | undefined;
64
65
  let autoUpdateEnabled = true;
65
66
  const refreshObserver = (ctx: ExtensionContext) => {
66
- const parsed = parseArgs(process.argv.slice(2));
67
+ const parsed = parseArgs(withoutAgentDir(process.argv.slice(2), agentDir));
67
68
  if (
68
69
  ctx.mode === "tui" &&
69
70
  autoUpdateEnabled &&
@@ -102,7 +103,7 @@ export function registerAutoUpdates(pi: ExtensionAPI): void {
102
103
  ctx.ui.notify(result?.slice(0, 1200) || "Updates active.", "info");
103
104
  return;
104
105
  }
105
- const rawArgs = process.argv.slice(2);
106
+ const rawArgs = withoutAgentDir(process.argv.slice(2), agentDir);
106
107
  const parsed = parseArgs(rawArgs);
107
108
  if (
108
109
  ctx.mode !== "tui" ||
@@ -1,6 +1,6 @@
1
1
  import { spawn } from "node:child_process";
2
2
  import { type FileHandle, mkdir, open, unlink } from "node:fs/promises";
3
- import { join } from "node:path";
3
+ import { join, resolve } from "node:path";
4
4
  import { stripVTControlCharacters } from "node:util";
5
5
  import type { Args } from "@earendil-works/pi-coding-agent";
6
6
 
@@ -22,6 +22,26 @@ export function consumeRestartMarker(
22
22
  return restarted;
23
23
  }
24
24
 
25
+ /**
26
+ * Pi 1.7.0 takes each `--agent-dir <dir>` pair out of its arguments before
27
+ * parsing them, whatever the value looks like, and applies it through
28
+ * PI_CODING_AGENT_DIR, which a restart inherits. Drop the pairs Pi applied so
29
+ * the parser sees what Pi saw. A pair Pi did not apply stays and reads as an
30
+ * unknown flag, which defers restart.
31
+ */
32
+ // @lat: [[auto-updates#Restart contract]]
33
+ export function withoutAgentDir(raw: string[], agentDir: string): string[] {
34
+ const args: string[] = [];
35
+ for (let i = 0; i < raw.length; i++) {
36
+ const arg = raw[i];
37
+ if (arg === "--") return [...args, ...raw.slice(i)];
38
+ const dir = raw[i + 1];
39
+ if (arg === "--agent-dir" && dir && resolve(dir) === resolve(agentDir)) i++;
40
+ else if (arg !== undefined) args.push(arg);
41
+ }
42
+ return args;
43
+ }
44
+
25
45
  // @lat: [[auto-updates#Restart contract]]
26
46
  export function restartArgs(
27
47
  raw: string[],
@@ -130,7 +150,14 @@ export function summary(items: string[]): string {
130
150
  // command arguments, registry credentials, or private repository URLs.
131
151
  export function updateStatus(line: string): string | undefined {
132
152
  const text = stripVTControlCharacters(line).trim();
133
- if (text === "Updated packages") return "Checking Pi version…";
153
+ // Pi 1.5.1 replaced "Updated packages" with these summaries; the per-package
154
+ // lines after them stay unrecognized because they can name private sources.
155
+ if (
156
+ /^(?:Updated packages|Updated \d+ packages?:|Packages are already up to date|No packages were updated, see the warnings above|Skipped package updates \(offline mode\))$/.test(
157
+ text,
158
+ )
159
+ )
160
+ return "Checking Pi version…";
134
161
  if (text === "Updating user npm packages...")
135
162
  return "Updating global packages…";
136
163
  if (text === "Updating project npm packages...")
@@ -94,8 +94,17 @@ function markdownRows(component: MarkdownHost, width: number) {
94
94
  component,
95
95
  ) as MarkdownHost;
96
96
  delete clone.cachedLines;
97
- // Pi 1.5.0 reuses rendered blocks across renders; drop them so every token replays.
98
- delete clone.blocks;
97
+ // Pi 1.5.0 reuses a rendered block whenever its source repeats, across renders and
98
+ // within one (every "\n\n" between paragraphs), skipping renderToken for it. The
99
+ // replay counts rows per renderToken call, so defeat the lookup on the map Pi
100
+ // stores in `blocks` and every token replays.
101
+ Object.defineProperty(clone, "blocks", {
102
+ get: () => undefined,
103
+ set: (ref: { deref?(): Map<string, unknown> | undefined } | undefined) => {
104
+ const blocks = ref?.deref?.();
105
+ if (blocks) blocks.get = () => undefined;
106
+ },
107
+ });
99
108
  const renderToken = component.renderToken;
100
109
  const rows = new Map<number, Row>();
101
110
  let depth = 0;
@@ -17,8 +17,13 @@ const GLOBAL_KEY = "contextTokens";
17
17
  */
18
18
  const MAX_INPUT = 922_000;
19
19
  const CODEX_MODELS = new Set([
20
- "gpt-6-astra",
20
+ // Not probed: OpenAI documents the same 922,000 maximum input for these
21
+ // four, and Codex's catalog gives them the same 872,000 budget.
22
+ "gpt-6.2-astra",
23
+ "gpt-6.2-sol",
24
+ "gpt-6.1-terra",
21
25
  "gpt-6.1-sol",
26
+ "gpt-6-astra",
22
27
  "gpt-6-sol",
23
28
  "gpt-6-luna",
24
29
  "gpt-5.6-sol",
@@ -124,7 +124,7 @@ export function installFooterColors(
124
124
  // so cache the raw lines per width and drop them whenever a visible input
125
125
  // changes. getLeafId() is O(1) and moves on every appended entry, which is
126
126
  // what the usage totals are derived from.
127
- const baseCache = new Map<number, string[]>();
127
+ const baseCache = new Map<number, readonly string[]>();
128
128
  let baseKey: string | undefined;
129
129
  let baseTheme: FooterTheme | undefined;
130
130
  let baseAt = 0;
@@ -133,7 +133,7 @@ export function installFooterColors(
133
133
  key: string,
134
134
  theme: FooterTheme,
135
135
  now: number,
136
- ): string[] => {
136
+ ): readonly string[] => {
137
137
  if (
138
138
  key !== baseKey ||
139
139
  theme !== baseTheme ||
@@ -196,11 +196,11 @@ export function installFooterColors(
196
196
  * the line keeps its width, matching how the provider's label would sit.
197
197
  */
198
198
  function tagFast(
199
- lines: string[],
199
+ lines: readonly string[],
200
200
  width: number,
201
201
  model: string,
202
202
  theme: FooterTheme,
203
- ): string[] {
203
+ ): readonly string[] {
204
204
  const index = lines.findIndex((line) =>
205
205
  stripTerminalSequences(line).includes(model),
206
206
  );
@@ -237,11 +237,11 @@ function tagFast(
237
237
  }
238
238
 
239
239
  function layoutFooter(
240
- lines: string[],
240
+ lines: readonly string[],
241
241
  width: number,
242
242
  theme: FooterTheme,
243
- reRender?: (width: number) => string[],
244
- ): string[] {
243
+ reRender?: (width: number) => readonly string[],
244
+ ): readonly string[] {
245
245
  if (lines.length < 2 || !Number.isFinite(width) || width < 20) return lines;
246
246
 
247
247
  let statsLine = lines[1];
@@ -331,7 +331,7 @@ function realignFooterRemainder(
331
331
  }
332
332
 
333
333
  function colorFooter(
334
- lines: string[],
334
+ lines: readonly string[],
335
335
  { level, model, now, theme }: FooterColorState,
336
336
  ): string[] {
337
337
  const result = [...lines];
@@ -15,6 +15,20 @@ type Controller = { activate(manager: Manager): void; dispose(): void };
15
15
  const INSTALLED = Symbol.for("pi-proper-base.prompt-display");
16
16
  const host = globalThis as typeof globalThis & { [INSTALLED]?: Controller };
17
17
 
18
+ // Pi 1.5.1 hands out a fresh closure per registered transformer, so only the
19
+ // runner's registration record still identifies the UI this extension owns.
20
+ function owns(session: AgentSession, marker: MarkdownTransformer): boolean {
21
+ const runner = session.extensionRunner;
22
+ const extensions: unknown = runner && Reflect.get(runner, "extensions");
23
+ return (
24
+ Array.isArray(extensions) &&
25
+ extensions.some((extension) => {
26
+ const registered = extension?.markdownTransformer;
27
+ return registered === marker || registered?.transformer === marker;
28
+ })
29
+ );
30
+ }
31
+
18
32
  /** Pi 0.86 has neither input correlation nor message identity in Markdown hooks.
19
33
  * Keep this adapter removable when those APIs exist. Never emulate expansion.
20
34
  * @lat: [[lat.md/proper-base/lifecycle#Prompt history lifecycle#Prompt display]]
@@ -103,7 +117,6 @@ export function installPromptDisplayHost(
103
117
  type InteractiveHost = {
104
118
  session: AgentSession;
105
119
  getUserMessageText(message: Message): string;
106
- getMarkdownTransformers(): MarkdownTransformer[];
107
120
  addMessageToChat(
108
121
  message: Message,
109
122
  options?: { populateHistory?: boolean },
@@ -113,7 +126,7 @@ export function installPromptDisplayHost(
113
126
  const prototype = InteractiveMode.prototype as unknown as InteractiveHost;
114
127
  const original = prototype.getUserMessageText;
115
128
  const wrapped: typeof original = function (this: InteractiveHost, message) {
116
- if (!active || !this.getMarkdownTransformers().includes(marker))
129
+ if (!active || !owns(this.session, marker))
117
130
  return original.call(this, message);
118
131
  if (manager !== this.session.sessionManager) {
119
132
  // Reload rebuilds chat before session_start. Resolve entry identities now.
@@ -132,11 +145,7 @@ export function installPromptDisplayHost(
132
145
  message,
133
146
  options,
134
147
  ) {
135
- if (
136
- !active ||
137
- message.role !== "user" ||
138
- !this.getMarkdownTransformers().includes(marker)
139
- )
148
+ if (!active || message.role !== "user" || !owns(this.session, marker))
140
149
  return addMessage.call(this, message, options);
141
150
  const text = this.getUserMessageText(message);
142
151
  const { skills, request } = splitSkillText(text);
@@ -7,8 +7,7 @@ import {
7
7
  visibleWidth,
8
8
  } from "@earendil-works/pi-tui";
9
9
 
10
- import { prioritize } from "./jump-to-bottom.ts";
11
- import type { OutlineEntry } from "./transcript-cleanup.ts";
10
+ import { type OutlineEntry, prioritize } from "./transcript-cleanup.ts";
12
11
 
13
12
  const INSTALLED = Symbol.for("pi-proper-base.prompt-jump");
14
13
  // Plain arrows rather than arrowheads or chevrons: U+2303/U+2304 and the
@@ -48,7 +48,7 @@ type State = {
48
48
  type AssistantRenderCache = {
49
49
  message: AssistantMessage;
50
50
  width: number;
51
- lines: Map<string, string[]>;
51
+ lines: Map<string, readonly string[]>;
52
52
  };
53
53
  type DetailKind = "tool" | "error";
54
54
  /**
@@ -255,7 +255,9 @@ function renderActive(
255
255
  sink: OutlineEntry[],
256
256
  base: number,
257
257
  ): string[] {
258
- const output: string[][] = Array.from({ length: children.length });
258
+ const output: (readonly string[])[] = Array.from({
259
+ length: children.length,
260
+ });
259
261
  const hits: DetailHit[][] = Array.from({ length: children.length });
260
262
  let hasTextBelow = false;
261
263
  for (let index = children.length - 1; index >= 0; index--) {
@@ -484,7 +486,7 @@ function renderExpandable(
484
486
  child: Component,
485
487
  width: number,
486
488
  state: State,
487
- ): string[] {
489
+ ): readonly string[] {
488
490
  const expandable = child as ToolComponent;
489
491
  if (typeof expandable.setExpanded !== "function") return child.render(width);
490
492
  expandable.setExpanded(state.expanded.get(child) ?? state.globalExpanded);
@@ -506,7 +508,7 @@ function renderAssistantContent(
506
508
  content: AssistantMessage["content"],
507
509
  width: number,
508
510
  state: State,
509
- ): string[] {
511
+ ): readonly string[] {
510
512
  if (!assistant.updateContent) return assistant.render(width);
511
513
  // The updateContent swap below rebuilds the component's children and
512
514
  // discards their internal render caches, so re-running it every frame
@@ -530,11 +532,11 @@ function renderAssistantContent(
530
532
  }
531
533
  }
532
534
 
533
- function withVerticalSpacing(lines: string[]): string[] {
535
+ function withVerticalSpacing(lines: readonly string[]): string[] {
534
536
  return lines.length ? ["", ...lines, ""] : [];
535
537
  }
536
538
 
537
- function hasSectionText(lines: string[]): boolean {
539
+ function hasSectionText(lines: readonly string[]): boolean {
538
540
  return lines.some((line) => {
539
541
  const text = stripTerminalSequences(line).trim();
540
542
  return (
@@ -716,7 +718,14 @@ function screenLines(tui: TUI): string[] {
716
718
  return host.previousScreen ?? host.previousLines ?? [];
717
719
  }
718
720
 
719
- function prioritize(tui: TUI, listener: TuiInputListener): void {
721
+ /**
722
+ * Pi's alternate-screen renderer consumes every mouse event from a listener it
723
+ * registers in its own constructor, so an extension listener never sees a
724
+ * click. Moving ours to the front of the set is the only way a control can
725
+ * respond to the mouse; if that internal field ever changes shape the control
726
+ * keeps rendering and simply stops reacting.
727
+ */
728
+ export function prioritize(tui: TUI, listener: TuiInputListener): void {
720
729
  const listeners = (tui as MouseTui).inputListeners;
721
730
  if (!listeners?.has(listener)) return;
722
731
  const rest = [...listeners].filter((entry) => entry !== listener);
@@ -1,126 +0,0 @@
1
- import type { Component, TUI, TuiInputListener } from "@earendil-works/pi-tui";
2
- import { visibleWidth } from "@earendil-works/pi-tui";
3
-
4
- import { rowsBelow } from "./autocomplete-details.ts";
5
-
6
- const INSTALLED = Symbol.for("pi-proper-base.jump-to-bottom");
7
- const LABEL = "↓ jump to bottom";
8
- const COMPACT_LABEL = "↓";
9
- /** Columns kept clear to the right of the button, matching the footer. */
10
- const RIGHT_GAP = 1;
11
- // ESC prefix is matched separately: biome bans control characters in
12
- // regexes, and string literals carry it fine.
13
- const SGR_MOUSE_TAIL = /^\[<(\d+);(\d+);(\d+)([Mm])$/;
14
- const LEFT_BUTTON = "0";
15
-
16
- /** Alternate-screen renderer surface used for the button. */
17
- type ScrollableTui = TUI & {
18
- readonly isFollowingOutput: boolean;
19
- scrollToBottom(): void;
20
- };
21
- type ListenerHost = TUI & { inputListeners?: Set<TuiInputListener> };
22
- type JumpEditor = Component & { [INSTALLED]?: () => void };
23
- /** Screen position of the rendered button, in 0-based terminal cells. */
24
- type Hit = { row: number; start: number; end: number };
25
-
26
- function scrollableTui(tui: TUI): ScrollableTui | undefined {
27
- const candidate = tui as Partial<ScrollableTui>;
28
- return typeof candidate.scrollToBottom === "function" &&
29
- typeof candidate.isFollowingOutput === "boolean"
30
- ? (candidate as ScrollableTui)
31
- : undefined;
32
- }
33
-
34
- /**
35
- * Pi's alternate-screen renderer consumes every mouse event from a listener it
36
- * registers in its own constructor, so an extension listener never sees a
37
- * click. Moving ours to the front of the set is the only way the button can
38
- * respond to the mouse; if that internal field ever changes shape the button
39
- * keeps rendering and simply stops reacting.
40
- */
41
- export function prioritize(tui: TUI, listener: TuiInputListener): void {
42
- const listeners = (tui as ListenerHost).inputListeners;
43
- if (!listeners?.has(listener)) return;
44
- const rest = [...listeners].filter((entry) => entry !== listener);
45
- listeners.clear();
46
- listeners.add(listener);
47
- for (const entry of rest) listeners.add(entry);
48
- }
49
-
50
- /**
51
- * Render a clickable jump-to-bottom button above the prompt while the
52
- * transcript viewport is scrolled up.
53
- *
54
- * The row is part of the editor's own render output rather than an overlay:
55
- * any visible overlay disables Pi's scrollbar dragging, which is exactly the
56
- * gesture in use while the button is on screen.
57
- *
58
- * Regular-mode terminals scroll themselves, so nothing is installed there.
59
- */
60
- export function installJumpToBottom(
61
- editor: Component,
62
- tui: TUI,
63
- ): (() => void) | undefined {
64
- const target = editor as JumpEditor;
65
- const existing = target[INSTALLED];
66
- if (existing) return existing;
67
- const view = scrollableTui(tui);
68
- if (!view) return undefined;
69
-
70
- let hit: Hit | undefined;
71
-
72
- const render = target.render.bind(target);
73
- target.render = (width: number) => {
74
- const lines = render(width);
75
- if (view.isFollowingOutput) {
76
- hit = undefined;
77
- return lines;
78
- }
79
-
80
- const label =
81
- width >= visibleWidth(LABEL) + 2 + RIGHT_GAP ? LABEL : COMPACT_LABEL;
82
- const chipWidth = visibleWidth(label) + 2;
83
- const start = width - RIGHT_GAP - chipWidth;
84
- if (start < 0) {
85
- hit = undefined;
86
- return lines;
87
- }
88
-
89
- hit = {
90
- row: tui.terminal.rows - lines.length - 1 - rowsBelow(tui, target, width),
91
- start,
92
- end: start + chipWidth,
93
- };
94
- return [
95
- `${" ".repeat(start)}\x1b[7m ${label} \x1b[0m${" ".repeat(RIGHT_GAP)}`,
96
- ...lines,
97
- ];
98
- };
99
-
100
- const listener: TuiInputListener = (data) => {
101
- const button = hit;
102
- if (!button) return undefined;
103
- if (!data.startsWith("\x1b")) return undefined;
104
- const match = SGR_MOUSE_TAIL.exec(data.slice(1));
105
- if (!match || match[1] !== LEFT_BUTTON) return undefined;
106
- const column = Number.parseInt(match[2] ?? "", 10) - 1;
107
- const row = Number.parseInt(match[3] ?? "", 10) - 1;
108
- if (row !== button.row || column < button.start || column >= button.end) {
109
- return undefined;
110
- }
111
- // Consume the release too, so the renderer never sees a half press and
112
- // starts a text selection at the button.
113
- if (match[4] === "M") view.scrollToBottom();
114
- return { consume: true };
115
- };
116
- const unsubscribe = tui.addInputListener(listener);
117
- prioritize(tui, listener);
118
-
119
- const dispose = () => {
120
- unsubscribe();
121
- hit = undefined;
122
- delete target[INSTALLED];
123
- };
124
- target[INSTALLED] = dispose;
125
- return dispose;
126
- }
@@ -1,43 +0,0 @@
1
- /**
2
- * Pi's fullscreen renderer scrolls its transcript exactly one line per
3
- * mouse-wheel report. Proper-base raises that to the terminal convention.
4
- */
5
-
6
- const DEFAULT_WHEEL_SCROLL_LINES = 3;
7
- const INSTALLED = Symbol.for("pi-proper-base.wheel-scroll-lines");
8
-
9
- type WheelController = { restore(): void };
10
- type WheelHost = {
11
- wheelScrollLines?: unknown;
12
- [INSTALLED]?: WheelController;
13
- };
14
-
15
- /** Lines per wheel event: a positive integer override, else three. */
16
- export function resolveWheelScrollLines(
17
- env: Record<string, string | undefined> = process.env,
18
- ): number {
19
- const parsed = Number.parseInt(env.PROPER_WHEEL_SCROLL_LINES ?? "", 10);
20
- return parsed >= 1 ? parsed : DEFAULT_WHEEL_SCROLL_LINES;
21
- }
22
-
23
- /** Patch a fullscreen renderer and return an ownership-checked restoration. */
24
- export function installWheelScrollLines(
25
- tui: unknown,
26
- lines: number = resolveWheelScrollLines(),
27
- ): (() => void) | undefined {
28
- const host = tui as WheelHost;
29
- host[INSTALLED]?.restore();
30
- if (typeof host.wheelScrollLines !== "number") return undefined;
31
- const original = host.wheelScrollLines;
32
- const applied = Math.floor(lines);
33
- const controller: WheelController = {
34
- restore() {
35
- if (host[INSTALLED] !== controller) return;
36
- if (host.wheelScrollLines === applied) host.wheelScrollLines = original;
37
- delete host[INSTALLED];
38
- },
39
- };
40
- host.wheelScrollLines = applied;
41
- host[INSTALLED] = controller;
42
- return () => controller.restore();
43
- }