@linxiraos/pi-tui 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,24 +1,20 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [1.5.0] - 2026-11-09
3
+ ## [1.5.1] - 2026-11-10
4
4
 
5
5
  ### Added
6
6
 
7
- - Added the Team Hub overlay: a database-backed roster of rooms, PMs and engineers with room events, real-member posting, filtering and keyboard navigation.
8
- - Added the HTML form dialog used by `ask` and extension `ui.formDialog`: paginated terminal forms with keyboard navigation, images and inline SVG, free-text "Other" answers, and partial submission on inactivity timeout.
9
- - Added undo support to Editor with Ctrl+- hotkey. Undo coalesces consecutive word characters into one unit (fish-style). ([#831](https://github.com/badlogic/pi-mono/pull/831) by [@Perlence](https://github.com/Perlence))
10
- - Hardware cursor positioning for IME support in `Editor` and `Input` components. The terminal cursor now follows the text cursor position, enabling proper IME candidate window placement for CJK input. ([#719](https://github.com/badlogic/pi-mono/pull/719))
11
- - `Focusable` interface for components that need hardware cursor positioning. Implement `focused: boolean` and emit `CURSOR_MARKER` in render output when focused.
12
- - `CURSOR_MARKER` constant and `isFocusable()` type guard exported from the package
7
+ - `/channels` opens the IM operator surface in the TUI: list configured channels and their live health (`state`, `detail`, `lastError`, `since`, `lastInboundAt`), run `login`/`status`/`logout`/`unbind`, and take a per-channel pairing lock so two processes cannot pair the same account at once. The command is refused on a backend-attached client, where the owning process owns pairing.
8
+ - `/cd` is a session command with a folder-only picker: real Windows volumes (drive type and volume label; A:/B: only when the system reports them) or POSIX mount points from `/proc/mounts`, pinned folders, type-to-filter, keyboard and mouse selection, `Ctrl+P` to pin, and `Ctrl+R` to open `/resume` on the highlighted folder instead of switching to it. A `/cd <path>` argument moves directly like `/move`.
13
9
 
14
10
  ### Changed
15
11
 
16
- - Changed Editor component to use proper box borders with vertical side borders instead of horizontal-only borders
12
+ - Large transcript replays on resume now hydrate a bounded window instead of the whole session, so a multi-thousand-entry transcript no longer freezes the TUI before the first frame; scrolling past the window pages the rest in on demand.
13
+ - Starting in the home directory keeps the `~/tmp` (or OS temp) workspace and reports the switch in a startup notice instead of failing silently.
17
14
 
18
15
  ### Fixed
19
16
 
20
- - Decode Kitty CSI-u printable sequences in the editor so shifted symbol keys (e.g., `@`, `?`) work in terminals that enable Kitty keyboard protocol ([#779](https://github.com/badlogic/pi-mono/pull/779) by [@iamd3vil](https://github.com/iamd3vil))
21
- - Keyboard shortcuts (Ctrl+C, Ctrl+D, etc.) now work on non-Latin keyboard layouts (Russian, Ukrainian, Bulgarian, etc.) in terminals supporting Kitty keyboard protocol with alternate key reporting ([#718](https://github.com/badlogic/pi-mono/pull/718) by [@dannote](https://github.com/dannote))
17
+ - A `task` batch coalesces spawn progress into at most one cumulative snapshot per 100 ms (matching the subagent HUD cadence), so a wide fan-out no longer rebuilds and deep-sanitizes the transcript card once per spawn report on the TUI thread; terminal spawn snapshots still publish immediately.
22
18
 
23
19
  ## [8.4.1] - 2026-01-25
24
20
 
@@ -112,6 +108,26 @@
112
108
 
113
109
  Initial release under @oh-my-pi scope. See previous releases at [badlogic/pi-mono](https://github.com/badlogic/pi-mono).
114
110
 
111
+ ## [1.5.0] - 2026-11-09
112
+
113
+ ### Added
114
+
115
+ - Added the Team Hub overlay: a database-backed roster of rooms, PMs and engineers with room events, real-member posting, filtering and keyboard navigation.
116
+ - Added the HTML form dialog used by `ask` and extension `ui.formDialog`: paginated terminal forms with keyboard navigation, images and inline SVG, free-text "Other" answers, and partial submission on inactivity timeout.
117
+ - Added undo support to Editor with Ctrl+- hotkey. Undo coalesces consecutive word characters into one unit (fish-style). ([#831](https://github.com/badlogic/pi-mono/pull/831) by [@Perlence](https://github.com/Perlence))
118
+ - Hardware cursor positioning for IME support in `Editor` and `Input` components. The terminal cursor now follows the text cursor position, enabling proper IME candidate window placement for CJK input. ([#719](https://github.com/badlogic/pi-mono/pull/719))
119
+ - `Focusable` interface for components that need hardware cursor positioning. Implement `focused: boolean` and emit `CURSOR_MARKER` in render output when focused.
120
+ - `CURSOR_MARKER` constant and `isFocusable()` type guard exported from the package
121
+
122
+ ### Changed
123
+
124
+ - Changed Editor component to use proper box borders with vertical side borders instead of horizontal-only borders
125
+
126
+ ### Fixed
127
+
128
+ - Decode Kitty CSI-u printable sequences in the editor so shifted symbol keys (e.g., `@`, `?`) work in terminals that enable Kitty keyboard protocol ([#779](https://github.com/badlogic/pi-mono/pull/779) by [@iamd3vil](https://github.com/iamd3vil))
129
+ - Keyboard shortcuts (Ctrl+C, Ctrl+D, etc.) now work on non-Latin keyboard layouts (Russian, Ukrainian, Bulgarian, etc.) in terminals supporting Kitty keyboard protocol with alternate key reporting ([#718](https://github.com/badlogic/pi-mono/pull/718) by [@dannote](https://github.com/dannote))
130
+
115
131
  ## [1.4.13] - 2026-11-08
116
132
 
117
133
  - Released as part of Zeta 1.4.13.
@@ -0,0 +1,62 @@
1
+ import { type SgrMouseEvent } from "../index.js";
2
+ import { OverlayPanel } from "../chrome/overlay-box.js";
3
+ import type { DescribeContext, NativeNode, NativeUiEvent } from "../native/node.js";
4
+ /** One directory row the picker can show. */
5
+ export interface DirectoryPickerEntry {
6
+ /** Row label (a folder name, or a volume label for a root row). */
7
+ name: string;
8
+ /** Absolute path the row stands for. */
9
+ path: string;
10
+ /** Detail line under/next to the label: a volume kind, mount source, or path. */
11
+ detail?: string;
12
+ /** Named icon for the row. */
13
+ icon?: string;
14
+ }
15
+ /** What the picker shows at one level. */
16
+ export interface DirectoryPickerListing {
17
+ /** Directory being browsed; `null` on the roots screen (drives / mounts). */
18
+ current: string | null;
19
+ /** Parent directory, or `null` at a filesystem root or the roots screen. */
20
+ parent: string | null;
21
+ /** What the roots screen lists; the title is localized by this component. */
22
+ rootsKind?: "drives" | "mounts";
23
+ /** Volumes or mounts for the roots screen; empty while browsing a directory. */
24
+ roots: DirectoryPickerEntry[];
25
+ /** Pinned directories, always shown first. */
26
+ pins: DirectoryPickerEntry[];
27
+ /** Subdirectories of `current`, folders only. */
28
+ directories: DirectoryPickerEntry[];
29
+ /** Whether `current` itself can become the session directory. */
30
+ selectable: boolean;
31
+ }
32
+ /** Host filesystem access; synchronous so a repaint never waits on I/O. */
33
+ export interface DirectoryPickerSource {
34
+ list(directory: string | null): DirectoryPickerListing;
35
+ /** Persist a pin change; resolves to the new pinned state. */
36
+ togglePin(directory: string): Promise<boolean>;
37
+ }
38
+ export interface DirectoryPickerOptions {
39
+ source: DirectoryPickerSource;
40
+ /** Directory that is currently the session workspace. */
41
+ initialPath: string;
42
+ /** Called when the user chooses a directory (Enter, click, or a pin). */
43
+ onSelect: (directory: string) => void;
44
+ /** Secondary action: open resume filtered to this directory's conversations. */
45
+ onResume: (directory: string) => void;
46
+ onCancel: () => void;
47
+ /** Home directory, abbreviated to `~` in breadcrumbs. */
48
+ home?: string;
49
+ }
50
+ export declare class DirectoryPickerOverlay extends OverlayPanel {
51
+ #private;
52
+ constructor(options: DirectoryPickerOptions);
53
+ /** Directories listed at the current level (tests and hosts). */
54
+ get listing(): DirectoryPickerListing;
55
+ get current(): string | null;
56
+ /** Highlighted row's directory, when the row names one. */
57
+ get highlightedPath(): string | undefined;
58
+ describe(cx: DescribeContext): NativeNode | null;
59
+ handleNativeEvent(event: NativeUiEvent): void;
60
+ routeMouse(event: SgrMouseEvent, line: number, col: number): void;
61
+ handleInput(data: string): void;
62
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@linxiraos/pi-tui",
4
- "version": "1.5.0",
4
+ "version": "1.5.1",
5
5
  "description": "Terminal User Interface library with differential rendering for efficient text-based applications",
6
6
  "homepage": "https://linxira-os.github.io/zeta/",
7
7
  "author": "Linxira-OS",
@@ -38,14 +38,14 @@
38
38
  "gen:glyphs": "bun scripts/gen-glyphs.ts"
39
39
  },
40
40
  "dependencies": {
41
- "@linxiraos/zeta-schema": "1.5.0",
42
- "@linxiraos/pi-agent-core": "1.5.0",
43
- "@linxiraos/pi-ai": "1.5.0",
44
- "@linxiraos/pi-catalog": "1.5.0",
45
- "@linxiraos/pi-natives": "1.5.0",
46
- "@linxiraos/pi-utils": "1.5.0",
47
- "@linxiraos/pi-wire": "1.5.0",
48
- "@linxiraos/zeta-compact": "1.5.0"
41
+ "@linxiraos/zeta-schema": "1.5.1",
42
+ "@linxiraos/pi-agent-core": "1.5.1",
43
+ "@linxiraos/pi-ai": "1.5.1",
44
+ "@linxiraos/pi-catalog": "1.5.1",
45
+ "@linxiraos/pi-natives": "1.5.1",
46
+ "@linxiraos/pi-utils": "1.5.1",
47
+ "@linxiraos/pi-wire": "1.5.1",
48
+ "@linxiraos/zeta-compact": "1.5.1"
49
49
  },
50
50
  "devDependencies": {
51
51
  "kitty-vt-wasm": "^0.2.0"
@@ -0,0 +1,387 @@
1
+ /**
2
+ * `/cd` directory picker: a folder-only browser for the current workspace.
3
+ *
4
+ * The picker never shows files. Windows lists its real volumes (internal,
5
+ * removable, network, optical), POSIX lists mount points; both then walk the
6
+ * chosen directory's subdirectories. Pinned paths sit at the top and act
7
+ * immediately: Enter or a click switches the session there, while Ctrl+R
8
+ * (or Ctrl+click) opens the resume picker filtered to that path's
9
+ * conversations.
10
+ *
11
+ * Keys: type to filter (always on), j/k and arrows to move, Enter to open a
12
+ * folder or use the current one, Backspace to go up, Esc to cancel, Ctrl+P to
13
+ * pin/unpin the highlighted folder, Ctrl+R to resume from it. Mouse: wheel
14
+ * scrolls, a click activates the row under the pointer.
15
+ */
16
+ import * as path from "node:path";
17
+ import {
18
+ SelectList,
19
+ Text,
20
+ extractPrintableText,
21
+ matchesKey,
22
+ routeSgrMouseInput,
23
+ type SelectItem,
24
+ type SgrMouseEvent,
25
+ } from "../index";
26
+ import { getSelectListTheme, theme } from "../theme/theme";
27
+ import { OverlayPanel } from "../chrome/overlay-box";
28
+ import { routeSelectListMouseWithTopBorder } from "../chrome/select-list-mouse-routing";
29
+ import type { DescribeContext, NativeNode, NativeUiEvent } from "../native/node";
30
+ import { SelectListSheet } from "../native/picker";
31
+ import { tuiText, tuiTextFmt } from "../i18n";
32
+
33
+ /** One directory row the picker can show. */
34
+ export interface DirectoryPickerEntry {
35
+ /** Row label (a folder name, or a volume label for a root row). */
36
+ name: string;
37
+ /** Absolute path the row stands for. */
38
+ path: string;
39
+ /** Detail line under/next to the label: a volume kind, mount source, or path. */
40
+ detail?: string;
41
+ /** Named icon for the row. */
42
+ icon?: string;
43
+ }
44
+
45
+ /** What the picker shows at one level. */
46
+ export interface DirectoryPickerListing {
47
+ /** Directory being browsed; `null` on the roots screen (drives / mounts). */
48
+ current: string | null;
49
+ /** Parent directory, or `null` at a filesystem root or the roots screen. */
50
+ parent: string | null;
51
+ /** What the roots screen lists; the title is localized by this component. */
52
+ rootsKind?: "drives" | "mounts";
53
+ /** Volumes or mounts for the roots screen; empty while browsing a directory. */
54
+ roots: DirectoryPickerEntry[];
55
+ /** Pinned directories, always shown first. */
56
+ pins: DirectoryPickerEntry[];
57
+ /** Subdirectories of `current`, folders only. */
58
+ directories: DirectoryPickerEntry[];
59
+ /** Whether `current` itself can become the session directory. */
60
+ selectable: boolean;
61
+ }
62
+
63
+ /** Host filesystem access; synchronous so a repaint never waits on I/O. */
64
+ export interface DirectoryPickerSource {
65
+ list(directory: string | null): DirectoryPickerListing;
66
+ /** Persist a pin change; resolves to the new pinned state. */
67
+ togglePin(directory: string): Promise<boolean>;
68
+ }
69
+
70
+ export interface DirectoryPickerOptions {
71
+ source: DirectoryPickerSource;
72
+ /** Directory that is currently the session workspace. */
73
+ initialPath: string;
74
+ /** Called when the user chooses a directory (Enter, click, or a pin). */
75
+ onSelect: (directory: string) => void;
76
+ /** Secondary action: open resume filtered to this directory's conversations. */
77
+ onResume: (directory: string) => void;
78
+ onCancel: () => void;
79
+ /** Home directory, abbreviated to `~` in breadcrumbs. */
80
+ home?: string;
81
+ }
82
+
83
+ interface Row {
84
+ kind: "use" | "parent" | "pin" | "root" | "dir";
85
+ entry: DirectoryPickerEntry;
86
+ }
87
+
88
+ export class DirectoryPickerOverlay extends OverlayPanel {
89
+ #source: DirectoryPickerSource;
90
+ #options: DirectoryPickerOptions;
91
+ #selectList: SelectList;
92
+ #sheet: SelectListSheet;
93
+ #statusText: Text;
94
+ #rows: Row[] = [];
95
+ /** True while typed characters filter; j/k move only outside it. */
96
+ #filtering = false;
97
+ #current: string | null;
98
+ #listing: DirectoryPickerListing;
99
+ #closed = false;
100
+
101
+ constructor(options: DirectoryPickerOptions) {
102
+ super(tuiText("cdPickerTitle", "Change directory"), "zeta.overlay.cd");
103
+ this.#options = options;
104
+ this.#source = options.source;
105
+ this.#current = options.initialPath;
106
+ this.#listing = this.#source.list(this.#current);
107
+
108
+ this.#selectList = new SelectList([], 14, getSelectListTheme(), {
109
+ // Folder browsing is short; typing must filter from the first key.
110
+ search: "always",
111
+ });
112
+ this.#selectList.onSelect = item => this.#activate(Number(item.value));
113
+ this.#selectList.onCancel = () => this.#cancel();
114
+ this.addChild(this.#selectList);
115
+ this.#statusText = new Text("", 1, 0);
116
+ this.addChild(this.#statusText);
117
+ this.#sheet = new SelectListSheet(this.#selectList, {
118
+ title: tuiText("cdPickerTitle", "Change directory"),
119
+ icon: "folderMove",
120
+ noun: "folders",
121
+ });
122
+ this.#rebuild();
123
+ this.#hint();
124
+ }
125
+
126
+ /** Directories listed at the current level (tests and hosts). */
127
+ get listing(): DirectoryPickerListing {
128
+ return this.#listing;
129
+ }
130
+
131
+ get current(): string | null {
132
+ return this.#current;
133
+ }
134
+
135
+ /** Highlighted row's directory, when the row names one. */
136
+ get highlightedPath(): string | undefined {
137
+ return this.#selectedRow()?.entry.path;
138
+ }
139
+
140
+ override describe(cx: DescribeContext): NativeNode | null {
141
+ return cx.supports("picker") ? this.#sheet.describe() : super.describe(cx);
142
+ }
143
+
144
+ handleNativeEvent(event: NativeUiEvent): void {
145
+ this.#sheet.handle(event);
146
+ }
147
+
148
+ routeMouse(event: SgrMouseEvent, line: number, col: number): void {
149
+ // Ctrl+click is the secondary action on the row under the pointer.
150
+ if (event.leftClick && (event.button & 16) !== 0) {
151
+ const index = this.#selectList.hitTest(line - 1);
152
+ const row = index === undefined ? undefined : this.#rows[index];
153
+ if (row) {
154
+ this.#resume(row.entry.path);
155
+ return;
156
+ }
157
+ }
158
+ routeSelectListMouseWithTopBorder(this.#selectList, event, line, col);
159
+ }
160
+
161
+ handleInput(data: string): void {
162
+ if (this.#closed) return;
163
+ if (routeSgrMouseInput(data, event => this.#handleMouse(event))) return;
164
+ if (matchesKey(data, "ctrl+p")) {
165
+ void this.#togglePin();
166
+ return;
167
+ }
168
+ if (matchesKey(data, "ctrl+r")) {
169
+ const row = this.#selectedRow();
170
+ if (row) this.#resume(row.entry.path);
171
+ return;
172
+ }
173
+ if (this.#filtering) {
174
+ if (matchesKey(data, "escape") || matchesKey(data, "ctrl+c")) {
175
+ this.#filtering = false;
176
+ this.#selectList.setFilter("");
177
+ this.#hint();
178
+ return;
179
+ }
180
+ if (matchesKey(data, "backspace") && this.#selectList.getFilter().length === 0) {
181
+ this.#filtering = false;
182
+ this.#goUp();
183
+ return;
184
+ }
185
+ this.#selectList.handleInput(data);
186
+ this.invalidate();
187
+ return;
188
+ }
189
+ // Navigation mode: vim keys move, and typing starts a filter. `/` starts one
190
+ // explicitly, which is how a filter may begin with `j` or `k`.
191
+ if (matchesKey(data, "j")) {
192
+ this.#selectList.handleInput("\x1b[B");
193
+ this.invalidate();
194
+ return;
195
+ }
196
+ if (matchesKey(data, "k")) {
197
+ this.#selectList.handleInput("\x1b[A");
198
+ this.invalidate();
199
+ return;
200
+ }
201
+ if (matchesKey(data, "/")) {
202
+ this.#filtering = true;
203
+ this.#selectList.setFilter("");
204
+ this.#hint();
205
+ return;
206
+ }
207
+ if (matchesKey(data, "backspace")) {
208
+ this.#goUp();
209
+ return;
210
+ }
211
+ if (extractPrintableText(data) !== undefined) this.#filtering = true;
212
+ this.#selectList.handleInput(data);
213
+ this.#hint();
214
+ this.invalidate();
215
+ }
216
+
217
+ /** Footer line: the mode-specific key hints. */
218
+ #hint(): void {
219
+ this.#statusText.setText(
220
+ theme.fg(
221
+ "dim",
222
+ this.#filtering
223
+ ? tuiText("cdPickerFilterHint", "type to filter · Enter open · Esc clear filter")
224
+ : tuiText(
225
+ "cdPickerNavHint",
226
+ "j/k move · type or / to filter · Enter open · ⌫ up · Ctrl+P pin · Ctrl+R resume",
227
+ ),
228
+ ),
229
+ );
230
+ }
231
+
232
+ #handleMouse(event: SgrMouseEvent): boolean {
233
+ this.routeMouse(event, event.row, event.col);
234
+ return true;
235
+ }
236
+
237
+ #selectedRow(): Row | undefined {
238
+ const selected = this.#selectList.pickerView().selected;
239
+ if (selected === null) return undefined;
240
+ return this.#rows[Number(selected)];
241
+ }
242
+
243
+ #title(): string {
244
+ if (this.#current === null) {
245
+ return this.#listing.rootsKind === "mounts"
246
+ ? tuiText("cdPickerMounts", "Mounts")
247
+ : tuiText("cdPickerDrives", "This PC");
248
+ }
249
+ return this.#abbreviate(this.#current);
250
+ }
251
+
252
+ #abbreviate(directory: string): string {
253
+ const home = this.#options.home;
254
+ if (!home) return directory;
255
+ const normalizedHome = path.resolve(home);
256
+ const normalized = path.resolve(directory);
257
+ if (normalized === normalizedHome) return "~";
258
+ if (normalized.startsWith(`${normalizedHome}${path.sep}`)) return `~${normalized.slice(normalizedHome.length)}`;
259
+ return normalized;
260
+ }
261
+
262
+ #rebuild(): void {
263
+ this.#listing = this.#source.list(this.#current);
264
+ const rows: Row[] = [];
265
+ const items: SelectItem[] = [];
266
+ const push = (row: Row, item: Omit<SelectItem, "value">) => {
267
+ items.push({ ...item, value: String(rows.length) });
268
+ rows.push(row);
269
+ };
270
+
271
+ if (this.#current !== null && this.#listing.selectable) {
272
+ push(
273
+ { kind: "use", entry: { name: this.#title(), path: this.#current } },
274
+ {
275
+ label: tuiText("cdPickerUseThisFolder", "Use this folder"),
276
+ description: this.#title(),
277
+ },
278
+ );
279
+ }
280
+ if (this.#listing.parent) {
281
+ push(
282
+ { kind: "parent", entry: { name: "..", path: this.#listing.parent } },
283
+ { label: "..", description: this.#abbreviate(this.#listing.parent) },
284
+ );
285
+ }
286
+ for (const pin of this.#listing.pins) {
287
+ push(
288
+ { kind: "pin", entry: pin },
289
+ {
290
+ label: pin.name,
291
+ description: pin.detail ?? this.#abbreviate(pin.path),
292
+ state: tuiText("cdPickerPinned", "pin"),
293
+ },
294
+ );
295
+ }
296
+ for (const root of this.#listing.roots) {
297
+ push(
298
+ { kind: "root", entry: root },
299
+ {
300
+ label: root.name,
301
+ description: root.detail,
302
+ },
303
+ );
304
+ }
305
+ for (const directory of this.#listing.directories) {
306
+ push({ kind: "dir", entry: directory }, { label: `${directory.name}/`, description: directory.detail });
307
+ }
308
+
309
+ this.#rows = rows;
310
+ this.#selectList.setItems(items);
311
+ this.#selectList.setSelectedIndex(0);
312
+ // Keep the overlay's own chrome in sync with the level being shown.
313
+ this.title = `${tuiText("cdPickerTitle", "Change directory")} ${this.#title()}`;
314
+ this.invalidate();
315
+ }
316
+
317
+ #activate(index: number): void {
318
+ const row = this.#rows[index];
319
+ if (!row) return;
320
+ switch (row.kind) {
321
+ case "use":
322
+ case "pin":
323
+ // A pin acts immediately: choosing it switches the workspace.
324
+ this.#select(row.entry.path);
325
+ return;
326
+ case "parent":
327
+ case "root":
328
+ case "dir":
329
+ this.#navigate(row.entry.path);
330
+ return;
331
+ }
332
+ }
333
+
334
+ #navigate(directory: string | null): void {
335
+ this.#current = directory;
336
+ this.#filtering = false;
337
+ this.#selectList.setFilter("");
338
+ this.#rebuild();
339
+ this.#hint();
340
+ }
341
+
342
+ #goUp(): void {
343
+ if (this.#listing.parent) {
344
+ this.#navigate(this.#listing.parent);
345
+ return;
346
+ }
347
+ if (this.#current !== null) this.#navigate(null);
348
+ }
349
+
350
+ #select(directory: string): void {
351
+ if (this.#closed) return;
352
+ this.#closed = true;
353
+ this.#options.onSelect(directory);
354
+ }
355
+
356
+ #resume(directory: string): void {
357
+ if (this.#closed) return;
358
+ this.#closed = true;
359
+ this.#options.onResume(directory);
360
+ }
361
+
362
+ #cancel(): void {
363
+ if (this.#closed) return;
364
+ this.#closed = true;
365
+ this.#options.onCancel();
366
+ }
367
+
368
+ async #togglePin(): Promise<void> {
369
+ const row = this.#selectedRow();
370
+ const directory = row?.entry.path ?? this.#current;
371
+ if (!directory) return;
372
+ try {
373
+ const pinned = await this.#source.togglePin(directory);
374
+ this.#statusText.setText(
375
+ theme.fg(
376
+ "dim",
377
+ pinned
378
+ ? tuiTextFmt("cdPickerPinnedFmt", "Pinned %s", directory)
379
+ : tuiTextFmt("cdPickerUnpinnedFmt", "Unpinned %s", directory),
380
+ ),
381
+ );
382
+ } catch (error) {
383
+ this.#statusText.setText(theme.fg("error", String(error instanceof Error ? error.message : error)));
384
+ }
385
+ this.#rebuild();
386
+ }
387
+ }