@linxiraos/pi-tui 1.3.2 → 1.4.0

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,8 +1,8 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [1.3.2] - 2026-10-19
3
+ ## [1.4.0] - 2026-10-21
4
4
 
5
- - Version line moves to 1.3.2 with the rest of the suite; no user-visible change in this package.
5
+ - Added a `zetawork` terminal id that resolves to the Kitty image protocol from the environment alone, so images render in the desktop app's own terminal
6
6
 
7
7
  ## [9.5.0] - 2026-02-01
8
8
 
@@ -187,6 +187,10 @@
187
187
 
188
188
  Initial release under @oh-my-pi scope. See previous releases at [badlogic/pi-mono](https://github.com/badlogic/pi-mono).
189
189
 
190
+ ## [1.3.2] - 2026-10-19
191
+
192
+ - Version line moves to 1.3.2 with the rest of the suite; no user-visible change in this package.
193
+
190
194
  ## [1.3.1] - 2026-10-19
191
195
 
192
196
  ### Breaking Changes
@@ -1,10 +1,13 @@
1
- import { type SessionSelectorEntry, type SessionHistoryMatcher } from "../overlays/session-selector.js";
1
+ import { type ResumeSourceLike, type SessionHistoryMatcher, type SessionSelectorEntry } from "../overlays/session-selector.js";
2
+ import type { ResumeTreeSource } from "../overlays/resume-tree.js";
2
3
  /** Persistence and history capabilities supplied by the session-owning host. */
3
4
  export interface SessionPickerHost<T extends SessionSelectorEntry = SessionSelectorEntry> {
4
5
  loadPinnedIds?(): Promise<ReadonlySet<string>>;
5
6
  loadHistoryMatcher?(): SessionHistoryMatcher;
6
7
  deleteSession?(session: T): Promise<boolean>;
7
8
  loadAllSessions?(): Promise<T[]>;
9
+ /** Builds the three-level resume source for the standalone `--resume` tree. */
10
+ loadResumeSource?(deleteMode: "trash" | "permanent", workspacePath?: string): Promise<ResumeTreeSource | undefined>;
8
11
  }
9
12
  /** Presentation and capability controls for the standalone session picker. */
10
13
  export interface SessionPickerOptions<T extends SessionSelectorEntry = SessionSelectorEntry> {
@@ -16,6 +19,15 @@ export interface SessionPickerOptions<T extends SessionSelectorEntry = SessionSe
16
19
  allowGlobalScope?: boolean;
17
20
  historySearch?: boolean;
18
21
  pinnedIds?: ReadonlySet<string>;
22
+ /** Opt into the three-level resume tree; `deleteMode` words the confirm step. */
23
+ resume?: {
24
+ deleteMode: "trash" | "permanent";
25
+ workspacePath?: string;
26
+ };
27
+ /** The host's resume model; when set, the native picker renders the project tree. */
28
+ resumeSource?: ResumeSourceLike;
29
+ /** Delete wording: in-session moves to trash, `--resume` deletes permanently. */
30
+ deleteMode?: "trash" | "permanent";
19
31
  }
20
32
  /**
21
33
  * Show the TUI session selector and return the selected session, or null if
@@ -0,0 +1,293 @@
1
+ /**
2
+ * Native (`picker`) mapping of the resume directory model.
3
+ *
4
+ * The coding-agent owns the data model (`ResumeDirectory` / `buildResumeView`:
5
+ * project → workspace → conversation). pi-tui cannot import it (dependency
6
+ * direction), so this module declares structurally compatible `*Like` types
7
+ * and accepts a {@link ResumeSourceLike} the host builds from its real
8
+ * directory and view builder (the ANSI tree passes the same object). Nothing
9
+ * here re-groups conversations: the rows come from the model, and this module
10
+ * only turns them into picker props.
11
+ */
12
+ import type { TspPickerGroup, TspPickerItem, TspPickerScope } from "@linxiraos/pi-wire";
13
+ import type { SessionSelectorStatus } from "./session-selector.js";
14
+ import type { NativeChild } from "../native/node.js";
15
+ export type ResumeScopeKindLike = "workspace" | "project" | "all";
16
+ export interface ResumeScopeLike {
17
+ readonly kind: ResumeScopeKindLike;
18
+ readonly key?: string;
19
+ readonly projectKey?: string;
20
+ readonly workspaceKey?: string;
21
+ }
22
+ export type ResumeScopeInputLike = ResumeScopeKindLike | ResumeScopeLike;
23
+ /** Parsed query, as far as the native renderer reads it (the ANSI tree passes a subset). */
24
+ export interface ResumeQueryLike {
25
+ readonly raw: string;
26
+ readonly terms?: readonly string[];
27
+ readonly project?: readonly string[];
28
+ readonly workspace?: readonly string[];
29
+ readonly branch?: readonly string[];
30
+ readonly status?: readonly string[];
31
+ readonly current?: boolean | null;
32
+ readonly fork?: boolean | null;
33
+ readonly pinned?: boolean | null;
34
+ }
35
+ /** The session fields the picker reads; the host's `SessionInfo` supplies all of them. */
36
+ export interface ResumeSessionLike {
37
+ readonly path: string;
38
+ readonly id: string;
39
+ readonly cwd: string;
40
+ readonly title?: string;
41
+ readonly modified: Date;
42
+ readonly size?: number;
43
+ readonly firstMessage?: string;
44
+ readonly allMessagesText?: string;
45
+ readonly status?: SessionSelectorStatus;
46
+ readonly parentSessionPath?: string;
47
+ readonly created?: Date;
48
+ readonly messageCount?: number;
49
+ readonly assistantTurns?: number;
50
+ /** Last model recorded in the session (`provider/modelId`), when one was persisted. */
51
+ readonly model?: string;
52
+ }
53
+ export interface ResumeConversationLike {
54
+ readonly session: ResumeSessionLike;
55
+ readonly key: string;
56
+ readonly id: string;
57
+ readonly path: string;
58
+ readonly title: string;
59
+ readonly cwd: string;
60
+ readonly projectKey: string;
61
+ readonly workspaceKey: string;
62
+ readonly created: Date;
63
+ readonly modified: Date;
64
+ readonly status?: SessionSelectorStatus;
65
+ readonly pinned: boolean;
66
+ readonly current: boolean;
67
+ readonly fork: boolean;
68
+ /** Subagent marker from `session_init.agent`; forks never set it. */
69
+ readonly isSubagent?: boolean;
70
+ readonly agentName?: string;
71
+ readonly parentKey?: string;
72
+ readonly subagents?: readonly ResumeConversationLike[];
73
+ readonly messageCount: number;
74
+ }
75
+ export interface ResumeWorkspaceLike {
76
+ readonly key: string;
77
+ readonly path: string;
78
+ readonly name: string;
79
+ readonly alias?: string | null;
80
+ readonly displayName?: string;
81
+ readonly projectKey: string;
82
+ readonly branch: string | null;
83
+ readonly isWorktree?: boolean;
84
+ readonly pinned: boolean;
85
+ readonly lastActivity: Date | null;
86
+ /** Flat conversation list; the core model keeps conversations on the directory only. */
87
+ readonly conversations?: readonly ResumeConversationLike[];
88
+ readonly counts: {
89
+ readonly conversations: number;
90
+ readonly pinnedConversations: number;
91
+ };
92
+ }
93
+ export interface ResumeProjectLike {
94
+ readonly key: string;
95
+ readonly root: string;
96
+ readonly name: string;
97
+ readonly alias: string | null;
98
+ readonly displayName: string;
99
+ readonly isDefault: boolean;
100
+ readonly pinned: boolean;
101
+ readonly removable?: boolean;
102
+ readonly collapsed: boolean;
103
+ readonly lastActivity: Date | null;
104
+ readonly workspaces?: readonly ResumeWorkspaceLike[];
105
+ readonly conversations?: readonly ResumeConversationLike[];
106
+ readonly counts: {
107
+ readonly conversations: number;
108
+ readonly workspaces: number;
109
+ readonly pinnedConversations: number;
110
+ };
111
+ }
112
+ export interface ResumeDirectoryLike {
113
+ readonly projects: readonly ResumeProjectLike[];
114
+ readonly workspaces: readonly ResumeWorkspaceLike[];
115
+ readonly conversations: readonly ResumeConversationLike[];
116
+ readonly defaultProjectKey: string;
117
+ readonly defaultWorkspaceKey: string;
118
+ readonly counts: {
119
+ readonly projects: number;
120
+ readonly workspaces: number;
121
+ readonly conversations: number;
122
+ readonly pinnedConversations: number;
123
+ };
124
+ }
125
+ export interface ResumeProjectRowLike {
126
+ readonly type: "project";
127
+ readonly key: string;
128
+ readonly project: ResumeProjectLike;
129
+ readonly depth?: 0;
130
+ readonly pinned: boolean;
131
+ readonly collapsed: boolean;
132
+ readonly conversationCount: number;
133
+ readonly totalConversationCount: number;
134
+ readonly workspaceCount: number;
135
+ readonly totalWorkspaceCount: number;
136
+ }
137
+ export interface ResumeWorkspaceRowLike {
138
+ readonly type: "workspace";
139
+ readonly key: string;
140
+ readonly workspace: ResumeWorkspaceLike;
141
+ readonly projectKey: string;
142
+ readonly depth?: 1;
143
+ readonly pinned: boolean;
144
+ readonly conversationCount: number;
145
+ readonly totalConversationCount: number;
146
+ }
147
+ export interface ResumeConversationRowLike {
148
+ readonly type: "conversation";
149
+ readonly key: string;
150
+ readonly conversation: ResumeConversationLike;
151
+ readonly projectKey: string;
152
+ readonly workspaceKey: string;
153
+ readonly depth?: number;
154
+ readonly pinned: boolean;
155
+ readonly current: boolean;
156
+ readonly score?: number;
157
+ readonly pinnedOnly?: boolean;
158
+ }
159
+ export type ResumeViewRowLike = ResumeProjectRowLike | ResumeWorkspaceRowLike | ResumeConversationRowLike;
160
+ export interface ResumeViewCountsLike {
161
+ readonly conversations: number;
162
+ readonly workspaces?: number;
163
+ readonly projects?: number;
164
+ readonly pinnedConversations?: number;
165
+ readonly totalConversations: number;
166
+ readonly totalWorkspaces?: number;
167
+ readonly totalProjects?: number;
168
+ }
169
+ export interface ResumeViewLike {
170
+ readonly scope: ResumeScopeLike;
171
+ readonly query: ResumeQueryLike;
172
+ readonly rows: readonly ResumeViewRowLike[];
173
+ /** Conversation rows; the ANSI tree leaves it out and read `rows` instead. */
174
+ readonly conversations?: readonly ResumeConversationRowLike[];
175
+ readonly counts: ResumeViewCountsLike;
176
+ readonly referenceBranch?: string | null;
177
+ readonly currentWorkspaceKey?: string;
178
+ }
179
+ export interface ResumeViewOptionsLike {
180
+ scope?: ResumeScopeInputLike;
181
+ query?: string;
182
+ currentSessionPath?: string;
183
+ }
184
+ /** Names and per-scope conversation totals for the segmented control. */
185
+ export interface ResumeScopeSummaryLike {
186
+ readonly workspaceName: string;
187
+ readonly projectName: string;
188
+ readonly counts: Readonly<Record<ResumeScopeKindLike, number>>;
189
+ }
190
+ /**
191
+ * The host's resume model: the loaded directory plus its pure view builder.
192
+ * Shared with the ANSI tree, which supplies the same object; `directory` is
193
+ * null until the first scan finishes, and `buildView` returns null then.
194
+ */
195
+ export interface ResumeSourceLike {
196
+ readonly directory: ResumeDirectoryLike | null;
197
+ readonly initialScope?: ResumeScopeKindLike;
198
+ readonly deleteMode?: "trash" | "permanent";
199
+ buildView(options: ResumeViewOptionsLike): ResumeViewLike | null;
200
+ scopeSummary?(): ResumeScopeSummaryLike;
201
+ persistScope?(scope: ResumeScopeKindLike): void | Promise<void>;
202
+ refresh?(): Promise<void>;
203
+ pinConversation?(conversation: ResumeConversationLike, pinned: boolean): void | Promise<void>;
204
+ deleteConversation?(conversation: ResumeConversationLike): boolean | Promise<boolean>;
205
+ isLoading?(): boolean;
206
+ loadError?(): string | undefined;
207
+ }
208
+ export declare const RESUME_SCOPE_ORDER: readonly ResumeScopeKindLike[];
209
+ /** The scope after `kind` in the three-way cycle (Tab). */
210
+ export declare function nextResumeScope(kind: ResumeScopeKindLike): ResumeScopeKindLike;
211
+ /** The segmented control's label for a scope kind. */
212
+ export declare function resumeScopeLabel(kind: ResumeScopeKindLike): string;
213
+ /**
214
+ * Per-scope conversation totals for the segmented control. The host summary
215
+ * wins when present (the ANSI tree already computes it); otherwise the active
216
+ * scope's own pre-query total is reused and the other scopes cost one
217
+ * empty-query view each, so the model's scope resolution (current session →
218
+ * default workspace) decides the group, not this module.
219
+ */
220
+ export declare function resumeScopeTabs(source: ResumeSourceLike, active: ResumeViewLike, currentSessionPath: string | undefined): TspPickerScope[];
221
+ /** Assistant turns the session persisted; older listings fall back to the message count. */
222
+ export declare function resumeTurnCount(conversation: ResumeConversationLike): number;
223
+ export interface ResumeItemOptions {
224
+ /** Show each conversation's working directory (multi-worktree scopes). */
225
+ readonly showCwd?: boolean;
226
+ readonly now?: number;
227
+ /** Branch of the current workspace; a repeated branch stays off the cards. */
228
+ readonly referenceBranch?: string | null;
229
+ }
230
+ /** One conversation card: the existing facts plus turns, branch and model. */
231
+ export declare function resumePickerItem(row: ResumeConversationRowLike, workspace: ResumeWorkspaceLike | undefined, options?: ResumeItemOptions): TspPickerItem;
232
+ /** Project and workspace section heads followed by their conversations, from the model's rows. */
233
+ export declare function resumePickerOrder(view: ResumeViewLike): (string | TspPickerGroup)[];
234
+ /** Free-text hit ranges for the displayed rows (structured tokens never highlight). */
235
+ export declare function resumePickerHits(view: ResumeViewLike, items: ReadonlyMap<string, TspPickerItem>): Record<string, readonly (readonly [number, number])[]> | undefined;
236
+ /** Catalogue items for every conversation in the target scope (identity stable while typing). */
237
+ export declare function resumePickerItems(catalogue: ResumeViewLike, directory: ResumeDirectoryLike, options?: ResumeItemOptions): {
238
+ items: TspPickerItem[];
239
+ byPath: Map<string, TspPickerItem>;
240
+ };
241
+ /** The selected conversation path: the caller's when still visible, else the first row. */
242
+ export declare function resumePickerSelection(view: ResumeViewLike, preferred: string | null | undefined): string | null;
243
+ /**
244
+ * The same view with locally deleted conversations (and the section heads
245
+ * left empty by them) removed. Deletes are host-driven; the directory is not
246
+ * rebuilt per keystroke, so the picker hides the removed rows itself.
247
+ */
248
+ export declare function resumeViewWithout(view: ResumeViewLike, hidden: ReadonlySet<string>): ResumeViewLike;
249
+ export interface ResumePickerModel {
250
+ readonly view: ResumeViewLike;
251
+ readonly catalogue: ResumeViewLike;
252
+ readonly items: readonly TspPickerItem[];
253
+ readonly order: readonly (string | TspPickerGroup)[];
254
+ readonly hits?: Readonly<Record<string, readonly (readonly [number, number])[]>>;
255
+ readonly tabs: readonly TspPickerScope[];
256
+ readonly selected: string | null;
257
+ readonly current: readonly string[];
258
+ readonly total: number;
259
+ /** Conversations the filter hides (the ANSI tree stays on screen while filtering). */
260
+ readonly hidden: number;
261
+ readonly empty: string;
262
+ readonly placeholder: string;
263
+ }
264
+ export interface ResumePickerModelOptions {
265
+ readonly scope: ResumeScopeInputLike;
266
+ readonly query: string;
267
+ readonly currentSessionPath?: string;
268
+ readonly hidden?: ReadonlySet<string>;
269
+ readonly showCwd?: boolean;
270
+ readonly now?: number;
271
+ /** Selection to keep when it survives the query; the first row otherwise. */
272
+ readonly preferredPath?: string | null;
273
+ }
274
+ /**
275
+ * Everything the native sheet needs for one scope + query: the model's
276
+ * filtered view (rows, counts, tokens), a stable catalogue built without the
277
+ * query, the picker items for it, section order, hits, scope tabs and copy.
278
+ */
279
+ export declare function buildResumePickerModel(source: ResumeSourceLike, options: ResumePickerModelOptions): ResumePickerModel | undefined;
280
+ /** True when the view carries any filter (free text or structured token). */
281
+ export declare function resumeQueryActive(view: ResumeViewLike): boolean;
282
+ /** The empty pane's copy: no matches while filtering, else the scope's own empty wording. */
283
+ export declare function resumeEmptyText(view: ResumeViewLike): string;
284
+ /** The search field's placeholder for the active scope (names come from the host summary). */
285
+ export declare function resumePlaceholder(source: ResumeSourceLike, scope: ResumeScopeInputLike): string;
286
+ /** The selected conversation's preview: project, workspace, branch, status, model, then the excerpt. */
287
+ export declare function resumeConversationPreview(conversation: ResumeConversationLike, project: ResumeProjectLike | undefined, workspace: ResumeWorkspaceLike | undefined): NativeChild[];
288
+ /** Project/workspace lookups for a conversation path, derived from the directory (no re-grouping). */
289
+ export declare function resumeConversationContext(directory: ResumeDirectoryLike, path: string): {
290
+ conversation: ResumeConversationLike;
291
+ project: ResumeProjectLike | undefined;
292
+ workspace: ResumeWorkspaceLike | undefined;
293
+ } | undefined;